'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_svXK12_number = Intl.NumberFormat('sv-x-k12', { style: 'decimal' }).format;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

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

var _Button2 = _interopRequireDefault(_Button);

var _IconPinLine = require('instructure-icons/lib/Line/IconPinLine');

var _IconPinLine2 = _interopRequireDefault(_IconPinLine);

var _IconPinSolid = require('instructure-icons/lib/Solid/IconPinSolid');

var _IconPinSolid2 = _interopRequireDefault(_IconPinSolid);

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

var _ScreenReaderContent2 = _interopRequireDefault(_ScreenReaderContent);

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

var _formatMessage2 = _interopRequireDefault(_formatMessage);

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

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.handleClick = function (e) {
      e.stopPropagation();
      _this.props.pinSessionItem();
    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  }

  (0, _createClass3.default)(Pin, [{
    key: 'render',
    value: function render() {
      var message = this.props.isPinned ? 'F\xF6rem\xE5l ' + _default_svXK12_number(this.props.position) + ' \xE4r fastn\xE5lat. Klicka f\xF6r att lossa.' : 'F\xF6rem\xE5let ' + _default_svXK12_number(this.props.position) + ' har lossats. Klicka f\xF6r att n\xE5la fast.';
      return _react2.default.createElement(
        _Button2.default,
        {
          onClick: this.handleClick,
          variant: this.props.variant,
          size: 'small',
          icon: this.props.isPinned ? _IconPinSolid2.default : _IconPinLine2.default
        },
        _react2.default.createElement(
          _ScreenReaderContent2.default,
          null,
          message
        )
      );
    }
  }]);
  Pin.displayName = 'Pin'
  ;
  return Pin;
}(_react.Component), _class.propTypes = {
  isPinned: _propTypes2.default.bool.isRequired,
  pinSessionItem: _propTypes2.default.func.isRequired,
  position: _propTypes2.default.number.isRequired,
  variant: _propTypes2.default.oneOf(['default', 'primary', 'success', 'danger', 'light', 'ghost', 'ghost-inverse', 'link', 'link-inverse', 'circle-default', 'circle-primary', 'circle-danger', 'icon', 'icon-inverse'])
}, _class.defaultProps = {
  variant: 'icon'
}, _temp2);
exports.default = Pin;