import { cv as axios, dG as q, x as jsxs, w as jsx, D as Body, bF as PriceDisplay, B as Box, k as useTranslation, aA as Drawer, aP as MenuItem, aF as Fragment, aB as Divider, J as tokenValueFormat, d as formatZeroAmount, c5 as FooterLogo } from './index-Cy6GwrlT.js';

const fetchRiskAssessmentV2 = async (assessmentData, config) => {
    const result = Object.fromEntries(assessmentData.map((data) => [data.address.toLowerCase(), { sanctioned: false }]));
    const riskConfig = (await config.remote.getConfig('riskAssessment'));
    if (!riskConfig?.enabled) {
        return result;
    }
    try {
        const riskLevels = riskConfig?.levels.map((l) => l.toLowerCase()) ?? [];
        // Prepare v2 request payload - always include token data
        const requestPayload = assessmentData.map((data) => ({
            address: data.address,
            // eslint-disable-next-line @typescript-eslint/naming-convention
            token_addr: data.tokenAddr,
            amount: data.amount.toString(),
        }));
        const response = await axios.post(`${q[config.environment]}/v2/sanctions/check`, requestPayload);
        for (const assessment of response.data) {
            result[assessment.address.toLowerCase()].sanctioned = riskLevels.includes(assessment.risk.toLowerCase());
        }
        return result;
    }
    catch (error) {
        // eslint-disable-next-line no-console
        console.error('Error fetching risk assessment', error);
        return result;
    }
};

var RiskAssessmentLevel;
(function (RiskAssessmentLevel) {
    RiskAssessmentLevel["LOW"] = "Low";
    RiskAssessmentLevel["MEDIUM"] = "Medium";
    RiskAssessmentLevel["HIGH"] = "High";
    RiskAssessmentLevel["SEVERE"] = "Severe";
})(RiskAssessmentLevel || (RiskAssessmentLevel = {}));
const isSingleAddressSanctioned = (riskAssessment, address) => riskAssessment[address.toLowerCase()].sanctioned;
const resultHasSanctionedWallets = (riskAssessment) => Object.values(riskAssessment).some((assessment) => assessment.sanctioned);

const feesBreakdownContentStyles = {
    display: 'flex',
    flexDirection: 'column',
    height: '100%',
    padding: '16px 16px 0 16px',
};
const feeItemContainerStyles = {
    display: 'flex',
    flexDirection: 'column',
    gap: '10px',
    height: '100%',
};
const feeItemStyles = { display: 'flex', width: '100%' };
const feeItemLabelStyles = (boldLabel) => ({
    width: '65%',
    color: boldLabel ? 'base.color.text.body.primary' : 'base.color.text.body.secondary',
});
const feeItemPriceDisplayStyles = {
    width: '35%',
};
const feeItemLoadingStyles = {
    display: 'flex',
    flexDirection: 'column',
    rowGap: 'base.spacing.x2',
};

function FeeItem({ boldLabel, label, amount, fiatAmount, tokenSymbol, prefix = '', }) {
    const key = label.toLowerCase().replace(' ', '-');
    return (jsxs(Box, { sx: feeItemStyles, testId: `fee-item-${key}`, children: [jsx(Body, { sx: feeItemLabelStyles(boldLabel), children: label }), jsx(PriceDisplay, { testId: key, sx: feeItemPriceDisplayStyles, price: `${prefix}${tokenSymbol} ${amount}`, fiatAmount: fiatAmount })] }));
}

function FeesBreakdown({ fees, children, visible, onCloseDrawer, totalFiatAmount, totalAmount, tokenSymbol, loading = false, }) {
    const { t } = useTranslation();
    return (jsxs(Drawer, { headerBarTitle: t('drawers.feesBreakdown.heading'), size: "threeQuarter", onCloseDrawer: onCloseDrawer, visible: visible, children: [jsx(Drawer.Target, { children: children }), jsxs(Drawer.Content, { testId: "fees-breakdown-content", sx: feesBreakdownContentStyles, children: [jsxs(Box, { sx: feeItemContainerStyles, children: [loading && (jsxs(Box, { sx: feeItemLoadingStyles, children: [jsx(MenuItem, { shimmer: true, emphasized: true, testId: "balance-item-shimmer--1" }), jsx(MenuItem, { shimmer: true, emphasized: true, testId: "balance-item-shimmer--2" })] })), !loading && fees.map(({ label, amount, fiatAmount, prefix, token, }) => (jsx(FeeItem, { label: label, amount: amount, fiatAmount: fiatAmount, tokenSymbol: token.symbol ?? tokenSymbol, prefix: prefix }, label))), totalAmount && (jsxs(Fragment, { children: [jsx(Divider, { size: "xSmall" }), jsx(FeeItem, { label: t('drawers.feesBreakdown.total'), amount: tokenValueFormat(totalAmount), fiatAmount: totalFiatAmount
                                            ? `≈ ${t('drawers.feesBreakdown.fees.fiatPricePrefix')}${totalFiatAmount}`
                                            : formatZeroAmount('0'), tokenSymbol: tokenSymbol, boldLabel: true }, t('drawers.feesBreakdown.total'))] }))] }), jsx(FooterLogo, {})] })] }));
}

export { FeesBreakdown as F, fetchRiskAssessmentV2 as f, isSingleAddressSanctioned as i, resultHasSanctionedWallets as r };
