import { Component, QueryLanguage, wrapFilterInHasOnes, HasMany } from "@contember/binding";
import { FieldContainer, Checkbox } from "@contember/ui";
import { jsxDEV } from "react/jsx-dev-runtime";
import { DataGridColumn } from "../base/DataGridColumn.js";
var _jsxFileName = "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/DataGrid/cells/HasManyAbsentCell.tsx";
const HasManyAbsentCell = Component((props) => {
  return /* @__PURE__ */ jsxDEV(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__ */ jsxDEV(FieldContainer, {
        label: "Has any",
        labelPosition: "labelInlineRight",
        children: /* @__PURE__ */ jsxDEV(Checkbox, {
          notNull: true,
          value: filter,
          onChange: (checked) => setFilter(!!checked)
        }, void 0, false, {
          fileName: _jsxFileName,
          lineNumber: 48,
          columnNumber: 6
        }, void 0)
      }, void 0, false, {
        fileName: _jsxFileName,
        lineNumber: 44,
        columnNumber: 12
      }, void 0);
    },
    children: /* @__PURE__ */ jsxDEV(HasMany, {
      ...props,
      listComponent: props.render
    }, void 0, false, {
      fileName: _jsxFileName,
      lineNumber: 52,
      columnNumber: 4
    }, void 0)
  }, void 0, false, {
    fileName: _jsxFileName,
    lineNumber: 25,
    columnNumber: 3
  }, void 0);
}, "HasManyAbsentCell");
export {
  HasManyAbsentCell
};
//# sourceMappingURL=HasManyAbsentCell.js.map
