"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxDevRuntime = require("react/jsx-dev-runtime");
const reactBinding = require("@contember/react-binding");
const ui = require("@contember/ui");
const react = require("react");
const reactBindingUi = require("@contember/react-binding-ui");
const LayoutRenderer = require("../LayoutRenderer.cjs");
const ImmutableEntityListTablePageRenderer = reactBinding.Component(
  ({
    enableRemoving = true,
    children,
    tableProps,
    tableRowProps,
    accessor,
    emptyMessage,
    emptyMessageComponent,
    afterTitle,
    ...layoutProps
  }) => {
    return /* @__PURE__ */ jsxDevRuntime.jsxDEV(
      LayoutRenderer.LayoutRenderer,
      {
        ...layoutProps,
        children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(TableRenderer, { accessor, ...{ emptyMessage, emptyMessageComponent }, ...tableProps, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(TableRowRenderer, { ...tableRowProps, enableRemoving, children }, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/pageRenderers/ImmutableEntityListTablePageRenderer.tsx",
          lineNumber: 34,
          columnNumber: 6
        }, void 0) }, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/pageRenderers/ImmutableEntityListTablePageRenderer.tsx",
          lineNumber: 33,
          columnNumber: 5
        }, void 0)
      },
      void 0,
      false,
      {
        fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/pageRenderers/ImmutableEntityListTablePageRenderer.tsx",
        lineNumber: 30,
        columnNumber: 4
      },
      void 0
    );
  },
  "ImmutableEntityListTablePageRenderer"
);
const TableRenderer = reactBinding.Component(
  ({ accessor, children, ...props }) => {
    const isEmpty = !Array.from(accessor).some((entity) => entity instanceof reactBinding.EntityAccessor && entity.existsOnServer);
    if (isEmpty) {
      return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBindingUi.EmptyMessage, { component: props.emptyMessageComponent, children: props.emptyMessage ?? "There are no items to display." }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/pageRenderers/ImmutableEntityListTablePageRenderer.tsx",
        lineNumber: 59,
        columnNumber: 5
      }, void 0);
    }
    return /* @__PURE__ */ jsxDevRuntime.jsxDEV(ui.Table, { ...props, children: Array.from(accessor).map((it, i) => /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.Entity, { accessor: it, children }, i, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/pageRenderers/ImmutableEntityListTablePageRenderer.tsx",
      lineNumber: 66,
      columnNumber: 6
    }, void 0)) }, void 0, false, {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/pageRenderers/ImmutableEntityListTablePageRenderer.tsx",
      lineNumber: 64,
      columnNumber: 4
    }, void 0);
  },
  ({ children }) => /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/pageRenderers/ImmutableEntityListTablePageRenderer.tsx",
    lineNumber: 73,
    columnNumber: 20
  }, void 0),
  "TableContainerRenderer"
);
const TableRowRenderer = react.memo((props) => /* @__PURE__ */ jsxDevRuntime.jsxDEV(ui.TableRow, { ...props, children: [
  props.children,
  props.enableRemoving && /* @__PURE__ */ jsxDevRuntime.jsxDEV(ui.TableCell, { shrunk: true, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBindingUi.DeleteEntityButton, { immediatePersist: true }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/pageRenderers/ImmutableEntityListTablePageRenderer.tsx",
    lineNumber: 89,
    columnNumber: 5
  }, void 0) }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/pageRenderers/ImmutableEntityListTablePageRenderer.tsx",
    lineNumber: 88,
    columnNumber: 4
  }, void 0)
] }, void 0, true, {
  fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/renderers/pageRenderers/ImmutableEntityListTablePageRenderer.tsx",
  lineNumber: 85,
  columnNumber: 2
}, void 0));
ui.TableRow.displayName = "TableRowRenderer";
exports.ImmutableEntityListTablePageRenderer = ImmutableEntityListTablePageRenderer;
exports.TableRenderer = TableRenderer;
//# sourceMappingURL=ImmutableEntityListTablePageRenderer.cjs.map
