import { Component, QueryLanguage, wrapFilterInHasOnes, HasMany } from "@contember/binding";
import { FieldContainer, Checkbox } from "@contember/ui";
import { jsx } from "react/jsx-runtime";
import { DataGridColumn } from "../base/DataGridColumn.js";
const HasManyAbsentCell = Component((props) => {
  return /* @__PURE__ */ jsx(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__ */ jsx(FieldContainer, {
        label: "Has any",
        labelPosition: "labelInlineRight",
        children: /* @__PURE__ */ jsx(Checkbox, {
          notNull: true,
          value: filter,
          onChange: (checked) => setFilter(!!checked)
        })
      });
    },
    children: /* @__PURE__ */ jsx(HasMany, {
      ...props,
      listComponent: props.render
    })
  });
}, "HasManyAbsentCell");
export {
  HasManyAbsentCell
};
//# sourceMappingURL=HasManyAbsentCell.js.map
