import * as i0 from '@angular/core';
import { Pipe, inject } from '@angular/core';
import { LanguageEnum, CurrencyEnum, LocalStorageKeysEnum } from '@testlocallibrary/shared-kernel/models/enums';
import * as i1 from '@testlocallibrary/shared-kernel/services/language';
import * as i1$1 from '@testlocallibrary/shared-kernel/services/local-storage';
import { LocalStorageService } from '@testlocallibrary/shared-kernel/services/local-storage';
import * as i1$2 from '@angular/platform-browser';
import { AppsUrlLinksConst } from '@testlocallibrary/shared-kernel/models/constants';

class PriceFormatPipe {
    constructor(languageService) {
        this.languageService = languageService;
    }
    transform(price, currency = '') {
        let language = this.languageService.getLanguage();
        let productPrice = '';
        if (price % 1 !== 0) {
            // Format with decimals and a thousand separators
            productPrice = price?.toLocaleString('en-US', {
                minimumFractionDigits: 0,
                maximumFractionDigits: 2,
            });
        }
        else {
            // Format as whole number with a thousand separators
            productPrice = Math.round(price)?.toLocaleString('en-US');
        }
        if (currency != '') {
            language == LanguageEnum.Ar
                ? currency.trim().toUpperCase() == CurrencyEnum.egp.toUpperCase()
                    ? (productPrice = productPrice + ' ج.م')
                    : (productPrice = productPrice + ' $')
                : productPrice = productPrice + ' ' + currency.toUpperCase();
        }
        return productPrice;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PriceFormatPipe, deps: [{ token: i1.LanguageService }], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: PriceFormatPipe, isStandalone: true, name: "priceformat" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PriceFormatPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'priceformat',
                    standalone: true,
                }]
        }], ctorParameters: function () { return [{ type: i1.LanguageService }]; } });

class ProductPricePeriodByCurrency {
    constructor(localStorageService) {
        this.localStorageService = localStorageService;
    }
    transform(product, months, period = 'annually', isMonthly = false) {
        const LANGUAGES = this.localStorageService.getFromLocalStorage(LocalStorageKeysEnum.Language) || 'en';
        const CURRENCY_FORMAT = (price) => {
            return new Intl.NumberFormat(`en-eg`, {
                maximumFractionDigits: 2,
            }).format(price);
        };
        //* EGP_PRICE and USD_PRICE are the prices of the product in EGP and USD respectively
        const EGP_PRICE = product?.pricing?.egp[period] ? Number(product.pricing.egp[period]) : 0;
        const USD_PRICE = product?.pricing?.usd[period] ? Number(product.pricing.usd[period]) : 0;
        const EGP_PRICE_MONTHLY = product?.pricing?.egp[period] ? Number(product.pricing.egp[period]) / months : 0;
        const USD_PRICE_MONTHLY = product?.pricing?.usd[period] ? Number(product.pricing.usd[period]) / months : 0;
        const CURRENCY_LOCAL_STORAGE = this.localStorageService.getFromLocalStorage(LocalStorageKeysEnum.Currency);
        const CURRENCY = LANGUAGES == 'en' ? (CURRENCY_LOCAL_STORAGE === CurrencyEnum.egp || CURRENCY_LOCAL_STORAGE == null) ? 'EGP' : 'USD'
            : CURRENCY_LOCAL_STORAGE === CurrencyEnum.egp ? 'ج.م' : '$';
        let price = CURRENCY === 'EGP' || CURRENCY === 'ج.م' ?
            CURRENCY_FORMAT(isMonthly ? EGP_PRICE_MONTHLY : EGP_PRICE) :
            CURRENCY_FORMAT(isMonthly ? USD_PRICE_MONTHLY : USD_PRICE);
        return price + ' ' + CURRENCY;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ProductPricePeriodByCurrency, deps: [{ token: i1$1.LocalStorageService }], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: ProductPricePeriodByCurrency, isStandalone: true, name: "productPricePeriodByCurrency", pure: false }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ProductPricePeriodByCurrency, decorators: [{
            type: Pipe,
            args: [{
                    name: 'productPricePeriodByCurrency',
                    standalone: true,
                    pure: false,
                }]
        }], ctorParameters: function () { return [{ type: i1$1.LocalStorageService }]; } });

class EnglishArabicPriceByLanguagePipe {
    constructor() {
        this._localStorage = inject(LocalStorageService);
    }
    transform(PRICE = 0) {
        const LANGUAGES = this._localStorage.getFromLocalStorage(LocalStorageKeysEnum.Language) || 'en';
        const currency = this._localStorage.getFromLocalStorage(LocalStorageKeysEnum.Currency) ?? CurrencyEnum.egp;
        const CURRENCY_FORMAT = (price) => {
            return new Intl.NumberFormat(`${LANGUAGES}-eg`, {
                style: 'currency',
                currency: currency.toUpperCase(),
                maximumFractionDigits: 0,
            }).format(price);
        };
        if (PRICE)
            return CURRENCY_FORMAT(+PRICE);
        else
            return '';
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EnglishArabicPriceByLanguagePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: EnglishArabicPriceByLanguagePipe, isStandalone: true, name: "englishArabicPriceByLanguage", pure: false }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EnglishArabicPriceByLanguagePipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'englishArabicPriceByLanguage',
                    standalone: true,
                    pure: false,
                }]
        }], ctorParameters: function () { return []; } });

