// packages/block-editor/src/layouts/utils.js
import { __, sprintf } from "@wordpress/i18n";
import { LAYOUT_DEFINITIONS } from "./definitions";
function appendSelectors(selectors, append = "") {
  return selectors.split(",").map(
    (subselector) => `${subselector}${append ? ` ${append}` : ""}`
  ).join(",");
}
function getBlockGapCSS(selector, layoutDefinitions = 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 = sprintf(__("Max %s wide"), contentSize);
  }
  if (sizeRegex.test(wideSize)) {
    alignmentInfo.wide = sprintf(__("Max %s wide"), wideSize);
  }
  return alignmentInfo;
}
export {
  appendSelectors,
  getAlignmentsInfo,
  getBlockGapCSS
};
//# sourceMappingURL=utils.js.map
