'use client'
import { jsx } from 'react/jsx-runtime';
import React__default from 'react';
import { createProviderHook } from '../../shared/utils/functions/createProviderHook/createProviderHook.js';
import { getWalletGroupType } from '../../utils/functions/getWalletGroupType/getWalletGroupType.js';
import { useWalletItemActions } from '../../utils/hooks/useWalletItemActions/useWalletItemActions.js';
import { useViewContext } from '../ViewContext/ViewContext.js';

const WalletGroupContext = React__default.createContext(undefined);
const useWalletGroupContext = createProviderHook(WalletGroupContext, 'WalletGroupContextProvider');
const WalletGroupContextProvider = ({ children, }) => {
    const [selectedWalletGroup, setSelectedWalletGroup] = React__default.useState();
    const { pushView } = useViewContext();
    const { handleWalletItemClick } = useWalletItemActions();
    const navigateToWalletGroup = React__default.useCallback((walletGroup, { onSelectWallet } = {}) => {
        setSelectedWalletGroup(walletGroup);
        const walletGroupType = getWalletGroupType(walletGroup);
        const mapGroupTypeToView = {
            'multi-chain': 'wallet-group',
            'multi-wallet': 'select-wallet-in-wallet-group',
        };
        const view = walletGroupType
            ? mapGroupTypeToView[walletGroupType]
            : mapGroupTypeToView['multi-chain'];
        pushView(view, {
            onSelectWallet: onSelectWallet !== null && onSelectWallet !== void 0 ? onSelectWallet : handleWalletItemClick,
        });
    }, [handleWalletItemClick, pushView]);
    const contextValue = {
        navigateToWalletGroup,
        selectedWalletGroup,
    };
    return (jsx(WalletGroupContext.Provider, { value: contextValue, children: children }));
};

export { WalletGroupContext, WalletGroupContextProvider, useWalletGroupContext };
