"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),_react=require("react"),React=_interopRequireWildcard(_react),_propTypes=require("prop-types"),PropTypes=_interopRequireWildcard(_propTypes),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var AnchorLink=function(e){function r(){(0,_classCallCheck3.default)(this,r);var e=(0,_possibleConstructorReturn3.default)(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments));return e.handleClick=function(){e.context.antAnchor.scrollTo(e.props.href)},e}return(0,_inherits3.default)(r,e),(0,_createClass3.default)(r,[{key:"componentDidMount",value:function(){this.context.antAnchor.registerLink(this.props.href)}},{key:"componentWillUnmount",value:function(){this.context.antAnchor.unregisterLink(this.props.href)}},{key:"render",value:function(){var e=this.props,r=e.prefixCls,t=e.href,n=e.title,i=e.children,s=this.context.antAnchor.activeLink===t,l=(0,_classnames2.default)(r+"-link",(0,_defineProperty3.default)({},r+"-link-active",s)),a=(0,_classnames2.default)(r+"-link-title",(0,_defineProperty3.default)({},r+"-link-title-active",s));return React.createElement("div",{className:l},React.createElement("a",{className:a,href:t,title:"string"==typeof n?n:"",onClick:this.handleClick},n),i)}}]),r}(React.Component);(exports.default=AnchorLink).defaultProps={prefixCls:"dt-anchor",href:"#"},AnchorLink.contextTypes={antAnchor:PropTypes.object},module.exports=exports.default;