function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
// @ts-nocheck
import dayjs from 'dayjs';
/*
* 工具类： 表单组控件值格式转换工具
* @params {Object} fieldsValue: 表单组内的控件值
* @params {Array} formItemGroup: 表单组
* @params {String} dateFormatter: 日期类控件批量类型 'dayjs' | 'string'  // 提交时，是否对日期类的进行格式转换转换
* */
var dateFieldTypes = ['datePicker', 'dateTimePicker', 'rangePicker', 'rangeTimePicker', 'timePicker', 'timePickerRange'];
export var UtilValueFormat = function UtilValueFormat(fieldsValue, formItemGroup, dateFormatter) {
  formItemGroup && formItemGroup.forEach(function (item) {
    var _item$protoConfig, _fieldsValue, _item$protoConfig2, _fieldsValue$, _item$protoConfig3, _fieldsValue$2, _item$protoConfig4;
    if (!fieldsValue[item.filedName || item.fieldName]) return;
    if (dateFormatter === 'string') {
      // 默认转换成字符串格式返回
      switch (item.type) {
        case 'datePicker':
        case 'dateTimePicker':
        case 'rangePicker':
        case 'rangeTimePicker':
          var pickerFormatNew;
          if (item !== null && item !== void 0 && (_item$protoConfig = item.protoConfig) !== null && _item$protoConfig !== void 0 && _item$protoConfig.picker) {
            switch (item.protoConfig.picker) {
              case 'week':
                pickerFormatNew = 'YYYY-wo';
                break;
              case 'month':
                pickerFormatNew = 'MM月';
                break;
              case 'year':
                pickerFormatNew = 'YYYY';
                break;
              default:
                break;
            }
          } else {
            pickerFormatNew = item.type === 'datePicker' || item.type === 'rangePicker' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss';
          }
          fieldsValue[item.filedName || item.fieldName] = item.type === 'datePicker' || item.type === 'dateTimePicker' ? (_fieldsValue = fieldsValue[item.filedName || item.fieldName]) === null || _fieldsValue === void 0 ? void 0 : _fieldsValue.format((item === null || item === void 0 || (_item$protoConfig2 = item.protoConfig) === null || _item$protoConfig2 === void 0 ? void 0 : _item$protoConfig2.format) || pickerFormatNew) : [(_fieldsValue$ = fieldsValue[item.filedName || item.fieldName][0]) === null || _fieldsValue$ === void 0 ? void 0 : _fieldsValue$.format((item === null || item === void 0 || (_item$protoConfig3 = item.protoConfig) === null || _item$protoConfig3 === void 0 ? void 0 : _item$protoConfig3.format) || pickerFormatNew), (_fieldsValue$2 = fieldsValue[item.filedName || item.fieldName][1]) === null || _fieldsValue$2 === void 0 ? void 0 : _fieldsValue$2.format((item === null || item === void 0 || (_item$protoConfig4 = item.protoConfig) === null || _item$protoConfig4 === void 0 ? void 0 : _item$protoConfig4.format) || pickerFormatNew)];
          break;
        default:
          break;
      }
    }
    if (item !== null && item !== void 0 && item.transform) {
      var _item$transform;
      var transValue = (item === null || item === void 0 || (_item$transform = item.transform) === null || _item$transform === void 0 ? void 0 : _item$transform.call(item, fieldsValue[item.filedName || item.fieldName])) || {};
      fieldsValue = _objectSpread(_objectSpread({}, fieldsValue), transValue);
      delete fieldsValue[item.filedName || item.fieldName]; // 删除转换的原参数名
    }
    if (item.hasOwnProperty('isHideInChange') && item.isHideInChange) {
      fieldsValue[item.filedName || item.fieldName] = undefined; // 删除隐藏的表单项的值
    }
  });
  return fieldsValue;
};

/*
* 工具类： 字符串内的时间或日期格式转换成dayjs格式
* @params {Object} fieldsValue: 表单组内的控件值
* @params {Array} formItemGroup: 表单组
* */
export var dateOrTimeStringToDayjs = function dateOrTimeStringToDayjs() {};
export var isDate = function isDate(value) {
  // 尝试解析日期，如果无法解析则返回 false
  return dayjs(value).isValid();
};