"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 _Button = _interopRequireDefault(require("@instructure/ui-buttons/lib/components/Button"));

var _IconPin = _interopRequireDefault(require("@instructure/ui-icons/lib/Line/IconPin"));

var _IconPin2 = _interopRequireDefault(require("@instructure/ui-icons/lib/Solid/IconPin"));

var _ScreenReaderContent = _interopRequireDefault(require("@instructure/ui-a11y/lib/components/ScreenReaderContent"));

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

var _default_da_number = Intl.NumberFormat("da", { style: "decimal" }).format;

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.handleClick = function (e) {
      e.stopPropagation();

      _this.props.pinSessionItem();
    };

    return _this;
  }

  (0, _createClass2.default)(Pin, [{
    key: "render",
    value: function render() {
      var message = this.props.isPinned ? "Element " + _default_da_number(this.props.position) + " er fastgjort. Klik for at frig\xF8re." : "Element " + _default_da_number(this.props.position) + " er frigjort. Klik for at fastg\xF8re.";
      return _react.default.createElement(_Button.default, {
        onClick: this.handleClick,
        variant: this.props.variant,
        size: "small",
        icon: this.props.isPinned ? _IconPin2.default : _IconPin.default
      }, _react.default.createElement(_ScreenReaderContent.default, null, message));
    }
  }]);
  Pin.displayName = "Pin";
  return Pin;
}(_react.Component);

exports.default = Pin;
Pin.propTypes = {
  isPinned: _propTypes.default.bool.isRequired,
  pinSessionItem: _propTypes.default.func.isRequired,
  position: _propTypes.default.number.isRequired,
  variant: _propTypes.default.oneOf(['default', 'primary', 'success', 'danger', 'light', 'ghost', 'ghost-inverse', 'link', 'link-inverse', 'circle-default', 'circle-primary', 'circle-danger', 'icon', 'icon-inverse'])
};
Pin.defaultProps = {
  variant: 'icon'
};