Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.156/page_editor/app/utils/drag_and_drop/defaultComputeHover",["module","exports","require","../../config/constants/layoutDataItemTypes","../collectionIsMapped","../formIsMapped","../isItemContainerFlex","../isItemEmpty","./checkAllowedChild","./constants/dragDropTargetType","./constants/orientations","./constants/targetPositions","./getDropTargetPosition","./getTargetData","./getTargetPositions","./itemIsAncestor"],(function(t,e,o){window;{Object.defineProperty(e,"__esModule",{value:!0}),e.default=function defaultComputeHover({dispatch:t,layoutDataRef:e,monitor:o,siblingItem:p=null,sourceItem:f,targetItem:I,targetRefs:g}){if(!o.isOver({shallow:!0}))return;const _=function getOrientation(t,e,o,r){if(!t.parentId||!(0,a.default)(r.current.items[t.parentId]))return c.ORIENTATIONS.vertical;const n=o.get(t.toControlsId(t.itemId)).current.getBoundingClientRect(),i=n.left+n.width/2,l=e.getClientOffset().x,s=l<i?d.TARGET_POSITIONS.LEFT:d.TARGET_POSITIONS.RIGHT;return(s===d.TARGET_POSITIONS.LEFT?l-n.left:n.right-l)<O?c.ORIENTATIONS.horizontal:c.ORIENTATIONS.vertical}(p||I,o,g,e),[m,E,P]=getItemPosition(p||I,o,g,_),y=(()=>{const t=I.type===r.LAYOUT_DATA_ITEM_TYPES.column,o=I.type===r.LAYOUT_DATA_ITEM_TYPES.collection&&!(0,n.collectionIsMapped)(I),s=(0,a.default)(I),u=I.type===r.LAYOUT_DATA_ITEM_TYPES.fragment,c=I.type===r.LAYOUT_DATA_ITEM_TYPES.form&&!(0,i.formIsMapped)(I),p=(0,l.default)(e.current.items[I.itemId],e.current);return m===d.TARGET_POSITIONS.MIDDLE&&(p||t||s||o||c)&&!u})();if(!p&&y&&!(0,T.default)(f,I,e))return t({dropItem:f,dropTargetItem:I,droppable:(0,s.default)(f,I,e),elevate:null,targetPositionWithMiddle:m,targetPositionWithoutMiddle:E,type:u.DRAG_DROP_TARGET_TYPE.INSIDE});if(p&&!shouldBeIgnoredInElevation(parent)&&function validElevation(t,e,o){const r=o.current.items[t.parentId];return e===c.ORIENTATIONS.horizontal?(0,a.default)(r):!(0,a.default)(r)}(p,_,e)&&!(0,T.default)(f,p,e))return t({dropItem:f,dropTargetItem:p,droppable:(0,s.default)(f,I,e),elevate:!0,targetPositionWithMiddle:m,targetPositionWithoutMiddle:E,type:u.DRAG_DROP_TARGET_TYPE.ELEVATE});if(P){const getElevatedTargetItem=(t,n)=>{let i=e.current.items[t.parentId];if(i&&(i=_objectSpread(_objectSpread({},i),{},{collectionItemIndex:t.collectionItemIndex,parentToControlsId:t.parentToControlsId,toControlsId:i.type===r.LAYOUT_DATA_ITEM_TYPES.collection?t.parentToControlsId:t.toControlsId})),i){const[e]=getItemPosition(t,o,g,_),[r]=getItemPosition(i,o,g,_);if(e!==m&&r!==m||shouldBeIgnoredInElevation(i))return getElevatedTargetItem(i,n);if(n>1){const[t,e]=getElevatedTargetItem(i,n-1);if(t)return[t,e]}return[i,t]}return[null,null]},[n,i]=getElevatedTargetItem(I,P);if(n&&n!==I)return defaultComputeHover({dispatch:t,layoutDataRef:e,monitor:o,siblingItem:i,sourceItem:f,targetItem:n,targetRefs:g})}};var r=o("../../config/constants/layoutDataItemTypes"),n=o("../collectionIsMapped"),i=o("../formIsMapped"),a=_interopRequireDefault(o("../isItemContainerFlex")),l=_interopRequireDefault(o("../isItemEmpty")),s=_interopRequireDefault(o("./checkAllowedChild")),u=o("./constants/dragDropTargetType"),c=o("./constants/orientations"),d=o("./constants/targetPositions"),p=_interopRequireDefault(o("./getDropTargetPosition")),f=_interopRequireDefault(o("./getTargetData")),I=_interopRequireDefault(o("./getTargetPositions")),T=_interopRequireDefault(o("./itemIsAncestor"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function ownKeys(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,r)}return o}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(o),!0).forEach((function(e){_defineProperty(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):ownKeys(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function _defineProperty(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}const t=15,g=3,O=80;function getItemPosition(e,o,r,n){const i=r.get(e.toControlsId(e.itemId));if(!i||!i.current)return[null,null,0];const a=n===c.ORIENTATIONS.horizontal?o.getClientOffset().x:o.getClientOffset().y,l=i.current.getBoundingClientRect(),s=(0,I.default)(n),u=(0,f.default)(l,n),T=Math.min(u.length/(2*(g+1)),t)*g,[O,_]=(0,p.default)(a,T,s,u);let m=0;if(O!==d.TARGET_POSITIONS.MIDDLE){const t=O===s.start?a-u.start:u.end-a;m=g-Math.floor(t/T*g)}return[O,_,m]}function shouldBeIgnoredInElevation(t){return t.type===r.LAYOUT_DATA_ITEM_TYPES.collection||t.type===r.LAYOUT_DATA_ITEM_TYPES.row}}}));
//# sourceMappingURL=defaultComputeHover.js.map