var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/pisellReservation/data/reservationDataUtils.ts
var reservationDataUtils_exports = {};
__export(reservationDataUtils_exports, {
  mergeGridBookingSearchParams: () => mergeGridBookingSearchParams,
  mergeSearchParamsBookingWindow: () => mergeSearchParamsBookingWindow,
  readBodyViewFromStorageKey: () => readBodyViewFromStorageKey,
  readPersistedReservationBodyView: () => readPersistedReservationBodyView,
  shouldUseBuiltinReservationList: () => shouldUseBuiltinReservationList
});
module.exports = __toCommonJS(reservationDataUtils_exports);
var import_reservationConstants = require("../reservationConstants");
var import_usePisellReservationBookingData = require("../hooks/usePisellReservationBookingData");
function shouldUseBuiltinReservationList(dataProp, totalProp, paginationProp, onPageChangeProp) {
  if (dataProp == null) return true;
  return Array.isArray(dataProp) && dataProp.length === 0 && totalProp === void 0 && onPageChangeProp === void 0;
}
function mergeGridBookingSearchParams(params) {
  const p = params && typeof params === "object" ? { ...params } : {};
  const filterRaw = p.filter;
  const filter = typeof filterRaw === "object" && filterRaw !== null && !Array.isArray(filterRaw) ? { ...filterRaw } : {};
  const valuesRaw = filter.values;
  const values = typeof valuesRaw === "object" && valuesRaw !== null && !Array.isArray(valuesRaw) ? { ...valuesRaw } : {};
  if (!Array.isArray(values.order_payment_status) || values.order_payment_status.length === 0) {
    values.order_payment_status = void 0;
  }
  return {
    ...p,
    filter: {
      ...filter,
      values
    }
  };
}
function mergeSearchParamsBookingWindow(prev, anchorDay) {
  const prevFilter = typeof prev.filter === "object" && prev.filter ? prev.filter : {};
  const prevValues = typeof prevFilter.values === "object" && prevFilter.values ? prevFilter.values : {};
  return {
    ...prev,
    filter: {
      ...prevFilter,
      values: {
        ...prevValues,
        booking_time_start_between: (0, import_usePisellReservationBookingData.bookingTimeWindowForAnchorDay)(anchorDay)
      }
    }
  };
}
function readBodyViewFromStorageKey(key) {
  if (typeof window === "undefined" || !key) return "floorMap";
  try {
    const raw = localStorage.getItem(key);
    if (raw === "grid" || raw === "floorMap") return raw;
  } catch {
  }
  return "floorMap";
}
function readPersistedReservationBodyView() {
  return readBodyViewFromStorageKey(import_reservationConstants.PISELL_RESERVATION_BODY_VIEW_STORAGE_KEY);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  mergeGridBookingSearchParams,
  mergeSearchParamsBookingWindow,
  readBodyViewFromStorageKey,
  readPersistedReservationBodyView,
  shouldUseBuiltinReservationList
});
