'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import React from 'react';
const ModifyClientFunctionContext = /*#__PURE__*/ React.createContext({
    addClientFunction: ()=>null,
    removeClientFunction: ()=>null
});
const ClientFunctionsContext = /*#__PURE__*/ React.createContext({});
export const ClientFunctionProvider = ({ children })=>{
    const [clientFunctions, setClientFunctions] = React.useState({});
    const addClientFunction = React.useCallback((args)=>{
        setClientFunctions((state)=>{
            const newState = {
                ...state
            };
            newState[args.key] = args.func;
            return newState;
        });
    }, []);
    const removeClientFunction = React.useCallback((args)=>{
        setClientFunctions((state)=>{
            const newState = {
                ...state
            };
            delete newState[args.key];
            return newState;
        });
    }, []);
    return /*#__PURE__*/ _jsxDEV(ModifyClientFunctionContext, {
        value: {
            addClientFunction,
            removeClientFunction
        },
        children: /*#__PURE__*/ _jsxDEV(ClientFunctionsContext, {
            value: clientFunctions,
            children: children
        }, void 0, false, {
            fileName: "src/providers/ClientFunction/index.tsx",
            lineNumber: 44,
            columnNumber: 7
        }, this)
    }, void 0, false, {
        fileName: "src/providers/ClientFunction/index.tsx",
        lineNumber: 38,
        columnNumber: 5
    }, this);
};
export const useAddClientFunction = (key, func)=>{
    const { addClientFunction, removeClientFunction } = React.use(ModifyClientFunctionContext);
    React.useEffect(()=>{
        addClientFunction({
            func,
            key
        });
        return ()=>{
            removeClientFunction({
                func,
                key
            });
        };
    }, [
        func,
        key,
        addClientFunction,
        removeClientFunction
    ]);
};
export const useClientFunctions = ()=>{
    return React.use(ClientFunctionsContext);
};

//# sourceMappingURL=index.js.map