diff --git a/client/dist/assets/index-62d0f7b2.js b/client/dist/assets/index-50c9551a.js similarity index 99% rename from client/dist/assets/index-62d0f7b2.js rename to client/dist/assets/index-50c9551a.js index 24af07b..c0e95b4 100644 --- a/client/dist/assets/index-62d0f7b2.js +++ b/client/dist/assets/index-50c9551a.js @@ -2787,7 +2787,7 @@ PERFORMANCE OF THIS SOFTWARE. border-left: 0; border-right: 0; } -`,MIN_ZOOM=1,MAX_ZOOM=3,Cropper=function(_e){__extends(_t,_e);function _t(){var Vt=_e!==null&&_e.apply(this,arguments)||this;return Vt.imageRef=React$98.createRef(),Vt.videoRef=React$98.createRef(),Vt.containerRef=null,Vt.styleRef=null,Vt.containerRect=null,Vt.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},Vt.dragStartPosition={x:0,y:0},Vt.dragStartCrop={x:0,y:0},Vt.gestureZoomStart=0,Vt.gestureRotationStart=0,Vt.isTouching=!1,Vt.lastPinchDistance=0,Vt.lastPinchRotation=0,Vt.rafDragTimeout=null,Vt.rafPinchTimeout=null,Vt.wheelTimer=null,Vt.currentDoc=typeof document<"u"?document:null,Vt.currentWindow=typeof window<"u"?window:null,Vt.resizeObserver=null,Vt.state={cropSize:null,hasWheelJustStarted:!1},Vt.initResizeObserver=function(){if(!(typeof window.ResizeObserver>"u"||!Vt.containerRef)){var Wt=!0;Vt.resizeObserver=new window.ResizeObserver(function(_r){if(Wt){Wt=!1;return}Vt.computeSizes()}),Vt.resizeObserver.observe(Vt.containerRef)}},Vt.preventZoomSafari=function(Wt){return Wt.preventDefault()},Vt.cleanEvents=function(){Vt.currentDoc&&(Vt.currentDoc.removeEventListener("mousemove",Vt.onMouseMove),Vt.currentDoc.removeEventListener("mouseup",Vt.onDragStopped),Vt.currentDoc.removeEventListener("touchmove",Vt.onTouchMove),Vt.currentDoc.removeEventListener("touchend",Vt.onDragStopped),Vt.currentDoc.removeEventListener("gesturemove",Vt.onGestureMove),Vt.currentDoc.removeEventListener("gestureend",Vt.onGestureEnd))},Vt.clearScrollEvent=function(){Vt.containerRef&&Vt.containerRef.removeEventListener("wheel",Vt.onWheel),Vt.wheelTimer&&clearTimeout(Vt.wheelTimer)},Vt.onMediaLoad=function(){var Wt=Vt.computeSizes();Wt&&(Vt.emitCropData(),Vt.setInitialCrop(Wt)),Vt.props.onMediaLoaded&&Vt.props.onMediaLoaded(Vt.mediaSize)},Vt.setInitialCrop=function(Wt){if(Vt.props.initialCroppedAreaPercentages){var _r=getInitialCropFromCroppedAreaPercentages(Vt.props.initialCroppedAreaPercentages,Vt.mediaSize,Vt.props.rotation,Wt,Vt.props.minZoom,Vt.props.maxZoom),_n=_r.crop,_i=_r.zoom;Vt.props.onCropChange(_n),Vt.props.onZoomChange&&Vt.props.onZoomChange(_i)}else if(Vt.props.initialCroppedAreaPixels){var _a=getInitialCropFromCroppedAreaPixels(Vt.props.initialCroppedAreaPixels,Vt.mediaSize,Vt.props.rotation,Wt,Vt.props.minZoom,Vt.props.maxZoom),_n=_a.crop,_i=_a.zoom;Vt.props.onCropChange(_n),Vt.props.onZoomChange&&Vt.props.onZoomChange(_i)}},Vt.computeSizes=function(){var Wt,_r,_n,_i,_a,_c,_u=Vt.imageRef.current||Vt.videoRef.current;if(_u&&Vt.containerRef){Vt.containerRect=Vt.containerRef.getBoundingClientRect();var _d=Vt.containerRect.width/Vt.containerRect.height,_p=((Wt=Vt.imageRef.current)===null||Wt===void 0?void 0:Wt.naturalWidth)||((_r=Vt.videoRef.current)===null||_r===void 0?void 0:_r.videoWidth)||0,_f=((_n=Vt.imageRef.current)===null||_n===void 0?void 0:_n.naturalHeight)||((_i=Vt.videoRef.current)===null||_i===void 0?void 0:_i.videoHeight)||0,n0=_u.offsetWidth<_p||_u.offsetHeight<_f,s0=_p/_f,o0=void 0;if(n0){var c0=Vt.getObjectFit();switch(c0){default:case"contain":o0=_d>s0?{width:Vt.containerRect.height*s0,height:Vt.containerRect.height}:{width:Vt.containerRect.width,height:Vt.containerRect.width/s0};break;case"horizontal-cover":o0={width:Vt.containerRect.width,height:Vt.containerRect.width/s0};break;case"vertical-cover":o0={width:Vt.containerRect.height*s0,height:Vt.containerRect.height};break}}else o0={width:_u.offsetWidth,height:_u.offsetHeight};Vt.mediaSize=__assign(__assign({},o0),{naturalWidth:_p,naturalHeight:_f}),Vt.props.setMediaSize&&Vt.props.setMediaSize(Vt.mediaSize);var t0=Vt.props.cropSize?Vt.props.cropSize:getCropSize(Vt.mediaSize.width,Vt.mediaSize.height,Vt.containerRect.width,Vt.containerRect.height,Vt.props.aspect,Vt.props.rotation);return(((_a=Vt.state.cropSize)===null||_a===void 0?void 0:_a.height)!==t0.height||((_c=Vt.state.cropSize)===null||_c===void 0?void 0:_c.width)!==t0.width)&&Vt.props.onCropSizeChange&&Vt.props.onCropSizeChange(t0),Vt.setState({cropSize:t0},Vt.recomputeCropPosition),Vt.props.setCropSize&&Vt.props.setCropSize(t0),t0}},Vt.onMouseDown=function(Wt){Vt.currentDoc&&(Wt.preventDefault(),Vt.currentDoc.addEventListener("mousemove",Vt.onMouseMove),Vt.currentDoc.addEventListener("mouseup",Vt.onDragStopped),Vt.onDragStart(_t.getMousePoint(Wt)))},Vt.onMouseMove=function(Wt){return Vt.onDrag(_t.getMousePoint(Wt))},Vt.onTouchStart=function(Wt){Vt.currentDoc&&(Vt.isTouching=!0,!(Vt.props.onTouchRequest&&!Vt.props.onTouchRequest(Wt))&&(Vt.currentDoc.addEventListener("touchmove",Vt.onTouchMove,{passive:!1}),Vt.currentDoc.addEventListener("touchend",Vt.onDragStopped),Wt.touches.length===2?Vt.onPinchStart(Wt):Wt.touches.length===1&&Vt.onDragStart(_t.getTouchPoint(Wt.touches[0]))))},Vt.onTouchMove=function(Wt){Wt.preventDefault(),Wt.touches.length===2?Vt.onPinchMove(Wt):Wt.touches.length===1&&Vt.onDrag(_t.getTouchPoint(Wt.touches[0]))},Vt.onGestureStart=function(Wt){Vt.currentDoc&&(Wt.preventDefault(),Vt.currentDoc.addEventListener("gesturechange",Vt.onGestureMove),Vt.currentDoc.addEventListener("gestureend",Vt.onGestureEnd),Vt.gestureZoomStart=Vt.props.zoom,Vt.gestureRotationStart=Vt.props.rotation)},Vt.onGestureMove=function(Wt){if(Wt.preventDefault(),!Vt.isTouching){var _r=_t.getMousePoint(Wt),_n=Vt.gestureZoomStart-1+Wt.scale;if(Vt.setNewZoom(_n,_r,{shouldUpdatePosition:!0}),Vt.props.onRotationChange){var _i=Vt.gestureRotationStart+Wt.rotation;Vt.props.onRotationChange(_i)}}},Vt.onGestureEnd=function(Wt){Vt.cleanEvents()},Vt.onDragStart=function(Wt){var _r,_n,_i=Wt.x,_a=Wt.y;Vt.dragStartPosition={x:_i,y:_a},Vt.dragStartCrop=__assign({},Vt.props.crop),(_n=(_r=Vt.props).onInteractionStart)===null||_n===void 0||_n.call(_r)},Vt.onDrag=function(Wt){var _r=Wt.x,_n=Wt.y;Vt.currentWindow&&(Vt.rafDragTimeout&&Vt.currentWindow.cancelAnimationFrame(Vt.rafDragTimeout),Vt.rafDragTimeout=Vt.currentWindow.requestAnimationFrame(function(){if(Vt.state.cropSize&&!(_r===void 0||_n===void 0)){var _i=_r-Vt.dragStartPosition.x,_a=_n-Vt.dragStartPosition.y,_c={x:Vt.dragStartCrop.x+_i,y:Vt.dragStartCrop.y+_a},_u=Vt.props.restrictPosition?restrictPosition(_c,Vt.mediaSize,Vt.state.cropSize,Vt.props.zoom,Vt.props.rotation):_c;Vt.props.onCropChange(_u)}}))},Vt.onDragStopped=function(){var Wt,_r;Vt.isTouching=!1,Vt.cleanEvents(),Vt.emitCropData(),(_r=(Wt=Vt.props).onInteractionEnd)===null||_r===void 0||_r.call(Wt)},Vt.onWheel=function(Wt){if(Vt.currentWindow&&!(Vt.props.onWheelRequest&&!Vt.props.onWheelRequest(Wt))){Wt.preventDefault();var _r=_t.getMousePoint(Wt),_n=normalizeWheel$1(Wt).pixelY,_i=Vt.props.zoom-_n*Vt.props.zoomSpeed/200;Vt.setNewZoom(_i,_r,{shouldUpdatePosition:!0}),Vt.state.hasWheelJustStarted||Vt.setState({hasWheelJustStarted:!0},function(){var _a,_c;return(_c=(_a=Vt.props).onInteractionStart)===null||_c===void 0?void 0:_c.call(_a)}),Vt.wheelTimer&&clearTimeout(Vt.wheelTimer),Vt.wheelTimer=Vt.currentWindow.setTimeout(function(){return Vt.setState({hasWheelJustStarted:!1},function(){var _a,_c;return(_c=(_a=Vt.props).onInteractionEnd)===null||_c===void 0?void 0:_c.call(_a)})},250)}},Vt.getPointOnContainer=function(Wt){var _r=Wt.x,_n=Wt.y;if(!Vt.containerRect)throw new Error("The Cropper is not mounted");return{x:Vt.containerRect.width/2-(_r-Vt.containerRect.left),y:Vt.containerRect.height/2-(_n-Vt.containerRect.top)}},Vt.getPointOnMedia=function(Wt){var _r=Wt.x,_n=Wt.y,_i=Vt.props,_a=_i.crop,_c=_i.zoom;return{x:(_r+_a.x)/_c,y:(_n+_a.y)/_c}},Vt.setNewZoom=function(Wt,_r,_n){var _i=_n===void 0?{}:_n,_a=_i.shouldUpdatePosition,_c=_a===void 0?!0:_a;if(!(!Vt.state.cropSize||!Vt.props.onZoomChange)){var _u=clamp(Wt,Vt.props.minZoom,Vt.props.maxZoom);if(_c){var _d=Vt.getPointOnContainer(_r),_p=Vt.getPointOnMedia(_d),_f={x:_p.x*_u-_d.x,y:_p.y*_u-_d.y},n0=Vt.props.restrictPosition?restrictPosition(_f,Vt.mediaSize,Vt.state.cropSize,_u,Vt.props.rotation):_f;Vt.props.onCropChange(n0)}Vt.props.onZoomChange(_u)}},Vt.getCropData=function(){if(!Vt.state.cropSize)return null;var Wt=Vt.props.restrictPosition?restrictPosition(Vt.props.crop,Vt.mediaSize,Vt.state.cropSize,Vt.props.zoom,Vt.props.rotation):Vt.props.crop;return computeCroppedArea(Wt,Vt.mediaSize,Vt.state.cropSize,Vt.getAspect(),Vt.props.zoom,Vt.props.rotation,Vt.props.restrictPosition)},Vt.emitCropData=function(){var Wt=Vt.getCropData();if(Wt){var _r=Wt.croppedAreaPercentages,_n=Wt.croppedAreaPixels;Vt.props.onCropComplete&&Vt.props.onCropComplete(_r,_n),Vt.props.onCropAreaChange&&Vt.props.onCropAreaChange(_r,_n)}},Vt.emitCropAreaChange=function(){var Wt=Vt.getCropData();if(Wt){var _r=Wt.croppedAreaPercentages,_n=Wt.croppedAreaPixels;Vt.props.onCropAreaChange&&Vt.props.onCropAreaChange(_r,_n)}},Vt.recomputeCropPosition=function(){if(Vt.state.cropSize){var Wt=Vt.props.restrictPosition?restrictPosition(Vt.props.crop,Vt.mediaSize,Vt.state.cropSize,Vt.props.zoom,Vt.props.rotation):Vt.props.crop;Vt.props.onCropChange(Wt),Vt.emitCropData()}},Vt}return _t.prototype.componentDidMount=function(){!this.currentDoc||!this.currentWindow||(this.containerRef&&(this.containerRef.ownerDocument&&(this.currentDoc=this.containerRef.ownerDocument),this.currentDoc.defaultView&&(this.currentWindow=this.currentDoc.defaultView),this.initResizeObserver(),typeof window.ResizeObserver>"u"&&this.currentWindow.addEventListener("resize",this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.onGestureStart)),this.props.disableAutomaticStylesInjection||(this.styleRef=this.currentDoc.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.props.nonce&&this.styleRef.setAttribute("nonce",this.props.nonce),this.styleRef.innerHTML=css_248z$1,this.currentDoc.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef))},_t.prototype.componentWillUnmount=function(){var Vt,Wt;!this.currentDoc||!this.currentWindow||(typeof window.ResizeObserver>"u"&&this.currentWindow.removeEventListener("resize",this.computeSizes),(Vt=this.resizeObserver)===null||Vt===void 0||Vt.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef&&((Wt=this.styleRef.parentNode)===null||Wt===void 0||Wt.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},_t.prototype.componentDidUpdate=function(Vt){var Wt,_r,_n,_i,_a,_c,_u,_d,_p;Vt.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):Vt.aspect!==this.props.aspect?this.computeSizes():Vt.zoom!==this.props.zoom?this.recomputeCropPosition():((Wt=Vt.cropSize)===null||Wt===void 0?void 0:Wt.height)!==((_r=this.props.cropSize)===null||_r===void 0?void 0:_r.height)||((_n=Vt.cropSize)===null||_n===void 0?void 0:_n.width)!==((_i=this.props.cropSize)===null||_i===void 0?void 0:_i.width)?this.computeSizes():(((_a=Vt.crop)===null||_a===void 0?void 0:_a.x)!==((_c=this.props.crop)===null||_c===void 0?void 0:_c.x)||((_u=Vt.crop)===null||_u===void 0?void 0:_u.y)!==((_d=this.props.crop)===null||_d===void 0?void 0:_d.y))&&this.emitCropAreaChange(),Vt.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),Vt.video!==this.props.video&&((_p=this.videoRef.current)===null||_p===void 0||_p.load())},_t.prototype.getAspect=function(){var Vt=this.props,Wt=Vt.cropSize,_r=Vt.aspect;return Wt?Wt.width/Wt.height:_r},_t.prototype.getObjectFit=function(){var Vt,Wt,_r,_n;if(this.props.objectFit==="cover"){var _i=this.imageRef.current||this.videoRef.current;if(_i&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var _a=this.containerRect.width/this.containerRect.height,_c=((Vt=this.imageRef.current)===null||Vt===void 0?void 0:Vt.naturalWidth)||((Wt=this.videoRef.current)===null||Wt===void 0?void 0:Wt.videoWidth)||0,_u=((_r=this.imageRef.current)===null||_r===void 0?void 0:_r.naturalHeight)||((_n=this.videoRef.current)===null||_n===void 0?void 0:_n.videoHeight)||0,_d=_c/_u;return _d<_a?"horizontal-cover":"vertical-cover"}return"horizontal-cover"}return this.props.objectFit},_t.prototype.onPinchStart=function(Vt){var Wt=_t.getTouchPoint(Vt.touches[0]),_r=_t.getTouchPoint(Vt.touches[1]);this.lastPinchDistance=getDistanceBetweenPoints(Wt,_r),this.lastPinchRotation=getRotationBetweenPoints(Wt,_r),this.onDragStart(getCenter(Wt,_r))},_t.prototype.onPinchMove=function(Vt){var Wt=this;if(!(!this.currentDoc||!this.currentWindow)){var _r=_t.getTouchPoint(Vt.touches[0]),_n=_t.getTouchPoint(Vt.touches[1]),_i=getCenter(_r,_n);this.onDrag(_i),this.rafPinchTimeout&&this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=this.currentWindow.requestAnimationFrame(function(){var _a=getDistanceBetweenPoints(_r,_n),_c=Wt.props.zoom*(_a/Wt.lastPinchDistance);Wt.setNewZoom(_c,_i,{shouldUpdatePosition:!1}),Wt.lastPinchDistance=_a;var _u=getRotationBetweenPoints(_r,_n),_d=Wt.props.rotation+(_u-Wt.lastPinchRotation);Wt.props.onRotationChange&&Wt.props.onRotationChange(_d),Wt.lastPinchRotation=_u})}},_t.prototype.render=function(){var Vt=this,Wt=this.props,_r=Wt.image,_n=Wt.video,_i=Wt.mediaProps,_a=Wt.transform,_c=Wt.crop,_u=_c.x,_d=_c.y,_p=Wt.rotation,_f=Wt.zoom,n0=Wt.cropShape,s0=Wt.showGrid,o0=Wt.style,c0=o0.containerStyle,t0=o0.cropAreaStyle,e0=o0.mediaStyle,i0=Wt.classes,r0=i0.containerClassName,l0=i0.cropAreaClassName,d0=i0.mediaClassName,f0=this.getObjectFit();return React$98.createElement("div",{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(b0){return Vt.containerRef=b0},"data-testid":"container",style:c0,className:classNames("reactEasyCrop_Container",r0)},_r?React$98.createElement("img",__assign({alt:"",className:classNames("reactEasyCrop_Image",f0==="contain"&&"reactEasyCrop_Contain",f0==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",f0==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",d0)},_i,{src:_r,ref:this.imageRef,style:__assign(__assign({},e0),{transform:_a||"translate(".concat(_u,"px, ").concat(_d,"px) rotate(").concat(_p,"deg) scale(").concat(_f,")")}),onLoad:this.onMediaLoad})):_n&&React$98.createElement("video",__assign({autoPlay:!0,loop:!0,muted:!0,className:classNames("reactEasyCrop_Video",f0==="contain"&&"reactEasyCrop_Contain",f0==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",f0==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",d0)},_i,{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:__assign(__assign({},e0),{transform:_a||"translate(".concat(_u,"px, ").concat(_d,"px) rotate(").concat(_p,"deg) scale(").concat(_f,")")}),controls:!1}),(Array.isArray(_n)?_n:[{src:_n}]).map(function(p0){return React$98.createElement("source",__assign({key:p0.src},p0))})),this.state.cropSize&&React$98.createElement("div",{style:__assign(__assign({},t0),{width:this.state.cropSize.width,height:this.state.cropSize.height}),"data-testid":"cropper",className:classNames("reactEasyCrop_CropArea",n0==="round"&&"reactEasyCrop_CropAreaRound",s0&&"reactEasyCrop_CropAreaGrid",l0)}))},_t.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:MAX_ZOOM,minZoom:MIN_ZOOM,cropShape:"rect",objectFit:"contain",showGrid:!0,style:{},classes:{},mediaProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0},_t.getMousePoint=function(Vt){return{x:Number(Vt.clientX),y:Number(Vt.clientY)}},_t.getTouchPoint=function(Vt){return{x:Number(Vt.clientX),y:Number(Vt.clientY)}},_t}(React$98.Component);const createImage=_e=>new Promise((_t,Vt)=>{const Wt=new Image;Wt.addEventListener("load",()=>_t(Wt)),Wt.addEventListener("error",_r=>Vt(_r)),Wt.setAttribute("crossOrigin","anonymous"),Wt.src=_e});function getRadianAngle(_e){return _e*Math.PI/180}function rotateSize(_e,_t,Vt){const Wt=getRadianAngle(Vt);return{width:Math.abs(Math.cos(Wt)*_e)+Math.abs(Math.sin(Wt)*_t),height:Math.abs(Math.sin(Wt)*_e)+Math.abs(Math.cos(Wt)*_t)}}async function getCroppedImg(_e,_t,Vt=0,Wt={horizontal:!1,vertical:!1}){const _r=await createImage(_e),_n=document.createElement("canvas"),_i=_n.getContext("2d");if(!_i)return null;const _a=getRadianAngle(Vt),{width:_c,height:_u}=rotateSize(_r.width,_r.height,Vt);_n.width=_c,_n.height=_u,_i.translate(_c/2,_u/2),_i.rotate(_a),_i.scale(Wt.horizontal?-1:1,Wt.vertical?-1:1),_i.translate(-_r.width/2,-_r.height/2),_i.drawImage(_r,0,0);const _d=_i.getImageData(_t.x,_t.y,_t.width,_t.height);return _n.width=_t.width,_n.height=_t.height,_i.putImageData(_d,0,0),new Promise(_p=>{_n.toBlob(_f=>{_p(_f)},"image/jpeg")})}const ImageCropper=({image:_e,getImage:_t,aspectRatio:Vt})=>{const[Wt,_r]=reactExports.useState({x:0,y:0}),[_n,_i]=reactExports.useState(1),[_a,_c]=reactExports.useState(0),[_u,_d]=reactExports.useState(null),[_p,_f]=reactExports.useState(null),n0=useDispatch(),s0=reactExports.useCallback((e0,i0)=>{_d(i0)},[]),o0=reactExports.useCallback(async()=>{try{if(_u){const e0=await getCroppedImg(_e,_u,_a);e0&&_f(e0)}}catch(e0){console.error(e0)}},[_u,_a,_e]),c0=reactExports.useCallback(()=>{_f(null)},[]),t0=reactExports.useCallback(()=>{Vt===1.5/1&&_p&&n0(setTempPostImage(URL.createObjectURL(_p))),_t(_p)},[Vt,_p,n0,_t]);return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col",children:[jsxRuntimeExports.jsx("div",{className:"z-10 container",style:{display:_e===null||_p!==null?"none":"block"},children:jsxRuntimeExports.jsx("div",{className:"crop-container z-20",children:jsxRuntimeExports.jsx(Cropper,{image:_e,crop:Wt,rotation:_a,zoom:_n,zoomSpeed:4,maxZoom:3,zoomWithScroll:!0,showGrid:!0,aspect:Vt,onCropChange:_r,onCropComplete:s0,onZoomChange:_i,onRotationChange:_c,cropShape:Vt===4/4?"round":"rect"})})}),jsxRuntimeExports.jsx(react.Button,{style:{display:_e===null||_p!==null?"none":"block"},onClick:o0,className:"z-30 bg-socioverse-500 text-white",children:"Crop"}),jsxRuntimeExports.jsxs("div",{className:"cropped-image-container",children:[_p&&jsxRuntimeExports.jsx("div",{className:"flex item-center justify-center border-4 border-double border-blue-gray-400",children:jsxRuntimeExports.jsx("img",{className:classnames("cropped-image p-2 ",{" w-full, h-full":Vt===4/1},{"w-[26rem] h-56 md:h-80":Vt===1.5/1},{"w-80 h-80 rounded-full":Vt===4/4}),src:URL.createObjectURL(_p),alt:"cropped"})}),_p&&jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-start mt-6 gap-4 ",children:[jsxRuntimeExports.jsx(react.Button,{variant:"outlined",size:"sm",className:"rounded-full text-black border-black",onClick:c0,children:"Cancel"}),jsxRuntimeExports.jsx(react.Button,{size:"sm",className:"rounded-full bg-socioverse-500",onClick:t0,children:"Update"})]})]})]})})};class Subscribable{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(_t){const Vt={listener:_t};return this.listeners.add(Vt),this.onSubscribe(),()=>{this.listeners.delete(Vt),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}}const isServer=typeof window>"u"||"Deno"in window;function noop$3(){}function functionalUpdate(_e,_t){return typeof _e=="function"?_e(_t):_e}function isValidTimeout(_e){return typeof _e=="number"&&_e>=0&&_e!==1/0}function timeUntilStale(_e,_t){return Math.max(_e+(_t||0)-Date.now(),0)}function parseQueryArgs(_e,_t,Vt){return isQueryKey(_e)?typeof _t=="function"?{...Vt,queryKey:_e,queryFn:_t}:{..._t,queryKey:_e}:_e}function parseMutationArgs(_e,_t,Vt){return isQueryKey(_e)?typeof _t=="function"?{...Vt,mutationKey:_e,mutationFn:_t}:{..._t,mutationKey:_e}:typeof _e=="function"?{..._t,mutationFn:_e}:{..._e}}function parseFilterArgs(_e,_t,Vt){return isQueryKey(_e)?[{..._t,queryKey:_e},Vt]:[_e||{},_t]}function matchQuery(_e,_t){const{type:Vt="all",exact:Wt,fetchStatus:_r,predicate:_n,queryKey:_i,stale:_a}=_e;if(isQueryKey(_i)){if(Wt){if(_t.queryHash!==hashQueryKeyByOptions(_i,_t.options))return!1}else if(!partialMatchKey(_t.queryKey,_i))return!1}if(Vt!=="all"){const _c=_t.isActive();if(Vt==="active"&&!_c||Vt==="inactive"&&_c)return!1}return!(typeof _a=="boolean"&&_t.isStale()!==_a||typeof _r<"u"&&_r!==_t.state.fetchStatus||_n&&!_n(_t))}function matchMutation(_e,_t){const{exact:Vt,fetching:Wt,predicate:_r,mutationKey:_n}=_e;if(isQueryKey(_n)){if(!_t.options.mutationKey)return!1;if(Vt){if(hashQueryKey(_t.options.mutationKey)!==hashQueryKey(_n))return!1}else if(!partialMatchKey(_t.options.mutationKey,_n))return!1}return!(typeof Wt=="boolean"&&_t.state.status==="loading"!==Wt||_r&&!_r(_t))}function hashQueryKeyByOptions(_e,_t){return((_t==null?void 0:_t.queryKeyHashFn)||hashQueryKey)(_e)}function hashQueryKey(_e){return JSON.stringify(_e,(_t,Vt)=>isPlainObject(Vt)?Object.keys(Vt).sort().reduce((Wt,_r)=>(Wt[_r]=Vt[_r],Wt),{}):Vt)}function partialMatchKey(_e,_t){return partialDeepEqual(_e,_t)}function partialDeepEqual(_e,_t){return _e===_t?!0:typeof _e!=typeof _t?!1:_e&&_t&&typeof _e=="object"&&typeof _t=="object"?!Object.keys(_t).some(Vt=>!partialDeepEqual(_e[Vt],_t[Vt])):!1}function replaceEqualDeep(_e,_t){if(_e===_t)return _e;const Vt=isPlainArray(_e)&&isPlainArray(_t);if(Vt||isPlainObject(_e)&&isPlainObject(_t)){const Wt=Vt?_e.length:Object.keys(_e).length,_r=Vt?_t:Object.keys(_t),_n=_r.length,_i=Vt?[]:{};let _a=0;for(let _c=0;_c<_n;_c++){const _u=Vt?_c:_r[_c];_i[_u]=replaceEqualDeep(_e[_u],_t[_u]),_i[_u]===_e[_u]&&_a++}return Wt===_n&&_a===Wt?_e:_i}return _t}function shallowEqualObjects(_e,_t){if(_e&&!_t||_t&&!_e)return!1;for(const Vt in _e)if(_e[Vt]!==_t[Vt])return!1;return!0}function isPlainArray(_e){return Array.isArray(_e)&&_e.length===Object.keys(_e).length}function isPlainObject(_e){if(!hasObjectPrototype(_e))return!1;const _t=_e.constructor;if(typeof _t>"u")return!0;const Vt=_t.prototype;return!(!hasObjectPrototype(Vt)||!Vt.hasOwnProperty("isPrototypeOf"))}function hasObjectPrototype(_e){return Object.prototype.toString.call(_e)==="[object Object]"}function isQueryKey(_e){return Array.isArray(_e)}function sleep(_e){return new Promise(_t=>{setTimeout(_t,_e)})}function scheduleMicrotask(_e){sleep(0).then(_e)}function getAbortController(){if(typeof AbortController=="function")return new AbortController}function replaceData(_e,_t,Vt){return Vt.isDataEqual!=null&&Vt.isDataEqual(_e,_t)?_e:typeof Vt.structuralSharing=="function"?Vt.structuralSharing(_e,_t):Vt.structuralSharing!==!1?replaceEqualDeep(_e,_t):_t}class FocusManager extends Subscribable{constructor(){super(),this.setup=_t=>{if(!isServer&&window.addEventListener){const Vt=()=>_t();return window.addEventListener("visibilitychange",Vt,!1),window.addEventListener("focus",Vt,!1),()=>{window.removeEventListener("visibilitychange",Vt),window.removeEventListener("focus",Vt)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var _t;(_t=this.cleanup)==null||_t.call(this),this.cleanup=void 0}}setEventListener(_t){var Vt;this.setup=_t,(Vt=this.cleanup)==null||Vt.call(this),this.cleanup=_t(Wt=>{typeof Wt=="boolean"?this.setFocused(Wt):this.onFocus()})}setFocused(_t){this.focused!==_t&&(this.focused=_t,this.onFocus())}onFocus(){this.listeners.forEach(({listener:_t})=>{_t()})}isFocused(){return typeof this.focused=="boolean"?this.focused:typeof document>"u"?!0:[void 0,"visible","prerender"].includes(document.visibilityState)}}const focusManager=new FocusManager,onlineEvents=["online","offline"];class OnlineManager extends Subscribable{constructor(){super(),this.setup=_t=>{if(!isServer&&window.addEventListener){const Vt=()=>_t();return onlineEvents.forEach(Wt=>{window.addEventListener(Wt,Vt,!1)}),()=>{onlineEvents.forEach(Wt=>{window.removeEventListener(Wt,Vt)})}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var _t;(_t=this.cleanup)==null||_t.call(this),this.cleanup=void 0}}setEventListener(_t){var Vt;this.setup=_t,(Vt=this.cleanup)==null||Vt.call(this),this.cleanup=_t(Wt=>{typeof Wt=="boolean"?this.setOnline(Wt):this.onOnline()})}setOnline(_t){this.online!==_t&&(this.online=_t,this.onOnline())}onOnline(){this.listeners.forEach(({listener:_t})=>{_t()})}isOnline(){return typeof this.online=="boolean"?this.online:typeof navigator>"u"||typeof navigator.onLine>"u"?!0:navigator.onLine}}const onlineManager=new OnlineManager;function defaultRetryDelay(_e){return Math.min(1e3*2**_e,3e4)}function canFetch(_e){return(_e??"online")==="online"?onlineManager.isOnline():!0}class CancelledError{constructor(_t){this.revert=_t==null?void 0:_t.revert,this.silent=_t==null?void 0:_t.silent}}function isCancelledError(_e){return _e instanceof CancelledError}function createRetryer(_e){let _t=!1,Vt=0,Wt=!1,_r,_n,_i;const _a=new Promise((c0,t0)=>{_n=c0,_i=t0}),_c=c0=>{Wt||(n0(new CancelledError(c0)),_e.abort==null||_e.abort())},_u=()=>{_t=!0},_d=()=>{_t=!1},_p=()=>!focusManager.isFocused()||_e.networkMode!=="always"&&!onlineManager.isOnline(),_f=c0=>{Wt||(Wt=!0,_e.onSuccess==null||_e.onSuccess(c0),_r==null||_r(),_n(c0))},n0=c0=>{Wt||(Wt=!0,_e.onError==null||_e.onError(c0),_r==null||_r(),_i(c0))},s0=()=>new Promise(c0=>{_r=t0=>{const e0=Wt||!_p();return e0&&c0(t0),e0},_e.onPause==null||_e.onPause()}).then(()=>{_r=void 0,Wt||_e.onContinue==null||_e.onContinue()}),o0=()=>{if(Wt)return;let c0;try{c0=_e.fn()}catch(t0){c0=Promise.reject(t0)}Promise.resolve(c0).then(_f).catch(t0=>{var e0,i0;if(Wt)return;const r0=(e0=_e.retry)!=null?e0:3,l0=(i0=_e.retryDelay)!=null?i0:defaultRetryDelay,d0=typeof l0=="function"?l0(Vt,t0):l0,f0=r0===!0||typeof r0=="number"&&Vt{if(_p())return s0()}).then(()=>{_t?n0(t0):o0()})})};return canFetch(_e.networkMode)?o0():s0().then(o0),{promise:_a,cancel:_c,continue:()=>(_r==null?void 0:_r())?_a:Promise.resolve(),cancelRetry:_u,continueRetry:_d}}const defaultLogger=console;function createNotifyManager(){let _e=[],_t=0,Vt=_d=>{_d()},Wt=_d=>{_d()};const _r=_d=>{let _p;_t++;try{_p=_d()}finally{_t--,_t||_a()}return _p},_n=_d=>{_t?_e.push(_d):scheduleMicrotask(()=>{Vt(_d)})},_i=_d=>(..._p)=>{_n(()=>{_d(..._p)})},_a=()=>{const _d=_e;_e=[],_d.length&&scheduleMicrotask(()=>{Wt(()=>{_d.forEach(_p=>{Vt(_p)})})})};return{batch:_r,batchCalls:_i,schedule:_n,setNotifyFunction:_d=>{Vt=_d},setBatchNotifyFunction:_d=>{Wt=_d}}}const notifyManager=createNotifyManager();class Removable{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),isValidTimeout(this.cacheTime)&&(this.gcTimeout=setTimeout(()=>{this.optionalRemove()},this.cacheTime))}updateCacheTime(_t){this.cacheTime=Math.max(this.cacheTime||0,_t??(isServer?1/0:5*60*1e3))}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}class Query extends Removable{constructor(_t){super(),this.abortSignalConsumed=!1,this.defaultOptions=_t.defaultOptions,this.setOptions(_t.options),this.observers=[],this.cache=_t.cache,this.logger=_t.logger||defaultLogger,this.queryKey=_t.queryKey,this.queryHash=_t.queryHash,this.initialState=_t.state||getDefaultState$1(this.options),this.state=this.initialState,this.scheduleGc()}get meta(){return this.options.meta}setOptions(_t){this.options={...this.defaultOptions,..._t},this.updateCacheTime(this.options.cacheTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.cache.remove(this)}setData(_t,Vt){const Wt=replaceData(this.state.data,_t,this.options);return this.dispatch({data:Wt,type:"success",dataUpdatedAt:Vt==null?void 0:Vt.updatedAt,manual:Vt==null?void 0:Vt.manual}),Wt}setState(_t,Vt){this.dispatch({type:"setState",state:_t,setStateOptions:Vt})}cancel(_t){var Vt;const Wt=this.promise;return(Vt=this.retryer)==null||Vt.cancel(_t),Wt?Wt.then(noop$3).catch(noop$3):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.initialState)}isActive(){return this.observers.some(_t=>_t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(_t=>_t.getCurrentResult().isStale)}isStaleByTime(_t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!timeUntilStale(this.state.dataUpdatedAt,_t)}onFocus(){var _t;const Vt=this.observers.find(Wt=>Wt.shouldFetchOnWindowFocus());Vt&&Vt.refetch({cancelRefetch:!1}),(_t=this.retryer)==null||_t.continue()}onOnline(){var _t;const Vt=this.observers.find(Wt=>Wt.shouldFetchOnReconnect());Vt&&Vt.refetch({cancelRefetch:!1}),(_t=this.retryer)==null||_t.continue()}addObserver(_t){this.observers.includes(_t)||(this.observers.push(_t),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:_t}))}removeObserver(_t){this.observers.includes(_t)&&(this.observers=this.observers.filter(Vt=>Vt!==_t),this.observers.length||(this.retryer&&(this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.scheduleGc()),this.cache.notify({type:"observerRemoved",query:this,observer:_t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.dispatch({type:"invalidate"})}fetch(_t,Vt){var Wt,_r;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&Vt!=null&&Vt.cancelRefetch)this.cancel({silent:!0});else if(this.promise){var _n;return(_n=this.retryer)==null||_n.continueRetry(),this.promise}}if(_t&&this.setOptions(_t),!this.options.queryFn){const n0=this.observers.find(s0=>s0.options.queryFn);n0&&this.setOptions(n0.options)}Array.isArray(this.options.queryKey);const _i=getAbortController(),_a={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},_c=n0=>{Object.defineProperty(n0,"signal",{enumerable:!0,get:()=>{if(_i)return this.abortSignalConsumed=!0,_i.signal}})};_c(_a);const _u=()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(_a)):Promise.reject("Missing queryFn for queryKey '"+this.options.queryHash+"'"),_d={fetchOptions:Vt,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:_u};if(_c(_d),(Wt=this.options.behavior)==null||Wt.onFetch(_d),this.revertState=this.state,this.state.fetchStatus==="idle"||this.state.fetchMeta!==((_r=_d.fetchOptions)==null?void 0:_r.meta)){var _p;this.dispatch({type:"fetch",meta:(_p=_d.fetchOptions)==null?void 0:_p.meta})}const _f=n0=>{if(isCancelledError(n0)&&n0.silent||this.dispatch({type:"error",error:n0}),!isCancelledError(n0)){var s0,o0,c0,t0;(s0=(o0=this.cache.config).onError)==null||s0.call(o0,n0,this),(c0=(t0=this.cache.config).onSettled)==null||c0.call(t0,this.state.data,n0,this)}this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=createRetryer({fn:_d.fetchFn,abort:_i==null?void 0:_i.abort.bind(_i),onSuccess:n0=>{var s0,o0,c0,t0;if(typeof n0>"u"){_f(new Error(this.queryHash+" data is undefined"));return}this.setData(n0),(s0=(o0=this.cache.config).onSuccess)==null||s0.call(o0,n0,this),(c0=(t0=this.cache.config).onSettled)==null||c0.call(t0,n0,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:_f,onFail:(n0,s0)=>{this.dispatch({type:"failed",failureCount:n0,error:s0})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:_d.options.retry,retryDelay:_d.options.retryDelay,networkMode:_d.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(_t){const Vt=Wt=>{var _r,_n;switch(_t.type){case"failed":return{...Wt,fetchFailureCount:_t.failureCount,fetchFailureReason:_t.error};case"pause":return{...Wt,fetchStatus:"paused"};case"continue":return{...Wt,fetchStatus:"fetching"};case"fetch":return{...Wt,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:(_r=_t.meta)!=null?_r:null,fetchStatus:canFetch(this.options.networkMode)?"fetching":"paused",...!Wt.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...Wt,data:_t.data,dataUpdateCount:Wt.dataUpdateCount+1,dataUpdatedAt:(_n=_t.dataUpdatedAt)!=null?_n:Date.now(),error:null,isInvalidated:!1,status:"success",...!_t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const _i=_t.error;return isCancelledError(_i)&&_i.revert&&this.revertState?{...this.revertState}:{...Wt,error:_i,errorUpdateCount:Wt.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:Wt.fetchFailureCount+1,fetchFailureReason:_i,fetchStatus:"idle",status:"error"};case"invalidate":return{...Wt,isInvalidated:!0};case"setState":return{...Wt,..._t.state}}};this.state=Vt(this.state),notifyManager.batch(()=>{this.observers.forEach(Wt=>{Wt.onQueryUpdate(_t)}),this.cache.notify({query:this,type:"updated",action:_t})})}}function getDefaultState$1(_e){const _t=typeof _e.initialData=="function"?_e.initialData():_e.initialData,Vt=typeof _t<"u",Wt=Vt?typeof _e.initialDataUpdatedAt=="function"?_e.initialDataUpdatedAt():_e.initialDataUpdatedAt:0;return{data:_t,dataUpdateCount:0,dataUpdatedAt:Vt?Wt??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:Vt?"success":"loading",fetchStatus:"idle"}}class QueryCache extends Subscribable{constructor(_t){super(),this.config=_t||{},this.queries=[],this.queriesMap={}}build(_t,Vt,Wt){var _r;const _n=Vt.queryKey,_i=(_r=Vt.queryHash)!=null?_r:hashQueryKeyByOptions(_n,Vt);let _a=this.get(_i);return _a||(_a=new Query({cache:this,logger:_t.getLogger(),queryKey:_n,queryHash:_i,options:_t.defaultQueryOptions(Vt),state:Wt,defaultOptions:_t.getQueryDefaults(_n)}),this.add(_a)),_a}add(_t){this.queriesMap[_t.queryHash]||(this.queriesMap[_t.queryHash]=_t,this.queries.push(_t),this.notify({type:"added",query:_t}))}remove(_t){const Vt=this.queriesMap[_t.queryHash];Vt&&(_t.destroy(),this.queries=this.queries.filter(Wt=>Wt!==_t),Vt===_t&&delete this.queriesMap[_t.queryHash],this.notify({type:"removed",query:_t}))}clear(){notifyManager.batch(()=>{this.queries.forEach(_t=>{this.remove(_t)})})}get(_t){return this.queriesMap[_t]}getAll(){return this.queries}find(_t,Vt){const[Wt]=parseFilterArgs(_t,Vt);return typeof Wt.exact>"u"&&(Wt.exact=!0),this.queries.find(_r=>matchQuery(Wt,_r))}findAll(_t,Vt){const[Wt]=parseFilterArgs(_t,Vt);return Object.keys(Wt).length>0?this.queries.filter(_r=>matchQuery(Wt,_r)):this.queries}notify(_t){notifyManager.batch(()=>{this.listeners.forEach(({listener:Vt})=>{Vt(_t)})})}onFocus(){notifyManager.batch(()=>{this.queries.forEach(_t=>{_t.onFocus()})})}onOnline(){notifyManager.batch(()=>{this.queries.forEach(_t=>{_t.onOnline()})})}}class Mutation extends Removable{constructor(_t){super(),this.defaultOptions=_t.defaultOptions,this.mutationId=_t.mutationId,this.mutationCache=_t.mutationCache,this.logger=_t.logger||defaultLogger,this.observers=[],this.state=_t.state||getDefaultState(),this.setOptions(_t.options),this.scheduleGc()}setOptions(_t){this.options={...this.defaultOptions,..._t},this.updateCacheTime(this.options.cacheTime)}get meta(){return this.options.meta}setState(_t){this.dispatch({type:"setState",state:_t})}addObserver(_t){this.observers.includes(_t)||(this.observers.push(_t),this.clearGcTimeout(),this.mutationCache.notify({type:"observerAdded",mutation:this,observer:_t}))}removeObserver(_t){this.observers=this.observers.filter(Vt=>Vt!==_t),this.scheduleGc(),this.mutationCache.notify({type:"observerRemoved",mutation:this,observer:_t})}optionalRemove(){this.observers.length||(this.state.status==="loading"?this.scheduleGc():this.mutationCache.remove(this))}continue(){var _t,Vt;return(_t=(Vt=this.retryer)==null?void 0:Vt.continue())!=null?_t:this.execute()}async execute(){const _t=()=>{var f0;return this.retryer=createRetryer({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:(p0,b0)=>{this.dispatch({type:"failed",failureCount:p0,error:b0})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:(f0=this.options.retry)!=null?f0:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode}),this.retryer.promise},Vt=this.state.status==="loading";try{var Wt,_r,_n,_i,_a,_c,_u,_d;if(!Vt){var _p,_f,n0,s0;this.dispatch({type:"loading",variables:this.options.variables}),await((_p=(_f=this.mutationCache.config).onMutate)==null?void 0:_p.call(_f,this.state.variables,this));const p0=await((n0=(s0=this.options).onMutate)==null?void 0:n0.call(s0,this.state.variables));p0!==this.state.context&&this.dispatch({type:"loading",context:p0,variables:this.state.variables})}const f0=await _t();return await((Wt=(_r=this.mutationCache.config).onSuccess)==null?void 0:Wt.call(_r,f0,this.state.variables,this.state.context,this)),await((_n=(_i=this.options).onSuccess)==null?void 0:_n.call(_i,f0,this.state.variables,this.state.context)),await((_a=(_c=this.mutationCache.config).onSettled)==null?void 0:_a.call(_c,f0,null,this.state.variables,this.state.context,this)),await((_u=(_d=this.options).onSettled)==null?void 0:_u.call(_d,f0,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:f0}),f0}catch(f0){try{var o0,c0,t0,e0,i0,r0,l0,d0;throw await((o0=(c0=this.mutationCache.config).onError)==null?void 0:o0.call(c0,f0,this.state.variables,this.state.context,this)),await((t0=(e0=this.options).onError)==null?void 0:t0.call(e0,f0,this.state.variables,this.state.context)),await((i0=(r0=this.mutationCache.config).onSettled)==null?void 0:i0.call(r0,void 0,f0,this.state.variables,this.state.context,this)),await((l0=(d0=this.options).onSettled)==null?void 0:l0.call(d0,void 0,f0,this.state.variables,this.state.context)),f0}finally{this.dispatch({type:"error",error:f0})}}}dispatch(_t){const Vt=Wt=>{switch(_t.type){case"failed":return{...Wt,failureCount:_t.failureCount,failureReason:_t.error};case"pause":return{...Wt,isPaused:!0};case"continue":return{...Wt,isPaused:!1};case"loading":return{...Wt,context:_t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!canFetch(this.options.networkMode),status:"loading",variables:_t.variables};case"success":return{...Wt,data:_t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...Wt,data:void 0,error:_t.error,failureCount:Wt.failureCount+1,failureReason:_t.error,isPaused:!1,status:"error"};case"setState":return{...Wt,..._t.state}}};this.state=Vt(this.state),notifyManager.batch(()=>{this.observers.forEach(Wt=>{Wt.onMutationUpdate(_t)}),this.mutationCache.notify({mutation:this,type:"updated",action:_t})})}}function getDefaultState(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0}}class MutationCache extends Subscribable{constructor(_t){super(),this.config=_t||{},this.mutations=[],this.mutationId=0}build(_t,Vt,Wt){const _r=new Mutation({mutationCache:this,logger:_t.getLogger(),mutationId:++this.mutationId,options:_t.defaultMutationOptions(Vt),state:Wt,defaultOptions:Vt.mutationKey?_t.getMutationDefaults(Vt.mutationKey):void 0});return this.add(_r),_r}add(_t){this.mutations.push(_t),this.notify({type:"added",mutation:_t})}remove(_t){this.mutations=this.mutations.filter(Vt=>Vt!==_t),this.notify({type:"removed",mutation:_t})}clear(){notifyManager.batch(()=>{this.mutations.forEach(_t=>{this.remove(_t)})})}getAll(){return this.mutations}find(_t){return typeof _t.exact>"u"&&(_t.exact=!0),this.mutations.find(Vt=>matchMutation(_t,Vt))}findAll(_t){return this.mutations.filter(Vt=>matchMutation(_t,Vt))}notify(_t){notifyManager.batch(()=>{this.listeners.forEach(({listener:Vt})=>{Vt(_t)})})}resumePausedMutations(){var _t;return this.resuming=((_t=this.resuming)!=null?_t:Promise.resolve()).then(()=>{const Vt=this.mutations.filter(Wt=>Wt.state.isPaused);return notifyManager.batch(()=>Vt.reduce((Wt,_r)=>Wt.then(()=>_r.continue().catch(noop$3)),Promise.resolve()))}).then(()=>{this.resuming=void 0}),this.resuming}}function infiniteQueryBehavior(){return{onFetch:_e=>{_e.fetchFn=()=>{var _t,Vt,Wt,_r,_n,_i;const _a=(_t=_e.fetchOptions)==null||(Vt=_t.meta)==null?void 0:Vt.refetchPage,_c=(Wt=_e.fetchOptions)==null||(_r=Wt.meta)==null?void 0:_r.fetchMore,_u=_c==null?void 0:_c.pageParam,_d=(_c==null?void 0:_c.direction)==="forward",_p=(_c==null?void 0:_c.direction)==="backward",_f=((_n=_e.state.data)==null?void 0:_n.pages)||[],n0=((_i=_e.state.data)==null?void 0:_i.pageParams)||[];let s0=n0,o0=!1;const c0=d0=>{Object.defineProperty(d0,"signal",{enumerable:!0,get:()=>{var f0;if((f0=_e.signal)!=null&&f0.aborted)o0=!0;else{var p0;(p0=_e.signal)==null||p0.addEventListener("abort",()=>{o0=!0})}return _e.signal}})},t0=_e.options.queryFn||(()=>Promise.reject("Missing queryFn for queryKey '"+_e.options.queryHash+"'")),e0=(d0,f0,p0,b0)=>(s0=b0?[f0,...s0]:[...s0,f0],b0?[p0,...d0]:[...d0,p0]),i0=(d0,f0,p0,b0)=>{if(o0)return Promise.reject("Cancelled");if(typeof p0>"u"&&!f0&&d0.length)return Promise.resolve(d0);const g0={queryKey:_e.queryKey,pageParam:p0,meta:_e.options.meta};c0(g0);const y0=t0(g0);return Promise.resolve(y0).then(S0=>e0(d0,p0,S0,b0))};let r0;if(!_f.length)r0=i0([]);else if(_d){const d0=typeof _u<"u",f0=d0?_u:getNextPageParam(_e.options,_f);r0=i0(_f,d0,f0)}else if(_p){const d0=typeof _u<"u",f0=d0?_u:getPreviousPageParam(_e.options,_f);r0=i0(_f,d0,f0,!0)}else{s0=[];const d0=typeof _e.options.getNextPageParam>"u";r0=(_a&&_f[0]?_a(_f[0],0,_f):!0)?i0([],d0,n0[0]):Promise.resolve(e0([],n0[0],_f[0]));for(let p0=1;p0<_f.length;p0++)r0=r0.then(b0=>{if(_a&&_f[p0]?_a(_f[p0],p0,_f):!0){const y0=d0?n0[p0]:getNextPageParam(_e.options,b0);return i0(b0,d0,y0)}return Promise.resolve(e0(b0,n0[p0],_f[p0]))})}return r0.then(d0=>({pages:d0,pageParams:s0}))}}}}function getNextPageParam(_e,_t){return _e.getNextPageParam==null?void 0:_e.getNextPageParam(_t[_t.length-1],_t)}function getPreviousPageParam(_e,_t){return _e.getPreviousPageParam==null?void 0:_e.getPreviousPageParam(_t[0],_t)}class QueryClient{constructor(_t={}){this.queryCache=_t.queryCache||new QueryCache,this.mutationCache=_t.mutationCache||new MutationCache,this.logger=_t.logger||defaultLogger,this.defaultOptions=_t.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[],this.mountCount=0}mount(){this.mountCount++,this.mountCount===1&&(this.unsubscribeFocus=focusManager.subscribe(()=>{focusManager.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())}),this.unsubscribeOnline=onlineManager.subscribe(()=>{onlineManager.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var _t,Vt;this.mountCount--,this.mountCount===0&&((_t=this.unsubscribeFocus)==null||_t.call(this),this.unsubscribeFocus=void 0,(Vt=this.unsubscribeOnline)==null||Vt.call(this),this.unsubscribeOnline=void 0)}isFetching(_t,Vt){const[Wt]=parseFilterArgs(_t,Vt);return Wt.fetchStatus="fetching",this.queryCache.findAll(Wt).length}isMutating(_t){return this.mutationCache.findAll({..._t,fetching:!0}).length}getQueryData(_t,Vt){var Wt;return(Wt=this.queryCache.find(_t,Vt))==null?void 0:Wt.state.data}ensureQueryData(_t,Vt,Wt){const _r=parseQueryArgs(_t,Vt,Wt),_n=this.getQueryData(_r.queryKey);return _n?Promise.resolve(_n):this.fetchQuery(_r)}getQueriesData(_t){return this.getQueryCache().findAll(_t).map(({queryKey:Vt,state:Wt})=>{const _r=Wt.data;return[Vt,_r]})}setQueryData(_t,Vt,Wt){const _r=this.queryCache.find(_t),_n=_r==null?void 0:_r.state.data,_i=functionalUpdate(Vt,_n);if(typeof _i>"u")return;const _a=parseQueryArgs(_t),_c=this.defaultQueryOptions(_a);return this.queryCache.build(this,_c).setData(_i,{...Wt,manual:!0})}setQueriesData(_t,Vt,Wt){return notifyManager.batch(()=>this.getQueryCache().findAll(_t).map(({queryKey:_r})=>[_r,this.setQueryData(_r,Vt,Wt)]))}getQueryState(_t,Vt){var Wt;return(Wt=this.queryCache.find(_t,Vt))==null?void 0:Wt.state}removeQueries(_t,Vt){const[Wt]=parseFilterArgs(_t,Vt),_r=this.queryCache;notifyManager.batch(()=>{_r.findAll(Wt).forEach(_n=>{_r.remove(_n)})})}resetQueries(_t,Vt,Wt){const[_r,_n]=parseFilterArgs(_t,Vt,Wt),_i=this.queryCache,_a={type:"active",..._r};return notifyManager.batch(()=>(_i.findAll(_r).forEach(_c=>{_c.reset()}),this.refetchQueries(_a,_n)))}cancelQueries(_t,Vt,Wt){const[_r,_n={}]=parseFilterArgs(_t,Vt,Wt);typeof _n.revert>"u"&&(_n.revert=!0);const _i=notifyManager.batch(()=>this.queryCache.findAll(_r).map(_a=>_a.cancel(_n)));return Promise.all(_i).then(noop$3).catch(noop$3)}invalidateQueries(_t,Vt,Wt){const[_r,_n]=parseFilterArgs(_t,Vt,Wt);return notifyManager.batch(()=>{var _i,_a;if(this.queryCache.findAll(_r).forEach(_u=>{_u.invalidate()}),_r.refetchType==="none")return Promise.resolve();const _c={..._r,type:(_i=(_a=_r.refetchType)!=null?_a:_r.type)!=null?_i:"active"};return this.refetchQueries(_c,_n)})}refetchQueries(_t,Vt,Wt){const[_r,_n]=parseFilterArgs(_t,Vt,Wt),_i=notifyManager.batch(()=>this.queryCache.findAll(_r).filter(_c=>!_c.isDisabled()).map(_c=>{var _u;return _c.fetch(void 0,{..._n,cancelRefetch:(_u=_n==null?void 0:_n.cancelRefetch)!=null?_u:!0,meta:{refetchPage:_r.refetchPage}})}));let _a=Promise.all(_i).then(noop$3);return _n!=null&&_n.throwOnError||(_a=_a.catch(noop$3)),_a}fetchQuery(_t,Vt,Wt){const _r=parseQueryArgs(_t,Vt,Wt),_n=this.defaultQueryOptions(_r);typeof _n.retry>"u"&&(_n.retry=!1);const _i=this.queryCache.build(this,_n);return _i.isStaleByTime(_n.staleTime)?_i.fetch(_n):Promise.resolve(_i.state.data)}prefetchQuery(_t,Vt,Wt){return this.fetchQuery(_t,Vt,Wt).then(noop$3).catch(noop$3)}fetchInfiniteQuery(_t,Vt,Wt){const _r=parseQueryArgs(_t,Vt,Wt);return _r.behavior=infiniteQueryBehavior(),this.fetchQuery(_r)}prefetchInfiniteQuery(_t,Vt,Wt){return this.fetchInfiniteQuery(_t,Vt,Wt).then(noop$3).catch(noop$3)}resumePausedMutations(){return this.mutationCache.resumePausedMutations()}getQueryCache(){return this.queryCache}getMutationCache(){return this.mutationCache}getLogger(){return this.logger}getDefaultOptions(){return this.defaultOptions}setDefaultOptions(_t){this.defaultOptions=_t}setQueryDefaults(_t,Vt){const Wt=this.queryDefaults.find(_r=>hashQueryKey(_t)===hashQueryKey(_r.queryKey));Wt?Wt.defaultOptions=Vt:this.queryDefaults.push({queryKey:_t,defaultOptions:Vt})}getQueryDefaults(_t){if(!_t)return;const Vt=this.queryDefaults.find(Wt=>partialMatchKey(_t,Wt.queryKey));return Vt==null?void 0:Vt.defaultOptions}setMutationDefaults(_t,Vt){const Wt=this.mutationDefaults.find(_r=>hashQueryKey(_t)===hashQueryKey(_r.mutationKey));Wt?Wt.defaultOptions=Vt:this.mutationDefaults.push({mutationKey:_t,defaultOptions:Vt})}getMutationDefaults(_t){if(!_t)return;const Vt=this.mutationDefaults.find(Wt=>partialMatchKey(_t,Wt.mutationKey));return Vt==null?void 0:Vt.defaultOptions}defaultQueryOptions(_t){if(_t!=null&&_t._defaulted)return _t;const Vt={...this.defaultOptions.queries,...this.getQueryDefaults(_t==null?void 0:_t.queryKey),..._t,_defaulted:!0};return!Vt.queryHash&&Vt.queryKey&&(Vt.queryHash=hashQueryKeyByOptions(Vt.queryKey,Vt)),typeof Vt.refetchOnReconnect>"u"&&(Vt.refetchOnReconnect=Vt.networkMode!=="always"),typeof Vt.useErrorBoundary>"u"&&(Vt.useErrorBoundary=!!Vt.suspense),Vt}defaultMutationOptions(_t){return _t!=null&&_t._defaulted?_t:{...this.defaultOptions.mutations,...this.getMutationDefaults(_t==null?void 0:_t.mutationKey),..._t,_defaulted:!0}}clear(){this.queryCache.clear(),this.mutationCache.clear()}}let MutationObserver$1=class extends Subscribable{constructor(_t,Vt){super(),this.client=_t,this.setOptions(Vt),this.bindMethods(),this.updateResult()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(_t){var Vt;const Wt=this.options;this.options=this.client.defaultMutationOptions(_t),shallowEqualObjects(Wt,this.options)||this.client.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.currentMutation,observer:this}),(Vt=this.currentMutation)==null||Vt.setOptions(this.options)}onUnsubscribe(){if(!this.hasListeners()){var _t;(_t=this.currentMutation)==null||_t.removeObserver(this)}}onMutationUpdate(_t){this.updateResult();const Vt={listeners:!0};_t.type==="success"?Vt.onSuccess=!0:_t.type==="error"&&(Vt.onError=!0),this.notify(Vt)}getCurrentResult(){return this.currentResult}reset(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})}mutate(_t,Vt){return this.mutateOptions=Vt,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,{...this.options,variables:typeof _t<"u"?_t:this.options.variables}),this.currentMutation.addObserver(this),this.currentMutation.execute()}updateResult(){const _t=this.currentMutation?this.currentMutation.state:getDefaultState(),Vt={..._t,isLoading:_t.status==="loading",isSuccess:_t.status==="success",isError:_t.status==="error",isIdle:_t.status==="idle",mutate:this.mutate,reset:this.reset};this.currentResult=Vt}notify(_t){notifyManager.batch(()=>{if(this.mutateOptions&&this.hasListeners()){if(_t.onSuccess){var Vt,Wt,_r,_n;(Vt=(Wt=this.mutateOptions).onSuccess)==null||Vt.call(Wt,this.currentResult.data,this.currentResult.variables,this.currentResult.context),(_r=(_n=this.mutateOptions).onSettled)==null||_r.call(_n,this.currentResult.data,null,this.currentResult.variables,this.currentResult.context)}else if(_t.onError){var _i,_a,_c,_u;(_i=(_a=this.mutateOptions).onError)==null||_i.call(_a,this.currentResult.error,this.currentResult.variables,this.currentResult.context),(_c=(_u=this.mutateOptions).onSettled)==null||_c.call(_u,void 0,this.currentResult.error,this.currentResult.variables,this.currentResult.context)}}_t.listeners&&this.listeners.forEach(({listener:_d})=>{_d(this.currentResult)})})}};const useSyncExternalStore=shimExports.useSyncExternalStore,defaultContext=reactExports.createContext(void 0),QueryClientSharingContext=reactExports.createContext(!1);function getQueryClientContext(_e,_t){return _e||(_t&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=defaultContext),window.ReactQueryClientContext):defaultContext)}const useQueryClient=({context:_e}={})=>{const _t=reactExports.useContext(getQueryClientContext(_e,reactExports.useContext(QueryClientSharingContext)));if(!_t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return _t},QueryClientProvider=({client:_e,children:_t,context:Vt,contextSharing:Wt=!1})=>{reactExports.useEffect(()=>(_e.mount(),()=>{_e.unmount()}),[_e]);const _r=getQueryClientContext(Vt,Wt);return reactExports.createElement(QueryClientSharingContext.Provider,{value:!Vt&&Wt},reactExports.createElement(_r.Provider,{value:_e},_t))};function shouldThrowError(_e,_t){return typeof _e=="function"?_e(..._t):!!_e}function useMutation(_e,_t,Vt){const Wt=parseMutationArgs(_e,_t,Vt),_r=useQueryClient({context:Wt.context}),[_n]=reactExports.useState(()=>new MutationObserver$1(_r,Wt));reactExports.useEffect(()=>{_n.setOptions(Wt)},[_n,Wt]);const _i=useSyncExternalStore(reactExports.useCallback(_c=>_n.subscribe(notifyManager.batchCalls(_c)),[_n]),()=>_n.getCurrentResult(),()=>_n.getCurrentResult()),_a=reactExports.useCallback((_c,_u)=>{_n.mutate(_c,_u).catch(noop$2)},[_n]);if(_i.error&&shouldThrowError(_n.options.useErrorBoundary,[_i.error]))throw _i.error;return{..._i,mutate:_a,mutateAsync:_i.mutate}}function noop$2(){}const usePostUploadMutation=()=>{const _e=useDispatch();return useMutation(async _t=>await uploadPost(_t),{onSuccess:_t=>{_e(setPost(_t))}})},PostDialogBox=({open:_e,handleOpen:_t,setIsLastPage:Vt,setPostCreated:Wt})=>{const _r=useSelector(S0=>S0.auth.user),[_n,_i]=reactExports.useState(!1),[_a,_c]=reactExports.useState(null),[_u,_d]=reactExports.useState(null),[_p,_f]=reactExports.useState(!1),[n0,s0]=reactExports.useState(null),[o0,c0]=reactExports.useState(new FormData),[t0,e0]=reactExports.useState([]),i0=useSelector(S0=>S0.post.image),r0=useDispatch(),l0=()=>_i(!_n),d0=()=>_f(!_p),f0=usePostUploadMutation(),p0=async(S0,x0)=>{if(S0.length>0)try{S0.forEach((O0,T0)=>{x0.append("files",O0,`image${T0}.jpg`)})}catch(O0){console.error("Upload error:",O0)}},b0=S0=>{e0(x0=>[...x0,{blob:S0,image:URL.createObjectURL(S0)}]),d0()},g0=S0=>{var x0;if((x0=S0.target.files)!=null&&x0.length&&S0.target.files[0]){const O0=S0.target.files[0];O0.type.startsWith("image/")?(s0(O0),_f(!0)):Q.warn("Only image files are allowed!",TOAST_ACTION)}},y0=async()=>{if(i0&&i0.length>0){const S0=t0.map(x0=>x0.blob);await p0(S0,o0)}if(_a&&o0.append("description",_a),_u&&o0.append("hashtags",_u),!_a&&!_u&&(!i0||i0.length===0))Q.dismiss(),Q.error("All the fields cannot be empty!",TOAST_ACTION);else try{const S0=f0.mutateAsync(o0);Q.promise(S0,{pending:"Uploading the post...",success:"Post uploaded successfully",error:"Upload failed!"},{...TOAST_ACTION,position:"bottom-left",closeButton:!1}),await(S0||f0.isSuccess)?(Vt(!1),Q.dismiss(),Wt((await S0).post)):Q.dismiss(),_t(),_d(null),_c(null),s0(null),r0(resetTempPostImage()),e0([])}catch{Q.dismiss(),Q.error("Upload failed!",{...TOAST_ACTION,position:"bottom-left"})}c0(new FormData)},_0=S0=>{r0(deleteTempPostImage(S0)),e0(x0=>x0.filter(O0=>O0.image!==S0))};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(react.Dialog,{open:_e,size:"md",handler:_t,dismiss:{enabled:!1},animate:{mount:{scale:1,y:0},unmount:{scale:.9,y:-100}},children:[jsxRuntimeExports.jsx(k,{}),jsxRuntimeExports.jsx(react.DialogHeader,{children:jsxRuntimeExports.jsxs("div",{className:"flex justify-between items-center w-full",children:[jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between gap-5 transition-transform duration-300 mx-1 px-2 pb-3 rounded-lg cursor-pointer hover:bg-gray-200 hover:scale-105",children:_r&&jsxRuntimeExports.jsx(Link,{to:`/profile/${_r._id}`,children:jsxRuntimeExports.jsxs("div",{className:"mt-3 flex items-center space-x-2",children:[jsxRuntimeExports.jsx("img",{className:"inline-block h-12 w-12 rounded-full",src:_r.dp?_r.dp:CONSTANTS_COMMON.DEFAULT_IMG,alt:"user dp"}),jsxRuntimeExports.jsxs("span",{className:"flex flex-col",children:[jsxRuntimeExports.jsx("span",{className:"text-[14px] font-bold text-gray-900",children:_r.name}),jsxRuntimeExports.jsx("span",{className:"text-[11px] font-bold text-green-500",children:"Post to Connections"})]})]})})}),jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx(AiOutlineCloseCircle,{className:"text-3xl cursor-pointer",onClick:_t})})]})}),jsxRuntimeExports.jsxs(react.DialogBody,{className:"flex flex-col gap-4 lg:mx-4 my-0 mx-2 px-4 py-0 md:px-4 md:py-4 max-h-[20.5rem] overflow-y-scroll",children:[jsxRuntimeExports.jsx("div",{className:"w-full mb-20 sm:mb-12",children:jsxRuntimeExports.jsx(ReactQuillComponent,{textValue:_a,setTextValue:_c})}),_n&&jsxRuntimeExports.jsx("div",{className:"w-full",children:jsxRuntimeExports.jsx(react.Input,{label:"Hashtags",value:_u||"",onChange:S0=>_d(S0.target.value)})}),i0&&i0.length>0&&jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3",children:[jsxRuntimeExports.jsx("div",{className:"border border-black/20 py-5 md:py-10 flex flex-col gap-2 md:gap-5",children:i0.map((S0,x0)=>jsxRuntimeExports.jsx("div",{className:"h-56 md:h-[19rem] w-full relative",style:{backgroundImage:`url(${S0})`,backgroundSize:"contain",backgroundRepeat:"no-repeat",backgroundPosition:"center"},children:jsxRuntimeExports.jsx("div",{className:"absolute flex gap-3 bottom-5 right-4 md:bottom-3 md:right-16",children:jsxRuntimeExports.jsx("div",{className:"flex justify-center items-center w-8 h-8 transition duration-300 ease-in-out bg-blue-gray-500 rounded-full cursor-pointer border-2 border-blue-gray-700 hover:border-red-700 hover:bg-white hover:border-3 group opacity-70 hover:opacity-100",children:jsxRuntimeExports.jsx(RiDeleteBin6Line,{className:"text-xl text-white group-hover:text-red-500",onClick:()=>_0(S0)})})})},x0))}),i0.length===5&&jsxRuntimeExports.jsx("em",{className:"text-sm font-light text-right pr-1",children:"* Max of 5 images are allowed!"})]})]}),jsxRuntimeExports.jsx(react.DialogFooter,{children:jsxRuntimeExports.jsxs("div",{className:"float-left mx-4 mb-4 flex justify-between items-center w-full",children:[jsxRuntimeExports.jsxs("div",{className:"flex justify-between items-center gap-3 mx-2",children:[jsxRuntimeExports.jsx("div",{className:classnames("flex justify-center items-center border-2 w-8 h-8 rounded-full cursor-pointer hover:border-socioverse-500 group",{"border-socioverse-500":_n},{"border-black":!_n}),onClick:l0,children:jsxRuntimeExports.jsx(HiHashtag,{className:classnames("text-2xl group-hover:text-socioverse-500",{"text-socioverse-500":_n},{"text-black":!_n})})}),jsxRuntimeExports.jsx("input",{type:"file",accept:"image/*",id:"image-input",className:"hidden",onChange:g0,disabled:(i0==null?void 0:i0.length)===5}),jsxRuntimeExports.jsx("label",{htmlFor:"image-input",className:"flex justify-center items-center text-black border-black border-2 w-8 h-8 rounded-full cursor-pointer hover:border-socioverse-500 group",children:jsxRuntimeExports.jsx(FiCamera,{className:"text-xl group-hover:text-socioverse-500"})})]}),jsxRuntimeExports.jsx(react.Button,{size:"sm",className:"rounded-full bg-socioverse-500",onClick:y0,children:"Post"})]})})]}),jsxRuntimeExports.jsxs(react.Dialog,{open:_p,size:"lg",handler:d0,animate:{mount:{scale:1,y:0},unmount:{scale:.9,y:-100}},children:[jsxRuntimeExports.jsx(react.DialogHeader,{children:jsxRuntimeExports.jsxs("div",{className:"flex justify-between items-center w-full",children:[jsxRuntimeExports.jsx("div",{className:"text-2xl",children:"Image"}),jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx(AiOutlineCloseCircle,{className:"text-3xl cursor-pointer",onClick:d0})})]})}),jsxRuntimeExports.jsx(react.DialogBody,{className:"lg:m-4 m-2",children:n0?jsxRuntimeExports.jsx("div",{className:"w-auto lg:h-[28rem] h-96 ",children:jsxRuntimeExports.jsx(ImageCropper,{image:URL.createObjectURL(n0),getImage:b0,aspectRatio:1.5/1})}):" "})]})]})},UsernameInputPopup=({handleUsernameInputPopup:_e,usernameInputPopupOpen:_t,setIsUsernameAvailable:Vt})=>{const Wt=create$3().shape({username:create$6().trim().matches(/^\S+$/,"Username cannot contain whitespace characters").min(3,"Username should be atleast 3 characters").required("Username is required")}),_r=useFormik({initialValues:{username:""},validationSchema:Wt,onSubmit:async _n=>{try{const _i=await addUsername(_n.username);_i.status==="success"?(Vt(!0),Q.success("Username added successfully",{...TOAST_ACTION,position:"bottom-left"}),Vt(!0),_e()):Q.error(_i.message,TOAST_ACTION)}catch(_i){if(isAxiosError(_i)){const _a=_i;if(_a.response&&_a.response.status>=400&&_a.response.status<=500){const _c=_a.response.data.message;Q.error(_c,TOAST_ACTION)}}}}});return jsxRuntimeExports.jsxs(react.Dialog,{open:_t,size:"md",handler:_e,dismiss:{enabled:!1},animate:{mount:{scale:1,y:0},unmount:{scale:.9,y:-100}},children:[jsxRuntimeExports.jsx(react.DialogHeader,{children:jsxRuntimeExports.jsxs("div",{className:"flex justify-between items-center w-full",children:[jsxRuntimeExports.jsx("div",{className:"text-2xl",children:"User Info"}),jsxRuntimeExports.jsx("div",{})]})}),jsxRuntimeExports.jsx(k,{}),jsxRuntimeExports.jsx(react.DialogBody,{className:"mx-4 mb-8",children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col",children:[jsxRuntimeExports.jsx("div",{className:"text-md mb-6 border-2 p-4 rounded-lg bg-green-50 border-green-500",children:"Enter your username to continue, it should be unique!"}),jsxRuntimeExports.jsxs("form",{onSubmit:_r.handleSubmit,className:"flex items-start gap-5 justify-center",children:[jsxRuntimeExports.jsx("div",{className:"w-[20rem]",children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntimeExports.jsx(react.Input,{type:"text",label:"Username",name:"username",value:_r.values.username,onChange:_r.handleChange,onBlur:_r.handleBlur}),_r.touched.username&&_r.errors.username&&jsxRuntimeExports.jsx("div",{className:"text-red-500 mt-[0.5rem] text-sm inline",children:_r.errors.username})]})}),jsxRuntimeExports.jsx(react.Button,{size:"lg",className:"bg-socioverse-500 hover:scale-105 text-white px-4 py-2 rounded-lg",disabled:!_r.values.username,type:"submit",children:"Continue"})]})]})})]})},HomeLarge=({user:_e,socket:_t})=>{const Vt=useDispatch(),[Wt,_r]=reactExports.useState([]),[_n,_i]=reactExports.useState(!1),[_a,_c]=reactExports.useState(1),[_u,_d]=reactExports.useState(!1),[_p,_f]=reactExports.useState(null),[n0,s0]=reactExports.useState(null),[o0,c0]=reactExports.useState(null),[t0,e0]=reactExports.useState(null),[i0,r0]=reactExports.useState(!1),[l0,d0]=reactExports.useState(!1),f0=useNavigate();reactExports.useEffect(()=>{_e&&r0(!!_e.username)},[_e]),reactExports.useEffect(()=>{d0(!i0)},[i0]);const p0=()=>{d0(P0=>!P0)},b0=async()=>{const P0=await getPosts(_a);_r(P0.posts),_c(_a+1),_i(!1)};reactExports.useEffect(()=>{b0()},[]),reactExports.useEffect(()=>{const P0=document.getElementById("sentinel"),k0=new IntersectionObserver(async U0=>{if(U0[0].isIntersecting&&!_n&&!_u){_i(!0);const G0=await getPosts(_a);if(G0.posts.length===0){_d(!0),_i(!1);return}else _d(!1);_r([...Wt,...G0.posts]),_c(_a+1),_i(!1)}});return k0.observe(P0),()=>{k0.unobserve(P0)}},[_n,Wt,_a,_u]),reactExports.useEffect(()=>{_e||getUserInfo().then(P0=>{Vt(setCredentials({user:P0.user,accessToken:store.getState().auth.accessToken}))})},[Vt,_e]);const[g0,y0]=reactExports.useState(!1),_0=()=>y0(!g0),S0=()=>{y0(!0)},[x0,O0]=reactExports.useState(!1),[T0,M0]=reactExports.useState(!1),I0=P0=>{O0(P0)},C0=P0=>{M0(P0)};return _p&&(_r(Wt.filter(P0=>P0._id!==_p)),_f(null)),reactExports.useEffect(()=>{n0&&(_r(Wt.filter(P0=>P0._id!==n0)),s0(null))},[Wt,n0]),reactExports.useEffect(()=>{o0&&(_r([{...o0,newPostCreated:!0},...Wt]),c0(null))},[o0,Wt]),reactExports.useEffect(()=>{t0&&(_r(Wt.map(P0=>P0._id===t0._id?t0:P0)),e0(null))},[t0,Wt]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"lg:flex gap-3 items-start justify-between h-[80vh] lg:h-[85vh]",children:[jsxRuntimeExports.jsx("aside",{className:"hidden lg:block w-3/12 px-3 sticky top-28 overflow-y-auto h-[80vh] no-scrollbar",children:jsxRuntimeExports.jsx(AsideOne,{newFollowing:x0,handleFollowingAdd:I0,removeFollowing:T0,handleFollowingRemove:C0,socket:_t})}),jsxRuntimeExports.jsxs("main",{className:"w-full lg:w-6/12 px-3 md:px-6 overflow-x-hidden overflow-y-auto h-[85vh] no-scrollbar flex flex-col items-center p-2",children:[jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between w-full md:p-2 mb-8 gap-3 md:gap-5 sticky top-0 z-40",children:[jsxRuntimeExports.jsx(react.Avatar,{variant:"circular",alt:"user dp",className:"border h-12 w-12 md:h-14 md:w-14 border-gray-500 p-0.5 cursor-pointer",src:_e&&_e.dp?_e.dp:CONSTANTS_COMMON.DEFAULT_IMG,onClick:()=>f0(`/profile/${_e&&_e._id}`)}),jsxRuntimeExports.jsx("div",{className:"w-full",onClick:S0,children:jsxRuntimeExports.jsx(PostBox,{})})]}),jsxRuntimeExports.jsxs("div",{className:" overflow-y-auto h-[85vh] w-full no-scrollbar flex flex-col items-center",children:[jsxRuntimeExports.jsxs("div",{className:"mb-10 max-w-[30rem] w-full",children:[Wt.map((P0,k0)=>jsxRuntimeExports.jsx("div",{className:"mb-10 w-full",children:jsxRuntimeExports.jsx(PostCard,{postData:P0,setDeletedPostId:_f,setReportedPostId:s0,setPostEdited:e0})},k0)),jsxRuntimeExports.jsx(PostDialogBox,{open:g0,handleOpen:_0,setIsLastPage:_d,setPostCreated:c0})]}),_u&&jsxRuntimeExports.jsx("div",{children:" No posts..."}),jsxRuntimeExports.jsx("div",{id:"sentinel",style:{height:"1px"},className:"mt-10",children:!_u&&jsxRuntimeExports.jsx("img",{src:loader$1,className:"w-20 h-20"})})]})]}),jsxRuntimeExports.jsx("aside",{className:"hidden lg:block w-3/12 px-3 pb-5 sticky top-28 overflow-hidden",children:jsxRuntimeExports.jsx(AsideTwo,{handleFollowingAdd:I0,handleFollowingRemove:C0})})]}),jsxRuntimeExports.jsx(UsernameInputPopup,{handleUsernameInputPopup:p0,usernameInputPopupOpen:l0,setIsUsernameAvailable:r0})]})},Home=({user:_e,socket:_t})=>jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(HomeLarge,{user:_e,socket:_t})}),HomePage=({socket:_e})=>{const _t=useSelector(_n=>_n.auth),Vt=useNavigate(),Wt=useDispatch();reactExports.useEffect(()=>{_t.isAuthenticated||_r()||Vt("/error")},[_t]);const _r=async()=>{try{const{user:_n}=await getUserInfo(),{accessToken:_i}=store.getState().auth;return Wt(setCredentials({user:_n,accessToken:_i})),_n}catch(_n){if(isAxiosError(_n)){const _i=_n;_i.response&&_i.response.status>=400&&_i.response.status<=500&&Vt("/login")}}};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Home,{user:_t.user,socket:_e})})},getSender=(_e,_t)=>_t[0]._id===_e?_t[1]:_t[0],groupByDate=_e=>_e.reduce((_t,Vt)=>{const Wt=hooks(Vt.createdAt).format("LL");return _t[Wt]||(_t[Wt]=[]),_t[Wt].push(Vt),_t},{}),truncate=(_e,_t)=>{if(!(!_e||typeof _e!="string"))return _e.length<=_t?_e:_e.slice(0,_t)+"..."};function FaArrowLeft(_e){return GenIcon({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M257.5 445.1l-22.2 22.2c-9.4 9.4-24.6 9.4-33.9 0L7 273c-9.4-9.4-9.4-24.6 0-33.9L201.4 44.7c9.4-9.4 24.6-9.4 33.9 0l22.2 22.2c9.5 9.5 9.3 25-.4 34.3L136.6 216H424c13.3 0 24 10.7 24 24v32c0 13.3-10.7 24-24 24H136.6l120.5 114.8c9.8 9.3 10 24.8.4 34.3z"}}]})(_e)}function FaPowerOff(_e){return GenIcon({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M400 54.1c63 45 104 118.6 104 201.9 0 136.8-110.8 247.7-247.5 248C120 504.3 8.2 393 8 256.4 7.9 173.1 48.9 99.3 111.8 54.2c11.7-8.3 28-4.8 35 7.7L162.6 90c5.9 10.5 3.1 23.8-6.6 31-41.5 30.8-68 79.6-68 134.9-.1 92.3 74.5 168.1 168 168.1 91.6 0 168.6-74.2 168-169.1-.3-51.8-24.7-101.8-68.1-134-9.7-7.2-12.4-20.5-6.5-30.9l15.8-28.1c7-12.4 23.2-16.1 34.8-7.8zM296 264V24c0-13.3-10.7-24-24-24h-32c-13.3 0-24 10.7-24 24v240c0 13.3 10.7 24 24 24h32c13.3 0 24-10.7 24-24z"}}]})(_e)}const UserCard=({user:_e})=>jsxRuntimeExports.jsx("div",{className:`flex w-full px-4 py-2 mb-5 items-center justify-between transition duration-100 +`,MIN_ZOOM=1,MAX_ZOOM=3,Cropper=function(_e){__extends(_t,_e);function _t(){var Vt=_e!==null&&_e.apply(this,arguments)||this;return Vt.imageRef=React$98.createRef(),Vt.videoRef=React$98.createRef(),Vt.containerRef=null,Vt.styleRef=null,Vt.containerRect=null,Vt.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},Vt.dragStartPosition={x:0,y:0},Vt.dragStartCrop={x:0,y:0},Vt.gestureZoomStart=0,Vt.gestureRotationStart=0,Vt.isTouching=!1,Vt.lastPinchDistance=0,Vt.lastPinchRotation=0,Vt.rafDragTimeout=null,Vt.rafPinchTimeout=null,Vt.wheelTimer=null,Vt.currentDoc=typeof document<"u"?document:null,Vt.currentWindow=typeof window<"u"?window:null,Vt.resizeObserver=null,Vt.state={cropSize:null,hasWheelJustStarted:!1},Vt.initResizeObserver=function(){if(!(typeof window.ResizeObserver>"u"||!Vt.containerRef)){var Wt=!0;Vt.resizeObserver=new window.ResizeObserver(function(_r){if(Wt){Wt=!1;return}Vt.computeSizes()}),Vt.resizeObserver.observe(Vt.containerRef)}},Vt.preventZoomSafari=function(Wt){return Wt.preventDefault()},Vt.cleanEvents=function(){Vt.currentDoc&&(Vt.currentDoc.removeEventListener("mousemove",Vt.onMouseMove),Vt.currentDoc.removeEventListener("mouseup",Vt.onDragStopped),Vt.currentDoc.removeEventListener("touchmove",Vt.onTouchMove),Vt.currentDoc.removeEventListener("touchend",Vt.onDragStopped),Vt.currentDoc.removeEventListener("gesturemove",Vt.onGestureMove),Vt.currentDoc.removeEventListener("gestureend",Vt.onGestureEnd))},Vt.clearScrollEvent=function(){Vt.containerRef&&Vt.containerRef.removeEventListener("wheel",Vt.onWheel),Vt.wheelTimer&&clearTimeout(Vt.wheelTimer)},Vt.onMediaLoad=function(){var Wt=Vt.computeSizes();Wt&&(Vt.emitCropData(),Vt.setInitialCrop(Wt)),Vt.props.onMediaLoaded&&Vt.props.onMediaLoaded(Vt.mediaSize)},Vt.setInitialCrop=function(Wt){if(Vt.props.initialCroppedAreaPercentages){var _r=getInitialCropFromCroppedAreaPercentages(Vt.props.initialCroppedAreaPercentages,Vt.mediaSize,Vt.props.rotation,Wt,Vt.props.minZoom,Vt.props.maxZoom),_n=_r.crop,_i=_r.zoom;Vt.props.onCropChange(_n),Vt.props.onZoomChange&&Vt.props.onZoomChange(_i)}else if(Vt.props.initialCroppedAreaPixels){var _a=getInitialCropFromCroppedAreaPixels(Vt.props.initialCroppedAreaPixels,Vt.mediaSize,Vt.props.rotation,Wt,Vt.props.minZoom,Vt.props.maxZoom),_n=_a.crop,_i=_a.zoom;Vt.props.onCropChange(_n),Vt.props.onZoomChange&&Vt.props.onZoomChange(_i)}},Vt.computeSizes=function(){var Wt,_r,_n,_i,_a,_c,_u=Vt.imageRef.current||Vt.videoRef.current;if(_u&&Vt.containerRef){Vt.containerRect=Vt.containerRef.getBoundingClientRect();var _d=Vt.containerRect.width/Vt.containerRect.height,_p=((Wt=Vt.imageRef.current)===null||Wt===void 0?void 0:Wt.naturalWidth)||((_r=Vt.videoRef.current)===null||_r===void 0?void 0:_r.videoWidth)||0,_f=((_n=Vt.imageRef.current)===null||_n===void 0?void 0:_n.naturalHeight)||((_i=Vt.videoRef.current)===null||_i===void 0?void 0:_i.videoHeight)||0,n0=_u.offsetWidth<_p||_u.offsetHeight<_f,s0=_p/_f,o0=void 0;if(n0){var c0=Vt.getObjectFit();switch(c0){default:case"contain":o0=_d>s0?{width:Vt.containerRect.height*s0,height:Vt.containerRect.height}:{width:Vt.containerRect.width,height:Vt.containerRect.width/s0};break;case"horizontal-cover":o0={width:Vt.containerRect.width,height:Vt.containerRect.width/s0};break;case"vertical-cover":o0={width:Vt.containerRect.height*s0,height:Vt.containerRect.height};break}}else o0={width:_u.offsetWidth,height:_u.offsetHeight};Vt.mediaSize=__assign(__assign({},o0),{naturalWidth:_p,naturalHeight:_f}),Vt.props.setMediaSize&&Vt.props.setMediaSize(Vt.mediaSize);var t0=Vt.props.cropSize?Vt.props.cropSize:getCropSize(Vt.mediaSize.width,Vt.mediaSize.height,Vt.containerRect.width,Vt.containerRect.height,Vt.props.aspect,Vt.props.rotation);return(((_a=Vt.state.cropSize)===null||_a===void 0?void 0:_a.height)!==t0.height||((_c=Vt.state.cropSize)===null||_c===void 0?void 0:_c.width)!==t0.width)&&Vt.props.onCropSizeChange&&Vt.props.onCropSizeChange(t0),Vt.setState({cropSize:t0},Vt.recomputeCropPosition),Vt.props.setCropSize&&Vt.props.setCropSize(t0),t0}},Vt.onMouseDown=function(Wt){Vt.currentDoc&&(Wt.preventDefault(),Vt.currentDoc.addEventListener("mousemove",Vt.onMouseMove),Vt.currentDoc.addEventListener("mouseup",Vt.onDragStopped),Vt.onDragStart(_t.getMousePoint(Wt)))},Vt.onMouseMove=function(Wt){return Vt.onDrag(_t.getMousePoint(Wt))},Vt.onTouchStart=function(Wt){Vt.currentDoc&&(Vt.isTouching=!0,!(Vt.props.onTouchRequest&&!Vt.props.onTouchRequest(Wt))&&(Vt.currentDoc.addEventListener("touchmove",Vt.onTouchMove,{passive:!1}),Vt.currentDoc.addEventListener("touchend",Vt.onDragStopped),Wt.touches.length===2?Vt.onPinchStart(Wt):Wt.touches.length===1&&Vt.onDragStart(_t.getTouchPoint(Wt.touches[0]))))},Vt.onTouchMove=function(Wt){Wt.preventDefault(),Wt.touches.length===2?Vt.onPinchMove(Wt):Wt.touches.length===1&&Vt.onDrag(_t.getTouchPoint(Wt.touches[0]))},Vt.onGestureStart=function(Wt){Vt.currentDoc&&(Wt.preventDefault(),Vt.currentDoc.addEventListener("gesturechange",Vt.onGestureMove),Vt.currentDoc.addEventListener("gestureend",Vt.onGestureEnd),Vt.gestureZoomStart=Vt.props.zoom,Vt.gestureRotationStart=Vt.props.rotation)},Vt.onGestureMove=function(Wt){if(Wt.preventDefault(),!Vt.isTouching){var _r=_t.getMousePoint(Wt),_n=Vt.gestureZoomStart-1+Wt.scale;if(Vt.setNewZoom(_n,_r,{shouldUpdatePosition:!0}),Vt.props.onRotationChange){var _i=Vt.gestureRotationStart+Wt.rotation;Vt.props.onRotationChange(_i)}}},Vt.onGestureEnd=function(Wt){Vt.cleanEvents()},Vt.onDragStart=function(Wt){var _r,_n,_i=Wt.x,_a=Wt.y;Vt.dragStartPosition={x:_i,y:_a},Vt.dragStartCrop=__assign({},Vt.props.crop),(_n=(_r=Vt.props).onInteractionStart)===null||_n===void 0||_n.call(_r)},Vt.onDrag=function(Wt){var _r=Wt.x,_n=Wt.y;Vt.currentWindow&&(Vt.rafDragTimeout&&Vt.currentWindow.cancelAnimationFrame(Vt.rafDragTimeout),Vt.rafDragTimeout=Vt.currentWindow.requestAnimationFrame(function(){if(Vt.state.cropSize&&!(_r===void 0||_n===void 0)){var _i=_r-Vt.dragStartPosition.x,_a=_n-Vt.dragStartPosition.y,_c={x:Vt.dragStartCrop.x+_i,y:Vt.dragStartCrop.y+_a},_u=Vt.props.restrictPosition?restrictPosition(_c,Vt.mediaSize,Vt.state.cropSize,Vt.props.zoom,Vt.props.rotation):_c;Vt.props.onCropChange(_u)}}))},Vt.onDragStopped=function(){var Wt,_r;Vt.isTouching=!1,Vt.cleanEvents(),Vt.emitCropData(),(_r=(Wt=Vt.props).onInteractionEnd)===null||_r===void 0||_r.call(Wt)},Vt.onWheel=function(Wt){if(Vt.currentWindow&&!(Vt.props.onWheelRequest&&!Vt.props.onWheelRequest(Wt))){Wt.preventDefault();var _r=_t.getMousePoint(Wt),_n=normalizeWheel$1(Wt).pixelY,_i=Vt.props.zoom-_n*Vt.props.zoomSpeed/200;Vt.setNewZoom(_i,_r,{shouldUpdatePosition:!0}),Vt.state.hasWheelJustStarted||Vt.setState({hasWheelJustStarted:!0},function(){var _a,_c;return(_c=(_a=Vt.props).onInteractionStart)===null||_c===void 0?void 0:_c.call(_a)}),Vt.wheelTimer&&clearTimeout(Vt.wheelTimer),Vt.wheelTimer=Vt.currentWindow.setTimeout(function(){return Vt.setState({hasWheelJustStarted:!1},function(){var _a,_c;return(_c=(_a=Vt.props).onInteractionEnd)===null||_c===void 0?void 0:_c.call(_a)})},250)}},Vt.getPointOnContainer=function(Wt){var _r=Wt.x,_n=Wt.y;if(!Vt.containerRect)throw new Error("The Cropper is not mounted");return{x:Vt.containerRect.width/2-(_r-Vt.containerRect.left),y:Vt.containerRect.height/2-(_n-Vt.containerRect.top)}},Vt.getPointOnMedia=function(Wt){var _r=Wt.x,_n=Wt.y,_i=Vt.props,_a=_i.crop,_c=_i.zoom;return{x:(_r+_a.x)/_c,y:(_n+_a.y)/_c}},Vt.setNewZoom=function(Wt,_r,_n){var _i=_n===void 0?{}:_n,_a=_i.shouldUpdatePosition,_c=_a===void 0?!0:_a;if(!(!Vt.state.cropSize||!Vt.props.onZoomChange)){var _u=clamp(Wt,Vt.props.minZoom,Vt.props.maxZoom);if(_c){var _d=Vt.getPointOnContainer(_r),_p=Vt.getPointOnMedia(_d),_f={x:_p.x*_u-_d.x,y:_p.y*_u-_d.y},n0=Vt.props.restrictPosition?restrictPosition(_f,Vt.mediaSize,Vt.state.cropSize,_u,Vt.props.rotation):_f;Vt.props.onCropChange(n0)}Vt.props.onZoomChange(_u)}},Vt.getCropData=function(){if(!Vt.state.cropSize)return null;var Wt=Vt.props.restrictPosition?restrictPosition(Vt.props.crop,Vt.mediaSize,Vt.state.cropSize,Vt.props.zoom,Vt.props.rotation):Vt.props.crop;return computeCroppedArea(Wt,Vt.mediaSize,Vt.state.cropSize,Vt.getAspect(),Vt.props.zoom,Vt.props.rotation,Vt.props.restrictPosition)},Vt.emitCropData=function(){var Wt=Vt.getCropData();if(Wt){var _r=Wt.croppedAreaPercentages,_n=Wt.croppedAreaPixels;Vt.props.onCropComplete&&Vt.props.onCropComplete(_r,_n),Vt.props.onCropAreaChange&&Vt.props.onCropAreaChange(_r,_n)}},Vt.emitCropAreaChange=function(){var Wt=Vt.getCropData();if(Wt){var _r=Wt.croppedAreaPercentages,_n=Wt.croppedAreaPixels;Vt.props.onCropAreaChange&&Vt.props.onCropAreaChange(_r,_n)}},Vt.recomputeCropPosition=function(){if(Vt.state.cropSize){var Wt=Vt.props.restrictPosition?restrictPosition(Vt.props.crop,Vt.mediaSize,Vt.state.cropSize,Vt.props.zoom,Vt.props.rotation):Vt.props.crop;Vt.props.onCropChange(Wt),Vt.emitCropData()}},Vt}return _t.prototype.componentDidMount=function(){!this.currentDoc||!this.currentWindow||(this.containerRef&&(this.containerRef.ownerDocument&&(this.currentDoc=this.containerRef.ownerDocument),this.currentDoc.defaultView&&(this.currentWindow=this.currentDoc.defaultView),this.initResizeObserver(),typeof window.ResizeObserver>"u"&&this.currentWindow.addEventListener("resize",this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.onGestureStart)),this.props.disableAutomaticStylesInjection||(this.styleRef=this.currentDoc.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.props.nonce&&this.styleRef.setAttribute("nonce",this.props.nonce),this.styleRef.innerHTML=css_248z$1,this.currentDoc.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef))},_t.prototype.componentWillUnmount=function(){var Vt,Wt;!this.currentDoc||!this.currentWindow||(typeof window.ResizeObserver>"u"&&this.currentWindow.removeEventListener("resize",this.computeSizes),(Vt=this.resizeObserver)===null||Vt===void 0||Vt.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef&&((Wt=this.styleRef.parentNode)===null||Wt===void 0||Wt.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},_t.prototype.componentDidUpdate=function(Vt){var Wt,_r,_n,_i,_a,_c,_u,_d,_p;Vt.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):Vt.aspect!==this.props.aspect?this.computeSizes():Vt.zoom!==this.props.zoom?this.recomputeCropPosition():((Wt=Vt.cropSize)===null||Wt===void 0?void 0:Wt.height)!==((_r=this.props.cropSize)===null||_r===void 0?void 0:_r.height)||((_n=Vt.cropSize)===null||_n===void 0?void 0:_n.width)!==((_i=this.props.cropSize)===null||_i===void 0?void 0:_i.width)?this.computeSizes():(((_a=Vt.crop)===null||_a===void 0?void 0:_a.x)!==((_c=this.props.crop)===null||_c===void 0?void 0:_c.x)||((_u=Vt.crop)===null||_u===void 0?void 0:_u.y)!==((_d=this.props.crop)===null||_d===void 0?void 0:_d.y))&&this.emitCropAreaChange(),Vt.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),Vt.video!==this.props.video&&((_p=this.videoRef.current)===null||_p===void 0||_p.load())},_t.prototype.getAspect=function(){var Vt=this.props,Wt=Vt.cropSize,_r=Vt.aspect;return Wt?Wt.width/Wt.height:_r},_t.prototype.getObjectFit=function(){var Vt,Wt,_r,_n;if(this.props.objectFit==="cover"){var _i=this.imageRef.current||this.videoRef.current;if(_i&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var _a=this.containerRect.width/this.containerRect.height,_c=((Vt=this.imageRef.current)===null||Vt===void 0?void 0:Vt.naturalWidth)||((Wt=this.videoRef.current)===null||Wt===void 0?void 0:Wt.videoWidth)||0,_u=((_r=this.imageRef.current)===null||_r===void 0?void 0:_r.naturalHeight)||((_n=this.videoRef.current)===null||_n===void 0?void 0:_n.videoHeight)||0,_d=_c/_u;return _d<_a?"horizontal-cover":"vertical-cover"}return"horizontal-cover"}return this.props.objectFit},_t.prototype.onPinchStart=function(Vt){var Wt=_t.getTouchPoint(Vt.touches[0]),_r=_t.getTouchPoint(Vt.touches[1]);this.lastPinchDistance=getDistanceBetweenPoints(Wt,_r),this.lastPinchRotation=getRotationBetweenPoints(Wt,_r),this.onDragStart(getCenter(Wt,_r))},_t.prototype.onPinchMove=function(Vt){var Wt=this;if(!(!this.currentDoc||!this.currentWindow)){var _r=_t.getTouchPoint(Vt.touches[0]),_n=_t.getTouchPoint(Vt.touches[1]),_i=getCenter(_r,_n);this.onDrag(_i),this.rafPinchTimeout&&this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=this.currentWindow.requestAnimationFrame(function(){var _a=getDistanceBetweenPoints(_r,_n),_c=Wt.props.zoom*(_a/Wt.lastPinchDistance);Wt.setNewZoom(_c,_i,{shouldUpdatePosition:!1}),Wt.lastPinchDistance=_a;var _u=getRotationBetweenPoints(_r,_n),_d=Wt.props.rotation+(_u-Wt.lastPinchRotation);Wt.props.onRotationChange&&Wt.props.onRotationChange(_d),Wt.lastPinchRotation=_u})}},_t.prototype.render=function(){var Vt=this,Wt=this.props,_r=Wt.image,_n=Wt.video,_i=Wt.mediaProps,_a=Wt.transform,_c=Wt.crop,_u=_c.x,_d=_c.y,_p=Wt.rotation,_f=Wt.zoom,n0=Wt.cropShape,s0=Wt.showGrid,o0=Wt.style,c0=o0.containerStyle,t0=o0.cropAreaStyle,e0=o0.mediaStyle,i0=Wt.classes,r0=i0.containerClassName,l0=i0.cropAreaClassName,d0=i0.mediaClassName,f0=this.getObjectFit();return React$98.createElement("div",{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(b0){return Vt.containerRef=b0},"data-testid":"container",style:c0,className:classNames("reactEasyCrop_Container",r0)},_r?React$98.createElement("img",__assign({alt:"",className:classNames("reactEasyCrop_Image",f0==="contain"&&"reactEasyCrop_Contain",f0==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",f0==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",d0)},_i,{src:_r,ref:this.imageRef,style:__assign(__assign({},e0),{transform:_a||"translate(".concat(_u,"px, ").concat(_d,"px) rotate(").concat(_p,"deg) scale(").concat(_f,")")}),onLoad:this.onMediaLoad})):_n&&React$98.createElement("video",__assign({autoPlay:!0,loop:!0,muted:!0,className:classNames("reactEasyCrop_Video",f0==="contain"&&"reactEasyCrop_Contain",f0==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",f0==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",d0)},_i,{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:__assign(__assign({},e0),{transform:_a||"translate(".concat(_u,"px, ").concat(_d,"px) rotate(").concat(_p,"deg) scale(").concat(_f,")")}),controls:!1}),(Array.isArray(_n)?_n:[{src:_n}]).map(function(p0){return React$98.createElement("source",__assign({key:p0.src},p0))})),this.state.cropSize&&React$98.createElement("div",{style:__assign(__assign({},t0),{width:this.state.cropSize.width,height:this.state.cropSize.height}),"data-testid":"cropper",className:classNames("reactEasyCrop_CropArea",n0==="round"&&"reactEasyCrop_CropAreaRound",s0&&"reactEasyCrop_CropAreaGrid",l0)}))},_t.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:MAX_ZOOM,minZoom:MIN_ZOOM,cropShape:"rect",objectFit:"contain",showGrid:!0,style:{},classes:{},mediaProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0},_t.getMousePoint=function(Vt){return{x:Number(Vt.clientX),y:Number(Vt.clientY)}},_t.getTouchPoint=function(Vt){return{x:Number(Vt.clientX),y:Number(Vt.clientY)}},_t}(React$98.Component);const createImage=_e=>new Promise((_t,Vt)=>{const Wt=new Image;Wt.addEventListener("load",()=>_t(Wt)),Wt.addEventListener("error",_r=>Vt(_r)),Wt.setAttribute("crossOrigin","anonymous"),Wt.src=_e});function getRadianAngle(_e){return _e*Math.PI/180}function rotateSize(_e,_t,Vt){const Wt=getRadianAngle(Vt);return{width:Math.abs(Math.cos(Wt)*_e)+Math.abs(Math.sin(Wt)*_t),height:Math.abs(Math.sin(Wt)*_e)+Math.abs(Math.cos(Wt)*_t)}}async function getCroppedImg(_e,_t,Vt=0,Wt={horizontal:!1,vertical:!1}){const _r=await createImage(_e),_n=document.createElement("canvas"),_i=_n.getContext("2d");if(!_i)return null;const _a=getRadianAngle(Vt),{width:_c,height:_u}=rotateSize(_r.width,_r.height,Vt);_n.width=_c,_n.height=_u,_i.translate(_c/2,_u/2),_i.rotate(_a),_i.scale(Wt.horizontal?-1:1,Wt.vertical?-1:1),_i.translate(-_r.width/2,-_r.height/2),_i.drawImage(_r,0,0);const _d=_i.getImageData(_t.x,_t.y,_t.width,_t.height);return _n.width=_t.width,_n.height=_t.height,_i.putImageData(_d,0,0),new Promise(_p=>{_n.toBlob(_f=>{_p(_f)},"image/jpeg")})}const ImageCropper=({image:_e,getImage:_t,aspectRatio:Vt})=>{const[Wt,_r]=reactExports.useState({x:0,y:0}),[_n,_i]=reactExports.useState(1),[_a,_c]=reactExports.useState(0),[_u,_d]=reactExports.useState(null),[_p,_f]=reactExports.useState(null),n0=useDispatch(),s0=reactExports.useCallback((e0,i0)=>{_d(i0)},[]),o0=reactExports.useCallback(async()=>{try{if(_u){const e0=await getCroppedImg(_e,_u,_a);e0&&_f(e0)}}catch(e0){console.error(e0)}},[_u,_a,_e]),c0=reactExports.useCallback(()=>{_f(null)},[]),t0=reactExports.useCallback(()=>{Vt===1.5/1&&_p&&n0(setTempPostImage(URL.createObjectURL(_p))),_t(_p)},[Vt,_p,n0,_t]);return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col",children:[jsxRuntimeExports.jsx("div",{className:"z-10 container",style:{display:_e===null||_p!==null?"none":"block"},children:jsxRuntimeExports.jsx("div",{className:"crop-container z-20",children:jsxRuntimeExports.jsx(Cropper,{image:_e,crop:Wt,rotation:_a,zoom:_n,zoomSpeed:4,maxZoom:3,zoomWithScroll:!0,showGrid:!0,aspect:Vt,onCropChange:_r,onCropComplete:s0,onZoomChange:_i,onRotationChange:_c,cropShape:Vt===4/4?"round":"rect"})})}),jsxRuntimeExports.jsx(react.Button,{style:{display:_e===null||_p!==null?"none":"block"},onClick:o0,className:"z-30 bg-socioverse-500 text-white",children:"Crop"}),jsxRuntimeExports.jsxs("div",{className:"cropped-image-container",children:[_p&&jsxRuntimeExports.jsx("div",{className:"flex item-center justify-center border-4 border-double border-blue-gray-400",children:jsxRuntimeExports.jsx("img",{className:classnames("cropped-image p-2 ",{" w-full, h-full":Vt===4/1},{"w-[26rem] h-56 md:h-80":Vt===1.5/1},{"w-80 h-80 rounded-full":Vt===4/4}),src:URL.createObjectURL(_p),alt:"cropped"})}),_p&&jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-start mt-6 gap-4 ",children:[jsxRuntimeExports.jsx(react.Button,{variant:"outlined",size:"sm",className:"rounded-full text-black border-black",onClick:c0,children:"Cancel"}),jsxRuntimeExports.jsx(react.Button,{size:"sm",className:"rounded-full bg-socioverse-500",onClick:t0,children:"Update"})]})]})]})})};class Subscribable{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(_t){const Vt={listener:_t};return this.listeners.add(Vt),this.onSubscribe(),()=>{this.listeners.delete(Vt),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}}const isServer=typeof window>"u"||"Deno"in window;function noop$3(){}function functionalUpdate(_e,_t){return typeof _e=="function"?_e(_t):_e}function isValidTimeout(_e){return typeof _e=="number"&&_e>=0&&_e!==1/0}function timeUntilStale(_e,_t){return Math.max(_e+(_t||0)-Date.now(),0)}function parseQueryArgs(_e,_t,Vt){return isQueryKey(_e)?typeof _t=="function"?{...Vt,queryKey:_e,queryFn:_t}:{..._t,queryKey:_e}:_e}function parseMutationArgs(_e,_t,Vt){return isQueryKey(_e)?typeof _t=="function"?{...Vt,mutationKey:_e,mutationFn:_t}:{..._t,mutationKey:_e}:typeof _e=="function"?{..._t,mutationFn:_e}:{..._e}}function parseFilterArgs(_e,_t,Vt){return isQueryKey(_e)?[{..._t,queryKey:_e},Vt]:[_e||{},_t]}function matchQuery(_e,_t){const{type:Vt="all",exact:Wt,fetchStatus:_r,predicate:_n,queryKey:_i,stale:_a}=_e;if(isQueryKey(_i)){if(Wt){if(_t.queryHash!==hashQueryKeyByOptions(_i,_t.options))return!1}else if(!partialMatchKey(_t.queryKey,_i))return!1}if(Vt!=="all"){const _c=_t.isActive();if(Vt==="active"&&!_c||Vt==="inactive"&&_c)return!1}return!(typeof _a=="boolean"&&_t.isStale()!==_a||typeof _r<"u"&&_r!==_t.state.fetchStatus||_n&&!_n(_t))}function matchMutation(_e,_t){const{exact:Vt,fetching:Wt,predicate:_r,mutationKey:_n}=_e;if(isQueryKey(_n)){if(!_t.options.mutationKey)return!1;if(Vt){if(hashQueryKey(_t.options.mutationKey)!==hashQueryKey(_n))return!1}else if(!partialMatchKey(_t.options.mutationKey,_n))return!1}return!(typeof Wt=="boolean"&&_t.state.status==="loading"!==Wt||_r&&!_r(_t))}function hashQueryKeyByOptions(_e,_t){return((_t==null?void 0:_t.queryKeyHashFn)||hashQueryKey)(_e)}function hashQueryKey(_e){return JSON.stringify(_e,(_t,Vt)=>isPlainObject(Vt)?Object.keys(Vt).sort().reduce((Wt,_r)=>(Wt[_r]=Vt[_r],Wt),{}):Vt)}function partialMatchKey(_e,_t){return partialDeepEqual(_e,_t)}function partialDeepEqual(_e,_t){return _e===_t?!0:typeof _e!=typeof _t?!1:_e&&_t&&typeof _e=="object"&&typeof _t=="object"?!Object.keys(_t).some(Vt=>!partialDeepEqual(_e[Vt],_t[Vt])):!1}function replaceEqualDeep(_e,_t){if(_e===_t)return _e;const Vt=isPlainArray(_e)&&isPlainArray(_t);if(Vt||isPlainObject(_e)&&isPlainObject(_t)){const Wt=Vt?_e.length:Object.keys(_e).length,_r=Vt?_t:Object.keys(_t),_n=_r.length,_i=Vt?[]:{};let _a=0;for(let _c=0;_c<_n;_c++){const _u=Vt?_c:_r[_c];_i[_u]=replaceEqualDeep(_e[_u],_t[_u]),_i[_u]===_e[_u]&&_a++}return Wt===_n&&_a===Wt?_e:_i}return _t}function shallowEqualObjects(_e,_t){if(_e&&!_t||_t&&!_e)return!1;for(const Vt in _e)if(_e[Vt]!==_t[Vt])return!1;return!0}function isPlainArray(_e){return Array.isArray(_e)&&_e.length===Object.keys(_e).length}function isPlainObject(_e){if(!hasObjectPrototype(_e))return!1;const _t=_e.constructor;if(typeof _t>"u")return!0;const Vt=_t.prototype;return!(!hasObjectPrototype(Vt)||!Vt.hasOwnProperty("isPrototypeOf"))}function hasObjectPrototype(_e){return Object.prototype.toString.call(_e)==="[object Object]"}function isQueryKey(_e){return Array.isArray(_e)}function sleep(_e){return new Promise(_t=>{setTimeout(_t,_e)})}function scheduleMicrotask(_e){sleep(0).then(_e)}function getAbortController(){if(typeof AbortController=="function")return new AbortController}function replaceData(_e,_t,Vt){return Vt.isDataEqual!=null&&Vt.isDataEqual(_e,_t)?_e:typeof Vt.structuralSharing=="function"?Vt.structuralSharing(_e,_t):Vt.structuralSharing!==!1?replaceEqualDeep(_e,_t):_t}class FocusManager extends Subscribable{constructor(){super(),this.setup=_t=>{if(!isServer&&window.addEventListener){const Vt=()=>_t();return window.addEventListener("visibilitychange",Vt,!1),window.addEventListener("focus",Vt,!1),()=>{window.removeEventListener("visibilitychange",Vt),window.removeEventListener("focus",Vt)}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var _t;(_t=this.cleanup)==null||_t.call(this),this.cleanup=void 0}}setEventListener(_t){var Vt;this.setup=_t,(Vt=this.cleanup)==null||Vt.call(this),this.cleanup=_t(Wt=>{typeof Wt=="boolean"?this.setFocused(Wt):this.onFocus()})}setFocused(_t){this.focused!==_t&&(this.focused=_t,this.onFocus())}onFocus(){this.listeners.forEach(({listener:_t})=>{_t()})}isFocused(){return typeof this.focused=="boolean"?this.focused:typeof document>"u"?!0:[void 0,"visible","prerender"].includes(document.visibilityState)}}const focusManager=new FocusManager,onlineEvents=["online","offline"];class OnlineManager extends Subscribable{constructor(){super(),this.setup=_t=>{if(!isServer&&window.addEventListener){const Vt=()=>_t();return onlineEvents.forEach(Wt=>{window.addEventListener(Wt,Vt,!1)}),()=>{onlineEvents.forEach(Wt=>{window.removeEventListener(Wt,Vt)})}}}}onSubscribe(){this.cleanup||this.setEventListener(this.setup)}onUnsubscribe(){if(!this.hasListeners()){var _t;(_t=this.cleanup)==null||_t.call(this),this.cleanup=void 0}}setEventListener(_t){var Vt;this.setup=_t,(Vt=this.cleanup)==null||Vt.call(this),this.cleanup=_t(Wt=>{typeof Wt=="boolean"?this.setOnline(Wt):this.onOnline()})}setOnline(_t){this.online!==_t&&(this.online=_t,this.onOnline())}onOnline(){this.listeners.forEach(({listener:_t})=>{_t()})}isOnline(){return typeof this.online=="boolean"?this.online:typeof navigator>"u"||typeof navigator.onLine>"u"?!0:navigator.onLine}}const onlineManager=new OnlineManager;function defaultRetryDelay(_e){return Math.min(1e3*2**_e,3e4)}function canFetch(_e){return(_e??"online")==="online"?onlineManager.isOnline():!0}class CancelledError{constructor(_t){this.revert=_t==null?void 0:_t.revert,this.silent=_t==null?void 0:_t.silent}}function isCancelledError(_e){return _e instanceof CancelledError}function createRetryer(_e){let _t=!1,Vt=0,Wt=!1,_r,_n,_i;const _a=new Promise((c0,t0)=>{_n=c0,_i=t0}),_c=c0=>{Wt||(n0(new CancelledError(c0)),_e.abort==null||_e.abort())},_u=()=>{_t=!0},_d=()=>{_t=!1},_p=()=>!focusManager.isFocused()||_e.networkMode!=="always"&&!onlineManager.isOnline(),_f=c0=>{Wt||(Wt=!0,_e.onSuccess==null||_e.onSuccess(c0),_r==null||_r(),_n(c0))},n0=c0=>{Wt||(Wt=!0,_e.onError==null||_e.onError(c0),_r==null||_r(),_i(c0))},s0=()=>new Promise(c0=>{_r=t0=>{const e0=Wt||!_p();return e0&&c0(t0),e0},_e.onPause==null||_e.onPause()}).then(()=>{_r=void 0,Wt||_e.onContinue==null||_e.onContinue()}),o0=()=>{if(Wt)return;let c0;try{c0=_e.fn()}catch(t0){c0=Promise.reject(t0)}Promise.resolve(c0).then(_f).catch(t0=>{var e0,i0;if(Wt)return;const r0=(e0=_e.retry)!=null?e0:3,l0=(i0=_e.retryDelay)!=null?i0:defaultRetryDelay,d0=typeof l0=="function"?l0(Vt,t0):l0,f0=r0===!0||typeof r0=="number"&&Vt{if(_p())return s0()}).then(()=>{_t?n0(t0):o0()})})};return canFetch(_e.networkMode)?o0():s0().then(o0),{promise:_a,cancel:_c,continue:()=>(_r==null?void 0:_r())?_a:Promise.resolve(),cancelRetry:_u,continueRetry:_d}}const defaultLogger=console;function createNotifyManager(){let _e=[],_t=0,Vt=_d=>{_d()},Wt=_d=>{_d()};const _r=_d=>{let _p;_t++;try{_p=_d()}finally{_t--,_t||_a()}return _p},_n=_d=>{_t?_e.push(_d):scheduleMicrotask(()=>{Vt(_d)})},_i=_d=>(..._p)=>{_n(()=>{_d(..._p)})},_a=()=>{const _d=_e;_e=[],_d.length&&scheduleMicrotask(()=>{Wt(()=>{_d.forEach(_p=>{Vt(_p)})})})};return{batch:_r,batchCalls:_i,schedule:_n,setNotifyFunction:_d=>{Vt=_d},setBatchNotifyFunction:_d=>{Wt=_d}}}const notifyManager=createNotifyManager();class Removable{destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),isValidTimeout(this.cacheTime)&&(this.gcTimeout=setTimeout(()=>{this.optionalRemove()},this.cacheTime))}updateCacheTime(_t){this.cacheTime=Math.max(this.cacheTime||0,_t??(isServer?1/0:5*60*1e3))}clearGcTimeout(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)}}class Query extends Removable{constructor(_t){super(),this.abortSignalConsumed=!1,this.defaultOptions=_t.defaultOptions,this.setOptions(_t.options),this.observers=[],this.cache=_t.cache,this.logger=_t.logger||defaultLogger,this.queryKey=_t.queryKey,this.queryHash=_t.queryHash,this.initialState=_t.state||getDefaultState$1(this.options),this.state=this.initialState,this.scheduleGc()}get meta(){return this.options.meta}setOptions(_t){this.options={...this.defaultOptions,..._t},this.updateCacheTime(this.options.cacheTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.cache.remove(this)}setData(_t,Vt){const Wt=replaceData(this.state.data,_t,this.options);return this.dispatch({data:Wt,type:"success",dataUpdatedAt:Vt==null?void 0:Vt.updatedAt,manual:Vt==null?void 0:Vt.manual}),Wt}setState(_t,Vt){this.dispatch({type:"setState",state:_t,setStateOptions:Vt})}cancel(_t){var Vt;const Wt=this.promise;return(Vt=this.retryer)==null||Vt.cancel(_t),Wt?Wt.then(noop$3).catch(noop$3):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.initialState)}isActive(){return this.observers.some(_t=>_t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(_t=>_t.getCurrentResult().isStale)}isStaleByTime(_t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!timeUntilStale(this.state.dataUpdatedAt,_t)}onFocus(){var _t;const Vt=this.observers.find(Wt=>Wt.shouldFetchOnWindowFocus());Vt&&Vt.refetch({cancelRefetch:!1}),(_t=this.retryer)==null||_t.continue()}onOnline(){var _t;const Vt=this.observers.find(Wt=>Wt.shouldFetchOnReconnect());Vt&&Vt.refetch({cancelRefetch:!1}),(_t=this.retryer)==null||_t.continue()}addObserver(_t){this.observers.includes(_t)||(this.observers.push(_t),this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:_t}))}removeObserver(_t){this.observers.includes(_t)&&(this.observers=this.observers.filter(Vt=>Vt!==_t),this.observers.length||(this.retryer&&(this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.scheduleGc()),this.cache.notify({type:"observerRemoved",query:this,observer:_t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.dispatch({type:"invalidate"})}fetch(_t,Vt){var Wt,_r;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&Vt!=null&&Vt.cancelRefetch)this.cancel({silent:!0});else if(this.promise){var _n;return(_n=this.retryer)==null||_n.continueRetry(),this.promise}}if(_t&&this.setOptions(_t),!this.options.queryFn){const n0=this.observers.find(s0=>s0.options.queryFn);n0&&this.setOptions(n0.options)}Array.isArray(this.options.queryKey);const _i=getAbortController(),_a={queryKey:this.queryKey,pageParam:void 0,meta:this.meta},_c=n0=>{Object.defineProperty(n0,"signal",{enumerable:!0,get:()=>{if(_i)return this.abortSignalConsumed=!0,_i.signal}})};_c(_a);const _u=()=>this.options.queryFn?(this.abortSignalConsumed=!1,this.options.queryFn(_a)):Promise.reject("Missing queryFn for queryKey '"+this.options.queryHash+"'"),_d={fetchOptions:Vt,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:_u};if(_c(_d),(Wt=this.options.behavior)==null||Wt.onFetch(_d),this.revertState=this.state,this.state.fetchStatus==="idle"||this.state.fetchMeta!==((_r=_d.fetchOptions)==null?void 0:_r.meta)){var _p;this.dispatch({type:"fetch",meta:(_p=_d.fetchOptions)==null?void 0:_p.meta})}const _f=n0=>{if(isCancelledError(n0)&&n0.silent||this.dispatch({type:"error",error:n0}),!isCancelledError(n0)){var s0,o0,c0,t0;(s0=(o0=this.cache.config).onError)==null||s0.call(o0,n0,this),(c0=(t0=this.cache.config).onSettled)==null||c0.call(t0,this.state.data,n0,this)}this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return this.retryer=createRetryer({fn:_d.fetchFn,abort:_i==null?void 0:_i.abort.bind(_i),onSuccess:n0=>{var s0,o0,c0,t0;if(typeof n0>"u"){_f(new Error(this.queryHash+" data is undefined"));return}this.setData(n0),(s0=(o0=this.cache.config).onSuccess)==null||s0.call(o0,n0,this),(c0=(t0=this.cache.config).onSettled)==null||c0.call(t0,n0,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:_f,onFail:(n0,s0)=>{this.dispatch({type:"failed",failureCount:n0,error:s0})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:_d.options.retry,retryDelay:_d.options.retryDelay,networkMode:_d.options.networkMode}),this.promise=this.retryer.promise,this.promise}dispatch(_t){const Vt=Wt=>{var _r,_n;switch(_t.type){case"failed":return{...Wt,fetchFailureCount:_t.failureCount,fetchFailureReason:_t.error};case"pause":return{...Wt,fetchStatus:"paused"};case"continue":return{...Wt,fetchStatus:"fetching"};case"fetch":return{...Wt,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:(_r=_t.meta)!=null?_r:null,fetchStatus:canFetch(this.options.networkMode)?"fetching":"paused",...!Wt.dataUpdatedAt&&{error:null,status:"loading"}};case"success":return{...Wt,data:_t.data,dataUpdateCount:Wt.dataUpdateCount+1,dataUpdatedAt:(_n=_t.dataUpdatedAt)!=null?_n:Date.now(),error:null,isInvalidated:!1,status:"success",...!_t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const _i=_t.error;return isCancelledError(_i)&&_i.revert&&this.revertState?{...this.revertState}:{...Wt,error:_i,errorUpdateCount:Wt.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:Wt.fetchFailureCount+1,fetchFailureReason:_i,fetchStatus:"idle",status:"error"};case"invalidate":return{...Wt,isInvalidated:!0};case"setState":return{...Wt,..._t.state}}};this.state=Vt(this.state),notifyManager.batch(()=>{this.observers.forEach(Wt=>{Wt.onQueryUpdate(_t)}),this.cache.notify({query:this,type:"updated",action:_t})})}}function getDefaultState$1(_e){const _t=typeof _e.initialData=="function"?_e.initialData():_e.initialData,Vt=typeof _t<"u",Wt=Vt?typeof _e.initialDataUpdatedAt=="function"?_e.initialDataUpdatedAt():_e.initialDataUpdatedAt:0;return{data:_t,dataUpdateCount:0,dataUpdatedAt:Vt?Wt??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:Vt?"success":"loading",fetchStatus:"idle"}}class QueryCache extends Subscribable{constructor(_t){super(),this.config=_t||{},this.queries=[],this.queriesMap={}}build(_t,Vt,Wt){var _r;const _n=Vt.queryKey,_i=(_r=Vt.queryHash)!=null?_r:hashQueryKeyByOptions(_n,Vt);let _a=this.get(_i);return _a||(_a=new Query({cache:this,logger:_t.getLogger(),queryKey:_n,queryHash:_i,options:_t.defaultQueryOptions(Vt),state:Wt,defaultOptions:_t.getQueryDefaults(_n)}),this.add(_a)),_a}add(_t){this.queriesMap[_t.queryHash]||(this.queriesMap[_t.queryHash]=_t,this.queries.push(_t),this.notify({type:"added",query:_t}))}remove(_t){const Vt=this.queriesMap[_t.queryHash];Vt&&(_t.destroy(),this.queries=this.queries.filter(Wt=>Wt!==_t),Vt===_t&&delete this.queriesMap[_t.queryHash],this.notify({type:"removed",query:_t}))}clear(){notifyManager.batch(()=>{this.queries.forEach(_t=>{this.remove(_t)})})}get(_t){return this.queriesMap[_t]}getAll(){return this.queries}find(_t,Vt){const[Wt]=parseFilterArgs(_t,Vt);return typeof Wt.exact>"u"&&(Wt.exact=!0),this.queries.find(_r=>matchQuery(Wt,_r))}findAll(_t,Vt){const[Wt]=parseFilterArgs(_t,Vt);return Object.keys(Wt).length>0?this.queries.filter(_r=>matchQuery(Wt,_r)):this.queries}notify(_t){notifyManager.batch(()=>{this.listeners.forEach(({listener:Vt})=>{Vt(_t)})})}onFocus(){notifyManager.batch(()=>{this.queries.forEach(_t=>{_t.onFocus()})})}onOnline(){notifyManager.batch(()=>{this.queries.forEach(_t=>{_t.onOnline()})})}}class Mutation extends Removable{constructor(_t){super(),this.defaultOptions=_t.defaultOptions,this.mutationId=_t.mutationId,this.mutationCache=_t.mutationCache,this.logger=_t.logger||defaultLogger,this.observers=[],this.state=_t.state||getDefaultState(),this.setOptions(_t.options),this.scheduleGc()}setOptions(_t){this.options={...this.defaultOptions,..._t},this.updateCacheTime(this.options.cacheTime)}get meta(){return this.options.meta}setState(_t){this.dispatch({type:"setState",state:_t})}addObserver(_t){this.observers.includes(_t)||(this.observers.push(_t),this.clearGcTimeout(),this.mutationCache.notify({type:"observerAdded",mutation:this,observer:_t}))}removeObserver(_t){this.observers=this.observers.filter(Vt=>Vt!==_t),this.scheduleGc(),this.mutationCache.notify({type:"observerRemoved",mutation:this,observer:_t})}optionalRemove(){this.observers.length||(this.state.status==="loading"?this.scheduleGc():this.mutationCache.remove(this))}continue(){var _t,Vt;return(_t=(Vt=this.retryer)==null?void 0:Vt.continue())!=null?_t:this.execute()}async execute(){const _t=()=>{var f0;return this.retryer=createRetryer({fn:()=>this.options.mutationFn?this.options.mutationFn(this.state.variables):Promise.reject("No mutationFn found"),onFail:(p0,b0)=>{this.dispatch({type:"failed",failureCount:p0,error:b0})},onPause:()=>{this.dispatch({type:"pause"})},onContinue:()=>{this.dispatch({type:"continue"})},retry:(f0=this.options.retry)!=null?f0:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode}),this.retryer.promise},Vt=this.state.status==="loading";try{var Wt,_r,_n,_i,_a,_c,_u,_d;if(!Vt){var _p,_f,n0,s0;this.dispatch({type:"loading",variables:this.options.variables}),await((_p=(_f=this.mutationCache.config).onMutate)==null?void 0:_p.call(_f,this.state.variables,this));const p0=await((n0=(s0=this.options).onMutate)==null?void 0:n0.call(s0,this.state.variables));p0!==this.state.context&&this.dispatch({type:"loading",context:p0,variables:this.state.variables})}const f0=await _t();return await((Wt=(_r=this.mutationCache.config).onSuccess)==null?void 0:Wt.call(_r,f0,this.state.variables,this.state.context,this)),await((_n=(_i=this.options).onSuccess)==null?void 0:_n.call(_i,f0,this.state.variables,this.state.context)),await((_a=(_c=this.mutationCache.config).onSettled)==null?void 0:_a.call(_c,f0,null,this.state.variables,this.state.context,this)),await((_u=(_d=this.options).onSettled)==null?void 0:_u.call(_d,f0,null,this.state.variables,this.state.context)),this.dispatch({type:"success",data:f0}),f0}catch(f0){try{var o0,c0,t0,e0,i0,r0,l0,d0;throw await((o0=(c0=this.mutationCache.config).onError)==null?void 0:o0.call(c0,f0,this.state.variables,this.state.context,this)),await((t0=(e0=this.options).onError)==null?void 0:t0.call(e0,f0,this.state.variables,this.state.context)),await((i0=(r0=this.mutationCache.config).onSettled)==null?void 0:i0.call(r0,void 0,f0,this.state.variables,this.state.context,this)),await((l0=(d0=this.options).onSettled)==null?void 0:l0.call(d0,void 0,f0,this.state.variables,this.state.context)),f0}finally{this.dispatch({type:"error",error:f0})}}}dispatch(_t){const Vt=Wt=>{switch(_t.type){case"failed":return{...Wt,failureCount:_t.failureCount,failureReason:_t.error};case"pause":return{...Wt,isPaused:!0};case"continue":return{...Wt,isPaused:!1};case"loading":return{...Wt,context:_t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!canFetch(this.options.networkMode),status:"loading",variables:_t.variables};case"success":return{...Wt,data:_t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...Wt,data:void 0,error:_t.error,failureCount:Wt.failureCount+1,failureReason:_t.error,isPaused:!1,status:"error"};case"setState":return{...Wt,..._t.state}}};this.state=Vt(this.state),notifyManager.batch(()=>{this.observers.forEach(Wt=>{Wt.onMutationUpdate(_t)}),this.mutationCache.notify({mutation:this,type:"updated",action:_t})})}}function getDefaultState(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0}}class MutationCache extends Subscribable{constructor(_t){super(),this.config=_t||{},this.mutations=[],this.mutationId=0}build(_t,Vt,Wt){const _r=new Mutation({mutationCache:this,logger:_t.getLogger(),mutationId:++this.mutationId,options:_t.defaultMutationOptions(Vt),state:Wt,defaultOptions:Vt.mutationKey?_t.getMutationDefaults(Vt.mutationKey):void 0});return this.add(_r),_r}add(_t){this.mutations.push(_t),this.notify({type:"added",mutation:_t})}remove(_t){this.mutations=this.mutations.filter(Vt=>Vt!==_t),this.notify({type:"removed",mutation:_t})}clear(){notifyManager.batch(()=>{this.mutations.forEach(_t=>{this.remove(_t)})})}getAll(){return this.mutations}find(_t){return typeof _t.exact>"u"&&(_t.exact=!0),this.mutations.find(Vt=>matchMutation(_t,Vt))}findAll(_t){return this.mutations.filter(Vt=>matchMutation(_t,Vt))}notify(_t){notifyManager.batch(()=>{this.listeners.forEach(({listener:Vt})=>{Vt(_t)})})}resumePausedMutations(){var _t;return this.resuming=((_t=this.resuming)!=null?_t:Promise.resolve()).then(()=>{const Vt=this.mutations.filter(Wt=>Wt.state.isPaused);return notifyManager.batch(()=>Vt.reduce((Wt,_r)=>Wt.then(()=>_r.continue().catch(noop$3)),Promise.resolve()))}).then(()=>{this.resuming=void 0}),this.resuming}}function infiniteQueryBehavior(){return{onFetch:_e=>{_e.fetchFn=()=>{var _t,Vt,Wt,_r,_n,_i;const _a=(_t=_e.fetchOptions)==null||(Vt=_t.meta)==null?void 0:Vt.refetchPage,_c=(Wt=_e.fetchOptions)==null||(_r=Wt.meta)==null?void 0:_r.fetchMore,_u=_c==null?void 0:_c.pageParam,_d=(_c==null?void 0:_c.direction)==="forward",_p=(_c==null?void 0:_c.direction)==="backward",_f=((_n=_e.state.data)==null?void 0:_n.pages)||[],n0=((_i=_e.state.data)==null?void 0:_i.pageParams)||[];let s0=n0,o0=!1;const c0=d0=>{Object.defineProperty(d0,"signal",{enumerable:!0,get:()=>{var f0;if((f0=_e.signal)!=null&&f0.aborted)o0=!0;else{var p0;(p0=_e.signal)==null||p0.addEventListener("abort",()=>{o0=!0})}return _e.signal}})},t0=_e.options.queryFn||(()=>Promise.reject("Missing queryFn for queryKey '"+_e.options.queryHash+"'")),e0=(d0,f0,p0,b0)=>(s0=b0?[f0,...s0]:[...s0,f0],b0?[p0,...d0]:[...d0,p0]),i0=(d0,f0,p0,b0)=>{if(o0)return Promise.reject("Cancelled");if(typeof p0>"u"&&!f0&&d0.length)return Promise.resolve(d0);const g0={queryKey:_e.queryKey,pageParam:p0,meta:_e.options.meta};c0(g0);const y0=t0(g0);return Promise.resolve(y0).then(S0=>e0(d0,p0,S0,b0))};let r0;if(!_f.length)r0=i0([]);else if(_d){const d0=typeof _u<"u",f0=d0?_u:getNextPageParam(_e.options,_f);r0=i0(_f,d0,f0)}else if(_p){const d0=typeof _u<"u",f0=d0?_u:getPreviousPageParam(_e.options,_f);r0=i0(_f,d0,f0,!0)}else{s0=[];const d0=typeof _e.options.getNextPageParam>"u";r0=(_a&&_f[0]?_a(_f[0],0,_f):!0)?i0([],d0,n0[0]):Promise.resolve(e0([],n0[0],_f[0]));for(let p0=1;p0<_f.length;p0++)r0=r0.then(b0=>{if(_a&&_f[p0]?_a(_f[p0],p0,_f):!0){const y0=d0?n0[p0]:getNextPageParam(_e.options,b0);return i0(b0,d0,y0)}return Promise.resolve(e0(b0,n0[p0],_f[p0]))})}return r0.then(d0=>({pages:d0,pageParams:s0}))}}}}function getNextPageParam(_e,_t){return _e.getNextPageParam==null?void 0:_e.getNextPageParam(_t[_t.length-1],_t)}function getPreviousPageParam(_e,_t){return _e.getPreviousPageParam==null?void 0:_e.getPreviousPageParam(_t[0],_t)}class QueryClient{constructor(_t={}){this.queryCache=_t.queryCache||new QueryCache,this.mutationCache=_t.mutationCache||new MutationCache,this.logger=_t.logger||defaultLogger,this.defaultOptions=_t.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[],this.mountCount=0}mount(){this.mountCount++,this.mountCount===1&&(this.unsubscribeFocus=focusManager.subscribe(()=>{focusManager.isFocused()&&(this.resumePausedMutations(),this.queryCache.onFocus())}),this.unsubscribeOnline=onlineManager.subscribe(()=>{onlineManager.isOnline()&&(this.resumePausedMutations(),this.queryCache.onOnline())}))}unmount(){var _t,Vt;this.mountCount--,this.mountCount===0&&((_t=this.unsubscribeFocus)==null||_t.call(this),this.unsubscribeFocus=void 0,(Vt=this.unsubscribeOnline)==null||Vt.call(this),this.unsubscribeOnline=void 0)}isFetching(_t,Vt){const[Wt]=parseFilterArgs(_t,Vt);return Wt.fetchStatus="fetching",this.queryCache.findAll(Wt).length}isMutating(_t){return this.mutationCache.findAll({..._t,fetching:!0}).length}getQueryData(_t,Vt){var Wt;return(Wt=this.queryCache.find(_t,Vt))==null?void 0:Wt.state.data}ensureQueryData(_t,Vt,Wt){const _r=parseQueryArgs(_t,Vt,Wt),_n=this.getQueryData(_r.queryKey);return _n?Promise.resolve(_n):this.fetchQuery(_r)}getQueriesData(_t){return this.getQueryCache().findAll(_t).map(({queryKey:Vt,state:Wt})=>{const _r=Wt.data;return[Vt,_r]})}setQueryData(_t,Vt,Wt){const _r=this.queryCache.find(_t),_n=_r==null?void 0:_r.state.data,_i=functionalUpdate(Vt,_n);if(typeof _i>"u")return;const _a=parseQueryArgs(_t),_c=this.defaultQueryOptions(_a);return this.queryCache.build(this,_c).setData(_i,{...Wt,manual:!0})}setQueriesData(_t,Vt,Wt){return notifyManager.batch(()=>this.getQueryCache().findAll(_t).map(({queryKey:_r})=>[_r,this.setQueryData(_r,Vt,Wt)]))}getQueryState(_t,Vt){var Wt;return(Wt=this.queryCache.find(_t,Vt))==null?void 0:Wt.state}removeQueries(_t,Vt){const[Wt]=parseFilterArgs(_t,Vt),_r=this.queryCache;notifyManager.batch(()=>{_r.findAll(Wt).forEach(_n=>{_r.remove(_n)})})}resetQueries(_t,Vt,Wt){const[_r,_n]=parseFilterArgs(_t,Vt,Wt),_i=this.queryCache,_a={type:"active",..._r};return notifyManager.batch(()=>(_i.findAll(_r).forEach(_c=>{_c.reset()}),this.refetchQueries(_a,_n)))}cancelQueries(_t,Vt,Wt){const[_r,_n={}]=parseFilterArgs(_t,Vt,Wt);typeof _n.revert>"u"&&(_n.revert=!0);const _i=notifyManager.batch(()=>this.queryCache.findAll(_r).map(_a=>_a.cancel(_n)));return Promise.all(_i).then(noop$3).catch(noop$3)}invalidateQueries(_t,Vt,Wt){const[_r,_n]=parseFilterArgs(_t,Vt,Wt);return notifyManager.batch(()=>{var _i,_a;if(this.queryCache.findAll(_r).forEach(_u=>{_u.invalidate()}),_r.refetchType==="none")return Promise.resolve();const _c={..._r,type:(_i=(_a=_r.refetchType)!=null?_a:_r.type)!=null?_i:"active"};return this.refetchQueries(_c,_n)})}refetchQueries(_t,Vt,Wt){const[_r,_n]=parseFilterArgs(_t,Vt,Wt),_i=notifyManager.batch(()=>this.queryCache.findAll(_r).filter(_c=>!_c.isDisabled()).map(_c=>{var _u;return _c.fetch(void 0,{..._n,cancelRefetch:(_u=_n==null?void 0:_n.cancelRefetch)!=null?_u:!0,meta:{refetchPage:_r.refetchPage}})}));let _a=Promise.all(_i).then(noop$3);return _n!=null&&_n.throwOnError||(_a=_a.catch(noop$3)),_a}fetchQuery(_t,Vt,Wt){const _r=parseQueryArgs(_t,Vt,Wt),_n=this.defaultQueryOptions(_r);typeof _n.retry>"u"&&(_n.retry=!1);const _i=this.queryCache.build(this,_n);return _i.isStaleByTime(_n.staleTime)?_i.fetch(_n):Promise.resolve(_i.state.data)}prefetchQuery(_t,Vt,Wt){return this.fetchQuery(_t,Vt,Wt).then(noop$3).catch(noop$3)}fetchInfiniteQuery(_t,Vt,Wt){const _r=parseQueryArgs(_t,Vt,Wt);return _r.behavior=infiniteQueryBehavior(),this.fetchQuery(_r)}prefetchInfiniteQuery(_t,Vt,Wt){return this.fetchInfiniteQuery(_t,Vt,Wt).then(noop$3).catch(noop$3)}resumePausedMutations(){return this.mutationCache.resumePausedMutations()}getQueryCache(){return this.queryCache}getMutationCache(){return this.mutationCache}getLogger(){return this.logger}getDefaultOptions(){return this.defaultOptions}setDefaultOptions(_t){this.defaultOptions=_t}setQueryDefaults(_t,Vt){const Wt=this.queryDefaults.find(_r=>hashQueryKey(_t)===hashQueryKey(_r.queryKey));Wt?Wt.defaultOptions=Vt:this.queryDefaults.push({queryKey:_t,defaultOptions:Vt})}getQueryDefaults(_t){if(!_t)return;const Vt=this.queryDefaults.find(Wt=>partialMatchKey(_t,Wt.queryKey));return Vt==null?void 0:Vt.defaultOptions}setMutationDefaults(_t,Vt){const Wt=this.mutationDefaults.find(_r=>hashQueryKey(_t)===hashQueryKey(_r.mutationKey));Wt?Wt.defaultOptions=Vt:this.mutationDefaults.push({mutationKey:_t,defaultOptions:Vt})}getMutationDefaults(_t){if(!_t)return;const Vt=this.mutationDefaults.find(Wt=>partialMatchKey(_t,Wt.mutationKey));return Vt==null?void 0:Vt.defaultOptions}defaultQueryOptions(_t){if(_t!=null&&_t._defaulted)return _t;const Vt={...this.defaultOptions.queries,...this.getQueryDefaults(_t==null?void 0:_t.queryKey),..._t,_defaulted:!0};return!Vt.queryHash&&Vt.queryKey&&(Vt.queryHash=hashQueryKeyByOptions(Vt.queryKey,Vt)),typeof Vt.refetchOnReconnect>"u"&&(Vt.refetchOnReconnect=Vt.networkMode!=="always"),typeof Vt.useErrorBoundary>"u"&&(Vt.useErrorBoundary=!!Vt.suspense),Vt}defaultMutationOptions(_t){return _t!=null&&_t._defaulted?_t:{...this.defaultOptions.mutations,...this.getMutationDefaults(_t==null?void 0:_t.mutationKey),..._t,_defaulted:!0}}clear(){this.queryCache.clear(),this.mutationCache.clear()}}let MutationObserver$1=class extends Subscribable{constructor(_t,Vt){super(),this.client=_t,this.setOptions(Vt),this.bindMethods(),this.updateResult()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(_t){var Vt;const Wt=this.options;this.options=this.client.defaultMutationOptions(_t),shallowEqualObjects(Wt,this.options)||this.client.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.currentMutation,observer:this}),(Vt=this.currentMutation)==null||Vt.setOptions(this.options)}onUnsubscribe(){if(!this.hasListeners()){var _t;(_t=this.currentMutation)==null||_t.removeObserver(this)}}onMutationUpdate(_t){this.updateResult();const Vt={listeners:!0};_t.type==="success"?Vt.onSuccess=!0:_t.type==="error"&&(Vt.onError=!0),this.notify(Vt)}getCurrentResult(){return this.currentResult}reset(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})}mutate(_t,Vt){return this.mutateOptions=Vt,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,{...this.options,variables:typeof _t<"u"?_t:this.options.variables}),this.currentMutation.addObserver(this),this.currentMutation.execute()}updateResult(){const _t=this.currentMutation?this.currentMutation.state:getDefaultState(),Vt={..._t,isLoading:_t.status==="loading",isSuccess:_t.status==="success",isError:_t.status==="error",isIdle:_t.status==="idle",mutate:this.mutate,reset:this.reset};this.currentResult=Vt}notify(_t){notifyManager.batch(()=>{if(this.mutateOptions&&this.hasListeners()){if(_t.onSuccess){var Vt,Wt,_r,_n;(Vt=(Wt=this.mutateOptions).onSuccess)==null||Vt.call(Wt,this.currentResult.data,this.currentResult.variables,this.currentResult.context),(_r=(_n=this.mutateOptions).onSettled)==null||_r.call(_n,this.currentResult.data,null,this.currentResult.variables,this.currentResult.context)}else if(_t.onError){var _i,_a,_c,_u;(_i=(_a=this.mutateOptions).onError)==null||_i.call(_a,this.currentResult.error,this.currentResult.variables,this.currentResult.context),(_c=(_u=this.mutateOptions).onSettled)==null||_c.call(_u,void 0,this.currentResult.error,this.currentResult.variables,this.currentResult.context)}}_t.listeners&&this.listeners.forEach(({listener:_d})=>{_d(this.currentResult)})})}};const useSyncExternalStore=shimExports.useSyncExternalStore,defaultContext=reactExports.createContext(void 0),QueryClientSharingContext=reactExports.createContext(!1);function getQueryClientContext(_e,_t){return _e||(_t&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=defaultContext),window.ReactQueryClientContext):defaultContext)}const useQueryClient=({context:_e}={})=>{const _t=reactExports.useContext(getQueryClientContext(_e,reactExports.useContext(QueryClientSharingContext)));if(!_t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return _t},QueryClientProvider=({client:_e,children:_t,context:Vt,contextSharing:Wt=!1})=>{reactExports.useEffect(()=>(_e.mount(),()=>{_e.unmount()}),[_e]);const _r=getQueryClientContext(Vt,Wt);return reactExports.createElement(QueryClientSharingContext.Provider,{value:!Vt&&Wt},reactExports.createElement(_r.Provider,{value:_e},_t))};function shouldThrowError(_e,_t){return typeof _e=="function"?_e(..._t):!!_e}function useMutation(_e,_t,Vt){const Wt=parseMutationArgs(_e,_t,Vt),_r=useQueryClient({context:Wt.context}),[_n]=reactExports.useState(()=>new MutationObserver$1(_r,Wt));reactExports.useEffect(()=>{_n.setOptions(Wt)},[_n,Wt]);const _i=useSyncExternalStore(reactExports.useCallback(_c=>_n.subscribe(notifyManager.batchCalls(_c)),[_n]),()=>_n.getCurrentResult(),()=>_n.getCurrentResult()),_a=reactExports.useCallback((_c,_u)=>{_n.mutate(_c,_u).catch(noop$2)},[_n]);if(_i.error&&shouldThrowError(_n.options.useErrorBoundary,[_i.error]))throw _i.error;return{..._i,mutate:_a,mutateAsync:_i.mutate}}function noop$2(){}const usePostUploadMutation=()=>{const _e=useDispatch();return useMutation(async _t=>await uploadPost(_t),{onSuccess:_t=>{_e(setPost(_t))}})},PostDialogBox=({open:_e,handleOpen:_t,setIsLastPage:Vt,setPostCreated:Wt})=>{const _r=useSelector(S0=>S0.auth.user),[_n,_i]=reactExports.useState(!1),[_a,_c]=reactExports.useState(null),[_u,_d]=reactExports.useState(null),[_p,_f]=reactExports.useState(!1),[n0,s0]=reactExports.useState(null),[o0,c0]=reactExports.useState(new FormData),[t0,e0]=reactExports.useState([]),i0=useSelector(S0=>S0.post.image),r0=useDispatch(),l0=()=>_i(!_n),d0=()=>_f(!_p),f0=usePostUploadMutation(),p0=async(S0,x0)=>{if(S0.length>0)try{S0.forEach((O0,T0)=>{x0.append("files",O0,`image${T0}.jpg`)})}catch(O0){console.error("Upload error:",O0)}},b0=S0=>{e0(x0=>[...x0,{blob:S0,image:URL.createObjectURL(S0)}]),d0()},g0=S0=>{var x0;if((x0=S0.target.files)!=null&&x0.length&&S0.target.files[0]){const O0=S0.target.files[0];O0.type.startsWith("image/")?(s0(O0),_f(!0)):Q.warn("Only image files are allowed!",TOAST_ACTION)}},y0=async()=>{if(i0&&i0.length>0){const S0=t0.map(x0=>x0.blob);await p0(S0,o0)}if(_a&&o0.append("description",_a),_u&&o0.append("hashtags",_u),!_a&&!_u&&(!i0||i0.length===0))Q.dismiss(),Q.error("All the fields cannot be empty!",TOAST_ACTION);else try{const S0=f0.mutateAsync(o0);Q.promise(S0,{pending:"Uploading the post...",success:"Post uploaded successfully",error:"Upload failed!"},{...TOAST_ACTION,position:"bottom-left",closeButton:!1}),await(S0||f0.isSuccess)?(Vt(!1),Q.dismiss(),Wt((await S0).post)):Q.dismiss(),_t(),_d(null),_c(null),s0(null),r0(resetTempPostImage()),e0([])}catch{Q.dismiss(),Q.error("Upload failed!",{...TOAST_ACTION,position:"bottom-left"})}c0(new FormData)},_0=S0=>{r0(deleteTempPostImage(S0)),e0(x0=>x0.filter(O0=>O0.image!==S0))};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(react.Dialog,{open:_e,size:"md",handler:_t,dismiss:{enabled:!1},animate:{mount:{scale:1,y:0},unmount:{scale:.9,y:-100}},children:[jsxRuntimeExports.jsx(k,{}),jsxRuntimeExports.jsx(react.DialogHeader,{children:jsxRuntimeExports.jsxs("div",{className:"flex justify-between items-center w-full",children:[jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between gap-5 transition-transform duration-300 mx-1 px-2 pb-3 rounded-lg cursor-pointer hover:bg-gray-200 hover:scale-105",children:_r&&jsxRuntimeExports.jsx(Link,{to:`/profile/${_r._id}`,children:jsxRuntimeExports.jsxs("div",{className:"mt-3 flex items-center space-x-2",children:[jsxRuntimeExports.jsx("img",{className:"inline-block h-12 w-12 rounded-full",src:_r.dp?_r.dp:CONSTANTS_COMMON.DEFAULT_IMG,alt:"user dp"}),jsxRuntimeExports.jsxs("span",{className:"flex flex-col",children:[jsxRuntimeExports.jsx("span",{className:"text-[14px] font-bold text-gray-900",children:_r.name}),jsxRuntimeExports.jsx("span",{className:"text-[11px] font-bold text-green-500",children:"Post to Connections"})]})]})})}),jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx(AiOutlineCloseCircle,{className:"text-3xl cursor-pointer",onClick:_t})})]})}),jsxRuntimeExports.jsxs(react.DialogBody,{className:"flex flex-col gap-4 lg:mx-4 my-0 mx-2 px-4 py-0 md:px-4 md:py-4 max-h-[20.5rem] overflow-y-scroll",children:[jsxRuntimeExports.jsx("div",{className:"w-full mb-20 sm:mb-12",children:jsxRuntimeExports.jsx(ReactQuillComponent,{textValue:_a,setTextValue:_c})}),_n&&jsxRuntimeExports.jsx("div",{className:"w-full",children:jsxRuntimeExports.jsx(react.Input,{label:"Hashtags",value:_u||"",onChange:S0=>_d(S0.target.value)})}),i0&&i0.length>0&&jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3",children:[jsxRuntimeExports.jsx("div",{className:"border border-black/20 py-5 md:py-10 flex flex-col gap-2 md:gap-5",children:i0.map((S0,x0)=>jsxRuntimeExports.jsx("div",{className:"h-56 md:h-[19rem] w-full relative",style:{backgroundImage:`url(${S0})`,backgroundSize:"contain",backgroundRepeat:"no-repeat",backgroundPosition:"center"},children:jsxRuntimeExports.jsx("div",{className:"absolute flex gap-3 bottom-5 right-4 md:bottom-3 md:right-16",children:jsxRuntimeExports.jsx("div",{className:"flex justify-center items-center w-8 h-8 transition duration-300 ease-in-out bg-blue-gray-500 rounded-full cursor-pointer border-2 border-blue-gray-700 hover:border-red-700 hover:bg-white hover:border-3 group opacity-70 hover:opacity-100",children:jsxRuntimeExports.jsx(RiDeleteBin6Line,{className:"text-xl text-white group-hover:text-red-500",onClick:()=>_0(S0)})})})},x0))}),i0.length===5&&jsxRuntimeExports.jsx("em",{className:"text-sm font-light text-right pr-1",children:"* Max of 5 images are allowed!"})]})]}),jsxRuntimeExports.jsx(react.DialogFooter,{children:jsxRuntimeExports.jsxs("div",{className:"float-left mx-4 mb-4 flex justify-between items-center w-full",children:[jsxRuntimeExports.jsxs("div",{className:"flex justify-between items-center gap-3 mx-2",children:[jsxRuntimeExports.jsx("div",{className:classnames("flex justify-center items-center border-2 w-8 h-8 rounded-full cursor-pointer hover:border-socioverse-500 group",{"border-socioverse-500":_n},{"border-black":!_n}),onClick:l0,children:jsxRuntimeExports.jsx(HiHashtag,{className:classnames("text-2xl group-hover:text-socioverse-500",{"text-socioverse-500":_n},{"text-black":!_n})})}),jsxRuntimeExports.jsx("input",{type:"file",accept:"image/*",id:"image-input",className:"hidden",onChange:g0,disabled:(i0==null?void 0:i0.length)===5}),jsxRuntimeExports.jsx("label",{htmlFor:"image-input",className:"flex justify-center items-center text-black border-black border-2 w-8 h-8 rounded-full cursor-pointer hover:border-socioverse-500 group",children:jsxRuntimeExports.jsx(FiCamera,{className:"text-xl group-hover:text-socioverse-500"})})]}),jsxRuntimeExports.jsx(react.Button,{size:"sm",className:"rounded-full bg-socioverse-500",onClick:y0,children:"Post"})]})})]}),jsxRuntimeExports.jsxs(react.Dialog,{open:_p,size:"lg",handler:d0,animate:{mount:{scale:1,y:0},unmount:{scale:.9,y:-100}},children:[jsxRuntimeExports.jsx(react.DialogHeader,{children:jsxRuntimeExports.jsxs("div",{className:"flex justify-between items-center w-full",children:[jsxRuntimeExports.jsx("div",{className:"text-2xl",children:"Image"}),jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx(AiOutlineCloseCircle,{className:"text-3xl cursor-pointer",onClick:d0})})]})}),jsxRuntimeExports.jsx(react.DialogBody,{className:"lg:m-4 m-2",children:n0?jsxRuntimeExports.jsx("div",{className:"w-auto lg:h-[28rem] h-96 ",children:jsxRuntimeExports.jsx(ImageCropper,{image:URL.createObjectURL(n0),getImage:b0,aspectRatio:1.5/1})}):" "})]})]})},UsernameInputPopup=({handleUsernameInputPopup:_e,usernameInputPopupOpen:_t,setIsUsernameAvailable:Vt})=>{const Wt=create$3().shape({username:create$6().trim().matches(/^\S+$/,"Username cannot contain whitespace characters").min(3,"Username should be atleast 3 characters").required("Username is required")}),_r=useFormik({initialValues:{username:""},validationSchema:Wt,onSubmit:async _n=>{try{const _i=await addUsername(_n.username);_i.status==="success"?(Vt(!0),Q.success("Username added successfully",{...TOAST_ACTION,position:"bottom-left"}),Vt(!0),_e()):Q.error(_i.message,TOAST_ACTION)}catch(_i){if(isAxiosError(_i)){const _a=_i;if(_a.response&&_a.response.status>=400&&_a.response.status<=500){const _c=_a.response.data.message;Q.error(_c,TOAST_ACTION)}}}}});return jsxRuntimeExports.jsxs(react.Dialog,{open:_t,size:"md",handler:_e,dismiss:{enabled:!1},animate:{mount:{scale:1,y:0},unmount:{scale:.9,y:-100}},children:[jsxRuntimeExports.jsx(react.DialogHeader,{children:jsxRuntimeExports.jsxs("div",{className:"flex justify-between items-center w-full",children:[jsxRuntimeExports.jsx("div",{className:"text-2xl",children:"User Info"}),jsxRuntimeExports.jsx("div",{})]})}),jsxRuntimeExports.jsx(k,{}),jsxRuntimeExports.jsx(react.DialogBody,{className:"mx-4 mb-8",children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col",children:[jsxRuntimeExports.jsx("div",{className:"text-md mb-6 border-2 p-4 rounded-lg bg-green-50 border-green-500",children:"Enter your username to continue, it should be unique!"}),jsxRuntimeExports.jsxs("form",{onSubmit:_r.handleSubmit,className:"flex items-start gap-5 justify-center",children:[jsxRuntimeExports.jsx("div",{className:"w-[20rem]",children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntimeExports.jsx(react.Input,{type:"text",label:"Username",name:"username",value:_r.values.username,onChange:_r.handleChange,onBlur:_r.handleBlur}),_r.touched.username&&_r.errors.username&&jsxRuntimeExports.jsx("div",{className:"text-red-500 mt-[0.5rem] text-sm inline",children:_r.errors.username})]})}),jsxRuntimeExports.jsx(react.Button,{size:"lg",className:"bg-socioverse-500 hover:scale-105 text-white px-4 py-2 rounded-lg",disabled:!_r.values.username,type:"submit",children:"Continue"})]})]})})]})},HomeLarge=({user:_e,socket:_t})=>{const Vt=useDispatch(),[Wt,_r]=reactExports.useState([]),[_n,_i]=reactExports.useState(!1),[_a,_c]=reactExports.useState(1),[_u,_d]=reactExports.useState(!1),[_p,_f]=reactExports.useState(null),[n0,s0]=reactExports.useState(null),[o0,c0]=reactExports.useState(null),[t0,e0]=reactExports.useState(null),[i0,r0]=reactExports.useState(!1),[l0,d0]=reactExports.useState(!1),f0=useNavigate();reactExports.useEffect(()=>{_e&&r0(!!_e.username)},[_e]),reactExports.useEffect(()=>{_e&&d0(!i0)},[i0,_e]);const p0=()=>{d0(P0=>!P0)},b0=async()=>{const P0=await getPosts(_a);_r(P0.posts),_c(_a+1),_i(!1)};reactExports.useEffect(()=>{b0()},[]),reactExports.useEffect(()=>{const P0=document.getElementById("sentinel"),k0=new IntersectionObserver(async U0=>{if(U0[0].isIntersecting&&!_n&&!_u){_i(!0);const G0=await getPosts(_a);if(G0.posts.length===0){_d(!0),_i(!1);return}else _d(!1);_r([...Wt,...G0.posts]),_c(_a+1),_i(!1)}});return k0.observe(P0),()=>{k0.unobserve(P0)}},[_n,Wt,_a,_u]),reactExports.useEffect(()=>{_e||getUserInfo().then(P0=>{Vt(setCredentials({user:P0.user,accessToken:store.getState().auth.accessToken}))})},[Vt,_e]);const[g0,y0]=reactExports.useState(!1),_0=()=>y0(!g0),S0=()=>{y0(!0)},[x0,O0]=reactExports.useState(!1),[T0,M0]=reactExports.useState(!1),I0=P0=>{O0(P0)},C0=P0=>{M0(P0)};return _p&&(_r(Wt.filter(P0=>P0._id!==_p)),_f(null)),reactExports.useEffect(()=>{n0&&(_r(Wt.filter(P0=>P0._id!==n0)),s0(null))},[Wt,n0]),reactExports.useEffect(()=>{o0&&(_r([{...o0,newPostCreated:!0},...Wt]),c0(null))},[o0,Wt]),reactExports.useEffect(()=>{t0&&(_r(Wt.map(P0=>P0._id===t0._id?t0:P0)),e0(null))},[t0,Wt]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"lg:flex gap-3 items-start justify-between h-[80vh] lg:h-[85vh]",children:[jsxRuntimeExports.jsx("aside",{className:"hidden lg:block w-3/12 px-3 sticky top-28 overflow-y-auto h-[80vh] no-scrollbar",children:jsxRuntimeExports.jsx(AsideOne,{newFollowing:x0,handleFollowingAdd:I0,removeFollowing:T0,handleFollowingRemove:C0,socket:_t})}),jsxRuntimeExports.jsxs("main",{className:"w-full lg:w-6/12 px-3 md:px-6 overflow-x-hidden overflow-y-auto h-[85vh] no-scrollbar flex flex-col items-center p-2",children:[jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between w-full md:p-2 mb-8 gap-3 md:gap-5 sticky top-0 z-40",children:[jsxRuntimeExports.jsx(react.Avatar,{variant:"circular",alt:"user dp",className:"border h-12 w-12 md:h-14 md:w-14 border-gray-500 p-0.5 cursor-pointer",src:_e&&_e.dp?_e.dp:CONSTANTS_COMMON.DEFAULT_IMG,onClick:()=>f0(`/profile/${_e&&_e._id}`)}),jsxRuntimeExports.jsx("div",{className:"w-full",onClick:S0,children:jsxRuntimeExports.jsx(PostBox,{})})]}),jsxRuntimeExports.jsxs("div",{className:" overflow-y-auto h-[85vh] w-full no-scrollbar flex flex-col items-center",children:[jsxRuntimeExports.jsxs("div",{className:"mb-10 max-w-[30rem] w-full",children:[Wt.map((P0,k0)=>jsxRuntimeExports.jsx("div",{className:"mb-10 w-full",children:jsxRuntimeExports.jsx(PostCard,{postData:P0,setDeletedPostId:_f,setReportedPostId:s0,setPostEdited:e0})},k0)),jsxRuntimeExports.jsx(PostDialogBox,{open:g0,handleOpen:_0,setIsLastPage:_d,setPostCreated:c0})]}),_u&&jsxRuntimeExports.jsx("div",{children:" No posts..."}),jsxRuntimeExports.jsx("div",{id:"sentinel",style:{height:"1px"},className:"mt-10",children:!_u&&jsxRuntimeExports.jsx("img",{src:loader$1,className:"w-20 h-20"})})]})]}),jsxRuntimeExports.jsx("aside",{className:"hidden lg:block w-3/12 px-3 pb-5 sticky top-28 overflow-hidden",children:jsxRuntimeExports.jsx(AsideTwo,{handleFollowingAdd:I0,handleFollowingRemove:C0})})]}),jsxRuntimeExports.jsx(UsernameInputPopup,{handleUsernameInputPopup:p0,usernameInputPopupOpen:l0,setIsUsernameAvailable:r0})]})},Home=({user:_e,socket:_t})=>jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(HomeLarge,{user:_e,socket:_t})}),HomePage=({socket:_e})=>{const _t=useSelector(_n=>_n.auth),Vt=useNavigate(),Wt=useDispatch();reactExports.useEffect(()=>{_t.isAuthenticated||_r()||Vt("/error")},[_t]);const _r=async()=>{try{const{user:_n}=await getUserInfo(),{accessToken:_i}=store.getState().auth;return Wt(setCredentials({user:_n,accessToken:_i})),_n}catch(_n){if(isAxiosError(_n)){const _i=_n;_i.response&&_i.response.status>=400&&_i.response.status<=500&&Vt("/login")}}};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Home,{user:_t.user,socket:_e})})},getSender=(_e,_t)=>_t[0]._id===_e?_t[1]:_t[0],groupByDate=_e=>_e.reduce((_t,Vt)=>{const Wt=hooks(Vt.createdAt).format("LL");return _t[Wt]||(_t[Wt]=[]),_t[Wt].push(Vt),_t},{}),truncate=(_e,_t)=>{if(!(!_e||typeof _e!="string"))return _e.length<=_t?_e:_e.slice(0,_t)+"..."};function FaArrowLeft(_e){return GenIcon({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M257.5 445.1l-22.2 22.2c-9.4 9.4-24.6 9.4-33.9 0L7 273c-9.4-9.4-9.4-24.6 0-33.9L201.4 44.7c9.4-9.4 24.6-9.4 33.9 0l22.2 22.2c9.5 9.5 9.3 25-.4 34.3L136.6 216H424c13.3 0 24 10.7 24 24v32c0 13.3-10.7 24-24 24H136.6l120.5 114.8c9.8 9.3 10 24.8.4 34.3z"}}]})(_e)}function FaPowerOff(_e){return GenIcon({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M400 54.1c63 45 104 118.6 104 201.9 0 136.8-110.8 247.7-247.5 248C120 504.3 8.2 393 8 256.4 7.9 173.1 48.9 99.3 111.8 54.2c11.7-8.3 28-4.8 35 7.7L162.6 90c5.9 10.5 3.1 23.8-6.6 31-41.5 30.8-68 79.6-68 134.9-.1 92.3 74.5 168.1 168 168.1 91.6 0 168.6-74.2 168-169.1-.3-51.8-24.7-101.8-68.1-134-9.7-7.2-12.4-20.5-6.5-30.9l15.8-28.1c7-12.4 23.2-16.1 34.8-7.8zM296 264V24c0-13.3-10.7-24-24-24h-32c-13.3 0-24 10.7-24 24v240c0 13.3 10.7 24 24 24h32c13.3 0 24-10.7 24-24z"}}]})(_e)}const UserCard=({user:_e})=>jsxRuntimeExports.jsx("div",{className:`flex w-full px-4 py-2 mb-5 items-center justify-between transition duration-100 ease-in-out rounded-lg shadow-md hover:scale-95 hover:rounded-lg cursor-pointer bg-[#E8E8E8] hover:bg-blue-gray-600 group`,children:jsxRuntimeExports.jsxs("div",{className:"s) => setLimt-3 flex items-center space-x-2",children:[jsxRuntimeExports.jsx("img",{className:"inline-block h-12 w-12 rounded-full",src:_e.dp?_e.dp:CONSTANTS_COMMON.DEFAULT_IMG,alt:"user dp"}),jsxRuntimeExports.jsxs("span",{className:"flex flex-col",children:[jsxRuntimeExports.jsx("span",{className:"text-[14px] font-medium text-gray-900 group-hover:text-white group-hover:font-bold",children:_e.name}),jsxRuntimeExports.jsxs("span",{className:"text-[11px] font-medium text-gray-500 group-hover:text-white group-hover:font-bold",children:["@",_e.username]})]})]})}),ChatLoading=()=>jsxRuntimeExports.jsx("div",{className:"border border-blue-300 shadow rounded-lg p-3 w-full mx-auto",children:jsxRuntimeExports.jsxs("div",{className:"animate-pulse flex space-x-4",children:[jsxRuntimeExports.jsx("div",{className:"rounded-full bg-blue-gray-700 h-10 w-10"}),jsxRuntimeExports.jsx("div",{className:"flex-1 space-y-6 py-1",children:jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[jsxRuntimeExports.jsx("div",{className:"h-2 bg-blue-gray-700 rounded"}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[jsxRuntimeExports.jsx("div",{className:"h-2 bg-blue-gray-700 rounded col-span-2"}),jsxRuntimeExports.jsx("div",{className:"h-2 bg-blue-gray-700 rounded col-span-1"})]})]})})]})}),AdminGroupEdit=({updateGroup:_e,setUpdateGroup:_t,handleOpenOptions:Vt,setDisableUpdate:Wt,socket:_r})=>{const _n=useSelector(_0=>_0.chat.selectedChat),_i=useSelector(_0=>{var S0;return(S0=_0.auth.user)==null?void 0:S0._id}),[_a,_c]=reactExports.useState((_n==null?void 0:_n.chatName)??""),[_u,_d]=reactExports.useState(""),[_p,_f]=reactExports.useState((_n==null?void 0:_n.users)??[]),[n0,s0]=reactExports.useState(),[o0,c0]=reactExports.useState([]),[t0,e0]=reactExports.useState(!1),[i0,r0]=reactExports.useState(new FormData),[l0,d0]=reactExports.useState(new FormData),f0=useDispatch();reactExports.useEffect(()=>{(_n==null?void 0:_n.chatName)===_a&&(_n==null?void 0:_n.users)===_p?Wt(!0):Wt(!1),n0&&Wt(!1)},[_a,_p,n0]),reactExports.useEffect(()=>{let _0;const S0=async()=>{try{e0(!0);const x0=await searchUsers(_u);e0(!1),c0(x0.users)}catch{Q.dismiss(),Q.error("Failed to load search results",TOAST_ACTION)}};return _u.length>0&&(_0=setTimeout(S0,500)),()=>{clearTimeout(_0)}},[_u]),reactExports.useEffect(()=>{_e&&p0()},[_t,_e]);const p0=async()=>{if(_a.trim().length===0&&_p.length===0){Q.dismiss(),Q.error("Group name and members cannot be empty",TOAST_ACTION);return}if(_a!==(_n==null?void 0:_n.chatName)&&i0.append("chatName",_a),_p!==(_n==null?void 0:_n.users)){const _0=_p.map(S0=>S0._id);i0.append("users",JSON.stringify(_0))}n0&&l0.append("groupDp",n0);try{let _0;Q.info("Updating group...",{...TOAST_ACTION,autoClose:!1}),(_a!==(_n==null?void 0:_n.chatName)||_p!==(_n==null?void 0:_n.users))&&(_0=_n&&await updateGroupChat(_n==null?void 0:_n._id,i0)),n0&&(_0=_n&&await addGroupDp(_n._id,l0)),_0&&f0(setSelectedChat(_0.groupChat)),f0(setFetchUserChatsAgain(!0)),_0&&_r.emit("group updation",_0.groupChat),Q.dismiss(),_t(!1),Q.success("Group updated successfully",TOAST_ACTION),d0(new FormData),r0(new FormData),Vt()}catch{Q.dismiss(),Q.error("Failed to update group",TOAST_ACTION)}},b0=_0=>{_f(_p.filter(S0=>S0!==_0))},g0=_0=>{if(_p.some(S0=>S0._id===_0._id)){Q.dismiss(),Q.warn("User already added",TOAST_ACTION);return}else _f([..._p,_0])},y0=_0=>{_0.target.files&&_0.target.files.length>0&&s0(_0.target.files[0])};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(react.Typography,{className:"-mb-2",variant:"h6",children:"Add Image"}),jsxRuntimeExports.jsxs("div",{className:"mx-auto",children:[jsxRuntimeExports.jsx("input",{type:"file",accept:"image/*",id:"newGroup-image",className:"hidden",onChange:y0}),jsxRuntimeExports.jsx("label",{htmlFor:"newGroup-image",children:jsxRuntimeExports.jsx("img",{src:n0 instanceof File?URL.createObjectURL(n0):_n==null?void 0:_n.groupDp,className:"h-36 w-36 rounded-full border-4 border-gray-500 border-dashed bg-white m-2 flex items-center justify-center cursor-pointer p-2"})})]}),jsxRuntimeExports.jsx(react.Typography,{className:"-mb-2",variant:"h6",children:"Group Name"}),jsxRuntimeExports.jsx(react.Input,{label:"Enter the name",size:"lg",value:_a,onChange:_0=>_c(_0.target.value)}),jsxRuntimeExports.jsx(react.Typography,{className:"-mb-2",variant:"h6",children:"Add Members"}),jsxRuntimeExports.jsx(react.Input,{label:"Enter the members",size:"lg",onChange:_0=>_d(_0.target.value)}),jsxRuntimeExports.jsx("div",{className:"max-h-36 overflow-y-scroll flex items-center justify-center flex-wrap gap-2 no-scrollbar",children:_p.map(_0=>_0._id!==_i&&jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx(react.Chip,{variant:"ghost",animate:{mount:{y:0},unmount:{y:50}},value:_0.name,onClose:()=>b0(_0),className:"rounded-full",color:"green"})},`selected-${_0._id}`))}),t0?jsxRuntimeExports.jsx("div",{className:"overflow-y-hidden flex flex-col gap-4",children:Array(3).fill(0).map((_0,S0)=>jsxRuntimeExports.jsx(ChatLoading,{},S0))}):jsxRuntimeExports.jsx("div",{className:"max-h-64 overflow-y-scroll overflow-x-hidden no-scrollbar mx-4",children:o0==null?void 0:o0.slice(0,4).map(_0=>_0._id!==_i&&jsxRuntimeExports.jsx("div",{className:"w-full",onClick:()=>g0(_0),children:jsxRuntimeExports.jsx(UserCard,{user:_0})},`search-${_0._id}`))})]})},OptionsDialog=({openOptions:_e,handleOpenOptions:_t,socket:Vt})=>{const Wt=useSelector(o0=>o0.chat.selectedChat),_r=useSelector(o0=>{var c0;return(c0=o0.auth.user)==null?void 0:c0._id}),_n=useSelector(o0=>o0.chat.chats),[_i,_a]=reactExports.useState(!1),[_c,_u]=reactExports.useState(!1),_d=useDispatch(),_p=async()=>{Q.dismiss(),Q(jsxRuntimeExports.jsx(ConfirmDeleteToast,{onDelete:_f,message:"Are you sure you want to leave this Group?"}),{...TOAST_ACTION,closeButton:!1})},_f=async()=>{const o0=Wt&&_r&&await removeFromGroup(Wt==null?void 0:Wt._id,_r);o0&&(o0==null?void 0:o0.status)==="success"&&(Q.dismiss(),_d(setSelectedChat("")),_d(setChats(_n.filter(c0=>c0._id!==(Wt==null?void 0:Wt._id)))),Q.success("Successfully left the group"),_t())},n0=async()=>{Q.dismiss(),Q(jsxRuntimeExports.jsx(ConfirmDeleteToast,{onDelete:s0,message:"Are you sure you want to delete this group?"}),{...TOAST_ACTION,closeButton:!1})},s0=async()=>{const o0=Wt&&await groupRemove(Wt==null?void 0:Wt._id);o0&&(o0==null?void 0:o0.status)==="success"&&(Q.dismiss(),_d(setSelectedChat("")),_d(setChats(_n.filter(c0=>c0._id!==(Wt==null?void 0:Wt._id)))),Q.success("Successfully deleted the group"),_t())};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs(react.Dialog,{size:"xs",dismiss:{enabled:!1},open:_e,handler:_t,className:"bg-transparent shadow-none",children:[jsxRuntimeExports.jsx(k,{}),jsxRuntimeExports.jsxs(react.Card,{className:"mx-auto w-full ",children:[jsxRuntimeExports.jsxs(react.CardBody,{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntimeExports.jsx("h1",{className:"text-2xl font-medium text-black",children:Wt!=null&&Wt.isGroupChat?Wt.chatName:"User Info"}),jsxRuntimeExports.jsx(AiOutlineCloseCircle,{className:"text-3xl cursor-pointer text-black",onClick:o0=>{o0.stopPropagation(),_t()}})]}),Wt&&!Wt.isGroupChat?jsxRuntimeExports.jsxs("div",{className:"relative h-60 md:h-80 w-60 md:w-80 rounded-md mx-auto overflow-hidden",children:[jsxRuntimeExports.jsx("img",{src:_r&&getSender(_r,Wt.users).dp?getSender(_r,Wt.users).dp:CONSTANTS_COMMON.DEFAULT_IMG,alt:"user dp",className:"z-0 h-full w-full rounded-md object-cover"}),jsxRuntimeExports.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-gray-900 to-transparent"}),jsxRuntimeExports.jsxs("div",{className:"absolute bottom-4 left-4 text-left",children:[jsxRuntimeExports.jsx("h1",{className:"text-lg font-semibold text-white",children:_r&&getSender(_r,Wt.users).name}),jsxRuntimeExports.jsxs("h1",{className:"text-xs font-light text-white",children:["@",_r&&getSender(_r,Wt.users).username]}),jsxRuntimeExports.jsx(Link,{to:`/profile/${_r&&getSender(_r,Wt.users)._id}`,children:jsxRuntimeExports.jsx("button",{className:"mt-2 inline-flex cursor-pointer items-center text-sm font-semibold text-white",children:"View Profile →"})})]})]}):(Wt==null?void 0:Wt.groupAdmin._id)===_r?jsxRuntimeExports.jsx(AdminGroupEdit,{updateGroup:_i,setUpdateGroup:_a,handleOpenOptions:_t,setDisableUpdate:_u,socket:Vt}):jsxRuntimeExports.jsxs("div",{className:"max-h-96 overflow-y-scroll overflow-x-hidden no-scrollbar mx-4",children:[jsxRuntimeExports.jsx("img",{src:Wt==null?void 0:Wt.groupDp,className:"h-48 w-48 rounded-full border-4 border-gray-500 border-dashed bg-white mx-auto flex items-center justify-center p-2"}),jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center mb-2",children:[jsxRuntimeExports.jsx("h1",{className:"text-lg font-medium",children:"Admin"}),jsxRuntimeExports.jsx("span",{className:`inline-flex items-center justify-center px-2 py-1 mr-2 text-xs font-bold leading-none text-white bg-socioverse-400 rounded-full`,children:Wt&&(Wt==null?void 0:Wt.users.filter(o0=>o0._id===Wt.groupAdmin._id).length)})]}),Wt==null?void 0:Wt.users.map(o0=>o0._id===Wt.groupAdmin._id&&jsxRuntimeExports.jsx(UserCard,{user:o0},o0._id)),jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center mb-2",children:[jsxRuntimeExports.jsx("h1",{className:"text-lg font-medium",children:"Members"}),jsxRuntimeExports.jsx("span",{className:`inline-flex items-center justify-center px-2 py-1 mr-2 text-xs diff --git a/client/dist/index.html b/client/dist/index.html index fd03b94..8afe35a 100644 --- a/client/dist/index.html +++ b/client/dist/index.html @@ -11,7 +11,7 @@ /> Socioverse - +