%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/ai.rezakurnia.com/zh-router-frontend/node_modules/recharts/lib/cartesian/
Upload File :
Create Path :
Current File : /home2/rezakur1/ai.rezakurnia.com/zh-router-frontend/node_modules/recharts/lib/cartesian/Bar.js

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Bar = void 0;
exports.computeBarRectangles = computeBarRectangles;
exports.defaultBarProps = void 0;
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _omit = _interopRequireDefault(require("es-toolkit/compat/omit"));
var _clsx = require("clsx");
var _Layer = require("../container/Layer");
var _LabelList = require("../component/LabelList");
var _DataUtils = require("../util/DataUtils");
var _ChartUtils = require("../util/ChartUtils");
var _types = require("../util/types");
var _BarUtils = require("../util/BarUtils");
var _tooltipContext = require("../context/tooltipContext");
var _SetTooltipEntrySettings = require("../state/SetTooltipEntrySettings");
var _ErrorBarContext = require("../context/ErrorBarContext");
var _GraphicalItemClipPath = require("./GraphicalItemClipPath");
var _chartLayoutContext = require("../context/chartLayoutContext");
var _barSelectors = require("../state/selectors/barSelectors");
var _hooks = require("../state/hooks");
var _PanoramaContext = require("../context/PanoramaContext");
var _tooltipSelectors = require("../state/selectors/tooltipSelectors");
var _SetLegendPayload = require("../state/SetLegendPayload");
var _resolveDefaultProps = require("../util/resolveDefaultProps");
var _RegisterGraphicalItemId = require("../context/RegisterGraphicalItemId");
var _SetGraphicalItem = require("../state/SetGraphicalItem");
var _svgPropertiesNoEvents = require("../util/svgPropertiesNoEvents");
var _AnimatedItems = require("../animation/AnimatedItems");
var _matchBy = require("../animation/matchBy");
var _ZIndexLayer = require("../zIndex/ZIndexLayer");
var _DefaultZIndexes = require("../zIndex/DefaultZIndexes");
var _getZIndexFromUnknown = require("../zIndex/getZIndexFromUnknown");
var _propsAreEqual = require("../util/propsAreEqual");
var _useCells = require("../util/useCells");
var _BarStack = require("./BarStack");
var _useBackwardsCompatibleTheme = require("../theme/useBackwardsCompatibleTheme");
var _useGraphicalItemIdentity = require("../theme/useGraphicalItemIdentity");
var _useEffectiveDataKey = require("../util/useEffectiveDataKey");
var _dataEntryStyles = require("../theme/dataEntryStyles");
var _activeStyles = require("../theme/activeStyles");
var _fillDefinitions = require("../fill/fillDefinitions");
var _labelTheme = require("../theme/labelTheme");
var _excluded = ["onMouseEnter", "onMouseLeave", "onClick"],
  _excluded2 = ["value", "background", "tooltipPosition"],
  _excluded3 = ["id"],
  _excluded4 = ["onMouseEnter", "onClick", "onMouseLeave"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
/**
 * @public
 */

/**
 * @public
 */

/**
 * The type is exported only so that TypeScript can name it in the declaration files of projects
 * that wrap Recharts components. It is not part of the public API and may change in any release.
 *
 * @internal
 */

/**
 * The type is exported only so that TypeScript can name it in the declaration files of projects
 * that wrap Recharts components. It is not part of the public API and may change in any release.
 *
 * @internal
 */

/**
 * @public
 */

/**
 * Props with `fill` resolved to the base color string. Theme and color logic work with these.
 */

var computeLegendPayloadFromBarData = (props, fillObject) => {
  var dataKey = props.dataKey,
    name = props.name,
    fill = props.fill,
    legendType = props.legendType,
    hide = props.hide;
  return [{
    inactive: hide,
    dataKey,
    type: legendType,
    color: fill,
    fill: fillObject,
    value: (0, _ChartUtils.getTooltipNameProp)(name, dataKey),
    payload: props
  }];
};
var SetBarTooltipEntrySettings = /*#__PURE__*/React.memo(_ref => {
  var dataKey = _ref.dataKey,
    stroke = _ref.stroke,
    strokeWidth = _ref.strokeWidth,
    fill = _ref.fill,
    name = _ref.name,
    hide = _ref.hide,
    unit = _ref.unit,
    formatter = _ref.formatter,
    tooltipType = _ref.tooltipType,
    id = _ref.id,
    unthemedColors = _ref.unthemedColors;
  var tooltipEntrySettings = {
    dataDefinedOnItem: undefined,
    getPosition: _DataUtils.noop,
    getEntryColor: entry => (0, _dataEntryStyles.getEntryColor)(entry, fill, stroke, unthemedColors),
    settings: {
      stroke,
      strokeWidth,
      fill,
      dataKey,
      nameKey: undefined,
      name: (0, _ChartUtils.getTooltipNameProp)(name, dataKey),
      hide,
      type: tooltipType,
      color: fill,
      unit,
      formatter,
      graphicalItemId: id
    }
  };
  return /*#__PURE__*/React.createElement(_SetTooltipEntrySettings.SetTooltipEntrySettings, {
    tooltipEntrySettings: tooltipEntrySettings
  });
});
var defaultLegacyBarBackgroundProps = {
  fill: '#eee'
};
function BarBackground(props) {
  var activeIndex = (0, _hooks.useAppSelector)(_tooltipSelectors.selectActiveTooltipIndex);
  var data = props.data,
    dataKey = props.dataKey,
    backgroundFromProps = props.background,
    allOtherBarProps = props.allOtherBarProps;
  var backgroundProps = (0, _svgPropertiesNoEvents.svgPropertiesNoEventsFromUnknown)(backgroundFromProps);
  var backgroundThemeProps = (0, _useBackwardsCompatibleTheme.useBackwardsCompatibleTheme)(theme => theme.barBackground, backgroundProps !== null && backgroundProps !== void 0 ? backgroundProps : {}, defaultLegacyBarBackgroundProps);
  var onMouseEnterFromProps = allOtherBarProps.onMouseEnter,
    onMouseLeaveFromProps = allOtherBarProps.onMouseLeave,
    onItemClickFromProps = allOtherBarProps.onClick,
    restOfAllOtherProps = _objectWithoutProperties(allOtherBarProps, _excluded);
  var onMouseEnterFromContext = (0, _tooltipContext.useMouseEnterItemDispatch)(onMouseEnterFromProps, dataKey, allOtherBarProps.id);
  var onMouseLeaveFromContext = (0, _tooltipContext.useMouseLeaveItemDispatch)(onMouseLeaveFromProps);
  var onClickFromContext = (0, _tooltipContext.useMouseClickItemDispatch)(onItemClickFromProps, dataKey, allOtherBarProps.id);
  if (!backgroundFromProps || data == null) {
    return null;
  }
  return /*#__PURE__*/React.createElement(_ZIndexLayer.ZIndexLayer, {
    zIndex: (0, _getZIndexFromUnknown.getZIndexFromUnknown)(backgroundFromProps, _DefaultZIndexes.DefaultZIndexes.barBackground)
  }, data.map((entry, i) => {
    var value = entry.value,
      backgroundFromDataEntry = entry.background,
      tooltipPosition = entry.tooltipPosition,
      rest = _objectWithoutProperties(entry, _excluded2);
    if (!backgroundFromDataEntry) {
      return null;
    }
    var onMouseEnter = onMouseEnterFromContext(entry, entry.originalDataIndex);
    var onMouseLeave = onMouseLeaveFromContext(entry, entry.originalDataIndex);
    var onClick = onClickFromContext(entry, entry.originalDataIndex);

    // @ts-expect-error backgroundProps is contributing unknown props
    var barRectangleProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
      option: backgroundFromProps,
      isActive: String(entry.originalDataIndex) === activeIndex
    }, (0, _dataEntryStyles.omitEntrySvgProps)(rest)), backgroundThemeProps), backgroundFromDataEntry), backgroundProps), (0, _types.adaptEventsOfChild)(restOfAllOtherProps, entry, entry.originalDataIndex)), {}, {
      onMouseEnter,
      onMouseLeave,
      onClick,
      dataKey,
      index: i,
      className: 'recharts-bar-background-rectangle'
    });
    return /*#__PURE__*/React.createElement(_BarUtils.BarRectangle, _extends({
      key: "background-bar-".concat(i)
    }, barRectangleProps));
  }));
}
function BarLabelListProvider(_ref2) {
  var showLabels = _ref2.showLabels,
    children = _ref2.children,
    rects = _ref2.rects,
    fill = _ref2.fill,
    stroke = _ref2.stroke,
    unthemedColors = _ref2.unthemedColors;
  // The same color as in Tooltip and Legend.
  var labelColors = React.useMemo(() => ({
    hasFilledShapes: true,
    getShapeColors: index => {
      var _rects$index;
      return (0, _dataEntryStyles.getEntryShapeColors)(rects === null || rects === void 0 || (_rects$index = rects[index]) === null || _rects$index === void 0 ? void 0 : _rects$index.payload, fill, stroke, unthemedColors);
    }
  }), [rects, fill, stroke, unthemedColors]);
  var labelListEntries = rects === null || rects === void 0 ? void 0 : rects.map(entry => {
    var viewBox = {
      x: entry.x,
      y: entry.y,
      width: entry.width,
      lowerWidth: entry.width,
      upperWidth: entry.width,
      height: entry.height
    };
    return _objectSpread(_objectSpread({}, viewBox), {}, {
      value: entry.value,
      payload: entry.payload,
      parentViewBox: entry.parentViewBox,
      viewBox,
      fill: entry.fill,
      // rects skip bars without a size, so the position in rects is not the index of the data entry
      originalDataIndex: entry.originalDataIndex
    });
  });
  return /*#__PURE__*/React.createElement(_LabelList.CartesianLabelListContextProvider, {
    value: showLabels ? labelListEntries : undefined
  }, /*#__PURE__*/React.createElement(_labelTheme.DataLabelColorsContextProvider, {
    value: labelColors
  }, children));
}
function BarRectangleWithActiveState(props) {
  var shape = props.shape,
    activeBar = props.activeBar,
    baseProps = props.baseProps,
    entryStyleOverrides = props.entryStyleOverrides,
    themedActiveStyles = props.themedActiveStyles,
    entry = props.entry,
    index = props.index,
    dataKey = props.dataKey;
  var activeIndex = (0, _hooks.useAppSelector)(_tooltipSelectors.selectActiveTooltipIndex);
  var activeDataKey = (0, _hooks.useAppSelector)(_tooltipSelectors.selectActiveTooltipDataKey);
  /*
   * Bars support stacking, meaning that there can be multiple bars at the same x value.
   * With Tooltip shared=false we only want to highlight the currently active Bar, not all.
   *
   * Also, if the tooltip is shared, we want to highlight all bars at the same x value
   * regardless of the dataKey.
   *
   * With shared Tooltip, the activeDataKey is undefined.
   *
   * We use entry.originalDataIndex to match against activeIndex because the render index parameter
   * is based on the filtered array, while activeIndex is based on the pre-filter displayed data slice.
   * When entries are filtered out (for example null/zero-dimension bars), these indices can differ.
   */
  var isActive = activeBar && String(entry.originalDataIndex) === activeIndex && (activeDataKey == null || dataKey === activeDataKey);
  var isAnotherBarActive = activeIndex != null && (String(entry.originalDataIndex) !== activeIndex || activeDataKey != null && dataKey !== activeDataKey);
  var _useState = (0, _react.useState)(false),
    _useState2 = _slicedToArray(_useState, 2),
    stayInLayer = _useState2[0],
    setStayInLayer = _useState2[1];
  var _useState3 = (0, _react.useState)(false),
    _useState4 = _slicedToArray(_useState3, 2),
    hasMountedActive = _useState4[0],
    setHasMountedActive = _useState4[1];
  (0, _react.useEffect)(() => {
    var rafId;
    if (isActive) {
      // 1. Enter the layer immediately
      setStayInLayer(true);

      // 2. Wait for the browser to paint the "inactive" state in the new layer,
      // then switch to active to trigger the CSS transition (width grow).
      rafId = requestAnimationFrame(() => {
        setHasMountedActive(true);
      });
    } else {
      setHasMountedActive(false);
      if (isAnotherBarActive) {
        setStayInLayer(false);
      }
    }
    return () => {
      cancelAnimationFrame(rafId);
    };
  }, [isActive, isAnotherBarActive]);
  var handleTransitionEnd = (0, _react.useCallback)(() => {
    // 4. Leave the layer only when the exit transition finishes
    if (!isActive) {
      setStayInLayer(false);
    }
  }, [isActive]);

  // Determine props:
  // - If entering (isActive=true) but not mounted yet (hasMountedActive=false), pass isActive=false (inactive size).
  // - If exiting (isActive=false), pass isActive=false (inactive size).
  var isVisuallyActive = isActive && hasMountedActive;

  // Render in ZIndexLayer if active OR if we are waiting for exit transition
  var shouldRenderInLayer = isActive || stayInLayer;
  var option;
  if (isActive) {
    if (activeBar === true) {
      option = shape;
    } else {
      option = activeBar;
    }
  } else {
    option = shape;
  }
  /*
   * Follows `isVisuallyActive` so that the theme styles change together with the `isActive` prop of the shape.
   *
   * `activeBar={true}` renders the `shape`, so a custom `shape` is a custom active bar too,
   * and it decides on its own how the active state looks like.
   */
  var activeStyleOverrides = isVisuallyActive ? (0, _activeStyles.getActiveStyleOverrides)(option === _BarUtils.defaultBarShape ? true : option, themedActiveStyles, entry) : undefined;
  var content = /*#__PURE__*/React.createElement(_BarUtils.BarRectangle, _extends({}, baseProps, {
    name: baseProps.name == null ? undefined : String(baseProps.name)
  }, entryStyleOverrides, entry, activeStyleOverrides, {
    isActive: isVisuallyActive,
    option: option,
    index: index,
    dataKey: dataKey,
    animationElapsedTime: props.animationElapsedTime,
    isAnimating: props.isAnimating,
    isEntrance: props.isEntrance,
    onTransitionEnd: handleTransitionEnd
  }));
  if (shouldRenderInLayer) {
    return /*#__PURE__*/React.createElement(_ZIndexLayer.ZIndexLayer, {
      zIndex: _DefaultZIndexes.DefaultZIndexes.activeBar
    }, /*#__PURE__*/React.createElement(_BarStack.BarStackClipLayer, {
      index: entry.originalDataIndex
    }, content));
  }
  return content;
}
function BarRectangleNeverActive(props) {
  var shape = props.shape,
    baseProps = props.baseProps,
    entryStyleOverrides = props.entryStyleOverrides,
    entry = props.entry,
    index = props.index,
    dataKey = props.dataKey;
  return /*#__PURE__*/React.createElement(_BarUtils.BarRectangle, _extends({}, baseProps, {
    name: baseProps.name == null ? undefined : String(baseProps.name)
  }, entryStyleOverrides, entry, {
    isActive: false,
    option: shape,
    index: index,
    dataKey: dataKey,
    animationElapsedTime: props.animationElapsedTime,
    isAnimating: props.isAnimating,
    isEntrance: props.isEntrance
  }));
}
function BarRectangles(_ref3) {
  var _svgPropertiesNoEvent;
  var data = _ref3.data,
    props = _ref3.props,
    animationElapsedTime = _ref3.animationElapsedTime,
    isAnimating = _ref3.isAnimating,
    isEntrance = _ref3.isEntrance;
  var _ref4 = (_svgPropertiesNoEvent = (0, _svgPropertiesNoEvents.svgPropertiesNoEvents)(props)) !== null && _svgPropertiesNoEvent !== void 0 ? _svgPropertiesNoEvent : {},
    id = _ref4.id,
    svgProps = _objectWithoutProperties(_ref4, _excluded3);
  var shape = props.shape,
    dataKey = props.dataKey,
    activeBar = props.activeBar,
    unthemedColors = props.unthemedColors,
    themedActiveStyles = props.themedActiveStyles,
    paintFill = props.paintFill;
  // `fill` is the base color, for labels, Legend and Tooltip. The shapes paint with the pattern or gradient.
  var baseProps = paintFill == null ? svgProps : _objectSpread(_objectSpread({}, svgProps), {}, {
    fill: paintFill
  });
  var onMouseEnterFromProps = props.onMouseEnter,
    onItemClickFromProps = props.onClick,
    onMouseLeaveFromProps = props.onMouseLeave,
    restOfAllOtherProps = _objectWithoutProperties(props, _excluded4);
  var onMouseEnterFromContext = (0, _tooltipContext.useMouseEnterItemDispatch)(onMouseEnterFromProps, dataKey, id);
  var onMouseLeaveFromContext = (0, _tooltipContext.useMouseLeaveItemDispatch)(onMouseLeaveFromProps);
  var onClickFromContext = (0, _tooltipContext.useMouseClickItemDispatch)(onItemClickFromProps, dataKey, id);
  if (!data) {
    return null;
  }
  return /*#__PURE__*/React.createElement(React.Fragment, null, data.map((entry, i) => {
    // a data entry with its own fill object paints with its own definition
    var paintedEntry = (0, _fillDefinitions.readEntryFill)(entry.payload).fillObject == null ? entry : _objectSpread(_objectSpread({}, entry), {}, {
      fill: (0, _fillDefinitions.getFillUrl)((0, _fillDefinitions.getEntryFillId)(id, entry.originalDataIndex))
    });
    return /*#__PURE__*/React.createElement(_BarStack.BarStackClipLayer, _extends({
      index: entry.originalDataIndex
      /*
       * Key by position only. x and y change on every animation frame, so a key built from
       * them remounts every rectangle on every frame (#8064). The index alone is unique (#5415).
       */,
      key: "rectangle-".concat(i),
      className: "recharts-bar-rectangle"
    }, (0, _types.adaptEventsOfChild)(restOfAllOtherProps, entry, entry.originalDataIndex), {
      onMouseEnter: onMouseEnterFromContext(entry, entry.originalDataIndex),
      onMouseLeave: onMouseLeaveFromContext(entry, entry.originalDataIndex),
      onClick: onClickFromContext(entry, entry.originalDataIndex)
    }), activeBar ? /*#__PURE__*/React.createElement(BarRectangleWithActiveState, {
      shape: shape,
      activeBar: activeBar,
      baseProps: baseProps,
      entryStyleOverrides: (0, _dataEntryStyles.getEntryStyleOverrides)(entry, unthemedColors),
      themedActiveStyles: themedActiveStyles,
      entry: paintedEntry,
      index: i,
      dataKey: dataKey,
      animationElapsedTime: animationElapsedTime,
      isAnimating: isAnimating,
      isEntrance: isEntrance
    }) :
    /*#__PURE__*/
    /*
     * If the `activeBar` prop is falsy, then let's call the variant without hooks.
     * Using the `selectActiveTooltipIndex` selector is usually fast
     * but in charts with large-ish amount of data even the few nanoseconds add up to a noticeable jank.
     * If the activeBar is false then we don't need to know which index is active - because we won't use it anyway.
     * So let's just skip the hooks altogether. That way, React can skip rendering the component,
     * and can skip the tree reconciliation for its children too.
     * Because we can't call hooks conditionally, we need to have a separate component for that.
     */
    React.createElement(BarRectangleNeverActive, {
      shape: shape,
      baseProps: baseProps,
      entryStyleOverrides: (0, _dataEntryStyles.getEntryStyleOverrides)(entry, unthemedColors),
      entry: paintedEntry,
      index: i,
      dataKey: dataKey,
      animationElapsedTime: animationElapsedTime,
      isAnimating: isAnimating,
      isEntrance: isEntrance
    }));
  }));
}
var defaultBarAnimateItems = (items, animationElapsedTime, layout) => {
  if (items == null) return [];
  if (animationElapsedTime === 1) {
    return items.flatMap(item => item.status === 'removed' ? [] : [item.next]);
  }
  return items.flatMap(item => {
    if (item.status === 'removed') {
      // animate removed items to 0 height/width respective of layout
      if (layout === 'horizontal') {
        return [_objectSpread(_objectSpread({}, item.prev), {}, {
          height: (0, _DataUtils.interpolate)(item.prev.height, 0, animationElapsedTime),
          y: (0, _DataUtils.interpolate)(item.prev.y, item.prev.y + item.prev.height, animationElapsedTime)
        })];
      }
      return [_objectSpread(_objectSpread({}, item.prev), {}, {
        width: (0, _DataUtils.interpolate)(item.prev.width, 0, animationElapsedTime)
      })];
    }
    if (item.status === 'matched') {
      return [_objectSpread(_objectSpread({}, item.next), {}, {
        x: (0, _DataUtils.interpolate)(item.prev.x, item.next.x, animationElapsedTime),
        y: (0, _DataUtils.interpolate)(item.prev.y, item.next.y, animationElapsedTime),
        width: (0, _DataUtils.interpolate)(item.prev.width, item.next.width, animationElapsedTime),
        height: (0, _DataUtils.interpolate)(item.prev.height, item.next.height, animationElapsedTime)
      })];
    }
    // added
    var next = item.next;
    if (layout === 'horizontal') {
      return [_objectSpread(_objectSpread({}, next), {}, {
        height: (0, _DataUtils.interpolate)(0, next.height, animationElapsedTime),
        y: (0, _DataUtils.interpolate)(next.stackedBarStart, next.y, animationElapsedTime)
      })];
    }
    return [_objectSpread(_objectSpread({}, next), {}, {
      width: (0, _DataUtils.interpolate)(0, next.width, animationElapsedTime),
      x: (0, _DataUtils.interpolate)(next.stackedBarStart, next.x, animationElapsedTime)
    })];
  });
};
function RectanglesWithAnimation(_ref5) {
  var props = _ref5.props,
    previousRectanglesRef = _ref5.previousRectanglesRef;
  var data = props.data,
    isAnimationActive = props.isAnimationActive,
    animationBegin = props.animationBegin,
    animationDuration = props.animationDuration,
    animationEasing = props.animationEasing,
    animationInterpolateFn = props.animationInterpolateFn,
    layout = props.layout;
  var _useAnimationCallback = (0, _AnimatedItems.useAnimationCallbacks)(props.onAnimationStart, props.onAnimationEnd),
    isAnimating = _useAnimationCallback.isAnimating,
    handleAnimationStart = _useAnimationCallback.handleAnimationStart,
    handleAnimationEnd = _useAnimationCallback.handleAnimationEnd;
  return /*#__PURE__*/React.createElement(BarLabelListProvider, {
    showLabels: !isAnimating,
    rects: data,
    fill: props.fill,
    stroke: props.stroke,
    unthemedColors: props.unthemedColors
  }, /*#__PURE__*/React.createElement(_AnimatedItems.AnimatedItems, {
    animationInput: data,
    animationIdPrefix: "recharts-bar-",
    items: data,
    previousItemsRef: previousRectanglesRef,
    isAnimationActive: isAnimationActive,
    animationBegin: animationBegin,
    animationDuration: animationDuration,
    animationEasing: animationEasing,
    onAnimationStart: handleAnimationStart,
    onAnimationEnd: handleAnimationEnd,
    animationInterpolateFn: animationInterpolateFn,
    animationMatchBy: props.animationMatchBy,
    layout: layout
  }, (stepData, animationElapsedTime, isEntrance) => /*#__PURE__*/React.createElement(_Layer.Layer, null, /*#__PURE__*/React.createElement(BarRectangles, {
    props: props,
    data: stepData,
    animationElapsedTime: animationElapsedTime,
    isAnimating: isAnimating || animationElapsedTime < 1,
    isEntrance: isEntrance
  }))), /*#__PURE__*/React.createElement(_LabelList.LabelListFromLabelProp, {
    label: props.label
  }), props.children);
}
function RenderRectangles(props) {
  var previousRectanglesRef = (0, _react.useRef)(null);
  return /*#__PURE__*/React.createElement(RectanglesWithAnimation, {
    previousRectanglesRef: previousRectanglesRef,
    props: props
  });
}
var defaultMinPointSize = 0;
var errorBarDataPointFormatter = (dataPoint, dataKey) => {
  /**
   * if the value coming from `selectBarRectangles` is an array then this is a stacked bar chart.
   * arr[1] represents end value of the bar since the data is in the form of [startValue, endValue].
   * */
  var value = Array.isArray(dataPoint.value) ? dataPoint.value[1] : dataPoint.value;
  return {
    x: dataPoint.x,
    y: dataPoint.y,
    value,
    // getValueByDataKey does not validate the output type
    errorVal: (0, _ChartUtils.getValueByDataKey)(dataPoint, dataKey)
  };
};
class BarWithState extends _react.PureComponent {
  render() {
    var _this$props = this.props,
      hide = _this$props.hide,
      data = _this$props.data,
      dataKey = _this$props.dataKey,
      className = _this$props.className,
      xAxisId = _this$props.xAxisId,
      yAxisId = _this$props.yAxisId,
      needClip = _this$props.needClip,
      background = _this$props.background,
      id = _this$props.id,
      fillObject = _this$props.fillObject,
      fill = _this$props.fill,
      stroke = _this$props.stroke,
      unthemedColors = _this$props.unthemedColors;
    if (hide || data == null) {
      return null;
    }
    var layerClass = (0, _clsx.clsx)('recharts-bar', className);
    var clipPathId = id;
    var hasEntryFills = (0, _fillDefinitions.hasEntryFillObjects)(data.map(entry => entry.payload));
    return /*#__PURE__*/React.createElement(_Layer.Layer, {
      className: layerClass,
      id: id
    }, (needClip || fillObject != null || hasEntryFills) && /*#__PURE__*/React.createElement("defs", null, needClip && /*#__PURE__*/React.createElement(_GraphicalItemClipPath.GraphicalItemClipPath, {
      clipPathId: clipPathId,
      xAxisId: xAxisId,
      yAxisId: yAxisId
    }), fillObject != null && /*#__PURE__*/React.createElement(_fillDefinitions.FillObjectDefinition, {
      id: (0, _fillDefinitions.getSeriesFillId)(id),
      fillObject: fillObject,
      color: fill
    }), hasEntryFills && /*#__PURE__*/React.createElement(_fillDefinitions.EntryFillDefinitions, {
      id: id,
      entries: data.map(entry => ({
        index: entry.originalDataIndex,
        payload: entry.payload,
        color: (0, _dataEntryStyles.getEntryShapeColors)(entry.payload, fill, stroke, unthemedColors).fill
      }))
    })), /*#__PURE__*/React.createElement(_Layer.Layer, {
      className: "recharts-bar-rectangles",
      clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : undefined
    }, /*#__PURE__*/React.createElement(BarBackground, {
      data: data,
      dataKey: dataKey,
      background: background,
      allOtherBarProps: this.props
    }), /*#__PURE__*/React.createElement(_LabelList.SetLabelListClipArea, {
      xAxisId: xAxisId,
      yAxisId: yAxisId
    }, /*#__PURE__*/React.createElement(RenderRectangles, this.props))));
  }
}
var defaultBarProps = exports.defaultBarProps = {
  activeBar: false,
  animationBegin: 0,
  animationDuration: 400,
  animationEasing: 'ease',
  animationInterpolateFn: defaultBarAnimateItems,
  animationMatchBy: _matchBy.matchAppend,
  background: false,
  hide: false,
  isAnimationActive: 'auto',
  label: false,
  legendType: 'rect',
  minPointSize: defaultMinPointSize,
  shape: _BarUtils.defaultBarShape,
  xAxisId: 0,
  yAxisId: 0,
  zIndex: _DefaultZIndexes.DefaultZIndexes.bar
};
function BarImpl(props) {
  var xAxisId = props.xAxisId,
    yAxisId = props.yAxisId,
    hide = props.hide,
    legendType = props.legendType,
    minPointSize = props.minPointSize,
    activeBar = props.activeBar,
    animationBegin = props.animationBegin,
    animationDuration = props.animationDuration,
    animationEasing = props.animationEasing,
    isAnimationActive = props.isAnimationActive;
  var _useNeedsClip = (0, _GraphicalItemClipPath.useNeedsClip)(xAxisId, yAxisId),
    needClip = _useNeedsClip.needClip;
  var layout = (0, _chartLayoutContext.useChartLayout)();
  var isPanorama = (0, _PanoramaContext.useIsPanorama)();

  /*
   * `cells` is an argument to the memoized selector below, so it has to be referentially stable,
   * otherwise every render of this component is a cache miss that returns a brand new `rects` array,
   * which changes the animationId, which starts a spurious animation.
   */
  var cells = (0, _useCells.useCells)(props.children);
  var rects = (0, _hooks.useAppSelector)(state => (0, _barSelectors.selectBarRectangles)(state, props.id, isPanorama, cells));
  if (layout !== 'vertical' && layout !== 'horizontal') {
    return null;
  }
  var errorBarOffset;
  var firstDataPoint = rects === null || rects === void 0 ? void 0 : rects[0];
  if (firstDataPoint == null || firstDataPoint.height == null || firstDataPoint.width == null) {
    errorBarOffset = 0;
  } else {
    errorBarOffset = layout === 'vertical' ? firstDataPoint.height / 2 : firstDataPoint.width / 2;
  }
  return /*#__PURE__*/React.createElement(_ErrorBarContext.SetErrorBarContext, {
    xAxisId: xAxisId,
    yAxisId: yAxisId,
    data: rects,
    dataPointFormatter: errorBarDataPointFormatter,
    errorBarOffset: errorBarOffset,
    clipPath: needClip ? "url(#clipPath-".concat(props.id, ")") : undefined
  }, /*#__PURE__*/React.createElement(BarWithState, _extends({}, props, {
    layout: layout,
    needClip: needClip,
    data: rects,
    xAxisId: xAxisId,
    yAxisId: yAxisId,
    hide: hide,
    legendType: legendType,
    minPointSize: minPointSize,
    activeBar: activeBar,
    animationBegin: animationBegin,
    animationDuration: animationDuration,
    animationEasing: animationEasing,
    isAnimationActive: isAnimationActive
  })));
}
function computeBarRectangles(_ref6) {
  var layout = _ref6.layout,
    _ref6$barSettings = _ref6.barSettings,
    dataKey = _ref6$barSettings.dataKey,
    minPointSizeProp = _ref6$barSettings.minPointSize,
    hasCustomShape = _ref6$barSettings.hasCustomShape,
    pos = _ref6.pos,
    bandSize = _ref6.bandSize,
    xAxis = _ref6.xAxis,
    yAxis = _ref6.yAxis,
    xAxisTicks = _ref6.xAxisTicks,
    yAxisTicks = _ref6.yAxisTicks,
    stackedData = _ref6.stackedData,
    stackedMinPointSizeShift = _ref6.stackedMinPointSizeShift,
    displayedData = _ref6.displayedData,
    offset = _ref6.offset,
    cells = _ref6.cells,
    parentViewBox = _ref6.parentViewBox,
    dataStartIndex = _ref6.dataStartIndex;
  var numericAxis = layout === 'horizontal' ? yAxis : xAxis;
  // @ts-expect-error this assumes that the domain is always numeric, but doesn't check for it
  var stackedDomain = stackedData ? numericAxis.scale.domain() : null;
  var baseValue = (0, _ChartUtils.getBaseValueOfBar)({
    numericAxis
  });
  var stackedBarStart = numericAxis.scale.map(baseValue);
  return displayedData.map((entry, index) => {
    var value, x, y, width, height, background;
    if (stackedData) {
      // Use dataStartIndex to access the correct element in the full stackedData array
      var untruncatedValue = stackedData[index + dataStartIndex];
      if (untruncatedValue == null) {
        return null;
      }
      value = (0, _ChartUtils.truncateByDomain)(untruncatedValue, stackedDomain);
    } else {
      value = (0, _ChartUtils.getValueByDataKey)(entry, dataKey);
      if (!Array.isArray(value)) {
        value = [baseValue, value];
      }
    }
    var minPointSize = (0, _BarUtils.minPointSizeCallback)(minPointSizeProp, defaultMinPointSize)(value[1], index);
    if (layout === 'horizontal') {
      var _ref7;
      var baseValueScale = yAxis.scale.map(value[0]);
      var currentValueScale = yAxis.scale.map(value[1]);
      if (baseValueScale == null || currentValueScale == null) {
        return null;
      }
      x = (0, _ChartUtils.getCateCoordinateOfBar)({
        axis: xAxis,
        ticks: xAxisTicks,
        bandSize,
        offset: pos.offset,
        entry,
        index
      });
      y = (_ref7 = currentValueScale !== null && currentValueScale !== void 0 ? currentValueScale : baseValueScale) !== null && _ref7 !== void 0 ? _ref7 : undefined;
      width = pos.size;
      var computedHeight = baseValueScale - currentValueScale;
      height = (0, _DataUtils.isNan)(computedHeight) ? 0 : computedHeight;
      background = {
        x,
        y: offset.top,
        width,
        height: offset.height
      };
      if (stackedData && y != null) {
        var _stackedMinPointSizeS;
        y -= (_stackedMinPointSizeS = stackedMinPointSizeShift === null || stackedMinPointSizeShift === void 0 ? void 0 : stackedMinPointSizeShift[index + dataStartIndex]) !== null && _stackedMinPointSizeS !== void 0 ? _stackedMinPointSizeS : 0;
      }
      if (Math.abs(minPointSize) > 0 && Math.abs(height) < Math.abs(minPointSize)) {
        var delta = (0, _DataUtils.mathSign)(height || minPointSize) * (Math.abs(minPointSize) - Math.abs(height));
        y -= delta;
        height += delta;
      }
    } else {
      var _baseValueScale = xAxis.scale.map(value[0]);
      var _currentValueScale = xAxis.scale.map(value[1]);
      if (_baseValueScale == null || _currentValueScale == null) {
        return null;
      }
      x = _baseValueScale;
      y = (0, _ChartUtils.getCateCoordinateOfBar)({
        axis: yAxis,
        ticks: yAxisTicks,
        bandSize,
        offset: pos.offset,
        entry,
        index
      });
      width = _currentValueScale - _baseValueScale;
      height = pos.size;
      background = {
        x: offset.left,
        y,
        width: offset.width,
        height
      };
      if (stackedData) {
        var _stackedMinPointSizeS2;
        x += (_stackedMinPointSizeS2 = stackedMinPointSizeShift === null || stackedMinPointSizeShift === void 0 ? void 0 : stackedMinPointSizeShift[index + dataStartIndex]) !== null && _stackedMinPointSizeS2 !== void 0 ? _stackedMinPointSizeS2 : 0;
      }
      if (Math.abs(minPointSize) > 0 && Math.abs(width) < Math.abs(minPointSize)) {
        var _delta = (0, _DataUtils.mathSign)(width || minPointSize) * (Math.abs(minPointSize) - Math.abs(width));
        width += _delta;
      }
    }

    /*
     * Filter out 0-dimension rectangles early to avoid creating unnecessary component trees.
     * BarStack clip-paths use originalDataIndex, so sparse filtered arrays remain index-stable.
     * Bars with a custom shape are not filtered out: the custom renderer may still draw something
     * visible at zero-dimension positions (e.g. horizontal lines in a BoxPlot).
     */
    if (x == null || y == null || width == null || height == null || !hasCustomShape && (width === 0 || height === 0)) {
      return null;
    }

    /*
     * `id` from a data entry is never spread on rendered elements to avoid duplicate DOM ids.
     * The raw entry, id included, stays available through `payload`.
     */
    var entryWithoutId = entry != null && typeof entry === 'object' ? (0, _omit.default)(entry, ['id']) : entry;
    var barRectangleItem = _objectSpread(_objectSpread({}, entryWithoutId), {}, {
      stackedBarStart,
      x,
      y,
      width,
      height,
      value: stackedData ? value : value[1],
      payload: entry,
      background,
      tooltipPosition: {
        x: x + width / 2,
        y: y + height / 2
      },
      parentViewBox,
      originalDataIndex: index
    }, cells && cells[index] && cells[index].props);
    return (0, _fillDefinitions.withEntryFillColor)(barRectangleItem, entry);
  }).filter(Boolean);
}
function BarFn(propsWithFillObject) {
  var _outsideProps$xAxisId, _outsideProps$yAxisId, _outsideProps$fill, _outsideProps$stroke, _outsideProps$strokeW, _outsideProps$strokeO, _outsideProps$strokeD, _outsideProps$fillOpa;
  var _splitFill = (0, _fillDefinitions.splitFill)(propsWithFillObject.fill),
    fillColor = _splitFill.color,
    fillObject = _splitFill.fillObject;
  // From here on, `fill` is the base color
  var outsideProps = _objectSpread(_objectSpread({}, propsWithFillObject), {}, {
    fill: fillColor
  });
  var dataKey = (0, _useEffectiveDataKey.useEffectiveDataKey)({
    dataKey: outsideProps.dataKey,
    xAxisId: (_outsideProps$xAxisId = outsideProps.xAxisId) !== null && _outsideProps$xAxisId !== void 0 ? _outsideProps$xAxisId : defaultBarProps.xAxisId,
    yAxisId: (_outsideProps$yAxisId = outsideProps.yAxisId) !== null && _outsideProps$yAxisId !== void 0 ? _outsideProps$yAxisId : defaultBarProps.yAxisId
  });
  var graphicalItemThemeSelector = (0, _useGraphicalItemIdentity.useGraphicalItemIdentity)(dataKey, outsideProps);
  // The Bar's own fill object wins. Without one, it paints with the fill object of its theme entry, if there is one.
  var themeFillObject = (0, _useGraphicalItemIdentity.useGraphicalItemThemeFill)(dataKey, outsideProps);
  var effectiveFillObject = fillObject !== null && fillObject !== void 0 ? fillObject : themeFillObject;
  var resolveLabelTheme = (0, _labelTheme.useSeriesLabelThemeResolver)(graphicalItemThemeSelector);
  var unthemedColors = (0, _dataEntryStyles.useUnthemedColors)(outsideProps);
  var themedActiveStyles = (0, _activeStyles.useThemedActiveStyles)(graphicalItemThemeSelector, outsideProps);
  var graphicalItemStyle = (0, _useBackwardsCompatibleTheme.useBackwardsCompatibleTheme)(graphicalItemThemeSelector, outsideProps, undefined);
  var props = (0, _resolveDefaultProps.resolveDefaultProps)(_objectSpread(_objectSpread({}, outsideProps), {}, {
    dataKey
  }), defaultBarProps);
  // stackId may arrive from props or from BarStack context
  var stackId = (0, _BarStack.useStackId)(props.stackId);
  var isPanorama = (0, _PanoramaContext.useIsPanorama)();
  var themeFill = (_outsideProps$fill = outsideProps.fill) !== null && _outsideProps$fill !== void 0 ? _outsideProps$fill : graphicalItemStyle === null || graphicalItemStyle === void 0 ? void 0 : graphicalItemStyle.fill;
  var themeStroke = (_outsideProps$stroke = outsideProps.stroke) !== null && _outsideProps$stroke !== void 0 ? _outsideProps$stroke : graphicalItemStyle === null || graphicalItemStyle === void 0 ? void 0 : graphicalItemStyle.stroke;
  var themeStrokeWidth = (_outsideProps$strokeW = outsideProps.strokeWidth) !== null && _outsideProps$strokeW !== void 0 ? _outsideProps$strokeW : graphicalItemStyle === null || graphicalItemStyle === void 0 ? void 0 : graphicalItemStyle.strokeWidth;
  var themeStrokeOpacity = (_outsideProps$strokeO = outsideProps.strokeOpacity) !== null && _outsideProps$strokeO !== void 0 ? _outsideProps$strokeO : graphicalItemStyle === null || graphicalItemStyle === void 0 ? void 0 : graphicalItemStyle.strokeOpacity;
  var themeStrokeDasharray = (_outsideProps$strokeD = outsideProps.strokeDasharray) !== null && _outsideProps$strokeD !== void 0 ? _outsideProps$strokeD : graphicalItemStyle === null || graphicalItemStyle === void 0 ? void 0 : graphicalItemStyle.strokeDasharray;
  var themeFillOpacity = (_outsideProps$fillOpa = outsideProps.fillOpacity) !== null && _outsideProps$fillOpa !== void 0 ? _outsideProps$fillOpa : graphicalItemStyle === null || graphicalItemStyle === void 0 ? void 0 : graphicalItemStyle.fillOpacity;
  var themedProps = {};
  if (themeFill !== undefined) themedProps.fill = themeFill;
  if (themeStroke !== undefined) themedProps.stroke = themeStroke;
  if (themeStrokeWidth !== undefined) themedProps.strokeWidth = themeStrokeWidth;
  if (themeStrokeOpacity !== undefined) themedProps.strokeOpacity = themeStrokeOpacity;
  if (themeStrokeDasharray !== undefined) themedProps.strokeDasharray = themeStrokeDasharray;
  if (themeFillOpacity !== undefined) themedProps.fillOpacity = themeFillOpacity;

  // Report all props to Redux store first, before calling any hooks, to avoid circular dependencies.
  return /*#__PURE__*/React.createElement(_RegisterGraphicalItemId.RegisterGraphicalItemId, {
    id: props.id,
    type: "bar"
  }, id => {
    var _themedProps$stroke, _themedProps$strokeWi, _themedProps$fill, _themedProps$strokeWi2;
    return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_SetLegendPayload.SetLegendPayload, {
      legendPayload: computeLegendPayloadFromBarData(_objectSpread(_objectSpread({}, props), themedProps), effectiveFillObject)
    }), /*#__PURE__*/React.createElement(SetBarTooltipEntrySettings, {
      dataKey: props.dataKey,
      stroke: (_themedProps$stroke = themedProps.stroke) !== null && _themedProps$stroke !== void 0 ? _themedProps$stroke : props.stroke,
      strokeWidth: (_themedProps$strokeWi = themedProps.strokeWidth) !== null && _themedProps$strokeWi !== void 0 ? _themedProps$strokeWi : props.strokeWidth,
      fill: (_themedProps$fill = themedProps.fill) !== null && _themedProps$fill !== void 0 ? _themedProps$fill : props.fill,
      name: props.name,
      hide: props.hide,
      unit: props.unit,
      formatter: props.formatter,
      tooltipType: props.tooltipType,
      id: id,
      unthemedColors: unthemedColors
    }), /*#__PURE__*/React.createElement(_SetGraphicalItem.SetCartesianGraphicalItem, {
      type: "bar",
      id: id,
      data: props.data,
      xAxisId: props.xAxisId,
      yAxisId: props.yAxisId,
      zAxisId: 0,
      dataKey: props.dataKey,
      stackId: stackId,
      hide: props.hide,
      barSize: props.barSize,
      minPointSize: props.minPointSize,
      maxBarSize: props.maxBarSize,
      isPanorama: isPanorama,
      hasCustomShape: props.shape != null && props.shape !== _BarUtils.defaultBarShape,
      strokeWidth: (_themedProps$strokeWi2 = themedProps.strokeWidth) !== null && _themedProps$strokeWi2 !== void 0 ? _themedProps$strokeWi2 : props.strokeWidth
    }), /*#__PURE__*/React.createElement(_ZIndexLayer.ZIndexLayer, {
      zIndex: props.zIndex
    }, /*#__PURE__*/React.createElement(_labelTheme.DataLabelThemeContextProvider, {
      value: resolveLabelTheme
    }, /*#__PURE__*/React.createElement(BarImpl, _extends({}, props, themedProps, {
      id: id,
      unthemedColors: unthemedColors,
      themedActiveStyles: themedActiveStyles,
      fillObject: effectiveFillObject,
      paintFill: effectiveFillObject == null ? undefined : (0, _fillDefinitions.getFillUrl)((0, _fillDefinitions.getSeriesFillId)(id))
    })))));
  });
}

/**
 * @provides ErrorBarContext
 * @provides LabelListContext
 * @provides CellReader
 * @consumes CartesianChartContext
 * @consumes BarStackContext
 * @public
 */
var Bar = exports.Bar = /*#__PURE__*/React.memo(BarFn, _propsAreEqual.propsAreEqual);
// @ts-expect-error we need to set the displayName for debugging purposes
Bar.displayName = 'Bar';

Zerion Mini Shell 1.0