'use strict';

var _extends = require('@babel/runtime/helpers/extends');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var react = require('@carbon/react');
var React = require('react');
var PropTypes = require('prop-types');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var _extends__default = /*#__PURE__*/_interopDefault(_extends);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);
var React__namespace = /*#__PURE__*/_interopNamespace(React);
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);

var _excluded = ["direction", "align", "tooltipText", "openOnHover", "children"];
var TooltipDefinition = function TooltipDefinition(_ref) {
  var _ref$direction = _ref.direction,
    direction = _ref$direction === void 0 ? 'bottom' : _ref$direction,
    _ref$align = _ref.align,
    align = _ref$align === void 0 ? 'start' : _ref$align,
    _ref$tooltipText = _ref.tooltipText,
    tooltipText = _ref$tooltipText === void 0 ? '' : _ref$tooltipText,
    _ref$openOnHover = _ref.openOnHover,
    openOnHover = _ref$openOnHover === void 0 ? true : _ref$openOnHover,
    children = _ref.children,
    other = _objectWithoutProperties__default.default(_ref, _excluded);
  var newAlign;
  // This function is to pass the old direction, align property to the new align property since The align and direction props have been merged into the align prop
  if (direction === 'bottom' && align === 'center') {
    newAlign = 'bottom';
  } else if (direction === 'bottom' && align === 'end') {
    newAlign = 'bottom-end';
  } else if (direction === 'top' && align === 'start') {
    newAlign = 'top-start';
  } else if (direction === 'top' && align === 'center') {
    newAlign = 'top';
  } else if (direction === 'top' && align === 'end') {
    newAlign = 'top-end';
  } else if (direction === 'right' && align === 'start') {
    newAlign = 'right-start';
  } else if (direction === 'right' && align === 'center') {
    newAlign = 'right';
  } else if (direction === 'right' && align === 'end') {
    newAlign = 'right-end';
  } else if (direction === 'left' && align === 'start') {
    newAlign = 'left-start';
  } else if (direction === 'left' && align === 'center') {
    newAlign = 'left';
  } else if (direction === 'left' && align === 'end') {
    newAlign = 'left-end';
  } else {
    newAlign = 'bottom-start';
  }
  return /*#__PURE__*/React__namespace.createElement(react.DefinitionTooltip, _extends__default.default({}, other, {
    // The tooltipText prop has been renamed to definition
    openOnHover: openOnHover,
    definition: tooltipText,
    align: newAlign
  }), children);
};
TooltipDefinition.propTypes = {
  direction: PropTypes__default.default.string,
  align: PropTypes__default.default.string,
  tooltipText: PropTypes__default.default.string,
  children: PropTypes__default.default.node.isRequired,
  openOnHover: PropTypes__default.default.bool
};
TooltipDefinition.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "TooltipDefinition",
  "props": {
    "direction": {
      "defaultValue": {
        "value": "'bottom'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "align": {
      "defaultValue": {
        "value": "'start'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "tooltipText": {
      "defaultValue": {
        "value": "''",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "openOnHover": {
      "defaultValue": {
        "value": "true",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "children": {
      "description": "",
      "type": {
        "name": "node"
      },
      "required": true
    }
  }
};
var TooltipDefinition$1 = TooltipDefinition;

module.exports = TooltipDefinition$1;
