"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.createFixedGuidelinesFromLengths = void 0;
Object.defineProperty(exports, "createGuidesFromLengths", {
  enumerable: true,
  get: function get() {
    return _createGuidesFromLengths.createGuidesFromLengths;
  }
});
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _createGuidesFromLengths = require("./createGuidesFromLengths");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
 * This creates a Guideline configuration generating a collection of guideline pairs from each supplied length value.
 * Each length value generates a guideline config for both the left and right side of the length.
 * When length is 0, generate a guideline at position: {x: 0}
 *
 */
var createFixedGuidelinesFromLengths = exports.createFixedGuidelinesFromLengths = function createFixedGuidelinesFromLengths(lengths) {
  var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'guide';
  var hasFullWidthGuide = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  return (0, _createGuidesFromLengths.createGuidesFromLengths)(lengths, hasFullWidthGuide).reduce(function (acc, _ref) {
    var left = _ref.left,
      right = _ref.right,
      length = _ref.length,
      isFullWidth = _ref.isFullWidth;
    if (length === 0) {
      return [].concat((0, _toConsumableArray2.default)(acc), [{
        key: "".concat(key, "-").concat(length, "-centre"),
        position: {
          x: left
        }
      }]);
    } else {
      return [].concat((0, _toConsumableArray2.default)(acc), [{
        key: "".concat(key, "-").concat(length, "-left"),
        position: {
          x: left
        }
      }, _objectSpread({
        key: "".concat(key, "-").concat(length, "-right"),
        position: {
          x: right
        }
      }, isFullWidth ? {
        isFullWidth: true
      } : {})]);
    }
  }, []);
};
// eslint-disable-next-line @atlaskit/editor/no-re-export