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

var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
  enumerable: true,
  configurable: true,
  writable: true,
  value
}) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
    if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
  }
  return a;
};
const ContentList = "E_4100_0_7_c1ss4prm";
const MultiRejectContentList = "E_4100_0_7_ms3tlei";
const Description = "E_4100_0_7_du44iy7";
const PartialDescription = "E_4100_0_7_p1qmhanr";
const SecondaryDesc = "E_4100_0_7_srje1h0";
const Divider = "E_4100_0_7_di3zi7v";
const SingleRejectContent = ({
  content,
  listType = "ordered",
  resourceIcon
}) => {
  if (listType === "resource" && Array.isArray(content)) {
    return /* @__PURE__ */React__default.createElement("div", {
      className: cx(MultiRejectContentList)
    }, content.map((name, index) => /* @__PURE__ */React__default.createElement("li", {
      className: Typo.Label.l4_regular,
      key: index
    }, resourceIcon, /* @__PURE__ */React__default.createElement("span", null, name))));
  }
  if (Array.isArray(content) && content.length > 1) {
    if (listType === "ordered") {
      return /* @__PURE__ */React__default.createElement("ol", {
        className: cx(ContentList)
      }, content.map((reason, index) => /* @__PURE__ */React__default.createElement("li", {
        className: Typo.Label.l4_regular,
        key: index
      }, reason)));
    }
    return /* @__PURE__ */React__default.createElement("ul", {
      className: cx(ContentList)
    }, content.map((reason, index) => /* @__PURE__ */React__default.createElement("li", {
      className: Typo.Label.l4_regular,
      key: index
    }, reason)));
  }
  return /* @__PURE__ */React__default.createElement("div", {
    className: cx(ContentList, Typo.Label.l4_regular)
  }, content);
};
const MultiRejectContent = ({
  content,
  resourceIcon
}) => {
  const {
    t
  } = useParrotTranslation();
  return /* @__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
  }, resourceIcon, /* @__PURE__ */React__default.createElement("span", null, name + t("common.colon_with_space") + reasons.join(t("common.semicolon_with_space"))))));
};
const RejectDialog = props => {
  const {
    title,
    cancelText,
    beforeDescription,
    description,
    className,
    footerClassName,
    okButtonProps
  } = props;
  const renderContent = () => {
    switch (props.type) {
      case RejectDialogType.Single:
        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), /* @__PURE__ */React__default.createElement(SingleRejectContent, {
          content: props.content,
          listType: props.listType,
          resourceIcon: props.resourceIcon
        }));
      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(PartialDescription, Typo.Label.l3_regular)
        }, props.partialDescription)), /* @__PURE__ */React__default.createElement(MultiRejectContent, {
          content: props.content,
          resourceIcon: props.resourceIcon
        }));
      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: __spreadValues({
      danger: props.type === RejectDialogType.Part
    }, okButtonProps),
    onCancel: props.onCancel,
    className,
    footerClassName
  }, beforeDescription, description && /* @__PURE__ */React__default.createElement("div", {
    className: cx(Description, Typo.Label.l3_regular)
  }, description), renderContent());
};

export { RejectDialog };
