Liferay.Loader.define("app-builder-workflow-web@1.0.40/js/pages/apps/edit/workflow-builder/WorkflowStep.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/badge', '@frontend-taglib-clay$clayui/button', '@frontend-taglib-clay$clayui/drop-down', '@frontend-taglib-clay$clayui/icon', '@frontend-taglib-clay$clayui/tooltip', 'frontend-js-react-web$classnames', 'frontend-js-react-web$react', '../../../../components/button-info/ButtonInfo.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = WorkflowStep;

    var _badge = _interopRequireDefault(require("@frontend-taglib-clay$clayui/badge"));

    var _button = require("@frontend-taglib-clay$clayui/button");

    var _dropDown = _interopRequireDefault(require("@frontend-taglib-clay$clayui/drop-down"));

    var _icon = _interopRequireDefault(require("@frontend-taglib-clay$clayui/icon"));

    var _tooltip = require("@frontend-taglib-clay$clayui/tooltip");

    var _classnames = _interopRequireDefault(require("frontend-js-react-web$classnames"));

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _ButtonInfo = _interopRequireDefault(require("../../../../components/button-info/ButtonInfo.es"));

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj.default = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    function _slicedToArray(arr, i) {
      return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
    }

    function _nonIterableRest() {
      throw new TypeError("Invalid attempt to destructure non-iterable instance");
    }

    function _iterableToArrayLimit(arr, i) {
      if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
        return;
      }var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
        for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
          _arr.push(_s.value);if (i && _arr.length === i) break;
        }
      } catch (err) {
        _d = true;_e = err;
      } finally {
        try {
          if (!_n && _i["return"] != null) _i["return"]();
        } finally {
          if (_d) throw _e;
        }
      }return _arr;
    }

    function _arrayWithHoles(arr) {
      if (Array.isArray(arr)) return arr;
    }

    var Arrow = function Arrow(_ref) {
      var addStep = _ref.addStep,
          selected = _ref.selected;
      var isIE = /Trident/.test(navigator.userAgent);
      return (/*#__PURE__*/_react.default.createElement("div", {
          className: (0, _classnames.default)('arrow ', selected && 'selected')
        }, /*#__PURE__*/_react.default.createElement(_icon.default, {
          className: (0, _classnames.default)('arrow-point icon', isIE && 'arrow-point-ie'),
          symbol: "live"
        }), selected && /*#__PURE__*/_react.default.createElement(_tooltip.ClayTooltipProvider, null, /*#__PURE__*/_react.default.createElement("div", {
          className: (0, _classnames.default)('arrow-plus-button', isIE && 'arrow-plus-button-ie'),
          "data-tooltip-align": "left",
          "data-tooltip-delay": "0",
          onClick: addStep,
          title: Liferay.Language.get('create-new-step')
        }, /*#__PURE__*/_react.default.createElement(_icon.default, {
          className: "icon",
          symbol: "plus"
        }))), /*#__PURE__*/_react.default.createElement("div", {
          className: "arrow-body"
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: "arrow-tail"
        }), /*#__PURE__*/_react.default.createElement(_icon.default, {
          className: (0, _classnames.default)('arrow-head icon', isIE && 'arrow-head-ie'),
          symbol: "caret-bottom"
        })))
      );
    };

    var Card = function Card(_ref2) {
      var _errors$formViews;

      var actions = _ref2.actions,
          errors = _ref2.errors,
          isInitialOrFinalSteps = _ref2.isInitialOrFinalSteps,
          name = _ref2.name,
          onClick = _ref2.onClick,
          selected = _ref2.selected,
          stepInfo = _ref2.stepInfo;

      var _useState = (0, _react.useState)(false),
          _useState2 = _slicedToArray(_useState, 2),
          active = _useState2[0],
          setActive = _useState2[1];

      var duplicatedFields = (errors === null || errors === void 0 ? void 0 : (_errors$formViews = errors.formViews) === null || _errors$formViews === void 0 ? void 0 : _errors$formViews.duplicatedFields) || [];

      var handleOnClick = function handleOnClick(event, onClick) {
        event.preventDefault();
        setActive(false);
        onClick();
      };

      return (/*#__PURE__*/_react.default.createElement("div", {
          className: (0, _classnames.default)('step-card', selected && 'selected'),
          onClick: onClick
        }, /*#__PURE__*/_react.default.createElement("div", null, name, /*#__PURE__*/_react.default.createElement(_ButtonInfo.default, {
          items: stepInfo
        })), duplicatedFields.length > 0 && /*#__PURE__*/_react.default.createElement(_tooltip.ClayTooltipProvider, null, /*#__PURE__*/_react.default.createElement(_icon.default, {
          className: "tooltip-icon-error",
          "data-tooltip-align": "bottom",
          "data-tooltip-delay": "0",
          fontSize: "26px",
          symbol: "exclamation-full",
          title: "".concat(Liferay.Language.get('error'), ": ").concat(Liferay.Language.get('there-are-form-views-with-duplicated-fields'))
        })), /*#__PURE__*/_react.default.createElement("div", {
          className: "d-flex"
        }, !isInitialOrFinalSteps && /*#__PURE__*/_react.default.createElement(_tooltip.ClayTooltipProvider, null, /*#__PURE__*/_react.default.createElement(_dropDown.default, {
          active: active,
          "data-tooltip-align": "bottom",
          "data-tooltip-delay": "0",
          onActiveChange: setActive,
          title: Liferay.Language.get('options'),
          trigger: /*#__PURE__*/_react.default.createElement(_button.ClayButtonWithIcon, {
            className: "border-0",
            displayType: "secondary",
            symbol: "ellipsis-v"
          })
        }, /*#__PURE__*/_react.default.createElement(_dropDown.default.ItemList, null, actions.map(function (_ref3, index) {
          var label = _ref3.label,
              _onClick = _ref3.onClick;
          return (/*#__PURE__*/_react.default.createElement(_dropDown.default.Item, {
              key: index,
              onClick: function onClick(event) {
                return handleOnClick(event, _onClick);
              }
            }, label)
          );
        }))))))
      );
    };

    function WorkflowStep(_ref4) {
      var actions = _ref4.actions,
          addStep = _ref4.addStep,
          badgeLabel = _ref4.badgeLabel,
          errors = _ref4.errors,
          initial = _ref4.initial,
          name = _ref4.name,
          onClick = _ref4.onClick,
          selected = _ref4.selected,
          stepInfo = _ref4.stepInfo;
      var isInitialOrFinalSteps = initial !== undefined;

      return (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
          className: "step"
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: "step-wrapper"
        }, /*#__PURE__*/_react.default.createElement(_badge.default, {
          className: (0, _classnames.default)('step-badge', !isInitialOrFinalSteps && 'index-badge'),
          displayType: selected ? 'primary' : 'secondary',
          label: badgeLabel
        }), /*#__PURE__*/_react.default.createElement(Card, {
          actions: actions,
          errors: errors,
          isInitialOrFinalSteps: isInitialOrFinalSteps,
          name: name,
          onClick: onClick,
          selected: selected,
          stepInfo: stepInfo
        }))), !(isInitialOrFinalSteps && !initial) && /*#__PURE__*/_react.default.createElement(Arrow, {
          addStep: addStep,
          selected: selected
        }))
      );
    }
    //# sourceMappingURL=WorkflowStep.es.js.map
  }
});
//# sourceMappingURL=WorkflowStep.es.js.map