import { cx } from '@linaria/core';
import { Typo } from '../../../core/Typo/index.js';
import React__default from 'react';
import { SmallDialog } from '../../../core/SmallDialog/SmallDialog.js';
import { RejectDialogType } from './RejectDialog.type.js';

const ContentList = "E_c1ss4prm";
const MultiRejectContentList = "E_ms3tlei";
const Description = "E_du44iy7";
const SecondaryDesc = "E_s1qmhanr";
const Divider = "E_drje1h0";
const SingleRejectContent = ({
  content
}) => {
  if (Array.isArray(content) && content.length > 1) {
    return /* @__PURE__ */React__default.createElement("div", {
      className: cx(ContentList)
    }, content.map((reason, index) => /* @__PURE__ */React__default.createElement("li", {
      className: Typo.Label.l4_regular,
      key: index
    }, index + 1, ". ", reason)));
  }
  return /* @__PURE__ */React__default.createElement("div", {
    className: cx(ContentList, Typo.Label.l4_regular)
  }, content);
};
const MultiRejectContent = ({
  content
}) => /* @__PURE__ */React__default.createElement("div", {
  className: cx(MultiRejectContentList)
}, Object.entries(content).map(([name, reasons], index) => /* @__PURE__ */React__default.createElement("li", {
  className: Typo.Label.l4_regular,
  key: index
}, name, ": ", reasons.join("; "))));
const RejectDialog = props => {
  const {
    title,
    cancelText,
    description,
    className,
    footerClassName
  } = props;
  const renderContent = () => {
    switch (props.type) {
      case RejectDialogType.Single:
        return /* @__PURE__ */React__default.createElement(SingleRejectContent, {
          content: props.content
        });
      case RejectDialogType.All:
      case RejectDialogType.Part:
        return /* @__PURE__ */React__default.createElement(React__default.Fragment, null, props.secondaryDesc && /* @__PURE__ */React__default.createElement("div", {
          className: cx(SecondaryDesc, Typo.Label.l4_regular)
        }, props.secondaryDesc), props.type === RejectDialogType.Part && /* @__PURE__ */React__default.createElement(React__default.Fragment, null, /* @__PURE__ */React__default.createElement("div", {
          className: Divider
        }), /* @__PURE__ */React__default.createElement("div", {
          className: cx(Description, Typo.Label.l3_regular)
        }, props.partialDescription)), /* @__PURE__ */React__default.createElement(MultiRejectContent, {
          content: props.content
        }));
      case RejectDialogType.Custom:
        return props.customContent;
    }
  };
  return /* @__PURE__ */React__default.createElement(SmallDialog, {
    title,
    cancelText,
    showOk: props.type === RejectDialogType.Part,
    okText: props.type === RejectDialogType.Part ? props.okText : void 0,
    onOk: props.type === RejectDialogType.Part ? props.onOk : void 0,
    okButtonProps: {
      danger: props.type === RejectDialogType.Part
    },
    onCancel: props.onCancel,
    className,
    footerClassName
  }, description && /* @__PURE__ */React__default.createElement("div", {
    className: cx(Description, Typo.Label.l3_regular)
  }, description), renderContent());
};

export { RejectDialog };
