import { createElement } from "react";
import { Component, QueryLanguage, wrapFilterInHasOnes, HasMany } from "@contember/binding";
import { FieldContainer, Checkbox } from "@contember/ui";
import { DataGridColumn } from "../base/DataGridColumn.js";
const HasManyAbsentCell = Component((props) => {
  return /* @__PURE__ */ createElement(DataGridColumn, {
    ...props,
    enableOrdering: false,
    getNewFilter: (filter, { environment }) => {
      if (filter === false) {
        return void 0;
      }
      const desugared = QueryLanguage.desugarRelativeEntityList(props, environment);
      return wrapFilterInHasOnes(desugared.hasOneRelationPath, {
        [desugared.hasManyRelation.field]: {
          id: {
            not: { isNull: true }
          }
        }
      });
    },
    emptyFilter: false,
    filterRenderer: ({ filter, setFilter }) => {
      return /* @__PURE__ */ createElement(FieldContainer, {
        label: "Has any",
        labelPosition: "labelInlineRight"
      }, /* @__PURE__ */ createElement(Checkbox, {
        notNull: true,
        value: filter,
        onChange: (checked) => setFilter(!!checked)
      }));
    }
  }, /* @__PURE__ */ createElement(HasMany, {
    ...props,
    listComponent: props.render
  }));
}, "HasManyAbsentCell");
export { HasManyAbsentCell };
//# sourceMappingURL=HasManyAbsentCell.js.map
