import { mixNumber as g } from "../../utils/mix/number.es.js";
import { hasTransform as _ } from "../utils/has-transform.es.js";
function p(t, n, o) {
  const l = t - o, i = n * l;
  return o + i;
}
function r(t, n, o, l, i) {
  return i !== void 0 && (t = p(t, i, l)), p(t, o, l) + n;
}
function u(t, n = 0, o = 1, l, i) {
  t.min = r(t.min, n, o, l, i), t.max = r(t.max, n, o, l, i);
}
function d(t, { x: n, y: o }) {
  u(t.x, n.translate, n.scale, n.originPoint), u(t.y, o.translate, o.scale, o.originPoint);
}
const a = 0.999999999999, m = 1.0000000000001;
function T(t, n, o, l = !1) {
  var y;
  const i = o.length;
  if (!i)
    return;
  n.x = n.y = 1;
  let s, f;
  for (let e = 0; e < i; e++) {
    s = o[e], f = s.projectionDelta;
    const { visualElement: c } = s.options;
    c && c.props.style && c.props.style.display === "contents" || (l && s.options.layoutScroll && s.scroll && s !== s.root && (x(t.x, -s.scroll.offset.x), x(t.y, -s.scroll.offset.y)), f && (n.x *= f.x.scale, n.y *= f.y.scale, d(t, f)), l && _(s.latestValues) && D(t, s.latestValues, (y = s.layout) == null ? void 0 : y.layoutBox));
  }
  n.x < m && n.x > a && (n.x = 1), n.y < m && n.y > a && (n.y = 1);
}
function x(t, n) {
  t.min += n, t.max += n;
}
function A(t, n, o, l, i = 0.5) {
  const s = g(t.min, t.max, i);
  u(t, n, o, s, l);
}
function E(t, n) {
  return typeof t == "string" ? parseFloat(t) / 100 * (n.max - n.min) : t;
}
function D(t, n, o) {
  const l = o ?? t;
  A(t.x, E(n.x, l.x), n.scaleX, n.scale, n.originX), A(t.y, E(n.y, l.y), n.scaleY, n.scale, n.originY);
}
export {
  u as applyAxisDelta,
  d as applyBoxDelta,
  r as applyPointDelta,
  T as applyTreeDeltas,
  p as scalePoint,
  A as transformAxis,
  D as transformBox,
  x as translateAxis
};
//# sourceMappingURL=delta-apply.es.js.map
