var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/pisellReservation/components/ReservationNewReservationModal.tsx
var ReservationNewReservationModal_exports = {};
__export(ReservationNewReservationModal_exports, {
  ReservationNewReservationModal: () => ReservationNewReservationModal
});
module.exports = __toCommonJS(ReservationNewReservationModal_exports);
var import_react = __toESM(require("react"));
var import_ahooks = require("ahooks");
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_useNewReservationRoutesFromEngine = require("../hooks/useNewReservationRoutesFromEngine");
var import_reservationConstants = require("../reservationConstants");
var ReservationNewReservationModal = (0, import_react.forwardRef)(function ReservationNewReservationModal2({ router, app }, ref) {
  const newReservationRoutes = (0, import_useNewReservationRoutesFromEngine.useNewReservationRoutesFromEngine)(router);
  const [open, setOpen] = (0, import_react.useState)(false);
  const handleRouteJump = (0, import_ahooks.useMemoizedFn)((routePath) => {
    var _a, _b;
    if (!routePath) return;
    setOpen(false);
    (_b = (_a = app == null ? void 0 : app.history) == null ? void 0 : _a.push) == null ? void 0 : _b.call(_a, routePath);
  });
  const requestOpen = (0, import_ahooks.useMemoizedFn)(() => {
    if (newReservationRoutes.length === 1) {
      handleRouteJump(newReservationRoutes[0].router);
      return;
    }
    setOpen(true);
  });
  (0, import_react.useImperativeHandle)(ref, () => ({ requestOpen }), [requestOpen]);
  const handleClose = (0, import_ahooks.useMemoizedFn)(() => {
    setOpen(false);
  });
  return /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellModal,
    {
      platform: "pc",
      open,
      title: import_utils.locales.getText(import_reservationConstants.I18N_NEW_MODAL_TITLE),
      onCancel: handleClose,
      maskClosable: true,
      footer: null,
      width: 520,
      wrapClassName: "pisell-reservation-new-modal-wrap",
      destroyOnClose: true
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-reservation-new-modal-placeholder" }, newReservationRoutes.length > 0 ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-reservation-new-modal-route-list" }, newReservationRoutes.map((routeItem) => /* @__PURE__ */ import_react.default.createElement(
      "button",
      {
        key: `${routeItem.router}-${routeItem.pageName}`,
        type: "button",
        className: "pisell-reservation-new-modal-route-item",
        onClick: () => handleRouteJump(routeItem.router)
      },
      /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-reservation-new-modal-route-name" }, routeItem.pageName),
      /* @__PURE__ */ import_react.default.createElement(
        import_materials.Icon,
        {
          type: "icon-right-arrow",
          className: "pisell-reservation-new-modal-route-arrow"
        }
      )
    ))) : /* @__PURE__ */ import_react.default.createElement("p", { className: "pisell-reservation-new-modal-empty" }, import_utils.locales.getText(import_reservationConstants.I18N_NEW_MODAL_PLACEHOLDER)))
  );
});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ReservationNewReservationModal
});
