Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.169/page_editor/app/components/DragPreview",["module","exports","require","@frontend-taglib-clay$clayui/icon","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","liferay!frontend-js-react-web$react-dnd","../config/constants/itemActivationOrigins","../config/constants/layoutDataItemTypes","../config/index","../contexts/StoreContext","../selectors/selectLanguageId","../utils/getWidget"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function DragPreview(){var e;const t=(0,i.useRef)(),n=(0,d.useSelector)((e=>e.fragmentEntryLinks)),g=(0,d.useSelector)((e=>e.fragments)),p=(0,d.useSelector)(s.default),y=(0,d.useSelector)((e=>e.layoutData)),m=(0,d.useSelector)((e=>e.widgets)),{currentOffset:v,isDragging:_,item:w}=(0,o.useDragLayer)((e=>({currentOffset:e.getClientOffset(),isDragging:e.isDragging(),item:e.getItem()})));if(!_||!(null==w?void 0:w.id)||w.namespace!==u.config.portletNamespace)return null;const b=y.items[null==w?void 0:w.id];let D;(null==w?void 0:w.icon)?D=w.icon:b&&(D=function getItemIcon(e,t,n,r){var a;const i=n.flatMap((e=>e.fragmentEntries));if(e.type===c.LAYOUT_DATA_ITEM_TYPES.fragment){var o;const n=t[e.config.fragmentEntryLinkId];if(n.portletId){const e=(0,f.default)(r,n.portletId);return(null==e?void 0:e.instanceable)?"square-hole-multi":"square-hole"}return null===(o=i.find((e=>e.fragmentEntryKey===n.fragmentEntryKey)))||void 0===o?void 0:o.icon}return null===(a=i.find((t=>t.type===e.type)))||void 0===a?void 0:a.icon}(b,n,g,m));return i.default.createElement("div",{className:"cadmin"},i.default.createElement("div",{className:"page-editor__drag-preview"},i.default.createElement("div",{className:(0,a.default)("page-editor__drag-preview__content",{"page-editor__drag-preview__content__treeview":(null==w?void 0:w.origin)===l.ITEM_ACTIVATION_ORIGINS.sidebar}),dir:Liferay.Language.direction[null===(e=themeDisplay)||void 0===e?void 0:e.getLanguageId()],ref:t,style:getItemStyles(v,t,"rtl"===Liferay.Language.direction[p])},D&&i.default.createElement("div",{className:"align-items-center d-flex h-100"},i.default.createElement(r.default,{className:"mt-0",symbol:D})),i.default.createElement("span",{className:(0,a.default)("text-truncate",{"ml-3":D})},(null==w?void 0:w.name)?w.name:Liferay.Language.get("element")))))};var r=_interopRequireDefault(n("@frontend-taglib-clay$clayui/icon")),a=_interopRequireDefault(n("liferay!frontend-js-react-web$classnames")),i=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 n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var i=r?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react")),o=n("liferay!frontend-js-react-web$react-dnd"),l=n("../config/constants/itemActivationOrigins"),c=n("../config/constants/layoutDataItemTypes"),u=n("../config/index"),d=n("../contexts/StoreContext"),s=_interopRequireDefault(n("../selectors/selectLanguageId")),f=_interopRequireDefault(n("../utils/getWidget"));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 getItemStyles=(e,t,n)=>{if(!e||!t.current)return{display:"none"};const r=t.current.getBoundingClientRect(),a=n?e.x+.5*r.width-window.innerWidth:e.x-.5*r.width,i=e.y-.5*r.height;return{transform:"translate(".concat(a,"px, ").concat(i,"px)")}}}}));
//# sourceMappingURL=DragPreview.js.map