import _Select from "@alifd/next/es/select";
import _extends from "@babel/runtime/helpers/extends";
import React, { useEffect, useState } from "react";
import BoxSlotComponent from "../../_components/boxSlotComponent";
import { GroupComponent } from "./groupComponent";
import { OperateEnumType, getComCloseActiveList } from "../config";
import { OperationType } from "../type";
import { RotateWheelComponent } from "./rotateWheelComponent";
import { t } from "../../../../src/locale";
import { DialogComponent } from "./dialogComponent";
import { BehaviorType } from "../../../../src/utils/CLowCodeService/type";
import { GroupDataSourceType } from "../../cGroupManage-setter/type";
import { AnimationComponent } from "./animationComponent";
import { CarouselComponent } from "./carouselComponent";
export var CloseComponent = function CloseComponent(props) {
  var value = props.value,
    onChange = props.onChange;
  var _useState = useState(value || {
      operateType: OperateEnumType.Dialog
    }),
    openPageObj = _useState[0],
    setOpenPageObj = _useState[1];
  useEffect(function () {
    onChange(openPageObj);
  }, [openPageObj]);
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BoxSlotComponent, {
    title: t("setter.controls")
  }, /*#__PURE__*/React.createElement(_Select, {
    placeholder: t("setter.selectPlaceHolder"),
    notFoundContent: t("setter.notFoundContent"),
    showSearch: true,
    value: openPageObj.operateType,
    dataSource: getComCloseActiveList(),
    onChange: function onChange(e) {
      setOpenPageObj(_extends({}, openPageObj, {
        operateType: e
      }));
    }
  })), openPageObj.operateType === OperateEnumType.Dialog && /*#__PURE__*/React.createElement(DialogComponent, {
    title: t("setter.closeBehavior"),
    value: openPageObj.closeParams,
    onChange: function onChange(e) {
      setOpenPageObj(_extends({}, openPageObj, {
        closeParams: Object.assign({}, e)
      }));
    }
  }), openPageObj.operateType === OperateEnumType.RotateWheel && /*#__PURE__*/React.createElement(RotateWheelComponent, {
    type: OperationType.stop,
    value: openPageObj.rotateWheelParams,
    onChange: function onChange(e) {
      setOpenPageObj(_extends({}, openPageObj, {
        rotateWheelParams: Object.assign({}, e)
      }));
    }
  }), openPageObj.operateType === OperateEnumType.Animation && /*#__PURE__*/React.createElement(AnimationComponent, {
    type: OperationType.stop,
    value: openPageObj.animationParams,
    onChange: function onChange(e) {
      setOpenPageObj(_extends({}, openPageObj, {
        animationParams: e
      }));
    }
  }), openPageObj.operateType === OperateEnumType.Carousel && /*#__PURE__*/React.createElement(CarouselComponent, {
    type: OperationType.stop,
    value: openPageObj.carouselParams,
    onChange: function onChange(e) {
      setOpenPageObj(_extends({}, openPageObj, {
        carouselParams: Object.assign({}, e)
      }));
    }
  }), openPageObj.operateType === OperateEnumType.Group && /*#__PURE__*/React.createElement(GroupComponent, {
    originNode: BehaviorType.closeBehavior,
    value: openPageObj.groupParams || {
      groupId: '',
      groupIndex: '',
      groupIndexSelectType: GroupDataSourceType["default"],
      groupStateSelectType: GroupDataSourceType["default"],
      groupFollowStateSelectType: GroupDataSourceType["default"]
    },
    onChange: function onChange(e) {
      setOpenPageObj(_extends({}, openPageObj, {
        groupParams: Object.assign({}, e)
      }));
    }
  }));
};