import formItemCheckboxMeta from '../form-item-checkbox/meta';
import formItemCheckboxGroupMeta from '../form-item-checkbox.group/meta';
import formItemColorPickerMeta from '../form-item-color-picker/meta';
import formItemDatePickerMeta from '../form-item-date-picker/meta';
import formItemInputMeta from '../form-item-input/meta';
import formItemInputNumberMeta from '../form-item-input-number/meta';
import formItemInputEmailMeta from '../form-item-input.email/meta';
import formItemInputJsonMeta from '../form-item-input.json/meta';
import formItemInputPasswordMeta from '../form-item-input.password/meta';
import formItemInputPhoneMeta from '../form-item-input.phone/meta';
import formItemInputTextAreaMeta from '../form-item-input.text-area/meta';
import formItemInputUrlMeta from '../form-item-input.url/meta';
import formItemRadioMeta from '../form-item-radio/meta';
import formItemRadioGroupMeta from '../form-item-radio.group/meta';
import formItemSelectMeta from '../form-item-select/meta';
import formItemTimePickerMeta from '../form-item-time-picker/meta';
import formItemUploadMeta from '../form-item-upload/meta';

export const metaAll = [
  formItemCheckboxMeta,
  formItemCheckboxGroupMeta,
  formItemColorPickerMeta,
  formItemDatePickerMeta,
  formItemInputMeta,
  formItemInputNumberMeta,
  formItemInputEmailMeta,
  formItemInputJsonMeta,
  formItemInputPasswordMeta,
  formItemInputPhoneMeta,
  formItemInputTextAreaMeta,
  formItemInputUrlMeta,
  formItemRadioMeta,
  formItemRadioGroupMeta,
  formItemSelectMeta,
  formItemTimePickerMeta,
  formItemUploadMeta,
]

export const formItemMetaMap: Record<string, any> = metaAll.reduce((p, c) => {
  return {
    ...p,
    [c.componentName]: c,
  };
}, {});

// nocobase组件映射到pisell组件
export const nocobaseCpt2PisellCptMap: Record<string, any> = {
  InputNumber: 'FormItemInputNumber',
  Percent: 'FormItemInputNumber',
  DatePicker: 'FormItemDatePicker',
  Input: 'FormItemInput',
  // 整个json输入框输入
  'Input.InputJSON': 'FormItemInput.JSON',
  // json下自定义创建了字段
  'Input.JSON': 'JsonWrapper',
  'Input.URL': 'FormItemInput.URL',
  'Input.TextArea': 'FormItemInput.TextArea',
  'Input.Email': 'FormItemInput.Email',
  'Input.Phone': 'FormItemInput.Phone',
  Password: 'FormItemInput.Password',
  Select: 'FormItemSelect',
  Radio: 'FormItemRadio',
  TimePicker: 'FormItemTimePicker',
  ColorPicker: 'FormItemColorPicker',
  Checkbox: 'FormItemCheckbox',
  'Radio.Group': 'FormItemRadio.Group',
  'Checkbox.Group': 'FormItemCheckbox.Group',
  Upload: 'FormItemUpload',
  Translation: "FormItemTranslation"
};



export const pisellCptMap: Record<string, boolean> = Object.entries(
  nocobaseCpt2PisellCptMap
).reduce((p, [key, value]) => {
  return {
    ...p,
    [value]: true,
  };
}, {});

// 系统字段
export const systemFields = [
  'created_at',
  'updated_at',
  'deleted_at',
  'id',
  'createdAt',
  'updatedAt',
  'deletedAt',
  'createdBy',
  'updatedBy',
  'shop_id',
  'tenant_id'
];
