"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _defineProperty2=require("babel-runtime/helpers/defineProperty"),_defineProperty3=_interopRequireDefault(_defineProperty2),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_extends2=require("babel-runtime/helpers/extends"),_extends3=_interopRequireDefault(_extends2),_react=require("react"),React=_interopRequireWildcard(_react),_rcTooltip=require("rc-tooltip"),_rcTooltip2=_interopRequireDefault(_rcTooltip),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_placements=require("./placements"),_placements2=_interopRequireDefault(_placements);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var splitObject=function(t,e){var i={},r=(0,_extends3.default)({},t);return e.forEach(function(e){t&&e in t&&(i[e]=t[e],delete r[e])}),{picked:i,omited:r}},Tooltip=function(e){function t(e){(0,_classCallCheck3.default)(this,t);var n=(0,_possibleConstructorReturn3.default)(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.onVisibleChange=function(e){var t=n.props.onVisibleChange;"visible"in n.props||n.setState({visible:!n.isNoTitle()&&e}),t&&!n.isNoTitle()&&t(e)},n.onPopupAlign=function(e,t){var i=n.getPlacements(),r=Object.keys(i).filter(function(e){return i[e].points[0]===t.points[0]&&i[e].points[1]===t.points[1]})[0];if(r){var l=e.getBoundingClientRect(),o={top:"50%",left:"50%"};0<=r.indexOf("top")||0<=r.indexOf("Bottom")?o.top=l.height-t.offset[1]+"px":(0<=r.indexOf("Top")||0<=r.indexOf("bottom"))&&(o.top=-t.offset[1]+"px"),0<=r.indexOf("left")||0<=r.indexOf("Right")?o.left=l.width-t.offset[0]+"px":(0<=r.indexOf("right")||0<=r.indexOf("Left"))&&(o.left=-t.offset[0]+"px"),e.style.transformOrigin=o.left+" "+o.top}},n.saveTooltip=function(e){n.tooltip=e},n.state={visible:!!e.visible||!!e.defaultVisible},n}return(0,_inherits3.default)(t,e),(0,_createClass3.default)(t,[{key:"componentWillReceiveProps",value:function(e){"visible"in e&&this.setState({visible:e.visible})}},{key:"getPopupDomNode",value:function(){return this.tooltip.getPopupDomNode()}},{key:"getPlacements",value:function(){var e=this.props,t=e.builtinPlacements,i=e.arrowPointAtCenter,r=e.autoAdjustOverflow;return t||(0,_placements2.default)({arrowPointAtCenter:i,verticalArrowShift:8,autoAdjustOverflow:r})}},{key:"isHoverTrigger",value:function(){var e=this.props.trigger;return!e||"hover"===e||!!Array.isArray(e)&&0<=e.indexOf("hover")}},{key:"getDisabledCompatibleChildren",value:function(e){if((e.type.__ANT_BUTTON||"button"===e.type)&&e.props.disabled&&this.isHoverTrigger()){var t=splitObject(e.props.style,["position","left","right","top","bottom","float","display","zIndex"]),i=t.picked,r=t.omited,l=(0,_extends3.default)({display:"inline-block"},i,{cursor:"not-allowed"}),o=(0,_extends3.default)({},r,{pointerEvents:"none"}),n=(0,_react.cloneElement)(e,{style:o,className:null});return React.createElement("span",{style:l,className:e.props.className},n)}return e}},{key:"isNoTitle",value:function(){var e=this.props,t=e.title,i=e.overlay;return!t&&!i}},{key:"render",value:function(){var e=this.props,t=this.state,i=e.prefixCls,r=e.title,l=e.overlay,o=e.openClassName,n=e.getPopupContainer,s=e.getTooltipContainer,a=e.children,u=t.visible;"visible"in e||!this.isNoTitle()||(u=!1);var p=this.getDisabledCompatibleChildren(React.isValidElement(a)?a:React.createElement("span",null,a)),c=p.props,f=(0,_classnames2.default)(c.className,(0,_defineProperty3.default)({},o||i+"-open",!0));return React.createElement(_rcTooltip2.default,(0,_extends3.default)({},this.props,{getTooltipContainer:n||s,ref:this.saveTooltip,builtinPlacements:this.getPlacements(),overlay:l||r||"",visible:u,onVisibleChange:this.onVisibleChange,onPopupAlign:this.onPopupAlign}),u?(0,_react.cloneElement)(p,{className:f}):p)}}]),t}(React.Component);(exports.default=Tooltip).defaultProps={prefixCls:"dt-tooltip",placement:"top",transitionName:"zoom-big-fast",mouseEnterDelay:.1,mouseLeaveDelay:.1,arrowPointAtCenter:!1,autoAdjustOverflow:!0},module.exports=exports.default;