import { isCSSVariableName } from "./dist-es-render-dom-utils-is-css-variable.js";
import { getValueAsType } from "./dist-es-render-dom-value-types-get-as-type.js";
import { numberValueTypes } from "./dist-es-render-dom-value-types-number.js";
import { buildTransform } from "./dist-es-render-html-utils-build-transform.js";
import { transformProps } from "./dist-es-render-html-utils-keys-transform.js";
function buildHTMLStyles(state, latestValues, transformTemplate) {
  const { style, vars, transformOrigin } = state;
  let hasTransform = false;
  let hasTransformOrigin = false;
  for (const key in latestValues) {
    const value = latestValues[key];
    if (transformProps.has(key)) {
      hasTransform = true;
      continue;
    } else if (isCSSVariableName(key)) {
      vars[key] = value;
      continue;
    } else {
      const valueAsType = getValueAsType(value, numberValueTypes[key]);
      if (key.startsWith("origin")) {
        hasTransformOrigin = true;
        transformOrigin[key] = valueAsType;
      } else {
        style[key] = valueAsType;
      }
    }
  }
  if (!latestValues.transform) {
    if (hasTransform || transformTemplate) {
      style.transform = buildTransform(latestValues, state.transform, transformTemplate);
    } else if (style.transform) {
      style.transform = "none";
    }
  }
  if (hasTransformOrigin) {
    const { originX = "50%", originY = "50%", originZ = 0 } = transformOrigin;
    style.transformOrigin = `${originX} ${originY} ${originZ}`;
  }
}
export {
  buildHTMLStyles
};
//# sourceMappingURL=dist-es-render-html-utils-build-styles.js.map
