"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

exports.__esModule = true;
exports["default"] = exports.ProductContent = void 0;

var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));

var _react = _interopRequireWildcard(require("react"));

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _lib = require("@sentecacommerce-theme/lib");

var _AvailabilityPerStore = require("../AvailabilityPerStore");

var _templateObject, _templateObject2;

var ProductContent = function ProductContent(_ref) {
  var _metaData$content$len, _metaData$content;

  var renderVariantSelector = _ref.renderVariantSelector,
      isSizeSelected = _ref.isSizeSelected,
      handleClickDescription = _ref.handleClickDescription;

  var _useState = (0, _react.useState)(false),
      storesModalOpen = _useState[0],
      setStoresModalOpen = _useState[1];

  var _useProductState = (0, _lib.useProductState)(),
      metaData = _useProductState.metaData,
      selectedVariant = _useProductState.selectedVariant;

  var _useUIFunctions = (0, _lib.useUIFunctions)(),
      enqueueView = _useUIFunctions.enqueueView;

  var _useConfigState = (0, _lib.useConfigState)(),
      views = _useConfigState.views;

  var handleStoresModalOpen = function handleStoresModalOpen() {
    return setStoresModalOpen(true);
  };

  var handleStoresModalClose = function handleStoresModalClose() {
    return setStoresModalOpen(false);
  };

  var hasDescription = ((_metaData$content$len = metaData == null ? void 0 : (_metaData$content = metaData.content) == null ? void 0 : _metaData$content.length) != null ? _metaData$content$len : 0) > 0;
  var labels = (0, _lib.useLocalLabels)();
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(ShortDescription, null, metaData.shortDescription), hasDescription && /*#__PURE__*/_react["default"].createElement(ViewMoreDetails // onClick={() =>
  //   enqueueView<ItemDescriptionProps>(views.itemDesc, {
  //     content: metaData.content,
  //     title: metaData.name,
  //   })
  // }
  , {
    onClick: handleClickDescription
  }, labels.vieProductDetails), /*#__PURE__*/_react["default"].createElement(ViewMoreDetails, {
    onClick: handleStoresModalOpen,
    withTopMargin: true
  }, labels.checkAvailablity), storesModalOpen && /*#__PURE__*/_react["default"].createElement(_AvailabilityPerStore.AvailabilityPerStore, {
    isSizeSelected: isSizeSelected,
    renderVariantSelector: renderVariantSelector,
    onClose: handleStoresModalClose
  }));
};

exports.ProductContent = ProductContent;

var ShortDescription = _styledComponents["default"].p.attrs({
  className: 'pt-2 pb-2'
})(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2["default"])([""])));

var ViewMoreDetails = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteralLoose2["default"])(["\n  box-shadow: inset 0 -1px 0 0 ", ";\n  cursor: pointer;\n  width: fit-content;\n  margin-top: ", ";\n\n  &:hover {\n    opacity: 0.7;\n  }\n"])), function (_ref2) {
  var theme = _ref2.theme;
  return theme.palette.primary;
}, function (props) {
  return props.withTopMargin ? '1.2rem' : 0;
});

var _default = ProductContent;
exports["default"] = _default;
//# sourceMappingURL=index.js.map