"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.OpenComponent = void 0;
var _select = _interopRequireDefault(require("@alifd/next/lib/select"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _boxSlotComponent = _interopRequireDefault(require("../../_components/boxSlotComponent"));
var _config = require("../config");
var _type = require("../type");
var _dialogComponent = require("./dialogComponent");
var _toLinkComponent = require("./toLinkComponent");
var _tipComponent = require("./tipComponent");
var _groupComponent = require("./groupComponent");
var _videoComponent = require("./videoComponent");
var _rotateWheelComponent = require("./rotateWheelComponent");
var _locale = require("../../../../src/locale");
var _telegramComponent = require("./telegramComponent");
var _type2 = require("../../cGroupManage-setter/type");
var _type3 = require("../../../../src/utils/CLowCodeService/type");
var _animationComponent = require("./animationComponent");
var _carouselComponent = require("./carouselComponent");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
var OpenComponent = exports.OpenComponent = function OpenComponent(props) {
  var value = props.value,
    onChange = props.onChange;
  var _useState = (0, _react.useState)(value || {
      operateType: _config.OperateEnumType.Dialog,
      modelName: [],
      modelTreeData: [],
      apiParams: []
    }),
    openPageObj = _useState[0],
    setOpenPageObj = _useState[1];
  (0, _react.useEffect)(function () {
    onChange(openPageObj);
  }, [openPageObj]);
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("setter.controls")
  }, /*#__PURE__*/_react["default"].createElement(_select["default"], {
    placeholder: (0, _locale.t)("setter.selectPlaceHolder"),
    notFoundContent: (0, _locale.t)('setter.notFoundContent'),
    showSearch: true,
    value: openPageObj.operateType,
    dataSource: (0, _config.getComOpenActiveList)(),
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        modelName: [],
        modelTreeData: [],
        operateType: e
      }));
    }
  })), openPageObj.operateType === _config.OperateEnumType.Dialog && /*#__PURE__*/_react["default"].createElement(_dialogComponent.DialogComponent, {
    title: (0, _locale.t)("setter.bindWindow"),
    value: {
      modelName: openPageObj.modelName,
      modelTreeData: openPageObj.modelTreeData,
      apiParams: openPageObj.apiParams
    },
    maxList: 1,
    isParams: true,
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, e));
    }
  }), openPageObj.operateType === _config.OperateEnumType.ToLink && /*#__PURE__*/_react["default"].createElement(_toLinkComponent.ToLinkComponent, {
    value: openPageObj.linkParams || '',
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        linkParams: e
      }));
    }
  }), openPageObj.operateType === _config.OperateEnumType.Tip && /*#__PURE__*/_react["default"].createElement(_tipComponent.TipComponent, {
    value: openPageObj.messageConfig,
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        messageConfig: Object.assign({}, e)
      }));
    }
  }), openPageObj.operateType === _config.OperateEnumType.Group && /*#__PURE__*/_react["default"].createElement(_groupComponent.GroupComponent, {
    originNode: _type3.BehaviorType.openBehavior,
    value: openPageObj.groupParams || {
      groupId: '',
      groupIndex: '',
      groupIndexSelectType: _type2.GroupDataSourceType["default"],
      groupStateSelectType: _type2.GroupDataSourceType["default"],
      groupFollowStateSelectType: _type2.GroupDataSourceType["default"]
    },
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        groupParams: Object.assign({}, e)
      }));
    }
  }), openPageObj.operateType === _config.OperateEnumType.Video && /*#__PURE__*/_react["default"].createElement(_videoComponent.VideoComponent, {
    value: openPageObj.videoParams || {
      videoComponentKey: '',
      videoGroupId: '',
      videoDataSourceType: _type2.GroupDataSourceType["default"]
    },
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        videoParams: Object.assign({}, e)
      }));
    }
  }), openPageObj.operateType === _config.OperateEnumType.Telegram && /*#__PURE__*/_react["default"].createElement(_telegramComponent.TelegramComponent, {
    value: openPageObj.telegramParams || {
      type: _type.TelegramType.link,
      data: {}
    },
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        telegramParams: Object.assign({}, e)
      }));
    }
  }), openPageObj.operateType === _config.OperateEnumType.RotateWheel && /*#__PURE__*/_react["default"].createElement(_rotateWheelComponent.RotateWheelComponent, {
    type: _type.OperationType.start,
    value: openPageObj.rotateWheelParams,
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        rotateWheelParams: Object.assign({}, e)
      }));
    }
  }), openPageObj.operateType === _config.OperateEnumType.Animation && /*#__PURE__*/_react["default"].createElement(_animationComponent.AnimationComponent, {
    type: _type.OperationType.start,
    value: openPageObj.animationParams,
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        animationParams: e
      }));
    }
  }), openPageObj.operateType === _config.OperateEnumType.Carousel && /*#__PURE__*/_react["default"].createElement(_carouselComponent.CarouselComponent, {
    type: _type.OperationType.start,
    value: openPageObj.carouselParams,
    onChange: function onChange(e) {
      setOpenPageObj((0, _extends2["default"])({}, openPageObj, {
        carouselParams: Object.assign({}, e)
      }));
    }
  }));
};