import { jsx as a } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useCallback as u, useMemo as p } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import m from "../../../../internal/Typography/Typography.js";
import { TypographyVariant as n, TypographyElement as l } from "../../../../internal/Typography/types.js";
import { GRANT_DETAILS_CLASS_NAMES as r } from "./constants.js";
/* empty css                  */
import { getPercentage as d } from "../../../CapitalOffer/components/utils/utils.js";
import { Tooltip as y } from "../../../../internal/Tooltip/Tooltip.js";
import { CAPITAL_REPAYMENT_FREQUENCY as f } from "../../../../constants.js";
import A from "../../../../../core/Context/preact/useCoreContext.js";
import { Translation as v } from "../../../../internal/Translation/Translation.js";
import h from "../../../../internal/StructuredList/StructuredList.js";
const E = ({ grant: e }) => {
  const { i18n: o } = A(), i = u((t) => o.amount(t.value, t.currency), [o]), c = p(() => {
    const t = e.maximumRepaymentPeriodDays ? Math.ceil(e.maximumRepaymentPeriodDays / 30) : null, s = [
      {
        key: "capital.common.fields.remainingAmount",
        value: o.amount(e.remainingGrantAmount.value, e.remainingGrantAmount.currency)
      },
      { key: "capital.common.fields.remainingFees", value: i(e.remainingFeesAmount) },
      { key: "capital.common.fields.repaidAmount", value: i(e.repaidGrantAmount) },
      { key: "capital.common.fields.repaidFees", value: i(e.repaidFeesAmount) },
      {
        key: "capital.common.fields.dailyRepaymentRate",
        value: `${o.get("capital.common.values.percentage", {
          values: { percentage: d(e.repaymentRate) }
        })}`
      },
      {
        key: "capital.common.fields.expectedRepaymentPeriod",
        value: o.get("capital.common.values.daysWithDaysLeft", {
          values: {
            days: e.expectedRepaymentPeriodDays,
            daysLeft: e.repaymentPeriodLeft
          }
        })
      },
      { key: "capital.common.fields.totalFees", value: i(e.feesAmount) },
      { key: "capital.common.fields.totalRepaymentAmount", value: i(e.totalAmount) },
      { key: "capital.common.fields.repaymentThreshold", value: i(e.thresholdAmount) },
      { key: "capital.common.fields.grantID", value: e.id },
      { key: "capital.common.fields.accountDescription", value: e.balanceAccountDescription },
      { key: "capital.common.fields.accountID", value: e.balanceAccountCode }
    ];
    return t && s.splice(5, 0, {
      key: "capital.common.fields.maximumRepaymentPeriod",
      value: o.get("capital.common.values.numberOfMonths", { values: { months: t } })
    }), s;
  }, [e, i, o]);
  return /* @__PURE__ */ a("div", { className: r.base, children: /* @__PURE__ */ a("div", { className: r.content, children: [
    /* @__PURE__ */ a("div", { className: r.header, children: /* @__PURE__ */ a(m, { el: l.SPAN, variant: n.BODY, children: /* @__PURE__ */ a(m, { el: l.PARAGRAPH, variant: n.BODY, children: /* @__PURE__ */ a(
      v,
      {
        translationKey: "capital.overview.grants.item.details.requestedFunds",
        fills: {
          amount: /* @__PURE__ */ a(m, { el: l.SPAN, variant: n.BODY, strongest: !0, children: o.amount(e.grantAmount.value, e.grantAmount.currency) })
        }
      }
    ) }) }) }),
    /* @__PURE__ */ a(
      h,
      {
        renderLabel: (t, s) => s === "capital.common.fields.repaymentThreshold" ? /* @__PURE__ */ a(
          y,
          {
            isUnderlineVisible: !0,
            content: o.get("capital.common.fields.repaymentThreshold.description", {
              values: { days: f }
            }),
            children: /* @__PURE__ */ a("span", { children: /* @__PURE__ */ a(
              m,
              {
                className: r.label,
                el: l.SPAN,
                variant: n.CAPTION,
                children: t
              }
            ) })
          }
        ) : /* @__PURE__ */ a(m, { className: r.label, el: l.SPAN, variant: n.CAPTION, children: t }),
        renderValue: (t) => /* @__PURE__ */ a(m, { el: l.SPAN, stronger: !0, variant: n.CAPTION, children: t }),
        items: c
      }
    )
  ] }) });
};
export {
  E as GrantDetails
};
