var _excluded = ["refreshVersion"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React, { useEffect, useRef } from 'react';
import SaleDetail from "../../saleDetail";
/**
 * 给内联 SaleDetail 加一层「版本号 → 命令式 refresh()」桥接。
 *
 * key / osKey 仅按订单 id 稳定（不随版本变化），实时订阅命中订单时由外层 bump
 * `refreshVersion`，本组件通过 ref 调 `SaleDetail.refresh()` 就地刷新，避免「换 key」
 * 导致整块 remount 闪烁，也不必往 SDK 透传会变化的 prop。
 */
var RefreshableSaleDetail = function RefreshableSaleDetail(_ref) {
  var _ref$refreshVersion = _ref.refreshVersion,
    refreshVersion = _ref$refreshVersion === void 0 ? 0 : _ref$refreshVersion,
    saleDetailProps = _objectWithoutProperties(_ref, _excluded);
  var handleRef = useRef(null);
  var initedRef = useRef(false);
  useEffect(function () {
    var _handleRef$current;
    // 首次挂载由 SaleDetail 自身 bootstrap 拉取，无需重复刷新。
    if (!initedRef.current) {
      initedRef.current = true;
      return;
    }
    void ((_handleRef$current = handleRef.current) === null || _handleRef$current === void 0 ? void 0 : _handleRef$current.refresh({
      forceRemote: true
    }));
  }, [refreshVersion]);
  return /*#__PURE__*/React.createElement(SaleDetail, _extends({
    ref: handleRef
  }, saleDetailProps));
};
export default RefreshableSaleDetail;