import React from 'react';
import { getBalanceOf } from '@universal-login/commons';
import { TransferDropdownItem } from './TransferDropdownItem';
import { useToggler } from '../../hooks/useToggler';
import { getIconForToken } from '../../../core/utils/getIconForToken';
export var TransferDropdown = function (_a) {
    var sdk = _a.sdk, tokenDetailsWithBalance = _a.tokenDetailsWithBalance, tokenDetails = _a.tokenDetails, setToken = _a.setToken, className = _a.className;
    var _b = useToggler(), visible = _b.visible, toggle = _b.toggle;
    var onClick = function (token) {
        toggle();
        setToken(token);
    };
    var renderTransferDropdownItems = function (tokensDetails, predicate, dropdownClassName) {
        return tokensDetails
            .filter(predicate)
            .map(function (tokenDetails) { return renderTransferDropdownItem(tokenDetails, dropdownClassName); });
    };
    var renderTransferDropdownItem = function (tokenDetails, dropdownClassName) { return (React.createElement(TransferDropdownItem, { key: tokenDetails.name + "-" + tokenDetails.symbol, sdk: sdk, dropdownClassName: dropdownClassName, className: className, tokenDetails: tokenDetails, icon: getIconForToken(tokenDetails.symbol), balance: getBalanceOf(tokenDetails.symbol, tokenDetailsWithBalance), onClick: onClick })); };
    return (React.createElement("div", { className: "currency-accordion" },
        renderTransferDropdownItems(sdk.tokensDetailsStore.tokensDetails, function (_a) {
            var symbol = _a.symbol;
            return symbol === tokenDetails.symbol;
        }, "currency-accordion-btn currency-accordion-item " + (visible ? 'expaned' : '')),
        visible &&
            React.createElement("div", { className: "currency-scrollable-list" }, renderTransferDropdownItems(sdk.tokensDetailsStore.tokensDetails, function (_a) {
                var symbol = _a.symbol;
                return symbol !== tokenDetails.symbol;
            }, 'currency-accordion-item currency-accordion-item-list'))));
};
//# sourceMappingURL=TransferDropdown.js.map