import { Component, Input } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/cdk/clipboard";
import * as i2 from "primeng/api";
import * as i3 from "@seniorsistemas/angular-components/chips";
import * as i4 from "@angular/forms";
import * as i5 from "@seniorsistemas/angular-components/tooltip";
import * as i6 from "../../../components/field-label/field-label.component";
import * as i7 from "@ngx-translate/core";
export class ChipsFieldComponent {
    clipboard;
    changeDetectorRef;
    elementRef;
    field;
    formControl;
    feedbackMessageVisible = false;
    copyButtonVisible = true;
    inputRef = null;
    constructor(clipboard, changeDetectorRef, elementRef) {
        this.clipboard = clipboard;
        this.changeDetectorRef = changeDetectorRef;
        this.elementRef = elementRef;
    }
    onCopyFieldContent() {
        if (this.formControl.value) {
            this.copyButtonVisible = false;
            this.feedbackMessageVisible = true;
            setTimeout(() => {
                this.feedbackMessageVisible = false;
                this.copyButtonVisible = true;
            }, 3000);
            const content = this.formControl.value.join(this.field.separator || '\n');
            this.clipboard.copy(content);
            if (this.field.onCopy) {
                this.field.onCopy(content);
            }
        }
    }
    ngAfterViewInit() {
        this.setInputRef();
        this.changeDetectorRef.detectChanges();
    }
    setInputRef() {
        this.inputRef = this.elementRef.nativeElement.querySelector('input');
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ChipsFieldComponent, deps: [{ token: i1.Clipboard }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ChipsFieldComponent, selector: "ng-component", inputs: { field: "field", formControl: "formControl" }, ngImport: i0, template: "@if (inputRef) {\n    <s-field-label\n        [field]=\"field\"\n        [fieldContainerRef]=\"inputRef\"\n    ></s-field-label>\n}\n\n<div class=\"chips-field-wrapper\">\n    <div style=\"width: 100%\">\n        @if (field.keyFilter) {\n            <s-chips\n                [inputId]=\"field.id || field.name\"\n                [formControl]=\"formControl\"\n                [placeholder]=\"field.placeholder\"\n                [allowDuplicated]=\"false\"\n                [addOnTab]=\"true\"\n                [addOnBlur]=\"true\"\n                (onAdd)=\"field.onAdd ? field.onAdd($event) : null\"\n                (onRemove)=\"field.onRemove ? field.onRemove($event) : null\"\n                (onChipClick)=\"field.onChipClick ? field.onChipClick($event) : null\"\n                (onFocus)=\"field.onFocus ? field.onFocus($event) : null\"\n                (onBlur)=\"field.onBlur ? field.onBlur($event) : null\"\n                [keyFilter]=\"field.keyFilter\"\n            >\n                <ng-template\n                    let-item\n                    pTemplate=\"item\"\n                >\n                    <span\n                        class=\"chip-content\"\n                        [sTooltip]=\"item\"\n                    >\n                        {{ item }}\n                    </span>\n                </ng-template>\n            </s-chips>\n        } @else {\n            <s-chips\n                [inputId]=\"field.id || field.name\"\n                [formControl]=\"formControl\"\n                [placeholder]=\"field.placeholder\"\n                [allowDuplicated]=\"false\"\n                [addOnTab]=\"true\"\n                [addOnBlur]=\"true\"\n                (onAdd)=\"field.onAdd ? field.onAdd($event) : null\"\n                (onRemove)=\"field.onRemove ? field.onRemove($event) : null\"\n                (onChipClick)=\"field.onChipClick ? field.onChipClick($event) : null\"\n                (onFocus)=\"field.onFocus ? field.onFocus($event) : null\"\n                (onBlur)=\"field.onBlur ? field.onBlur($event) : null\"\n            >\n                <ng-template\n                    let-item\n                    pTemplate=\"item\"\n                >\n                    <span\n                        class=\"chip-content\"\n                        [sTooltip]=\"item\"\n                    >\n                        {{ item }}\n                    </span>\n                </ng-template>\n            </s-chips>\n        }\n\n    </div>\n\n    @if(field.showCopyButton && formControl.value?.length > 0 && copyButtonVisible) {\n        <button\n            class=\"copy-content-button\"\n            (click)=\"onCopyFieldContent()\"\n        >\n            {{ 'platform.angular_components.copy_field_content' | translate }}\n        </button>\n    }\n\n    @if(feedbackMessageVisible) {\n        <span\n            class=\"feedback-message\"\n        >\n            {{ 'platform.angular_components.copied_to_clipboard' | translate }}\n        </span>\n    }\n</div>\n", styles: [".chips-field-wrapper{align-items:flex-start;display:flex;flex-direction:column}.chips-field-wrapper .chip-content{display:block;overflow:hidden;padding-right:1rem;text-overflow:ellipsis}.chips-field-wrapper .copy-content-button{background-color:transparent;border:none;color:#2a6496;cursor:pointer;margin-top:8px}.chips-field-wrapper .feedback-message{color:#0c9348;display:block;margin-top:8px;-webkit-user-select:none;user-select:none}\n"], dependencies: [{ kind: "directive", type: i2.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "component", type: i3.ChipsComponent, selector: "s-chips", inputs: ["disabled", "field", "value", "placeholder", "max", "maxLength", "inputId", "allowDuplicated", "caseSensitiveDuplication", "addOnTab", "addOnBlur", "separator", "autofocus", "infoLabel", "keyFilter", "showTooltip", "maxLengthRenderWithoutTooltip"], outputs: ["added", "removed", "focused", "focusLost", "chipClicked", "valueChange"] }, { kind: "directive", type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i5.TooltipDirective, selector: "[sTooltip]", inputs: ["sTooltip", "tooltipPosition", "showDelay", "displayTime", "tooltipEvent", "escape", "visible", "mobileBehavior", "focusedInputRef", "checkTruncatedText"] }, { kind: "component", type: i6.FieldLabelComponent, selector: "s-field-label", inputs: ["field", "fieldContainerRef"] }, { kind: "pipe", type: i7.TranslatePipe, name: "translate" }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ChipsFieldComponent, decorators: [{
            type: Component,
            args: [{ template: "@if (inputRef) {\n    <s-field-label\n        [field]=\"field\"\n        [fieldContainerRef]=\"inputRef\"\n    ></s-field-label>\n}\n\n<div class=\"chips-field-wrapper\">\n    <div style=\"width: 100%\">\n        @if (field.keyFilter) {\n            <s-chips\n                [inputId]=\"field.id || field.name\"\n                [formControl]=\"formControl\"\n                [placeholder]=\"field.placeholder\"\n                [allowDuplicated]=\"false\"\n                [addOnTab]=\"true\"\n                [addOnBlur]=\"true\"\n                (onAdd)=\"field.onAdd ? field.onAdd($event) : null\"\n                (onRemove)=\"field.onRemove ? field.onRemove($event) : null\"\n                (onChipClick)=\"field.onChipClick ? field.onChipClick($event) : null\"\n                (onFocus)=\"field.onFocus ? field.onFocus($event) : null\"\n                (onBlur)=\"field.onBlur ? field.onBlur($event) : null\"\n                [keyFilter]=\"field.keyFilter\"\n            >\n                <ng-template\n                    let-item\n                    pTemplate=\"item\"\n                >\n                    <span\n                        class=\"chip-content\"\n                        [sTooltip]=\"item\"\n                    >\n                        {{ item }}\n                    </span>\n                </ng-template>\n            </s-chips>\n        } @else {\n            <s-chips\n                [inputId]=\"field.id || field.name\"\n                [formControl]=\"formControl\"\n                [placeholder]=\"field.placeholder\"\n                [allowDuplicated]=\"false\"\n                [addOnTab]=\"true\"\n                [addOnBlur]=\"true\"\n                (onAdd)=\"field.onAdd ? field.onAdd($event) : null\"\n                (onRemove)=\"field.onRemove ? field.onRemove($event) : null\"\n                (onChipClick)=\"field.onChipClick ? field.onChipClick($event) : null\"\n                (onFocus)=\"field.onFocus ? field.onFocus($event) : null\"\n                (onBlur)=\"field.onBlur ? field.onBlur($event) : null\"\n            >\n                <ng-template\n                    let-item\n                    pTemplate=\"item\"\n                >\n                    <span\n                        class=\"chip-content\"\n                        [sTooltip]=\"item\"\n                    >\n                        {{ item }}\n                    </span>\n                </ng-template>\n            </s-chips>\n        }\n\n    </div>\n\n    @if(field.showCopyButton && formControl.value?.length > 0 && copyButtonVisible) {\n        <button\n            class=\"copy-content-button\"\n            (click)=\"onCopyFieldContent()\"\n        >\n            {{ 'platform.angular_components.copy_field_content' | translate }}\n        </button>\n    }\n\n    @if(feedbackMessageVisible) {\n        <span\n            class=\"feedback-message\"\n        >\n            {{ 'platform.angular_components.copied_to_clipboard' | translate }}\n        </span>\n    }\n</div>\n", styles: [".chips-field-wrapper{align-items:flex-start;display:flex;flex-direction:column}.chips-field-wrapper .chip-content{display:block;overflow:hidden;padding-right:1rem;text-overflow:ellipsis}.chips-field-wrapper .copy-content-button{background-color:transparent;border:none;color:#2a6496;cursor:pointer;margin-top:8px}.chips-field-wrapper .feedback-message{color:#0c9348;display:block;margin-top:8px;-webkit-user-select:none;user-select:none}\n"] }]
        }], ctorParameters: () => [{ type: i1.Clipboard }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }], propDecorators: { field: [{
                type: Input,
                args: [{ required: true }]
            }], formControl: [{
                type: Input,
                args: [{ required: true }]
            }] } });
//# sourceMappingURL=data:application/json;base64, 