"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useAcceptedCurrency = void 0;
const react_1 = require("react");
const support_1 = require("@ledgerhq/coin-framework/currencies/support");
const useCurrenciesUnderFeatureFlag_1 = require("./useCurrenciesUnderFeatureFlag");
/**
 * Hook that returns a predicate function to check if a currency or token is accepted.
 * A currency is accepted if:
 * - It is supported by the platform (via isCurrencySupported)
 * - It is not deactivated by a feature flag
 *
 * For tokens, the parent currency is checked instead.
 */
function useAcceptedCurrency() {
    const { deactivatedCurrencyIds } = (0, useCurrenciesUnderFeatureFlag_1.useCurrenciesUnderFeatureFlag)();
    const isAcceptedCurrency = (0, react_1.useCallback)((currencyOrToken) => {
        const currency = currencyOrToken.type === "TokenCurrency" ? currencyOrToken.parentCurrency : currencyOrToken;
        return (0, support_1.isCurrencySupported)(currency) && !deactivatedCurrencyIds.has(currency.id);
    }, [deactivatedCurrencyIds]);
    return isAcceptedCurrency;
}
exports.useAcceptedCurrency = useAcceptedCurrency;
//# sourceMappingURL=useAcceptedCurrency.js.map