function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _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 _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(arr) { if (Array.isArray(arr)) return arr; }
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(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
import React, { useCallback, useMemo, useState } from 'react';
import classNames from 'classnames';
import Decimal from 'decimal.js';
import { PisellHierarchicalSummaryList } from '@pisell/materials';
import { formatAmount, locales } from '@pisell/utils';
import useInitLocalesOnce from "../../hooks/useInitLocalesOnce";
import useEngineContext from "../../hooks/useEngineContext";
import { resolvePaymentMethodName, usePaymentMethodNameMap } from "../pisellSalesManagement/hooks/usePaymentMethodNameMap";
import localeTexts from "./locales";
import "./index.less";
var PREFIX = 'pisell-sale-summary-detail';
var SECTION_ROW_CLASS = "".concat(PREFIX, "__section-row");
var STANDALONE_ROW_CLASS = "".concat(PREFIX, "__standalone-row");
var DIVIDER_ROW_CLASS = "".concat(PREFIX, "__divider-row");
var PAYMENT_SURCHARGE_ROW_CLASS = "".concat(PREFIX, "__payment-surcharge-row");
var SUMMARY_DETAIL_LEVEL_CONFIG = {
  1: {
    rowStyle: {
      padding: '0 0 12px'
    },
    labelTextStyle: {
      color: '#a9b8ee',
      fontSize: 13,
      fontWeight: 900,
      lineHeight: '18px'
    },
    valueTextStyle: {
      color: '#f5f8ff',
      fontSize: 13,
      fontWeight: 900,
      lineHeight: '18px'
    },
    expandIconStyle: {
      size: 14,
      color: '#e7eeff'
    }
  },
  2: {
    rowStyle: {
      padding: '0'
    },
    labelTextStyle: {
      color: '#f5f8ff',
      fontSize: 13,
      fontWeight: 800,
      lineHeight: '19px'
    },
    valueTextStyle: {
      color: '#f5f8ff',
      fontSize: 13,
      fontWeight: 900,
      lineHeight: '19px'
    },
    expandIconStyle: {
      size: 14,
      color: '#e7eeff'
    }
  },
  3: {
    rowStyle: {
      padding: '0'
    },
    labelTextStyle: {
      color: '#a9b8ee',
      fontSize: 13,
      fontWeight: 700,
      lineHeight: '19px'
    },
    valueTextStyle: {
      color: '#a9b8ee',
      fontSize: 13,
      fontWeight: 800,
      lineHeight: '19px'
    },
    expandIconStyle: {
      size: 14,
      color: '#e7eeff'
    }
  }
};
function normalizeVisibleDetailChildren(children) {
  var _children$filter;
  return (_children$filter = children === null || children === void 0 ? void 0 : children.filter(function (child) {
    return !child.hidden;
  })) !== null && _children$filter !== void 0 ? _children$filter : [];
}
function collectDefaultExpandedDetailKeys(items) {
  var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  var keys = [];
  items.filter(function (item) {
    return !item.hidden;
  }).forEach(function (item) {
    var children = normalizeVisibleDetailChildren(item.children);
    var canDefaultExpand = item.key !== undefined && children.length > 0;
    if (canDefaultExpand && level <= 2) {
      keys.push(item.key);
    }
    if (children.length > 0 && level < 2) {
      keys.push.apply(keys, _toConsumableArray(collectDefaultExpandedDetailKeys(children, level + 1)));
    }
  });
  return keys;
}
function uppercaseSectionLabel(label, locale) {
  return typeof label === 'string' ? label.toLocaleUpperCase(locale) : label;
}
function toDecimal(value) {
  try {
    if (value instanceof Decimal) return value;
    if (value === undefined || value === null || value === '') {
      return new Decimal(0);
    }
    return new Decimal(value);
  } catch (_unused) {
    return new Decimal(0);
  }
}
function isNonZeroAmount(value) {
  return !toDecimal(value).isZero();
}
function formatMoney(value, symbol) {
  return formatAmount(toDecimal(value).toString(), 2, symbol);
}
function formatNegativeMoney(value, symbol) {
  return formatMoney(toDecimal(value).abs().negated(), symbol);
}
function asRecords(value) {
  return Array.isArray(value) ? value.filter(function (item) {
    return !!item && _typeof(item) === 'object';
  }) : [];
}
function firstDefined(record, keys) {
  if (!record) return undefined;
  var _iterator = _createForOfIteratorHelper(keys),
    _step;
  try {
    for (_iterator.s(); !(_step = _iterator.n()).done;) {
      var key = _step.value;
      var value = record[key];
      if (value !== undefined && value !== null && value !== '') {
        return value;
      }
    }
  } catch (err) {
    _iterator.e(err);
  } finally {
    _iterator.f();
  }
  return undefined;
}
function getPaymentAmount(record) {
  return firstDefined(record, ['origin_amount', 'amount']);
}
function getPaymentSurchargeAmount(record) {
  return record.service_fee;
}
function isVoucherPaymentRecord(record) {
  return !!record.voucher_id;
}
function isRefundPaymentRecord(record) {
  var rawType = String(record.type || record.status || '').toLowerCase();
  return rawType.includes('refund') || toDecimal(getPaymentAmount(record)).lt(0);
}
function createDetailRow(key, label, value, options) {
  return {
    key: key,
    label: label,
    value: value,
    hidden: options === null || options === void 0 ? void 0 : options.hidden,
    children: options === null || options === void 0 ? void 0 : options.children,
    rowClassName: options === null || options === void 0 ? void 0 : options.rowClassName
  };
}
function filterDetailItemsByKeys(items, visibleKeys) {
  if (!(visibleKeys !== null && visibleKeys !== void 0 && visibleKeys.size)) return items;
  return items.map(function (item) {
    var itemKey = item.key === undefined ? undefined : String(item.key);
    var isDirectlyVisible = itemKey !== undefined && visibleKeys.has(itemKey);
    if (isDirectlyVisible) {
      return item;
    }
    var children = item.children ? filterDetailItemsByKeys(item.children, visibleKeys) : undefined;
    var hasVisibleChildren = normalizeVisibleDetailChildren(children).length > 0;
    if (!hasVisibleChildren) {
      return _objectSpread(_objectSpread({}, item), {}, {
        hidden: true,
        children: children
      });
    }
    return _objectSpread(_objectSpread({}, item), {}, {
      children: children
    });
  }).filter(function (item) {
    return !item.hidden;
  });
}
function getSummaryAmount(summary, keys) {
  var _ref;
  var fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  return (_ref = firstDefined(summary, keys)) !== null && _ref !== void 0 ? _ref : fallback;
}
function getRefundTaxAmount(summary) {
  return getSummaryAmount(summary, ['refund_tax_fee', 'tax_refund_amount', 'gst_refund_amount', 'refund_gst_amount']);
}
function getRefundNetAmount(summary) {
  var explicit = firstDefined(summary, ['net_refund_amount', 'refund_net_amount']);
  if (explicit !== undefined) return explicit;
  return toDecimal(summary.total_refund_amount).minus(toDecimal(getRefundTaxAmount(summary))).toString();
}
function getBalanceDueAmount(summary, paymentStatus) {
  return String(paymentStatus !== null && paymentStatus !== void 0 ? paymentStatus : '').toLowerCase() === 'payment_processing' ? summary.expect_amount : summary.amount_gap;
}
function getPaidExclPaymentSurchargeLabel(paymentSurchargeText) {
  var formatLabel = locales.getText('pisell2.sale-detail.paid-excl-payment-sc');
  if (typeof formatLabel === 'function') {
    return formatLabel(paymentSurchargeText);
  }
  return "".concat(locales.getText('pisell2.sale-detail.pay.paid'), " (").concat(paymentSurchargeText, ")");
}
function buildPaymentRows(payments, paymentMethodNameMap, symbol, options) {
  return payments.filter(function (payment) {
    return !isVoucherPaymentRecord(payment);
  }).map(function (payment, index) {
    var _firstDefined;
    var amount = getPaymentAmount(payment);
    var isRefund = isRefundPaymentRecord(payment);
    var serviceFee = getPaymentSurchargeAmount(payment);
    var lastDigits = String((_firstDefined = firstDefined(payment, ['card_last_four', 'card_last4', 'last4', 'last_digits'])) !== null && _firstDefined !== void 0 ? _firstDefined : '').trim();
    var title = [options === null || options === void 0 ? void 0 : options.labelPrefix, resolvePaymentMethodName(payment, paymentMethodNameMap), lastDigits].filter(Boolean).join(' ');
    return createDetailRow("payment-".concat(payment.order_payment_id || payment.id || index), title, formatMoney(isRefund ? toDecimal(amount).abs().negated() : amount, symbol), {
      children: [createDetailRow("payment-".concat(index, "-surcharge"), locales.getText('pisell2.sale-detail.payment-surcharge'), formatMoney(serviceFee, symbol), {
        hidden: !isNonZeroAmount(serviceFee),
        rowClassName: PAYMENT_SURCHARGE_ROW_CLASS
      })]
    });
  });
}
function buildDetailItems(options) {
  var _dataSource$translati, _dataSource$paymentMe, _detailOptions$paymen, _detailOptions$visibl;
  var dataSource = options.dataSource,
    detailOptions = options.detailOptions,
    fallbackPaymentMethodNameMap = options.fallbackPaymentMethodNameMap,
    fallbackSymbol = options.fallbackSymbol,
    fallbackTranslationOriginal = options.fallbackTranslationOriginal,
    locale = options.locale;
  var summary = dataSource.summary;
  if (!summary) return [];
  var symbol = dataSource.currencySymbol || fallbackSymbol;
  var translationOriginal = (_dataSource$translati = dataSource.translationOriginal) !== null && _dataSource$translati !== void 0 ? _dataSource$translati : fallbackTranslationOriginal;
  var payments = asRecords(dataSource.payments);
  var paymentMethodNameMap = (_dataSource$paymentMe = dataSource.paymentMethodNameMap) !== null && _dataSource$paymentMe !== void 0 ? _dataSource$paymentMe : fallbackPaymentMethodNameMap;
  var surcharges = summary.surcharges ? summary.surcharges : [];
  var surchargeList = surcharges.filter(function (surcharge) {
    return surcharge.name;
  }).map(function (surcharge) {
    return {
      key: "custom_surcharge_".concat(surcharge.surcharge_id),
      value: firstDefined(surcharge, ['amount', 'value']),
      label: (translationOriginal === null || translationOriginal === void 0 ? void 0 : translationOriginal(surcharge.name)) || String(surcharge.name)
    };
  });
  var paymentRows = buildPaymentRows(payments.filter(function (payment) {
    return !isRefundPaymentRecord(payment);
  }), paymentMethodNameMap, symbol);
  var refundRows = buildPaymentRows(payments.filter(isRefundPaymentRecord), paymentMethodNameMap, symbol, {
    labelPrefix: locales.getText('pisell2.sale-detail.refund-payment-prefix')
  });
  var additionsSubtotal = surchargeList.reduce(function (total, surcharge) {
    return total.plus(toDecimal(surcharge.value));
  }, new Decimal(0)).plus(toDecimal(summary.rounding_amount)).plus(toDecimal(summary.tax_fee));
  var balanceDueAmount = getBalanceDueAmount(summary, dataSource.paymentStatus);
  var paymentSurchargeAmount = summary.pay_service_charge_amount;
  var customerTotalPaid = toDecimal(summary.order_paid_amount).plus(toDecimal(paymentSurchargeAmount));
  var totalRefundAmount = toDecimal(summary.total_refund_amount).abs();
  var paymentStatusPaidMode = (_detailOptions$paymen = detailOptions === null || detailOptions === void 0 ? void 0 : detailOptions.paymentStatusPaidMode) !== null && _detailOptions$paymen !== void 0 ? _detailOptions$paymen : 'split';
  var visibleKeys = detailOptions !== null && detailOptions !== void 0 && (_detailOptions$visibl = detailOptions.visibleItemKeys) !== null && _detailOptions$visibl !== void 0 && _detailOptions$visibl.length ? new Set(detailOptions.visibleItemKeys.map(String)) : undefined;
  var paymentStatusPaidRows = paymentStatusPaidMode === 'combined' ? [createDetailRow('payment-status-paid', getPaidExclPaymentSurchargeLabel(formatMoney(paymentSurchargeAmount, symbol)), formatMoney(summary.order_paid_amount, symbol))] : [createDetailRow('payment-status-paid', locales.getText('pisell2.sale-detail.payment-applied'), formatMoney(summary.order_paid_amount, symbol)), createDetailRow('payment-status-surcharge', locales.getText('pisell2.sale-detail.payment-surcharge'), formatMoney(paymentSurchargeAmount, symbol))];
  var items = [{
    key: 'paymentStatus',
    rowClassName: SECTION_ROW_CLASS,
    label: uppercaseSectionLabel(locales.getText('pisell2.sale-detail.payment-status'), locale),
    children: [createDetailRow('payment-status-total', locales.getText('pisell2.sale-detail.total-amount'), formatMoney(summary.expect_amount, symbol))].concat(paymentStatusPaidRows, [createDetailRow('payment-status-refunded', locales.getText('pisell2.sale-detail.refunded'), formatNegativeMoney(summary.total_refund_amount, symbol)), createDetailRow('payment-status-balance', locales.getText('pisell2.sale-detail.balance-due'), formatMoney(balanceDueAmount, symbol))])
  }, {
    key: 'paymentAdditions',
    rowClassName: SECTION_ROW_CLASS,
    label: uppercaseSectionLabel(locales.getText('pisell2.sale-detail.payment-additions'), locale),
    children: [].concat(_toConsumableArray(surchargeList.map(function (surcharge) {
      return createDetailRow(surcharge.key, surcharge.label, formatMoney(surcharge.value, symbol), {
        hidden: !isNonZeroAmount(surcharge.value)
      });
    })), [createDetailRow('addition-rounding', locales.getText('pisell2.sale-detail.rounding'), formatMoney(summary.rounding_amount, symbol)), createDetailRow('addition-tax', dataSource.taxTitle || summary.tax_title || locales.getText('pisell2.sale-detail.tax'), formatMoney(summary.tax_fee, symbol)), createDetailRow('addition-subtotal', locales.getText('pisell2.sale-detail.subtotal'), formatMoney(additionsSubtotal, symbol))])
  }, createDetailRow('payments-total-amount', uppercaseSectionLabel(locales.getText('pisell2.sale-detail.total-amount'), locale), formatMoney(summary.expect_amount, symbol), {
    rowClassName: SECTION_ROW_CLASS
  }), {
    key: 'payments',
    rowClassName: SECTION_ROW_CLASS,
    label: uppercaseSectionLabel(locales.getText('pisell2.sale-detail.payments'), locale),
    children: [].concat(_toConsumableArray(paymentRows), [createDetailRow('payments-divider', '', '', {
      rowClassName: DIVIDER_ROW_CLASS
    }), createDetailRow('payments-applied-subtotal', locales.getText('pisell2.sale-detail.total-payment-applied'), formatMoney(summary.order_paid_amount, symbol)), createDetailRow('payments-total-surcharge', locales.getText('pisell2.sale-detail.total-payment-surcharge'), formatMoney(paymentSurchargeAmount, symbol)), createDetailRow('payments-customer-paid', locales.getText('pisell2.sale-detail.customer-total-paid'), formatMoney(customerTotalPaid, symbol))])
  }, {
    key: 'refunds',
    rowClassName: SECTION_ROW_CLASS,
    label: uppercaseSectionLabel(locales.getText('pisell2.sale-detail.refunds'), locale),
    hidden: !refundRows.length && totalRefundAmount.isZero(),
    children: [].concat(_toConsumableArray(refundRows), [createDetailRow('refund-net', locales.getText('pisell2.sale-detail.net-refund'), formatNegativeMoney(getRefundNetAmount(summary), symbol)), createDetailRow('refund-tax', locales.getText('pisell2.sale-detail.gst-refund-included'), formatNegativeMoney(getRefundTaxAmount(summary), symbol), {
      hidden: true
    }), createDetailRow('refund-subtotal', locales.getText('pisell2.sale-detail.refund-subtotal'), formatNegativeMoney(summary.total_refund_amount, symbol))])
  }, createDetailRow('detail-balance-due', locales.getText('pisell2.sale-detail.balance-due'), formatMoney(balanceDueAmount, symbol), {
    rowClassName: STANDALONE_ROW_CLASS
  })];
  return filterDetailItemsByKeys(items, visibleKeys);
}

/**
 * 独立的销售金额明细内容组件，通过 dataSource 接收展示字段来源。
 */
export var PisellSaleSummaryDetail = /*#__PURE__*/React.memo(function (_ref2) {
  var _engineContext$appHel, _engineContext$appHel2, _engineContext$appHel3, _engineContext$appHel4;
  var dataSource = _ref2.dataSource,
    className = _ref2.className,
    options = _ref2.options;
  useInitLocalesOnce(localeTexts);
  var engineContext = useEngineContext();
  var paymentMethodNameMap = usePaymentMethodNameMap();
  var _useState = useState([]),
    _useState2 = _slicedToArray(_useState, 2),
    collapsedDefaultKeys = _useState2[0],
    setCollapsedDefaultKeys = _useState2[1];
  var _useState3 = useState([]),
    _useState4 = _slicedToArray(_useState3, 2),
    manualExpandedKeys = _useState4[0],
    setManualExpandedKeys = _useState4[1];
  var currentLocale = locales.getLocale();
  var fallbackSymbol = (_engineContext$appHel = (_engineContext$appHel2 = engineContext.appHelper) === null || _engineContext$appHel2 === void 0 || (_engineContext$appHel2 = _engineContext$appHel2.utils) === null || _engineContext$appHel2 === void 0 || (_engineContext$appHel3 = _engineContext$appHel2.getSymbolic) === null || _engineContext$appHel3 === void 0 ? void 0 : _engineContext$appHel3.call(_engineContext$appHel2)) !== null && _engineContext$appHel !== void 0 ? _engineContext$appHel : '';
  var fallbackTranslationOriginal = (_engineContext$appHel4 = engineContext.appHelper) === null || _engineContext$appHel4 === void 0 || (_engineContext$appHel4 = _engineContext$appHel4.utils) === null || _engineContext$appHel4 === void 0 ? void 0 : _engineContext$appHel4.translationOriginal;
  var items = useMemo(function () {
    return buildDetailItems({
      dataSource: dataSource !== null && dataSource !== void 0 ? dataSource : {},
      detailOptions: options,
      fallbackPaymentMethodNameMap: paymentMethodNameMap,
      fallbackSymbol: fallbackSymbol,
      fallbackTranslationOriginal: fallbackTranslationOriginal,
      locale: currentLocale
    });
  }, [currentLocale, dataSource, fallbackSymbol, fallbackTranslationOriginal, options, paymentMethodNameMap]);
  var defaultExpandedKeys = useMemo(function () {
    return collectDefaultExpandedDetailKeys(items);
  }, [items]);
  var expandedKeys = useMemo(function () {
    var collapsedSet = new Set(collapsedDefaultKeys);
    var defaultSet = new Set(defaultExpandedKeys);
    var nextKeys = defaultExpandedKeys.filter(function (key) {
      return !collapsedSet.has(key);
    });
    manualExpandedKeys.forEach(function (key) {
      if (!defaultSet.has(key)) {
        nextKeys.push(key);
      }
    });
    return nextKeys;
  }, [collapsedDefaultKeys, defaultExpandedKeys, manualExpandedKeys]);
  var handleExpandedKeysChange = useCallback(function (keys) {
    var expandedSet = new Set(keys);
    var defaultSet = new Set(defaultExpandedKeys);
    setCollapsedDefaultKeys(defaultExpandedKeys.filter(function (key) {
      return !expandedSet.has(key);
    }));
    setManualExpandedKeys(keys.filter(function (key) {
      return !defaultSet.has(key);
    }));
  }, [defaultExpandedKeys]);
  return /*#__PURE__*/React.createElement("div", {
    className: classNames(PREFIX, className)
  }, /*#__PURE__*/React.createElement(PisellHierarchicalSummaryList, {
    className: "".concat(PREFIX, "__list"),
    items: [{
      key: 'summary-detail-root',
      label: '',
      children: items
    }],
    expandedKeys: expandedKeys,
    onExpandedKeysChange: handleExpandedKeysChange,
    indent: 26,
    rowGap: 4,
    padding: 0,
    levelConfig: SUMMARY_DETAIL_LEVEL_CONFIG,
    gaps: {
      row: 8,
      rowLeft: 6,
      rowRight: 6
    }
  }));
});
PisellSaleSummaryDetail.displayName = 'PisellSaleSummaryDetail';
export default PisellSaleSummaryDetail;