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/productSelect/ProductList/index.tsx
var ProductList_exports = {};
__export(ProductList_exports, {
  GRID_LAYOUTS: () => import_gridComponents.GRID_LAYOUTS,
  createCustomGrid: () => import_gridComponents.createCustomGrid,
  createGridComponents: () => import_gridComponents.createGridComponents,
  createTwoColumnGrid: () => import_gridComponents.createTwoColumnGrid,
  default: () => ProductList_default
});
module.exports = __toCommonJS(ProductList_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_gridComponents = require("./gridComponents");
var DefaultListComponent = (0, import_react.memo)(({ children, ...listProps }) => /* @__PURE__ */ import_react.default.createElement("div", { className: "product-list-wrapper", ...listProps }, children));
var DefaultItemComponent = (0, import_react.memo)(({ children, index, ...itemProps }) => /* @__PURE__ */ import_react.default.createElement("div", { ...itemProps, "data-index": index, "data-item-index": index }, children));
var ProductList = (0, import_react.forwardRef)((props, ref) => {
  const { className, data, context, components, itemContent } = props;
  const ListComponent = (0, import_react.useMemo)(
    () => (components == null ? void 0 : components.List) || DefaultListComponent,
    [components == null ? void 0 : components.List]
  );
  const ItemComponent = (0, import_react.useMemo)(
    () => (components == null ? void 0 : components.Item) || DefaultItemComponent,
    [components == null ? void 0 : components.Item]
  );
  const itemContentRenderer = (0, import_react.useMemo)(() => {
    if (itemContent) {
      return (item, index) => itemContent(index, item, context);
    }
    return (item, index) => /* @__PURE__ */ import_react.default.createElement("div", null, index);
  }, [itemContent, context]);
  const renderedItems = (0, import_react.useMemo)(() => {
    return data == null ? void 0 : data.map((item, index) => {
      const content = itemContentRenderer(item, index);
      return /* @__PURE__ */ import_react.default.createElement(
        ItemComponent,
        {
          key: `${item.id || index}-${index}`,
          item,
          index,
          "data-index": index,
          "data-item-index": index,
          context
        },
        content
      );
    });
  }, [data, ItemComponent, itemContentRenderer]);
  return /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_classnames.default)(className) }, /* @__PURE__ */ import_react.default.createElement(ListComponent, { ref, context }, renderedItems));
});
var ProductList_default = ProductList;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  GRID_LAYOUTS,
  createCustomGrid,
  createGridComponents,
  createTwoColumnGrid
});
