"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const number = require("./dist-es-utils-mix-number.cjs");
const units = require("./dist-es-value-types-numbers-units.cjs");
const deltaApply = require("./dist-es-projection-geometry-delta-apply.cjs");
function removePointDelta(point, translate, scale, originPoint, boxScale) {
  point -= translate;
  point = deltaApply.scalePoint(point, 1 / scale, originPoint);
  if (boxScale !== void 0) {
    point = deltaApply.scalePoint(point, 1 / boxScale, originPoint);
  }
  return point;
}
function removeAxisDelta(axis, translate = 0, scale = 1, origin = 0.5, boxScale, originAxis = axis, sourceAxis = axis) {
  if (units.percent.test(translate)) {
    translate = parseFloat(translate);
    const relativeProgress = number.mixNumber(sourceAxis.min, sourceAxis.max, translate / 100);
    translate = relativeProgress - sourceAxis.min;
  }
  if (typeof translate !== "number")
    return;
  let originPoint = number.mixNumber(originAxis.min, originAxis.max, origin);
  if (axis === originAxis)
    originPoint -= translate;
  axis.min = removePointDelta(axis.min, translate, scale, originPoint, boxScale);
  axis.max = removePointDelta(axis.max, translate, scale, originPoint, boxScale);
}
function removeAxisTransforms(axis, transforms, [key, scaleKey, originKey], origin, sourceAxis) {
  removeAxisDelta(axis, transforms[key], transforms[scaleKey], transforms[originKey], transforms.scale, origin, sourceAxis);
}
const xKeys = ["x", "scaleX", "originX"];
const yKeys = ["y", "scaleY", "originY"];
function removeBoxTransforms(box, transforms, originBox, sourceBox) {
  removeAxisTransforms(box.x, transforms, xKeys, originBox ? originBox.x : void 0, sourceBox ? sourceBox.x : void 0);
  removeAxisTransforms(box.y, transforms, yKeys, originBox ? originBox.y : void 0, sourceBox ? sourceBox.y : void 0);
}
exports.removeAxisDelta = removeAxisDelta;
exports.removeAxisTransforms = removeAxisTransforms;
exports.removeBoxTransforms = removeBoxTransforms;
exports.removePointDelta = removePointDelta;
//# sourceMappingURL=dist-es-projection-geometry-delta-remove.cjs.map
