'use strict';

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

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _class, _temp;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactRelay = require('react-relay');

var _reactRelay2 = _interopRequireDefault(_reactRelay);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _issueishTimelineContainer = require('./issueish-timeline-container');

var _issueishTimelineContainer2 = _interopRequireDefault(_issueishTimelineContainer);

var _octicon = require('../views/octicon');

var _octicon2 = _interopRequireDefault(_octicon);

var _githubDotcomMarkdown = require('../views/github-dotcom-markdown');

var _githubDotcomMarkdown2 = _interopRequireDefault(_githubDotcomMarkdown);

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

const reactionTypeToEmoji = {
  THUMBS_UP: '👍',
  THUMBS_DOWN: '👎',
  LAUGH: '😆',
  HOORAY: '🎉',
  CONFUSED: '😕',
  HEART: '❤️'
};

const typeAndStateToIcon = {
  Issue: {
    OPEN: 'issue-opened',
    CLOSED: 'issue-closed'
  },
  PullRequest: {
    OPEN: 'git-pull-request',
    CLOSED: 'git-pull-request',
    MERGED: 'git-merge'
  }
};

let IssueishPaneItemView = exports.IssueishPaneItemView = (_temp = _class = class IssueishPaneItemView extends _react2.default.Component {

  render() {
    const repo = this.props.repository;
    const issueish = this.props.issueish;
    const icons = typeAndStateToIcon[issueish.__typename] || {};
    const icon = icons[issueish.state] || '';
    const childProps = {
      issue: issueish.__typename === 'Issue' ? issueish : null,
      pullRequest: issueish.__typename === 'PullRequest' ? issueish : null
    };
    return _react2.default.createElement(
      'div',
      { className: 'github-PrPaneItem' },
      _react2.default.createElement(
        'div',
        { className: 'github-PrPaneItem-container' },
        _react2.default.createElement(
          'div',
          { className: 'issueish-badge-and-link' },
          _react2.default.createElement(
            'span',
            { className: (0, _classnames2.default)('issueish-badge', 'badge', issueish.state.toLowerCase()) },
            _react2.default.createElement(_octicon2.default, { icon: icon }),
            issueish.state.toLowerCase()
          ),
          _react2.default.createElement(
            'span',
            { className: 'issueish-link' },
            _react2.default.createElement(
              'a',
              { href: issueish.url },
              repo.owner.login,
              '/',
              repo.name,
              '#',
              issueish.number
            )
          )
        ),
        _react2.default.createElement(
          'div',
          { className: 'issueish-avatar-and-title' },
          _react2.default.createElement(
            'a',
            { className: 'author-avatar-link', href: issueish.author.url },
            _react2.default.createElement('img', { className: 'author-avatar', src: issueish.author.avatarUrl, title: issueish.author.login })
          ),
          _react2.default.createElement(
            'h3',
            { className: 'issueish-title' },
            issueish.title
          )
        ),
        _react2.default.createElement(_githubDotcomMarkdown2.default, {
          html: issueish.bodyHTML || '<em>No description provided.</em>',
          switchToIssueish: this.props.switchToIssueish
        }),
        _react2.default.createElement(
          'div',
          { className: 'reactions' },
          issueish.reactionGroups.map(group => group.users.totalCount > 0 ? _react2.default.createElement(
            'span',
            { className: (0, _classnames2.default)('reaction-group', group.content.toLowerCase()), key: group.content },
            reactionTypeToEmoji[group.content],
            ' \xA0 ',
            group.users.totalCount
          ) : null)
        ),
        _react2.default.createElement(_issueishTimelineContainer2.default, _extends({}, childProps, { switchToIssueish: this.props.switchToIssueish }))
      )
    );
  }
}, _class.propTypes = {
  switchToIssueish: _propTypes2.default.func.isRequired,
  repository: _propTypes2.default.shape({
    name: _propTypes2.default.string.isRequired,
    owner: _propTypes2.default.shape({
      login: _propTypes2.default.string
    })
  }),
  issueish: _propTypes2.default.shape({
    title: _propTypes2.default.string,
    bodyHTML: _propTypes2.default.string,
    number: _propTypes2.default.number,
    state: _propTypes2.default.oneOf(['OPEN', 'CLOSED', 'MERGED']).isRequired,
    author: _propTypes2.default.shape({
      login: _propTypes2.default.string.isRequired,
      avatarUrl: _propTypes2.default.string.isRequired,
      url: _propTypes2.default.string.isRequired
    }).isRequired,
    reactionGroups: _propTypes2.default.arrayOf(_propTypes2.default.shape({
      content: _propTypes2.default.string.isRequired,
      users: _propTypes2.default.shape({
        totalCount: _propTypes2.default.number.isRequired
      }).isRequired
    })).isRequired
  }).isRequired
}, _temp);
exports.default = _reactRelay2.default.createContainer(IssueishPaneItemView, {
  fragments: {
    repository: () => function () {
      return {
        children: [{
          fieldName: 'name',
          kind: 'Field',
          metadata: {},
          type: 'String'
        }, {
          children: [{
            fieldName: 'login',
            kind: 'Field',
            metadata: {},
            type: 'String'
          }, {
            fieldName: 'id',
            kind: 'Field',
            metadata: {
              isGenerated: true,
              isRequisite: true
            },
            type: 'ID'
          }, {
            fieldName: '__typename',
            kind: 'Field',
            metadata: {
              isGenerated: true,
              isRequisite: true
            },
            type: 'String'
          }],
          fieldName: 'owner',
          kind: 'Field',
          metadata: {
            canHaveSubselections: true,
            inferredRootCallName: 'node',
            inferredPrimaryKey: 'id',
            isAbstract: true
          },
          type: 'RepositoryOwner'
        }, {
          fieldName: 'id',
          kind: 'Field',
          metadata: {
            isGenerated: true,
            isRequisite: true
          },
          type: 'ID'
        }],
        id: _reactRelay2.default.QL.__id(),
        kind: 'Fragment',
        metadata: {},
        name: 'Issueish_RepositoryRelayQL',
        type: 'Repository'
      };
    }(),

    issueish: () => function (RQL_0, RQL_1) {
      return {
        children: [{
          fieldName: '__typename',
          kind: 'Field',
          metadata: {
            isRequisite: true
          },
          type: 'String'
        }, {
          children: [].concat.apply([], [{
            fieldName: 'state',
            kind: 'Field',
            metadata: {},
            type: 'IssueState'
          }, {
            fieldName: 'number',
            kind: 'Field',
            metadata: {},
            type: 'Int'
          }, {
            fieldName: 'title',
            kind: 'Field',
            metadata: {},
            type: 'String'
          }, {
            fieldName: 'bodyHTML',
            kind: 'Field',
            metadata: {},
            type: 'HTML'
          }, {
            children: [{
              fieldName: 'login',
              kind: 'Field',
              metadata: {},
              type: 'String'
            }, {
              fieldName: 'avatarUrl',
              kind: 'Field',
              metadata: {},
              type: 'URI'
            }, {
              fieldName: '__typename',
              kind: 'Field',
              metadata: {
                isGenerated: true,
                isRequisite: true
              },
              type: 'String'
            }, {
              children: [{
                fieldName: 'url',
                kind: 'Field',
                metadata: {},
                type: 'URI'
              }, {
                fieldName: 'id',
                kind: 'Field',
                metadata: {
                  isGenerated: true,
                  isRequisite: true
                },
                type: 'ID'
              }],
              id: _reactRelay2.default.QL.__id(),
              kind: 'Fragment',
              metadata: {},
              name: 'User',
              type: 'User'
            }, {
              children: [{
                fieldName: 'url',
                kind: 'Field',
                metadata: {},
                type: 'URI'
              }, {
                fieldName: 'id',
                kind: 'Field',
                metadata: {
                  isGenerated: true,
                  isRequisite: true
                },
                type: 'ID'
              }],
              id: _reactRelay2.default.QL.__id(),
              kind: 'Fragment',
              metadata: {},
              name: 'Bot',
              type: 'Bot'
            }, {
              children: [{
                fieldName: 'id',
                kind: 'Field',
                metadata: {
                  isGenerated: true,
                  isRequisite: true
                },
                type: 'ID'
              }, {
                fieldName: '__typename',
                kind: 'Field',
                metadata: {
                  isGenerated: true,
                  isRequisite: true
                },
                type: 'String'
              }],
              id: _reactRelay2.default.QL.__id(),
              kind: 'Fragment',
              metadata: {
                isAbstract: true
              },
              name: 'IdFragment',
              type: 'Node'
            }],
            fieldName: 'author',
            kind: 'Field',
            metadata: {
              canHaveSubselections: true,
              inferredRootCallName: 'node',
              inferredPrimaryKey: 'id',
              isAbstract: true
            },
            type: 'Actor'
          }, {
            fieldName: 'id',
            kind: 'Field',
            metadata: {
              isGenerated: true,
              isRequisite: true
            },
            type: 'ID'
          }, _reactRelay2.default.QL.__frag(RQL_0)]),
          id: _reactRelay2.default.QL.__id(),
          kind: 'Fragment',
          metadata: {},
          name: 'Issue',
          type: 'Issue'
        }, {
          children: [].concat.apply([], [{
            fieldName: 'state',
            kind: 'Field',
            metadata: {},
            type: 'PullRequestState'
          }, {
            fieldName: 'number',
            kind: 'Field',
            metadata: {},
            type: 'Int'
          }, {
            fieldName: 'title',
            kind: 'Field',
            metadata: {},
            type: 'String'
          }, {
            fieldName: 'bodyHTML',
            kind: 'Field',
            metadata: {},
            type: 'HTML'
          }, {
            children: [{
              fieldName: 'login',
              kind: 'Field',
              metadata: {},
              type: 'String'
            }, {
              fieldName: 'avatarUrl',
              kind: 'Field',
              metadata: {},
              type: 'URI'
            }, {
              fieldName: '__typename',
              kind: 'Field',
              metadata: {
                isGenerated: true,
                isRequisite: true
              },
              type: 'String'
            }, {
              children: [{
                fieldName: 'url',
                kind: 'Field',
                metadata: {},
                type: 'URI'
              }, {
                fieldName: 'id',
                kind: 'Field',
                metadata: {
                  isGenerated: true,
                  isRequisite: true
                },
                type: 'ID'
              }],
              id: _reactRelay2.default.QL.__id(),
              kind: 'Fragment',
              metadata: {},
              name: 'User',
              type: 'User'
            }, {
              children: [{
                fieldName: 'url',
                kind: 'Field',
                metadata: {},
                type: 'URI'
              }, {
                fieldName: 'id',
                kind: 'Field',
                metadata: {
                  isGenerated: true,
                  isRequisite: true
                },
                type: 'ID'
              }],
              id: _reactRelay2.default.QL.__id(),
              kind: 'Fragment',
              metadata: {},
              name: 'Bot',
              type: 'Bot'
            }, {
              children: [{
                fieldName: 'id',
                kind: 'Field',
                metadata: {
                  isGenerated: true,
                  isRequisite: true
                },
                type: 'ID'
              }, {
                fieldName: '__typename',
                kind: 'Field',
                metadata: {
                  isGenerated: true,
                  isRequisite: true
                },
                type: 'String'
              }],
              id: _reactRelay2.default.QL.__id(),
              kind: 'Fragment',
              metadata: {
                isAbstract: true
              },
              name: 'IdFragment',
              type: 'Node'
            }],
            fieldName: 'author',
            kind: 'Field',
            metadata: {
              canHaveSubselections: true,
              inferredRootCallName: 'node',
              inferredPrimaryKey: 'id',
              isAbstract: true
            },
            type: 'Actor'
          }, {
            fieldName: 'id',
            kind: 'Field',
            metadata: {
              isGenerated: true,
              isRequisite: true
            },
            type: 'ID'
          }, _reactRelay2.default.QL.__frag(RQL_1)]),
          id: _reactRelay2.default.QL.__id(),
          kind: 'Fragment',
          metadata: {},
          name: 'PullRequest',
          type: 'PullRequest'
        }, {
          children: [{
            fieldName: 'url',
            kind: 'Field',
            metadata: {},
            type: 'URI'
          }, {
            fieldName: '__typename',
            kind: 'Field',
            metadata: {
              isGenerated: true,
              isRequisite: true
            },
            type: 'String'
          }, {
            children: [{
              fieldName: 'id',
              kind: 'Field',
              metadata: {
                isGenerated: true,
                isRequisite: true
              },
              type: 'ID'
            }, {
              fieldName: '__typename',
              kind: 'Field',
              metadata: {
                isGenerated: true,
                isRequisite: true
              },
              type: 'String'
            }],
            id: _reactRelay2.default.QL.__id(),
            kind: 'Fragment',
            metadata: {
              isAbstract: true
            },
            name: 'IdFragment',
            type: 'Node'
          }],
          id: _reactRelay2.default.QL.__id(),
          kind: 'Fragment',
          metadata: {
            isAbstract: true
          },
          name: 'UniformResourceLocatable',
          type: 'UniformResourceLocatable'
        }, {
          children: [{
            children: [{
              fieldName: 'content',
              kind: 'Field',
              metadata: {},
              type: 'ReactionContent'
            }, {
              children: [{
                fieldName: 'totalCount',
                kind: 'Field',
                metadata: {},
                type: 'Int'
              }],
              fieldName: 'users',
              kind: 'Field',
              metadata: {
                canHaveSubselections: true,
                isConnection: true
              },
              type: 'ReactingUserConnection'
            }],
            fieldName: 'reactionGroups',
            kind: 'Field',
            metadata: {
              canHaveSubselections: true,
              isPlural: true
            },
            type: 'ReactionGroup'
          }, {
            fieldName: 'id',
            kind: 'Field',
            metadata: {
              isGenerated: true,
              isRequisite: true
            },
            type: 'ID'
          }, {
            fieldName: '__typename',
            kind: 'Field',
            metadata: {
              isGenerated: true,
              isRequisite: true
            },
            type: 'String'
          }],
          id: _reactRelay2.default.QL.__id(),
          kind: 'Fragment',
          metadata: {
            isAbstract: true
          },
          name: 'Reactable',
          type: 'Reactable'
        }, {
          children: [{
            fieldName: 'id',
            kind: 'Field',
            metadata: {
              isGenerated: true,
              isRequisite: true
            },
            type: 'ID'
          }, {
            fieldName: '__typename',
            kind: 'Field',
            metadata: {
              isGenerated: true,
              isRequisite: true
            },
            type: 'String'
          }],
          id: _reactRelay2.default.QL.__id(),
          kind: 'Fragment',
          metadata: {
            isAbstract: true
          },
          name: 'IdFragment',
          type: 'Node'
        }],
        id: _reactRelay2.default.QL.__id(),
        kind: 'Fragment',
        metadata: {
          isAbstract: true
        },
        name: 'Issueish_IssueishRelayQL',
        type: 'IssueOrPullRequest'
      };
    }(_issueishTimelineContainer2.default.getFragment('issue'), _issueishTimelineContainer2.default.getFragment('pullRequest'))
  }
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64, 