"use strict";

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

var _index = require("./index");

var _utils = require("../common-painter/utils");

function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

function _default(_x, _x2, _x3) {
  return _ref.apply(this, arguments);
}

function _ref() {
  _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ctx, krs, y) {
    var lineHeight, space, dotRadius, dotSpace, _iterator, _step, kr;

    return regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            if (!(!krs || !krs.length)) {
              _context.next = 2;
              break;
            }

            return _context.abrupt("return", y);

          case 2:
            y += 12;
            lineHeight = 22;
            space = 43;
            dotRadius = 7 / 2;
            dotSpace = 8;
            ctx.font = "normal 14px/".concat(lineHeight, "px arial,sans-serif");
            _iterator = _createForOfIteratorHelper(krs);
            _context.prev = 9;

            _iterator.s();

          case 11:
            if ((_step = _iterator.n()).done) {
              _context.next = 25;
              break;
            }

            kr = _step.value;
            ctx.beginPath();
            ctx.arc(space - dotSpace - dotRadius, y + lineHeight / 2, dotRadius, 0, Math.PI * 2);
            ctx.fillStyle = '#FECCC6';
            ctx.fill();
            ctx.closePath();
            ctx.fillStyle = '#3F4755';
            _context.next = 21;
            return (0, _utils.drawTextMiddle)(ctx, kr, space, y, lineHeight, _index.pinkCardwidth - space * 2);

          case 21:
            _context.t0 = _context.sent;
            y = _context.t0 + 8;

          case 23:
            _context.next = 11;
            break;

          case 25:
            _context.next = 30;
            break;

          case 27:
            _context.prev = 27;
            _context.t1 = _context["catch"](9);

            _iterator.e(_context.t1);

          case 30:
            _context.prev = 30;

            _iterator.f();

            return _context.finish(30);

          case 33:
            return _context.abrupt("return", y - 8);

          case 34:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[9, 27, 30, 33]]);
  }));
  return _ref.apply(this, arguments);
}