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); }
import React from 'react';
import { Tabs } from 'antd';
import { SalesSdkProvider } from "../context/SalesSdkProvider";
import { SalesSdkDemoTabShell } from "./components/SalesSdkDemoTabShell";
import { DemoTabDetail } from "./components/DemoTabDetail";
import { DemoTabCreate } from "./components/DemoTabCreate";
import { DemoTabEdit } from "./components/DemoTabEdit";
import { FIXTURE_DETAIL, FIXTURE_EDIT } from "./fixtures";
import "./index.less";
var DEFAULT_OS_KEY = 'sales-sdk-demo';

/**
 * SalesSdkDemo：salesSdk 内部使用的真实 SDK 示例页面。
 *
 * 不 mock 数据，必须运行在可访问 `appHelper.utils.pisellos` 的业务环境中。
 *
 * 拆成「详情展示 / 新建 / 编辑」三个 Tab：
 *  - 详情 Tab：只读，演示 sales.loadDetail 流程
 *  - 新建 Tab：一键串行 createNew → 选客户 → 加车 → recalcSummary → submit
 *  - 编辑 Tab：一键串行 loadDetail → 选客户 → 加车 → recalcSummary → submit
 *
 * 每个 Tab 各自包一层 SalesSdkProvider（osKey 后缀 `-detail / -create / -edit`，外部 osKey
 * prop 作前缀），状态完全隔离；切换 Tab 时不活跃 Tab 通过 `destroyInactiveTabPane` 自动卸载，
 * 避免同时挂三个 BookingTicket 实例。
 *
 * 三个 Provider 都关掉 autoBootstrap：业务接口需由用户显式点击「一键」触发，
 * 避免「切到 Tab 就调真实接口」的副作用。
 */
export function SalesSdkDemo(_ref) {
  var _providerCommon$other;
  var _ref$osKey = _ref.osKey,
    osKey = _ref$osKey === void 0 ? DEFAULT_OS_KEY : _ref$osKey,
    orderId = _ref.orderId,
    businessCode = _ref.businessCode,
    otherParams = _ref.otherParams,
    rulesHooks = _ref.rulesHooks,
    className = _ref.className;
  var rootClassName = ['sales-sdk-demo', className].filter(Boolean).join(' ');
  var baseOsKey = osKey || DEFAULT_OS_KEY;
  var providerCommon = {
    businessCode: businessCode,
    otherParams: otherParams,
    rulesHooks: rulesHooks,
    autoBootstrap: false
  };
  if (!((_providerCommon$other = providerCommon.otherParams) !== null && _providerCommon$other !== void 0 && _providerCommon$other.platform)) {
    providerCommon.otherParams = {
      platform: 'shop'
    };
  }
  return /*#__PURE__*/React.createElement("div", {
    className: rootClassName
  }, /*#__PURE__*/React.createElement(Tabs, {
    className: "sales-sdk-demo__tabs",
    defaultActiveKey: "create",
    destroyInactiveTabPane: true,
    items: [{
      key: 'detail',
      label: '详情展示',
      children: /*#__PURE__*/React.createElement(SalesSdkProvider, _extends({
        osKey: "".concat(baseOsKey, "-detail")
      }, providerCommon), /*#__PURE__*/React.createElement(DemoTabDetail, {
        initialOrderId: orderId !== null && orderId !== void 0 ? orderId : FIXTURE_DETAIL.orderId
      }))
    }, {
      key: 'create',
      label: '新建',
      children: /*#__PURE__*/React.createElement(SalesSdkDemoTabShell, _extends({
        osKey: "".concat(baseOsKey, "-create")
      }, providerCommon), /*#__PURE__*/React.createElement(DemoTabCreate, null))
    }, {
      key: 'edit',
      label: '编辑',
      children: /*#__PURE__*/React.createElement(SalesSdkDemoTabShell, _extends({
        osKey: "".concat(baseOsKey, "-edit")
      }, providerCommon), /*#__PURE__*/React.createElement(DemoTabEdit, {
        initialOrderId: orderId !== null && orderId !== void 0 ? orderId : FIXTURE_EDIT.orderId
      }))
    }]
  }));
}
export default SalesSdkDemo;