import React from 'react';
import { PREFIX } from "../constants";
import { formatMoney } from "../utils/render";
var AmountFooter = function AmountFooter(_ref) {
  var _product$_extend$disp, _product$_extend;
  var product = _ref.product,
    bundle = _ref.bundle,
    symbol = _ref.symbol,
    isOnlyTotal = _ref.isOnlyTotal;
  var quantity = Number(bundle ? bundle.num : (_product$_extend$disp = (_product$_extend = product._extend) === null || _product$_extend === void 0 ? void 0 : _product$_extend.displayQuantity) !== null && _product$_extend$disp !== void 0 ? _product$_extend$disp : product.num) || 1;
  var unitTotal = bundle ? bundle.bundle_selling_price : product.selling_price;
  var unitOriginal = bundle ? bundle.original_total : product.original_price;
  var total = Number(unitTotal !== null && unitTotal !== void 0 ? unitTotal : 0) * quantity;
  var original = Number(unitOriginal !== null && unitOriginal !== void 0 ? unitOriginal : 0) * quantity;
  var isDiscount = original > 0 && original !== total;
  return /*#__PURE__*/React.createElement("div", {
    className: "".concat(PREFIX, "__amount-footer")
  }, !isOnlyTotal ? /*#__PURE__*/React.createElement("span", {
    className: "".concat(PREFIX, "__amount-unit")
  }, formatMoney(unitTotal, symbol), " x", quantity) : null, /*#__PURE__*/React.createElement("span", {
    className: "".concat(PREFIX, "__amount-total")
  }, isDiscount ? /*#__PURE__*/React.createElement("span", {
    className: "".concat(PREFIX, "__amount-original")
  }, formatMoney(original, symbol)) : null, /*#__PURE__*/React.createElement("span", null, formatMoney(total, symbol))));
};
export default AmountFooter;