"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLazyLedgerCurrency = void 0;
const react_1 = require("react");
const api_1 = require("../state-manager/api");
const useEnv_1 = __importDefault(require("../../hooks/useEnv"));
const currencySelection_1 = require("../utils/currencySelection");
function useLazyLedgerCurrency(options, currency) {
    const devMode = (0, useEnv_1.default)("MANAGER_DEV_MODE");
    const [triggerGetAssetData] = api_1.assetsDataApi.useLazyGetAssetDataQuery();
    const getLedgerCurrency = (0, react_1.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 (0, currencySelection_1.selectCurrency)(result);
        }
        catch {
            return undefined;
        }
    }, [currency, devMode, options, triggerGetAssetData]);
    return { getLedgerCurrency };
}
exports.useLazyLedgerCurrency = useLazyLedgerCurrency;
//# sourceMappingURL=useLazyLedgerCurrency.js.map