"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _loopData = _interopRequireDefault(require("../_com-props/loopData"));
var _componentKey = _interopRequireDefault(require("../_com-props/componentKey"));
var _componentName = _interopRequireDefault(require("../_com-props/componentName"));
var _snippets = _interopRequireDefault(require("./snippets"));
var _setters = require("../_setters");
var _locale = require("../../src/locale");
var _default = exports["default"] = {
  componentName: "RotationWheel",
  title: (0, _locale.t)("rotation-wheel.title"),
  category: (0, _locale.t)("rotation-wheel.category"),
  group: (0, _locale.t)("rotation-wheel.group"),
  props: [_loopData["default"], _componentKey["default"], _componentName["default"], {
    name: "rwStyle",
    //转盘样式配置
    title: (0, _locale.t)("rotation-wheel.backgroundAndButtonSetting"),
    type: "group",
    extraProps: {
      display: "accordion"
    },
    condition: function condition(target) {
      var rwStyle = target.parent.getPropValue("rwStyle");
      var mode = rwStyle.mode,
        buttonMode = rwStyle.buttonMode,
        rwBackgroundImage = rwStyle.rwBackgroundImage,
        buttonImage = rwStyle.buttonImage,
        borderImage = rwStyle.borderImage;
      target.getProps().setPropValue('mode', mode);
      target.getProps().setPropValue('buttonMode', buttonMode);
      target.getProps().setPropValue('rwBackgroundImage', rwBackgroundImage);
      target.getProps().setPropValue('buttonImage', buttonImage);
      target.getProps().setPropValue('borderImage', borderImage);
      return true;
    },
    items: [
    //转盘边框
    {
      name: "borderImage",
      title: {
        label: (0, _locale.t)("rotation-wheel.borderImage")
      },
      setter: "CUploadImageDefaultSetter",
      extraProps: {
        setValue: function setValue(target, value) {
          var rwStyle = target.parent.getPropValue("rwStyle");
          target.getProps().setPropValue('rwStyle', (0, _extends2["default"])({}, rwStyle, {
            borderImage: value
          }));
        }
      }
    },
    //选择模式  背景图  自由模式（自由定义格子）
    {
      name: 'mode',
      title: {
        label: (0, _locale.t)('rotation-wheel.mode'),
        tip: (0, _locale.t)('rotation-wheel.modeTip')
      },
      defaultValue: function defaultValue() {
        return "free";
      },
      extraProps: {
        setValue: function setValue(target, value) {
          var rwStyle = target.parent.getPropValue("rwStyle");
          target.getProps().setPropValue('rwStyle', (0, _extends2["default"])({}, rwStyle, {
            mode: value
          }));
        }
      },
      setter: {
        componentName: 'SelectSetter',
        props: {
          options: [{
            title: (0, _locale.t)('rotation-wheel.free'),
            value: 'free'
          }, {
            title: (0, _locale.t)('rotation-wheel.backgroundImage'),
            value: 'backgroundImage'
          }]
        }
      }
    },
    //选择按钮模式  背景图  自由模式（自由定义颜色）
    {
      name: 'buttonMode',
      title: {
        label: (0, _locale.t)('rotation-wheel.buttonMode'),
        tip: (0, _locale.t)('rotation-wheel.buttonModeTip')
      },
      defaultValue: function defaultValue() {
        return "free";
      },
      extraProps: {
        setValue: function setValue(target, value) {
          var rwStyle = target.parent.getPropValue("rwStyle");
          target.getProps().setPropValue('rwStyle', (0, _extends2["default"])({}, rwStyle, {
            buttonMode: value
          }));
        }
      },
      setter: {
        componentName: 'SelectSetter',
        props: {
          options: [{
            title: (0, _locale.t)('rotation-wheel.free'),
            value: 'free'
          }, {
            title: (0, _locale.t)('rotation-wheel.backgroundImage'),
            value: 'backgroundImage'
          }]
        }
      }
    },
    //转盘背景图
    {
      name: "rwBackgroundImage",
      title: {
        label: (0, _locale.t)("rotation-wheel.backgroundImage"),
        tip: (0, _locale.t)("rotation-wheel.backgroundImageTip")
      },
      setter: "CUploadImageDefaultSetter",
      extraProps: {
        setValue: function setValue(target, value) {
          var rwStyle = target.parent.getPropValue("rwStyle");
          target.getProps().setPropValue('rwStyle', (0, _extends2["default"])({}, rwStyle, {
            rwBackgroundImage: value
          }));
        }
      }
    },
    //按钮图
    {
      name: "buttonImage",
      title: {
        label: (0, _locale.t)("rotation-wheel.buttonImage"),
        tip: (0, _locale.t)("rotation-wheel.buttonImageTip")
      },
      setter: "CUploadImageDefaultSetter",
      extraProps: {
        setValue: function setValue(target, value) {
          var rwStyle = target.parent.getPropValue("rwStyle");
          target.getProps().setPropValue('rwStyle', (0, _extends2["default"])({}, rwStyle, {
            buttonImage: value
          }));
        }
      },
      condition: function condition(target) {
        var mode = target.getProps().getPropValue("buttonMode");
        if (mode === 'free') {
          return false;
        } else {
          return true;
        }
      }
    }]
  },
  //直径
  {
    title: (0, _locale.t)("rotation-wheel.diameter"),
    display: "block",
    setter: {
      componentName: 'SelectSetter',
      props: {
        options: [{
          title: '200',
          value: 200
        }, {
          title: '250',
          value: 250
        }, {
          title: '300',
          value: 300
        }, {
          title: '350',
          value: 350
        }, {
          title: '400',
          value: 400
        }, {
          title: '450',
          value: 450
        }, {
          title: '500',
          value: 500
        }, {
          title: '550',
          value: 550
        }, {
          title: '600',
          value: 600
        }, {
          title: '650',
          value: 650
        }, {
          title: '700',
          value: 700
        }, {
          title: '750',
          value: 750
        }, {
          title: '800',
          value: 800
        }]
      }
    },
    name: "diameter",
    tip: (0, _locale.t)("rotation-wheel.diameterTip")
  },
  //格子颜色1 奇数单色配置
  {
    title: (0, _locale.t)("rotation-wheel.itemColor1"),
    display: "block",
    // type: "group",
    setter: "ColorSetter",
    name: "itemColor1",
    tip: (0, _locale.t)("rotation-wheel.itemColorTip"),
    condition: function condition(target) {
      var mode = target.getProps().getPropValue("mode");
      if (mode === 'free') {
        return true;
      } else {
        return false;
      }
    }
  },
  //格子颜色2 偶数双色配置
  {
    title: (0, _locale.t)("rotation-wheel.itemColor2"),
    display: "block",
    // type: "group",
    setter: "ColorSetter",
    name: "itemColor2",
    tip: (0, _locale.t)("rotation-wheel.itemColorTip"),
    condition: function condition(target) {
      //判断奖项单数还是双数
      var isEven = target.getProps().getPropValue("isEven");
      var mode = target.getProps().getPropValue("mode");
      // 奇数对应一个颜色  偶数对应两个颜色
      if (isEven && mode === 'free') {
        return true;
      } else {
        return false;
      }
    }
  },
  //格子间距颜色
  {
    title: (0, _locale.t)("rotation-wheel.gutterColor"),
    display: "block",
    // type: "group",
    setter: "ColorSetter",
    name: "gutterColor",
    tip: (0, _locale.t)("rotation-wheel.gutterColorTip"),
    condition: function condition(target) {
      var mode = target.getProps().getPropValue("mode");
      if (mode === 'free') {
        return true;
      } else {
        return false;
      }
    }
  },
  //指针颜色
  {
    title: (0, _locale.t)("rotation-wheel.pointerColor"),
    display: "block",
    setter: "ColorSetter",
    name: "pointerColor",
    tip: (0, _locale.t)("rotation-wheel.pointerColorTip"),
    condition: function condition(target) {
      var mode = target.getProps().getPropValue("buttonMode");
      if (mode === 'free') {
        return true;
      } else {
        return false;
      }
    }
  },
  //指针文字
  {
    title: (0, _locale.t)("rotation-wheel.pointerContent"),
    display: "block",
    setter: "StringSetter",
    name: "pointerContent",
    tip: (0, _locale.t)("rotation-wheel.pointerContentTip"),
    condition: function condition(target) {
      var mode = target.getProps().getPropValue("buttonMode");
      if (mode === 'free') {
        return true;
      } else {
        return false;
      }
    }
  },
  //展示内容
  {
    type: "field",
    name: "showContent",
    title: (0, _locale.t)('rotation-wheel.showContent'),
    extraProps: {
      display: "inline",
      defaultValue: true
    },
    setter: "BoolSetter"
  },
  //展示Token图标
  {
    type: "field",
    name: "showIcon",
    title: (0, _locale.t)('rotation-wheel.showIcon'),
    extraProps: {
      display: "inline",
      defaultValue: true
    },
    setter: "BoolSetter",
    condition: function condition(target) {
      var showContent = target.getProps().getPropValue("showContent");
      if (showContent) {
        return true;
      } else {
        return false;
      }
    }
  },
  //展示name
  {
    type: "field",
    name: "showName",
    title: (0, _locale.t)('rotation-wheel.showName'),
    extraProps: {
      display: "inline",
      defaultValue: true
    },
    setter: "BoolSetter",
    condition: function condition(target) {
      var showContent = target.getProps().getPropValue("showContent");
      if (showContent) {
        return true;
      } else {
        return false;
      }
    }
  },
  //展示token account数量
  {
    type: "field",
    name: "showAccount",
    title: (0, _locale.t)('rotation-wheel.showAccount'),
    extraProps: {
      display: "inline",
      defaultValue: true
    },
    setter: "BoolSetter",
    condition: function condition(target) {
      var showContent = target.getProps().getPropValue("showContent");
      if (showContent) {
        return true;
      } else {
        return false;
      }
    }
  },
  //展示NFT account数量
  {
    type: "field",
    name: "showNFTAccount",
    title: (0, _locale.t)('rotation-wheel.showNFTAccount'),
    extraProps: {
      display: "inline",
      defaultValue: true
    },
    setter: "BoolSetter",
    condition: function condition(target) {
      var showContent = target.getProps().getPropValue("showContent");
      if (showContent) {
        return true;
      } else {
        return false;
      }
    }
  },
  //展示NFT Id
  {
    type: "field",
    name: "showId",
    title: (0, _locale.t)('rotation-wheel.showId'),
    extraProps: {
      display: "inline",
      defaultValue: true
    },
    setter: "BoolSetter",
    condition: function condition(target) {
      var showContent = target.getProps().getPropValue("showContent");
      if (showContent) {
        return true;
      } else {
        return false;
      }
    }
  },
  //选择规则
  {
    title: (0, _locale.t)("rotation-wheel.dataSource"),
    name: "dataSource",
    display: "block",
    setter: {
      componentName: _setters.CRuleSelectSetter,
      props: function props(target) {
        // 动态计算属性
        var dataType = target.getProps().getPropValue('dataType');
        var isEven = target.getProps().getPropValue('isEven');
        return {
          dataType: dataType,
          isEven: isEven
        };
      }
    },
    extraProps: {
      setValue: function setValue(target, value) {
        target.getProps().setPropValue('dataType', value.dataType);
        target.getProps().setPropValue('dataSource', value.dataSourceId);
        //是否为偶数个奖项
        target.getProps().setPropValue('isEven', value.isEven);
      }
    },
    supportVariable: false
  }],
  configure: {
    supports: {
      events: false,
      style: true,
      loop: false,
      condition: false
    }
  },
  snippets: _snippets["default"]
};