//@ts-nocheck
import { App } from '@/App';
import GlobalStyles from '@/styles/GlobalStyles';
import { queryClient } from '@q/query_client';
import { QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { App as AntApp, ConfigProvider } from 'antd';
import zhCN from 'antd/es/locale/zh_CN';
import 'babel-polyfill';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import arraySupport from 'dayjs/plugin/arraySupport';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import { enableAllPlugins } from 'immer';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import './main.less';

// 启用Dayjs库中相应的功能。
dayjs.locale('zh-cn');
dayjs.extend(customParseFormat);
dayjs.extend(arraySupport);
// 启用Immer库中的所有功能。
enableAllPlugins();

// 我们将dayjs默认的toString方法和toJSON重写为format到指定格式
dayjs.prototype.constructor.prototype.toString = dayjs.prototype.constructor.prototype.toJSON = function () {
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
  return this.format('YYYY-MM-DD HH:mm:ss');
};

// 用于修补不存在ResizeObserver功能的代码
if (!window.ResizeObserver) {
  window.ResizeObserver = import('resize-observer-polyfill').default;
}

ReactDOM.createRoot(document.getElementById('root')).render(
  <QueryClientProvider client={queryClient}>
    <ConfigProvider locale={zhCN} theme={{ token: { colorPrimary: '#00B578' } }}>
      <AntApp>
        <BrowserRouter>
          <GlobalStyles />
          <App />
          <ReactQueryDevtools initialIsOpen={false} />
        </BrowserRouter>
      </AntApp>
    </ConfigProvider>
  </QueryClientProvider>
);
