var _excluded = ["children", "uiHosts"];
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, { useMemo, useRef } from 'react';
import useEngineContext from "../../../../hooks/useEngineContext";
import { SalesSdkProvider } from "../../context/SalesSdkProvider";
import { DemoHostRuntimeBridge } from "./DemoHostRuntimeBridge";
/**
 * Demo 专用：在 create/edit Tab 外包一层 Provider，并注入 legacy Info2 商品弹窗 Host。
 *
 * - 普通商品 / 资源 / 跨日 / Holder Host 由 SalesSdkProvider 实例 bridge 提供
 * - 预约商品 `openProductDetail` legacy 分支走 `pisell1.handleOpenProductModal`
 */
export var SalesSdkDemoTabShell = function SalesSdkDemoTabShell(_ref) {
  var _context$appHelper;
  var children = _ref.children,
    uiHosts = _ref.uiHosts,
    providerProps = _objectWithoutProperties(_ref, _excluded);
  var context = useEngineContext();
  var action = context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.action;
  var runtimeRef = useRef({
    date: undefined,
    customerId: undefined
  });
  var legacyOpenProductDetail = useMemo(function () {
    return action ? {
      action: action,
      getRuntime: function getRuntime() {
        return runtimeRef.current;
      }
    } : undefined;
  }, [action]);
  return /*#__PURE__*/React.createElement(SalesSdkProvider, _extends({}, providerProps, {
    legacyOpenProductDetail: legacyOpenProductDetail,
    uiHosts: uiHosts
  }), /*#__PURE__*/React.createElement(DemoHostRuntimeBridge, {
    runtimeRef: runtimeRef
  }), children);
};