Files
school2/public/assets/ImageUploader-CHryWmjJ.js
2026-07-13 15:23:29 +08:00

81 lines
32 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{Er as e,It as t,Or as n,Tr as r,n as i,t as a}from"./jsx-runtime-NwRKtVrk.js";import{t as o}from"./button-CM-rzMOH.js";import{t as s}from"./upload-CV7KMHYr.js";import{b as c,k as l,s as u,y as d}from"./index-B7MUL4ct.js";import{a as f,n as p,r as m,t as h}from"./tslib.es6-5i5FW2KX.js";var g=e(((e,t)=>{var n=!1,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;function v(){if(!n){n=!0;var e=navigator.userAgent,t=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(e),v=/(Mac OS X)|(Windows)|(Linux)/.exec(e);if(m=/\b(iPhone|iP[ao]d)/.exec(e),h=/\b(iP[ao]d)/.exec(e),f=/Android/i.exec(e),g=/FBAN\/\w+;/i.exec(e),_=/Mobile/i.exec(e),p=!!/Win64/.exec(e),t){r=t[1]?parseFloat(t[1]):t[5]?parseFloat(t[5]):NaN,r&&document&&document.documentMode&&(r=document.documentMode);var y=/(?:Trident\/(\d+.\d+))/.exec(e);c=y?parseFloat(y[1])+4:r,i=t[2]?parseFloat(t[2]):NaN,a=t[3]?parseFloat(t[3]):NaN,o=t[4]?parseFloat(t[4]):NaN,o?(t=/(?:Chrome\/(\d+\.\d+))/.exec(e),s=t&&t[1]?parseFloat(t[1]):NaN):s=NaN}else r=i=a=s=o=NaN;if(v){if(v[1]){var b=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(e);l=b?parseFloat(b[1].replace(`_`,`.`)):!0}else l=!1;u=!!v[2],d=!!v[3]}else l=u=d=!1}}var y={ie:function(){return v()||r},ieCompatibilityMode:function(){return v()||c>r},ie64:function(){return y.ie()&&p},firefox:function(){return v()||i},opera:function(){return v()||a},webkit:function(){return v()||o},safari:function(){return y.webkit()},chrome:function(){return v()||s},windows:function(){return v()||u},osx:function(){return v()||l},linux:function(){return v()||d},iphone:function(){return v()||m},mobile:function(){return v()||m||h||f||_},nativeApp:function(){return v()||g},android:function(){return v()||f},ipad:function(){return v()||h}};t.exports=y})),_=e(((e,t)=>{var n=!!(typeof window<`u`&&window.document&&window.document.createElement);t.exports={canUseDOM:n,canUseWorkers:typeof Worker<`u`,canUseEventListeners:n&&!!(window.addEventListener||window.attachEvent),canUseViewport:n&&!!window.screen,isInWorker:!n}})),v=e(((e,t)=>{var n=_(),r;n.canUseDOM&&(r=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature(``,``)!==!0);function i(e,t){if(!n.canUseDOM||t&&!(`addEventListener`in document))return!1;var i=`on`+e,a=i in document;if(!a){var o=document.createElement(`div`);o.setAttribute(i,`return;`),a=typeof o[i]==`function`}return!a&&r&&e===`wheel`&&(a=document.implementation.hasFeature(`Events.wheel`,`3.0`)),a}t.exports=i})),y=e(((e,t)=>{var n=g(),r=v(),i=10,a=40,o=800;function s(e){var t=0,n=0,r=0,s=0;return`detail`in e&&(n=e.detail),`wheelDelta`in e&&(n=-e.wheelDelta/120),`wheelDeltaY`in e&&(n=-e.wheelDeltaY/120),`wheelDeltaX`in e&&(t=-e.wheelDeltaX/120),`axis`in e&&e.axis===e.HORIZONTAL_AXIS&&(t=n,n=0),r=t*i,s=n*i,`deltaY`in e&&(s=e.deltaY),`deltaX`in e&&(r=e.deltaX),(r||s)&&e.deltaMode&&(e.deltaMode==1?(r*=a,s*=a):(r*=o,s*=o)),r&&!t&&(t=r<1?-1:1),s&&!n&&(n=s<1?-1:1),{spinX:t,spinY:n,pixelX:r,pixelY:s}}s.getEventType=function(){return n.firefox()?`DOMMouseScroll`:r(`wheel`)?`wheel`:`mousewheel`},t.exports=s})),b=e(((e,t)=>{t.exports=y()})),x=a(),S=n(r(),1),C=n(b(),1);function w(e,t,n,r,i,a){a===void 0&&(a=0);var o=R(e,t,a),s=o.width,c=o.height,l=Math.min(s,n),u=Math.min(c,r);return l>u*i?{width:u*i,height:u}:{width:l,height:l/i}}function T(e){return e.width>e.height?e.width/e.naturalWidth:e.height/e.naturalHeight}function E(e,t,n,r,i){i===void 0&&(i=0);var a=R(t.width,t.height,i),o=a.width,s=a.height;return{x:D(e.x,o,n.width,r),y:D(e.y,s,n.height,r)}}function D(e,t,n,r){var i=Math.abs(t*r/2-n/2);return z(e,-i,i)}function O(e,t){return Math.sqrt((e.y-t.y)**2+(e.x-t.x)**2)}function k(e,t){return Math.atan2(t.y-e.y,t.x-e.x)*180/Math.PI}function A(e,t,n,r,i,a,o){a===void 0&&(a=0),o===void 0&&(o=!0);var s=o?j:M,c=R(t.width,t.height,a),l=R(t.naturalWidth,t.naturalHeight,a),u={x:s(100,((c.width-n.width/i)/2-e.x/i)/c.width*100),y:s(100,((c.height-n.height/i)/2-e.y/i)/c.height*100),width:s(100,n.width/c.width*100/i),height:s(100,n.height/c.height*100/i)},d=Math.round(s(l.width,u.width*l.width/100)),f=Math.round(s(l.height,u.height*l.height/100)),p=l.width>=l.height*r?{width:Math.round(f*r),height:f}:{width:d,height:Math.round(d/r)};return{croppedAreaPercentages:u,croppedAreaPixels:h(h({},p),{x:Math.round(s(l.width-p.width,u.x*l.width/100)),y:Math.round(s(l.height-p.height,u.y*l.height/100))})}}function j(e,t){return Math.min(e,Math.max(0,t))}function M(e,t){return t}function N(e,t,n,r,i,a){var o=R(t.width,t.height,n),s=z(r.width/o.width*(100/e.width),i,a);return{crop:{x:s*o.width/2-r.width/2-o.width*s*(e.x/100),y:s*o.height/2-r.height/2-o.height*s*(e.y/100)},zoom:s}}function P(e,t,n){var r=T(t);return n.height>n.width?n.height/(e.height*r):n.width/(e.width*r)}function F(e,t,n,r,i,a){n===void 0&&(n=0);var o=R(t.naturalWidth,t.naturalHeight,n),s=z(P(e,t,r),i,a),c=r.height>r.width?r.height/e.height:r.width/e.width;return{crop:{x:((o.width-e.width)/2-e.x)*c,y:((o.height-e.height)/2-e.y)*c},zoom:s}}function I(e,t){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function L(e){return e*Math.PI/180}function R(e,t,n){var r=L(n);return{width:Math.abs(Math.cos(r)*e)+Math.abs(Math.sin(r)*t),height:Math.abs(Math.sin(r)*e)+Math.abs(Math.cos(r)*t)}}function z(e,t,n){return Math.min(Math.max(e,t),n)}function B(){return[...arguments].filter(function(e){return typeof e==`string`&&e.length>0}).join(` `).trim()}var V=`.reactEasyCrop_Container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
user-select: none;
touch-action: none;
cursor: move;
display: flex;
justify-content: center;
align-items: center;
}
.reactEasyCrop_Image,
.reactEasyCrop_Video {
will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */
}
.reactEasyCrop_Contain {
max-width: 100%;
max-height: 100%;
margin: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.reactEasyCrop_Cover_Horizontal {
width: 100%;
height: auto;
}
.reactEasyCrop_Cover_Vertical {
width: auto;
height: 100%;
}
.reactEasyCrop_CropArea {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border: 1px solid rgba(255, 255, 255, 0.5);
box-sizing: border-box;
box-shadow: 0 0 0 9999em;
color: rgba(0, 0, 0, 0.5);
overflow: hidden;
}
.reactEasyCrop_CropAreaRound {
border-radius: 50%;
}
.reactEasyCrop_CropAreaGrid::before {
content: ' ';
box-sizing: border-box;
position: absolute;
border: 1px solid rgba(255, 255, 255, 0.5);
top: 0;
bottom: 0;
left: 33.33%;
right: 33.33%;
border-top: 0;
border-bottom: 0;
}
.reactEasyCrop_CropAreaGrid::after {
content: ' ';
box-sizing: border-box;
position: absolute;
border: 1px solid rgba(255, 255, 255, 0.5);
top: 33.33%;
bottom: 33.33%;
left: 0;
right: 0;
border-left: 0;
border-right: 0;
}
`,H=1,U=3,W=1,G=function(e){m(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.cropperRef=S.createRef(),n.imageRef=S.createRef(),n.videoRef=S.createRef(),n.containerPosition={x:0,y:0},n.containerRef=null,n.styleRef=null,n.containerRect=null,n.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},n.dragStartPosition={x:0,y:0},n.dragStartCrop={x:0,y:0},n.gestureZoomStart=0,n.gestureRotationStart=0,n.isTouching=!1,n.lastPinchDistance=0,n.lastPinchRotation=0,n.rafDragTimeout=null,n.rafPinchTimeout=null,n.wheelTimer=null,n.currentDoc=typeof document<`u`?document:null,n.currentWindow=typeof window<`u`?window:null,n.resizeObserver=null,n.previousCropSize=null,n.isInitialized=!1,n.state={cropSize:null,hasWheelJustStarted:!1,mediaObjectFit:void 0},n.initResizeObserver=function(){if(!(window.ResizeObserver===void 0||!n.containerRef)){var e=!0;n.resizeObserver=new window.ResizeObserver(function(t){if(e){e=!1;return}n.computeSizes()}),n.resizeObserver.observe(n.containerRef)}},n.preventZoomSafari=function(e){return e.preventDefault()},n.cleanEvents=function(){n.currentDoc&&(n.currentDoc.removeEventListener(`mousemove`,n.onMouseMove),n.currentDoc.removeEventListener(`mouseup`,n.onDragStopped),n.currentDoc.removeEventListener(`touchmove`,n.onTouchMove),n.currentDoc.removeEventListener(`touchend`,n.onDragStopped),n.currentDoc.removeEventListener(`gesturechange`,n.onGestureChange),n.currentDoc.removeEventListener(`gestureend`,n.onGestureEnd),n.currentDoc.removeEventListener(`scroll`,n.onScroll))},n.clearScrollEvent=function(){n.containerRef&&n.containerRef.removeEventListener(`wheel`,n.onWheel),n.wheelTimer&&clearTimeout(n.wheelTimer)},n.onMediaLoad=function(){var e=n.computeSizes();e&&(n.previousCropSize=e,n.emitCropData(),n.setInitialCrop(e),n.isInitialized=!0),n.props.onMediaLoaded&&n.props.onMediaLoaded(n.mediaSize)},n.setInitialCrop=function(e){if(n.props.initialCroppedAreaPercentages){var t=N(n.props.initialCroppedAreaPercentages,n.mediaSize,n.props.rotation,e,n.props.minZoom,n.props.maxZoom),r=t.crop,i=t.zoom;n.props.onCropChange(r),n.props.onZoomChange&&n.props.onZoomChange(i)}else if(n.props.initialCroppedAreaPixels){var a=F(n.props.initialCroppedAreaPixels,n.mediaSize,n.props.rotation,e,n.props.minZoom,n.props.maxZoom),r=a.crop,i=a.zoom;n.props.onCropChange(r),n.props.onZoomChange&&n.props.onZoomChange(i)}},n.computeSizes=function(){var e=n.imageRef.current||n.videoRef.current;if(e&&n.containerRef){n.containerRect=n.containerRef.getBoundingClientRect(),n.saveContainerPosition();var t=n.containerRect.width/n.containerRect.height,r=n.imageRef.current?.naturalWidth||n.videoRef.current?.videoWidth||0,i=n.imageRef.current?.naturalHeight||n.videoRef.current?.videoHeight||0,a=e.offsetWidth<r||e.offsetHeight<i,o=r/i,s=void 0;if(a)switch(n.state.mediaObjectFit){default:case`contain`:s=t>o?{width:n.containerRect.height*o,height:n.containerRect.height}:{width:n.containerRect.width,height:n.containerRect.width/o};break;case`horizontal-cover`:s={width:n.containerRect.width,height:n.containerRect.width/o};break;case`vertical-cover`:s={width:n.containerRect.height*o,height:n.containerRect.height};break}else s={width:e.offsetWidth,height:e.offsetHeight};n.mediaSize=h(h({},s),{naturalWidth:r,naturalHeight:i}),n.props.setMediaSize&&n.props.setMediaSize(n.mediaSize);var c=n.props.cropSize?n.props.cropSize:w(n.mediaSize.width,n.mediaSize.height,n.containerRect.width,n.containerRect.height,n.props.aspect,n.props.rotation);return(n.state.cropSize?.height!==c.height||n.state.cropSize?.width!==c.width)&&n.props.onCropSizeChange&&n.props.onCropSizeChange(c),n.setState({cropSize:c},n.recomputeCropPosition),n.props.setCropSize&&n.props.setCropSize(c),c}},n.saveContainerPosition=function(){if(n.containerRef){var e=n.containerRef.getBoundingClientRect();n.containerPosition={x:e.left,y:e.top}}},n.onMouseDown=function(e){n.currentDoc&&(e.preventDefault(),n.currentDoc.addEventListener(`mousemove`,n.onMouseMove),n.currentDoc.addEventListener(`mouseup`,n.onDragStopped),n.saveContainerPosition(),n.onDragStart(t.getMousePoint(e)))},n.onMouseMove=function(e){return n.onDrag(t.getMousePoint(e))},n.onScroll=function(e){n.currentDoc&&(e.preventDefault(),n.saveContainerPosition())},n.onTouchStart=function(e){n.currentDoc&&(n.isTouching=!0,!(n.props.onTouchRequest&&!n.props.onTouchRequest(e))&&(n.currentDoc.addEventListener(`touchmove`,n.onTouchMove,{passive:!1}),n.currentDoc.addEventListener(`touchend`,n.onDragStopped),n.saveContainerPosition(),e.touches.length===2?n.onPinchStart(e):e.touches.length===1&&n.onDragStart(t.getTouchPoint(e.touches[0]))))},n.onTouchMove=function(e){e.preventDefault(),e.touches.length===2?n.onPinchMove(e):e.touches.length===1&&n.onDrag(t.getTouchPoint(e.touches[0]))},n.onGestureStart=function(e){n.currentDoc&&(e.preventDefault(),n.currentDoc.addEventListener(`gesturechange`,n.onGestureChange),n.currentDoc.addEventListener(`gestureend`,n.onGestureEnd),n.gestureZoomStart=n.props.zoom,n.gestureRotationStart=n.props.rotation)},n.onGestureChange=function(e){if(e.preventDefault(),!n.isTouching){var r=t.getMousePoint(e),i=n.gestureZoomStart-1+e.scale;if(n.setNewZoom(i,r,{shouldUpdatePosition:!0}),n.props.onRotationChange){var a=n.gestureRotationStart+e.rotation;n.props.onRotationChange(a)}}},n.onGestureEnd=function(e){n.cleanEvents()},n.onDragStart=function(e){var t,r;n.dragStartPosition={x:e.x,y:e.y},n.dragStartCrop=h({},n.props.crop),(r=(t=n.props).onInteractionStart)==null||r.call(t)},n.onDrag=function(e){var t=e.x,r=e.y;n.currentWindow&&(n.rafDragTimeout&&n.currentWindow.cancelAnimationFrame(n.rafDragTimeout),n.rafDragTimeout=n.currentWindow.requestAnimationFrame(function(){if(n.state.cropSize&&!(t===void 0||r===void 0)){var e=t-n.dragStartPosition.x,i=r-n.dragStartPosition.y,a={x:n.dragStartCrop.x+e,y:n.dragStartCrop.y+i},o=n.props.restrictPosition?E(a,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):a;n.props.onCropChange(o)}}))},n.onDragStopped=function(){var e,t;n.isTouching=!1,n.cleanEvents(),n.emitCropData(),(t=(e=n.props).onInteractionEnd)==null||t.call(e)},n.onWheel=function(e){if(n.currentWindow&&!(n.props.onWheelRequest&&!n.props.onWheelRequest(e))){e.preventDefault();var r=t.getMousePoint(e),i=(0,C.default)(e).pixelY,a=n.props.zoom-i*n.props.zoomSpeed/200;n.setNewZoom(a,r,{shouldUpdatePosition:!0}),n.state.hasWheelJustStarted||n.setState({hasWheelJustStarted:!0},function(){var e;return(e=n.props).onInteractionStart?.call(e)}),n.wheelTimer&&clearTimeout(n.wheelTimer),n.wheelTimer=n.currentWindow.setTimeout(function(){return n.setState({hasWheelJustStarted:!1},function(){var e;return(e=n.props).onInteractionEnd?.call(e)})},250)}},n.getPointOnContainer=function(e,t){var r=e.x,i=e.y;if(!n.containerRect)throw Error(`The Cropper is not mounted`);return{x:n.containerRect.width/2-(r-t.x),y:n.containerRect.height/2-(i-t.y)}},n.getPointOnMedia=function(e){var t=e.x,r=e.y,i=n.props,a=i.crop,o=i.zoom;return{x:(t+a.x)/o,y:(r+a.y)/o}},n.setNewZoom=function(e,t,r){var i=(r===void 0?{}:r).shouldUpdatePosition,a=i===void 0?!0:i;if(!(!n.state.cropSize||!n.props.onZoomChange)){var o=z(e,n.props.minZoom,n.props.maxZoom);if(a){var s=n.getPointOnContainer(t,n.containerPosition),c=n.getPointOnMedia(s),l={x:c.x*o-s.x,y:c.y*o-s.y},u=n.props.restrictPosition?E(l,n.mediaSize,n.state.cropSize,o,n.props.rotation):l;n.props.onCropChange(u)}n.props.onZoomChange(o)}},n.getCropData=function(){return n.state.cropSize?A(n.props.restrictPosition?E(n.props.crop,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):n.props.crop,n.mediaSize,n.state.cropSize,n.getAspect(),n.props.zoom,n.props.rotation,n.props.restrictPosition):null},n.emitCropData=function(){var e=n.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;n.props.onCropComplete&&n.props.onCropComplete(t,r),n.props.onCropAreaChange&&n.props.onCropAreaChange(t,r)}},n.emitCropAreaChange=function(){var e=n.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;n.props.onCropAreaChange&&n.props.onCropAreaChange(t,r)}},n.recomputeCropPosition=function(){if(n.state.cropSize){var e=n.props.crop;if(n.isInitialized&&n.previousCropSize?.width&&n.previousCropSize?.height&&(Math.abs(n.previousCropSize.width-n.state.cropSize.width)>1e-6||Math.abs(n.previousCropSize.height-n.state.cropSize.height)>1e-6)){var t=n.state.cropSize.width/n.previousCropSize.width,r=n.state.cropSize.height/n.previousCropSize.height;e={x:n.props.crop.x*t,y:n.props.crop.y*r}}var i=n.props.restrictPosition?E(e,n.mediaSize,n.state.cropSize,n.props.zoom,n.props.rotation):e;n.previousCropSize=n.state.cropSize,n.props.onCropChange(i),n.emitCropData()}},n.onKeyDown=function(e){var t,r,i=n.props,a=i.crop,o=i.onCropChange,s=i.keyboardStep,c=i.zoom,l=i.rotation,u=s;if(n.state.cropSize){e.shiftKey&&(u*=.2);var d=h({},a);switch(e.key){case`ArrowUp`:d.y-=u,e.preventDefault();break;case`ArrowDown`:d.y+=u,e.preventDefault();break;case`ArrowLeft`:d.x-=u,e.preventDefault();break;case`ArrowRight`:d.x+=u,e.preventDefault();break;default:return}n.props.restrictPosition&&(d=E(d,n.mediaSize,n.state.cropSize,c,l)),e.repeat||(r=(t=n.props).onInteractionStart)==null||r.call(t),o(d)}},n.onKeyUp=function(e){var t,r;switch(e.key){case`ArrowUp`:case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:e.preventDefault();break;default:return}n.emitCropData(),(r=(t=n.props).onInteractionEnd)==null||r.call(t)},n}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(),window.ResizeObserver===void 0&&this.currentWindow.addEventListener(`resize`,this.computeSizes),this.props.zoomWithScroll&&this.containerRef.addEventListener(`wheel`,this.onWheel,{passive:!1}),this.containerRef.addEventListener(`gesturestart`,this.onGestureStart)),this.currentDoc.addEventListener(`scroll`,this.onScroll),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=V,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),this.props.setCropperRef&&this.props.setCropperRef(this.cropperRef))},t.prototype.componentWillUnmount=function(){var e,t;!this.currentDoc||!this.currentWindow||(window.ResizeObserver===void 0&&this.currentWindow.removeEventListener(`resize`,this.computeSizes),(e=this.resizeObserver)==null||e.disconnect(),this.containerRef&&this.containerRef.removeEventListener(`gesturestart`,this.preventZoomSafari),this.styleRef&&((t=this.styleRef.parentNode)==null||t.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent())},t.prototype.componentDidUpdate=function(e){var t;e.rotation===this.props.rotation?e.aspect===this.props.aspect&&e.objectFit===this.props.objectFit?e.zoom===this.props.zoom?e.cropSize?.height!==this.props.cropSize?.height||e.cropSize?.width!==this.props.cropSize?.width?this.computeSizes():(e.crop?.x!==this.props.crop?.x||e.crop?.y!==this.props.crop?.y)&&this.emitCropAreaChange():this.recomputeCropPosition():this.computeSizes():(this.computeSizes(),this.recomputeCropPosition()),e.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener(`wheel`,this.onWheel,{passive:!1}):this.clearScrollEvent()),e.video!==this.props.video&&((t=this.videoRef.current)==null||t.load());var n=this.getObjectFit();n!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:n},this.computeSizes)},t.prototype.getAspect=function(){var e=this.props,t=e.cropSize,n=e.aspect;return t?t.width/t.height:n},t.prototype.getObjectFit=function(){if(this.props.objectFit===`cover`){if((this.imageRef.current||this.videoRef.current)&&this.containerRef){this.containerRect=this.containerRef.getBoundingClientRect();var e=this.containerRect.width/this.containerRect.height;return(this.imageRef.current?.naturalWidth||this.videoRef.current?.videoWidth||0)/(this.imageRef.current?.naturalHeight||this.videoRef.current?.videoHeight||0)<e?`horizontal-cover`:`vertical-cover`}return`horizontal-cover`}return this.props.objectFit},t.prototype.onPinchStart=function(e){var n=t.getTouchPoint(e.touches[0]),r=t.getTouchPoint(e.touches[1]);this.lastPinchDistance=O(n,r),this.lastPinchRotation=k(n,r),this.onDragStart(I(n,r))},t.prototype.onPinchMove=function(e){var n=this;if(!(!this.currentDoc||!this.currentWindow)){var r=t.getTouchPoint(e.touches[0]),i=t.getTouchPoint(e.touches[1]),a=I(r,i);this.onDrag(a),this.rafPinchTimeout&&this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=this.currentWindow.requestAnimationFrame(function(){var e=O(r,i),t=n.props.zoom*(e/n.lastPinchDistance);n.setNewZoom(t,a,{shouldUpdatePosition:!1}),n.lastPinchDistance=e;var o=k(r,i),s=n.props.rotation+(o-n.lastPinchRotation);n.props.onRotationChange&&n.props.onRotationChange(s),n.lastPinchRotation=o})}},t.prototype.render=function(){var e=this,t=this.props,n=t.image,r=t.video,i=t.mediaProps,a=t.cropperProps,o=t.transform,s=t.crop,c=s.x,l=s.y,u=t.rotation,d=t.zoom,f=t.cropShape,p=t.showGrid,m=t.roundCropAreaPixels,g=t.style,_=g.containerStyle,v=g.cropAreaStyle,y=g.mediaStyle,b=t.classes,x=b.containerClassName,C=b.cropAreaClassName,w=b.mediaClassName,T=this.state.mediaObjectFit??this.getObjectFit();return S.createElement(`div`,{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(t){return e.containerRef=t},"data-testid":`container`,style:_,className:B(`reactEasyCrop_Container`,x)},n?S.createElement(`img`,h({alt:``,className:B(`reactEasyCrop_Image`,T===`contain`&&`reactEasyCrop_Contain`,T===`horizontal-cover`&&`reactEasyCrop_Cover_Horizontal`,T===`vertical-cover`&&`reactEasyCrop_Cover_Vertical`,w)},i,{src:n,ref:this.imageRef,style:h(h({},y),{transform:o||`translate(${c}px, ${l}px) rotate(${u}deg) scale(${d})`}),onLoad:this.onMediaLoad})):r&&S.createElement(`video`,h({autoPlay:!0,playsInline:!0,loop:!0,muted:!0,className:B(`reactEasyCrop_Video`,T===`contain`&&`reactEasyCrop_Contain`,T===`horizontal-cover`&&`reactEasyCrop_Cover_Horizontal`,T===`vertical-cover`&&`reactEasyCrop_Cover_Vertical`,w)},i,{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:h(h({},y),{transform:o||`translate(${c}px, ${l}px) rotate(${u}deg) scale(${d})`}),controls:!1}),(Array.isArray(r)?r:[{src:r}]).map(function(e){return S.createElement(`source`,h({key:e.src},e))})),this.state.cropSize&&S.createElement(`div`,h({ref:this.cropperRef,style:h(h({},v),{width:m?Math.round(this.state.cropSize.width):this.state.cropSize.width,height:m?Math.round(this.state.cropSize.height):this.state.cropSize.height}),tabIndex:0,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp,"data-testid":`cropper`,className:B(`reactEasyCrop_CropArea`,f===`round`&&`reactEasyCrop_CropAreaRound`,p&&`reactEasyCrop_CropAreaGrid`,C)},a)))},t.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:U,minZoom:H,cropShape:`rect`,objectFit:`contain`,showGrid:!0,style:{},classes:{},mediaProps:{},cropperProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0,keyboardStep:W},t.getMousePoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t.getTouchPoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t}(S.Component),K=`img-crop`,q=1,J=.1,Y=0,X=-180,Z=180,Q=1,$=.01,ee=(0,S.memo)((0,S.forwardRef)((e,t)=>{let{cropperRef:n,zoomSlider:r,rotationSlider:i,aspectSlider:a,showReset:s,resetBtnText:c,modalImage:u,aspect:d,minZoom:f,maxZoom:p,minAspect:m,maxAspect:h,cropShape:g,showGrid:_,cropperProps:v}=e,[y,b]=(0,S.useState)({x:0,y:0}),[C,w]=(0,S.useState)(q),[T,E]=(0,S.useState)(Y),[D,O]=(0,S.useState)(d),k=(0,S.useRef)({width:0,height:0,x:0,y:0}),A=(0,S.useCallback)((e,t)=>{k.current=t},[]),j=(0,S.useRef)(d);j.current!==d&&(j.current=d,O(d));let M=C!==q||T!==Y||D!==d,N=()=>{w(q),E(Y),O(d)};(0,S.useImperativeHandle)(t,()=>({rotation:T,cropPixelsRef:k,onReset:N}));let P=`[display:flex] [align-items:center] [width:60%] [margin-inline:auto]`,F=`[display:flex] [align-items:center] [justify-content:center] [height:32px] [width:32px] [background:transparent] [border:0] [font-family:inherit] [font-size:18px] [cursor:pointer] disabled:[opacity:20%] disabled:[cursor:default]`,I=`[flex:1]`;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(G,Object.assign({},v,{ref:n,image:u,crop:y,zoom:C,rotation:T,aspect:D,minZoom:f,maxZoom:p,zoomWithScroll:r,cropShape:g,showGrid:_,onCropChange:b,onZoomChange:w,onRotationChange:E,onCropComplete:A,classes:{containerClassName:`${K}-container ![position:relative] [width:100%] [height:40vh] [&~section:first-of-type]:[margin-top:16px] [&~section:last-of-type]:[margin-bottom:16px]`,mediaClassName:`${K}-media`}})),r&&(0,x.jsxs)(`section`,{className:`${K}-control ${K}-control-zoom ${P}`,children:[(0,x.jsx)(`button`,{className:F,onClick:()=>w(+(C-J).toFixed(1)),disabled:C-J<f,children:``}),(0,x.jsx)(l,{className:I,min:f,max:p,step:J,value:C,onChange:w}),(0,x.jsx)(`button`,{className:F,onClick:()=>w(+(C+J).toFixed(1)),disabled:C+J>p,children:``})]}),i&&(0,x.jsxs)(`section`,{className:`${K}-control ${K}-control-rotation ${P}`,children:[(0,x.jsx)(`button`,{className:`${F} [font-size:16px]`,onClick:()=>E(T-Q),disabled:T===X,children:`↺`}),(0,x.jsx)(l,{className:I,min:X,max:Z,step:Q,value:T,onChange:E}),(0,x.jsx)(`button`,{className:`${F} [font-size:16px]`,onClick:()=>E(T+Q),disabled:T===Z,children:`↻`})]}),a&&(0,x.jsxs)(`section`,{className:`${K}-control ${K}-control-aspect ${P}`,children:[(0,x.jsx)(`button`,{className:F,onClick:()=>O(+(D-$).toFixed(2)),disabled:D-$<m,children:`↕`}),(0,x.jsx)(l,{className:I,min:m,max:h,step:$,value:D,onChange:O}),(0,x.jsx)(`button`,{className:F,onClick:()=>O(+(D+$).toFixed(2)),disabled:D+$>h,children:`↔`})]}),s&&(r||i||a)&&(0,x.jsx)(o,{className:`[position:absolute] [bottom:20px]`,style:M?{}:{opacity:.3,pointerEvents:`none`},onClick:N,children:c})]})})),te=`/*! tailwindcss v4.2.1 | MIT License | https://tailwindcss.com */.visible{visibility:visible}.\\!\\[position\\:relative\\]{position:relative!important}.\\[position\\:absolute\\]{position:absolute}.\\[bottom\\:20px\\]{bottom:20px}.container{width:100%}.\\[margin-inline\\:auto\\]{margin-inline:auto}.\\[display\\:flex\\]{display:flex}.grid{display:grid}.\\[height\\:32px\\]{height:32px}.\\[height\\:40vh\\]{height:40vh}.\\[width\\:32px\\]{width:32px}.\\[width\\:60\\%\\]{width:60%}.\\[width\\:100\\%\\]{width:100%}.\\[flex\\:1\\]{flex:1}.\\[cursor\\:pointer\\]{cursor:pointer}.\\[align-items\\:center\\]{align-items:center}.\\[justify-content\\:center\\]{justify-content:center}.\\[font-family\\:inherit\\]{font-family:inherit}.\\[font-size\\:16px\\]{font-size:16px}.\\[font-size\\:18px\\]{font-size:18px}.\\[background\\:transparent\\]{background:transparent}.\\[border\\:0\\]{border:0}.disabled\\:\\[cursor\\:default\\]{&:disabled{cursor:default}}.disabled\\:\\[opacity\\:20\\%\\]{&:disabled{opacity:20%}}.\\[\\&\\~section\\:first-of-type\\]\\:\\[margin-top\\:16px\\]{&~section:first-of-type{margin-top:16px}}.\\[\\&\\~section\\:last-of-type\\]\\:\\[margin-bottom\\:16px\\]{&~section:last-of-type{margin-bottom:16px}}`;(function(){if(typeof document>`u`)return;let e=document.createElement(`style`),t=document.querySelector(`meta[name="csp-nonce"]`);t&&t.content&&e.setAttribute(`nonce`,t.content),e.textContent=te,document.head.appendChild(e)})();var ne=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number),i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e]??0,i=r[e]??0;if(t>i)return!0;if(t<i)return!1}return!0},re=(0,S.forwardRef)((e,n)=>{let{quality:r=.4,fillColor:i=`white`,zoomSlider:a=!0,rotationSlider:o=!1,aspectSlider:c=!1,showReset:l=!1,resetText:u,aspect:m=1,minZoom:h=1,maxZoom:g=3,minAspect:_=.5,maxAspect:v=2,cropShape:y=`rect`,showGrid:b=!1,cropperProps:C,modalClassName:w,modalTitle:T,modalWidth:E,modalOk:D,modalCancel:O,onModalOk:k,onModalCancel:A,modalProps:j,beforeCrop:M,children:N}=e,P=(0,S.useRef)({});P.current.onModalOk=k,P.current.onModalCancel=A,P.current.beforeCrop=M;let F=(0,S.useRef)(null),I=(0,S.useCallback)(e=>{let t=document.createElement(`canvas`),n=t.getContext(`2d`),r=((e?.getRootNode)?.call(e)||document).querySelector(`.${K}-media`),{width:a,height:s,x:c,y:l}=F.current.cropPixelsRef.current;if(o&&F.current.rotation!==Y){let{naturalWidth:e,naturalHeight:o}=r,u=F.current.rotation*(Math.PI/180),d=Math.abs(Math.sin(u)),f=Math.abs(Math.cos(u)),p=e*f+o*d,m=o*f+e*d;t.width=p,t.height=m,n.fillStyle=i,n.fillRect(0,0,p,m);let h=p/2,g=m/2;n.translate(h,g),n.rotate(u),n.translate(-h,-g);let _=(p-e)/2,v=(m-o)/2;n.drawImage(r,0,0,e,o,_,v,e,o);let y=n.getImageData(0,0,p,m);t.width=a,t.height=s,n.putImageData(y,-c,-l)}else t.width=a,t.height=s,n.fillStyle=i,n.fillRect(0,0,a,s),n.drawImage(r,c,l,a,s,0,0,a,s);return t},[i,o]),[L,R]=(0,S.useState)(!1),[z,B]=(0,S.useState)(``),V=(0,S.useRef)(void 0),H=(0,S.useRef)(void 0),U=(0,S.useCallback)(e=>p(void 0,[e],void 0,function*({beforeUpload:e,file:t,resolve:n,reject:r}){let i=t;if(typeof e!=`function`){n(i);return}try{let r=yield e(t,[t]);n(r===!1?!1:r!==!0&&r||i)}catch(e){r(e)}}),[]),W=(0,S.useCallback)(e=>((t,n)=>new Promise((i,a)=>p(void 0,void 0,void 0,function*(){let o=t;if(typeof P.current.beforeCrop==`function`)try{let r=yield P.current.beforeCrop(t,n);if(r===!1)return U({beforeUpload:e,file:t,resolve:i,reject:a});r!==!0&&(o=r||t)}catch{return U({beforeUpload:e,file:t,resolve:i,reject:a})}let c=new FileReader;c.addEventListener(`load`,()=>{typeof c.result==`string`&&(R(!0),setTimeout(()=>{B(c.result)},10))}),c.readAsDataURL(o),V.current=()=>{var e,t;R(!1),B(``),F.current.onReset();let n=!1;(t=(e=P.current).onModalCancel)==null||t.call(e,e=>{i(e),n=!0}),n||i(s.LIST_IGNORE)},H.current=t=>p(void 0,void 0,void 0,function*(){R(!1),B(``),F.current.onReset();let n=I(t.target),{type:s,name:c,uid:l}=o;n.toBlob(t=>p(void 0,void 0,void 0,function*(){let n=new File([t],c,{type:s});Object.assign(n,{uid:l}),U({beforeUpload:e,file:n,resolve:e=>{var t,n;i(e),(n=(t=P.current).onModalOk)==null||n.call(t,e)},reject:e=>{var t,n;a(e),(n=(t=P.current).onModalOk)==null||n.call(t,e)}})}),s,r)})}))),[I,r,U]),G=(0,S.useCallback)(e=>{let t=Array.isArray(e)?e[0]:e,n=t.props,{beforeUpload:r,accept:i}=n,a=f(n,[`beforeUpload`,`accept`]);return Object.assign(Object.assign({},t),{props:Object.assign(Object.assign({},a),{accept:i||`image/*`,beforeUpload:W(r)})})},[W]),q=(0,S.useMemo)(()=>{let e={};return E!==void 0&&(e.width=E),D!==void 0&&(e.okText=D),O!==void 0&&(e.cancelText=O),e},[O,D,E]),J=`${K}-modal${w?` ${w}`:``}`,X=(typeof window>`u`?``:window.navigator.language)===`zh-CN`,Z=T||(X?`编辑图片`:`Edit image`),Q=u||(X?`重置`:`Reset`);return(0,x.jsxs)(x.Fragment,{children:[G(N),(0,x.jsx)(d,Object.assign({},j,q,{open:L,title:Z,onCancel:V.current,onOk:H.current,wrapClassName:J,destroyOnHidden:!0},ne(t,`6.3.1`)?{mask:{closable:!1}}:{maskClosable:!0},{children:(0,x.jsx)(ee,{ref:F,cropperRef:n,zoomSlider:a,rotationSlider:o,aspectSlider:c,showReset:l,resetBtnText:Q,modalImage:z,aspect:m,minZoom:h,maxZoom:g,minAspect:_,maxAspect:v,cropShape:y,showGrid:b,cropperProps:C})}))]})}),ie=({action:e,value:t,onChange:n,mode:r=`single`,disabled:a=!1,maxCount:o,maxWidth:l=1920,maxHeight:d=1080,maxSize:f=5,croppable:p=!1,cropperOptions:m})=>{let{t:h}=u(),[g,_]=(0,S.useState)([]),v=(0,S.useMemo)(()=>o||(r===`single`?1:9),[r,o]),y=e=>({uid:e.id?.toString()||`${e.id}`,name:e.file_name||`image-${e.id}`,status:`done`,url:e.preview_url,response:{success:!0,data:e,message:`Upload success`}});(0,S.useEffect)(()=>{if(!t){_([]);return}_((Array.isArray(t)?t:[t]).map(y))},[t]);let b=(0,S.useCallback)(e=>new Promise((t,n)=>{if(!e.type.startsWith(`image/`)){c.error(h(`xin.form.imageUploader.error.notImage`)),n(!1);return}if(!(e.size/1024/1024<f)){c.error(h(`xin.form.imageUploader.error.sizeExceeded`,{maxSize:f})),n(!1);return}let r=new FileReader;r.readAsDataURL(e),r.onload=e=>{let r=document.createElement(`img`);r.src=e.target?.result,r.onload=()=>{let e=r.width<=l,i=r.height<=d;if(!e||!i){c.error(h(`xin.form.imageUploader.error.dimensionExceeded`,{maxWidth:l,maxHeight:d})),n(!1);return}t(!0)},r.onerror=()=>{c.error(h(`xin.form.imageUploader.error.loadFailed`)),n(!1)}},r.onerror=()=>{c.error(h(`xin.form.imageUploader.error.readFailed`)),n(!1)}}),[f,l,d]),C=({fileList:e})=>{if(e.length!==0&&(_(e),e.every(e=>e.status===`done`||e.status===`error`))){let t=e.filter(e=>e.status===`done`&&e.response).map(e=>e.response.data);r===`single`?n?.(t[0]):n?.(t);let i=e.filter(e=>e.status===`error`);_([...t.map(y),...i])}},w=(0,S.useMemo)(()=>(0,x.jsxs)(`button`,{style:{border:0,background:`none`},type:`button`,children:[(0,x.jsx)(i,{}),(0,x.jsx)(`div`,{style:{marginTop:8},children:h(`xin.form.imageUploader.uploadText`)})]}),[h]),T=(0,x.jsx)(s,{listType:`picture-card`,name:`file`,fileList:g,beforeUpload:b,onChange:C,disabled:a,maxCount:v,multiple:r===`multiple`,headers:{Authorization:`Bearer ${localStorage.getItem(`token`)}`},onRemove:e=>{_(g.filter(t=>t.uid!=e.uid))},action:`/index.php`+e,accept:`image/*`,children:g.length>=v?null:w});return(0,x.jsx)(x.Fragment,{children:p&&r===`single`?(0,x.jsx)(re,{...m,children:T}):T})};export{ie as t};