"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.generateDefaultGuidelines = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
var _mediaSingle = require("../media-single");
var _getContainerWidthOrFullEditorWidth = require("./getContainerWidthOrFullEditorWidth");
var getDefaultGuidelines = (0, _memoizeOne.default)(function (editorWidth) {
  return [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6].map(function (val, index) {
    return {
      key: "grid_".concat(index),
      position: {
        x: (0, _mediaSingle.roundToNearest)(val / 12 * editorWidth)
      }
    };
  });
});
var getWideGuidelines = (0, _memoizeOne.default)(function (editorWidth) {
  var wideSpacing = (0, _mediaSingle.roundToNearest)(editorWidth * _editorSharedStyles.breakoutWideScaleRatio / 2);
  return [{
    key: "wide_left",
    position: {
      x: -wideSpacing
    }
  }, {
    key: "wide_right",
    position: {
      x: wideSpacing
    }
  }];
});
var getFullWidthGuidelines = (0, _memoizeOne.default)(function (containerWidth) {
  var fullWidth = (0, _mediaSingle.roundToNearest)((0, _getContainerWidthOrFullEditorWidth.getContainerWidthOrFullEditorWidth)(containerWidth));
  return [{
    key: "full_width_left",
    position: {
      x: -fullWidth
    }
  }, {
    key: "full_width_right",
    position: {
      x: fullWidth
    }
  }];
});
var generateDefaultGuidelines = exports.generateDefaultGuidelines = function generateDefaultGuidelines(editorWidth, containerWidth) {
  var isFullWidthMode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  var innerGrids = getDefaultGuidelines(editorWidth);
  var wideGuidelines = !isFullWidthMode ? getWideGuidelines(editorWidth) : [];
  var fullWidthGuidelines = !isFullWidthMode ? getFullWidthGuidelines(containerWidth) : [];
  return [].concat((0, _toConsumableArray2.default)(innerGrids), (0, _toConsumableArray2.default)(wideGuidelines), (0, _toConsumableArray2.default)(fullWidthGuidelines));
};