Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.169/page_editor/app/components/KeyboardMovementPreview",["module","exports","require","@frontend-taglib-clay$clayui/icon","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$classnames","frontend-js-web","liferay!frontend-js-react-web$react","../contexts/KeyboardMovementContext","../utils/drag_and_drop/constants/targetPositions","../utils/getLayoutDataItemTopperUniqueClassName"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function KeyboardMovementPreview(){const{itemId:t}=(0,c.useMovementTarget)(),r=(0,c.useMovementTargetPosition)(),u=(0,c.useMovementSource)(),[d,s]=(0,l.useState)(e),f=(0,l.useRef)();if((0,l.useEffect)((()=>{if(t){getItemStyle(t,r,f)&&s(getItemStyle(t,r,f))}}),[t,r]),(0,a.useEventListener)("scroll",(0,i.debounce)((()=>{if(t){getItemStyle(t,r,f)&&s(getItemStyle(t,r,f))}}),100),!0,document),!t)return null;return l.default.createElement("div",{className:"cadmin"},l.default.createElement("div",{className:"page-editor__drag-preview"},l.default.createElement("div",{className:"page-editor__drag-preview__content",ref:f,style:d},l.default.createElement("div",{className:"align-items-center d-flex h-100"},l.default.createElement(n.default,{className:"mt-0",symbol:null==u?void 0:u.icon})),l.default.createElement("span",{className:(0,o.default)("text-truncate",{"ml-3":null==u?void 0:u.icon})},null==u?void 0:u.name))))};var n=_interopRequireDefault(r("@frontend-taglib-clay$clayui/icon")),a=r("@liferay/frontend-js-react-web"),o=_interopRequireDefault(r("liferay!frontend-js-react-web$classnames")),i=r("frontend-js-web"),l=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var o=n?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),c=r("../contexts/KeyboardMovementContext"),u=r("../utils/drag_and_drop/constants/targetPositions"),d=_interopRequireDefault(r("../utils/getLayoutDataItemTopperUniqueClassName"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e={opacity:0},s=6,getItemStyle=(e,t,r)=>{if(!r.current)return{};const n=getKeyboardMovementPosition(e,t,r);if(!n)return null;const{x:a,y:o}=n;return{opacity:1,transform:"translate(".concat(a,"px, ").concat(o,"px)")}},getKeyboardMovementPosition=(e,t,r)=>{const n=(0,d.default)(e),a=document.querySelector(".".concat(n));if(!a.offsetParent)return null;const o=a.getBoundingClientRect(),i=r.current.getBoundingClientRect();let l,c;return l=t===u.TARGET_POSITIONS.LEFT?o.left-.5*i.width:t===u.TARGET_POSITIONS.RIGHT?o.right-.5*i.width:o.left+.5*o.width-.5*i.width,c=t===u.TARGET_POSITIONS.MIDDLE?o.bottom-.5*o.height-.5*i.height:t===u.TARGET_POSITIONS.BOTTOM?o.bottom-.5*i.height-.5*s:t===u.TARGET_POSITIONS.TOP?o.top-.5*i.height+.5*s:o.top+.5*o.height-.5*s,{x:l,y:c}}}}));
//# sourceMappingURL=KeyboardMovementPreview.js.map