"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.PopupContentSkeleton = PopupContentSkeleton;
exports.PopupTargetSkeleton = PopupTargetSkeleton;
exports["default"] = PopupSkeleton;

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

var _PopupModule = _interopRequireDefault(require("./Popup.module.css"));

var _Popup = _interopRequireDefault(require("./Popup.constantProps"));

var _Popup2 = _interopRequireWildcard(require("./Popup.propTypes"));

var _Popup3 = _interopRequireDefault(require("./Popup.ComputeProps"));

var _popupstylemapping = require("./__popupstylemapping.json");

var _Button = _interopRequireDefault(require("../button/Button"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function PopupSkeleton(props) {
  var childrenWithPropsData = props.childrenWithPropsData;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: _PopupModule["default"].popupContainer
  }, childrenWithPropsData);
}

function PopupTargetSkeleton(props) {
  var children = props.children,
      togglePopup = props.togglePopup,
      isPopupOpen = props.isPopupOpen,
      removeClose = props.removeClose,
      getTargetRef = props.getTargetRef;

  if (children) {
    var childrenWithPropsTarget = _react["default"].Children.map(children, function (child, index) {
      return /*#__PURE__*/_react["default"].cloneElement(child, props);
    });

    return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, childrenWithPropsTarget);
  }

  return /*#__PURE__*/_react["default"].createElement(_Button["default"], _extends({
    ref: getTargetRef,
    onClick: togglePopup
  }, props));
}

function PopupContentSkeleton(props) {
  var children = props.children,
      togglePopup = props.togglePopup,
      isPopupOpen = props.isPopupOpen,
      removeClose = props.removeClose,
      position = props.position,
      arrowPosition = props.arrowPosition,
      placement = props.placement,
      color = props.color,
      size = props.size,
      getContainerRef = props.getContainerRef;
  console.log(placement, position, "sdad");
  var boxPosition = placement ? placement : position;
  var boxDirection = _popupstylemapping.positionMapping[boxPosition].direction;
  arrowPosition = arrowPosition ? arrowPosition : _popupstylemapping.positionMapping[boxPosition].arrowPosition;
  boxPosition = _popupstylemapping.positionMapping[boxPosition].positionStyle;
  var contentSize = _PopupModule["default"][size];
  var colorStyle = _PopupModule["default"][color];

  if (children) {
    return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children);
  } else if (isPopupOpen && !children) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      ref: getContainerRef,
      className: "".concat(_PopupModule["default"].popupSubContainer, " ").concat(_PopupModule["default"][boxPosition], " ").concat(_PopupModule["default"][boxDirection], "  ").concat(_PopupModule["default"]["arrow".concat(boxDirection)]),
      onClick: removeClose
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(_PopupModule["default"].popup, " ").concat(contentSize, " ").concat(colorStyle)
    }, /*#__PURE__*/_react["default"].createElement("span", {
      className: _PopupModule["default"][arrowPosition]
    }, /*#__PURE__*/_react["default"].createElement("span", {
      className: _PopupModule["default"].arrowShape
    }))), children);
  }

  return null;
}