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/SelectFloorMapResourceDialog.tsx
var SelectFloorMapResourceDialog_exports = {};
__export(SelectFloorMapResourceDialog_exports, {
  SelectFloorMapResourceDialog: () => SelectFloorMapResourceDialog,
  default: () => SelectFloorMapResourceDialog_default
});
module.exports = __toCommonJS(SelectFloorMapResourceDialog_exports);
var import_react = __toESM(require("react"));
var import_dayjs = __toESM(require("dayjs"));
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_PisellReservation = require("../PisellReservation");
var import_SelectFloorMapResourceDialog = require("./SelectFloorMapResourceDialog.less");
var I18N_TITLE = "pisell-reservation.select-resource.title";
var DIALOG_WIDTH = "99%";
var DIALOG_BODY_STYLE = { padding: 0, height: "100%" };
function normalizeScheduleValue(value) {
  if (value == null) return void 0;
  const rawAt = typeof value === "string" ? value : value.at;
  const at = (0, import_dayjs.default)(rawAt);
  if (!at.isValid()) return void 0;
  const rawDate = typeof value === "string" ? void 0 : value.date;
  const parsedDate = (0, import_dayjs.default)(rawDate);
  const date = rawDate != null && parsedDate.isValid() ? parsedDate.startOf("day") : at.startOf("day");
  return { date, at };
}
function SelectFloorMapResourceDialog({
  open,
  onClose,
  onClick,
  reservationBiz,
  businessCode,
  associatedMenuListIds,
  scheduleValue,
  floorPlanId,
  floorPlanCode,
  floorPlanCanvasWidth,
  floorPlanCanvasHeight,
  dataSources,
  floorMap,
  title
}) {
  const handleSelectResource = (0, import_react.useCallback)(
    (payload) => {
      onClick == null ? void 0 : onClick(payload);
    },
    [onClick]
  );
  const resourceSelectMode = (0, import_react.useMemo)(
    () => ({
      enabled: true,
      onSelectResource: handleSelectResource
    }),
    [handleSelectResource]
  );
  const normalizedScheduleValue = (0, import_react.useMemo)(
    () => normalizeScheduleValue(scheduleValue),
    [scheduleValue]
  );
  return /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellModal,
    {
      platform: "pc",
      open,
      onCancel: onClose,
      title: title ?? import_utils.locales.getText(I18N_TITLE),
      footer: null,
      destroyOnClose: true,
      width: DIALOG_WIDTH,
      className: "pisell-select-floor-map-resource-dialog-modal",
      bodyStyle: DIALOG_BODY_STYLE,
      wrapClassName: "pisell-select-floor-map-resource-dialog"
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-select-floor-map-resource-dialog-content" }, /* @__PURE__ */ import_react.default.createElement(
      import_PisellReservation.PisellReservationCore,
      {
        reservationBiz: reservationBiz ?? businessCode,
        associatedMenuListIds,
        scheduleValue: normalizedScheduleValue,
        floorPlanId,
        floorPlanCode,
        floorPlanCanvasWidth,
        floorPlanCanvasHeight,
        dataSources,
        floorMap,
        bodyViewSwitchable: false,
        lockedBodyView: "floorMap",
        resourceSelectMode
      }
    ))
  );
}
var SelectFloorMapResourceDialog_default = SelectFloorMapResourceDialog;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  SelectFloorMapResourceDialog
});
