"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Resource = Resource;
exports.MetadataQuestion = MetadataQuestion;
exports.CollapsableSection = CollapsableSection;

var _core = require("@emotion/core");

var _react = require("react");

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

var _lodash = _interopRequireDefault(require("lodash"));

var _shortid = require("shortid");

var _Collapsable = _interopRequireDefault(require("../Collapsable/Collapsable"));

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

function Resource(_ref) {
  var section = _ref.section;
  return (0, _core.jsx)(_react.Fragment, null, (0, _core.jsx)("h3", null, section.heading), (0, _core.jsx)("ul", null, section.items.map(function (item) {
    return (0, _core.jsx)("li", {
      key: (0, _shortid.generate)()
    }, (0, _core.jsx)("a", {
      href: item.link
    }, item.description));
  })));
}

Resource.propTypes = {
  section: _propTypes["default"].shape({
    heading: _propTypes["default"].string,
    items: _propTypes["default"].arrayOf(_propTypes["default"].shape({
      link: _propTypes["default"].string,
      description: _propTypes["default"].string
    }))
  })
};

function MetadataQuestion(_ref2) {
  var question = _ref2.question,
      answer = _ref2.answer;
  return (0, _core.jsx)(_react.Fragment, null, (0, _core.jsx)("h4", null, question), (0, _core.jsx)("p", null, answer));
}

MetadataQuestion.propTypes = {
  question: _propTypes["default"].string,
  answer: _propTypes["default"].string
};

function CollapsableSection(_ref3) {
  var items = _ref3.items,
      collapseAfter = _ref3.collapseAfter,
      description = _ref3.description;

  var beforeFold = _lodash["default"].slice(items, 0, collapseAfter);

  var afterFold = _lodash["default"].slice(items, collapseAfter);

  return (afterFold && afterFold.length) > 0 ? (0, _core.jsx)(_Collapsable["default"], {
    description: description
  }, (0, _core.jsx)(_Collapsable["default"].Section, null, beforeFold), (0, _core.jsx)(_Collapsable["default"].Section, {
    hidden: true
  }, afterFold)) : (0, _core.jsx)(_react.Fragment, null, beforeFold);
}

CollapsableSection.propTypes = {
  items: _propTypes["default"].arrayOf(_propTypes["default"].node),
  collapseAfter: _propTypes["default"].number,
  description: _propTypes["default"].string
};