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/components/shoppingCart/utils.ts
var utils_exports = {};
__export(utils_exports, {
  formatCartList: () => formatCartList,
  formatService: () => formatService,
  formatState: () => formatState,
  isEmptyStatus: () => isEmptyStatus,
  isProductList: () => isProductList,
  updateProduct: () => updateProduct
});
module.exports = __toCommonJS(utils_exports);
var formatCartList = (state) => {
  const { products, holders } = state;
  return holders == null ? void 0 : holders.map((holder) => {
    return {
      ...holder,
      products: products == null ? void 0 : products.filter(
        (product) => (product == null ? void 0 : product.holder_id) === (holder == null ? void 0 : holder.key)
      )
    };
  });
};
var isEmptyStatus = (state) => {
  const { products, holders, isOpenGroup } = state;
  if (!isOpenGroup && !(products == null ? void 0 : products.length)) return true;
  if (isOpenGroup && !(holders == null ? void 0 : holders.length)) return true;
  return false;
};
var isProductList = (state) => {
  const { holders, isOpenGroup } = state;
  if (isOpenGroup && (holders == null ? void 0 : holders.length)) return false;
  return true;
};
var formatState = (state) => {
  const _default = { ...state };
  const _carts = formatCartList(_default);
  return {
    isEmpty: isEmptyStatus(_default),
    isProductList: isProductList(_default),
    carts: _carts
  };
};
var updateProduct = (state, newProducts) => {
  return {
    products: newProducts,
    carts: formatCartList({ ...state, products: newProducts })
  };
};
var formatService = (service, id) => {
  return service.map((item) => {
    return {
      ...item,
      holder_id: id
    };
  });
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  formatCartList,
  formatService,
  formatState,
  isEmptyStatus,
  isProductList,
  updateProduct
});
