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 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); }
import React, { useLayoutEffect, useMemo, useRef } from 'react';
import { Provider, createStore } from "./miniRedux";
import { locales } from '@pisell/utils';
import dayjs from 'dayjs';
import { cloneDeep } from 'lodash';
import TicketBooking from "./components/ticketBooking/index";
import { request } from "../../utils";
import useEngineContext from "../../hooks/useEngineContext";
import { getDefaultStartParam } from "./utils";
import localeTexts from "./locales";
import MenuBar from "./components/menuBar";
import "./index.less";
var initialState = {
  amountSymbol: '$',
  modalState: {
    client: {
      showModal: false,
      clients: [],
      value: {
        id: 0,
        nickname: 'Select a customer'
      },
      clientsParams: {
        skip: 1,
        num: 100,
        search: ''
      },
      edit: false
    },
    date: {
      value: dayjs(),
      edit: false
    },
    service: {
      addModal: false,
      editModal: false,
      reloadResourceModal: false,
      services: [],
      resources: [],
      value: [],
      cacheItem: null,
      edit: false
    },
    pet: {
      showModal: false,
      pets: [],
      value: {},
      edit: false
    },
    addons: {
      showModal: false,
      value: [],
      productList: [],
      originData: [],
      edit: false,
      load: false
    },
    form: {
      value: {},
      forms: [],
      edit: false
    },
    notes: {
      orderNote: '',
      internalNotes: [],
      edit: false
    },
    // 是否禁用编辑
    disabledEdit: false,
    // 渠道禁止编辑
    channelDisabledEdit: false,
    // 预约状态
    appointment_status: 'new',
    eventOtherParams: undefined
  },
  bookingConfig: null,
  bookingDetail: null,
  bookingId: 0,
  loading: false,
  open: false,
  isShowDeposit: false,
  activeKey: 'info',
  exitModal: false,
  rebookState: {
    open: false,
    date: '2024-03-13 18:00'
  },
  bookingFunctions: {},
  // Event活动预约抽屉
  eventOpen: false,
  renderType: 'booking',
  // 是否是rebook模式
  openRebook: false,
  // 禁用活动预约编辑
  disableEventBookingEdit: false,
  isShowInfo: false,
  // 是否pin住
  persistent: true,
  // persistent:
  //   this.utils.storage.get(`drawer-booking`) === 'true' ??
  //   this.utils.isTerminal(),
  // 是否定时设置当前时间
  intervalSetTime: true,
  // 时间是否更改
  isTimeChange: false,
  // 日期是否更改
  isDateChange: false,
  list: {
    /** 列表loading */
    isLoading: false,
    /** 预约列表数据 */
    bookingList: [],
    /** 预约列表查询参数 */
    params: _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, 'with', ['order', 'order.customer', 'contacts', 'item', 'appointmentForm.formRecord', 'holder.formRecord']), "booking_time_start_between", getDefaultStartParam()), "child_booking", 1), "skip", 1), "num", 1000),
    showList: [],
    listSelectType: 'all',
    search: '',
    sort: ''
  },
  confirmOpen: false,
  createCount: 0,
  verticalAddServiceKey: 0,
  currentProduct: null,
  bookingConfigParams: {
    item_type: 'appointment_booking'
  },
  productExtensionType: ['appointment_ticket', 'session_ticket', "product_appointment", "service_product", "session_product", "normal", 'product_appointment']
};
export default (function (props) {
  var _context$appHelper$ut;
  var productExtensionType = props.productExtensionType,
    bookingConfigParams = props.bookingConfigParams;
  var storeRef = useRef(null);
  var context = useEngineContext();
  locales.init(localeTexts, ((_context$appHelper$ut = context.appHelper.utils) === null || _context$appHelper$ut === void 0 || (_context$appHelper$ut = _context$appHelper$ut.storage) === null || _context$appHelper$ut === void 0 ? void 0 : _context$appHelper$ut.get('umi_locale')) || 'en');
  useLayoutEffect(function () {
    request.setRequest(context.appHelper.utils.request);
  }, []);
  useMemo(function () {
    var store = createStore(_objectSpread(_objectSpread({}, cloneDeep(initialState)), {}, {
      bookingConfigParams: bookingConfigParams,
      productExtensionType: productExtensionType
    }));
    storeRef.current = store;
  }, []);
  return /*#__PURE__*/React.createElement("div", {
    className: "pisell-ticket-booking-wrapper"
  }, /*#__PURE__*/React.createElement(MenuBar, null), /*#__PURE__*/React.createElement(Provider, {
    store: storeRef.current
  }, /*#__PURE__*/React.createElement(TicketBooking, null)));
});