import { useCallback } from "react";
import { assetsDataApi } from "../state-manager/api";
import useEnv from "../../hooks/useEnv";
import { selectCurrency } from "../utils/currencySelection";
export function useLazyLedgerCurrency(options, currency) {
    const devMode = useEnv("MANAGER_DEV_MODE");
    const [triggerGetAssetData] = assetsDataApi.useLazyGetAssetDataQuery();
    const getLedgerCurrency = useCallback(async () => {
        if (!currency?.ledgerIds || currency.ledgerIds.length === 0)
            return undefined;
        try {
            const result = await triggerGetAssetData({
                currencyIds: currency.ledgerIds,
                product: options.product,
                version: options.version,
                isStaging: false,
                includeTestNetworks: devMode,
            }, true).unwrap();
            return selectCurrency(result);
        }
        catch {
            return undefined;
        }
    }, [currency, devMode, options, triggerGetAssetData]);
    return { getLedgerCurrency };
}
//# sourceMappingURL=useLazyLedgerCurrency.js.map