"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useBatchAccountsSyncState = exports.useAccountSyncState = void 0;
const context_1 = require("./context");
const nothingState = {
    pending: false,
    error: null,
};
function useAccountSyncState({ accountId, } = {}) {
    const syncState = (0, context_1.useBridgeSyncState)();
    return (accountId && syncState[accountId]) || nothingState;
}
exports.useAccountSyncState = useAccountSyncState;
function useBatchAccountsSyncState({ accounts, } = {}) {
    const syncState = (0, context_1.useBridgeSyncState)();
    if (!accounts || !accounts?.length)
        return [];
    return accounts.reduce((acc, account) => {
        if (account) {
            acc.push({
                account,
                syncState: syncState[account.id] || nothingState,
            });
        }
        return acc;
    }, []);
}
exports.useBatchAccountsSyncState = useBatchAccountsSyncState;
//# sourceMappingURL=useAccountSyncState.js.map