"use strict";

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

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

var _shortid = _interopRequireDefault(require("shortid"));

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

var _CivicStoryCard = _interopRequireDefault(require("../CivicStoryCard/CivicStoryCard"));

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

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }

function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }

function _templateObject2() {
  var data = _taggedTemplateLiteral(["\n  position: absolute;\n  z-index: ", ";\n  left: ", "px;\n  top: ", "px;\n  opacity: ", ";\n  padding-right: ", "px;\n"]);

  _templateObject2 = function _templateObject2() {
    return data;
  };

  return data;
}

function _templateObject() {
  var data = _taggedTemplateLiteral(["\n  padding: 0 ", "px ", "px 0;\n"]);

  _templateObject = function _templateObject() {
    return data;
  };

  return data;
}

function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }

var smallWatermark = (0, _core.jsx)("svg", {
  xmlns: "http://www.w3.org/2000/svg"
}, (0, _core.jsx)("g", {
  fill: "none",
  fillRule: "evenodd"
}, (0, _core.jsx)("path", {
  d: "M0 75V0l11.566 11.597v63.421H0z",
  fill: "#191119"
}), (0, _core.jsx)("path", {
  d: "M75 0v11.597H11.566v.008L0 .008V0h133.864z",
  fill: "#DC4556"
})));
var LAST_CARD_OPACITY = 0.4;

var cardStackWrapper = function cardStackWrapper(total) {
  return (0, _core.css)(_templateObject(), total * 5, total * 5);
};

var bgCard = function bgCard(index, total, baseOpacity) {
  return (0, _core.css)(_templateObject2(), total - index, 5 * index, -5 * index + 20, 1 - index * (1 - baseOpacity) / (total - 1), 5 * (total - index - 1));
};

var BackgroundStoryCard = function BackgroundStoryCard(index, total, children) {
  return (0, _core.jsx)("div", {
    css: bgCard(index, total, LAST_CARD_OPACITY),
    key: _shortid["default"].generate()
  }, (0, _core.jsx)(_CivicStoryCard["default"], {
    footer: false,
    watermark: smallWatermark
  }, children));
};

var CivicCardStack = function CivicCardStack(_ref) {
  var cards = _ref.cards,
      children = _ref.children;
  return (0, _core.jsx)("div", {
    css: cardStackWrapper(cards)
  }, cards && _toConsumableArray(Array(cards)).map(function (item, index) {
    return BackgroundStoryCard(index, cards, children);
  }));
};

CivicCardStack.propTypes = {
  children: _propTypes["default"].node,
  cards: _propTypes["default"].oneOf([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
};
CivicCardStack.defaultProps = {};
var _default = CivicCardStack;
exports["default"] = _default;