import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/taggedTemplateLiteralLoose";

var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;

import React from 'react';
import styled from 'styled-components';
import { createDangerousMarkup, usePrice, useProductState } from '@sentecacommerce-theme/lib';
import { Typography } from '../../../Common';
export var Price = () => {
  var _selectedVariant$offe, _selectedVariant$offe2;

  var {
    selectedVariant
  } = useProductState();
  var {
    price,
    discountPercentage,
    discountPrice
  } = usePrice({
    price: selectedVariant == null ? void 0 : (_selectedVariant$offe = selectedVariant.offer) == null ? void 0 : _selectedVariant$offe.originalPrice,
    discountedPrice: selectedVariant == null ? void 0 : (_selectedVariant$offe2 = selectedVariant.offer) == null ? void 0 : _selectedVariant$offe2.discountedPrice
  });

  if (discountPrice) {
    return /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(CurrentPrice, {
      isDiscount: true,
      dangerouslySetInnerHTML: createDangerousMarkup(discountPrice.html)
    }), /*#__PURE__*/React.createElement(OldPrice, {
      dangerouslySetInnerHTML: createDangerousMarkup(price.html)
    }), /*#__PURE__*/React.createElement(DiscountPercentage, null, "-", discountPercentage, "%")));
  }

  return /*#__PURE__*/React.createElement(CurrentPrice, {
    dangerouslySetInnerHTML: createDangerousMarkup(price.html)
  });
};
var CurrentPrice = styled(Typography).attrs(props => ({
  variant: 4,
  color: props.isDiscount ? 'discount' : 'primary'
}))(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n  font-weight: 600;\n"])));
var OldPrice = styled(Typography).attrs({
  variant: 6,
  className: 'mx-2 '
})(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n  text-decoration: line-through;\n  line-height: 1.2;\n  opacity: 0.5;\n"])));
var Container = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose([""])));
var DiscountPercentage = styled(Typography).attrs({
  variant: 7,
  color: 'secondary',
  className: 'px-2 mb-1 '
})(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n  border-radius: 0.3rem;\n  width: fit-content;\n  align-self: center;\n  background-color: ", ";\n"])), (_ref) => {
  var {
    theme
  } = _ref;
  return theme.palette.discount;
});
var Row = styled.div.attrs({
  className: 'd-flex my-2'
})(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n  align-items: baseline;\n"])));
//# sourceMappingURL=index.js.map