/**
 * PriceDisplay – reusable price display primitive
 *
 * Handles single price, compare price with strikethrough, discount percentage,
 * and price range display.
 */
import React from 'react';
import { clsx } from 'clsx';
const formatNum = (value, currency, position, decimals) => {
    const formatted = value.toLocaleString(undefined, {
        minimumFractionDigits: decimals,
        maximumFractionDigits: decimals,
    });
    return position === 'before' ? `${currency}${formatted}` : `${formatted}${currency}`;
};
export function PriceDisplay({ price, comparePrice, priceRange, currency = '$', currencyPosition = 'before', priceDecimals = 2, showDiscount = true, className, style, }) {
    const fmt = (v) => formatNum(v, currency, currencyPosition, priceDecimals);
    // Price range mode
    if (priceRange) {
        return (React.createElement("span", { className: clsx('seekora-price-display', 'seekora-price-range', className), style: style },
            fmt(priceRange.min),
            " \u2013 ",
            fmt(priceRange.max)));
    }
    if (price == null)
        return null;
    const hasCompare = comparePrice != null && comparePrice > price;
    const discount = hasCompare ? Math.round(((comparePrice - price) / comparePrice) * 100) : 0;
    return (React.createElement("span", { className: clsx('seekora-price-display', className), style: { display: 'inline-flex', alignItems: 'center', gap: 6, flexWrap: 'wrap', ...style } },
        React.createElement("span", { className: "seekora-price-current", style: { fontWeight: 600 } }, fmt(price)),
        hasCompare && (React.createElement("span", { className: "seekora-price-compare", style: {
                textDecoration: 'line-through',
                color: 'var(--seekora-text-secondary, #6b7280)',
                fontSize: '0.875em',
            } }, fmt(comparePrice))),
        hasCompare && showDiscount && discount > 0 && (React.createElement("span", { className: "seekora-price-discount", style: {
                color: 'var(--seekora-error, #ef4444)',
                fontSize: '0.8125em',
                fontWeight: 600,
            } },
            "-",
            discount,
            "%"))));
}
