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/salesSdk/utils/multiDayPriceCache.ts
var multiDayPriceCache_exports = {};
__export(multiDayPriceCache_exports, {
  formatMultiDayBoundary: () => formatMultiDayBoundary,
  hasMatchingMultiDayQuotationOnCacheItem: () => hasMatchingMultiDayQuotationOnCacheItem,
  isMultiDayQuotationExpanded: () => isMultiDayQuotationExpanded
});
module.exports = __toCommonJS(multiDayPriceCache_exports);
var import_dayjs = __toESM(require("dayjs"));
function formatMultiDayBoundary(value) {
  if (value == null || value === "") return "";
  const d = (0, import_dayjs.default)(value);
  return d.isValid() ? d.format("YYYY-MM-DD") : String(value);
}
function hasMatchingMultiDayQuotationOnCacheItem(cacheItem) {
  const ext = cacheItem == null ? void 0 : cacheItem._extend;
  if (!(ext == null ? void 0 : ext.multiDayPrices) || typeof ext.multiDayPrices !== "object") {
    return false;
  }
  const keys = Object.keys(ext.multiDayPrices);
  if (!keys.length) return false;
  const start = formatMultiDayBoundary(ext.start_date ?? ext.startDate);
  const end = formatMultiDayBoundary(ext.end_date ?? ext.endDate);
  if (!start || !end) {
    return keys.length > 0;
  }
  return keys.includes(start);
}
function isMultiDayQuotationExpanded(cacheItem) {
  var _a;
  if (Array.isArray((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.items) && cacheItem._extend.items.length > 0) {
    return true;
  }
  return hasMatchingMultiDayQuotationOnCacheItem(cacheItem);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  formatMultiDayBoundary,
  hasMatchingMultiDayQuotationOnCacheItem,
  isMultiDayQuotationExpanded
});
