import { cloneDeep } from 'lodash-es';
import { getUUID } from './chart-util';

// 请求基础属性
export const requestConfig = {
  requestDataType: 0,
  requestHttpType: 'get',
  requestUrl: '',
  requestInterval: undefined,
  requestIntervalUnit: 'second',
  requestContentType: 0,
  requestParamsBodyType: 'none',
  requestSQLContent: {
    sql: 'select * from  where'
  },
  requestParams: {
    Body: {
      'form-data': {},
      'x-www-form-urlencoded': {},
      json: '',
      xml: ''
    },
    Header: {},
    Params: {}
  }
}

// 单实例类
export class PublicConfigClass {
    id = getUUID();
    isGroup = false;
    // 基本信息
    attr = {
      x: 50,
      y: 50,
      w: 500,
      h: 300,
      // 不建议动 offset
      offsetX: 0,
      offsetY: 0,
      zIndex: -1
    };
    // 基本样式
    styles = {
      // 使用滤镜
      filterShow: false,
      // 色相
      hueRotate: 0,
      // 饱和度
      saturate: 1,
      // 对比度
      contrast: 1,
      // 亮度
      brightness: 1,
      // 透明
      opacity: 1,
  
      // 旋转
      rotateZ: 0,
      rotateX: 0,
      rotateY: 0,
  
      // 倾斜
      skewX: 0,
      skewY: 0,
  
      // 混合模式
      blendMode: 'normal',
  
      // 动画
      animations: []
    };
    // 状态
    status = {
      lock: false,
      hide: false
    };
    // 请求
    request = cloneDeep(requestConfig);
    // 数据过滤
    filter = undefined;
    // 事件
    events = {
      baseEvent: {
        click: undefined,
        dblclick: undefined,
        mouseenter: undefined,
        mouseleave: undefined
      },
      advancedEvents: {
        vnodeMounted: undefined,
        vnodeBeforeMount: undefined
      }
    };
}

// 图表初始配置(px)
export const chartInitConfig = {
  x: 50,
  y: 50,
  w: 500,
  h: 300,
  // 不建议动 offset
  offsetX: 0,
  offsetY: 0,
}