import * as i0 from '@angular/core';
import { Component, inject, TemplateRef, ViewContainerRef, Directive, Input, NgModule } from '@angular/core';
import { NgTemplateOutlet } from '@angular/common';
import { TooltipDirective } from '@seniorsistemas/angular-components/tooltip';

class InfoSignComponent {
    templateRef = null;
    tooltip;
    displayTime;
    focusedInputRef = null;
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InfoSignComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: InfoSignComponent, isStandalone: true, selector: "s-info-sign-component", ngImport: i0, template: "<span class=\"info-sign\">\n    <span *ngTemplateOutlet=\"templateRef\"></span>\n    <i\n        class=\"info-sign__icon fa fa-info-circle\"\n        aria-hidden=\"true\"\n        [sTooltip]=\"tooltip\"\n        [escape]=\"false\"\n        [displayTime]=\"displayTime\"\n        mobileBehavior=\"tap\"\n        [showDelay]=\"0\"\n        [tooltipEvent]=\"focusedInputRef ? 'focus' : 'hover'\"\n        [focusedInputRef]=\"focusedInputRef\">\n    </i>\n</span>\n", styles: [".info-sign{align-items:baseline;display:inline-flex;justify-content:flex-start}.info-sign .info-sign__icon{padding:0 12px}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: TooltipDirective, selector: "[sTooltip]", inputs: ["sTooltip", "tooltipPosition", "showDelay", "displayTime", "tooltipEvent", "escape", "visible", "mobileBehavior", "focusedInputRef", "checkTruncatedText"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InfoSignComponent, decorators: [{
            type: Component,
            args: [{ selector: 's-info-sign-component', standalone: true, imports: [NgTemplateOutlet, TooltipDirective], template: "<span class=\"info-sign\">\n    <span *ngTemplateOutlet=\"templateRef\"></span>\n    <i\n        class=\"info-sign__icon fa fa-info-circle\"\n        aria-hidden=\"true\"\n        [sTooltip]=\"tooltip\"\n        [escape]=\"false\"\n        [displayTime]=\"displayTime\"\n        mobileBehavior=\"tap\"\n        [showDelay]=\"0\"\n        [tooltipEvent]=\"focusedInputRef ? 'focus' : 'hover'\"\n        [focusedInputRef]=\"focusedInputRef\">\n    </i>\n</span>\n", styles: [".info-sign{align-items:baseline;display:inline-flex;justify-content:flex-start}.info-sign .info-sign__icon{padding:0 12px}\n"] }]
        }] });

/**
 * @description Diretiva estrutural que exibe um ícone de informação ao lado do elemento hospedeiro.
 * Ao interagir com o ícone, um tooltip com a mensagem configurada é exibido temporariamente.
 * Suporta sincronização de posição com um campo de input referenciado.
 *
 * @example
 * ```html
 * <input *sInfoSign="'Informe seu CPF'; displayTime: 4000" type="text" />
 * ```
 *
 * @category Overlay
 */
class InfoSignDirective {
    templateRef = inject(TemplateRef);
    viewContainer = inject(ViewContainerRef);
    /**
     * @description Mensagem exibida no tooltip do ícone de informação. Campo obrigatório.
     */
    sInfoSign;
    /**
     * @description Tempo em milissegundos que o tooltip permanece visível após ser exibido.
     *
     * @default 5000
     */
    displayTime = 5000;
    /**
     * @description Referência a um elemento de input HTML para posicionamento relativo do info sign.
     * Utilizado quando `useFocusedInputRef` é `true`.
     */
    focusedInputRef = null;
    /**
     * @description Quando `true`, utiliza `focusedInputRef` para calcular o posicionamento do ícone.
     *
     * @default true
     */
    useFocusedInputRef = true;
    componentRef = null;
    ngOnChanges() {
        this.createInfoSign();
    }
    ngOnInit() {
        this.createInfoSign();
    }
    ngOnDestroy() {
        if (this.componentRef) {
            this.componentRef.destroy();
        }
    }
    createInfoSign() {
        if (!this.componentRef && this.sInfoSign) {
            this.viewContainer.clear();
            this.componentRef = this.viewContainer.createComponent(InfoSignComponent);
            const _infoSignComponent = this.componentRef.instance;
            _infoSignComponent.templateRef = this.templateRef;
            _infoSignComponent.tooltip = this.sInfoSign;
            _infoSignComponent.displayTime = this.displayTime;
            if (this.useFocusedInputRef && this.focusedInputRef) {
                _infoSignComponent.focusedInputRef = this.focusedInputRef;
            }
        }
        else if (this.componentRef && this.sInfoSign) {
            this.componentRef.instance.tooltip = this.sInfoSign;
        }
        else {
            this.viewContainer.clear();
            this.viewContainer.createEmbeddedView(this.templateRef);
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InfoSignDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
    static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: InfoSignDirective, isStandalone: true, selector: "[sInfoSign]", inputs: { sInfoSign: "sInfoSign", displayTime: ["sInfoSignDisplayTime", "displayTime"], focusedInputRef: ["sInfoSignFocusedInputRef", "focusedInputRef"], useFocusedInputRef: ["sInfoSignUseFocusedInputRef", "useFocusedInputRef"] }, usesOnChanges: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InfoSignDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[sInfoSign]',
                    standalone: true,
                }]
        }], propDecorators: { sInfoSign: [{
                type: Input,
                args: [{ required: true }]
            }], displayTime: [{
                type: Input,
                args: ['sInfoSignDisplayTime']
            }], focusedInputRef: [{
                type: Input,
                args: ['sInfoSignFocusedInputRef']
            }], useFocusedInputRef: [{
                type: Input,
                args: ['sInfoSignUseFocusedInputRef']
            }] } });

class InfoSignModule {
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InfoSignModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
    static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: InfoSignModule, imports: [InfoSignDirective], exports: [InfoSignDirective] });
    static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InfoSignModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InfoSignModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [InfoSignDirective],
                    exports: [InfoSignDirective],
                }]
        }] });

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

export { InfoSignDirective, InfoSignModule };
//# sourceMappingURL=seniorsistemas-angular-components-info-sign.mjs.map
