import * as i0 from '@angular/core';
import { EventEmitter, ContentChild, ViewChild, Output, Input, Inject, Optional, ChangeDetectionStrategy, Component } from '@angular/core';
import * as i3 from '@angular/forms';
import { NgForm, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
import * as uuid from 'uuid';
import * as i2 from '@angular/common';
import { CommonModule } from '@angular/common';
import { MatButtonModule } from '@angular/material/button';
import * as i4 from '@angular/material/form-field';
import { MatFormFieldModule } from '@angular/material/form-field';
import * as i6 from '@angular/material/icon';
import { MatIconModule } from '@angular/material/icon';
import * as i5 from '@angular/material/input';
import { MatInputModule } from '@angular/material/input';
import * as i7 from '@angular/material/tooltip';
import { MatTooltipModule } from '@angular/material/tooltip';
import { SdViewDefDirective, SdSuffixDefDirective, SdLabelDefDirective } from '@sd-angular/core/forms/directives';
import { SdFormControl, HandleSdCustomValidator, SD_FORM_CONFIGURATION } from '@sd-angular/core/forms/models';
import { NumberUtilities } from '@sd-angular/core/utilities/extensions';
import { Subscription } from 'rxjs';
import * as i1 from '@sd-angular/core/pipes';
import { SdEmptyPipe, SdFormatNumberPipe } from '@sd-angular/core/pipes';
import { SD_CORE_CONFIGURATION } from '@sd-angular/core/configurations';
import { SdLabel } from '@sd-angular/core/forms/label';

/* eslint-disable @angular-eslint/component-class-suffix */
/* eslint-disable @angular-eslint/no-input-rename */
/* eslint-disable @typescript-eslint/no-explicit-any */
class SdInputNumberErrotStateMatcher {
    formControl;
    constructor(formControl) {
        this.formControl = formControl;
    }
    isErrorState(control, form) {
        const isSubmitted = form && form.submitted;
        return !!(this.formControl?.invalid && (this.formControl?.dirty || this.formControl?.touched || isSubmitted));
    }
}
class SdInputNumber {
    ref;
    coreConfiguration;
    formatNumberPipe;
    formConfig;
    id = `I${uuid.v4()}`;
    autoId;
    set _autoId(val) {
        if (!val) {
            return;
        }
        this.autoId = `forms-input-number-${val}`;
    }
    #name = uuid.v4();
    set name(val) {
        if (val) {
            this.#name = val;
        }
    }
    size = 'md';
    #form;
    set form(val) {
        if (val) {
            if (val instanceof NgForm) {
                this.#form = val.form;
            }
            else {
                this.#form = val;
            }
        }
    }
    label;
    set _label(val) {
        this.label = val;
    }
    helperText;
    set _helperText(val) {
        this.helperText = val;
    }
    placeholder;
    hideInlineError = false;
    set _hideInlineError(val) {
        this.hideInlineError = val === '' || val;
    }
    #blurOnEnter = false;
    set _blurOnEnter(val) {
        this.#blurOnEnter = val === '' || val;
    }
    #model;
    set model(value) {
        if (this.#model !== value) {
            this.#model = value;
            this.formControl.setValue(this.#model, {
                emitEvent: false,
            });
            if (value || value === 0) {
                const val = value.toString().replace(/\./g, this.#decimalSeparator);
                this.inputControl.setValue(this.#getValueWithFormat(val), {
                    emitEvent: false,
                });
            }
            else {
                this.inputControl.setValue('', {
                    emitEvent: false,
                });
            }
        }
    }
    modelChange = new EventEmitter();
    // Validator
    required = false;
    set _required(val) {
        this.required = val === '' || !!val;
        this.#updateValidator();
    }
    type; //negative: chỉ nhập số âm, positive: chỉ số dương
    precision = 3; //số chữ số thập phân
    readonly = false;
    set _readonly(val) {
        this.readonly = val === '' || val;
    }
    min;
    set _min(val) {
        this.min = val ?? undefined;
        this.#updateValidator();
    }
    max;
    set _max(val) {
        this.max = val ?? undefined;
        this.#updateValidator();
    }
    #validator;
    set validator(validator) {
        this.#validator = validator;
        this.#updateValidator();
    }
    inlineError;
    set _inlineError(val) {
        this.inlineError = val;
        this.#updateValidator();
    }
    set disabled(val) {
        val = val === '' || val;
        if (val) {
            this.inputControl.disable();
            this.formControl.disable();
        }
        else {
            this.inputControl.enable();
            this.formControl.enable();
        }
    }
    viewed = false;
    set _viewed(val) {
        this.viewed = val === '' || !!val;
    }
    hyperlink;
    appearance = 'outline';
    sdChange = new EventEmitter();
    sdFocus = new EventEmitter();
    sdBlur = new EventEmitter();
    sdFocusForceBlur = new EventEmitter();
    keyupEnter = new EventEmitter();
    control;
    formControl = new SdFormControl();
    inputControl = new SdFormControl();
    #subscription = new Subscription();
    matcher = new SdInputNumberErrotStateMatcher(this.formControl);
    #preCompositionValue;
    sdViewDef;
    sdSuffixDef;
    sdLabelDef;
    isFocused = false;
    constructor(ref, coreConfiguration, formatNumberPipe, formConfig) {
        this.ref = ref;
        this.coreConfiguration = coreConfiguration;
        this.formatNumberPipe = formatNumberPipe;
        this.formConfig = formConfig;
    }
    ngOnInit() {
        this.appearance = this.appearance || this.formConfig?.appearance;
        this.#subscription.add(this.inputControl.touchChanges.subscribe(() => {
            this.formControl.markAsTouched();
            this.ref.markForCheck();
        }));
        this.#subscription.add(this.formControl.sdChanges.subscribe(() => {
            this.ref.markForCheck();
        }));
        this.#subscription.add(this.inputControl.sdChanges.subscribe(() => {
            this.ref.markForCheck();
        }));
    }
    get #decimalSeparator() {
        if (this.coreConfiguration?.format?.number === '1.234.567,89') {
            return ',';
        }
        return '.';
    }
    get #thousandsSeparator() {
        if (this.coreConfiguration?.format?.number === '1.234.567,89') {
            return '.';
        }
        return ',';
    }
    get #regex() {
        const decimal = this.#decimalSeparator;
        const thousand = this.#thousandsSeparator;
        const escDecimal = decimal === '.' ? '\\.' : decimal;
        const escThousand = thousand === '.' ? '\\.' : thousand;
        // Phần nguyên: có thể có hoặc không có phân cách hàng nghìn
        const integerPart = `(([0-9]+(${escThousand}[0-9])?)+)`; //`([0-9]{1,3}(${escThousand}[0-9]{3})*|[0-9]+)`;
        // Phần thập phân: có hoặc không, tùy theo precision
        const decimalPart = this.precision > 0 ? `(${escDecimal}[0-9]{0,${this.precision}})?` : '';
        let result = `${integerPart}${decimalPart}$`;
        if (this.type === 'negative') {
            result = `[-]${integerPart}${decimalPart}$`;
        }
        else if (!this.type) {
            result = `[-]?${integerPart}${decimalPart}$`;
        }
        return result;
    }
    ngAfterViewInit() {
        this.#subscription.add(this.inputControl.valueChanges.subscribe(() => {
            const val = this.inputControl.value;
            if (!val) {
                this.#onChange(undefined);
                return;
            }
            const value = this.#toNumber(val);
            if (!isNaN(value)) {
                this.inputControl.setValue(this.#getValueWithFormat(val), {
                    emitEvent: false,
                });
                this.#onChange(value);
            }
        }));
        this.#form?.addControl(this.#name, this.formControl);
        this.ref.detectChanges();
    }
    #getValueWithFormat = (value) => {
        const arrayNext = value.split(this.#decimalSeparator);
        if (arrayNext.length >= 2) {
            return `${this.#formatNumber(arrayNext[0])}${this.#decimalSeparator}${arrayNext[1]}`;
        }
        return this.#formatNumber(value);
    };
    #formatNumber = (text) => {
        if (this.coreConfiguration?.format?.number === '1.234.567,89') {
            return NumberUtilities.toVN((text?.toString() || '').replace(/\./g, ''));
        }
        else {
            return NumberUtilities.toISO((text?.toString() || '').replace(/\,/g, ''));
        }
    };
    #toNumber = (text) => {
        const raw = text?.toString() || '';
        const value = raw
            .split(this.#thousandsSeparator)
            .join('') // Xóa dấu phân cách phần nghìn
            .replace(this.#decimalSeparator, '.'); // Chuyển dấu phân cách thập phân về dấu .
        return +value;
    };
    ngOnDestroy() {
        this.#form?.removeControl(this.#name);
        this.#subscription.unsubscribe();
    }
    reValidate = () => {
        this.formControl.updateValueAndValidity();
    };
    #updateValidator = () => {
        this.formControl.clearValidators();
        this.formControl.clearAsyncValidators();
        const validators = [];
        const asyncValidators = [];
        if (this.required) {
            validators.push(Validators.required);
        }
        if (this.min || this.min === 0) {
            validators.push(Validators.min(this.min));
        }
        if (this.max || this.max === 0) {
            validators.push(Validators.max(this.max));
        }
        if (this.#validator) {
            asyncValidators.push(HandleSdCustomValidator(this.#validator));
        }
        if (this.inlineError) {
            validators.push(this.customInlineErrorValidator());
        }
        this.formControl.setValidators(validators);
        this.formControl.setAsyncValidators(asyncValidators);
        this.formControl.updateValueAndValidity();
    };
    // Hàm tạo Validators tùy chỉnh cho inlineError
    customInlineErrorValidator() {
        return () => {
            return { inlineError: true };
        };
    }
    #onChange = (value) => {
        this.#model = value ?? null;
        this.modelChange.emit(this.#model);
        this.sdChange.emit(this.#model);
        this.formControl.setValue(this.#model);
    };
    onKeyupEnter = () => {
        const val = (this.inputControl.value ?? '').toString();
        if (val.length > val.trim().length) {
            this.inputControl.setValue(val.trim());
        }
        this.keyupEnter.emit(this.inputControl.value);
        if (this.#blurOnEnter) {
            this.blur();
        }
    };
    onKeydown = (event) => {
        if (event.ctrlKey && event.key == 'v') {
            this.#checkValue(event, '');
            return;
        }
        const key = event.keyCode || event.charCode;
        if (key == 8 || key == 46 || key == 37 || key == 39 || key == 35 || key == 36 || key == 9) {
            return;
        }
        if (event.ctrlKey && (event.key == 'c' || event.key == 'x' || event.key == 'a')) {
            return;
        }
        if (event.shiftKey && key == 9) {
            return;
        }
        this.#checkValue(event, event.key);
    };
    onPaste(event) {
        const nextKey = event?.clipboardData?.getData('text');
        this.#checkValue(event, nextKey);
    }
    onCompositionEnd(event) {
        const compositionValue = event.data;
        const regExp = new RegExp(`^${this.#regex}`, 'g');
        if (compositionValue && !String(compositionValue).match(regExp)) {
            this.inputControl.setValue(this.#preCompositionValue || '');
        }
        this.#preCompositionValue = undefined;
    }
    onCompositionStart(event) {
        this.#preCompositionValue = this.inputControl.value;
    }
    #checkValue = (event, nextKey) => {
        const current = event?.target?.value;
        // if(this.maxNumber === +current.toString().replace(/\./g, '').replace(/,/g, '.')){
        //   event.preventDefault();
        //   return;
        // }
        const curval_arr = current.split('');
        curval_arr.splice(event.target.selectionStart, event.target.selectionEnd - event.target.selectionStart, nextKey || '');
        const newval = curval_arr.join('');
        if (this.type !== 'positive' && newval === '-') {
            return;
        }
        const regExp = new RegExp(`^${this.#regex}`, 'g');
        if (newval && !String(newval).match(regExp)) {
            event.preventDefault();
            return;
        }
        // const value = (newval.toString().replace(/\./g, '').replace(/,/g, '.'));
        // if ((this.maxNumber || this.maxNumber === 0) && +value > this.maxNumber) {
        //   setTimeout(() => {
        //     this.inputControl.setValue(this.#getValueWithFormat(this.maxNumber.toString().replace(/\./g, ',')));
        //   }, 10);
        //   event.preventDefault();
        // }
    };
    onFocus = () => {
        this.isFocused = true;
        this.sdFocus.emit();
        if (this.sdFocusForceBlur.observers?.length > 0) {
            this.blur();
            this.sdFocusForceBlur.emit();
        }
    };
    onBlur = () => {
        this.isFocused = false;
        const val = (this.inputControl.value ?? '').toString();
        // If value is empty, set to empty string and emit to model
        if (!val || val.trim() === '') {
            this.inputControl.setValue('', { emitEvent: false });
            this.#onChange(null);
            this.sdBlur.emit(null);
            return;
        }
        const arrayValue = val.split(this.#decimalSeparator);
        if (arrayValue.length >= 2 && arrayValue[1] == '') {
            this.inputControl.setValue(this.#formatNumber(arrayValue[0]));
            return;
        }
        if (val.length > val.trim().length) {
            this.inputControl.setValue(val.trim());
        }
        this.sdBlur.emit(this.formControl.value);
    };
    onClick = () => {
        if (this.sdViewDef?.templateRef) {
            if (!this.formControl.disabled && !this.isFocused) {
                this.focus();
            }
        }
    };
    blur = () => {
        this.isFocused = false;
        this.control?.nativeElement?.blur();
    };
    focus = () => {
        this.isFocused = true;
        setTimeout(() => {
            this.control?.nativeElement?.focus();
        }, 100);
    };
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdInputNumber, deps: [{ token: i0.ChangeDetectorRef }, { token: SD_CORE_CONFIGURATION, optional: true }, { token: i1.SdFormatNumberPipe }, { token: SD_FORM_CONFIGURATION, optional: true }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.17", type: SdInputNumber, isStandalone: true, selector: "sd-input-number", inputs: { _autoId: ["autoId", "_autoId"], name: "name", size: "size", form: "form", _label: ["label", "_label"], _helperText: ["helperText", "_helperText"], placeholder: "placeholder", _hideInlineError: ["hideInlineError", "_hideInlineError"], _blurOnEnter: ["blurOnEnter", "_blurOnEnter"], model: "model", _required: ["required", "_required"], type: "type", precision: "precision", _readonly: ["readonly", "_readonly"], _min: ["min", "_min"], _max: ["max", "_max"], validator: "validator", _inlineError: ["inlineError", "_inlineError"], disabled: "disabled", _viewed: ["viewed", "_viewed"], hyperlink: "hyperlink", appearance: "appearance" }, outputs: { modelChange: "modelChange", sdChange: "sdChange", sdFocus: "sdFocus", sdBlur: "sdBlur", sdFocusForceBlur: "sdFocusForceBlur", keyupEnter: "keyupEnter" }, queries: [{ propertyName: "sdViewDef", first: true, predicate: SdViewDefDirective, descendants: true }, { propertyName: "sdSuffixDef", first: true, predicate: SdSuffixDefDirective, descendants: true }, { propertyName: "sdLabelDef", first: true, predicate: SdLabelDefDirective, descendants: true }], viewQueries: [{ propertyName: "control", first: true, predicate: ["control"], descendants: true }], ngImport: i0, template: "@if (viewed) {\r\n  @if (sdLabelDef?.templateRef) {\r\n    <ng-container *ngTemplateOutlet=\"sdLabelDef!.templateRef\"> </ng-container>\r\n  } @else if (label) {\r\n    <div class=\"T14R text-black400\">{{ label }}</div>\r\n  }\r\n  @if (hyperlink) {\r\n    <!-- N\u1EBFu c\u00F3 hyperlink th\u00EC d\u00F9ng th\u1EBB a -->\r\n    <a [href]=\"hyperlink\">{{ formControl.value }}</a>\r\n  } @else {\r\n    <!-- Ngo\u00E0i ra d\u00F9ng th\u1EBB m\u1EB7c \u0111\u1ECBnh -->\r\n    <div class=\"T14M\">{{ formControl.value | sdFormatNumber | sdEmpty }}</div>\r\n  }\r\n} @else {\r\n  @if (!appearance && sdLabelDef?.templateRef) {\r\n    <ng-container *ngTemplateOutlet=\"sdLabelDef!.templateRef\"> </ng-container>\r\n  }\r\n  @if (!appearance && label && !sdLabelDef?.templateRef) {\r\n    <sd-label [label]=\"label\" [required]=\"required\"></sd-label>\r\n  }\r\n  <div\r\n    class=\"d-flex align-items-center\"\r\n    [class.sd-view]=\"!!sdViewDef?.templateRef\"\r\n    [class.c-focused]=\"isFocused\"\r\n    [class.c-disabled]=\"formControl.disabled\"\r\n    (click)=\"onClick()\"\r\n    aria-hidden=\"true\">\r\n    @if (sdViewDef?.templateRef && !isFocused) {\r\n      <ng-container\r\n        *ngTemplateOutlet=\"\r\n          sdViewDef!.templateRef;\r\n          context: {\r\n            value: formControl.value\r\n          }\r\n        \">\r\n      </ng-container>\r\n    } @else {\r\n      <mat-form-field\r\n        [class.sd-md]=\"size === 'md'\"\r\n        [class.sd-sm]=\"size === 'sm'\"\r\n        [class.hide-inline-error]=\"hideInlineError\"\r\n        [appearance]=\"appearance\">\r\n        @if (appearance && label) {\r\n          <mat-label style=\"display: inline-block\">\r\n            <div style=\"display: flex; align-items: center; gap: 4px\">\r\n              <span>{{ label }}</span>\r\n              @if (helperText) {\r\n                <mat-icon [matTooltip]=\"helperText\" matTooltipPosition=\"below\">info_outline</mat-icon>\r\n              }\r\n            </div>\r\n          </mat-label>\r\n        }\r\n        <input\r\n          aria-hidden=\"true\"\r\n          [id]=\"id\"\r\n          [formControl]=\"inputControl\"\r\n          #control\r\n          matInput\r\n          [placeholder]=\"placeholder || label || ''\"\r\n          [errorStateMatcher]=\"matcher\"\r\n          (keyup.enter)=\"onKeyupEnter()\"\r\n          (focus)=\"onFocus()\"\r\n          (blur)=\"onBlur()\"\r\n          (keydown)=\"onKeydown($event)\"\r\n          (compositionstart)=\"onCompositionStart($event)\"\r\n          (compositionend)=\"onCompositionEnd($event)\"\r\n          [required]=\"required\"\r\n          [readonly]=\"readonly\"\r\n          [autocomplete]=\"id\"\r\n          (paste)=\"onPaste($event)\"\r\n          autocorrect=\"off\"\r\n          [attr.data-autoId]=\"autoId\" />\r\n        @if (sdSuffixDef?.templateRef) {\r\n          <ng-container matSuffix>\r\n            <ng-container [ngTemplateOutlet]=\"sdSuffixDef?.templateRef ?? null\"></ng-container>\r\n          </ng-container>\r\n        }\r\n\r\n        @if (formControl.errors?.['required']) {\r\n          <mat-error>\r\n            @if (!hideInlineError) {\r\n              {{ 'Vui l\u00F2ng nh\u1EADp th\u00F4ng tin' }}\r\n            }\r\n          </mat-error>\r\n        }\r\n\r\n        @if (formControl.errors?.['min']) {\r\n          <mat-error>\r\n            @if (!hideInlineError) {\r\n              {{ 'Gi\u00E1 tr\u1ECB kh\u00F4ng \u0111\u01B0\u1EE3c nh\u1ECF h\u01A1n ' }} <strong>{{ min }}</strong>\r\n            }\r\n          </mat-error>\r\n        }\r\n\r\n        @if (formControl.errors?.['max']) {\r\n          <mat-error>\r\n            @if (!hideInlineError) {\r\n              {{ 'Gi\u00E1 tr\u1ECB kh\u00F4ng \u0111\u01B0\u1EE3c l\u1EDBn h\u01A1n ' }} <strong>{{ max }}</strong>\r\n            }\r\n          </mat-error>\r\n        }\r\n\r\n        @if (formControl.errors?.['customValidator']) {\r\n          <mat-error>\r\n            @if (!hideInlineError) {\r\n              {{ formControl.errors?.['customValidator'] }}\r\n            }\r\n          </mat-error>\r\n        }\r\n\r\n        @if (formControl.errors?.['inlineError']) {\r\n          <mat-error>\r\n            @if (!hideInlineError) {\r\n              {{ inlineError }}\r\n            }\r\n          </mat-error>\r\n        }\r\n      </mat-form-field>\r\n    }\r\n  </div>\r\n  <!-- <sd-popover #error=\"sdPopover\" type=\"danger\" width=\"300px\">\r\n  <span *ngIf=\"formControl.errors?.required\">\r\n    {{ \"Vui l\u00F2ng nh\u1EADp th\u00F4ng tin\" | sdTranslate }}\r\n  </span>\r\n  <span *ngIf=\"formControl.errors?.customValidator\">\r\n    {{formControl.errors?.customValidator}}\r\n  </span>\r\n</sd-popover> -->\r\n}\r\n", styles: [".text-primary{color:var(--sd-primary)!important}.bg-primary{background:var(--sd-primary)!important}.border-primary{border-color:var(--sd-primary)!important}.text-primary-light{color:var(--sd-primary-light)!important}.bg-primary-light{background:var(--sd-primary-light)!important}.border-primary-light{border-color:var(--sd-primary-light)!important}.text-primary-dark{color:var(--sd-primary-dark)!important}.bg-primary-dark{background:var(--sd-primary-dark)!important}.border-primary-dark{border-color:var(--sd-primary-dark)!important}.text-info{color:var(--sd-info)!important}.bg-info{background:var(--sd-info)!important}.border-info{border-color:var(--sd-info)!important}.text-info-light{color:var(--sd-info-light)!important}.bg-info-light{background:var(--sd-info-light)!important}.border-info-light{border-color:var(--sd-info-light)!important}.text-info-dark{color:var(--sd-info-dark)!important}.bg-info-dark{background:var(--sd-info-dark)!important}.border-info-dark{border-color:var(--sd-info-dark)!important}.text-success{color:var(--sd-success)!important}.bg-success{background:var(--sd-success)!important}.border-success{border-color:var(--sd-success)!important}.text-success-light{color:var(--sd-success-light)!important}.bg-success-light{background:var(--sd-success-light)!important}.border-success-light{border-color:var(--sd-success-light)!important}.text-success-dark{color:var(--sd-success-dark)!important}.bg-success-dark{background:var(--sd-success-dark)!important}.border-success-dark{border-color:var(--sd-success-dark)!important}.text-warning{color:var(--sd-warning)!important}.bg-warning{background:var(--sd-warning)!important}.border-warning{border-color:var(--sd-warning)!important}.text-warning-light{color:var(--sd-warning-light)!important}.bg-warning-light{background:var(--sd-warning-light)!important}.border-warning-light{border-color:var(--sd-warning-light)!important}.text-warning-dark{color:var(--sd-warning-dark)!important}.bg-warning-dark{background:var(--sd-warning-dark)!important}.border-warning-dark{border-color:var(--sd-warning-dark)!important}.text-error{color:var(--sd-error)!important}.bg-error{background:var(--sd-error)!important}.border-error{border-color:var(--sd-error)!important}.text-error-light{color:var(--sd-error-light)!important}.bg-error-light{background:var(--sd-error-light)!important}.border-error-light{border-color:var(--sd-error-light)!important}.text-error-dark{color:var(--sd-error-dark)!important}.bg-error-dark{background:var(--sd-error-dark)!important}.border-error-dark{border-color:var(--sd-error-dark)!important}.text-secondary{color:var(--sd-secondary)!important}.bg-secondary{background:var(--sd-secondary)!important}.border-secondary{border-color:var(--sd-secondary)!important}.text-secondary-light{color:var(--sd-secondary-light)!important}.bg-secondary-light{background:var(--sd-secondary-light)!important}.border-secondary-light{border-color:var(--sd-secondary-light)!important}.text-secondary-dark{color:var(--sd-secondary-dark)!important}.bg-secondary-dark{background:var(--sd-secondary-dark)!important}.border-secondary-dark{border-color:var(--sd-secondary-dark)!important}.text-light{color:var(--sd-light)!important}.bg-light{background:var(--sd-light)!important}.border-light{border-color:var(--sd-light)!important}.text-dark{color:var(--sd-dark)!important}.bg-dark{background:var(--sd-dark)!important}.border-dark{border-color:var(--sd-dark)!important}.text-black500{color:var(--sd-black500)!important}.bg-black500{background:var(--sd-black500)!important}.border-black500{border-color:var(--sd-black500)!important}.text-black400{color:var(--sd-black400)!important}.bg-black400{background:var(--sd-black400)!important}.border-black400{border-color:var(--sd-black400)!important}.text-black300{color:var(--sd-black300)!important}.bg-black300{background:var(--sd-black300)!important}.border-black300{border-color:var(--sd-black300)!important}.text-black200{color:var(--sd-black200)!important}.bg-black200{background:var(--sd-black200)!important}.border-black200{border-color:var(--sd-black200)!important}.text-black100{color:var(--sd-black100)!important}.bg-black100{background:var(--sd-black100)!important}.border-black100{border-color:var(--sd-black100)!important}.text-white{color:#fff!important}.bg-white{background:#fff!important}.border-white{border-color:#fff!important}.text-black{color:#000!important}.bg-black{background:#000!important}.border-black{border-color:#000!important}:host ::ng-deep .mat-mdc-form-field.sd-form-tooltip{width:calc(100% - 30px)}:host ::ng-deep .mat-mdc-form-field.mat-form-field-appearance-outline.mat-form-field-disabled .mat-mdc-text-field-wrapper{background:var(--sd-black100)}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field .mat-mdc-placeholder-required{color:var(--sd-error)}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}.sd-tooltip{display:inline-block;text-align:center;margin:auto;width:30px}:host{padding-top:5px;display:block}.sd-md:hover .btn-copy{visibility:visible}.btn-copy{visibility:hidden;background:#e9e9e9!important;line-height:26px!important;margin-bottom:3px;font-size:12px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4.MatLabel, selector: "mat-label" }, { kind: "directive", type: i4.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i4.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i5.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl],      input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i7.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: SdLabel, selector: "sd-label", inputs: ["label", "description", "required", "helperText"] }, { kind: "pipe", type: SdEmptyPipe, name: "sdEmpty" }, { kind: "pipe", type: SdFormatNumberPipe, name: "sdFormatNumber" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: SdInputNumber, decorators: [{
            type: Component,
            args: [{ selector: 'sd-input-number', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [
                        CommonModule,
                        FormsModule,
                        ReactiveFormsModule,
                        MatFormFieldModule,
                        MatInputModule,
                        MatIconModule,
                        MatTooltipModule,
                        MatButtonModule,
                        SdLabel,
                        SdEmptyPipe,
                        SdFormatNumberPipe
                    ], template: "@if (viewed) {\r\n  @if (sdLabelDef?.templateRef) {\r\n    <ng-container *ngTemplateOutlet=\"sdLabelDef!.templateRef\"> </ng-container>\r\n  } @else if (label) {\r\n    <div class=\"T14R text-black400\">{{ label }}</div>\r\n  }\r\n  @if (hyperlink) {\r\n    <!-- N\u1EBFu c\u00F3 hyperlink th\u00EC d\u00F9ng th\u1EBB a -->\r\n    <a [href]=\"hyperlink\">{{ formControl.value }}</a>\r\n  } @else {\r\n    <!-- Ngo\u00E0i ra d\u00F9ng th\u1EBB m\u1EB7c \u0111\u1ECBnh -->\r\n    <div class=\"T14M\">{{ formControl.value | sdFormatNumber | sdEmpty }}</div>\r\n  }\r\n} @else {\r\n  @if (!appearance && sdLabelDef?.templateRef) {\r\n    <ng-container *ngTemplateOutlet=\"sdLabelDef!.templateRef\"> </ng-container>\r\n  }\r\n  @if (!appearance && label && !sdLabelDef?.templateRef) {\r\n    <sd-label [label]=\"label\" [required]=\"required\"></sd-label>\r\n  }\r\n  <div\r\n    class=\"d-flex align-items-center\"\r\n    [class.sd-view]=\"!!sdViewDef?.templateRef\"\r\n    [class.c-focused]=\"isFocused\"\r\n    [class.c-disabled]=\"formControl.disabled\"\r\n    (click)=\"onClick()\"\r\n    aria-hidden=\"true\">\r\n    @if (sdViewDef?.templateRef && !isFocused) {\r\n      <ng-container\r\n        *ngTemplateOutlet=\"\r\n          sdViewDef!.templateRef;\r\n          context: {\r\n            value: formControl.value\r\n          }\r\n        \">\r\n      </ng-container>\r\n    } @else {\r\n      <mat-form-field\r\n        [class.sd-md]=\"size === 'md'\"\r\n        [class.sd-sm]=\"size === 'sm'\"\r\n        [class.hide-inline-error]=\"hideInlineError\"\r\n        [appearance]=\"appearance\">\r\n        @if (appearance && label) {\r\n          <mat-label style=\"display: inline-block\">\r\n            <div style=\"display: flex; align-items: center; gap: 4px\">\r\n              <span>{{ label }}</span>\r\n              @if (helperText) {\r\n                <mat-icon [matTooltip]=\"helperText\" matTooltipPosition=\"below\">info_outline</mat-icon>\r\n              }\r\n            </div>\r\n          </mat-label>\r\n        }\r\n        <input\r\n          aria-hidden=\"true\"\r\n          [id]=\"id\"\r\n          [formControl]=\"inputControl\"\r\n          #control\r\n          matInput\r\n          [placeholder]=\"placeholder || label || ''\"\r\n          [errorStateMatcher]=\"matcher\"\r\n          (keyup.enter)=\"onKeyupEnter()\"\r\n          (focus)=\"onFocus()\"\r\n          (blur)=\"onBlur()\"\r\n          (keydown)=\"onKeydown($event)\"\r\n          (compositionstart)=\"onCompositionStart($event)\"\r\n          (compositionend)=\"onCompositionEnd($event)\"\r\n          [required]=\"required\"\r\n          [readonly]=\"readonly\"\r\n          [autocomplete]=\"id\"\r\n          (paste)=\"onPaste($event)\"\r\n          autocorrect=\"off\"\r\n          [attr.data-autoId]=\"autoId\" />\r\n        @if (sdSuffixDef?.templateRef) {\r\n          <ng-container matSuffix>\r\n            <ng-container [ngTemplateOutlet]=\"sdSuffixDef?.templateRef ?? null\"></ng-container>\r\n          </ng-container>\r\n        }\r\n\r\n        @if (formControl.errors?.['required']) {\r\n          <mat-error>\r\n            @if (!hideInlineError) {\r\n              {{ 'Vui l\u00F2ng nh\u1EADp th\u00F4ng tin' }}\r\n            }\r\n          </mat-error>\r\n        }\r\n\r\n        @if (formControl.errors?.['min']) {\r\n          <mat-error>\r\n            @if (!hideInlineError) {\r\n              {{ 'Gi\u00E1 tr\u1ECB kh\u00F4ng \u0111\u01B0\u1EE3c nh\u1ECF h\u01A1n ' }} <strong>{{ min }}</strong>\r\n            }\r\n          </mat-error>\r\n        }\r\n\r\n        @if (formControl.errors?.['max']) {\r\n          <mat-error>\r\n            @if (!hideInlineError) {\r\n              {{ 'Gi\u00E1 tr\u1ECB kh\u00F4ng \u0111\u01B0\u1EE3c l\u1EDBn h\u01A1n ' }} <strong>{{ max }}</strong>\r\n            }\r\n          </mat-error>\r\n        }\r\n\r\n        @if (formControl.errors?.['customValidator']) {\r\n          <mat-error>\r\n            @if (!hideInlineError) {\r\n              {{ formControl.errors?.['customValidator'] }}\r\n            }\r\n          </mat-error>\r\n        }\r\n\r\n        @if (formControl.errors?.['inlineError']) {\r\n          <mat-error>\r\n            @if (!hideInlineError) {\r\n              {{ inlineError }}\r\n            }\r\n          </mat-error>\r\n        }\r\n      </mat-form-field>\r\n    }\r\n  </div>\r\n  <!-- <sd-popover #error=\"sdPopover\" type=\"danger\" width=\"300px\">\r\n  <span *ngIf=\"formControl.errors?.required\">\r\n    {{ \"Vui l\u00F2ng nh\u1EADp th\u00F4ng tin\" | sdTranslate }}\r\n  </span>\r\n  <span *ngIf=\"formControl.errors?.customValidator\">\r\n    {{formControl.errors?.customValidator}}\r\n  </span>\r\n</sd-popover> -->\r\n}\r\n", styles: [".text-primary{color:var(--sd-primary)!important}.bg-primary{background:var(--sd-primary)!important}.border-primary{border-color:var(--sd-primary)!important}.text-primary-light{color:var(--sd-primary-light)!important}.bg-primary-light{background:var(--sd-primary-light)!important}.border-primary-light{border-color:var(--sd-primary-light)!important}.text-primary-dark{color:var(--sd-primary-dark)!important}.bg-primary-dark{background:var(--sd-primary-dark)!important}.border-primary-dark{border-color:var(--sd-primary-dark)!important}.text-info{color:var(--sd-info)!important}.bg-info{background:var(--sd-info)!important}.border-info{border-color:var(--sd-info)!important}.text-info-light{color:var(--sd-info-light)!important}.bg-info-light{background:var(--sd-info-light)!important}.border-info-light{border-color:var(--sd-info-light)!important}.text-info-dark{color:var(--sd-info-dark)!important}.bg-info-dark{background:var(--sd-info-dark)!important}.border-info-dark{border-color:var(--sd-info-dark)!important}.text-success{color:var(--sd-success)!important}.bg-success{background:var(--sd-success)!important}.border-success{border-color:var(--sd-success)!important}.text-success-light{color:var(--sd-success-light)!important}.bg-success-light{background:var(--sd-success-light)!important}.border-success-light{border-color:var(--sd-success-light)!important}.text-success-dark{color:var(--sd-success-dark)!important}.bg-success-dark{background:var(--sd-success-dark)!important}.border-success-dark{border-color:var(--sd-success-dark)!important}.text-warning{color:var(--sd-warning)!important}.bg-warning{background:var(--sd-warning)!important}.border-warning{border-color:var(--sd-warning)!important}.text-warning-light{color:var(--sd-warning-light)!important}.bg-warning-light{background:var(--sd-warning-light)!important}.border-warning-light{border-color:var(--sd-warning-light)!important}.text-warning-dark{color:var(--sd-warning-dark)!important}.bg-warning-dark{background:var(--sd-warning-dark)!important}.border-warning-dark{border-color:var(--sd-warning-dark)!important}.text-error{color:var(--sd-error)!important}.bg-error{background:var(--sd-error)!important}.border-error{border-color:var(--sd-error)!important}.text-error-light{color:var(--sd-error-light)!important}.bg-error-light{background:var(--sd-error-light)!important}.border-error-light{border-color:var(--sd-error-light)!important}.text-error-dark{color:var(--sd-error-dark)!important}.bg-error-dark{background:var(--sd-error-dark)!important}.border-error-dark{border-color:var(--sd-error-dark)!important}.text-secondary{color:var(--sd-secondary)!important}.bg-secondary{background:var(--sd-secondary)!important}.border-secondary{border-color:var(--sd-secondary)!important}.text-secondary-light{color:var(--sd-secondary-light)!important}.bg-secondary-light{background:var(--sd-secondary-light)!important}.border-secondary-light{border-color:var(--sd-secondary-light)!important}.text-secondary-dark{color:var(--sd-secondary-dark)!important}.bg-secondary-dark{background:var(--sd-secondary-dark)!important}.border-secondary-dark{border-color:var(--sd-secondary-dark)!important}.text-light{color:var(--sd-light)!important}.bg-light{background:var(--sd-light)!important}.border-light{border-color:var(--sd-light)!important}.text-dark{color:var(--sd-dark)!important}.bg-dark{background:var(--sd-dark)!important}.border-dark{border-color:var(--sd-dark)!important}.text-black500{color:var(--sd-black500)!important}.bg-black500{background:var(--sd-black500)!important}.border-black500{border-color:var(--sd-black500)!important}.text-black400{color:var(--sd-black400)!important}.bg-black400{background:var(--sd-black400)!important}.border-black400{border-color:var(--sd-black400)!important}.text-black300{color:var(--sd-black300)!important}.bg-black300{background:var(--sd-black300)!important}.border-black300{border-color:var(--sd-black300)!important}.text-black200{color:var(--sd-black200)!important}.bg-black200{background:var(--sd-black200)!important}.border-black200{border-color:var(--sd-black200)!important}.text-black100{color:var(--sd-black100)!important}.bg-black100{background:var(--sd-black100)!important}.border-black100{border-color:var(--sd-black100)!important}.text-white{color:#fff!important}.bg-white{background:#fff!important}.border-white{border-color:#fff!important}.text-black{color:#000!important}.bg-black{background:#000!important}.border-black{border-color:#000!important}:host ::ng-deep .mat-mdc-form-field.sd-form-tooltip{width:calc(100% - 30px)}:host ::ng-deep .mat-mdc-form-field.mat-form-field-appearance-outline.mat-form-field-disabled .mat-mdc-text-field-wrapper{background:var(--sd-black100)}:host ::ng-deep .mat-mdc-form-field input.mat-mdc-input-element:disabled{color:var(--sd-black400)!important}:host ::ng-deep .mat-mdc-form-field .mat-mdc-placeholder-required{color:var(--sd-error)}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}.sd-tooltip{display:inline-block;text-align:center;margin:auto;width:30px}:host{padding-top:5px;display:block}.sd-md:hover .btn-copy{visibility:visible}.btn-copy{visibility:hidden;background:#e9e9e9!important;line-height:26px!important;margin-bottom:3px;font-size:12px}\n"] }]
        }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [SD_CORE_CONFIGURATION]
                }, {
                    type: Optional
                }] }, { type: i1.SdFormatNumberPipe }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [SD_FORM_CONFIGURATION]
                }, {
                    type: Optional
                }] }], propDecorators: { _autoId: [{
                type: Input,
                args: ['autoId']
            }], name: [{
                type: Input
            }], size: [{
                type: Input
            }], form: [{
                type: Input
            }], _label: [{
                type: Input,
                args: ['label']
            }], _helperText: [{
                type: Input,
                args: ['helperText']
            }], placeholder: [{
                type: Input
            }], _hideInlineError: [{
                type: Input,
                args: ['hideInlineError']
            }], _blurOnEnter: [{
                type: Input,
                args: ['blurOnEnter']
            }], model: [{
                type: Input
            }], modelChange: [{
                type: Output
            }], _required: [{
                type: Input,
                args: ['required']
            }], type: [{
                type: Input
            }], precision: [{
                type: Input
            }], _readonly: [{
                type: Input,
                args: ['readonly']
            }], _min: [{
                type: Input,
                args: ['min']
            }], _max: [{
                type: Input,
                args: ['max']
            }], validator: [{
                type: Input
            }], _inlineError: [{
                type: Input,
                args: ['inlineError']
            }], disabled: [{
                type: Input
            }], _viewed: [{
                type: Input,
                args: ['viewed']
            }], hyperlink: [{
                type: Input
            }], appearance: [{
                type: Input
            }], sdChange: [{
                type: Output
            }], sdFocus: [{
                type: Output
            }], sdBlur: [{
                type: Output
            }], sdFocusForceBlur: [{
                type: Output
            }], keyupEnter: [{
                type: Output
            }], control: [{
                type: ViewChild,
                args: ['control']
            }], sdViewDef: [{
                type: ContentChild,
                args: [SdViewDefDirective]
            }], sdSuffixDef: [{
                type: ContentChild,
                args: [SdSuffixDefDirective]
            }], sdLabelDef: [{
                type: ContentChild,
                args: [SdLabelDefDirective]
            }] } });

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

export { SdInputNumber };
//# sourceMappingURL=sd-angular-core-forms-input-number.mjs.map
