import { s as v } from "../../../../../../../_virtual/stringifier.js";
import "./reducer.js";
import { __exports as c } from "../../../../../../../_virtual/reducer.js";
(function(n, l) {
  Object.defineProperty(l, "__esModule", {
    value: !0
  }), l.default = function(a, r, u) {
    var e = t(r, u);
    return r.type === "MathExpression" && (e = a + "(" + e + ")"), e;
  };
  var p = c, i = {
    "*": 0,
    "/": 0,
    "+": 1,
    "-": 1
  };
  function o(a, r) {
    if (r !== !1) {
      var u = Math.pow(10, r);
      return Math.round(a * u) / u;
    }
    return a;
  }
  function t(a, r) {
    switch (a.type) {
      case "MathExpression": {
        var u = a.left, e = a.right, s = a.operator, f = "";
        return u.type === "MathExpression" && i[s] < i[u.operator] ? f += "(" + t(u, r) + ")" : f += t(u, r), f += " " + a.operator + " ", e.type === "MathExpression" && i[s] < i[e.operator] ? f += "(" + t(e, r) + ")" : (e.type === "MathExpression" && s === "-" && ["+", "-"].includes(e.operator) && (e.operator = (0, p.flip)(e.operator)), f += t(e, r)), f;
      }
      case "Value":
        return o(a.value, r);
      case "CssVariable":
        return a.fallback ? "var(" + a.value + ", " + t(a.fallback, r) + ")" : "var(" + a.value + ")";
      case "Calc":
        return a.prefix ? "-" + a.prefix + "-calc(" + t(a.value, r) + ")" : "calc(" + t(a.value, r) + ")";
      default:
        return o(a.value, r) + a.unit;
    }
  }
  n.exports = l.default;
})(v, v.exports);
//# sourceMappingURL=stringifier.js.map