class EnglishArabicNumbersPipe {
    constructor(localStorageService) {
        this.localStorageService = localStorageService;
    }
    transform(NUMBER = 0) {
        const LANGUAGES = this.localStorageService.getFromLocalStorage(LocalStorageKeysEnum.Language) || 'en';
        const NUMBER_FORMAT = (num) => {
            return new Intl.NumberFormat(`${LANGUAGES}-eg`).format(num);
        };
        if (NUMBER)
            return NUMBER_FORMAT(+NUMBER);
        else
            return '';
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EnglishArabicNumbersPipe, deps: [{ token: i1$1.LocalStorageService }], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: EnglishArabicNumbersPipe, isStandalone: true, name: "englishArabicNumbers", pure: false }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EnglishArabicNumbersPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'englishArabicNumbers',
                    standalone: true,
                    pure: false,
                }]
        }], ctorParameters: function () { return [{ type: i1$1.LocalStorageService }]; } });

class DiscountPercentagePipe {
    transform(priceBeforeDiscount, priceAfterDiscount) {
        let discountPercentage = Math.round((priceBeforeDiscount - priceAfterDiscount) / priceBeforeDiscount * 100);
        return discountPercentage;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DiscountPercentagePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: DiscountPercentagePipe, isStandalone: true, name: "discountPercentage" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DiscountPercentagePipe, decorators: [{
            type: Pipe,
            args: [{
                    name: "discountPercentage",
                    standalone: true,
                }]
        }] });

class PricePerMonthPipe {
    transform(price, duration) {
        return Number(price) / duration;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PricePerMonthPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: PricePerMonthPipe, isStandalone: true, name: "pricePerMonth" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PricePerMonthPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: "pricePerMonth",
                    standalone: true,
                }]
        }] });

class IdFormatPipe {
    constructor(_language) {
        this._language = _language;
    }
    transform(value) {
        return `txt_${value}_${this._language.getLanguage()}`;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IdFormatPipe, deps: [{ token: i1.LanguageService }], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: IdFormatPipe, isStandalone: true, name: "IdFormat" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IdFormatPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'IdFormat',
                    standalone: true,
                }]
        }], ctorParameters: function () { return [{ type: i1.LanguageService }]; } });

class SanitizerHtmlPipe {
    constructor(sanitizer) {
        this.sanitizer = sanitizer;
    }
    transform(value) {
        return this.sanitizer.bypassSecurityTrustHtml(value);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SanitizerHtmlPipe, deps: [{ token: i1$2.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: SanitizerHtmlPipe, isStandalone: true, name: "sanitizerHtml" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SanitizerHtmlPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'sanitizerHtml',
                    standalone: true,
                }]
        }], ctorParameters: function () { return [{ type: i1$2.DomSanitizer }]; } });

class IsThereDiscountPipe {
    transform(priceBeforeDiscount, priceAfterDiscount) {
        return (priceBeforeDiscount - priceAfterDiscount) > 1;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IsThereDiscountPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: IsThereDiscountPipe, isStandalone: true, name: "isThereDiscount" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: IsThereDiscountPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'isThereDiscount',
                    standalone: true,
                }]
        }] });

class SetBaseUrlPipe {
    constructor(languageService) {
        this.languageService = languageService;
        this.language = LanguageEnum.En;
        this.language = this.languageService.getLanguage();
    }
    transform(BaseUrl) {
        BaseUrl = BaseUrl?.replaceAll('LdcBaseUrl', AppsUrlLinksConst.ldc + '/' + this.language);
        BaseUrl = BaseUrl?.replaceAll('WhiteBaseUrl', AppsUrlLinksConst.white + '/' + this.language);
        BaseUrl = BaseUrl?.replaceAll('BlueBaseUrl', AppsUrlLinksConst.blue + '/' + this.language);
        BaseUrl = BaseUrl?.replaceAll('YellowBaseUrl', AppsUrlLinksConst.yellow + '/' + this.language);
        BaseUrl = BaseUrl?.replaceAll('RedBaseUrl', AppsUrlLinksConst.red + '/' + this.language);
        return BaseUrl;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SetBaseUrlPipe, deps: [{ token: i1.LanguageService }], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: SetBaseUrlPipe, isStandalone: true, name: "setBaseUrl" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SetBaseUrlPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'setBaseUrl',
                    standalone: true,
                }]
        }], ctorParameters: function () { return [{ type: i1.LanguageService }]; } });

class PricePrefixTranslationPipe {
    constructor(languageService) {
        this.languageService = languageService;
    }
    transform(prefix) {
        let translatedPricePrefix;
        let language = this.languageService.getLanguage();
        language == LanguageEnum.Ar
            ? prefix.trim() == CurrencyEnum.egp.toUpperCase()
                ? (translatedPricePrefix = ' ج.م ')
                : (translatedPricePrefix = ' $ ')
            : (translatedPricePrefix = prefix);
        return translatedPricePrefix;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PricePrefixTranslationPipe, deps: [{ token: i1.LanguageService }], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: PricePrefixTranslationPipe, isStandalone: true, name: "pricePrefixTranslation" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PricePrefixTranslationPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'pricePrefixTranslation',
                    standalone: true,
                }]
        }], ctorParameters: function () { return [{ type: i1.LanguageService }]; } });

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

export { DiscountPercentagePipe, EnglishArabicNumbersPipe, EnglishArabicPriceByLanguagePipe, IdFormatPipe, IsThereDiscountPipe, PriceFormatPipe, PricePerMonthPipe, PricePrefixTranslationPipe, ProductPricePeriodByCurrency, SanitizerHtmlPipe, SetBaseUrlPipe };
//# sourceMappingURL=testlocallibrary-shared-kernel-pipes.mjs.map
