/*
 * Copyright 2026 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 from "react";
import { formatCbacError } from "../utils/errorMessages.js";
import { BaseCbacBanner } from "./BaseCbacBanner.js";
import { CategoryMarkingGroup } from "./CategoryMarkingGroup.js";
import { InfoBanner } from "./InfoBanner.js";
import { ValidationWarning } from "./ValidationWarning.js";
import styles from "./BaseCbacPicker.module.css.js";
export function BaseCbacPicker({
  categories,
  markingStates,
  banner,
  onMarkingToggle,
  onDismissBanner,
  showInfoBanner,
  requiredMarkingGroups,
  isValid,
  readOnly,
  isLoading,
  error,
  validationCallouts,
  className
}) {
  const errorMessage = error != null ? formatCbacError(error) : undefined;
  const showInitialLoading = isLoading === true && categories.length === 0;
  const showValidationWarning = isValid === false && requiredMarkingGroups != null && requiredMarkingGroups.length > 0;
  return /*#__PURE__*/React.createElement("div", {
    className: classnames(styles.picker, className)
  }, showInfoBanner === true && /*#__PURE__*/React.createElement(InfoBanner, {
    message: "Implied markings are (in parentheses)."
  }), banner != null && /*#__PURE__*/React.createElement(BaseCbacBanner, {
    classificationString: banner.classificationString,
    textColor: banner.textColor,
    backgroundColors: banner.backgroundColors,
    onDismiss: onDismissBanner,
    className: styles.innerBanner
  }), errorMessage !== undefined ? /*#__PURE__*/React.createElement("div", {
    className: styles.statusMessage,
    role: "alert"
  }, /*#__PURE__*/React.createElement("p", null, errorMessage.title), errorMessage.remediation && /*#__PURE__*/React.createElement("p", null, errorMessage.remediation)) : showInitialLoading ? /*#__PURE__*/React.createElement("div", {
    className: styles.statusMessage,
    role: "status",
    "aria-live": "polite"
  }, "Loading...") : /*#__PURE__*/React.createElement("div", {
    className: styles.categoriesContainer
  }, categories.map(group => /*#__PURE__*/React.createElement(CategoryMarkingGroup, {
    key: group.category.id,
    categoryName: group.category.name,
    categoryDescription: group.category.description,
    markings: group.markings,
    markingStates: markingStates,
    readOnly: readOnly,
    onMarkingToggle: onMarkingToggle
  }))), validationCallouts, showValidationWarning && /*#__PURE__*/React.createElement(ValidationWarning, {
    requiredMarkingGroups: requiredMarkingGroups
  }));
}
//# sourceMappingURL=BaseCbacPicker.js.map