'use client';
import type { PropsWithChildren } from 'react';

import { px2remTransformer, StyleProvider } from '@ant-design/cssinjs';
import { AntdRegistry } from '@ant-design/nextjs-registry';
import { App as AntdApp, ConfigProvider, theme } from 'antd';
import zh_CN from 'antd/locale/zh_CN';
import React from 'react';
import '@ant-design/v5-patch-for-react-19';

import { LoacalProvider } from './_components/context/constants';
import { Theme } from './_components/reducer/reduce';
import $styles from './layout.module.css';
const AdminLayout: React.FC<PropsWithChildren> = ({ children }) => (
    <AntdRegistry>
        <Theme>
            <ConfigProvider
                locale={zh_CN}
                theme={{
                    algorithm: theme.defaultAlgorithm,
                    cssVar: true,
                    hashed: false,
                    token: {},
                }}
            >
                <LoacalProvider>
                    <AntdApp>
                        <StyleProvider transformers={[px2remTransformer()]}>
                            <div className={$styles.layout}>{children}</div>
                        </StyleProvider>
                    </AntdApp>
                </LoacalProvider>
            </ConfigProvider>
        </Theme>
    </AntdRegistry>
);

export default AdminLayout;
