"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.BubbleArrow = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _consts = require("./consts");
var _consts2 = require("../Bubble/consts");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var arrowUp = (0, _styledComponents.css)(["&::before{border-left:", "px solid transparent;border-right:", "px solid transparent;border-bottom:", "px solid ", ";}&::after{left:", "px;top:", "px;border-left:", "px solid transparent;border-right:", "px solid transparent;border-bottom:", "px solid ", ";}"], _consts.TRIANGLE_SIZE, _consts.TRIANGLE_SIZE, _consts.TRIANGLE_SIZE, function (p) {
  return p.noBorder ? 'transparent' : p.theme.color.bubbleBorder;
}, _consts2.BORDER_SIZE * 2, _consts2.BORDER_SIZE * 2, _consts.TRIANGLE_SIZE - _consts2.BORDER_SIZE * 2, _consts.TRIANGLE_SIZE - _consts2.BORDER_SIZE * 2, _consts.TRIANGLE_SIZE - _consts2.BORDER_SIZE * 2, function (p) {
  return p.theme.color.bubbleBackground;
});
var arrowRight = (0, _styledComponents.css)(["&::before{border-top:", "px solid transparent;border-bottom:", "px solid transparent;border-left:", "px solid ", ";}&::after{left:0;top:", "px;border-top:", "px solid transparent;border-bottom:", "px solid transparent;border-left:", "px solid ", ";}"], _consts.TRIANGLE_SIZE, _consts.TRIANGLE_SIZE, _consts.TRIANGLE_SIZE, function (p) {
  return p.noBorder ? 'transparent' : p.theme.color.bubbleBorder;
}, _consts2.BORDER_SIZE * 2, _consts.TRIANGLE_SIZE - _consts2.BORDER_SIZE * 2, _consts.TRIANGLE_SIZE - _consts2.BORDER_SIZE * 2, _consts.TRIANGLE_SIZE - _consts2.BORDER_SIZE * 2, function (p) {
  return p.theme.color.bubbleBackground;
});
var arrowDown = (0, _styledComponents.css)(["&::before{border-left:", "px solid transparent;border-right:", "px solid transparent;border-top:", "px solid ", ";}&::after{left:", "px;top:0;border-left:", "px solid transparent;border-right:", "px solid transparent;border-top:", "px solid ", ";}"], _consts.TRIANGLE_SIZE, _consts.TRIANGLE_SIZE, _consts.TRIANGLE_SIZE, function (p) {
  return p.noBorder ? 'transparent' : p.theme.color.bubbleBorder;
}, _consts2.BORDER_SIZE * 2, _consts.TRIANGLE_SIZE - _consts2.BORDER_SIZE * 2, _consts.TRIANGLE_SIZE - _consts2.BORDER_SIZE * 2, _consts.TRIANGLE_SIZE - _consts2.BORDER_SIZE * 2, function (p) {
  return p.theme.color.bubbleBackground;
});
var arrowLeft = (0, _styledComponents.css)(["&::before{border-top:", "px solid transparent;border-bottom:", "px solid transparent;border-right:", "px solid ", ";}&::after{left:", "px;top:", "px;border-top:", "px solid transparent;border-bottom:", "px solid transparent;border-right:", "px solid ", ";}"], _consts.TRIANGLE_SIZE, _consts.TRIANGLE_SIZE, _consts.TRIANGLE_SIZE, function (p) {
  return p.noBorder ? 'transparent' : p.theme.color.bubbleBorder;
}, _consts2.BORDER_SIZE * 2, _consts2.BORDER_SIZE * 2, _consts.TRIANGLE_SIZE - _consts2.BORDER_SIZE * 2, _consts.TRIANGLE_SIZE - _consts2.BORDER_SIZE * 2, _consts.TRIANGLE_SIZE - _consts2.BORDER_SIZE * 2, function (p) {
  return p.theme.color.bubbleBackground;
});
var Arrow = _styledComponents.default.div.withConfig({
  displayName: "BubbleArrow__Arrow",
  componentId: "sc-6ix6wd-0"
})(["position:absolute;&::before,&::after{content:'';display:block;width:0;height:0;position:absolute;top:0;left:0;}", " ", " ", " ", ""], function (p) {
  return p.$bubblePlacement === 'left' ? arrowRight : '';
}, function (p) {
  return p.$bubblePlacement === 'top' ? arrowDown : '';
}, function (p) {
  return p.$bubblePlacement === 'right' ? arrowLeft : '';
}, function (p) {
  return p.$bubblePlacement === 'bottom' ? arrowUp : '';
});
var getArrowPositionStyles = function getArrowPositionStyles(bubblePlacement) {
  if (bubblePlacement === 'top') {
    return {
      left: _consts.TRIANGLE_INDENTATION,
      top: '100%'
    };
  }
  if (bubblePlacement === 'right') {
    return {
      left: 0 - _consts.TRIANGLE_SIZE,
      top: _consts.TRIANGLE_INDENTATION
    };
  }
  if (bubblePlacement === 'left') {
    return {
      left: '100%',
      top: _consts.TRIANGLE_INDENTATION
    };
  }
  return {
    left: _consts.TRIANGLE_INDENTATION,
    top: 0 - _consts.TRIANGLE_SIZE
  };
};
var BubbleArrow = exports.BubbleArrow = _react.default.forwardRef(function (_ref, ref) {
  var bubblePlacement = _ref.bubblePlacement,
    noBorder = _ref.noBorder;
  var arrowPositionStyles = getArrowPositionStyles(bubblePlacement);
  return _react.default.createElement(Arrow, {
    $bubblePlacement: bubblePlacement,
    style: arrowPositionStyles,
    ref: ref,
    noBorder: noBorder
  });
});