import React, {Fragment} from 'react';
import ReactDOM from 'react-dom/client';
import {Inspector} from 'react-dev-inspector';
import {ThemeProvider} from './styles/theme/ThemeProvider';
import {Provider} from 'react-redux';
import { store } from './redux/configureStore';
import './global.less';
import "./locales/i18n";
// import { Debugger } from './app/utils/debugger';

export const entryPointFactory = (EntryPointComponent) => {
  const IS_DEVELOPMENT = process.env.NODE_ENV === 'development';
  const MOUNT_NODE = document.getElementById('root') ;
  // Debugger.instance.setEnable(IS_DEVELOPMENT);

  /**
   * 开发环境时使用 Ctrl + Shift + Alt + C 唤起调试
   */
  const InspectorWrapper = IS_DEVELOPMENT ? Inspector : Fragment;

  ReactDOM.createRoot(MOUNT_NODE).render(
    <InspectorWrapper>
      <Provider store={store}>
        <ThemeProvider>
          <React.StrictMode>
            <EntryPointComponent/>
          </React.StrictMode>
        </ThemeProvider>
      </Provider>
    </InspectorWrapper>
  );

}
