import { QueryLanguage } from "@contember/binding";
import { FieldContainer, Checkbox } from "@contember/ui";
import { dataGridCellsDictionary } from "./dataGridCellsDictionary.js";
import { jsxDEV } from "react/jsx-dev-runtime";
import { useMessageFormatter } from "../../../../../i18n/useMessageFormatter.js";
var _jsxFileName = "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/DataGrid/cells/NullConditionFilter.tsx";
const NullConditionFilter = ({
  filter,
  setFilter,
  field,
  environment,
  showNullConditionFilter
}) => {
  const formatMessage = useMessageFormatter(dataGridCellsDictionary);
  const desugared = QueryLanguage.desugarRelativeSingleField(field, environment);
  const entitySchema = environment.getSubTreeNode().entity;
  const fieldSchema = entitySchema.fields.get(desugared.field);
  const showFilter = showNullConditionFilter ?? fieldSchema?.nullable === true;
  if (!showFilter) {
    return null;
  }
  return /* @__PURE__ */ jsxDEV(FieldContainer, {
    label: /* @__PURE__ */ jsxDEV("i", {
      style: {
        opacity: 0.8,
        fontWeight: "normal"
      },
      children: formatMessage("dataGridCells.includeNull")
    }, void 0, false, {
      fileName: _jsxFileName,
      lineNumber: 33,
      columnNumber: 11
    }, void 0),
    labelPosition: "labelInlineRight",
    children: /* @__PURE__ */ jsxDEV(Checkbox, {
      notNull: true,
      value: filter.nullCondition,
      onChange: (checked) => {
        setFilter({
          ...filter,
          nullCondition: !!checked
        });
      }
    }, void 0, false, {
      fileName: _jsxFileName,
      lineNumber: 38,
      columnNumber: 4
    }, void 0)
  }, "__null", false, {
    fileName: _jsxFileName,
    lineNumber: 31,
    columnNumber: 3
  }, void 0);
};
export {
  NullConditionFilter
};
//# sourceMappingURL=NullConditionFilter.js.map
