"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const cssVariablesConversion = require("../../render/dom/utils/css-variables-conversion.js");
const index = require("../../../../../../../style-value-types@5.0.0/node_modules/style-value-types/dist/es/complex/index.js");
const mix = require("../../../../../../../popmotion@11.0.3/node_modules/popmotion/dist/es/utils/mix.js");
var varToken = "_$css";
var correctBoxShadow = {
  correct: function(latest, _a) {
    var treeScale = _a.treeScale, projectionDelta = _a.projectionDelta;
    var original = latest;
    var containsCSSVariables = latest.includes("var(");
    var cssVariables = [];
    if (containsCSSVariables) {
      latest = latest.replace(cssVariablesConversion.cssVariableRegex, function(match) {
        cssVariables.push(match);
        return varToken;
      });
    }
    var shadow = index.complex.parse(latest);
    if (shadow.length > 5)
      return original;
    var template = index.complex.createTransformer(latest);
    var offset = typeof shadow[0] !== "number" ? 1 : 0;
    var xScale = projectionDelta.x.scale * treeScale.x;
    var yScale = projectionDelta.y.scale * treeScale.y;
    shadow[0 + offset] /= xScale;
    shadow[1 + offset] /= yScale;
    var averageScale = mix.mix(xScale, yScale, 0.5);
    if (typeof shadow[2 + offset] === "number")
      shadow[2 + offset] /= averageScale;
    if (typeof shadow[3 + offset] === "number")
      shadow[3 + offset] /= averageScale;
    var output = template(shadow);
    if (containsCSSVariables) {
      var i_1 = 0;
      output = output.replace(varToken, function() {
        var cssVariable = cssVariables[i_1];
        i_1++;
        return cssVariable;
      });
    }
    return output;
  }
};
exports.correctBoxShadow = correctBoxShadow;
//# sourceMappingURL=scale-box-shadow.js.map
