import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import _cloneDeep from "lodash/cloneDeep";
import React, { useState } from 'react';
import { i18n } from '@fishx/i18n';
import { Modal } from '@whalecloud/fdx';
import ResourceGroup from "../ResourceGroup";
import { AssetsTypeGroup } from "../../../utils/resource";

var ImageDialog = function ImageDialog(_ref) {
  var visible = _ref.visible,
      imageClick = _ref.imageClick,
      langInfo = _ref.langInfo;

  var _useState = useState(null),
      _useState2 = _slicedToArray(_useState, 2),
      imagePath = _useState2[0],
      setImagePath = _useState2[1];

  var handleOk = function handleOk() {
    imageClick(imagePath);
  };

  var clearIcon = function clearIcon() {
    imageClick('');
    setImagePath(null);
  };

  var ChooseImage = function ChooseImage(res) {
    var newData = _cloneDeep(res);

    newData.langInfo = langInfo;
    setImagePath(newData);
  };

  return /*#__PURE__*/React.createElement(Modal, {
    title: i18n('PAGEBUIDER_PLS_SELECT'),
    width: "60%",
    height: "500",
    visible: visible,
    okText: i18n('PAGEBUIDER_SETTINGS_CONFIRM'),
    cancelText: i18n('PAGEBUIDER_SETTINGS_CANCEL'),
    onOk: handleOk,
    onCancel: clearIcon,
    zIndex: 1031
  }, /*#__PURE__*/React.createElement(ResourceGroup, {
    onClick: ChooseImage,
    type: AssetsTypeGroup.IMAGE
  }));
};

export default ImageDialog;
//# sourceMappingURL=index.js.map