import { useMemo } from 'react';
import { CustomThemeProvider } from '@kevisual/components/theme/index.tsx';
import { ToastContainer } from 'react-toastify';
import { FileEditor } from './file-editor/FileEditor';

export const InitProvider = ({ children }: { children: React.ReactNode }) => {
  return <>{children}</>;
};

type AppProvider = {
  key: string;
  use: boolean;
};
export type AppProps = {
  providers?: AppProvider[];
  noProvider?: boolean;
  /**
   * 是否是单个应用
   * 默认是单个应用模块。
   */
  isSingleApp?: boolean;
};
export const App = ({ providers, noProvider, isSingleApp = true }: AppProps) => {
  const children = useMemo(() => {
    return (
      <InitProvider>
        <FileEditor />
      </InitProvider>
    );
  }, []);
  if (noProvider) {
    return <>{children}</>;
  }
  return (
    <CustomThemeProvider>
      {children}
      <ToastContainer />
    </CustomThemeProvider>
  );
};
