"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _react = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/lib/format-message"));

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

var _default_nbXK12_number = Intl.NumberFormat("nb-x-k12", { style: "decimal" }).format;

// 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 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(Pin, _Component);

  function Pin() {
    var _getPrototypeOf2;

    var _this;

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

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(Pin)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _this.scroll = function () {
      _this.props.scrollToItem(_this.props.position)(_this.props.sessionItemId);
    };

    return _this;
  }

  (0, _createClass2.default)(Pin, [{
    key: "render",
    value: function render() {
      return _react.default.createElement(_Button.default, {
        variant: "link",
        onClick: this.scroll,
        size: "small",
        margin: "0",
        fluidWidth: true
      }, "Sp\xF8rsm\xE5l " + _default_nbXK12_number(this.props.position));
    }
  }]);
  Pin.displayName = "Pin";
  return Pin;
}(_react.Component);

exports.default = Pin;
Pin.propTypes = {
  scrollToItem: _propTypes.default.func.isRequired,
  sessionItemId: _propTypes.default.string.isRequired,
  position: _propTypes.default.number.isRequired
};