import { useCallback } from "react";
import { getCryptoCurrencyIds, isCurrencyInCatalog } from "./helpers";
import { useRampCatalogContext } from "./index";
export function useRampCatalog() {
    const state = useRampCatalogContext();
    /** @param mode "onRamp" for can buy, "offRamp" for can sell. */
    const getSupportedCryptoCurrencyIds = useCallback((mode) => {
        if (!state.value) {
            return null;
        }
        return getCryptoCurrencyIds(state.value[mode]);
    }, [state.value]);
    /** @param mode "onRamp" for can buy, "offRamp" for can sell.
     * @returns true if the currency is supported, false if not, null if the catalog is not loaded yet.
     */
    const isCurrencyAvailable = useCallback((currencyId, mode) => {
        if (!state.value) {
            return false;
        }
        return isCurrencyInCatalog(currencyId, state.value, mode);
    }, [state.value]);
    return {
        getSupportedCryptoCurrencyIds,
        isCurrencyAvailable,
    };
}
//# sourceMappingURL=useRampCatalog.js.map