"use client";
import { createSelector as u } from "../../../../reselect/dist/reselect.js";
import Q from "../../../../../_virtual/range.js";
import * as k from "../../../../victory-vendor/es/d3-scale.js";
import { selectChartLayout as h } from "../../context/chartLayoutContext.js";
import { checkDomainOfScale as Oe, getValueByDataKey as C, isCategoricalAxis as x, getDomainOfStackGroups as Ie, getStackedData as Ne } from "../../util/ChartUtils.js";
import { selectChartDataWithIndexesIfNotInPanorama as ee, selectChartDataWithIndexes as Pe } from "./dataSelectors.js";
import { isWellFormedNumberDomain as G, numericalDomainSpecifiedWithoutRequiringData as Se, parseNumericalUserDomain as Be } from "../../util/isDomainSpecifiedByUser.js";
import { upperFirst as re, hasDuplicate as te, isNumOrStr as ne, isNan as F, getPercentValue as _e, mathSign as ie } from "../../util/DataUtils.js";
import { isWellBehavedNumber as j } from "../../util/isWellBehavedNumber.js";
import { selectChartHeight as Ee, selectChartWidth as Me } from "./containerSelectors.js";
import { selectAllXAxes as ae, selectAllYAxes as le } from "./selectAllAxes.js";
import { selectChartOffsetInternal as A } from "./selectChartOffsetInternal.js";
import { selectBrushDimensions as ue, selectBrushSettings as oe } from "./brushSelectors.js";
import { selectBarCategoryGap as Ke, selectStackOffsetType as ce, selectChartName as Ge } from "./rootPropsSelectors.js";
import { selectRadiusAxis as de, selectAngleAxis as fe, selectRadiusAxisRange as je, selectAngleAxisRange as Re } from "./polarAxisSelectors.js";
import { pickAxisType as f } from "./pickAxisType.js";
import { pickAxisId as P } from "./pickAxisId.js";
import { combineAxisRangeWithReverse as ze } from "./combiners/combineAxisRangeWithReverse.js";
import { DEFAULT_Y_AXIS_WIDTH as X } from "../../util/Constants.js";
import { getStackSeriesIdentifier as Fe } from "../../util/stacks/getStackSeriesIdentifier.js";
import { selectTooltipAxis as Xe } from "./selectTooltipAxis.js";
import { combineDisplayedStackedData as Ye } from "./combiners/combineDisplayedStackedData.js";
import { isStacked as We } from "../types/StackedGraphicalItem.js";
import { getNiceTickValues as Ve, getTickValuesFixedDomain as Te } from "../../util/scale/getNiceTickValues.js";
function q(r, e) {
  var t = Object.keys(r);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(r);
    e && (n = n.filter(function(i) {
      return Object.getOwnPropertyDescriptor(r, i).enumerable;
    })), t.push.apply(t, n);
  }
  return t;
}
function N(r) {
  for (var e = 1; e < arguments.length; e++) {
    var t = arguments[e] != null ? arguments[e] : {};
    e % 2 ? q(Object(t), !0).forEach(function(n) {
      $e(r, n, t[n]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(t)) : q(Object(t)).forEach(function(n) {
      Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(t, n));
    });
  }
  return r;
}
function $e(r, e, t) {
  return (e = He(e)) in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r;
}
function He(r) {
  var e = Le(r, "string");
  return typeof e == "symbol" ? e : e + "";
}
function Le(r, e) {
  if (typeof r != "object" || !r) return r;
  var t = r[Symbol.toPrimitive];
  if (t !== void 0) {
    var n = t.call(r, e);
    if (typeof n != "object") return n;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (e === "string" ? String : Number)(r);
}
var R = [0, "auto"], Ue = {
  allowDataOverflow: !1,
  allowDecimals: !0,
  allowDuplicatedCategory: !0,
  angle: 0,
  dataKey: void 0,
  domain: void 0,
  height: 30,
  hide: !0,
  id: 0,
  includeHidden: !1,
  interval: "preserveEnd",
  minTickGap: 5,
  mirror: !1,
  name: void 0,
  orientation: "bottom",
  padding: {
    left: 0,
    right: 0
  },
  reversed: !1,
  scale: "auto",
  tick: !0,
  tickCount: 5,
  tickFormatter: void 0,
  ticks: void 0,
  type: "category",
  unit: void 0
}, Ze = (r, e) => r.cartesianAxis.xAxis[e], g = (r, e) => {
  var t = Ze(r, e);
  return t ?? Ue;
}, qe = {
  allowDataOverflow: !1,
  allowDecimals: !0,
  allowDuplicatedCategory: !0,
  angle: 0,
  dataKey: void 0,
  domain: R,
  hide: !0,
  id: 0,
  includeHidden: !1,
  interval: "preserveEnd",
  minTickGap: 5,
  mirror: !1,
  name: void 0,
  orientation: "left",
  padding: {
    top: 0,
    bottom: 0
  },
  reversed: !1,
  scale: "auto",
  tick: !0,
  tickCount: 5,
  tickFormatter: void 0,
  ticks: void 0,
  type: "number",
  unit: void 0,
  width: X
}, Je = (r, e) => r.cartesianAxis.yAxis[e], y = (r, e) => {
  var t = Je(r, e);
  return t ?? qe;
}, Qe = {
  domain: [0, "auto"],
  includeHidden: !1,
  reversed: !1,
  allowDataOverflow: !1,
  allowDuplicatedCategory: !1,
  dataKey: void 0,
  id: 0,
  name: "",
  range: [64, 64],
  scale: "auto",
  type: "number",
  unit: ""
}, Y = (r, e) => {
  var t = r.cartesianAxis.zAxis[e];
  return t ?? Qe;
}, m = (r, e, t) => {
  switch (e) {
    case "xAxis":
      return g(r, t);
    case "yAxis":
      return y(r, t);
    case "zAxis":
      return Y(r, t);
    case "angleAxis":
      return fe(r, t);
    case "radiusAxis":
      return de(r, t);
    default:
      throw new Error("Unexpected axis type: ".concat(e));
  }
}, er = (r, e, t) => {
  switch (e) {
    case "xAxis":
      return g(r, t);
    case "yAxis":
      return y(r, t);
    default:
      throw new Error("Unexpected axis type: ".concat(e));
  }
}, S = (r, e, t) => {
  switch (e) {
    case "xAxis":
      return g(r, t);
    case "yAxis":
      return y(r, t);
    case "angleAxis":
      return fe(r, t);
    case "radiusAxis":
      return de(r, t);
    default:
      throw new Error("Unexpected axis type: ".concat(e));
  }
}, rr = (r) => r.graphicalItems.cartesianItems.some((e) => e.type === "bar") || r.graphicalItems.polarItems.some((e) => e.type === "radialBar");
function tr(r, e) {
  return (t) => {
    switch (r) {
      case "xAxis":
        return "xAxisId" in t && t.xAxisId === e;
      case "yAxis":
        return "yAxisId" in t && t.yAxisId === e;
      case "zAxis":
        return "zAxisId" in t && t.zAxisId === e;
      case "angleAxis":
        return "angleAxisId" in t && t.angleAxisId === e;
      case "radiusAxis":
        return "radiusAxisId" in t && t.radiusAxisId === e;
      default:
        return !1;
    }
  };
}
var nr = (r) => r.graphicalItems.cartesianItems, ir = u([f, P], tr), ar = (r, e, t) => r.filter(t).filter((n) => e?.includeHidden === !0 ? !0 : !n.hide), O = u([nr, m, ir], ar), se = u([O], (r) => r.filter((e) => e.type === "area" || e.type === "bar").filter(We)), lr = (r) => r.filter((e) => !("stackId" in e) || e.stackId === void 0), ve = u([O], lr), ur = (r) => r.map((e) => e.data).filter(Boolean).flat(1), or = u([O], ur), cr = (r, e) => {
  var {
    chartData: t = [],
    dataStartIndex: n,
    dataEndIndex: i
  } = e;
  return r.length > 0 ? r : t.slice(n, i + 1);
}, W = u([or, ee], cr), dr = (r, e, t) => e?.dataKey != null ? r.map((n) => ({
  value: C(n, e.dataKey)
})) : t.length > 0 ? t.map((n) => n.dataKey).flatMap((n) => r.map((i) => ({
  value: C(i, n)
}))) : r.map((n) => ({
  value: n
})), B = u([W, m, O], dr);
function me(r, e) {
  switch (r) {
    case "xAxis":
      return e.direction === "x";
    case "yAxis":
      return e.direction === "y";
    default:
      return !1;
  }
}
function D(r) {
  return r.filter((e) => ne(e) || e instanceof Date).map(Number).filter((e) => F(e) === !1);
}
function fr(r, e, t) {
  return !t || typeof e != "number" || F(e) ? [] : t.length ? D(t.flatMap((n) => {
    var i = C(r, n.dataKey), a, l;
    if (Array.isArray(i) ? [a, l] = i : a = l = i, !(!j(a) || !j(l)))
      return [e - a, e + l];
  })) : [];
}
var sr = u([se, ee, Xe], Ye), vr = (r, e, t) => {
  var n = {}, i = e.reduce((a, l) => (l.stackId == null || (a[l.stackId] == null && (a[l.stackId] = []), a[l.stackId].push(l)), a), n);
  return Object.fromEntries(Object.entries(i).map((a) => {
    var [l, o] = a, c = o.map(Fe);
    return [l, {
      // @ts-expect-error getStackedData requires that the input is array of objects, Recharts does not test for that
      stackedData: Ne(r, c, t),
      graphicalItems: o
    }];
  }));
}, mr = u([sr, se, ce], vr), pr = (r, e, t) => {
  var {
    dataStartIndex: n,
    dataEndIndex: i
  } = e;
  if (t !== "zAxis") {
    var a = Ie(r, n, i);
    if (!(a != null && a[0] === 0 && a[1] === 0))
      return a;
  }
}, hr = u([mr, Pe, f], pr), Ar = (r, e, t, n, i) => t.length > 0 ? r.flatMap((a) => t.flatMap((l) => {
  var o, c, d = (o = n[l.id]) === null || o === void 0 ? void 0 : o.filter((b) => me(i, b)), v = C(a, (c = e.dataKey) !== null && c !== void 0 ? c : l.dataKey);
  return {
    value: v,
    errorDomain: fr(a, v, d)
  };
})).filter(Boolean) : e?.dataKey != null ? r.map((a) => ({
  value: C(a, e.dataKey),
  errorDomain: []
})) : r.map((a) => ({
  value: a,
  errorDomain: []
})), V = (r) => r.errorBars, pe = (r, e, t) => r.flatMap((n) => e[n.id]).filter(Boolean).filter((n) => me(t, n));
u([ve, V, f], pe);
var gr = u([W, m, ve, V, f], Ar);
function yr(r) {
  var {
    value: e
  } = r;
  if (ne(e) || e instanceof Date)
    return e;
}
var J = (r) => {
  var e = r.flatMap((n) => [n.value, n.errorDomain]).flat(1), t = D(e);
  if (t.length !== 0)
    return [Math.min(...t), Math.max(...t)];
}, br = (r, e, t) => {
  var n = r.map(yr).filter((i) => i != null);
  return t && (e.dataKey == null || e.allowDuplicatedCategory && te(n)) ? Q(0, r.length) : e.allowDuplicatedCategory ? n : Array.from(new Set(n));
}, he = (r) => {
  var e;
  if (r == null || !("domain" in r))
    return R;
  if (r.domain != null)
    return r.domain;
  if (r.ticks != null) {
    if (r.type === "number") {
      var t = D(r.ticks);
      return [Math.min(...t), Math.max(...t)];
    }
    if (r.type === "category")
      return r.ticks.map(String);
  }
  return (e = r?.domain) !== null && e !== void 0 ? e : R;
}, z = function() {
  for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
    t[n] = arguments[n];
  var i = t.filter(Boolean);
  if (i.length !== 0) {
    var a = i.flat(), l = Math.min(...a), o = Math.max(...a);
    return [l, o];
  }
}, Dr = (r) => r.referenceElements.dots, T = (r, e, t) => r.filter((n) => n.ifOverflow === "extendDomain").filter((n) => e === "xAxis" ? n.xAxisId === t : n.yAxisId === t), xr = u([Dr, f, P], T), wr = (r) => r.referenceElements.areas, kr = u([wr, f, P], T), Cr = (r) => r.referenceElements.lines, Or = u([Cr, f, P], T), Ir = (r, e) => {
  var t = D(r.map((n) => e === "xAxis" ? n.x : n.y));
  if (t.length !== 0)
    return [Math.min(...t), Math.max(...t)];
}, Nr = u(xr, f, Ir), Pr = (r, e) => {
  var t = D(r.flatMap((n) => [e === "xAxis" ? n.x1 : n.y1, e === "xAxis" ? n.x2 : n.y2]));
  if (t.length !== 0)
    return [Math.min(...t), Math.max(...t)];
}, Sr = u([kr, f], Pr), Br = (r, e) => {
  var t = D(r.map((n) => e === "xAxis" ? n.x : n.y));
  if (t.length !== 0)
    return [Math.min(...t), Math.max(...t)];
}, _r = u(Or, f, Br), Er = u(Nr, _r, Sr, (r, e, t) => z(r, t, e)), Mr = u([m], he), Kr = (r, e, t, n, i, a, l) => {
  var o = Se(e, r.allowDataOverflow);
  if (o != null)
    return o;
  var c = a === "vertical" && l === "xAxis" || a === "horizontal" && l === "yAxis", d = c ? z(t, i, J(n)) : z(i, J(n));
  return Be(e, d, r.allowDataOverflow);
}, Gr = u([m, Mr, hr, gr, Er, h, f], Kr), jr = [0, 1], Rr = (r, e, t, n, i, a, l) => {
  if (!((r == null || t == null || t.length === 0) && l === void 0)) {
    var {
      dataKey: o,
      type: c
    } = r, d = x(e, a);
    return d && o == null ? Q(0, t.length) : c === "category" ? br(n, r, d) : i === "expand" ? jr : l;
  }
}, $ = u([m, h, W, B, ce, f, Gr], Rr), zr = (r, e, t, n, i) => {
  if (r != null) {
    var {
      scale: a,
      type: l
    } = r;
    if (a === "auto")
      return e === "radial" && i === "radiusAxis" ? "band" : e === "radial" && i === "angleAxis" ? "linear" : l === "category" && n && (n.indexOf("LineChart") >= 0 || n.indexOf("AreaChart") >= 0 || n.indexOf("ComposedChart") >= 0 && !t) ? "point" : l === "category" ? "band" : "linear";
    if (typeof a == "string") {
      var o = "scale".concat(re(a));
      return o in k ? o : "point";
    }
  }
}, I = u([m, h, rr, Ge, f], zr);
function Fr(r) {
  if (r != null) {
    if (r in k)
      return k[r]();
    var e = "scale".concat(re(r));
    if (e in k)
      return k[e]();
  }
}
function Ae(r, e, t, n) {
  if (!(t == null || n == null)) {
    if (typeof r.scale == "function")
      return r.scale.copy().domain(t).range(n);
    var i = Fr(e);
    if (i != null) {
      var a = i.domain(t).range(n);
      return Oe(a), a;
    }
  }
}
var Xr = (r, e, t) => {
  var n = he(e);
  if (!(t !== "auto" && t !== "linear")) {
    if (e != null && e.tickCount && Array.isArray(n) && (n[0] === "auto" || n[1] === "auto") && G(r))
      return Ve(r, e.tickCount, e.allowDecimals);
    if (e != null && e.tickCount && e.type === "number" && G(r))
      return Te(r, e.tickCount, e.allowDecimals);
  }
}, H = u([$, S, I], Xr), Yr = (r, e, t, n) => {
  if (
    /*
     * Angle axis for some reason uses nice ticks when rendering axis tick labels,
     * but doesn't use nice ticks for extending domain like all the other axes do.
     * Not really sure why? Is there a good reason,
     * or is it just because someone added support for nice ticks to the other axes and forgot this one?
     */
    n !== "angleAxis" && r?.type === "number" && G(e) && Array.isArray(t) && t.length > 0
  ) {
    var i = e[0], a = t[0], l = e[1], o = t[t.length - 1];
    return [Math.min(i, a), Math.max(l, o)];
  }
  return e;
}, Wr = u([m, $, H, f], Yr), Vr = u(B, m, (r, e) => {
  if (!(!e || e.type !== "number")) {
    var t = 1 / 0, n = Array.from(D(r.map((o) => o.value))).sort((o, c) => o - c);
    if (n.length < 2)
      return 1 / 0;
    var i = n[n.length - 1] - n[0];
    if (i === 0)
      return 1 / 0;
    for (var a = 0; a < n.length - 1; a++) {
      var l = n[a + 1] - n[a];
      t = Math.min(t, l);
    }
    return t / i;
  }
}), ge = u(Vr, h, Ke, A, (r, e, t, n) => n, (r, e, t, n, i) => {
  if (!j(r))
    return 0;
  var a = e === "vertical" ? n.height : n.width;
  if (i === "gap")
    return r * a / 2;
  if (i === "no-gap") {
    var l = _e(t, r * a), o = r * a / 2;
    return o - l - (o - l) / a * l;
  }
  return 0;
}), Tr = (r, e) => {
  var t = g(r, e);
  return t == null || typeof t.padding != "string" ? 0 : ge(r, "xAxis", e, t.padding);
}, $r = (r, e) => {
  var t = y(r, e);
  return t == null || typeof t.padding != "string" ? 0 : ge(r, "yAxis", e, t.padding);
}, Hr = u(g, Tr, (r, e) => {
  var t, n;
  if (r == null)
    return {
      left: 0,
      right: 0
    };
  var {
    padding: i
  } = r;
  return typeof i == "string" ? {
    left: e,
    right: e
  } : {
    left: ((t = i.left) !== null && t !== void 0 ? t : 0) + e,
    right: ((n = i.right) !== null && n !== void 0 ? n : 0) + e
  };
}), Lr = u(y, $r, (r, e) => {
  var t, n;
  if (r == null)
    return {
      top: 0,
      bottom: 0
    };
  var {
    padding: i
  } = r;
  return typeof i == "string" ? {
    top: e,
    bottom: e
  } : {
    top: ((t = i.top) !== null && t !== void 0 ? t : 0) + e,
    bottom: ((n = i.bottom) !== null && n !== void 0 ? n : 0) + e
  };
}), Ur = u([A, Hr, ue, oe, (r, e, t) => t], (r, e, t, n, i) => {
  var {
    padding: a
  } = n;
  return i ? [a.left, t.width - a.right] : [r.left + e.left, r.left + r.width - e.right];
}), Zr = u([A, h, Lr, ue, oe, (r, e, t) => t], (r, e, t, n, i, a) => {
  var {
    padding: l
  } = i;
  return a ? [n.height - l.bottom, l.top] : e === "horizontal" ? [r.top + r.height - t.bottom, r.top + t.top] : [r.top + t.top, r.top + r.height - t.bottom];
}), _ = (r, e, t, n) => {
  var i;
  switch (e) {
    case "xAxis":
      return Ur(r, t, n);
    case "yAxis":
      return Zr(r, t, n);
    case "zAxis":
      return (i = Y(r, t)) === null || i === void 0 ? void 0 : i.range;
    case "angleAxis":
      return Re(r);
    case "radiusAxis":
      return je(r, t);
    default:
      return;
  }
}, ye = u([m, _], ze), E = u([m, I, Wr, ye], Ae);
u([O, V, f], pe);
function be(r, e) {
  return r.id < e.id ? -1 : r.id > e.id ? 1 : 0;
}
var M = (r, e) => e, K = (r, e, t) => t, qr = u(ae, M, K, (r, e, t) => r.filter((n) => n.orientation === e).filter((n) => n.mirror === t).sort(be)), Jr = u(le, M, K, (r, e, t) => r.filter((n) => n.orientation === e).filter((n) => n.mirror === t).sort(be)), De = (r, e) => ({
  width: r.width,
  height: e.height
}), Qr = (r, e) => {
  var t = typeof e.width == "number" ? e.width : X;
  return {
    width: t,
    height: r.height
  };
};
u(A, g, De);
var et = (r, e, t) => {
  switch (e) {
    case "top":
      return r.top;
    case "bottom":
      return t - r.bottom;
    default:
      return 0;
  }
}, rt = (r, e, t) => {
  switch (e) {
    case "left":
      return r.left;
    case "right":
      return t - r.right;
    default:
      return 0;
  }
}, tt = u(Ee, A, qr, M, K, (r, e, t, n, i) => {
  var a = {}, l;
  return t.forEach((o) => {
    var c = De(e, o);
    l == null && (l = et(e, n, r));
    var d = n === "top" && !i || n === "bottom" && i;
    a[o.id] = l - Number(d) * c.height, l += (d ? -1 : 1) * c.height;
  }), a;
}), nt = u(Me, A, Jr, M, K, (r, e, t, n, i) => {
  var a = {}, l;
  return t.forEach((o) => {
    var c = Qr(e, o);
    l == null && (l = rt(e, n, r));
    var d = n === "left" && !i || n === "right" && i;
    a[o.id] = l - Number(d) * c.width, l += (d ? -1 : 1) * c.width;
  }), a;
}), it = (r, e) => {
  var t = g(r, e);
  if (t != null)
    return tt(r, t.orientation, t.mirror);
};
u([A, g, it, (r, e) => e], (r, e, t, n) => {
  if (e != null) {
    var i = t?.[n];
    return i == null ? {
      x: r.left,
      y: 0
    } : {
      x: r.left,
      y: i
    };
  }
});
var at = (r, e) => {
  var t = y(r, e);
  if (t != null)
    return nt(r, t.orientation, t.mirror);
};
u([A, y, at, (r, e) => e], (r, e, t, n) => {
  if (e != null) {
    var i = t?.[n];
    return i == null ? {
      x: 0,
      y: r.top
    } : {
      x: i,
      y: r.top
    };
  }
});
u(A, y, (r, e) => {
  var t = typeof e.width == "number" ? e.width : X;
  return {
    width: t,
    height: r.height
  };
});
var lt = (r, e, t, n) => {
  if (t != null) {
    var {
      allowDuplicatedCategory: i,
      type: a,
      dataKey: l
    } = t, o = x(r, n), c = e.map((d) => d.value);
    if (l && o && a === "category" && i && te(c))
      return c;
  }
}, L = u([h, B, m, f], lt), ut = (r, e, t, n) => {
  if (!(t == null || t.dataKey == null)) {
    var {
      type: i,
      scale: a
    } = t, l = x(r, n);
    if (l && (i === "number" || a !== "auto"))
      return e.map((o) => o.value);
  }
}, U = u([h, B, S, f], ut);
u([h, er, I, E, L, U, _, H, f], (r, e, t, n, i, a, l, o, c) => {
  if (e == null)
    return null;
  var d = x(r, c);
  return {
    angle: e.angle,
    interval: e.interval,
    minTickGap: e.minTickGap,
    orientation: e.orientation,
    tick: e.tick,
    tickCount: e.tickCount,
    tickFormatter: e.tickFormatter,
    ticks: e.ticks,
    type: e.type,
    unit: e.unit,
    axisType: c,
    categoricalDomain: a,
    duplicateDomain: i,
    isCategorical: d,
    niceTicks: o,
    range: l,
    realScaleType: t,
    scale: n
  };
});
var ot = (r, e, t, n, i, a, l, o, c) => {
  if (!(e == null || n == null)) {
    var d = x(r, c), {
      type: v,
      ticks: b,
      tickCount: xe
    } = e, we = t === "scaleBand" && typeof n.bandwidth == "function" ? n.bandwidth() / 2 : 2, p = v === "category" && n.bandwidth ? n.bandwidth() / we : 0;
    p = c === "angleAxis" && a != null && a.length >= 2 ? ie(a[0] - a[1]) * 2 * p : p;
    var Z = b || i;
    if (Z) {
      var ke = Z.map((s, w) => {
        var Ce = l ? l.indexOf(s) : s;
        return {
          index: w,
          // If the scaleContent is not a number, the coordinate will be NaN.
          // That could be the case for example with a PointScale and a string as domain.
          coordinate: n(Ce) + p,
          value: s,
          offset: p
        };
      });
      return ke.filter((s) => !F(s.coordinate));
    }
    return d && o ? o.map((s, w) => ({
      coordinate: n(s) + p,
      value: s,
      index: w,
      offset: p
    })) : n.ticks ? n.ticks(xe).map((s) => ({
      coordinate: n(s) + p,
      value: s,
      offset: p
    })) : n.domain().map((s, w) => ({
      coordinate: n(s) + p,
      value: l ? l[s] : s,
      index: w,
      offset: p
    }));
  }
};
u([h, S, I, E, H, _, L, U, f], ot);
var ct = (r, e, t, n, i, a, l) => {
  if (!(e == null || t == null || n == null || n[0] === n[1])) {
    var o = x(r, l), {
      tickCount: c
    } = e, d = 0;
    return d = l === "angleAxis" && n?.length >= 2 ? ie(n[0] - n[1]) * 2 * d : d, o && a ? a.map((v, b) => ({
      coordinate: t(v) + d,
      value: v,
      index: b,
      offset: d
    })) : t.ticks ? t.ticks(c).map((v) => ({
      coordinate: t(v) + d,
      value: v,
      offset: d
    })) : t.domain().map((v, b) => ({
      coordinate: t(v) + d,
      value: i ? i[v] : v,
      index: b,
      offset: d
    }));
  }
};
u([h, S, E, _, L, U, f], ct);
u(m, E, (r, e) => {
  if (!(r == null || e == null))
    return N(N({}, r), {}, {
      scale: e
    });
});
var dt = u([m, I, $, ye], Ae);
u((r, e, t) => Y(r, t), dt, (r, e) => {
  if (!(r == null || e == null))
    return N(N({}, r), {}, {
      scale: e
    });
});
u([h, ae, le], (r, e, t) => {
  switch (r) {
    case "horizontal":
      return e.some((n) => n.reversed) ? "right-to-left" : "left-to-right";
    case "vertical":
      return t.some((n) => n.reversed) ? "bottom-to-top" : "top-to-bottom";
    // TODO: make this better. For now, right arrow triggers "forward", left arrow "back"
    // however, the tooltip moves an unintuitive direction because of how the indices are rendered
    case "centric":
    case "radial":
      return "left-to-right";
    default:
      return;
  }
});
export {
  Ar as combineAppliedNumericalValuesIncludingErrorValues,
  dr as combineAppliedValues,
  Pr as combineAreasDomain,
  Rr as combineAxisDomain,
  Yr as combineAxisDomainWithNiceTicks,
  ot as combineAxisTicks,
  ut as combineCategoricalDomain,
  cr as combineDisplayedData,
  pr as combineDomainOfStackGroups,
  Ir as combineDotsDomain,
  lt as combineDuplicateDomain,
  ct as combineGraphicalItemTicks,
  ur as combineGraphicalItemsData,
  ar as combineGraphicalItemsSettings,
  Br as combineLinesDomain,
  Xr as combineNiceTicks,
  Kr as combineNumericalDomain,
  zr as combineRealScaleType,
  Ae as combineScaleFunction,
  vr as combineStackGroups,
  Ur as combineXAxisRange,
  Zr as combineYAxisRange,
  lr as filterGraphicalNotStackedItems,
  T as filterReferenceElements,
  he as getDomainDefinition,
  fr as getErrorDomainByDataKey,
  Ue as implicitXAxis,
  qe as implicitYAxis,
  Qe as implicitZAxis,
  me as isErrorBarRelevantForAxisType,
  tr as itemAxisPredicate,
  z as mergeDomains,
  gr as selectAllAppliedNumericalValuesIncludingErrorValues,
  B as selectAllAppliedValues,
  V as selectAllErrorBarSettings,
  tt as selectAllXAxesOffsetSteps,
  nt as selectAllYAxesOffsetSteps,
  $ as selectAxisDomain,
  Wr as selectAxisDomainIncludingNiceTicks,
  _ as selectAxisRange,
  ye as selectAxisRangeWithReverse,
  E as selectAxisScale,
  S as selectAxisSettings,
  m as selectBaseAxis,
  Tr as selectCalculatedXAxisPadding,
  $r as selectCalculatedYAxisPadding,
  or as selectCartesianGraphicalItemsData,
  O as selectCartesianItemsSettings,
  U as selectCategoricalDomain,
  W as selectDisplayedData,
  sr as selectDisplayedStackedData,
  Mr as selectDomainDefinition,
  hr as selectDomainOfStackGroups,
  L as selectDuplicateDomain,
  rr as selectHasBar,
  H as selectNiceTicks,
  Gr as selectNumericalDomain,
  I as selectRealScaleType,
  wr as selectReferenceAreas,
  kr as selectReferenceAreasByAxis,
  Dr as selectReferenceDots,
  xr as selectReferenceDotsByAxis,
  Cr as selectReferenceLines,
  Or as selectReferenceLinesByAxis,
  Vr as selectSmallestDistanceBetweenValues,
  mr as selectStackGroups,
  se as selectStackedCartesianItemsSettings,
  nr as selectUnfilteredCartesianItems,
  g as selectXAxisSettings,
  Ze as selectXAxisSettingsNoDefaults,
  y as selectYAxisSettings,
  Je as selectYAxisSettingsNoDefaults,
  Y as selectZAxisSettings
};
