import { useState as N, useMemo as O } from "react";
import { toast as z } from "react-toastify";
import { useEnvironment as E } from "@m4l/core";
import { ICONS_PATH as i } from "../../constants.js";
import { ICONS as o } from "../../icons.js";
import { useComponentSize as R } from "../../../../hooks/useComponentSize/index.js";
import { getIconColor as _ } from "../../../../utils/getIconColor.js";
const c = {
  default: o.DEFAULT,
  info: o.INFO,
  success: o.SUCCESS,
  warning: o.WARNING,
  error: o.ERROR
};
function L(a) {
  const [m, u] = N(!1), { type: t = "default", description: f, toastId: r, containerId: l, size: p } = a, d = { type: t, hasDescription: !!f }, { host_static_assets: e, environment_assets: n } = E(), { currentSize: s } = R(p), S = s === "small" || s === "medium" ? s : "medium", $ = c?.[t || "default"] || c.default, C = `${e}/${n}/${i}/${$}`, I = `${e}/${n}/${i}/${o.CLOSE}`, P = `${e}/${n}/${i}/${o.PIN}`, T = O(() => _(t), [t]);
  function h() {
    r && (z.update(r, { containerId: l, autoClose: !1, closeOnClick: !1 }), u(!0));
  }
  return {
    pinToast: h,
    isPinned: m,
    ownerState: d,
    iconTypePath: C,
    iconClosePath: I,
    iconPinPath: P,
    currentSize: S,
    iconColor: T
  };
}
export {
  L as useToastMessage
};
