"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);
var style_exports = {};
__export(style_exports, {
  styleV1Css: () => styleV1Css
});
module.exports = __toCommonJS(style_exports);
var import_controls = require("@makeswift/controls");
var import_colorToString = require("../../../components/utils/colorToString");
var import_responsive_style = require("../../../components/utils/responsive-style");
var import_length_percentage = require("../../../css/length-percentage");
var import_margin = require("../../../css/margin");
var import_padding = require("../../../css/padding");
const defaultMargin = {
  marginTop: 0,
  marginRight: "auto",
  marginBottom: 0,
  marginLeft: "auto"
};
const defaultPadding = {
  paddingTop: 0,
  paddingRight: 0,
  paddingBottom: 0,
  paddingLeft: 0
};
function styleV1Css(breakpoints, style, properties) {
  return {
    ...properties.includes(import_controls.Style.Width) && {
      maxWidth: "100%"
    },
    ...(0, import_responsive_style.responsiveStyle)(
      breakpoints,
      [
        style?.width,
        style?.margin,
        style?.padding,
        style?.border,
        style?.borderRadius,
        style?.textStyle
      ],
      ([width, margin, padding, border, borderRadius, textStyle]) => ({
        ...properties.includes(import_controls.Style.Width) && {
          width: widthToString(width) ?? "100%"
        },
        ...properties.includes(import_controls.Style.Margin) && (0, import_margin.marginPropertyDataToStyle)(margin ?? defaultMargin, defaultMargin),
        ...properties.includes(import_controls.Style.Padding) && (0, import_padding.paddingPropertyDataToStyle)(padding ?? defaultPadding, defaultPadding),
        ...properties.includes(import_controls.Style.Border) && {
          borderTop: borderSideToString(border?.borderTop) ?? "0 solid black",
          borderRight: borderSideToString(border?.borderRight) ?? "0 solid black",
          borderBottom: borderSideToString(border?.borderBottom) ?? "0 solid black",
          borderLeft: borderSideToString(border?.borderLeft) ?? "0 solid black"
        },
        ...properties.includes(import_controls.Style.BorderRadius) && {
          borderTopLeftRadius: borderRadiusToString(borderRadius?.borderTopLeftRadius) ?? 0,
          borderTopRightRadius: borderRadiusToString(borderRadius?.borderTopRightRadius) ?? 0,
          borderBottomRightRadius: borderRadiusToString(borderRadius?.borderBottomRightRadius) ?? 0,
          borderBottomLeftRadius: borderRadiusToString(borderRadius?.borderBottomLeftRadius) ?? 0
        },
        ...properties.includes(import_controls.Style.TextStyle) && {
          ...textStyle?.fontFamily && { fontFamily: `"${textStyle.fontFamily}"` },
          ...textStyle?.letterSpacing && { letterSpacing: textStyle.letterSpacing },
          ...textStyle?.fontSize && { fontSize: fontSizeToString(textStyle.fontSize) },
          ...textStyle?.fontWeight && { fontWeight: textStyle.fontWeight },
          textTransform: textStyle?.textTransform ?? [],
          fontStyle: textStyle?.fontStyle ?? []
        }
      })
    )
  };
  function widthToString(widthProperty) {
    if (widthProperty == null)
      return null;
    return (0, import_length_percentage.lengthPercentageDataToString)(widthProperty);
  }
  function borderSideToString(borderSide) {
    if (borderSide == null)
      return null;
    const { width, color, style: style2 } = borderSide;
    return `${width != null ? width : 0}px ${style2} ${color != null ? (0, import_colorToString.colorToString)(color) : "black"}`;
  }
  function borderRadiusToString(borderRadius) {
    if (borderRadius == null)
      return null;
    return (0, import_length_percentage.lengthPercentageDataToString)(borderRadius);
  }
  function fontSizeToString(fontSize) {
    return `${fontSize.value}${fontSize.unit}`;
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  styleV1Css
});
//# sourceMappingURL=style.js.map