Files
jiang13-forum/embed_static/static/spa/assets/ProfilePage-BxbMpG9W.js
freefire 55c256654b 支持板块图标与主题色自定义,并优化列表加载与未保存离开提示。
新增后端图标校验与色槽规范化,前端展示 BoardBadge/骨架屏,发帖与板块管理页增加未保存确认。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 17:13:32 +08:00

96 lines
34 KiB
JavaScript
Raw 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{A as Gt,r as u,j as s,e as Ht}from"./react-vendor-BdyZmpPe.js";import{u as ut,a as ft,F as mt,c as L,d as F,e as T,b as Z,f as G,o as Pt,s as X}from"./form-DggfNWHU.js";import{S as et,B as P,n as z,h as Bt,u as Xt,b as H}from"./index-Cp7Ff9NP.js";import{I as W}from"./input-y6vZyHhN.js";import{B as Yt}from"./badge-xzbTTsRq.js";import{D as Vt,a as Kt,b as qt,c as Jt,d as Qt,e as $t}from"./dialog-DXwuwWJi.js";import{Q as te,at as ee,q as ie,a1 as oe,Y as re,D as se}from"./ui-vendor-B26O8baZ.js";var gt=!1,E,it,ot,Y,V,Dt,K,rt,st,nt,Rt,at,ht,zt,Et;function C(){if(!gt){gt=!0;var i=navigator.userAgent,e=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(i),t=/(Mac OS X)|(Windows)|(Linux)/.exec(i);if(at=/\b(iPhone|iP[ao]d)/.exec(i),ht=/\b(iP[ao]d)/.exec(i),nt=/Android/i.exec(i),zt=/FBAN\/\w+;/i.exec(i),Et=/Mobile/i.exec(i),Rt=!!/Win64/.exec(i),e){E=e[1]?parseFloat(e[1]):e[5]?parseFloat(e[5]):NaN,E&&document&&document.documentMode&&(E=document.documentMode);var o=/(?:Trident\/(\d+.\d+))/.exec(i);Dt=o?parseFloat(o[1])+4:E,it=e[2]?parseFloat(e[2]):NaN,ot=e[3]?parseFloat(e[3]):NaN,Y=e[4]?parseFloat(e[4]):NaN,Y?(e=/(?:Chrome\/(\d+\.\d+))/.exec(i),V=e&&e[1]?parseFloat(e[1]):NaN):V=NaN}else E=it=ot=V=Y=NaN;if(t){if(t[1]){var r=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(i);K=r?parseFloat(r[1].replace("_",".")):!0}else K=!1;rt=!!t[2],st=!!t[3]}else K=rt=st=!1}}var ct={ie:function(){return C()||E},ieCompatibilityMode:function(){return C()||Dt>E},ie64:function(){return ct.ie()&&Rt},firefox:function(){return C()||it},opera:function(){return C()||ot},webkit:function(){return C()||Y},safari:function(){return ct.webkit()},chrome:function(){return C()||V},windows:function(){return C()||rt},osx:function(){return C()||K},linux:function(){return C()||st},iphone:function(){return C()||at},mobile:function(){return C()||at||ht||nt||Et},nativeApp:function(){return C()||zt},android:function(){return C()||nt},ipad:function(){return C()||ht}},ne=ct,ae=!!(typeof window<"u"&&window.document&&window.document.createElement),he={canUseDOM:ae},ce=he,At=ce,Mt;At.canUseDOM&&(Mt=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("","")!==!0);/**
* Checks if an event is supported in the current execution environment.
*
* NOTE: This will not work correctly for non-generic events such as `change`,
* `reset`, `load`, `error`, and `select`.
*
* Borrows from Modernizr.
*
* @param {string} eventNameSuffix Event name, e.g. "click".
* @param {?boolean} capture Check if the capture phase is supported.
* @return {boolean} True if the event is supported.
* @internal
* @license Modernizr 3.0.0pre (Custom Build) | MIT
*/function le(i,e){if(!At.canUseDOM||e&&!("addEventListener"in document))return!1;var t="on"+i,o=t in document;if(!o){var r=document.createElement("div");r.setAttribute(t,"return;"),o=typeof r[t]=="function"}return!o&&Mt&&i==="wheel"&&(o=document.implementation.hasFeature("Events.wheel","3.0")),o}var pe=le,de=ne,ue=pe,vt=10,wt=40,xt=800;function Nt(i){var e=0,t=0,o=0,r=0;return"detail"in i&&(t=i.detail),"wheelDelta"in i&&(t=-i.wheelDelta/120),"wheelDeltaY"in i&&(t=-i.wheelDeltaY/120),"wheelDeltaX"in i&&(e=-i.wheelDeltaX/120),"axis"in i&&i.axis===i.HORIZONTAL_AXIS&&(e=t,t=0),o=e*vt,r=t*vt,"deltaY"in i&&(r=i.deltaY),"deltaX"in i&&(o=i.deltaX),(o||r)&&i.deltaMode&&(i.deltaMode==1?(o*=wt,r*=wt):(o*=xt,r*=xt)),o&&!e&&(e=o<1?-1:1),r&&!t&&(t=r<1?-1:1),{spinX:e,spinY:t,pixelX:o,pixelY:r}}Nt.getEventType=function(){return de.firefox()?"DOMMouseScroll":ue("wheel")?"wheel":"mousewheel"};var fe=Nt,me=fe;const ge=Gt(me);function I(i){"@babel/helpers - typeof";return I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(i)}function ve(i,e){if(I(i)!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var o=t.call(i,e);if(I(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function we(i){var e=ve(i,"string");return I(e)=="symbol"?e:e+""}function xe(i,e,t){return(e=we(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ct(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(i);e&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,o)}return t}function g(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ct(Object(t),!0).forEach(function(o){xe(i,o,t[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Ct(Object(t)).forEach(function(o){Object.defineProperty(i,o,Object.getOwnPropertyDescriptor(t,o))})}return i}function Ce(i,e,t,o,r,n=0){const{width:h,height:a}=M(i,e,n),c=Math.min(h,t),p=Math.min(a,o);return c>p*r?{width:p*r,height:p}:{width:c,height:c/r}}function ye(i){return i.width>i.height?i.width/i.naturalWidth:i.height/i.naturalHeight}function k(i,e,t,o,r=0){const{width:n,height:h}=M(e.width,e.height,r);return{x:yt(i.x,n,t.width,o),y:yt(i.y,h,t.height,o)}}function yt(i,e,t,o){const r=Math.abs(e*o/2-t/2);return q(i,-r,r)}function bt(i,e){return Math.sqrt(Math.pow(i.y-e.y,2)+Math.pow(i.x-e.x,2))}function St(i,e){return Math.atan2(e.y-i.y,e.x-i.x)*180/Math.PI}function be(i,e,t,o,r,n=0,h=!0){const a=h?Se:je,c=M(e.width,e.height,n),p=M(e.naturalWidth,e.naturalHeight,n),d={x:a(100,((c.width-t.width/r)/2-i.x/r)/c.width*100),y:a(100,((c.height-t.height/r)/2-i.y/r)/c.height*100),width:a(100,t.width/c.width*100/r),height:a(100,t.height/c.height*100/r)},f=Math.round(a(p.width,d.width*p.width/100)),m=Math.round(a(p.height,d.height*p.height/100)),v=p.width>=p.height*o?{width:Math.round(m*o),height:m}:{width:f,height:Math.round(f/o)};return{croppedAreaPercentages:d,croppedAreaPixels:g(g({},v),{},{x:Math.round(a(p.width-v.width,d.x*p.width/100)),y:Math.round(a(p.height-v.height,d.y*p.height/100))})}}function Se(i,e){return Math.min(i,Math.max(0,e))}function je(i,e){return e}function Pe(i,e,t,o,r,n){const h=M(e.width,e.height,t),a=q(o.width/h.width*(100/i.width),r,n);return{crop:{x:a*h.width/2-o.width/2-h.width*a*(i.x/100),y:a*h.height/2-o.height/2-h.height*a*(i.y/100)},zoom:a}}function De(i,e,t){const o=ye(e);return t.height>t.width?t.height/(i.height*o):t.width/(i.width*o)}function Re(i,e,t=0,o,r,n){const h=M(e.naturalWidth,e.naturalHeight,t),a=q(De(i,e,o),r,n),c=o.height>o.width?o.height/i.height:o.width/i.width;return{crop:{x:((h.width-i.width)/2-i.x)*c,y:((h.height-i.height)/2-i.y)*c},zoom:a}}function jt(i,e){return{x:(e.x+i.x)/2,y:(e.y+i.y)/2}}function ze(i){return i*Math.PI/180}function M(i,e,t){const o=ze(t);return{width:Math.abs(Math.cos(o)*i)+Math.abs(Math.sin(o)*e),height:Math.abs(Math.sin(o)*i)+Math.abs(Math.cos(o)*e)}}function q(i,e,t){return Math.min(Math.max(i,e),t)}function B(...i){return i.filter(e=>typeof e=="string"&&e.length>0).join(" ").trim()}var Ee=`.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 */
max-width: unset; /* prevent global img/video reset rules from constraining the cropper media */
}
.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;
}
`;const Ae=1,Me=3,Ne=1;var J=class S extends u.Component{constructor(...e){super(...e),this.cropperRef=u.createRef(),this.imageRef=u.createRef(),this.videoRef=u.createRef(),this.containerPosition={x:0,y:0},this.containerRef=null,this.styleRef=null,this.containerRect=null,this.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},this.dragStartPosition={x:0,y:0},this.dragStartCrop={x:0,y:0},this.gestureZoomStart=0,this.gestureRotationStart=0,this.isTouching=!1,this.lastPinchDistance=0,this.lastPinchRotation=0,this.rafDragTimeout=null,this.rafPinchTimeout=null,this.wheelTimer=null,this.currentDoc=typeof document<"u"?document:null,this.currentWindow=typeof window<"u"?window:null,this.resizeObserver=null,this.previousCropSize=null,this.isInitialized=!1,this.state={cropSize:null,hasWheelJustStarted:!1,mediaObjectFit:void 0},this.initResizeObserver=()=>{if(typeof window.ResizeObserver>"u"||!this.containerRef)return;let t=!0;this.resizeObserver=new window.ResizeObserver(o=>{if(t){t=!1;return}this.computeSizes()}),this.resizeObserver.observe(this.containerRef)},this.preventZoomSafari=t=>t.preventDefault(),this.cleanEvents=()=>{this.currentDoc&&(this.currentDoc.removeEventListener("mousemove",this.onMouseMove),this.currentDoc.removeEventListener("mouseup",this.onDragStopped),this.currentDoc.removeEventListener("touchmove",this.onTouchMove),this.currentDoc.removeEventListener("touchend",this.onDragStopped),this.currentDoc.removeEventListener("gesturechange",this.onGestureChange),this.currentDoc.removeEventListener("gestureend",this.onGestureEnd),this.currentDoc.removeEventListener("scroll",this.onScroll))},this.clearScrollEvent=()=>{this.containerRef&&this.containerRef.removeEventListener("wheel",this.onWheel),this.wheelTimer&&clearTimeout(this.wheelTimer)},this.onMediaLoad=()=>{const t=this.computeSizes();t&&(this.previousCropSize=t,this.emitCropData(),this.setInitialCrop(t),this.isInitialized=!0),this.props.onMediaLoaded&&this.props.onMediaLoaded(this.mediaSize)},this.setInitialCrop=t=>{if(this.props.initialCroppedAreaPercentages){const{crop:o,zoom:r}=Pe(this.props.initialCroppedAreaPercentages,this.mediaSize,this.props.rotation,t,this.props.minZoom,this.props.maxZoom);this.props.onCropChange(o),this.props.onZoomChange&&this.props.onZoomChange(r)}else if(this.props.initialCroppedAreaPixels){const{crop:o,zoom:r}=Re(this.props.initialCroppedAreaPixels,this.mediaSize,this.props.rotation,t,this.props.minZoom,this.props.maxZoom);this.props.onCropChange(o),this.props.onZoomChange&&this.props.onZoomChange(r)}},this.computeSizes=()=>{const t=this.imageRef.current||this.videoRef.current;if(t&&this.containerRef){var o,r,n,h,a,c;this.containerRect=this.containerRef.getBoundingClientRect(),this.saveContainerPosition();const p=this.containerRect.width/this.containerRect.height,d=((o=this.imageRef.current)===null||o===void 0?void 0:o.naturalWidth)||((r=this.videoRef.current)===null||r===void 0?void 0:r.videoWidth)||0,f=((n=this.imageRef.current)===null||n===void 0?void 0:n.naturalHeight)||((h=this.videoRef.current)===null||h===void 0?void 0:h.videoHeight)||0,m=t.offsetWidth<d||t.offsetHeight<f,v=d/f;let y;if(m)switch(this.state.mediaObjectFit){default:case"contain":y=p>v?{width:this.containerRect.height*v,height:this.containerRect.height}:{width:this.containerRect.width,height:this.containerRect.width/v};break;case"horizontal-cover":y={width:this.containerRect.width,height:this.containerRect.width/v};break;case"vertical-cover":y={width:this.containerRect.height*v,height:this.containerRect.height};break}else y={width:t.offsetWidth,height:t.offsetHeight};this.mediaSize=g(g({},y),{},{naturalWidth:d,naturalHeight:f}),this.props.setMediaSize&&this.props.setMediaSize(this.mediaSize);const x=this.props.cropSize?this.props.cropSize:Ce(this.mediaSize.width,this.mediaSize.height,this.containerRect.width,this.containerRect.height,this.props.aspect,this.props.rotation);return(((a=this.state.cropSize)===null||a===void 0?void 0:a.height)!==x.height||((c=this.state.cropSize)===null||c===void 0?void 0:c.width)!==x.width)&&this.props.onCropSizeChange&&this.props.onCropSizeChange(x),this.setState({cropSize:x},this.recomputeCropPosition),this.props.setCropSize&&this.props.setCropSize(x),x}},this.saveContainerPosition=()=>{if(this.containerRef){const t=this.containerRef.getBoundingClientRect();this.containerPosition={x:t.left,y:t.top}}},this.onMouseDown=t=>{this.currentDoc&&(t.preventDefault(),this.currentDoc.addEventListener("mousemove",this.onMouseMove),this.currentDoc.addEventListener("mouseup",this.onDragStopped),this.saveContainerPosition(),this.onDragStart(S.getMousePoint(t)))},this.onMouseMove=t=>this.onDrag(S.getMousePoint(t)),this.onScroll=t=>{this.currentDoc&&(t.preventDefault(),this.saveContainerPosition())},this.onTouchStart=t=>{this.currentDoc&&(this.isTouching=!0,!(this.props.onTouchRequest&&!this.props.onTouchRequest(t))&&(this.currentDoc.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.currentDoc.addEventListener("touchend",this.onDragStopped),this.saveContainerPosition(),t.touches.length===2?this.onPinchStart(t):t.touches.length===1&&this.onDragStart(S.getTouchPoint(t.touches[0]))))},this.onTouchMove=t=>{t.preventDefault(),t.touches.length===2?this.onPinchMove(t):t.touches.length===1&&this.onDrag(S.getTouchPoint(t.touches[0]))},this.onGestureStart=t=>{this.currentDoc&&(t.preventDefault(),this.currentDoc.addEventListener("gesturechange",this.onGestureChange),this.currentDoc.addEventListener("gestureend",this.onGestureEnd),this.gestureZoomStart=this.props.zoom,this.gestureRotationStart=this.props.rotation)},this.onGestureChange=t=>{if(t.preventDefault(),this.isTouching)return;const o=S.getMousePoint(t),r=this.gestureZoomStart-1+t.scale;if(this.setNewZoom(r,o,{shouldUpdatePosition:!0}),this.props.onRotationChange){const n=this.gestureRotationStart+t.rotation;this.props.onRotationChange(n)}},this.onGestureEnd=t=>{this.cleanEvents()},this.onDragStart=({x:t,y:o})=>{var r,n;this.dragStartPosition={x:t,y:o},this.dragStartCrop=g({},this.props.crop),(r=(n=this.props).onInteractionStart)===null||r===void 0||r.call(n)},this.onDrag=({x:t,y:o})=>{this.currentWindow&&(this.rafDragTimeout&&this.currentWindow.cancelAnimationFrame(this.rafDragTimeout),this.rafDragTimeout=this.currentWindow.requestAnimationFrame(()=>{if(!this.state.cropSize||t===void 0||o===void 0)return;const r=t-this.dragStartPosition.x,n=o-this.dragStartPosition.y,h={x:this.dragStartCrop.x+r,y:this.dragStartCrop.y+n},a=this.props.restrictPosition?k(h,this.mediaSize,this.state.cropSize,this.props.zoom,this.props.rotation):h;this.props.onCropChange(a)}))},this.onDragStopped=()=>{var t,o;this.isTouching=!1,this.cleanEvents(),this.emitCropData(),(t=(o=this.props).onInteractionEnd)===null||t===void 0||t.call(o)},this.onWheel=t=>{if(!this.currentWindow||this.props.onWheelRequest&&!this.props.onWheelRequest(t))return;t.preventDefault();const o=S.getMousePoint(t),{pixelY:r}=ge(t),n=this.props.zoom-r*this.props.zoomSpeed/200;this.setNewZoom(n,o,{shouldUpdatePosition:!0}),this.state.hasWheelJustStarted||this.setState({hasWheelJustStarted:!0},()=>{var h,a;return(h=(a=this.props).onInteractionStart)===null||h===void 0?void 0:h.call(a)}),this.wheelTimer&&clearTimeout(this.wheelTimer),this.wheelTimer=this.currentWindow.setTimeout(()=>this.setState({hasWheelJustStarted:!1},()=>{var h,a;return(h=(a=this.props).onInteractionEnd)===null||h===void 0?void 0:h.call(a)}),250)},this.getPointOnContainer=({x:t,y:o},r)=>{if(!this.containerRect)throw new Error("The Cropper is not mounted");return{x:this.containerRect.width/2-(t-r.x),y:this.containerRect.height/2-(o-r.y)}},this.getPointOnMedia=({x:t,y:o})=>{const{crop:r,zoom:n}=this.props;return{x:(t+r.x)/n,y:(o+r.y)/n}},this.setNewZoom=(t,o,{shouldUpdatePosition:r=!0}={})=>{if(!this.state.cropSize||!this.props.onZoomChange)return;const n=q(t,this.props.minZoom,this.props.maxZoom);if(r){const h=this.getPointOnContainer(o,this.containerPosition),a=this.getPointOnMedia(h),c={x:a.x*n-h.x,y:a.y*n-h.y},p=this.props.restrictPosition?k(c,this.mediaSize,this.state.cropSize,n,this.props.rotation):c;this.props.onCropChange(p)}this.props.onZoomChange(n)},this.getCropData=()=>this.state.cropSize?be(this.props.restrictPosition?k(this.props.crop,this.mediaSize,this.state.cropSize,this.props.zoom,this.props.rotation):this.props.crop,this.mediaSize,this.state.cropSize,this.getAspect(),this.props.zoom,this.props.rotation,this.props.restrictPosition):null,this.emitCropData=()=>{const t=this.getCropData();if(!t)return;const{croppedAreaPercentages:o,croppedAreaPixels:r}=t;this.props.onCropComplete&&this.props.onCropComplete(o,r),this.props.onCropAreaChange&&this.props.onCropAreaChange(o,r)},this.emitCropAreaChange=()=>{const t=this.getCropData();if(!t)return;const{croppedAreaPercentages:o,croppedAreaPixels:r}=t;this.props.onCropAreaChange&&this.props.onCropAreaChange(o,r)},this.recomputeCropPosition=()=>{var t,o;if(!this.state.cropSize)return;let r=this.props.crop;if(this.isInitialized&&(!((t=this.previousCropSize)===null||t===void 0)&&t.width)&&(!((o=this.previousCropSize)===null||o===void 0)&&o.height)&&(Math.abs(this.previousCropSize.width-this.state.cropSize.width)>1e-6||Math.abs(this.previousCropSize.height-this.state.cropSize.height)>1e-6)){const h=this.state.cropSize.width/this.previousCropSize.width,a=this.state.cropSize.height/this.previousCropSize.height;r={x:this.props.crop.x*h,y:this.props.crop.y*a}}const n=this.props.restrictPosition?k(r,this.mediaSize,this.state.cropSize,this.props.zoom,this.props.rotation):r;this.previousCropSize=this.state.cropSize,this.props.onCropChange(n),this.emitCropData()},this.onKeyDown=t=>{const{crop:o,onCropChange:r,keyboardStep:n,zoom:h,rotation:a}=this.props;let c=n;if(!this.state.cropSize)return;t.shiftKey&&(c*=.2);let p=g({},o);switch(t.key){case"ArrowUp":p.y-=c,t.preventDefault();break;case"ArrowDown":p.y+=c,t.preventDefault();break;case"ArrowLeft":p.x-=c,t.preventDefault();break;case"ArrowRight":p.x+=c,t.preventDefault();break;default:return}if(this.props.restrictPosition&&(p=k(p,this.mediaSize,this.state.cropSize,h,a)),!t.repeat){var d,f;(d=(f=this.props).onInteractionStart)===null||d===void 0||d.call(f)}r(p)},this.onKeyUp=t=>{var o,r;switch(t.key){case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":t.preventDefault();break;default:return}this.emitCropData(),(o=(r=this.props).onInteractionEnd)===null||o===void 0||o.call(r)}}componentDidMount(){!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.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=Ee,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))}componentWillUnmount(){var e;if(!(!this.currentDoc||!this.currentWindow)){if(typeof window.ResizeObserver>"u"&&this.currentWindow.removeEventListener("resize",this.computeSizes),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),this.containerRef&&this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.styleRef){var t;(t=this.styleRef.parentNode)===null||t===void 0||t.removeChild(this.styleRef)}this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent()}}componentDidUpdate(e){var t,o,r,n,h,a,c,p;if(e.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):e.aspect!==this.props.aspect?this.computeSizes():e.objectFit!==this.props.objectFit?this.computeSizes():e.zoom!==this.props.zoom?this.recomputeCropPosition():((t=e.cropSize)===null||t===void 0?void 0:t.height)!==((o=this.props.cropSize)===null||o===void 0?void 0:o.height)||((r=e.cropSize)===null||r===void 0?void 0:r.width)!==((n=this.props.cropSize)===null||n===void 0?void 0:n.width)?this.computeSizes():(((h=e.crop)===null||h===void 0?void 0:h.x)!==((a=this.props.crop)===null||a===void 0?void 0:a.x)||((c=e.crop)===null||c===void 0?void 0:c.y)!==((p=this.props.crop)===null||p===void 0?void 0:p.y))&&this.emitCropAreaChange(),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){var d;(d=this.videoRef.current)===null||d===void 0||d.load()}const f=this.getObjectFit();f!==this.state.mediaObjectFit&&this.setState({mediaObjectFit:f},this.computeSizes)}getAspect(){const{cropSize:e,aspect:t}=this.props;return e?e.width/e.height:t}getObjectFit(){if(this.props.objectFit==="cover"){if((this.imageRef.current||this.videoRef.current)&&this.containerRef){var e,t,o,r;this.containerRect=this.containerRef.getBoundingClientRect();const n=this.containerRect.width/this.containerRect.height;return(((e=this.imageRef.current)===null||e===void 0?void 0:e.naturalWidth)||((t=this.videoRef.current)===null||t===void 0?void 0:t.videoWidth)||0)/(((o=this.imageRef.current)===null||o===void 0?void 0:o.naturalHeight)||((r=this.videoRef.current)===null||r===void 0?void 0:r.videoHeight)||0)<n?"horizontal-cover":"vertical-cover"}return"horizontal-cover"}return this.props.objectFit}onPinchStart(e){const t=S.getTouchPoint(e.touches[0]),o=S.getTouchPoint(e.touches[1]);this.lastPinchDistance=bt(t,o),this.lastPinchRotation=St(t,o),this.onDragStart(jt(t,o))}onPinchMove(e){if(!this.currentDoc||!this.currentWindow)return;const t=S.getTouchPoint(e.touches[0]),o=S.getTouchPoint(e.touches[1]),r=jt(t,o);this.onDrag(r),this.rafPinchTimeout&&this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=this.currentWindow.requestAnimationFrame(()=>{const n=bt(t,o),h=this.props.zoom*(n/this.lastPinchDistance);this.setNewZoom(h,r,{shouldUpdatePosition:!1}),this.lastPinchDistance=n;const a=St(t,o),c=this.props.rotation+(a-this.lastPinchRotation);this.props.onRotationChange&&this.props.onRotationChange(c),this.lastPinchRotation=a})}render(){var e;const{image:t,video:o,mediaProps:r,cropperProps:n,transform:h,crop:{x:a,y:c},rotation:p,zoom:d,cropShape:f,showGrid:m,roundCropAreaPixels:v,style:{containerStyle:y,cropAreaStyle:x,mediaStyle:b},classes:{containerClassName:U,cropAreaClassName:Q,mediaClassName:N}}=this.props,j=(e=this.state.mediaObjectFit)!==null&&e!==void 0?e:this.getObjectFit();return u.createElement("div",{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:D=>this.containerRef=D,"data-testid":"container",style:y,className:B("reactEasyCrop_Container",U)},t?u.createElement("img",g(g({alt:"",className:B("reactEasyCrop_Image",j==="contain"&&"reactEasyCrop_Contain",j==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",j==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",N)},r),{},{src:t,ref:this.imageRef,style:g(g({},b),{},{transform:h||`translate(${a}px, ${c}px) rotate(${p}deg) scale(${d})`}),onLoad:this.onMediaLoad})):o&&u.createElement("video",g(g({autoPlay:!0,playsInline:!0,loop:!0,muted:!0,className:B("reactEasyCrop_Video",j==="contain"&&"reactEasyCrop_Contain",j==="horizontal-cover"&&"reactEasyCrop_Cover_Horizontal",j==="vertical-cover"&&"reactEasyCrop_Cover_Vertical",N)},r),{},{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:g(g({},b),{},{transform:h||`translate(${a}px, ${c}px) rotate(${p}deg) scale(${d})`}),controls:!1}),(Array.isArray(o)?o:[{src:o}]).map(D=>u.createElement("source",g({key:D.src},D)))),this.state.cropSize&&u.createElement("div",g({ref:this.cropperRef,style:g(g({},x),{},{width:v?Math.round(this.state.cropSize.width):this.state.cropSize.width,height:v?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",m&&"reactEasyCrop_CropAreaGrid",Q)},n)))}};J.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:Me,minZoom:Ae,cropShape:"rect",objectFit:"contain",showGrid:!0,style:{},classes:{},mediaProps:{},cropperProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0,keyboardStep:Ne};J.getMousePoint=i=>({x:Number(i.clientX),y:Number(i.clientY)});J.getTouchPoint=i=>({x:Number(i.clientX),y:Number(i.clientY)});var _e=J;const Oe="image/jpeg,image/png,image/gif,image/webp",Le=["image/jpeg","image/png","image/gif","image/webp"],Fe=512;function Te(i){return new Promise((e,t)=>{const o=new Image;o.onload=()=>e(o),o.onerror=()=>t(new Error("图片加载失败")),o.src=i})}function We(i,e){return Le.includes(i.type)?i.size>e*1024*1024?`头像不能超过 ${e}MB`:null:"仅支持 JPG、PNG、GIF、WebP 格式"}async function ke(i,e,t="avatar.jpg"){const o=await Te(i),r=document.createElement("canvas"),n=Fe;r.width=n,r.height=n;const h=r.getContext("2d");if(!h)throw new Error("裁剪失败");h.drawImage(o,e.x,e.y,e.width,e.height,0,0,n,n);const a=await new Promise((p,d)=>{r.toBlob(f=>f?p(f):d(new Error("裁剪失败")),"image/jpeg",.92)}),c=t.replace(/\.[^.]+$/,"")||"avatar";return new File([a],`${c}.jpg`,{type:"image/jpeg"})}function Ie({open:i,imageSrc:e,fileName:t,onOpenChange:o,onConfirm:r}){const[n,h]=u.useState({x:0,y:0}),[a,c]=u.useState(1),[p,d]=u.useState(null),[f,m]=u.useState(!1);u.useEffect(()=>{i&&(h({x:0,y:0}),c(1),d(null))},[i,e]);const v=u.useCallback((x,b)=>{d(b)},[]),y=async()=>{if(!(!e||!p)){m(!0);try{const x=await ke(e,p,t);r(x),o(!1)}catch{z.error("裁剪失败,请重试")}finally{m(!1)}}};return s.jsx(Vt,{open:i,onOpenChange:o,children:s.jsxs(Kt,{className:"avatar-crop-dialog",children:[s.jsxs(qt,{children:[s.jsx(Jt,{children:"裁剪头像"}),s.jsx(Qt,{children:"拖动图片调整位置滚轮或滑块缩放。GIF 裁剪后将变为静态 JPG。"})]}),s.jsx("div",{className:"avatar-crop-stage",children:e?s.jsx(_e,{image:e,crop:n,zoom:a,aspect:1,cropShape:"round",showGrid:!1,onCropChange:h,onZoomChange:c,onCropComplete:v}):s.jsx("div",{className:"avatar-crop-loading",children:s.jsx(et,{size:"lg"})})}),s.jsxs("div",{className:"avatar-crop-zoom",children:[s.jsx("span",{className:"avatar-crop-zoom-label",children:"缩放"}),s.jsx("input",{type:"range",min:1,max:3,step:.01,value:a,onChange:x=>c(Number(x.target.value)),"aria-label":"缩放"})]}),s.jsxs($t,{children:[s.jsx(P,{variant:"outline",disabled:f,onClick:()=>o(!1),children:"取消"}),s.jsx(P,{loading:f,disabled:!e,onClick:y,children:"确认裁剪"})]})]})})}const Ue=Pt({nickname:X().min(1,"请输入昵称").max(64)}),Ze=i=>Pt({old_password:X().min(1,"请输入当前密码"),new_password:X().min(i,`新密码至少 ${i}`),confirm_password:X().min(1,"请确认新密码")}).refine(e=>e.new_password===e.confirm_password,{message:"两次输入的新密码不一致",path:["confirm_password"]});function qe(){const i=Ht(),{user:e,loading:t,refresh:o}=Bt(),[r,n]=u.useState(!1),[h,a]=u.useState(!1),[c,p]=u.useState(!1),[d,f]=u.useState(null),[m,v]=u.useState(null),[y,x]=u.useState(!1),[b,U]=u.useState(null),[Q,N]=u.useState(""),[j,D]=u.useState(!1),R=u.useRef(null),_=u.useRef(0),{limits:$}=Xt(),tt=ut({resolver:ft(Ue),values:{nickname:(e==null?void 0:e.nickname)??""}}),A=ut({resolver:ft(Ze($.password_min_len)),defaultValues:{old_password:"",new_password:"",confirm_password:""}});u.useEffect(()=>{!t&&!e&&i("/login")},[t,e,i]),u.useEffect(()=>()=>{m&&URL.revokeObjectURL(m)},[m]),u.useEffect(()=>()=>{b&&URL.revokeObjectURL(b)},[b]);const _t=u.useCallback(l=>{l||(x(!1),U(w=>(w&&URL.revokeObjectURL(w),null)),N(""),R.current&&(R.current.value=""))},[]);if(t)return s.jsx("div",{className:"flex justify-center py-16",children:s.jsx(et,{size:"lg"})});if(!e)return null;const Ot=async l=>{n(!0);try{await H.updateNickname(l.nickname),await o(),z.success("昵称已更新")}catch(w){z.error(w instanceof Error?w.message:"更新失败")}finally{n(!1)}},Lt=async l=>{a(!0);try{await H.updatePassword(l.old_password,l.new_password),z.success("密码已修改,请重新登录"),A.reset(),await H.logout(),i("/login")}catch(w){z.error(w instanceof Error?w.message:"修改失败")}finally{a(!1)}},lt=()=>{m&&URL.revokeObjectURL(m),f(null),v(null),R.current&&(R.current.value="")},pt=l=>{const w=We(l,$.avatar_max_mb);if(w){z.error(w),R.current&&(R.current.value="");return}b&&URL.revokeObjectURL(b),N(l.name),U(URL.createObjectURL(l)),x(!0)},Ft=l=>{var O;const w=(O=l.target.files)==null?void 0:O[0];w&&pt(w)},Tt=l=>{m&&URL.revokeObjectURL(m),f(l),v(URL.createObjectURL(l))},Wt=async()=>{if(d){p(!0);try{await H.uploadAvatar(d),await o(),lt(),z.success("头像已更新")}catch(l){z.error(l instanceof Error?l.message:"上传失败")}finally{p(!1)}}},kt=l=>{l.preventDefault(),l.stopPropagation(),_.current+=1,l.dataTransfer.types.includes("Files")&&D(!0)},It=l=>{l.preventDefault(),l.stopPropagation(),_.current-=1,_.current<=0&&(_.current=0,D(!1))},Ut=l=>{l.preventDefault(),l.stopPropagation()},Zt=l=>{var O;if(l.preventDefault(),l.stopPropagation(),_.current=0,D(!1),c)return;const w=(O=l.dataTransfer.files)==null?void 0:O[0];w&&pt(w)},dt=m??e.avatar;return s.jsx("div",{className:"page-wrap",children:s.jsxs("div",{className:"page-inner-wide",style:{maxWidth:640},children:[s.jsxs(P,{variant:"ghost",className:"mb-3",onClick:()=>i(-1),children:[s.jsx(te,{}),"返回"]}),s.jsx("h1",{className:"page-title mb-4",children:"个人中心"}),s.jsxs("div",{className:`profile-header-card${j?" profile-header-card--dragover":""}`,onDragEnter:kt,onDragLeave:It,onDragOver:Ut,onDrop:Zt,children:[j&&s.jsxs("div",{className:"profile-drop-overlay",children:[s.jsx(ee,{size:28,strokeWidth:1.5}),s.jsx("span",{children:"松开以上传头像"})]}),s.jsx("input",{ref:R,type:"file",accept:Oe,className:"sr-only",onChange:Ft}),s.jsx("button",{type:"button",className:"profile-avatar-btn",title:"点击或拖拽图片到此处更换头像",disabled:c,onClick:()=>{var l;return(l=R.current)==null?void 0:l.click()},children:s.jsxs("div",{className:`profile-avatar-lg${d?" profile-avatar-lg--pending":""}`,children:[dt?s.jsx("img",{src:dt,alt:""}):e.nickname[0],s.jsx("span",{className:"profile-avatar-overlay",children:c?s.jsx(et,{size:"sm",className:"text-white"}):s.jsx(ie,{size:22,strokeWidth:1.75})})]})}),s.jsxs("div",{className:"profile-header-info",children:[s.jsxs("div",{className:"profile-header-main",children:[s.jsx("h1",{className:"profile-display-name",children:e.nickname}),s.jsxs("div",{className:"profile-username",children:["@",e.username]}),s.jsx("p",{className:"profile-avatar-tip",children:"点击头像选择图片,或拖拽到此处"}),e.role==="admin"&&s.jsx(Yt,{variant:"green",className:"mt-1.5",children:"管理员"})]}),d&&s.jsxs("div",{className:"profile-avatar-actions",children:[s.jsx("span",{className:"profile-avatar-hint",children:"已裁剪,待保存"}),s.jsx(P,{size:"sm",loading:c,onClick:Wt,children:"保存头像"}),s.jsx(P,{size:"sm",variant:"ghost",disabled:c,onClick:lt,"aria-label":"取消",children:s.jsx(oe,{size:16})})]})]})]}),s.jsx(Ie,{open:y,imageSrc:b,fileName:Q,onOpenChange:_t,onConfirm:Tt}),e.role==="admin"&&s.jsxs("div",{className:"section-card admin-entry-card",children:[s.jsx("div",{className:"section-card-title",children:"管理员入口"}),s.jsx("p",{style:{fontSize:13,color:"var(--color-text-3)",margin:"0 0 12px"},children:"管理板块、用户、帖子及系统设置"}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(P,{variant:"outline",onClick:()=>i("/admin/boards"),children:[s.jsx(re,{}),"管理板块"]}),s.jsxs(P,{onClick:()=>i("/admin/dashboard"),children:[s.jsx(se,{}),"进入系统后台"]})]})]}),s.jsxs("div",{className:"section-card",children:[s.jsx("div",{className:"section-card-title",children:"基本资料"}),s.jsx(mt,{...tt,children:s.jsxs("form",{onSubmit:tt.handleSubmit(Ot),className:"profile-form",children:[s.jsxs(L,{children:[s.jsx(F,{children:"用户名"}),s.jsx(T,{children:s.jsx(W,{value:e.username,disabled:!0})})]}),s.jsx(Z,{control:tt.control,name:"nickname",render:({field:l})=>s.jsxs(L,{children:[s.jsx(F,{children:"昵称"}),s.jsx(T,{children:s.jsx(W,{maxLength:64,placeholder:"显示名称",...l})}),s.jsx(G,{})]})}),s.jsxs("div",{className:"profile-form-footer",children:[s.jsxs("span",{className:"profile-form-hint",children:["支持 JPG、PNG、GIF、WebP头像不超过 ",$.avatar_max_mb,"MB"]}),s.jsx(P,{type:"submit",loading:r,children:"保存"})]})]})})]}),s.jsxs("div",{className:"section-card",children:[s.jsx("div",{className:"section-card-title",children:"修改密码"}),s.jsx(mt,{...A,children:s.jsxs("form",{onSubmit:A.handleSubmit(Lt),className:"profile-form",children:[s.jsx(Z,{control:A.control,name:"old_password",render:({field:l})=>s.jsxs(L,{children:[s.jsx(F,{children:"当前密码"}),s.jsx(T,{children:s.jsx(W,{type:"password",placeholder:"输入当前密码",...l})}),s.jsx(G,{})]})}),s.jsx(Z,{control:A.control,name:"new_password",render:({field:l})=>s.jsxs(L,{children:[s.jsx(F,{children:"新密码"}),s.jsx(T,{children:s.jsx(W,{type:"password",placeholder:"至少 6 位",...l})}),s.jsx(G,{})]})}),s.jsx(Z,{control:A.control,name:"confirm_password",render:({field:l})=>s.jsxs(L,{children:[s.jsx(F,{children:"确认新密码"}),s.jsx(T,{children:s.jsx(W,{type:"password",placeholder:"再次输入新密码",...l})}),s.jsx(G,{})]})}),s.jsx("div",{className:"profile-form-footer profile-form-footer--end",children:s.jsx(P,{type:"submit",variant:"destructive",loading:h,children:"修改密码"})})]})})]})]})})}export{qe as default};