'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = undefined;

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 _class,
    _temp2,
    _default_nl_number = Intl.NumberFormat('nl', { style: 'decimal' }).format;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _formatMessage = require('../../../../format-message');

var _formatMessage2 = _interopRequireDefault(_formatMessage);

var _Button = require('@instructure/ui-buttons/lib/components/Button');

var _Button2 = _interopRequireDefault(_Button);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// Component exists to prevent the recreation of the scroll function with each render,
// which would cause a new rerender on each data change
var Pin = (_temp2 = _class = function (_Component) {
  (0, _inherits3.default)(Pin, _Component);

  function Pin() {
    var _ref;

    var _temp, _this, _ret;

    (0, _classCallCheck3.default)(this, Pin);

    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 = Pin.__proto__ || Object.getPrototypeOf(Pin)).call.apply(_ref, [this].concat(args))), _this), _this.scroll = function () {
      _this.props.scrollToItem(_this.props.position)(_this.props.sessionItemId);
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(Pin, [{
    key: 'render',
    value: function render() {
      return _react2.default.createElement(
        _Button2.default,
        {
          variant: 'link',
          onClick: this.scroll,
          size: 'small',
          margin: '0',
          fluidWidth: true
        },
        'Vraag ' + _default_nl_number(this.props.position)
      );
    }
  }]);
  Pin.displayName = 'Pin'
  ;
  return Pin;
}(_react.Component), _class.propTypes = {
  scrollToItem: _propTypes2.default.func.isRequired,
  sessionItemId: _propTypes2.default.string.isRequired,
  position: _propTypes2.default.number.isRequired
}, _temp2);
exports.default = Pin;