import Decimal from 'decimal.js';
export var formatProductPrice = function formatProductPrice(item) {
  var _ref = item || {},
    _price = _ref.price,
    _original_price = _ref.original_price,
    is_bundle = _ref.is_bundle,
    minimum_markup_price = _ref.minimum_markup_price;
  var price = _price;
  var original_price = _original_price;
  if (is_bundle) {
    price = new Decimal(price).plus(new Decimal(minimum_markup_price)).toFixed(2);
    original_price = new Decimal(original_price).plus(new Decimal(minimum_markup_price)).toFixed(2);
  }
  return {
    price: price,
    original_price: original_price
  };
};

/**
 * @description: 获取sku卡配置
 * @param {ProductCardConfig} finalConfig
 * @return {*}
 */
export var getSkuCardConfig = function getSkuCardConfig(finalConfig) {
  var imgHeight = finalConfig.imgHeight,
    imgWidth = finalConfig.imgWidth,
    isOriginPrice = finalConfig.isOriginPrice,
    isPrice = finalConfig.isPrice,
    isProductCover = finalConfig.isProductCover,
    isStock = finalConfig.isStock,
    isSubtitle = finalConfig.isSubtitle,
    isTitle = finalConfig.isTitle,
    radius = finalConfig.radius,
    showZeroPrice = finalConfig.showZeroPrice,
    coverTextFontSize = finalConfig.coverTextFontSize,
    skuCardPaddingX = finalConfig.skuCardPaddingX,
    skuCardPaddingY = finalConfig.skuCardPaddingY,
    _finalConfig$layoutDi = finalConfig.layoutDirection,
    layoutDirection = _finalConfig$layoutDi === void 0 ? 'row' : _finalConfig$layoutDi;
  return {
    skuCardConfig: {
      displayMode: 'display_a9',
      paddingY: skuCardPaddingY,
      paddingX: skuCardPaddingX,
      isBorderVisible: false,
      layoutDirection: layoutDirection
    },
    skuActionConfig: {
      isOpen: false
    },
    skuExtraConfig: {
      isOpen: false
    },
    skuTextConfig: {
      skuSubtitleConfig: {
        isOpen: isSubtitle
      },
      skuNameConfig: {
        isOpen: isTitle
      },
      skuPriceConfig: {
        isOpen: isPrice || isOriginPrice,
        isPrice: isPrice,
        isShowZeroPrice: showZeroPrice,
        isOriginPrice: isOriginPrice
      },
      skuStockConfig: {
        isOpen: isStock
      }
    },
    skuImageConfig: {
      isCover: isProductCover,
      width: imgWidth,
      height: imgHeight,
      isTextFallback: true,
      radius: radius,
      textFontSize: coverTextFontSize
    }
  };
};