import React from "react";
import { arrayMoveImmutable } from "../utils.js";
import { MediaItemActionMenu } from "./media-item-action-menu.js";
import { SortableList } from "./sortable-list.js";
const MediaList = ({
  onFileSelect,
  onEditClick,
  onItemDoubleClick,
  galleryItems,
  onChange,
  logBi
}) => {
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
    MediaItemActionMenu,
    {
      items: galleryItems,
      onSelectAllClick: () => onChange({
        type: "selection",
        items: galleryItems.map((item) => ({ ...item, selected: true }))
      }),
      onUnselectAllClick: () => onChange({
        type: "selection",
        items: galleryItems.map((item) => ({ ...item, selected: false }))
      }),
      onDeleteClick: () => {
        onChange({ type: "delete", items: galleryItems.filter((i) => !i.selected) });
      },
      onEditClick,
      logBi
    }
  ), /* @__PURE__ */ React.createElement(
    SortableList,
    {
      items: galleryItems,
      onSortEnd: ({ oldIndex, newIndex }) => {
        if (oldIndex !== newIndex) {
          const sortedItems = arrayMoveImmutable(galleryItems, oldIndex, newIndex);
          onChange({ type: "sort", items: sortedItems });
        }
      },
      onItemClick: (id) => {
        onChange({
          type: "selection",
          items: galleryItems.map((item, index) => ({
            ...item,
            selected: index === id ? !item.selected : item.selected
          }))
        });
      },
      onItemDoubleClick,
      onFileSelect,
      logBi
    }
  ));
};
export {
  MediaList
};
//# sourceMappingURL=media-list.js.map
