Liferay.Loader.define("layout-admin-web@4.0.122/js/miller_columns/MillerColumnsColumn", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/layout', 'frontend-js-react-web$classnames', 'frontend-js-web', 'frontend-js-react-web$react', 'frontend-js-react-web$react-dnd', './MillerColumnsItem', './constants'], 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 = void 0;

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

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

    var _frontendJsWeb = require("frontend-js-web");

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

    var _reactDnd = require("frontend-js-react-web$react-dnd");

    var _MillerColumnsItem = _interopRequireDefault(require("./MillerColumnsItem"));

    var _constants = require("./constants");

    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 ownKeys(object, enumerableOnly) {
      var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {
          return Object.getOwnPropertyDescriptor(object, sym).enumerable;
        });keys.push.apply(keys, symbols);
      }return keys;
    }

    function _objectSpread(target) {
      for (var i = 1; i < arguments.length; i++) {
        var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {
          ownKeys(Object(source), true).forEach(function (key) {
            _defineProperty(target, key, source[key]);
          });
        } else if (Object.getOwnPropertyDescriptors) {
          Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
        } else {
          ownKeys(Object(source)).forEach(function (key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
          });
        }
      }return target;
    }

    function _defineProperty(obj, key, value) {
      if (key in obj) {
        Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
      } else {
        obj[key] = value;
      }return 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 AUTOSCROLL_DELAY = 20;
    var AUTOSCROLL_DISTANCE = 20;
    var AUTOSCROLL_RANGE_LENGTH = 20;

    var scroll = function scroll(columnsContainer, monitor) {
      var clientOffset = monitor.getClientOffset();
      var containerRect = columnsContainer.current.getBoundingClientRect();
      var hoverClientX = containerRect.right - (clientOffset === null || clientOffset === void 0 ? void 0 : clientOffset.x);

      if (hoverClientX < AUTOSCROLL_RANGE_LENGTH) {
        columnsContainer.current.scrollLeft += AUTOSCROLL_DISTANCE;
      } else if (hoverClientX > containerRect.width - AUTOSCROLL_RANGE_LENGTH) {
        columnsContainer.current.scrollLeft -= AUTOSCROLL_DISTANCE;
      }
    };

    var throttledScroll = (0, _frontendJsWeb.throttle)(scroll, AUTOSCROLL_DELAY);

    var isValidTarget = function isValidTarget(sources, parent) {
      return !sources.some(function (source) {
        return !(parent && (source.columnIndex > parent.columnIndex + 1 || source.columnIndex === parent.columnIndex + 1 && source.parentId !== parent.id || parent.parentable && source.columnIndex <= parent.columnIndex && !source.active));
      });
    };

    var MillerColumnsColumn = function MillerColumnsColumn(_ref) {
      var actionHandlers = _ref.actionHandlers,
          _ref$columnItems = _ref.columnItems,
          columnItems = _ref$columnItems === void 0 ? [] : _ref$columnItems,
          columnsContainer = _ref.columnsContainer,
          items = _ref.items,
          namespace = _ref.namespace,
          onItemDrop = _ref.onItemDrop,
          onItemStayHover = _ref.onItemStayHover,
          parent = _ref.parent,
          rtl = _ref.rtl;
      var ref = (0, _react.useRef)();

      var _useDrop = (0, _reactDnd.useDrop)({
        accept: _constants.ACCEPTING_TYPES.ITEM,
        canDrop: function canDrop(source, monitor) {
          return monitor.isOver({
            shallow: true
          }) && isValidTarget(source.items, parent);
        },
        collect: function collect(monitor) {
          return {
            canDrop: !!monitor.canDrop()
          };
        },
        drop: function drop(source) {
          if (canDrop) {
            onItemDrop(source.items, parent.id, columnItems.length);
          }
        },
        hover: function hover(source, monitor) {
          if (Liferay.Browser.isSafari() && !Liferay.Browser.isChrome()) {
            throttledScroll(columnsContainer, monitor);
          }
        }
      }),
          _useDrop2 = _slicedToArray(_useDrop, 2),
          canDrop = _useDrop2[0].canDrop,
          drop = _useDrop2[1];

      (0, _react.useEffect)(function () {
        drop(ref);
      }, [drop]);
      return (/*#__PURE__*/_react.default.createElement(_layout.default.Col, {
          className: (0, _classnames.default)('miller-columns-col show-quick-actions-on-hover', {
            'drop-target': canDrop
          }),
          containerElement: "ul",
          lg: "4",
          md: "6",
          ref: ref,
          size: "11"
        }, columnItems.map(function (item, index) {
          return (/*#__PURE__*/_react.default.createElement(_MillerColumnsItem.default, {
              actionHandlers: actionHandlers,
              item: _objectSpread(_objectSpread({}, item), {}, {
                itemIndex: index
              }),
              items: items,
              key: item.key,
              namespace: namespace,
              onItemDrop: onItemDrop,
              onItemStayHover: onItemStayHover,
              rtl: rtl
            })
          );
        }))
      );
    };

    var _default = MillerColumnsColumn;
    exports.default = _default;
    //# sourceMappingURL=MillerColumnsColumn.js.map
  }
});
//# sourceMappingURL=MillerColumnsColumn.js.map