/*
 * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import classnames from "classnames";
import React, { memo, useCallback } from "react";
import { Checkbox } from "../../../base-components/checkbox/Checkbox.js";
import { formatCompactCount } from "./formatCompactCount.js";
import { NoValueLabel } from "./NoValueLabel.js";
import styles from "./NullValueWrapper.module.css.js";
import sharedStyles from "./shared.module.css.js";
function NullValueWrapperInner({
  nullCount,
  isLoading,
  error,
  includeNull = false,
  onIncludeNullChange,
  showNullCount = true,
  children,
  className,
  style
}) {
  const handleToggle = useCallback(() => {
    onIncludeNullChange(!includeNull);
  }, [includeNull, onIncludeNullChange]);
  return /*#__PURE__*/React.createElement("div", {
    className: classnames(styles.nullWrapper, className),
    style: style
  }, children, /*#__PURE__*/React.createElement("div", {
    className: styles.nullValueRow,
    "data-checked": includeNull,
    "data-loading": isLoading
  }, /*#__PURE__*/React.createElement("label", {
    className: styles.nullLabel
  }, /*#__PURE__*/React.createElement(Checkbox, {
    checked: includeNull,
    onCheckedChange: handleToggle
  }), /*#__PURE__*/React.createElement(NoValueLabel, {
    className: styles.noValueLabel
  })), showNullCount && !error && /*#__PURE__*/React.createElement("span", {
    className: styles.count,
    title: nullCount.toLocaleString()
  }, formatCompactCount(nullCount))), error && /*#__PURE__*/React.createElement("div", {
    className: sharedStyles.errorMessage
  }, "Failed to load null count"));
}
export const NullValueWrapper = /*#__PURE__*/memo(NullValueWrapperInner);
//# sourceMappingURL=NullValueWrapper.js.map