import { jsx as o, jsxs as f } from "react/jsx-runtime";
import { mr2 as E, mt1 as F, gap1 as L, pt2 as A, flexWrap as D, justifyContentBetween as P, dFlex as q, p2 as G, ml2 as H, justifyContentCenter as J, justifyContentEnd as K, justifyContentStart as M } from "./index-general.module.js";
import { classNames as i } from "./index-classNames.js";
import { AnimatedConditional as I } from "./index-AnimatedConditional.js";
import { Button as p, ButtonTypes as u, ButtonSizes as Q } from "./index-Button.js";
import { Collapse as B } from "./index-Collapse.js";
import { ComponentContainer as U } from "./index-ComponentContainer.js";
import { Icon as V, IconSize as w } from "./index-Icon.js";
import { IconNames as l } from "./index-IconNames.js";
import { InfoBoxBody as X } from "./index-InfoBoxBody.js";
import { Render as h } from "./index-Render.js";
import { Text as Y, FontWeights as Z, TextTypes as _ } from "./index-Text.js";
import { useState as $, useEffect as v } from "react";
import a from "./index-InfoBox.module.scss.js";
const ho = (N) => {
  const [b, m] = $(!0), {
    type: n,
    title: r,
    description: c,
    maxWidth: k,
    dismissible: j,
    dismissCallback: x,
    testId: S,
    replacements: C,
    links: y,
    position: W = "center",
    className: R,
    positive: e,
    negative: t,
    width: T,
    borderRadius: z = 4
  } = N;
  v(() => {
    m(!!(r || c));
  }, [r, c]);
  const d = (s) => {
    switch (s) {
      case "danger":
        return {
          color: "--e500",
          iconColor: "--e100",
          icon: l.exclamation
        };
      case "warn":
        return {
          color: "--w500",
          iconColor: "--w100",
          icon: l.warning
        };
      case "success":
        return {
          color: "--s500",
          iconColor: "--s100",
          icon: l.check
        };
      case "info":
      default:
        return {
          color: "--p500",
          iconColor: "--p100",
          icon: l.info
        };
    }
  }, O = (s) => {
    switch (s) {
      case "start":
        return M;
      case "end":
        return K;
      case "center":
        return J;
    }
  }, g = (s) => {
    m(s), x && x();
  };
  return !r && !c ? null : o(B, {
    isOpen: b,
    children: o(U, {
      testId: S,
      className: i(a.InfoBoxContainer, O(W), R),
      children: f("div", {
        "data-testid": "info-box-content",
        className: i(a.InfoBoxComponent, a[n || ""]),
        style: {
          maxWidth: k,
          width: T,
          borderRadius: z
        },
        children: [o(V, {
          testId: "info-box-icon",
          className: i(E),
          type: n != "warn" ? w.small : w.large,
          color: d(n).color,
          hasCircle: n != "warn",
          fillColor: d(n).iconColor,
          children: d(n).icon
        }), f("div", {
          children: [o(I, {
            condition: !!r,
            children: o(Y, {
              testId: "info-box-title",
              type: _.text,
              fontWeight: Z.medium,
              replacements: C,
              links: y,
              children: r
            })
          }), o(B, {
            isOpen: !!c,
            children: o("div", {
              className: i(r ? F : void 0),
              children: o(X, {
                description: c,
                replacements: C,
                links: y
              })
            })
          }), o(h, {
            if: !!t || !!e,
            children: f("div", {
              className: i(q, P, D, A, L),
              children: [o(h, {
                if: !!e,
                children: o(p, {
                  type: (e == null ? void 0 : e.type) ?? u.primary,
                  iconRight: e == null ? void 0 : e.icon,
                  onClick: () => {
                    e == null || e.cta();
                  },
                  children: e == null ? void 0 : e.text
                })
              }), o(h, {
                if: !!t,
                children: o(p, {
                  type: (t == null ? void 0 : t.type) ?? u.default,
                  iconLeft: t == null ? void 0 : t.icon,
                  onClick: () => {
                    t == null || t.cta();
                  },
                  children: t == null ? void 0 : t.text
                })
              })]
            })
          })]
        }), o(I, {
          condition: j,
          children: o(p, {
            testId: "info-box-cta",
            type: u.default,
            iconColor: "--n500",
            className: i("pointer", H, G, a.closeBtn),
            color: "--n500",
            size: Q.small,
            onClick: () => {
              g(!1);
            },
            iconLeft: l.close
          })
        })]
      })
    })
  });
};
export {
  ho as InfoBox
};
