import * as i0 from '@angular/core';
import { Component, ChangeDetectionStrategy, Inject, Input, NgModule } from '@angular/core';
import * as i3 from '@aztrix/helpers';
import { cardExpired, toDateFnsLocale, LOCALE, HelperPipesModule } from '@aztrix/helpers';
import { format } from 'date-fns';
import * as i4 from 'rxjs';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i2 from '@aztrix/icons';
import { IconsModule } from '@aztrix/icons';
import { ButtonModule } from '@aztrix/components/button';

class PaymentMethodComponent {
    constructor(_locale$) {
        this._locale$ = _locale$;
        this.selectMode = false;
    }
    cardExpired() {
        if (!this.paymentMethod.id) {
            return false;
        }
        return cardExpired(this.paymentMethod.card);
    }
    get expirationDateFromatted() {
        const date = new Date().setFullYear(this.paymentMethod.card?.exp_year ?? 0, (this.paymentMethod.card?.exp_month ?? 0) - 1);
        return format(date, 'MMMM yyyy', {
            locale: toDateFnsLocale(this._locale$.value),
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaymentMethodComponent, deps: [{ token: LOCALE }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: PaymentMethodComponent, selector: "ax-payment-method", inputs: { paymentMethod: "paymentMethod", selectMode: "selectMode" }, ngImport: i0, template: "<div class=\"method-wrapper\" [ngClass]=\"{selectmode: selectMode}\" *ngIf=\"paymentMethod?.id\">\n  <ax-icon class=\"icon card-icon\" [name]=\"'brands:' + paymentMethod.card?.brand\"></ax-icon>\n  <div>\n    <span class=\"fake-digits\">&#8226;&#8226;&#8226;&#8226;&nbsp;</span>\n    <span class=\"last-digits\">{{ paymentMethod.card?.last4 }}</span>\n  </div>\n  <div class=\"expired-label\" [ngClass]=\"{'is-expired': cardExpired()}\">\n    {{ 'label.expires' | translate }} {{ expirationDateFromatted }}\n  </div>\n</div>\n\n<div class=\"method-wrapper\" [ngClass]=\"{selectmode: selectMode}\" *ngIf=\"!paymentMethod?.id\">\n  <ax-icon class=\"icon\" [name]=\"'plus'\"></ax-icon>\n  <span class=\"last-digits\">{{ 'label.new' | translate }}</span>\n</div>\n", styles: [".method-wrapper{display:flex;flex-wrap:nowrap;align-items:center;justify-content:flex-start;padding:.75rem;background-color:#efefef;border-radius:10px;gap:.5rem}.method-wrapper.selectmode{padding:0 .75rem 0 0;background-color:transparent}.icon{width:32px}.card-icon{height:24px;background-color:#fff;border:1px solid #d7dde4;border-radius:2px;padding:1px}.fake-digits{font-size:.75rem;line-height:1rem;letter-spacing:.75px;vertical-align:middle}.expired-label{font-size:.75rem;margin-left:auto}.expired-label.is-expired{color:var(--warn-color-500)}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IconComponent, selector: "ax-icon", inputs: ["name", "inline"] }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaymentMethodComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-payment-method', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"method-wrapper\" [ngClass]=\"{selectmode: selectMode}\" *ngIf=\"paymentMethod?.id\">\n  <ax-icon class=\"icon card-icon\" [name]=\"'brands:' + paymentMethod.card?.brand\"></ax-icon>\n  <div>\n    <span class=\"fake-digits\">&#8226;&#8226;&#8226;&#8226;&nbsp;</span>\n    <span class=\"last-digits\">{{ paymentMethod.card?.last4 }}</span>\n  </div>\n  <div class=\"expired-label\" [ngClass]=\"{'is-expired': cardExpired()}\">\n    {{ 'label.expires' | translate }} {{ expirationDateFromatted }}\n  </div>\n</div>\n\n<div class=\"method-wrapper\" [ngClass]=\"{selectmode: selectMode}\" *ngIf=\"!paymentMethod?.id\">\n  <ax-icon class=\"icon\" [name]=\"'plus'\"></ax-icon>\n  <span class=\"last-digits\">{{ 'label.new' | translate }}</span>\n</div>\n", styles: [".method-wrapper{display:flex;flex-wrap:nowrap;align-items:center;justify-content:flex-start;padding:.75rem;background-color:#efefef;border-radius:10px;gap:.5rem}.method-wrapper.selectmode{padding:0 .75rem 0 0;background-color:transparent}.icon{width:32px}.card-icon{height:24px;background-color:#fff;border:1px solid #d7dde4;border-radius:2px;padding:1px}.fake-digits{font-size:.75rem;line-height:1rem;letter-spacing:.75px;vertical-align:middle}.expired-label{font-size:.75rem;margin-left:auto}.expired-label.is-expired{color:var(--warn-color-500)}\n"] }]
        }], ctorParameters: () => [{ type: i4.BehaviorSubject, decorators: [{
                    type: Inject,
                    args: [LOCALE]
                }] }], propDecorators: { paymentMethod: [{
                type: Input
            }], selectMode: [{
                type: Input
            }] } });

class PaymentMethodModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaymentMethodModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: PaymentMethodModule, declarations: [PaymentMethodComponent], imports: [CommonModule, HelperPipesModule, IconsModule, ButtonModule], exports: [PaymentMethodComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaymentMethodModule, imports: [CommonModule, HelperPipesModule, IconsModule, ButtonModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaymentMethodModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [PaymentMethodComponent],
                    imports: [CommonModule, HelperPipesModule, IconsModule, ButtonModule],
                    exports: [PaymentMethodComponent],
                }]
        }] });

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

export { PaymentMethodComponent, PaymentMethodModule };
//# sourceMappingURL=aztrix-components-payment-method.mjs.map
