import { Component, forwardRef, ViewEncapsulation } from '@angular/core';
import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatTooltipModule } from '@angular/material/tooltip';
import { OMatErrorDirective } from '../../../directives/o-mat-error.directive';
import { OIntegerPipe } from '../../../pipes/o-integer.pipe';
import { ORealPipe } from '../../../pipes/o-real.pipe';
import { OTranslatePipe } from '../../../pipes/o-translate.pipe';
import { CurrencyUtil } from '../../../util/currencyUtil';
import { ORealInputComponent } from '../real-input/o-real-input.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@angular/material/form-field";
import * as i3 from "@angular/material/input";
import * as i4 from "@angular/material/button";
import * as i5 from "@angular/material/icon";
import * as i6 from "@angular/material/tooltip";
export const DEFAULT_INPUTS_O_CURRENCY_INPUT = [
    'currencySymbol: currency-symbol',
    'currencySymbolPosition: currency-symbol-position'
];
export class OCurrencyInputComponent extends ORealInputComponent {
    constructor() {
        super(...arguments);
        this.currency_icons = new Map([
            ['EUR', 'euro_symbol'],
            ['USD', 'attach_money'],
            ['GBP', 'currency_pound'],
            ['ILS', 'currency_ils'],
            ['INR', 'currency_rupee'],
            ['JPY', 'currency_yen'],
            ['KRW', 'currency_krw'],
            ['BTC', 'currency_bitcoin']
        ]);
        this.currency_symbols = CurrencyUtil.currencyCodeToSymbol;
        this.currencySymbol = 'EUR';
        this.currencySymbolPosition = 'right';
    }
    existsOntimizeIcon() {
        return this.currency_icons.has(this.currencySymbol);
    }
    useIcon(position) {
        return this.existsOntimizeIcon() && this.currencySymbolPosition === position;
    }
    useSymbol(position) {
        return !this.existsOntimizeIcon() && this.currency_symbols.hasOwnProperty(this.currencySymbol) && this.currencySymbolPosition === position;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OCurrencyInputComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: OCurrencyInputComponent, isStandalone: true, selector: "o-currency-input", inputs: { currencySymbol: ["currency-symbol", "currencySymbol"], currencySymbolPosition: ["currency-symbol-position", "currencySymbolPosition"] }, providers: [ORealPipe, { provide: OIntegerPipe, useExisting: ORealPipe }, { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => OCurrencyInputComponent), multi: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"currency-container\" [formGroup]=\"getFormGroup()\" [matTooltip]=\"tooltip\" [matTooltipClass]=\"tooltipClass\" [matTooltipPosition]=\"tooltipPosition\"\n  [matTooltipShowDelay]=\"tooltipShowDelay\" [matTooltipHideDelay]=\"tooltipHideDelay\" class=\"o-flex-row o-layout-align-sb-center\">\n\n  @if (useSymbol('left')) {\n    <div matSuffix class=\"icon-btn\" [class.mat-disabled]=\"!enabled\">\n      {{ currency_symbols[currencySymbol] }}\n    </div>\n  }\n  @if (useIcon('left')) {\n    <mat-icon matIconSuffix [class.mat-disabled]=\"!enabled\">{{currency_icons.get(this.currencySymbol)}}\n    </mat-icon>\n  }\n  <mat-form-field [appearance]=\"appearance\" [floatLabel]=\"floatLabel\" [hideRequiredMarker]=\"hideRequiredMarker\" [class.custom-width]=\"hasCustomWidth\"\n    class=\"icon-field o-flex-fill\" [subscriptSizing]=\"subscriptSizing\">\n    @if (labelVisible) {\n      <mat-label>{{ olabel | oTranslate }}</mat-label>\n    }\n    <input matInput [type]=\"inputType\" [id]=\"getAttribute()\" [formControlName]=\"getAttribute()\" [placeholder]=\"placeHolder\"\n      (focus)=\"innerOnFocus($event)\" (blur)=\"innerOnBlur($event)\" [readonly]=\"isReadOnly\" [min]=\"min\" [max]=\"max\" [step]=\"step\"\n      [required]=\"isRequired\" (change)=\"onChangeEvent($event)\">\n\n      @if (showClearButton) {\n        <button type=\"button\" matSuffix mat-icon-button (click)=\"onClickClearValue($event)\">\n          <mat-icon>close</mat-icon>\n        </button>\n      }\n      @if (useSymbol('right')) {\n        <div matIconSuffix class=\"icon-btn\" [class.mat-disabled]=\"!enabled\">\n          {{ currency_symbols[currencySymbol] }}\n        </div>\n      }\n      @if (useIcon('right')) {\n        <mat-icon  matIconSuffix  [class.mat-disabled]=\"!enabled\">{{currency_icons.get(this.currencySymbol)}}\n        </mat-icon>\n      }\n\n      <mat-error *oMatError=\"hasError('required')\">\n        {{ 'FORM_VALIDATION.REQUIRED' | oTranslate }}\n      </mat-error>\n      <mat-error *oMatError=\"hasError('min')\">\n        {{ 'FORM_VALIDATION.MIN_VALUE' | oTranslate }}: {{ getErrorValue('min', 'min') }}\n      </mat-error>\n      <mat-error *oMatError=\"hasError('max')\">\n        {{ 'FORM_VALIDATION.MAX_VALUE' | oTranslate }}: {{ getErrorValue('max', 'max') }}\n      </mat-error>\n      <mat-error *oMatError=\"hasError('minDecimaldigits')\">\n        {{ 'FORM_VALIDATION.MIN_DECIMAL_DIGITS' | oTranslate }}: {{ getErrorValue('minDecimaldigits', 'requiredMinDecimaldigits') }}\n      </mat-error>\n      <mat-error *oMatError=\"hasError('maxDecimaldigits')\">\n        {{ 'FORM_VALIDATION.MAX_DECIMAL_DIGITS' | oTranslate }}: {{ getErrorValue('maxDecimaldigits', 'requiredMaxDecimaldigits') }}\n      </mat-error>\n      @for (oError of getActiveOErrors(); track oError) {\n        <mat-error>\n          {{ oError.text | oTranslate }}\n        </mat-error>\n      }\n    </mat-form-field>\n  </div>\n", styles: [".currency-container .icon-btn{font-weight:700;font-size:20px;margin-right:4px}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.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: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i2.MatLabel, selector: "mat-label" }, { kind: "directive", type: i2.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i2.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i3.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl],      input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i4.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i6.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "directive", type: OMatErrorDirective, selector: "[oMatError]", inputs: ["oMatError"] }, { kind: "pipe", type: OTranslatePipe, name: "oTranslate" }], encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OCurrencyInputComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [ReactiveFormsModule, MatFormFieldModule, MatInputModule, MatButtonModule, MatIconModule, MatTooltipModule, OMatErrorDirective, OTranslatePipe], selector: 'o-currency-input', inputs: DEFAULT_INPUTS_O_CURRENCY_INPUT, encapsulation: ViewEncapsulation.None, providers: [ORealPipe, { provide: OIntegerPipe, useExisting: ORealPipe }, { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => OCurrencyInputComponent), multi: true }], template: "<div class=\"currency-container\" [formGroup]=\"getFormGroup()\" [matTooltip]=\"tooltip\" [matTooltipClass]=\"tooltipClass\" [matTooltipPosition]=\"tooltipPosition\"\n  [matTooltipShowDelay]=\"tooltipShowDelay\" [matTooltipHideDelay]=\"tooltipHideDelay\" class=\"o-flex-row o-layout-align-sb-center\">\n\n  @if (useSymbol('left')) {\n    <div matSuffix class=\"icon-btn\" [class.mat-disabled]=\"!enabled\">\n      {{ currency_symbols[currencySymbol] }}\n    </div>\n  }\n  @if (useIcon('left')) {\n    <mat-icon matIconSuffix [class.mat-disabled]=\"!enabled\">{{currency_icons.get(this.currencySymbol)}}\n    </mat-icon>\n  }\n  <mat-form-field [appearance]=\"appearance\" [floatLabel]=\"floatLabel\" [hideRequiredMarker]=\"hideRequiredMarker\" [class.custom-width]=\"hasCustomWidth\"\n    class=\"icon-field o-flex-fill\" [subscriptSizing]=\"subscriptSizing\">\n    @if (labelVisible) {\n      <mat-label>{{ olabel | oTranslate }}</mat-label>\n    }\n    <input matInput [type]=\"inputType\" [id]=\"getAttribute()\" [formControlName]=\"getAttribute()\" [placeholder]=\"placeHolder\"\n      (focus)=\"innerOnFocus($event)\" (blur)=\"innerOnBlur($event)\" [readonly]=\"isReadOnly\" [min]=\"min\" [max]=\"max\" [step]=\"step\"\n      [required]=\"isRequired\" (change)=\"onChangeEvent($event)\">\n\n      @if (showClearButton) {\n        <button type=\"button\" matSuffix mat-icon-button (click)=\"onClickClearValue($event)\">\n          <mat-icon>close</mat-icon>\n        </button>\n      }\n      @if (useSymbol('right')) {\n        <div matIconSuffix class=\"icon-btn\" [class.mat-disabled]=\"!enabled\">\n          {{ currency_symbols[currencySymbol] }}\n        </div>\n      }\n      @if (useIcon('right')) {\n        <mat-icon  matIconSuffix  [class.mat-disabled]=\"!enabled\">{{currency_icons.get(this.currencySymbol)}}\n        </mat-icon>\n      }\n\n      <mat-error *oMatError=\"hasError('required')\">\n        {{ 'FORM_VALIDATION.REQUIRED' | oTranslate }}\n      </mat-error>\n      <mat-error *oMatError=\"hasError('min')\">\n        {{ 'FORM_VALIDATION.MIN_VALUE' | oTranslate }}: {{ getErrorValue('min', 'min') }}\n      </mat-error>\n      <mat-error *oMatError=\"hasError('max')\">\n        {{ 'FORM_VALIDATION.MAX_VALUE' | oTranslate }}: {{ getErrorValue('max', 'max') }}\n      </mat-error>\n      <mat-error *oMatError=\"hasError('minDecimaldigits')\">\n        {{ 'FORM_VALIDATION.MIN_DECIMAL_DIGITS' | oTranslate }}: {{ getErrorValue('minDecimaldigits', 'requiredMinDecimaldigits') }}\n      </mat-error>\n      <mat-error *oMatError=\"hasError('maxDecimaldigits')\">\n        {{ 'FORM_VALIDATION.MAX_DECIMAL_DIGITS' | oTranslate }}: {{ getErrorValue('maxDecimaldigits', 'requiredMaxDecimaldigits') }}\n      </mat-error>\n      @for (oError of getActiveOErrors(); track oError) {\n        <mat-error>\n          {{ oError.text | oTranslate }}\n        </mat-error>\n      }\n    </mat-form-field>\n  </div>\n", styles: [".currency-container .icon-btn{font-weight:700;font-size:20px;margin-right:4px}\n"] }]
        }] });
//# sourceMappingURL=data:application/json;base64, 