"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// packages/block-editor/src/layouts/utils.js
var utils_exports = {};
__export(utils_exports, {
  appendSelectors: () => appendSelectors,
  getAlignmentsInfo: () => getAlignmentsInfo,
  getBlockGapCSS: () => getBlockGapCSS
});
module.exports = __toCommonJS(utils_exports);
var import_i18n = require("@wordpress/i18n");
var import_definitions = require("./definitions");
function appendSelectors(selectors, append = "") {
  return selectors.split(",").map(
    (subselector) => `${subselector}${append ? ` ${append}` : ""}`
  ).join(",");
}
function getBlockGapCSS(selector, layoutDefinitions = import_definitions.LAYOUT_DEFINITIONS, layoutType, blockGapValue) {
  let output = "";
  if (layoutDefinitions?.[layoutType]?.spacingStyles?.length && blockGapValue) {
    layoutDefinitions[layoutType].spacingStyles.forEach((gapStyle) => {
      output += `${appendSelectors(
        selector,
        gapStyle.selector.trim()
      )} { `;
      output += Object.entries(gapStyle.rules).map(
        ([cssProperty, value]) => `${cssProperty}: ${value ? value : blockGapValue}`
      ).join("; ");
      output += "; }";
    });
  }
  return output;
}
function getAlignmentsInfo(layout) {
  const { contentSize, wideSize, type = "default" } = layout;
  const alignmentInfo = {};
  const sizeRegex = /^(?!0)\d+(px|em|rem|vw|vh|%|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)?$/i;
  if (sizeRegex.test(contentSize) && type === "constrained") {
    alignmentInfo.none = (0, import_i18n.sprintf)((0, import_i18n.__)("Max %s wide"), contentSize);
  }
  if (sizeRegex.test(wideSize)) {
    alignmentInfo.wide = (0, import_i18n.sprintf)((0, import_i18n.__)("Max %s wide"), wideSize);
  }
  return alignmentInfo;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  appendSelectors,
  getAlignmentsInfo,
  getBlockGapCSS
});
//# sourceMappingURL=utils.js.map
