text: 'use strict';
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  
  var _extends2 = require('babel-runtime/helpers/extends');
  
  var _extends3 = _interopRequireDefault(_extends2);
  
  var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
  
  var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
  
  var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
  
  var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
  
  var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
  
  var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  
  var _createClass2 = require('babel-runtime/helpers/createClass');
  
  var _createClass3 = _interopRequireDefault(_createClass2);
  
  var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
  
  var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
  
  var _inherits2 = require('babel-runtime/helpers/inherits');
  
  var _inherits3 = _interopRequireDefault(_inherits2);
  
  var _simpleAssign = require('simple-assign');
  
  var _simpleAssign2 = _interopRequireDefault(_simpleAssign);
  
  var _react = require('react');
  
  var _react2 = _interopRequireDefault(_react);
  
  var _propTypes = require('prop-types');
  
  var _propTypes2 = _interopRequireDefault(_propTypes);
  
  var _transitions = require('../styles/transitions');
  
  var _transitions2 = _interopRequireDefault(_transitions);
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function getStyles(props, context, state) {
    var verticalPosition = props.verticalPosition;
    var horizontalPosition = props.horizontalPosition;
    var touchMarginOffset = props.touch ? 10 : 0;
    var touchOffsetTop = props.touch ? -20 : -10;
    var offset = verticalPosition === 'bottom' ? 14 + touchMarginOffset : -14 - touchMarginOffset;
  
    var _context$muiTheme = context.muiTheme,
        baseTheme = _context$muiTheme.baseTheme,
        zIndex = _context$muiTheme.zIndex,
        tooltip = _context$muiTheme.tooltip,
        borderRadius = _context$muiTheme.borderRadius;
  
  
    var styles = {
      root: {
        position: 'absolute',
        fontFamily: baseTheme.fontFamily,
        fontSize: '10px',
        lineHeight: '22px',
        padding: '0 8px',
        zIndex: zIndex.tooltip,
        color: tooltip.color,
        overflow: 'hidden',
        top: -10000,
        borderRadius: borderRadius,
        userSelect: 'none',
        opacity: 0,
        right: horizontalPosition === 'left' ? 12 : null,
        left: horizontalPosition === 'center' ? (state.offsetWidth - 48) / 2 * -1 : horizontalPosition === 'right' ? 12 : null,
        transition: _transitions2.default.easeOut('0ms', 'top', '450ms') + ', ' + _transitions2.default.easeOut('450ms', 'transform', '0ms') + ', ' + _transitions2.default.easeOut('450ms', 'opacity', '0ms')
      },
      label: {
        position: 'relative',
        whiteSpace: 'nowrap'
      },
      ripple: {
        position: 'absolute',
        left: horizontalPosition === 'center' ? '50%' : horizontalPosition === 'left' ? '100%' : '0%',
        top: verticalPosition === 'bottom' ? 0 : '100%',
        transform: 'translate(-50%, -50%)',
        borderRadius: '50%',
        backgroundColor: 'transparent',
        transition: _transitions2.default.easeOut('0ms', 'width', '450ms') + ', ' + _transitions2.default.easeOut('0ms', 'height', '450ms') + ', ' + _transitions2.default.easeOut('450ms', 'backgroundColor', '0ms')
      },
      rootWhenShown: {
        top: verticalPosition === 'top' ? touchOffsetTop : 36,
        opacity: tooltip.opacity,
        transform: 'translate(0px, ' + offset + 'px)',
        transition: _transitions2.default.easeOut('0ms', 'top', '0ms') + ', ' + _transitions2.default.easeOut('450ms', 'transform', '0ms') + ', ' + _transitions2.default.easeOut('450ms', 'opacity', '0ms')
      },
      rootWhenTouched: {
        fontSize: '14px',
        lineHeight: '32px',
        padding: '0 16px'
      },
      rippleWhenShown: {
        backgroundColor: tooltip.rippleBackgroundColor,
        transition: _transitions2.default.easeOut('450ms', 'width', '0ms') + ', ' + _transitions2.default.easeOut('450ms', 'height', '0ms') + ', ' + _transitions2.default.easeOut('450ms', 'backgroundColor', '0ms')
      }
    };
  
    return styles;
  }
  
  var Tooltip = function (_Component) {
    (0, _inherits3.default)(Tooltip, _Component);
  
    function Tooltip() {
      var _ref;
  
      var _temp, _this, _ret;
  
      (0, _classCallCheck3.default)(this, Tooltip);
  
      for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
  
      return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = Tooltip.__proto__ || (0, _getPrototypeOf2.default)(Tooltip)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
        offsetWidth: null
      }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
    }
  
    (0, _createClass3.default)(Tooltip, [{
      key: 'componentDidMount',
      value: function componentDidMount() {
        this.setRippleSize();
        this.setTooltipPosition();
      }
    }, {
      key: 'componentWillReceiveProps',
      value: function componentWillReceiveProps() {
        this.setTooltipPosition();
      }
    }, {
      key: 'componentDidUpdate',
      value: function componentDidUpdate() {
        this.setRippleSize();
      }
    }, {
      key: 'setRippleSize',
      value: function setRippleSize() {
        var ripple = this.refs.ripple;
        var tooltip = this.refs.tooltip;
        var tooltipWidth = parseInt(tooltip.offsetWidth, 10) / (this.props.horizontalPosition === 'center' ? 2 : 1);
        var tooltipHeight = parseInt(tooltip.offsetHeight, 10);
  
        var rippleDiameter = Math.ceil(Math.sqrt(Math.pow(tooltipHeight, 2) + Math.pow(tooltipWidth, 2)) * 2);
        if (this.props.show) {
          ripple.style.height = rippleDiameter + 'px';
          ripple.style.width = rippleDiameter + 'px';
        } else {
          ripple.style.width = '0px';
          ripple.style.height = '0px';
        }
      }
    }, {
      key: 'setTooltipPosition',
      value: function setTooltipPosition() {
        this.setState({ offsetWidth: this.refs.tooltip.offsetWidth });
      }
    }, {
      key: 'render',
      value: function render() {
        var _props = this.props,
            horizontalPosition = _props.horizontalPosition,
            label = _props.label,
            show = _props.show,
            touch = _props.touch,
            verticalPosition = _props.verticalPosition,
            other = (0, _objectWithoutProperties3.default)(_props, ['horizontalPosition', 'label', 'show', 'touch', 'verticalPosition']);
        var prepareStyles = this.context.muiTheme.prepareStyles;
  
        var styles = getStyles(this.props, this.context, this.state);
  
        return _react2.default.createElement(
          'div',
          (0, _extends3.default)({}, other, {
            ref: 'tooltip',
            style: prepareStyles((0, _simpleAssign2.default)(styles.root, this.props.show && styles.rootWhenShown, this.props.touch && styles.rootWhenTouched, this.props.style))
          }),
          _react2.default.createElement('div', {
            ref: 'ripple',
            style: prepareStyles((0, _simpleAssign2.default)(styles.ripple, this.props.show && styles.rippleWhenShown))
          }),
          _react2.default.createElement(
            'span',
            { style: prepareStyles(styles.label) },
            label
          )
        );
      }
    }]);
    return Tooltip;
  }(_react.Component);
  
  Tooltip.contextTypes = {
    muiTheme: _propTypes2.default.object.isRequired
  };
  process.env.NODE_ENV !== "production" ? Tooltip.propTypes = {
    /**
     * The css class name of the root element.
     */
    className: _propTypes2.default.string,
    horizontalPosition: _propTypes2.default.oneOf(['left', 'right', 'center']),
    label: _propTypes2.default.node.isRequired,
    show: _propTypes2.default.bool,
    /**
     * Override the inline-styles of the root element.
     */
    style: _propTypes2.default.object,
    touch: _propTypes2.default.bool,
    verticalPosition: _propTypes2.default.oneOf(['top', 'bottom'])
  } : void 0;
  exports.default = Tooltip;