import React, { forwardRef } from "react";
import { cx } from "../../utils";
import { formatCurrency } from "./utils/formatCurrency";
import { base, StyledPeriodicity } from "./Price.styles";
import { base as viewCSS } from "./variations/_view/base";
import { classes } from "./Price.tokens";
/**
 * Компонент для отображения цены / стоимости / суммы.
 */ export const priceRoot = (Root)=>/*#__PURE__*/ forwardRef(({ children, locale = 'ru', currency = 'rub', minimumFractionDigits = 0, stroked = false, periodicity, view, className, stroke = false, ...rest }, outerRootRef)=>{
        const strokedClass = stroked || stroke ? classes.stroked : undefined;
        const hasCurrency = currency && currency.length === 3;
        return /*#__PURE__*/ React.createElement(Root, {
            view: view,
            ref: outerRootRef,
            className: cx(strokedClass, className),
            ...rest
        }, hasCurrency && formatCurrency({
            value: children,
            locale,
            currency,
            minimumFractionDigits
        }), periodicity && /*#__PURE__*/ React.createElement(StyledPeriodicity, null, periodicity));
    });
export const priceConfig = {
    name: 'Price',
    tag: 'span',
    layout: priceRoot,
    base,
    variations: {
        view: {
            css: viewCSS
        }
    },
    defaults: {
        view: 'default'
    }
};
