Liferay.Loader.define("item-selector-taglib@5.2.9/image_selector/js/ImageSelectorImage",["module","exports","require","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=i(r("liferay!frontend-js-react-web$classnames")),o=(i(r("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=a();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var i=n?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(r,o,i):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")));function a(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return a=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}const e="both",u="horizontal",s="vertical",c=()=>{};var f=({direction:t=s,imageSrc:r,isCroppable:a,onImageCrop:i=c,portletNamespace:f})=>{const l=(0,o.useRef)(),p=(0,o.useRef)(),[d,g]=(0,o.useState)({x:0,y:0}),[m,y]=(0,o.useState)(),[v,b]=(0,o.useState)(),j=r=>{r.stopPropagation(),r.preventDefault();const n=l.current,o=p.current,a=n.getBoundingClientRect();let i=d.x,f=d.y;if(t===u||t===e){if(i+=r.pageX-a.left-m.x,i>=0||i<n.offsetWidth-o.offsetWidth)return void r.preventDefault()}if(t===s||t===e){if(f+=r.pageY-a.top-m.y,f>=0||f<n.offsetHeight-o.offsetHeight)return void r.preventDefault()}g({x:i,y:f})},w=e=>{e.stopPropagation(),e.preventDefault(),b(!1);const t=Liferay.Util.getCropRegion(p.current,{height:l.current.offsetHeight,x:Math.abs(d.x),y:Math.abs(d.y)});i(t)};return(0,o.useEffect)((()=>(v&&(document.addEventListener("mousemove",j),document.addEventListener("mouseup",w)),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",w)})),[v]),o.default.createElement("div",{className:(0,n.default)("image-wrapper",{cropper:a}),ref:l},o.default.createElement("img",{alt:Liferay.Language.get("current-image"),className:"current-image",id:"".concat(f,"image"),onMouseDown:e=>{e.stopPropagation(),e.preventDefault();const t=l.current.getBoundingClientRect();y({x:e.pageX-t.left,y:e.pageY-t.top}),b(!0)},ref:p,src:r,style:(()=>{let e={};return a&&(e={cursor:v?"move":"unset",left:d.x,position:"relative",top:d.y}),e})()}))};t.default=f}}));
//# sourceMappingURL=ImageSelectorImage.js.map