import '../../../../../node_modules/preact/compat/dist/compat.module.mjs';
import { useState as h, useCallback as T } from '../../../../../node_modules/preact/hooks/dist/hooks.module.mjs';

const useFormState = ({ remoteState })=>{
    const [localState, setLocalState] = h(remoteState);
    const resetLocalState = T(()=>{
        setLocalState(remoteState);
    }, [
        remoteState
    ]);
    const [editing, setEditing] = h(false);
    const handleSetEditing = T((newEditing)=>{
        if (newEditing) {
            resetLocalState();
        }
        setEditing(newEditing);
    }, [
        resetLocalState
    ]);
    return {
        localState,
        setLocalState,
        editing,
        handleSetEditing
    };
};

export { useFormState };
//# sourceMappingURL=useFormState.mjs.map
