import {
  Style
} from "@makeswift/controls";
import { colorToString } from "../../../components/utils/colorToString";
import { responsiveStyle } from "../../../components/utils/responsive-style";
import { lengthPercentageDataToString } from "../../../css/length-percentage";
import { marginPropertyDataToStyle } from "../../../css/margin";
import { paddingPropertyDataToStyle } from "../../../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(Style.Width) && {
      maxWidth: "100%"
    },
    ...responsiveStyle(
      breakpoints,
      [
        style?.width,
        style?.margin,
        style?.padding,
        style?.border,
        style?.borderRadius,
        style?.textStyle
      ],
      ([width, margin, padding, border, borderRadius, textStyle]) => ({
        ...properties.includes(Style.Width) && {
          width: widthToString(width) ?? "100%"
        },
        ...properties.includes(Style.Margin) && marginPropertyDataToStyle(margin ?? defaultMargin, defaultMargin),
        ...properties.includes(Style.Padding) && paddingPropertyDataToStyle(padding ?? defaultPadding, defaultPadding),
        ...properties.includes(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(Style.BorderRadius) && {
          borderTopLeftRadius: borderRadiusToString(borderRadius?.borderTopLeftRadius) ?? 0,
          borderTopRightRadius: borderRadiusToString(borderRadius?.borderTopRightRadius) ?? 0,
          borderBottomRightRadius: borderRadiusToString(borderRadius?.borderBottomRightRadius) ?? 0,
          borderBottomLeftRadius: borderRadiusToString(borderRadius?.borderBottomLeftRadius) ?? 0
        },
        ...properties.includes(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 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 ? colorToString(color) : "black"}`;
  }
  function borderRadiusToString(borderRadius) {
    if (borderRadius == null)
      return null;
    return lengthPercentageDataToString(borderRadius);
  }
  function fontSizeToString(fontSize) {
    return `${fontSize.value}${fontSize.unit}`;
  }
}
export {
  styleV1Css
};
//# sourceMappingURL=style.js.map