import ParameterSelect from '@/components/ParameterSelect';
import ResourceSelect, {
  ResourceSelectorType,
  requiredValidator,
} from '@/components/ResourceSelect';
import SubAreaTitle from '@/components/SubAreaTitle';
import { Col, Form, Input, InputNumber, Row, Switch } from 'antd';

function VideoExecuteConfig() {
  return (
    <>
      <SubAreaTitle
        title="执行配置"
        image={require('@/assets/img/model-deployment.png')}
        style={{ marginTop: '20px', marginBottom: '24px' }}
      ></SubAreaTitle>

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="数据集"
            name="dataset"
            rules={[
              {
                validator: requiredValidator,
                message: '请选择数据集',
              },
            ]}
            required
          >
            <ResourceSelect
              type={ResourceSelectorType.Dataset}
              placeholder="请选择数据集"
              canInput={false}
            />
          </Form.Item>
        </Col>
      </Row>

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="资源规格"
            name="computing_resource_id"
            rules={[
              {
                required: true,
                message: '请选择资源规格',
              },
            ]}
          >
            <ParameterSelect dataType="resource" placeholder="请选择资源规格" />
          </Form.Item>
        </Col>
      </Row>

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="类别数量"
            name="num_classes"
            rules={[
              {
                required: true,
                message: '请输入类别数量',
              },
            ]}
          >
            <InputNumber placeholder="请输入类别数量" min={0} precision={0} />
          </Form.Item>
        </Col>
      </Row>

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="batch_size"
            name="batch_size"
            rules={[
              {
                required: true,
                message: '请输入 batch_size',
              },
            ]}
          >
            <InputNumber placeholder="请输入 batch_size" min={0} precision={0} />
          </Form.Item>
        </Col>
      </Row>

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="epochs"
            name="epochs"
            rules={[
              {
                required: true,
                message: '请输入 epochs',
              },
            ]}
          >
            <InputNumber placeholder="请输入 epochs" min={0} precision={0} />
          </Form.Item>
        </Col>
      </Row>

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="学习率"
            name="lr"
            rules={[
              {
                required: true,
                message: '请输入学习率',
              },
            ]}
          >
            <InputNumber placeholder="请输入学习率" min={0} />
          </Form.Item>
        </Col>
      </Row>

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item label="是否验证" name="is_validate" valuePropName="checked">
            <Switch />
          </Form.Item>
        </Col>
      </Row>

      {/* <Row gutter={8}>
        <Col span={10}>
          <Form.Item label="是否测试" name="is_test" valuePropName="checked">
            <Switch />
          </Form.Item>
        </Col>
      </Row> */}

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="训练集路径"
            name="train_data_prefix"
            rules={[
              {
                required: true,
                message: '请输入训练集路径',
              },
            ]}
          >
            <Input placeholder="请输入训练集路径" maxLength={64} showCount allowClear />
          </Form.Item>
        </Col>
      </Row>

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="训练集标注文件"
            name="train_file_path"
            rules={[
              {
                required: true,
                message: '请输入训练集标注文件',
              },
            ]}
          >
            <Input placeholder="请输入训练集标注文件" maxLength={64} showCount allowClear />
          </Form.Item>
        </Col>
      </Row>

      <Form.Item dependencies={['is_validate']} noStyle>
        {({ getFieldValue }) => {
          const is_validate = getFieldValue('is_validate');
          if (is_validate) {
            return (
              <>
                <Row gutter={8}>
                  <Col span={10}>
                    <Form.Item
                      label="验证集路径"
                      name="valid_data_prefix"
                      rules={[
                        {
                          required: true,
                          message: '请输入验证集路径',
                        },
                      ]}
                    >
                      <Input placeholder="请输入验证集路径" maxLength={64} showCount allowClear />
                    </Form.Item>
                  </Col>
                </Row>

                <Row gutter={8}>
                  <Col span={10}>
                    <Form.Item
                      label="验证集标注文件"
                      name="valid_file_path"
                      rules={[
                        {
                          required: true,
                          message: '请输入验证集标注文件',
                        },
                      ]}
                    >
                      <Input
                        placeholder="请输入验证集标注文件"
                        maxLength={64}
                        showCount
                        allowClear
                      />
                    </Form.Item>
                  </Col>
                </Row>
              </>
            );
          }
        }}
      </Form.Item>

      {/* <Form.Item dependencies={['is_test']} noStyle>
        {({ getFieldValue }) => {
          const is_test = getFieldValue('is_test');
          if (is_test) {
            return (
              <>
                <Row gutter={8}>
                  <Col span={10}>
                    <Form.Item
                      label="测试集路径"
                      name="test_data_prefix"
                      rules={[
                        {
                          required: true,
                          message: '请输入测试集路径',
                        },
                      ]}
                    >
                      <Input placeholder="请输入测试集路径" maxLength={64} showCount allowClear />
                    </Form.Item>
                  </Col>
                </Row>

                <Row gutter={8}>
                  <Col span={10}>
                    <Form.Item
                      label="测试集标注文件"
                      name="test_file_path"
                      rules={[
                        {
                          required: true,
                          message: '请输入测试集标注文件',
                        },
                      ]}
                    >
                      <Input
                        placeholder="请输入测试集标注文件"
                        maxLength={64}
                        showCount
                        allowClear
                      />
                    </Form.Item>
                  </Col>
                </Row>
              </>
            );
          }
        }}
      </Form.Item> */}
    </>
  );
}

export default VideoExecuteConfig;
