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/salesSdk/utils/ensureMultiDayRangeSelected.ts
var ensureMultiDayRangeSelected_exports = {};
__export(ensureMultiDayRangeSelected_exports, {
  ensureMultiDayRangeSelected: () => ensureMultiDayRangeSelected
});
module.exports = __toCommonJS(ensureMultiDayRangeSelected_exports);
var import_patchCacheItemDateRange = require("./patchCacheItemDateRange");
var import_resolveIsMultiDayProduct = require("./resolveIsMultiDayProduct");
async function ensureMultiDayRangeSelected(input) {
  var _a, _b, _c, _d, _e, _f;
  const needsMultiDay = (0, import_resolveIsMultiDayProduct.resolveIsMultiDayProduct)(
    input.detail,
    input.cacheItem,
    input.catalogItem,
    input.product
  );
  if (!needsMultiDay) {
    return { status: "skip" };
  }
  if (input.existingRange) {
    const cacheItem2 = input.cacheItem ? (0, import_patchCacheItemDateRange.patchCacheItemDateRange)(input.cacheItem, input.existingRange) : void 0;
    return { status: "ok", range: input.existingRange, cacheItem: cacheItem2 };
  }
  const openMultiDay = (_a = input.hosts) == null ? void 0 : _a.openMultiDaySelect;
  if (!openMultiDay) {
    return { status: "missing_host" };
  }
  const label = ((_b = input.detail) == null ? void 0 : _b.title) || ((_c = input.catalogItem) == null ? void 0 : _c.title) || ((_d = input.product) == null ? void 0 : _d.title) || ((_f = (_e = input.cacheItem) == null ? void 0 : _e._extend) == null ? void 0 : _f.product_name);
  const range = await openMultiDay({
    productName: label,
    defaultStartDate: input.defaultStartDate ?? null
  });
  if (!range) {
    return { status: "cancelled" };
  }
  const cacheItem = input.cacheItem ? (0, import_patchCacheItemDateRange.patchCacheItemDateRange)(input.cacheItem, range) : void 0;
  return { status: "ok", range, cacheItem };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ensureMultiDayRangeSelected
});
