@mingxy/cerebro 1.19.2 → 1.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -80,7 +80,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
80
80
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dG(e,n){if(e){if(typeof e==`string`)return mG(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`)return Array.from(e);if(r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return mG(e,n)}}function fG(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function pG(e){if(Array.isArray(e))return mG(e)}function mG(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function hG(e,n){if(!(e instanceof n))throw TypeError(`Cannot call a class as a function`)}function gG(e,n){for(var r=0;r<n.length;r++){var i=n[r];i.enumerable=i.enumerable||!1,i.configurable=!0,`value`in i&&(i.writable=!0),Object.defineProperty(e,EG(i.key),i)}}function _G(e,n,r){return n&&gG(e.prototype,n),r&&gG(e,r),Object.defineProperty(e,`prototype`,{writable:!1}),e}function vG(e,n,r){return n=SG(n),yG(e,xG()?Reflect.construct(n,r||[],SG(e).constructor):n.apply(e,r))}function yG(e,n){if(n&&(rG(n)===`object`||typeof n==`function`))return n;if(n!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return bG(e)}function bG(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function xG(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(xG=function(){return!!e})()}function SG(e){return SG=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},SG(e)}function CG(e,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,`prototype`,{writable:!1}),n&&wG(e,n)}function wG(e,n){return wG=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e},wG(e,n)}function TG(e,n,r){return n=EG(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function EG(e){var n=DG(e,`string`);return rG(n)==`symbol`?n:n+``}function DG(e,n){if(rG(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(rG(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}var OG=function(e){function n(){var e;hG(this,n);var r=[...arguments];return e=vG(this,n,[].concat(r)),TG(e,`state`,{isAnimationFinished:!0,totalLength:0}),TG(e,`generateSimpleStrokeDasharray`,function(e,n){return`${n}px ${e-n}px`}),TG(e,`getStrokeDasharray`,function(r,i,a){var o=a.reduce(function(e,n){return e+n});if(!o)return e.generateSimpleStrokeDasharray(i,r);for(var s=Math.floor(r/o),c=r%o,l=i-r,u=[],d=0,f=0;d<a.length;f+=a[d],++d)if(f+a[d]>c){u=[].concat(lG(a.slice(0,d)),[c-f]);break}var p=u.length%2==0?[0,l]:[l];return[].concat(lG(n.repeat(a,s)),lG(u),p).map(function(e){return`${e}px`}).join(`, `)}),TG(e,`id`,Rx(`recharts-line-`)),TG(e,`pathRef`,function(n){e.mainCurve=n}),TG(e,`handleAnimationEnd`,function(){e.setState({isAnimationFinished:!0}),e.props.onAnimationEnd&&e.props.onAnimationEnd()}),TG(e,`handleAnimationStart`,function(){e.setState({isAnimationFinished:!1}),e.props.onAnimationStart&&e.props.onAnimationStart()}),e}return CG(n,e),_G(n,[{key:`componentDidMount`,value:function(){if(this.props.isAnimationActive){var e=this.getTotalLength();this.setState({totalLength:e})}}},{key:`componentDidUpdate`,value:function(){if(this.props.isAnimationActive){var e=this.getTotalLength();e!==this.state.totalLength&&this.setState({totalLength:e})}}},{key:`getTotalLength`,value:function(){var e=this.mainCurve;try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}},{key:`renderErrorBar`,value:function(e,n){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var r=this.props,i=r.points,a=r.xAxis,o=r.yAxis,s=r.layout,c=r.children,l=mS(c,aF);if(!l)return null;var u=function(e,n){return{x:e.x,y:e.y,value:e.value,errorVal:yF(e.payload,n)}},d={clipPath:e?`url(#clipPath-${n})`:null};return y.createElement(IS,d,l.map(function(e){return y.cloneElement(e,{key:`bar-${e.props.dataKey}`,data:i,xAxis:a,yAxis:o,layout:s,dataPointFormatter:u})}))}},{key:`renderDots`,value:function(e,r,i){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var a=this.props,o=a.dot,s=a.points,c=a.dataKey,l=xS(this.props,!1),u=xS(o,!0),d=s.map(function(e,r){var i=cG(cG(cG({key:`dot-${r}`,r:3},l),u),{},{index:r,cx:e.x,cy:e.y,value:e.value,dataKey:c,payload:e.payload,points:s});return n.renderDotItem(o,i)}),f={clipPath:e?`url(#clipPath-${r?``:`dots-`}${i})`:null};return y.createElement(IS,oG({className:`recharts-line-dots`,key:`dots`},f),d)}},{key:`renderCurveStatically`,value:function(e,n,r,i){var a=this.props,o=a.type,s=a.layout,c=a.connectNulls;a.ref;var l=cG(cG(cG({},xS(iG(a,tG),!0)),{},{fill:`none`,className:`recharts-line-curve`,clipPath:n?`url(#clipPath-${r})`:null,points:e},i),{},{type:o,layout:s,connectNulls:c});return y.createElement(DI,oG({},l,{pathRef:this.pathRef}))}},{key:`renderCurveWithAnimation`,value:function(e,n){var r=this,i=this.props,a=i.points,o=i.strokeDasharray,s=i.isAnimationActive,c=i.animationBegin,l=i.animationDuration,u=i.animationEasing,d=i.animationId,f=i.animateNewValues,p=i.width,m=i.height,h=this.state,g=h.prevPoints,_=h.totalLength;return y.createElement(PL,{begin:c,duration:l,isActive:s,easing:u,from:{t:0},to:{t:1},key:`line-${d}`,onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(i){var s=i.t;if(g){var c=g.length/a.length,l=a.map(function(e,n){var r=Math.floor(n*c);if(g[r]){var i=g[r],a=Hx(i.x,e.x),o=Hx(i.y,e.y);return cG(cG({},e),{},{x:a(s),y:o(s)})}if(f){var l=Hx(p*2,e.x),u=Hx(m/2,e.y);return cG(cG({},e),{},{x:l(s),y:u(s)})}return cG(cG({},e),{},{x:e.x,y:e.y})});return r.renderCurveStatically(l,e,n)}var u=Hx(0,_)(s),d;if(o){var h=`${o}`.split(/[,\s]+/gim).map(function(e){return parseFloat(e)});d=r.getStrokeDasharray(u,_,h)}else d=r.generateSimpleStrokeDasharray(_,u);return r.renderCurveStatically(a,e,n,{strokeDasharray:d})})}},{key:`renderCurve`,value:function(e,n){var r=this.props,i=r.points,a=r.isAnimationActive,o=this.state,s=o.prevPoints,c=o.totalLength;return a&&i&&i.length&&(!s&&c>0||!(0,fF.default)(s,i))?this.renderCurveWithAnimation(e,n):this.renderCurveStatically(i,e,n)}},{key:`render`,value:function(){var e=this.props,n=e.hide,r=e.dot,i=e.points,a=e.className,o=e.xAxis,s=e.yAxis,c=e.top,l=e.left,u=e.width,d=e.height,f=e.isAnimationActive,p=e.id;if(n||!i||!i.length)return null;var m=this.state.isAnimationFinished,h=i.length===1,g=Zd(`recharts-line`,a),_=o&&o.allowDataOverflow,v=s&&s.allowDataOverflow,b=_||v,x=(0,Mx.default)(p)?this.id:p,S=xS(r,!1)??{r:3,strokeWidth:2},C=S.r,w=C===void 0?3:C,T=S.strokeWidth,E=T===void 0?2:T,D=(yS(r)?r:{}).clipDot,O=D===void 0?!0:D,k=w*2+E;return y.createElement(IS,{className:g},_||v?y.createElement(`defs`,null,y.createElement(`clipPath`,{id:`clipPath-${x}`},y.createElement(`rect`,{x:_?l:l-u/2,y:v?c:c-d/2,width:_?u:u*2,height:v?d:d*2})),!O&&y.createElement(`clipPath`,{id:`clipPath-dots-${x}`},y.createElement(`rect`,{x:l-k/2,y:c-k/2,width:u+k,height:d+k}))):null,!h&&this.renderCurve(b,x),this.renderErrorBar(b,x),(h||r)&&this.renderDots(b,O,x),(!f||m)&&dI.renderCallByParent(this.props,i))}}],[{key:`getDerivedStateFromProps`,value:function(e,n){return e.animationId===n.prevAnimationId?e.points===n.curPoints?null:{curPoints:e.points}:{prevAnimationId:e.animationId,curPoints:e.points,prevPoints:n.curPoints}}},{key:`repeat`,value:function(e,n){for(var r=e.length%2==0?e:[].concat(lG(e),[0]),i=[],a=0;a<n;++a)i=[].concat(lG(i),lG(r));return i}},{key:`renderDotItem`,value:function(e,n){var r;if(y.isValidElement(e))r=y.cloneElement(e,n);else if((0,nS.default)(e))r=e(n);else{var i=n.key,a=iG(n,nG),o=Zd(`recharts-line-dot`,typeof e==`boolean`?``:e.className);r=y.createElement(mR,oG({key:i},a,{className:o}))}return r}}])}(y.PureComponent);TG(OG,`displayName`,`Line`),TG(OG,`defaultProps`,{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,fill:`#fff`,points:[],isAnimationActive:!SE.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,hide:!1,label:!1}),TG(OG,`getComposedData`,function(e){var n=e.props,r=e.xAxis,i=e.yAxis,a=e.xAxisTicks,o=e.yAxisTicks,s=e.dataKey,c=e.bandSize,l=e.displayedData,u=e.offset,d=n.layout;return cG({points:l.map(function(e,n){var l=yF(e,s);return d===`horizontal`?{x:NF({axis:r,ticks:a,bandSize:c,entry:e,index:n}),y:(0,Mx.default)(l)?null:i.scale(l),value:l,payload:e}:{x:(0,Mx.default)(l)?null:r.scale(l),y:NF({axis:i,ticks:o,bandSize:c,entry:e,index:n}),value:l,payload:e}}),layout:d},u)});var kG=[`layout`,`type`,`stroke`,`connectNulls`,`isRange`,`ref`],AG=[`key`],jG;function MG(e){"@babel/helpers - typeof";return MG=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},MG(e)}function NG(e,n){if(e==null)return{};var r=PG(e,n),i,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)i=o[a],!(n.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function PG(e,n){if(e==null)return{};var r={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){if(n.indexOf(i)>=0)continue;r[i]=e[i]}return r}function FG(){return FG=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},FG.apply(this,arguments)}function IG(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function LG(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]==null?{}:arguments[n];n%2?IG(Object(r),!0).forEach(function(n){JG(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):IG(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function RG(e,n){if(!(e instanceof n))throw TypeError(`Cannot call a class as a function`)}function zG(e,n){for(var r=0;r<n.length;r++){var i=n[r];i.enumerable=i.enumerable||!1,i.configurable=!0,`value`in i&&(i.writable=!0),Object.defineProperty(e,YG(i.key),i)}}function BG(e,n,r){return n&&zG(e.prototype,n),r&&zG(e,r),Object.defineProperty(e,`prototype`,{writable:!1}),e}function VG(e,n,r){return n=GG(n),HG(e,WG()?Reflect.construct(n,r||[],GG(e).constructor):n.apply(e,r))}function HG(e,n){if(n&&(MG(n)===`object`||typeof n==`function`))return n;if(n!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return UG(e)}function UG(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function WG(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(WG=function(){return!!e})()}function GG(e){return GG=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},GG(e)}function KG(e,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,`prototype`,{writable:!1}),n&&qG(e,n)}function qG(e,n){return qG=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e},qG(e,n)}function JG(e,n,r){return n=YG(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function YG(e){var n=XG(e,`string`);return MG(n)==`symbol`?n:n+``}function XG(e,n){if(MG(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(MG(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}var ZG=function(e){function n(){var e;RG(this,n);var r=[...arguments];return e=VG(this,n,[].concat(r)),JG(e,`state`,{isAnimationFinished:!0}),JG(e,`id`,Rx(`recharts-area-`)),JG(e,`handleAnimationEnd`,function(){var n=e.props.onAnimationEnd;e.setState({isAnimationFinished:!0}),(0,nS.default)(n)&&n()}),JG(e,`handleAnimationStart`,function(){var n=e.props.onAnimationStart;e.setState({isAnimationFinished:!1}),(0,nS.default)(n)&&n()}),e}return KG(n,e),BG(n,[{key:`renderDots`,value:function(e,r,i){var a=this.props.isAnimationActive,o=this.state.isAnimationFinished;if(a&&!o)return null;var s=this.props,c=s.dot,l=s.points,u=s.dataKey,d=xS(this.props,!1),f=xS(c,!0),p=l.map(function(e,r){var i=LG(LG(LG({key:`dot-${r}`,r:3},d),f),{},{index:r,cx:e.x,cy:e.y,dataKey:u,value:e.value,payload:e.payload,points:l});return n.renderDotItem(c,i)}),m={clipPath:e?`url(#clipPath-${r?``:`dots-`}${i})`:null};return y.createElement(IS,FG({className:`recharts-area-dots`},m),p)}},{key:`renderHorizontalRect`,value:function(e){var n=this.props,r=n.baseLine,i=n.points,a=n.strokeWidth,o=i[0].x,s=i[i.length-1].x,c=e*Math.abs(o-s),l=(0,uF.default)(i.map(function(e){return e.y||0}));return Y(r)&&typeof r==`number`?l=Math.max(r,l):r&&Array.isArray(r)&&r.length&&(l=Math.max((0,uF.default)(r.map(function(e){return e.y||0})),l)),Y(l)?y.createElement(`rect`,{x:o<s?o:o-c,y:0,width:c,height:Math.floor(l+(a?parseInt(`${a}`,10):1))}):null}},{key:`renderVerticalRect`,value:function(e){var n=this.props,r=n.baseLine,i=n.points,a=n.strokeWidth,o=i[0].y,s=i[i.length-1].y,c=e*Math.abs(o-s),l=(0,uF.default)(i.map(function(e){return e.x||0}));return Y(r)&&typeof r==`number`?l=Math.max(r,l):r&&Array.isArray(r)&&r.length&&(l=Math.max((0,uF.default)(r.map(function(e){return e.x||0})),l)),Y(l)?y.createElement(`rect`,{x:0,y:o<s?o:o-c,width:l+(a?parseInt(`${a}`,10):1),height:Math.floor(c)}):null}},{key:`renderClipRect`,value:function(e){return this.props.layout===`vertical`?this.renderVerticalRect(e):this.renderHorizontalRect(e)}},{key:`renderAreaStatically`,value:function(e,n,r,i){var a=this.props,o=a.layout,s=a.type,c=a.stroke,l=a.connectNulls,u=a.isRange;a.ref;var d=NG(a,kG);return y.createElement(IS,{clipPath:r?`url(#clipPath-${i})`:null},y.createElement(DI,FG({},xS(d,!0),{points:e,connectNulls:l,type:s,baseLine:n,layout:o,stroke:`none`,className:`recharts-area-area`})),c!==`none`&&y.createElement(DI,FG({},xS(this.props,!1),{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:e})),c!==`none`&&u&&y.createElement(DI,FG({},xS(this.props,!1),{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:n})))}},{key:`renderAreaWithAnimation`,value:function(e,n){var r=this,i=this.props,a=i.points,o=i.baseLine,s=i.isAnimationActive,c=i.animationBegin,l=i.animationDuration,u=i.animationEasing,d=i.animationId,f=this.state,p=f.prevPoints,m=f.prevBaseLine;return y.createElement(PL,{begin:c,duration:l,isActive:s,easing:u,from:{t:0},to:{t:1},key:`area-${d}`,onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(i){var s=i.t;if(p){var c=p.length/a.length,l=a.map(function(e,n){var r=Math.floor(n*c);if(p[r]){var i=p[r],a=Hx(i.x,e.x),o=Hx(i.y,e.y);return LG(LG({},e),{},{x:a(s),y:o(s)})}return e}),u=Y(o)&&typeof o==`number`?Hx(m,o)(s):(0,Mx.default)(o)||(0,kx.default)(o)?Hx(m,0)(s):o.map(function(e,n){var r=Math.floor(n*c);if(m[r]){var i=m[r],a=Hx(i.x,e.x),o=Hx(i.y,e.y);return LG(LG({},e),{},{x:a(s),y:o(s)})}return e});return r.renderAreaStatically(l,u,e,n)}return y.createElement(IS,null,y.createElement(`defs`,null,y.createElement(`clipPath`,{id:`animationClipPath-${n}`},r.renderClipRect(s))),y.createElement(IS,{clipPath:`url(#animationClipPath-${n})`},r.renderAreaStatically(a,o,e,n)))})}},{key:`renderArea`,value:function(e,n){var r=this.props,i=r.points,a=r.baseLine,o=r.isAnimationActive,s=this.state,c=s.prevPoints,l=s.prevBaseLine,u=s.totalLength;return o&&i&&i.length&&(!c&&u>0||!(0,fF.default)(c,i)||!(0,fF.default)(l,a))?this.renderAreaWithAnimation(e,n):this.renderAreaStatically(i,a,e,n)}},{key:`render`,value:function(){var e=this.props,n=e.hide,r=e.dot,i=e.points,a=e.className,o=e.top,s=e.left,c=e.xAxis,l=e.yAxis,u=e.width,d=e.height,f=e.isAnimationActive,p=e.id;if(n||!i||!i.length)return null;var m=this.state.isAnimationFinished,h=i.length===1,g=Zd(`recharts-area`,a),_=c&&c.allowDataOverflow,v=l&&l.allowDataOverflow,b=_||v,x=(0,Mx.default)(p)?this.id:p,S=xS(r,!1)??{r:3,strokeWidth:2},C=S.r,w=C===void 0?3:C,T=S.strokeWidth,E=T===void 0?2:T,D=(yS(r)?r:{}).clipDot,O=D===void 0?!0:D,k=w*2+E;return y.createElement(IS,{className:g},_||v?y.createElement(`defs`,null,y.createElement(`clipPath`,{id:`clipPath-${x}`},y.createElement(`rect`,{x:_?s:s-u/2,y:v?o:o-d/2,width:_?u:u*2,height:v?d:d*2})),!O&&y.createElement(`clipPath`,{id:`clipPath-dots-${x}`},y.createElement(`rect`,{x:s-k/2,y:o-k/2,width:u+k,height:d+k}))):null,h?null:this.renderArea(b,x),(r||h)&&this.renderDots(b,O,x),(!f||m)&&dI.renderCallByParent(this.props,i))}}],[{key:`getDerivedStateFromProps`,value:function(e,n){return e.animationId===n.prevAnimationId?e.points!==n.curPoints||e.baseLine!==n.curBaseLine?{curPoints:e.points,curBaseLine:e.baseLine}:null:{prevAnimationId:e.animationId,curPoints:e.points,curBaseLine:e.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}}}])}(y.PureComponent);jG=ZG,JG(ZG,`displayName`,`Area`),JG(ZG,`defaultProps`,{stroke:`#3182bd`,fill:`#3182bd`,fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:`line`,connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!SE.isSsr,animationBegin:0,animationDuration:1500,animationEasing:`ease`}),JG(ZG,`getBaseValue`,function(e,n,r,i){var a=e.layout,o=e.baseValue,s=n.props.baseValue??o;if(Y(s)&&typeof s==`number`)return s;var c=a===`horizontal`?i:r,l=c.scale.domain();if(c.type===`number`){var u=Math.max(l[0],l[1]),d=Math.min(l[0],l[1]);return s===`dataMin`?d:s===`dataMax`||u<0?u:Math.max(Math.min(l[0],l[1]),0)}return s===`dataMin`?l[0]:s===`dataMax`?l[1]:l[0]}),JG(ZG,`getComposedData`,function(e){var n=e.props,r=e.item,i=e.xAxis,a=e.yAxis,o=e.xAxisTicks,s=e.yAxisTicks,c=e.bandSize,l=e.dataKey,u=e.stackedData,d=e.dataStartIndex,f=e.displayedData,p=e.offset,m=n.layout,h=u&&u.length,g=jG.getBaseValue(n,r,i,a),_=m===`horizontal`,v=!1,y=f.map(function(e,n){var r;h?r=u[d+n]:(r=yF(e,l),Array.isArray(r)?v=!0:r=[g,r]);var f=r[1]==null||h&&yF(e,l)==null;return _?{x:NF({axis:i,ticks:o,bandSize:c,entry:e,index:n}),y:f?null:a.scale(r[1]),value:r,payload:e}:{x:f?null:i.scale(r[1]),y:NF({axis:a,ticks:s,bandSize:c,entry:e,index:n}),value:r,payload:e}});return LG({points:y,baseLine:h||v?y.map(function(e){var n=Array.isArray(e.value)?e.value[0]:null;return _?{x:e.x,y:n!=null&&e.y!=null?a.scale(n):null}:{x:n==null?null:i.scale(n),y:e.y}}):_?a.scale(g):i.scale(g),layout:m,isRange:v},p)}),JG(ZG,`renderDotItem`,function(e,n){var r;if(y.isValidElement(e))r=y.cloneElement(e,n);else if((0,nS.default)(e))r=e(n);else{var i=Zd(`recharts-area-dot`,typeof e==`boolean`?``:e.className),a=n.key,o=NG(n,AG);r=y.createElement(mR,FG({},o,{key:a,className:i}))}return r});function QG(e){"@babel/helpers - typeof";return QG=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},QG(e)}function $G(e,n){if(!(e instanceof n))throw TypeError(`Cannot call a class as a function`)}function eK(e,n){for(var r=0;r<n.length;r++){var i=n[r];i.enumerable=i.enumerable||!1,i.configurable=!0,`value`in i&&(i.writable=!0),Object.defineProperty(e,uK(i.key),i)}}function tK(e,n,r){return n&&eK(e.prototype,n),r&&eK(e,r),Object.defineProperty(e,`prototype`,{writable:!1}),e}function nK(e,n,r){return n=oK(n),rK(e,aK()?Reflect.construct(n,r||[],oK(e).constructor):n.apply(e,r))}function rK(e,n){if(n&&(QG(n)===`object`||typeof n==`function`))return n;if(n!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return iK(e)}function iK(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function aK(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(aK=function(){return!!e})()}function oK(e){return oK=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},oK(e)}function sK(e,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,`prototype`,{writable:!1}),n&&cK(e,n)}function cK(e,n){return cK=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e},cK(e,n)}function lK(e,n,r){return n=uK(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function uK(e){var n=dK(e,`string`);return QG(n)==`symbol`?n:n+``}function dK(e,n){if(QG(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(QG(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function fK(){return fK=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},fK.apply(this,arguments)}function pK(e){var n=e.xAxisId,r=IH(),i=LH(),a=AH(n);return a==null?null:y.createElement(NW,fK({},a,{className:Zd(`recharts-${a.axisType} ${a.axisType}`,a.className),viewBox:{x:0,y:0,width:r,height:i},ticksGenerator:function(e){return EF(e,!0)}}))}var mK=function(e){function n(){return $G(this,n),nK(this,n,arguments)}return sK(n,e),tK(n,[{key:`render`,value:function(){return y.createElement(pK,this.props)}}])}(y.Component);lK(mK,`displayName`,`XAxis`),lK(mK,`defaultProps`,{allowDecimals:!0,hide:!1,orientation:`bottom`,width:0,height:30,mirror:!1,xAxisId:0,tickCount:5,type:`category`,padding:{left:0,right:0},allowDataOverflow:!1,scale:`auto`,reversed:!1,allowDuplicatedCategory:!0});function hK(e){"@babel/helpers - typeof";return hK=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},hK(e)}function gK(e,n){if(!(e instanceof n))throw TypeError(`Cannot call a class as a function`)}function _K(e,n){for(var r=0;r<n.length;r++){var i=n[r];i.enumerable=i.enumerable||!1,i.configurable=!0,`value`in i&&(i.writable=!0),Object.defineProperty(e,DK(i.key),i)}}function vK(e,n,r){return n&&_K(e.prototype,n),r&&_K(e,r),Object.defineProperty(e,`prototype`,{writable:!1}),e}function yK(e,n,r){return n=CK(n),bK(e,SK()?Reflect.construct(n,r||[],CK(e).constructor):n.apply(e,r))}function bK(e,n){if(n&&(hK(n)===`object`||typeof n==`function`))return n;if(n!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return xK(e)}function xK(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function SK(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(SK=function(){return!!e})()}function CK(e){return CK=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},CK(e)}function wK(e,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,`prototype`,{writable:!1}),n&&TK(e,n)}function TK(e,n){return TK=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e},TK(e,n)}function EK(e,n,r){return n=DK(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function DK(e){var n=OK(e,`string`);return hK(n)==`symbol`?n:n+``}function OK(e,n){if(hK(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(hK(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function kK(){return kK=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},kK.apply(this,arguments)}var AK=function(e){var n=e.yAxisId,r=IH(),i=LH(),a=NH(n);return a==null?null:y.createElement(NW,kK({},a,{className:Zd(`recharts-${a.axisType} ${a.axisType}`,a.className),viewBox:{x:0,y:0,width:r,height:i},ticksGenerator:function(e){return EF(e,!0)}}))},jK=function(e){function n(){return gK(this,n),yK(this,n,arguments)}return wK(n,e),vK(n,[{key:`render`,value:function(){return y.createElement(AK,this.props)}}])}(y.Component);EK(jK,`displayName`,`YAxis`),EK(jK,`defaultProps`,{allowDuplicatedCategory:!0,allowDecimals:!0,hide:!1,orientation:`left`,width:60,height:0,mirror:!1,yAxisId:0,tickCount:5,type:`number`,padding:{top:0,bottom:0},allowDataOverflow:!1,scale:`auto`,reversed:!1});function MK(e){return IK(e)||FK(e)||PK(e)||NK()}function NK(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
81
81
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function PK(e,n){if(e){if(typeof e==`string`)return LK(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`)return Array.from(e);if(r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return LK(e,n)}}function FK(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function IK(e){if(Array.isArray(e))return LK(e)}function LK(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}var RK=function(e,n,r,i,a){var o=mS(e,dU),s=mS(e,AU),c=[].concat(MK(o),MK(s)),l=mS(e,YU),u=`${i}Id`,d=i[0],f=n;if(c.length&&(f=c.reduce(function(e,n){if(n.props[u]===r&&uV(n.props,`extendDomain`)&&Y(n.props[d])){var i=n.props[d];return[Math.min(e[0],i),Math.max(e[1],i)]}return e},f)),l.length){var p=`${d}1`,m=`${d}2`;f=l.reduce(function(e,n){if(n.props[u]===r&&uV(n.props,`extendDomain`)&&Y(n.props[p])&&Y(n.props[m])){var i=n.props[p],a=n.props[m];return[Math.min(e[0],i,a),Math.max(e[1],i,a)]}return e},f)}return a&&a.length&&(f=a.reduce(function(e,n){return Y(n)?[Math.min(e[0],n),Math.max(e[1],n)]:e},f)),f},zK=new(u(s(((e,n)=>{var r=Object.prototype.hasOwnProperty,i=`~`;function a(){}Object.create&&(a.prototype=Object.create(null),new a().__proto__||(i=!1));function o(e,n,r){this.fn=e,this.context=n,this.once=r||!1}function s(e,n,r,a,s){if(typeof r!=`function`)throw TypeError(`The listener must be a function`);var c=new o(r,a||e,s),l=i?i+n:n;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],c]:e._events[l].push(c):(e._events[l]=c,e._eventsCount++),e}function c(e,n){--e._eventsCount===0?e._events=new a:delete e._events[n]}function l(){this._events=new a,this._eventsCount=0}l.prototype.eventNames=function(){var e=[],n,a;if(this._eventsCount===0)return e;for(a in n=this._events)r.call(n,a)&&e.push(i?a.slice(1):a);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(n)):e},l.prototype.listeners=function(e){var n=i?i+e:e,r=this._events[n];if(!r)return[];if(r.fn)return[r.fn];for(var a=0,o=r.length,s=Array(o);a<o;a++)s[a]=r[a].fn;return s},l.prototype.listenerCount=function(e){var n=i?i+e:e,r=this._events[n];return r?r.fn?1:r.length:0},l.prototype.emit=function(e,n,r,a,o,s){var c=i?i+e:e;if(!this._events[c])return!1;var l=this._events[c],u=arguments.length,d,f;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),u){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,n),!0;case 3:return l.fn.call(l.context,n,r),!0;case 4:return l.fn.call(l.context,n,r,a),!0;case 5:return l.fn.call(l.context,n,r,a,o),!0;case 6:return l.fn.call(l.context,n,r,a,o,s),!0}for(f=1,d=Array(u-1);f<u;f++)d[f-1]=arguments[f];l.fn.apply(l.context,d)}else{var p=l.length,m;for(f=0;f<p;f++)switch(l[f].once&&this.removeListener(e,l[f].fn,void 0,!0),u){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,n);break;case 3:l[f].fn.call(l[f].context,n,r);break;case 4:l[f].fn.call(l[f].context,n,r,a);break;default:if(!d)for(m=1,d=Array(u-1);m<u;m++)d[m-1]=arguments[m];l[f].fn.apply(l[f].context,d)}}return!0},l.prototype.on=function(e,n,r){return s(this,e,n,r,!1)},l.prototype.once=function(e,n,r){return s(this,e,n,r,!0)},l.prototype.removeListener=function(e,n,r,a){var o=i?i+e:e;if(!this._events[o])return this;if(!n)return c(this,o),this;var s=this._events[o];if(s.fn)s.fn===n&&(!a||s.once)&&(!r||s.context===r)&&c(this,o);else{for(var l=0,u=[],d=s.length;l<d;l++)(s[l].fn!==n||a&&!s[l].once||r&&s[l].context!==r)&&u.push(s[l]);u.length?this._events[o]=u.length===1?u[0]:u:c(this,o)}return this},l.prototype.removeAllListeners=function(e){var n;return e?(n=i?i+e:e,this._events[n]&&c(this,n)):(this._events=new a,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=i,l.EventEmitter=l,n!==void 0&&(n.exports=l)}))())).default,BK=`recharts.syncMouseEvents`;function VK(e){"@babel/helpers - typeof";return VK=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},VK(e)}function HK(e,n){if(!(e instanceof n))throw TypeError(`Cannot call a class as a function`)}function UK(e,n){for(var r=0;r<n.length;r++){var i=n[r];i.enumerable=i.enumerable||!1,i.configurable=!0,`value`in i&&(i.writable=!0),Object.defineProperty(e,KK(i.key),i)}}function WK(e,n,r){return n&&UK(e.prototype,n),r&&UK(e,r),Object.defineProperty(e,`prototype`,{writable:!1}),e}function GK(e,n,r){return n=KK(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function KK(e){var n=qK(e,`string`);return VK(n)==`symbol`?n:n+``}function qK(e,n){if(VK(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(VK(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}var JK=function(){function e(){HK(this,e),GK(this,`activeIndex`,0),GK(this,`coordinateList`,[]),GK(this,`layout`,`horizontal`)}return WK(e,[{key:`setDetails`,value:function(e){var n=e.coordinateList,r=n===void 0?null:n,i=e.container,a=i===void 0?null:i,o=e.layout,s=o===void 0?null:o,c=e.offset,l=c===void 0?null:c,u=e.mouseHandlerCallback,d=u===void 0?null:u;this.coordinateList=r??this.coordinateList??[],this.container=a??this.container,this.layout=s??this.layout,this.offset=l??this.offset,this.mouseHandlerCallback=d??this.mouseHandlerCallback,this.activeIndex=Math.min(Math.max(this.activeIndex,0),this.coordinateList.length-1)}},{key:`focus`,value:function(){this.spoofMouse()}},{key:`keyboardEvent`,value:function(e){if(this.coordinateList.length!==0)switch(e.key){case`ArrowRight`:if(this.layout!==`horizontal`)return;this.activeIndex=Math.min(this.activeIndex+1,this.coordinateList.length-1),this.spoofMouse();break;case`ArrowLeft`:if(this.layout!==`horizontal`)return;this.activeIndex=Math.max(this.activeIndex-1,0),this.spoofMouse();break;default:break}}},{key:`setIndex`,value:function(e){this.activeIndex=e}},{key:`spoofMouse`,value:function(){if(this.layout===`horizontal`&&this.coordinateList.length!==0){var e=this.container.getBoundingClientRect(),n=e.x,r=e.y,i=e.height,a=this.coordinateList[this.activeIndex].coordinate,o=window?.scrollX||0,s=window?.scrollY||0,c=n+a+o,l=r+this.offset.top+i/2+s;this.mouseHandlerCallback({pageX:c,pageY:l})}}}])}();function YK(e,n,r){if(r===`number`&&n===!0&&Array.isArray(e)){var i=e?.[0],a=e?.[1];if(i&&a&&Y(i)&&Y(a))return!0}return!1}function XK(e,n,r,i){var a=i/2;return{stroke:`none`,fill:`#ccc`,x:e===`horizontal`?n.x-a:r.left+.5,y:e===`horizontal`?r.top+.5:n.y-a,width:e===`horizontal`?i:r.width-1,height:e===`horizontal`?r.height-1:i}}function ZK(e){var n=e.cx,r=e.cy,i=e.radius,a=e.startAngle,o=e.endAngle;return{points:[JF(n,r,i,a),JF(n,r,i,o)],cx:n,cy:r,radius:i,startAngle:a,endAngle:o}}function QK(e,n,r){var i,a,o,s;if(e===`horizontal`)i=n.x,o=i,a=r.top,s=r.top+r.height;else if(e===`vertical`)a=n.y,s=a,i=r.left,o=r.left+r.width;else if(n.cx!=null&&n.cy!=null)if(e===`centric`){var c=n.cx,l=n.cy,u=n.innerRadius,d=n.outerRadius,f=n.angle,p=JF(c,l,u,f),m=JF(c,l,d,f);i=p.x,a=p.y,o=m.x,s=m.y}else return ZK(n);return[{x:i,y:a},{x:o,y:s}]}function $K(e){"@babel/helpers - typeof";return $K=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},$K(e)}function eq(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function tq(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]==null?{}:arguments[n];n%2?eq(Object(r),!0).forEach(function(n){nq(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):eq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function nq(e,n,r){return n=rq(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function rq(e){var n=iq(e,`string`);return $K(n)==`symbol`?n:n+``}function iq(e,n){if($K(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if($K(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function aq(e){var n=e.element,r=e.tooltipEventType,i=e.isActive,a=e.activeCoordinate,o=e.activePayload,s=e.offset,c=e.activeTooltipIndex,l=e.tooltipAxisBandSize,u=e.layout,d=e.chartName,f=n.props.cursor??n.type.defaultProps?.cursor;if(!n||!f||!i||!a||d!==`ScatterChart`&&r!==`axis`)return null;var p,m=DI;if(d===`ScatterChart`)p=a,m=ER;else if(d===`BarChart`)p=XK(u,a,s,l),m=ZL;else if(u===`radial`){var h=ZK(a),g=h.cx,_=h.cy,v=h.radius;p={cx:g,cy:_,startAngle:h.startAngle,endAngle:h.endAngle,innerRadius:v,outerRadius:v},m=vI}else p={points:QK(u,a,s)},m=DI;var b=tq(tq(tq(tq({stroke:`#ccc`,pointerEvents:`none`},s),p),xS(f,!1)),{},{payload:o,payloadIndex:c,className:Zd(`recharts-tooltip-cursor`,f.className)});return(0,y.isValidElement)(f)?(0,y.cloneElement)(f,b):(0,y.createElement)(m,b)}var oq=[`item`],sq=[`children`,`className`,`width`,`height`,`style`,`compact`,`title`,`desc`];function cq(e){"@babel/helpers - typeof";return cq=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},cq(e)}function lq(){return lq=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},lq.apply(this,arguments)}function uq(e,n){return pq(e)||fq(e,n)||Oq(e,n)||dq()}function dq(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
82
82
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fq(e,n){var r=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(r!=null){var i,a,o,s,c=[],l=!0,u=!1;try{if(o=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=o.call(r)).done)&&(c.push(i.value),c.length!==n);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw a}}return c}}function pq(e){if(Array.isArray(e))return e}function mq(e,n){if(e==null)return{};var r=hq(e,n),i,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)i=o[a],!(n.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function hq(e,n){if(e==null)return{};var r={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){if(n.indexOf(i)>=0)continue;r[i]=e[i]}return r}function gq(e,n){if(!(e instanceof n))throw TypeError(`Cannot call a class as a function`)}function _q(e,n){for(var r=0;r<n.length;r++){var i=n[r];i.enumerable=i.enumerable||!1,i.configurable=!0,`value`in i&&(i.writable=!0),Object.defineProperty(e,Pq(i.key),i)}}function vq(e,n,r){return n&&_q(e.prototype,n),r&&_q(e,r),Object.defineProperty(e,`prototype`,{writable:!1}),e}function yq(e,n,r){return n=Cq(n),bq(e,Sq()?Reflect.construct(n,r||[],Cq(e).constructor):n.apply(e,r))}function bq(e,n){if(n&&(cq(n)===`object`||typeof n==`function`))return n;if(n!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return xq(e)}function xq(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function Sq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Sq=function(){return!!e})()}function Cq(e){return Cq=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Cq(e)}function wq(e,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,`prototype`,{writable:!1}),n&&Tq(e,n)}function Tq(e,n){return Tq=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e},Tq(e,n)}function Eq(e){return Aq(e)||kq(e)||Oq(e)||Dq()}function Dq(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
83
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oq(e,n){if(e){if(typeof e==`string`)return jq(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`)return Array.from(e);if(r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return jq(e,n)}}function kq(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Aq(e){if(Array.isArray(e))return jq(e)}function jq(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function Mq(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function Z(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]==null?{}:arguments[n];n%2?Mq(Object(r),!0).forEach(function(n){Nq(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Mq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Nq(e,n,r){return n=Pq(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function Pq(e){var n=Fq(e,`string`);return cq(n)==`symbol`?n:n+``}function Fq(e,n){if(cq(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(cq(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}var Iq={xAxis:[`bottom`,`top`],yAxis:[`left`,`right`]},Lq={width:`100%`,height:`100%`},Rq={x:0,y:0};function zq(e){return e}var Bq=function(e,n){return n===`horizontal`?e.x:n===`vertical`?e.y:n===`centric`?e.angle:e.radius},Vq=function(e,n,r,i){var a=n.find(function(e){return e&&e.index===r});if(a){if(e===`horizontal`)return{x:a.coordinate,y:i.y};if(e===`vertical`)return{x:i.x,y:a.coordinate};if(e===`centric`){var o=a.coordinate,s=i.radius;return Z(Z(Z({},i),JF(i.cx,i.cy,s,o)),{},{angle:o,radius:s})}var c=a.coordinate,l=i.angle;return Z(Z(Z({},i),JF(i.cx,i.cy,c,l)),{},{angle:l,radius:c})}return Rq},Hq=function(e,n){var r=n.graphicalItems,i=n.dataStartIndex,a=n.dataEndIndex,o=(r??[]).reduce(function(e,n){var r=n.props.data;return r&&r.length?[].concat(Eq(e),Eq(r)):e},[]);return o.length>0?o:e&&e.length&&Y(i)&&Y(a)?e.slice(i,a+1):[]};function Uq(e){return e===`number`?[0,`auto`]:void 0}var Wq=function(e,n,r,i){var a=e.graphicalItems,o=e.tooltipAxis,s=Hq(n,e);return r<0||!a||!a.length||r>=s.length?null:a.reduce(function(a,c){var l=c.props.data??n;l&&e.dataStartIndex+e.dataEndIndex!==0&&e.dataEndIndex-e.dataStartIndex>=r&&(l=l.slice(e.dataStartIndex,e.dataEndIndex+1));var u=o.dataKey&&!o.allowDuplicatedCategory?Ux(l===void 0?s:l,o.dataKey,i):l&&l[r]||s[r];return u?[].concat(Eq(a),[VF(c,u)]):a},[])},Gq=function(e,n,r,i){var a=i||{x:e.chartX,y:e.chartY},o=Bq(a,r),s=e.orderedTooltipTicks,c=e.tooltipAxis,l=e.tooltipTicks,u=rre(o,s,l,c);if(u>=0&&l){var d=l[u]&&l[u].value;return{activeTooltipIndex:u,activeLabel:d,activePayload:Wq(e,n,u,d),activeCoordinate:Vq(r,s,u,a)}}return null},Kq=function(e,n){var r=n.axes,i=n.graphicalItems,a=n.axisType,o=n.axisIdKey,s=n.stackGroups,c=n.dataStartIndex,l=n.dataEndIndex,u=e.layout,d=e.children,f=e.stackOffset,p=wF(u,a);return r.reduce(function(n,r){var m=r.type.defaultProps===void 0?r.props:Z(Z({},r.type.defaultProps),r.props),h=m.type,g=m.dataKey,_=m.allowDataOverflow,v=m.allowDuplicatedCategory,y=m.scale,b=m.ticks,x=m.includeHidden,S=m[o];if(n[S])return n;var C=Hq(e.data,{graphicalItems:i.filter(function(e){return(o in e.props?e.props[o]:e.type.defaultProps?.[o])===S}),dataStartIndex:c,dataEndIndex:l}),w=C.length,T,E,D;YK(m.domain,_,h)&&(T=RF(m.domain,null,_),p&&(h===`number`||y!==`auto`)&&(D=bF(C,g,`category`)));var O=Uq(h);if(!T||T.length===0){var k=m.domain??O;if(g){if(T=bF(C,g,h),h===`category`&&p){var A=Vx(T);v&&A?(E=T,T=(0,VB.default)(0,w)):v||(T=BF(k,T,r).reduce(function(e,n){return e.indexOf(n)>=0?e:[].concat(Eq(e),[n])},[]))}else if(h===`category`)T=v?T.filter(function(e){return e!==``&&!(0,Mx.default)(e)}):BF(k,T,r).reduce(function(e,n){return e.indexOf(n)>=0||n===``||(0,Mx.default)(n)?e:[].concat(Eq(e),[n])},[]);else if(h===`number`){var j=cre(C,i.filter(function(e){var n=o in e.props?e.props[o]:e.type.defaultProps?.[o],r=`hide`in e.props?e.props.hide:e.type.defaultProps?.hide;return n===S&&(x||!r)}),g,a,u);j&&(T=j)}p&&(h===`number`||y!==`auto`)&&(D=bF(C,g,`category`))}else T=p?(0,VB.default)(0,w):s&&s[S]&&s[S].hasStack&&h===`number`?f===`expand`?[0,1]:FF(s[S].stackGroups,c,l):CF(C,i.filter(function(e){var n=o in e.props?e.props[o]:e.type.defaultProps[o],r=`hide`in e.props?e.props.hide:e.type.defaultProps.hide;return n===S&&(x||!r)}),h,u,!0);if(h===`number`)T=RK(d,T,S,a,b),k&&(T=RF(k,T,_));else if(h===`category`&&k){var M=k;T.every(function(e){return M.indexOf(e)>=0})&&(T=M)}}return Z(Z({},n),{},Nq({},S,Z(Z({},m),{},{axisType:a,domain:T,categoricalDomain:D,duplicateDomain:E,originalDomain:m.domain??O,isCategorical:p,layout:u})))},{})},qq=function(e,n){var r=n.graphicalItems,i=n.Axis,a=n.axisType,o=n.axisIdKey,s=n.stackGroups,c=n.dataStartIndex,l=n.dataEndIndex,u=e.layout,d=e.children,f=Hq(e.data,{graphicalItems:r,dataStartIndex:c,dataEndIndex:l}),p=f.length,m=wF(u,a),h=-1;return r.reduce(function(e,n){var g=(n.type.defaultProps===void 0?n.props:Z(Z({},n.type.defaultProps),n.props))[o],_=Uq(`number`);if(!e[g]){h++;var v;return m?v=(0,VB.default)(0,p):s&&s[g]&&s[g].hasStack?(v=FF(s[g].stackGroups,c,l),v=RK(d,v,g,a)):(v=RF(_,CF(f,r.filter(function(e){var n=o in e.props?e.props[o]:e.type.defaultProps?.[o],r=`hide`in e.props?e.props.hide:e.type.defaultProps?.hide;return n===g&&!r}),`number`,u),i.defaultProps.allowDataOverflow),v=RK(d,v,g,a)),Z(Z({},e),{},Nq({},g,Z(Z({axisType:a},i.defaultProps),{},{hide:!0,orientation:(0,Ax.default)(Iq,`${a}.${h%2}`,null),domain:v,originalDomain:_,isCategorical:m,layout:u})))}return e},{})},Jq=function(e,n){var r=n.axisType,i=r===void 0?`xAxis`:r,a=n.AxisComp,o=n.graphicalItems,s=n.stackGroups,c=n.dataStartIndex,l=n.dataEndIndex,u=e.children,d=`${i}Id`,f=mS(u,a),p={};return f&&f.length?p=Kq(e,{axes:f,graphicalItems:o,axisType:i,axisIdKey:d,stackGroups:s,dataStartIndex:c,dataEndIndex:l}):o&&o.length&&(p=qq(e,{Axis:a,graphicalItems:o,axisType:i,axisIdKey:d,stackGroups:s,dataStartIndex:c,dataEndIndex:l})),p},Yq=function(e){var n=Bx(e),r=EF(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:(0,HT.default)(r,function(e){return e.coordinate}),tooltipAxis:n,tooltipAxisBandSize:zF(n,r)}},Xq=function(e){var n=e.children,r=e.defaultShowTooltip,i=hS(n,sV),a=0,o=0;return e.data&&e.data.length!==0&&(o=e.data.length-1),i&&i.props&&(i.props.startIndex>=0&&(a=i.props.startIndex),i.props.endIndex>=0&&(o=i.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:a,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!r}},Zq=function(e){return!e||!e.length?!1:e.some(function(e){var n=uS(e&&e.type);return n&&n.indexOf(`Bar`)>=0})},Qq=function(e){return e===`horizontal`?{numericAxisName:`yAxis`,cateAxisName:`xAxis`}:e===`vertical`?{numericAxisName:`xAxis`,cateAxisName:`yAxis`}:e===`centric`?{numericAxisName:`radiusAxis`,cateAxisName:`angleAxis`}:{numericAxisName:`angleAxis`,cateAxisName:`radiusAxis`}},$q=function(e,n){var r=e.props,i=e.graphicalItems,a=e.xAxisMap,o=a===void 0?{}:a,s=e.yAxisMap,c=s===void 0?{}:s,l=r.width,u=r.height,d=r.children,f=r.margin||{},p=hS(d,sV),m=hS(d,FT),h=Object.keys(c).reduce(function(e,n){var r=c[n],i=r.orientation;return!r.mirror&&!r.hide?Z(Z({},e),{},Nq({},i,e[i]+r.width)):e},{left:f.left||0,right:f.right||0}),g=Z(Z({},Object.keys(o).reduce(function(e,n){var r=o[n],i=r.orientation;return!r.mirror&&!r.hide?Z(Z({},e),{},Nq({},i,(0,Ax.default)(e,`${i}`)+r.height)):e},{top:f.top||0,bottom:f.bottom||0})),h),_=g.bottom;p&&(g.bottom+=p.props.height||sV.defaultProps.height),m&&n&&(g=ore(g,i,r,n));var v=l-g.left-g.right,y=u-g.top-g.bottom;return Z(Z({brushBottom:_},g),{},{width:Math.max(v,0),height:Math.max(y,0)})},eJ=function(e,n){if(n===`xAxis`)return e[n].width;if(n===`yAxis`)return e[n].height},tJ=function(e){var n=e.chartName,r=e.GraphicalChild,i=e.defaultTooltipEventType,a=i===void 0?`axis`:i,o=e.validateTooltipEventTypes,s=o===void 0?[`axis`]:o,c=e.axisComponents,l=e.legendContent,u=e.formatAxisMap,d=e.defaultProps,f=function(e,n){var r=n.graphicalItems,i=n.stackGroups,a=n.offset,o=n.updateId,s=n.dataStartIndex,l=n.dataEndIndex,u=e.barSize,d=e.layout,f=e.barGap,p=e.barCategoryGap,m=e.maxBarSize,h=Qq(d),g=h.numericAxisName,_=h.cateAxisName,v=Zq(r),y=[];return r.forEach(function(r,h){var b=Hq(e.data,{graphicalItems:[r],dataStartIndex:s,dataEndIndex:l}),x=r.type.defaultProps===void 0?r.props:Z(Z({},r.type.defaultProps),r.props),S=x.dataKey,C=x.maxBarSize,w=x[`${g}Id`],T=x[`${_}Id`],E=c.reduce(function(e,r){var i=n[`${r.axisType}Map`],a=x[`${r.axisType}Id`];!(i&&i[a]||r.axisType===`zAxis`)&&YP(!1);var o=i[a];return Z(Z({},e),{},Nq(Nq({},r.axisType,o),`${r.axisType}Ticks`,EF(o)))},{}),D=E[_],O=E[`${_}Ticks`],k=i&&i[w]&&i[w].hasStack&&hre(r,i[w].stackGroups),A=uS(r.type).indexOf(`Bar`)>=0,j=zF(D,O),M=[],N=v&&ire({barSize:u,stackGroups:i,totalSize:eJ(E,_)});if(A){var P=(0,Mx.default)(C)?m:C,F=zF(D,O,!0)??P??0;M=are({barGap:f,barCategoryGap:p,bandSize:F===j?j:F,sizeList:N[T],maxBarSize:P}),F!==j&&(M=M.map(function(e){return Z(Z({},e),{},{position:Z(Z({},e.position),{},{offset:e.position.offset-F/2})})}))}var I=r&&r.type&&r.type.getComposedData;I&&y.push({props:Z(Z({},I(Z(Z({},E),{},{displayedData:b,props:e,dataKey:S,item:r,bandSize:j,barPosition:M,offset:a,stackedData:k,layout:d,dataStartIndex:s,dataEndIndex:l}))),{},Nq(Nq(Nq({key:r.key||`item-${h}`},g,E[g]),_,E[_]),`animationId`,o)),childIndex:ES(r,e.children),item:r})}),y},p=function(e,i){var a=e.props,o=e.dataStartIndex,s=e.dataEndIndex,l=e.updateId;if(!gS({props:a}))return null;var d=a.children,p=a.layout,m=a.stackOffset,h=a.data,g=a.reverseStackOrder,_=Qq(p),v=_.numericAxisName,y=_.cateAxisName,b=mS(d,r),x=pre(h,b,`${v}Id`,`${y}Id`,m,g),S=c.reduce(function(e,n){var r=`${n.axisType}Map`;return Z(Z({},e),{},Nq({},r,Jq(a,Z(Z({},n),{},{graphicalItems:b,stackGroups:n.axisType===v&&x,dataStartIndex:o,dataEndIndex:s}))))},{}),C=$q(Z(Z({},S),{},{props:a,graphicalItems:b}),i?.legendBBox);Object.keys(S).forEach(function(e){S[e]=u(a,S[e],C,e.replace(`Map`,``),n)});var w=S[`${y}Map`],T=Yq(w);return Z(Z({formattedGraphicalItems:f(a,Z(Z({},S),{},{dataStartIndex:o,dataEndIndex:s,updateId:l,graphicalItems:b,stackGroups:x,offset:C})),graphicalItems:b,offset:C,stackGroups:x},T),S)},m=function(e){function r(e){var i;return gq(this,r),i=yq(this,r,[e]),Nq(i,`eventEmitterSymbol`,Symbol(`rechartsEventEmitter`)),Nq(i,`accessibilityManager`,new JK),Nq(i,`handleLegendBBoxUpdate`,function(e){if(e){var n=i.state,r=n.dataStartIndex,a=n.dataEndIndex,o=n.updateId;i.setState(Z({legendBBox:e},p({props:i.props,dataStartIndex:r,dataEndIndex:a,updateId:o},Z(Z({},i.state),{},{legendBBox:e}))))}}),Nq(i,`handleReceiveSyncEvent`,function(e,n,r){if(i.props.syncId===e){if(r===i.eventEmitterSymbol&&typeof i.props.syncMethod!=`function`)return;i.applySyncEvent(n)}}),Nq(i,`handleBrushChange`,function(e){var n=e.startIndex,r=e.endIndex;if(n!==i.state.dataStartIndex||r!==i.state.dataEndIndex){var a=i.state.updateId;i.setState(function(){return Z({dataStartIndex:n,dataEndIndex:r},p({props:i.props,dataStartIndex:n,dataEndIndex:r,updateId:a},i.state))}),i.triggerSyncEvent({dataStartIndex:n,dataEndIndex:r})}}),Nq(i,`handleMouseEnter`,function(e){var n=i.getMouseInfo(e);if(n){var r=Z(Z({},n),{},{isTooltipActive:!0});i.setState(r),i.triggerSyncEvent(r);var a=i.props.onMouseEnter;(0,nS.default)(a)&&a(r,e)}}),Nq(i,`triggeredAfterMouseMove`,function(e){var n=i.getMouseInfo(e),r=n?Z(Z({},n),{},{isTooltipActive:!0}):{isTooltipActive:!1};i.setState(r),i.triggerSyncEvent(r);var a=i.props.onMouseMove;(0,nS.default)(a)&&a(r,e)}),Nq(i,`handleItemMouseEnter`,function(e){i.setState(function(){return{isTooltipActive:!0,activeItem:e,activePayload:e.tooltipPayload,activeCoordinate:e.tooltipPosition||{x:e.cx,y:e.cy}}})}),Nq(i,`handleItemMouseLeave`,function(){i.setState(function(){return{isTooltipActive:!1}})}),Nq(i,`handleMouseMove`,function(e){e.persist(),i.throttleTriggeredAfterMouseMove(e)}),Nq(i,`handleMouseLeave`,function(e){i.throttleTriggeredAfterMouseMove.cancel();var n={isTooltipActive:!1};i.setState(n),i.triggerSyncEvent(n);var r=i.props.onMouseLeave;(0,nS.default)(r)&&r(n,e)}),Nq(i,`handleOuterEvent`,function(e){var n=TS(e),r=(0,Ax.default)(i.props,`${n}`);n&&(0,nS.default)(r)&&r((/.*touch.*/i.test(n)?i.getMouseInfo(e.changedTouches[0]):i.getMouseInfo(e))??{},e)}),Nq(i,`handleClick`,function(e){var n=i.getMouseInfo(e);if(n){var r=Z(Z({},n),{},{isTooltipActive:!0});i.setState(r),i.triggerSyncEvent(r);var a=i.props.onClick;(0,nS.default)(a)&&a(r,e)}}),Nq(i,`handleMouseDown`,function(e){var n=i.props.onMouseDown;(0,nS.default)(n)&&n(i.getMouseInfo(e),e)}),Nq(i,`handleMouseUp`,function(e){var n=i.props.onMouseUp;(0,nS.default)(n)&&n(i.getMouseInfo(e),e)}),Nq(i,`handleTouchMove`,function(e){e.changedTouches!=null&&e.changedTouches.length>0&&i.throttleTriggeredAfterMouseMove(e.changedTouches[0])}),Nq(i,`handleTouchStart`,function(e){e.changedTouches!=null&&e.changedTouches.length>0&&i.handleMouseDown(e.changedTouches[0])}),Nq(i,`handleTouchEnd`,function(e){e.changedTouches!=null&&e.changedTouches.length>0&&i.handleMouseUp(e.changedTouches[0])}),Nq(i,`handleDoubleClick`,function(e){var n=i.props.onDoubleClick;(0,nS.default)(n)&&n(i.getMouseInfo(e),e)}),Nq(i,`handleContextMenu`,function(e){var n=i.props.onContextMenu;(0,nS.default)(n)&&n(i.getMouseInfo(e),e)}),Nq(i,`triggerSyncEvent`,function(e){i.props.syncId!==void 0&&zK.emit(BK,i.props.syncId,e,i.eventEmitterSymbol)}),Nq(i,`applySyncEvent`,function(e){var n=i.props,r=n.layout,a=n.syncMethod,o=i.state.updateId,s=e.dataStartIndex,c=e.dataEndIndex;if(e.dataStartIndex!==void 0||e.dataEndIndex!==void 0)i.setState(Z({dataStartIndex:s,dataEndIndex:c},p({props:i.props,dataStartIndex:s,dataEndIndex:c,updateId:o},i.state)));else if(e.activeTooltipIndex!==void 0){var l=e.chartX,u=e.chartY,d=e.activeTooltipIndex,f=i.state,m=f.offset,h=f.tooltipTicks;if(!m)return;if(typeof a==`function`)d=a(h,e);else if(a===`value`){d=-1;for(var g=0;g<h.length;g++)if(h[g].value===e.activeLabel){d=g;break}}var _=Z(Z({},m),{},{x:m.left,y:m.top}),v=Math.min(l,_.x+_.width),y=Math.min(u,_.y+_.height),b=h[d]&&h[d].value,x=Wq(i.state,i.props.data,d),S=h[d]?{x:r===`horizontal`?h[d].coordinate:v,y:r===`horizontal`?y:h[d].coordinate}:Rq;i.setState(Z(Z({},e),{},{activeLabel:b,activeCoordinate:S,activePayload:x,activeTooltipIndex:d}))}else i.setState(e)}),Nq(i,`renderCursor`,function(e){var r=i.state,a=r.isTooltipActive,o=r.activeCoordinate,s=r.activePayload,c=r.offset,l=r.activeTooltipIndex,u=r.tooltipAxisBandSize,d=i.getTooltipEventType(),f=e.props.active??a,p=i.props.layout,m=e.key||`_recharts-cursor`;return y.createElement(aq,{key:m,activeCoordinate:o,activePayload:s,activeTooltipIndex:l,chartName:n,element:e,isActive:f,layout:p,offset:c,tooltipAxisBandSize:u,tooltipEventType:d})}),Nq(i,`renderPolarAxis`,function(e,n,r){var a=(0,Ax.default)(e,`type.axisType`),o=(0,Ax.default)(i.state,`${a}Map`),s=e.type.defaultProps,c=s===void 0?e.props:Z(Z({},s),e.props),l=o&&o[c[`${a}Id`]];return(0,y.cloneElement)(e,Z(Z({},l),{},{className:Zd(a,l.className),key:e.key||`${n}-${r}`,ticks:EF(l,!0)}))}),Nq(i,`renderPolarGrid`,function(e){var n=e.props,r=n.radialLines,a=n.polarAngles,o=n.polarRadius,s=i.state,c=s.radiusAxisMap,l=s.angleAxisMap,u=Bx(c),d=Bx(l),f=d.cx,p=d.cy,m=d.innerRadius,h=d.outerRadius;return(0,y.cloneElement)(e,{polarAngles:Array.isArray(a)?a:EF(d,!0).map(function(e){return e.coordinate}),polarRadius:Array.isArray(o)?o:EF(u,!0).map(function(e){return e.coordinate}),cx:f,cy:p,innerRadius:m,outerRadius:h,key:e.key||`polar-grid`,radialLines:r})}),Nq(i,`renderLegend`,function(){var e=i.state.formattedGraphicalItems,n=i.props,r=n.children,a=n.width,o=n.height,s=i.props.margin||{},c=lF({children:r,formattedGraphicalItems:e,legendWidth:a-(s.left||0)-(s.right||0),legendContent:l});if(!c)return null;var u=c.item;return(0,y.cloneElement)(u,Z(Z({},mq(c,oq)),{},{chartWidth:a,chartHeight:o,margin:s,onBBoxUpdate:i.handleLegendBBoxUpdate}))}),Nq(i,`renderTooltip`,function(){var e=i.props,n=e.children,r=e.accessibilityLayer,a=hS(n,VE);if(!a)return null;var o=i.state,s=o.isTooltipActive,c=o.activeCoordinate,l=o.activePayload,u=o.activeLabel,d=o.offset,f=a.props.active??s;return(0,y.cloneElement)(a,{viewBox:Z(Z({},d),{},{x:d.left,y:d.top}),active:f,label:u,payload:f?l:[],coordinate:c,accessibilityLayer:r})}),Nq(i,`renderBrush`,function(e){var n=i.props,r=n.margin,a=n.data,o=i.state,s=o.offset,c=o.dataStartIndex,l=o.dataEndIndex,u=o.updateId;return(0,y.cloneElement)(e,{key:e.key||`_recharts-brush`,onChange:OF(i.handleBrushChange,e.props.onChange),data:a,x:Y(e.props.x)?e.props.x:s.left,y:Y(e.props.y)?e.props.y:s.top+s.height+s.brushBottom-(r.bottom||0),width:Y(e.props.width)?e.props.width:s.width,startIndex:c,endIndex:l,updateId:`brush-${u}`})}),Nq(i,`renderReferenceElement`,function(e,n,r){if(!e)return null;var a=i.clipPathId,o=i.state,s=o.xAxisMap,c=o.yAxisMap,l=o.offset,u=e.type.defaultProps||{},d=e.props,f=d.xAxisId,p=f===void 0?u.xAxisId:f,m=d.yAxisId,h=m===void 0?u.yAxisId:m;return(0,y.cloneElement)(e,{key:e.key||`${n}-${r}`,xAxis:s[p],yAxis:c[h],viewBox:{x:l.left,y:l.top,width:l.width,height:l.height},clipPathId:a})}),Nq(i,`renderActivePoints`,function(e){var n=e.item,i=e.activePoint,a=e.basePoint,o=e.childIndex,s=e.isRange,c=[],l=n.props.key,u=n.item.type.defaultProps===void 0?n.item.props:Z(Z({},n.item.type.defaultProps),n.item.props),d=u.activeDot,f=u.dataKey,p=Z(Z({index:o,dataKey:f,cx:i.x,cy:i.y,r:4,fill:xF(n.item),strokeWidth:2,stroke:`#fff`,payload:i.payload,value:i.value},xS(d,!1)),$x(d));return c.push(r.renderActiveDot(d,p,`${l}-activePoint-${o}`)),a?c.push(r.renderActiveDot(d,Z(Z({},p),{},{cx:a.x,cy:a.y}),`${l}-basePoint-${o}`)):s&&c.push(null),c}),Nq(i,`renderGraphicChild`,function(e,n,r){var a=i.filterFormatItem(e,n,r);if(!a)return null;var o=i.getTooltipEventType(),s=i.state,c=s.isTooltipActive,l=s.tooltipAxis,u=s.activeTooltipIndex,d=s.activeLabel,f=i.props.children,p=hS(f,VE),m=a.props,h=m.points,g=m.isRange,_=m.baseLine,v=a.item.type.defaultProps===void 0?a.item.props:Z(Z({},a.item.type.defaultProps),a.item.props),b=v.activeDot,x=v.hide,S=v.activeBar,C=v.activeShape,w=!!(!x&&c&&p&&(b||S||C)),T={};o!==`axis`&&p&&p.props.trigger===`click`?T={onClick:OF(i.handleItemMouseEnter,e.props.onClick)}:o!==`axis`&&(T={onMouseLeave:OF(i.handleItemMouseLeave,e.props.onMouseLeave),onMouseEnter:OF(i.handleItemMouseEnter,e.props.onMouseEnter)});var E=(0,y.cloneElement)(e,Z(Z({},a.props),T));function D(e){return typeof l.dataKey==`function`?l.dataKey(e.payload):null}if(w)if(u>=0){var O,k;if(l.dataKey&&!l.allowDuplicatedCategory){var A=typeof l.dataKey==`function`?D:`payload.${l.dataKey.toString()}`;O=Ux(h,A,d),k=g&&_&&Ux(_,A,d)}else O=h?.[u],k=g&&_&&_[u];if(C||S){var j=e.props.activeIndex===void 0?u:e.props.activeIndex;return[(0,y.cloneElement)(e,Z(Z(Z({},a.props),T),{},{activeIndex:j})),null,null]}if(!(0,Mx.default)(O))return[E].concat(Eq(i.renderActivePoints({item:a,activePoint:O,basePoint:k,childIndex:u,isRange:g})))}else{var M=(i.getItemByXY(i.state.activeCoordinate)??{graphicalItem:E}).graphicalItem,N=M.item,P=N===void 0?e:N,F=M.childIndex;return[(0,y.cloneElement)(P,Z(Z(Z({},a.props),T),{},{activeIndex:F})),null,null]}return g?[E,null,null]:[E,null]}),Nq(i,`renderCustomized`,function(e,n,r){return(0,y.cloneElement)(e,Z(Z({key:`recharts-customized-${r}`},i.props),i.state))}),Nq(i,`renderMap`,{CartesianGrid:{handler:zq,once:!0},ReferenceArea:{handler:i.renderReferenceElement},ReferenceLine:{handler:zq},ReferenceDot:{handler:i.renderReferenceElement},XAxis:{handler:zq},YAxis:{handler:zq},Brush:{handler:i.renderBrush,once:!0},Bar:{handler:i.renderGraphicChild},Line:{handler:i.renderGraphicChild},Area:{handler:i.renderGraphicChild},Radar:{handler:i.renderGraphicChild},RadialBar:{handler:i.renderGraphicChild},Scatter:{handler:i.renderGraphicChild},Pie:{handler:i.renderGraphicChild},Funnel:{handler:i.renderGraphicChild},Tooltip:{handler:i.renderCursor,once:!0},PolarGrid:{handler:i.renderPolarGrid,once:!0},PolarAngleAxis:{handler:i.renderPolarAxis},PolarRadiusAxis:{handler:i.renderPolarAxis},Customized:{handler:i.renderCustomized}}),i.clipPathId=`${e.id??Rx(`recharts`)}-clip`,i.throttleTriggeredAfterMouseMove=(0,qE.default)(i.triggeredAfterMouseMove,e.throttleDelay??1e3/60),i.state={},i}return wq(r,e),vq(r,[{key:`componentDidMount`,value:function(){this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:this.props.margin.left??0,top:this.props.margin.top??0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:`displayDefaultTooltip`,value:function(){var e=this.props,n=e.children,r=e.data,i=e.height,a=e.layout,o=hS(n,VE);if(o){var s=o.props.defaultIndex;if(!(typeof s!=`number`||s<0||s>this.state.tooltipTicks.length-1)){var c=this.state.tooltipTicks[s]&&this.state.tooltipTicks[s].value,l=Wq(this.state,r,s,c),u=this.state.tooltipTicks[s].coordinate,d=(this.state.offset.top+i)/2,f=a===`horizontal`?{x:u,y:d}:{y:u,x:d},p=this.state.formattedGraphicalItems.find(function(e){return e.item.type.name===`Scatter`});p&&(f=Z(Z({},f),p.props.points[s].tooltipPosition),l=p.props.points[s].tooltipPayload);var m={activeTooltipIndex:s,isTooltipActive:!0,activeLabel:c,activePayload:l,activeCoordinate:f};this.setState(m),this.renderCursor(o),this.accessibilityManager.setIndex(s)}}}},{key:`getSnapshotBeforeUpdate`,value:function(e,n){return this.props.accessibilityLayer?(this.state.tooltipTicks!==n.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==e.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==e.margin&&this.accessibilityManager.setDetails({offset:{left:this.props.margin.left??0,top:this.props.margin.top??0}}),null):null}},{key:`componentDidUpdate`,value:function(e){SS([hS(e.children,VE)],[hS(this.props.children,VE)])||this.displayDefaultTooltip()}},{key:`componentWillUnmount`,value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:`getTooltipEventType`,value:function(){var e=hS(this.props.children,VE);if(e&&typeof e.props.shared==`boolean`){var n=e.props.shared?`axis`:`item`;return s.indexOf(n)>=0?n:a}return a}},{key:`getMouseInfo`,value:function(e){if(!this.container)return null;var n=this.container,r=n.getBoundingClientRect(),i=bD(r),a={chartX:Math.round(e.pageX-i.left),chartY:Math.round(e.pageY-i.top)},o=r.width/n.offsetWidth||1,s=this.inRange(a.chartX,a.chartY,o);if(!s)return null;var c=this.state,l=c.xAxisMap,u=c.yAxisMap,d=this.getTooltipEventType(),f=Gq(this.state,this.props.data,this.props.layout,s);if(d!==`axis`&&l&&u){var p=Bx(l).scale,m=Bx(u).scale,h=p&&p.invert?p.invert(a.chartX):null,g=m&&m.invert?m.invert(a.chartY):null;return Z(Z({},a),{},{xValue:h,yValue:g},f)}return f?Z(Z({},a),f):null}},{key:`inRange`,value:function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,i=this.props.layout,a=e/r,o=n/r;if(i===`horizontal`||i===`vertical`){var s=this.state.offset;return a>=s.left&&a<=s.left+s.width&&o>=s.top&&o<=s.top+s.height?{x:a,y:o}:null}var c=this.state,l=c.angleAxisMap,u=c.radiusAxisMap;if(l&&u){var d=Bx(l);return XF({x:a,y:o},d)}return null}},{key:`parseEventsOfWrapper`,value:function(){var e=this.props.children,n=this.getTooltipEventType(),r=hS(e,VE),i={};return r&&n===`axis`&&(i=r.props.trigger===`click`?{onClick:this.handleClick}:{onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu}),Z(Z({},$x(this.props,this.handleOuterEvent)),i)}},{key:`addListener`,value:function(){zK.on(BK,this.handleReceiveSyncEvent)}},{key:`removeListener`,value:function(){zK.removeListener(BK,this.handleReceiveSyncEvent)}},{key:`filterFormatItem`,value:function(e,n,r){for(var i=this.state.formattedGraphicalItems,a=0,o=i.length;a<o;a++){var s=i[a];if(s.item===e||s.props.key===e.key||n===uS(s.item.type)&&r===s.childIndex)return s}return null}},{key:`renderClipPath`,value:function(){var e=this.clipPathId,n=this.state.offset,r=n.left,i=n.top,a=n.height,o=n.width;return y.createElement(`defs`,null,y.createElement(`clipPath`,{id:e},y.createElement(`rect`,{x:r,y:i,height:a,width:o})))}},{key:`getXScales`,value:function(){var e=this.state.xAxisMap;return e?Object.entries(e).reduce(function(e,n){var r=uq(n,2),i=r[0],a=r[1];return Z(Z({},e),{},Nq({},i,a.scale))},{}):null}},{key:`getYScales`,value:function(){var e=this.state.yAxisMap;return e?Object.entries(e).reduce(function(e,n){var r=uq(n,2),i=r[0],a=r[1];return Z(Z({},e),{},Nq({},i,a.scale))},{}):null}},{key:`getXScaleByAxisId`,value:function(e){var n;return(n=this.state.xAxisMap)==null||(n=n[e])==null?void 0:n.scale}},{key:`getYScaleByAxisId`,value:function(e){var n;return(n=this.state.yAxisMap)==null||(n=n[e])==null?void 0:n.scale}},{key:`getItemByXY`,value:function(e){var n=this.state,r=n.formattedGraphicalItems,i=n.activeItem;if(r&&r.length)for(var a=0,o=r.length;a<o;a++){var s=r[a],c=s.props,l=s.item,u=l.type.defaultProps===void 0?l.props:Z(Z({},l.type.defaultProps),l.props),d=uS(l.type);if(d===`Bar`){var f=(c.data||[]).find(function(n){return YL(e,n)});if(f)return{graphicalItem:s,payload:f}}else if(d===`RadialBar`){var p=(c.data||[]).find(function(n){return XF(e,n)});if(p)return{graphicalItem:s,payload:p}}else if(eB(s,i)||tB(s,i)||nB(s,i)){var m=lB({graphicalItem:s,activeTooltipItem:i,itemData:u.data}),h=u.activeIndex===void 0?m:u.activeIndex;return{graphicalItem:Z(Z({},s),{},{childIndex:h}),payload:nB(s,i)?u.data[m]:s.props.data[m]}}}return null}},{key:`render`,value:function(){var e=this;if(!gS(this))return null;var n=this.props,r=n.children,i=n.className,a=n.width,o=n.height,s=n.style,c=n.compact,l=n.title,u=n.desc,d=xS(mq(n,sq),!1);if(c)return y.createElement(OH,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},y.createElement(jS,lq({},d,{width:a,height:o,title:l,desc:u}),this.renderClipPath(),wS(r,this.renderMap)));this.props.accessibilityLayer&&(d.tabIndex=this.props.tabIndex??0,d.role=this.props.role??`application`,d.onKeyDown=function(n){e.accessibilityManager.keyboardEvent(n)},d.onFocus=function(){e.accessibilityManager.focus()});var f=this.parseEventsOfWrapper();return y.createElement(OH,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},y.createElement(`div`,lq({className:Zd(`recharts-wrapper`,i),style:Z({position:`relative`,cursor:`default`,width:a,height:o},s)},f,{ref:function(n){e.container=n}}),y.createElement(jS,lq({},d,{width:a,height:o,title:l,desc:u,style:Lq}),this.renderClipPath(),wS(r,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])}(y.Component);Nq(m,`displayName`,n),Nq(m,`defaultProps`,Z({layout:`horizontal`,stackOffset:`none`,barCategoryGap:`10%`,barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:`index`},d)),Nq(m,`getDerivedStateFromProps`,function(e,n){var r=e.dataKey,i=e.data,a=e.children,o=e.width,s=e.height,c=e.layout,l=e.stackOffset,u=e.margin,d=n.dataStartIndex,f=n.dataEndIndex;if(n.updateId===void 0){var m=Xq(e);return Z(Z(Z({},m),{},{updateId:0},p(Z(Z({props:e},m),{},{updateId:0}),n)),{},{prevDataKey:r,prevData:i,prevWidth:o,prevHeight:s,prevLayout:c,prevStackOffset:l,prevMargin:u,prevChildren:a})}if(r!==n.prevDataKey||i!==n.prevData||o!==n.prevWidth||s!==n.prevHeight||c!==n.prevLayout||l!==n.prevStackOffset||!Gx(u,n.prevMargin)){var h=Xq(e),g={chartX:n.chartX,chartY:n.chartY,isTooltipActive:n.isTooltipActive},_=Z(Z({},Gq(n,i,c)),{},{updateId:n.updateId+1}),v=Z(Z(Z({},h),g),_);return Z(Z(Z({},v),p(Z({props:e},v),n)),{},{prevDataKey:r,prevData:i,prevWidth:o,prevHeight:s,prevLayout:c,prevStackOffset:l,prevMargin:u,prevChildren:a})}if(!SS(a,n.prevChildren)){var y=hS(a,sV),b=y?y.props?.startIndex??d:d,x=y?y.props?.endIndex??f:f,S=b!==d||x!==f,C=!(0,Mx.default)(i)&&!S?n.updateId:n.updateId+1;return Z(Z({updateId:C},p(Z(Z({props:e},n),{},{updateId:C,dataStartIndex:b,dataEndIndex:x}),n)),{},{prevChildren:a,dataStartIndex:b,dataEndIndex:x})}return null}),Nq(m,`renderActiveDot`,function(e,n,r){var i=(0,y.isValidElement)(e)?(0,y.cloneElement)(e,n):(0,nS.default)(e)?e(n):y.createElement(mR,n);return y.createElement(IS,{className:`recharts-active-dot`,key:r},i)});var h=(0,y.forwardRef)(function(e,n){return y.createElement(m,lq({},e,{ref:n}))});return h.displayName=m.displayName,h},nJ=tJ({chartName:`LineChart`,GraphicalChild:OG,axisComponents:[{axisType:`xAxis`,AxisComp:mK},{axisType:`yAxis`,AxisComp:jK}],formatAxisMap:cH}),rJ=tJ({chartName:`BarChart`,GraphicalChild:XV,defaultTooltipEventType:`axis`,validateTooltipEventTypes:[`axis`,`item`],axisComponents:[{axisType:`xAxis`,AxisComp:mK},{axisType:`yAxis`,AxisComp:jK}],formatAxisMap:cH}),iJ=tJ({chartName:`PieChart`,GraphicalChild:OB,validateTooltipEventTypes:[`item`],defaultTooltipEventType:`item`,legendContent:`children`,axisComponents:[{axisType:`angleAxis`,AxisComp:vz},{axisType:`radiusAxis`,AxisComp:QR}],formatAxisMap:Tre,defaultProps:{layout:`centric`,startAngle:0,endAngle:360,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`}}),aJ=tJ({chartName:`AreaChart`,GraphicalChild:ZG,axisComponents:[{axisType:`xAxis`,AxisComp:mK},{axisType:`yAxis`,AxisComp:jK}],formatAxisMap:cH}),oJ=[`#8b5cf6`,`#ec4899`,`#06b6d4`,`#f59e0b`,`#10b981`,`#ef4444`,`#6366f1`,`#f97316`],sJ={episodic:`情景记忆`,semantic:`语义记忆`,procedural:`程序记忆`,emotional:`情感记忆`,working:`工作记忆`},cJ={core:`#8b5cf6`,working:`#06b6d4`,peripheral:`#9ca3af`},lJ={core:`核心`,working:`工作区`,peripheral:`边缘`};function uJ({label:e,value:n,icon:r,loading:i}){return(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:e}),(0,G.jsx)(r,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:i?(0,G.jsx)(Cb,{className:`h-8 w-20`}):n})})]})}function dJ({className:e}){return(0,G.jsxs)(`div`,{className:Tp(`flex flex-col gap-4`,e),children:[(0,G.jsx)(Cb,{className:`h-6 w-32`}),(0,G.jsx)(Cb,{className:`flex-1 min-h-[240px]`})]})}function fJ(){let e=et(),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(!0),[o,s]=(0,y.useState)(null),{users:c,currentUserId:l}=dh(),u=c.find(e=>e.id===l)?.spaceName||`默认`;(0,y.useEffect)(()=>{async function e(){try{a(!0),s(null),r(await ib.get(`/v1/stats`))}catch(e){console.error(`Failed to fetch stats:`,e),s(`加载统计数据失败`)}finally{a(!1)}}e()},[]);let d=()=>{if(!n?.timeline?.length)return 0;let e=new Date().toISOString().split(`T`)[0];return n.timeline.find(n=>n.date===e)?.count??0},f=()=>n?.by_space?Object.keys(n.by_space).length:0,p=()=>n?.by_state?n.by_state.active??n.by_state.活跃??0:0,m=()=>n?.by_tier?n.by_tier.core??0:0,h=(0,y.useMemo)(()=>n?.by_type?Object.entries(n.by_type).map(([e,n])=>({name:sJ[e]||e,value:n,key:e})):[],[n]),g=(0,y.useMemo)(()=>n?.by_tier?Object.entries(n.by_tier).map(([e,n])=>({name:lJ[e]||e,value:n,key:e})):[],[n]),_=(0,y.useMemo)(()=>n?.timeline?.length?n.timeline.slice(-30):[],[n]),v=(0,y.useMemo)(()=>n?.by_category?Object.entries(n.by_category).map(([e,n])=>({name:e,value:n})).sort((e,n)=>n.value-e.value).slice(0,10):[],[n]);return(0,G.jsxs)(`div`,{className:`space-y-8`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`h1`,{className:`text-3xl font-semibold tracking-tight`,children:[u,`空间的记忆库状态`]}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:`概览当前空间的记忆数据`})]}),o&&(0,G.jsx)(`div`,{className:`rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive`,children:o}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,G.jsxs)(q,{size:`sm`,onClick:()=>e(`/memories/new`),children:[(0,G.jsx)(Nm,{className:`size-4 mr-1.5`}),`新建记忆`]}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>e(`/import`),children:[(0,G.jsx)(Ym,{className:`size-4 mr-1.5`}),`批量导入`]}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>e(`/analytics`),children:[(0,G.jsx)(um,{className:`size-4 mr-1.5`}),`查看统计报告`]})]}),(0,G.jsxs)(`div`,{className:Tp(`grid gap-4`,`grid-cols-1`,`md:grid-cols-2`,`lg:grid-cols-4`),children:[(0,G.jsx)(uJ,{label:`总记忆数`,value:n?.total??0,icon:qp,loading:i}),(0,G.jsx)(uJ,{label:`今日新增`,value:d(),icon:qm,loading:i}),(0,G.jsx)(uJ,{label:`空间数`,value:f(),icon:hm,loading:i}),(0,G.jsx)(uJ,{label:`总访问次数`,value:n?.total_access_count??0,icon:sm,loading:i})]}),(0,G.jsxs)(`div`,{className:Tp(`grid gap-4`,`grid-cols-1`,`md:grid-cols-2`,`lg:grid-cols-4`),children:[(0,G.jsx)(uJ,{label:`平均重要度`,value:n?.avg_importance?`${(n.avg_importance*100).toFixed(0)}%`:`—`,icon:Yp,loading:i}),(0,G.jsx)(uJ,{label:`平均置信度`,value:n?.avg_confidence?`${(n.avg_confidence*100).toFixed(0)}%`:`—`,icon:tm,loading:i}),(0,G.jsx)(uJ,{label:`核心记忆数`,value:m(),icon:Hm,loading:i}),(0,G.jsx)(uJ,{label:`活跃记忆数`,value:p(),icon:zp,loading:i})]}),(0,G.jsxs)(`div`,{className:Tp(`grid gap-4`,`grid-cols-1`,`lg:grid-cols-2`),children:[(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`记忆类型分布`})}),(0,G.jsx)(Sb,{children:i?(0,G.jsx)(dJ,{}):h.length===0?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[240px] text-muted-foreground text-sm`,children:`暂无数据`}):(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(iJ,{children:[(0,G.jsx)(OB,{data:h,cx:`50%`,cy:`50%`,outerRadius:100,dataKey:`value`,label:({name:e,percent:n})=>`${e} ${(n*100).toFixed(0)}%`,children:h.map((e,n)=>(0,G.jsx)(sD,{fill:oJ[n%oJ.length]},`cell-${e.key}`))}),(0,G.jsx)(VE,{})]})})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`记忆等级分布`})}),(0,G.jsx)(Sb,{children:i?(0,G.jsx)(dJ,{}):g.length===0?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[240px] text-muted-foreground text-sm`,children:`暂无数据`}):(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(iJ,{children:[(0,G.jsx)(OB,{data:g,cx:`50%`,cy:`50%`,innerRadius:70,outerRadius:100,paddingAngle:4,dataKey:`value`,children:g.map(e=>(0,G.jsx)(sD,{fill:cJ[e.key]||`#9ca3af`},`tier-${e.key}`))}),(0,G.jsx)(VE,{})]})}),(0,G.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center pointer-events-none`,children:[(0,G.jsx)(`span`,{className:`text-3xl font-bold`,children:n?.total??0}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`总记忆数`})]})]})})]}),(0,G.jsxs)(vb,{className:`lg:col-span-2`,children:[(0,G.jsx)(yb,{children:(0,G.jsxs)(bb,{className:`text-base`,children:[`新增趋势(最近`,_.length,`天)`]})}),(0,G.jsx)(Sb,{children:i?(0,G.jsx)(dJ,{}):_.length===0?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[240px] text-muted-foreground text-sm`,children:`暂无数据`}):(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(aJ,{data:_,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`colorCount`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`5%`,stopColor:`#8b5cf6`,stopOpacity:.3}),(0,G.jsx)(`stop`,{offset:`95%`,stopColor:`#8b5cf6`,stopOpacity:0})]})}),(0,G.jsx)(eG,{strokeDasharray:`3 3`,stroke:`#333`}),(0,G.jsx)(mK,{dataKey:`date`,tick:{fontSize:12},tickFormatter:e=>{let[,n,r]=e.split(`-`);return`${n}-${r}`}}),(0,G.jsx)(jK,{tick:{fontSize:12}}),(0,G.jsx)(VE,{labelFormatter:e=>`日期: ${e}`,formatter:e=>[e,`新增数量`]}),(0,G.jsx)(ZG,{type:`monotone`,dataKey:`count`,stroke:`#8b5cf6`,fillOpacity:1,fill:`url(#colorCount)`,strokeWidth:2})]})})})]}),(0,G.jsxs)(vb,{className:`lg:col-span-2`,children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`分类 TOP10`})}),(0,G.jsx)(Sb,{children:i?(0,G.jsx)(dJ,{}):v.length===0?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[240px] text-muted-foreground text-sm`,children:`暂无数据`}):(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(rJ,{data:v,layout:`vertical`,children:[(0,G.jsx)(eG,{strokeDasharray:`3 3`,stroke:`#333`}),(0,G.jsx)(mK,{type:`number`,tick:{fontSize:12}}),(0,G.jsx)(jK,{dataKey:`name`,type:`category`,tick:{fontSize:11},width:100}),(0,G.jsx)(VE,{}),(0,G.jsx)(XV,{dataKey:`value`,fill:`#06b6d4`,radius:[0,4,4,0]})]})})})]})]})]})}function pJ({...e}){return(0,G.jsx)(hg,{"data-slot":`alert-dialog`,...e})}function mJ({className:e,children:n,...r}){return(0,G.jsxs)(Zh,{children:[(0,G.jsx)(Eh,{className:`fixed inset-0 isolate z-50 bg-black/20 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`}),(0,G.jsx)(Yh,{"data-slot":`alert-dialog-content`,className:Tp(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-6 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:n})]})}function hJ({className:e,...n}){return(0,G.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:Tp(`flex flex-col gap-2`,e),...n})}function gJ({className:e,...n}){return(0,G.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:Tp(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...n})}function _J({className:e,...n}){return(0,G.jsx)(gg,{"data-slot":`alert-dialog-title`,className:Tp(`text-base font-semibold leading-none`,e),...n})}function vJ({className:e,...n}){return(0,G.jsx)(Oh,{"data-slot":`alert-dialog-description`,className:Tp(`text-sm text-muted-foreground`,e),...n})}function yJ({className:e,...n}){return(0,G.jsx)(Dh,{children:(0,G.jsx)(q,{"data-slot":`alert-dialog-action`,className:e,...n})})}function bJ({className:e,...n}){return(0,G.jsx)(Dh,{children:(0,G.jsx)(q,{"data-slot":`alert-dialog-cancel`,variant:`outline`,className:e,...n})})}function xJ(e){return Qs(e.defaultTagName??`div`,e,e)}var SJ=bh(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function CJ({className:e,variant:n=`default`,render:r,...i}){return xJ({defaultTagName:`span`,props:Rs({className:Tp(SJ({variant:n}),e)},i),render:r,state:{slot:`badge`,variant:n}})}var wJ={工作:{bg:`bg-blue-500/10`,text:`text-blue-600`,border:`border-blue-500/30`},学习:{bg:`bg-green-500/10`,text:`text-green-600`,border:`border-green-500/30`},生活:{bg:`bg-rose-500/10`,text:`text-rose-600`,border:`border-rose-500/30`},技术:{bg:`bg-violet-500/10`,text:`text-violet-600`,border:`border-violet-500/30`},重要:{bg:`bg-red-500/10`,text:`text-red-600`,border:`border-red-500/30`},待办:{bg:`bg-orange-500/10`,text:`text-orange-600`,border:`border-orange-500/30`},项目:{bg:`bg-indigo-500/10`,text:`text-indigo-600`,border:`border-indigo-500/30`},灵感:{bg:`bg-pink-500/10`,text:`text-pink-600`,border:`border-pink-500/30`},笔记:{bg:`bg-slate-500/10`,text:`text-slate-600`,border:`border-slate-500/30`},私密:{bg:`bg-amber-500/10`,text:`text-amber-600`,border:`border-amber-500/30`}},TJ=[{bg:`bg-cyan-500/10`,text:`text-cyan-600`,border:`border-cyan-500/30`},{bg:`bg-emerald-500/10`,text:`text-emerald-600`,border:`border-emerald-500/30`},{bg:`bg-teal-500/10`,text:`text-teal-600`,border:`border-teal-500/30`},{bg:`bg-sky-500/10`,text:`text-sky-600`,border:`border-sky-500/30`},{bg:`bg-fuchsia-500/10`,text:`text-fuchsia-600`,border:`border-fuchsia-500/30`},{bg:`bg-lime-500/10`,text:`text-lime-600`,border:`border-lime-500/30`},{bg:`bg-yellow-500/10`,text:`text-yellow-600`,border:`border-yellow-500/30`}];function EJ(e){let n=0;for(let r=0;r<e.length;r++)n=(n<<5)-n+e.charCodeAt(r)|0;return Math.abs(n)}function DJ(e){return wJ[e]||TJ[EJ(e)%TJ.length]}function OJ(e,n){let r=DJ(e);return Tp(r.bg,r.text,r.border,`border`,`hover:opacity-80`,n)}function kJ(e,n){return n===`private`?!0:e?.includes(`私密`)||!1}function AJ(e){switch(e?.toLowerCase()){case`profile`:return`bg-violet-500/10 text-violet-600 dark:text-violet-400 border-violet-500/30`;case`preferences`:return`bg-rose-500/10 text-rose-600 dark:text-rose-400 border-rose-500/30`;case`entities`:return`bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/30`;case`patterns`:return`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/30`;case`cases`:return`bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/30`;case`events`:return`bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/30`;case`decisions`:return`bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border-indigo-500/30`;default:return`bg-muted text-muted-foreground border-border`}}function jJ(e){switch(e?.toLowerCase()){case`core`:return`核心`;case`working`:return`工作区`;case`peripheral`:return`边缘`;default:return e||`—`}}function MJ(e){switch(e?.toLowerCase()){case`core`:return`default`;case`working`:return`secondary`;case`peripheral`:return`outline`;default:return`outline`}}function NJ(e){switch(e?.toLowerCase()){case`core`:return`bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/30`;case`working`:return`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/30`;case`peripheral`:return`bg-slate-500/10 text-slate-500 dark:text-slate-400 border-slate-500/30`;default:return`bg-muted text-muted-foreground border-border`}}var PJ=300;function FJ(e,n=120){return e?e.length<=n?e:e.slice(0,n)+`...`:`—`}function IJ(e){return new Date(e).toLocaleString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function LJ({memory:e,unlocked:n}){return kJ(e.tags,e.visibility)?n?(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Tm,{className:`h-3 w-3 text-amber-500`}),(0,G.jsx)(`span`,{className:`text-xs text-amber-500 font-medium`,children:`已解锁`})]}),(0,G.jsx)(`p`,{className:`text-sm text-foreground line-clamp-3`,children:FJ(e.content||e.l0_abstract)})]}):(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,G.jsx)(Em,{className:`h-3.5 w-3.5 text-amber-500`}),(0,G.jsx)(`span`,{children:`🔒 私密记忆 · 已加密`})]}):(0,G.jsx)(`p`,{className:`text-sm text-foreground line-clamp-3`,children:FJ(e.content||e.l0_abstract)})}function RJ(){let e=et(),n=Ze(),[r,i]=Nn(),a=(e,n)=>r.get(e)||n,o=(e,n)=>{let i=r.get(e);return i?parseInt(i,10):n},[s,c]=(0,y.useState)([]),[l,u]=(0,y.useState)(!0),[,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(o(`page`,1)),[m,h]=(0,y.useState)(a(`q`,``)),[g,_]=(0,y.useState)(0),v=ob(e=>e.isUnlocked),b=ob(e=>e.lock),x=ob(e=>e.unlock),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(``),[E,D]=(0,y.useState)(null),[O,k]=(0,y.useState)(a(`tier`,`all`)),[A,j]=(0,y.useState)(a(`sort`,`created_at`)),[M,N]=(0,y.useState)(o(`size`,20)),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(a(`privacy`,`all`)),[ee,B]=(0,y.useState)(a(`q`,``)),[V,H]=(0,y.useState)(new Set),[U,te]=(0,y.useState)(!1),[W,ne]=(0,y.useState)(!1),[re,ie]=(0,y.useState)(0),[ae,oe]=(0,y.useState)(a(`project`,``)),[se,ce]=(0,y.useState)([]),le=(0,y.useRef)(!0);(0,y.useEffect)(()=>{async function e(){try{let e=await ib.get(`/v1/memories/project-paths`);ce(Array.isArray(e)?e:[])}catch{ce([])}}e()},[re]),(0,y.useEffect)(()=>{if(le.current){le.current=!1;return}let e=setTimeout(()=>{p(1),B(m)},PJ);return()=>clearTimeout(e)},[m]);let ue=(0,y.useCallback)(async()=>{try{u(!0),d(null);let e={offset:(f-1)*M,limit:M,sort:A};ee.trim()&&(e.q=ee.trim()),O!==`all`&&(e.tier=O),R===`private`?e.visibility=`private`:R===`global`&&(e.visibility=`global`),ae&&(e.project_path=ae);let n=await ib.get(`/v1/memories`,{params:e});c(n.memories||[]),_(n.total_count||0)}catch(e){console.error(`Failed to fetch memories:`,e),d(`加载记忆列表失败`)}finally{u(!1)}},[f,ee,O,A,M,R,ae]);(0,y.useEffect)(()=>{ue()},[ue,re]),(0,y.useEffect)(()=>{let e=new URLSearchParams;f>1&&e.set(`page`,String(f)),m&&e.set(`q`,m),O!==`all`&&e.set(`tier`,O),A!==`created_at`&&e.set(`sort`,A),M!==20&&e.set(`size`,String(M)),R!==`all`&&e.set(`privacy`,R),ae&&e.set(`project`,ae),i(e,{replace:!0})},[f,m,O,A,M,R,ae,i]);let de=r=>{let i=n.pathname+n.search;sessionStorage.setItem(`memories-list-from`,i),e(`/memories/${r}`,{state:{from:i}})},fe=e=>{h(e.target.value)},pe=[m?{label:`搜索: "${m}"`,onClear:()=>h(``)}:null,O===`all`?null:{label:`分类: ${O}`,onClear:()=>k(`all`)},A===`created_at`?null:{label:`排序: ${A}`,onClear:()=>j(`created_at`)},R===`all`?null:{label:R===`private`?`仅私密`:`仅普通`,onClear:()=>z(`all`)},ae?{label:`项目: ${ae.split(`/`).pop()}`,onClear:()=>{oe(``),p(1)}}:null].filter(Boolean),me=()=>{h(``),k(`all`),j(`created_at`),z(`all`),oe(``),p(1)},he=()=>{f>1&&p(f-1)},ge=()=>{f*M<g&&p(f+1)},_e=async()=>{if(!w.trim()){D(`请输入密码`);return}if(!await x(w)){D(`密码错误`);return}D(null),C(!1),T(``)},ve=()=>{b()},ye=(e,n)=>{n.stopPropagation(),F(e)},be=async()=>{if(!P)return;let e=P;L(!0);try{await ib.delete(`/v1/memories/${e}`),ir.success(`记忆已删除`),F(null),ie(e=>e+1)}catch(e){console.error(`Failed to delete memory:`,e),ir.error(`删除失败,请重试`),F(null)}finally{L(!1)}},xe=e=>{H(n=>{let r=new Set(n);return r.has(e)?r.delete(e):r.add(e),r})},Se=()=>{H(new Set(s.map(e=>e.id)))},Ce=()=>{H(new Set)},we=async()=>{if(V.size===0)return;let e=Array.from(V);L(!0);try{await ib.post(`/v1/memories/batch-delete`,{memory_ids:e,confirm:!0}),ir.success(`已删除 ${e.length} 条记忆`),H(new Set),te(!1),ie(e=>e+1)}catch(e){console.error(`Failed to batch delete:`,e),ir.error(`批量删除失败`)}finally{L(!1)}},Te=f*M<g,Ee=f>1,De=Math.ceil(g/M);return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`记忆列表`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`浏览和管理您的所有记忆`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-4 flex-wrap`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1 max-w-md`,children:[(0,G.jsx)(Lm,{className:`absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground`}),(0,G.jsx)(hb,{type:`text`,placeholder:`搜索记忆内容...`,value:m,onChange:fe,className:`pl-9`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Bm,{className:`size-3.5 text-muted-foreground`}),(0,G.jsxs)(`select`,{value:O,onChange:e=>{k(e.target.value),p(1)},className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[(0,G.jsx)(`option`,{value:`all`,children:`全部分类`}),(0,G.jsx)(`option`,{value:`core`,children:`核心`}),(0,G.jsx)(`option`,{value:`working`,children:`工作区`}),(0,G.jsx)(`option`,{value:`peripheral`,children:`边缘`})]}),(0,G.jsx)(Up,{className:`size-3.5 text-muted-foreground`}),(0,G.jsxs)(`select`,{value:A,onChange:e=>{j(e.target.value),p(1)},className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[(0,G.jsx)(`option`,{value:`updated_at`,children:`按更新时间`}),(0,G.jsx)(`option`,{value:`created_at`,children:`按创建时间`}),(0,G.jsx)(`option`,{value:`importance`,children:`按重要性`}),(0,G.jsx)(`option`,{value:`confidence`,children:`按置信度`}),(0,G.jsx)(`option`,{value:`access_count`,children:`按访问次数`})]}),(0,G.jsxs)(`select`,{value:M,onChange:e=>{N(Number(e.target.value)),p(1)},className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[(0,G.jsx)(`option`,{value:20,children:`20条/页`}),(0,G.jsx)(`option`,{value:50,children:`50条/页`}),(0,G.jsx)(`option`,{value:100,children:`100条/页`})]}),(0,G.jsx)(Em,{className:`size-3.5 text-muted-foreground`}),(0,G.jsxs)(`select`,{value:R,onChange:e=>{z(e.target.value),p(1)},className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[(0,G.jsx)(`option`,{value:`all`,children:`全部记忆`}),(0,G.jsx)(`option`,{value:`global`,children:`普通记忆`}),(0,G.jsx)(`option`,{value:`private`,children:`私密记忆`})]}),se.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dm,{className:`size-3.5 text-muted-foreground`}),(0,G.jsxs)(`select`,{value:ae,onChange:e=>{oe(e.target.value),p(1)},className:`h-9 rounded-md border border-input bg-background px-3 text-sm max-w-[200px] truncate`,children:[(0,G.jsx)(`option`,{value:``,children:`全部项目`}),se.map(e=>(0,G.jsx)(`option`,{value:e,children:e.split(`/`).pop()||e},e))]})]}),pe.length>0&&(0,G.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:me,className:`text-muted-foreground hover:text-foreground`,children:[(0,G.jsx)(Fm,{className:`size-3.5 mr-1`}),`重置筛选`]})]}),(0,G.jsxs)(q,{size:`sm`,onClick:()=>e(`/memories/new`),children:[(0,G.jsx)(Nm,{className:`size-3.5 mr-1.5`}),`新建`]}),(0,G.jsx)(q,{variant:W?`default`:`outline`,size:`sm`,onClick:()=>{ne(!W),W&&Ce()},children:W?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)($m,{className:`size-3.5 mr-1.5`}),`退出管理`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Bm,{className:`size-3.5 mr-1.5`}),`批量管理`]})}),v?(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:ve,children:[(0,G.jsx)(Em,{className:`size-3.5 mr-1.5`}),`锁定 Vault`]}):(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>C(!S),children:[(0,G.jsx)(Tm,{className:`size-3.5 mr-1.5`}),`解锁 Vault`]})]}),pe.length>0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`活跃筛选:`}),pe.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:e.onClear,className:`inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-primary/10 text-primary hover:bg-primary/20 transition-colors`,children:[e.label,(0,G.jsx)($m,{className:`size-3`})]},e.label))]}),W&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between bg-muted/50 rounded-lg px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`span`,{className:`text-sm font-medium`,children:[`已选择 `,V.size,` 条记忆`]}),V.size>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,onClick:Ce,children:`取消选择`}),(0,G.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,onClick:Se,children:`全选本页`})]})]}),V.size>0&&(0,G.jsxs)(q,{variant:`destructive`,size:`sm`,className:`h-7`,onClick:()=>te(!0),children:[(0,G.jsx)(Km,{className:`size-3.5 mr-1`}),`删除 (`,V.size,`)`]})]}),S&&(0,G.jsxs)(`div`,{className:`space-y-2 max-w-md`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(hb,{type:`password`,placeholder:`输入 Vault 密码...`,value:w,onChange:e=>{T(e.target.value),D(null)},onKeyDown:e=>e.key===`Enter`&&_e(),className:E?`border-destructive flex-1`:`flex-1`}),(0,G.jsx)(q,{size:`sm`,onClick:_e,children:`解锁`})]}),E&&(0,G.jsx)(`p`,{className:`text-xs text-destructive`,children:E})]}),!l&&s.length>0&&De>1&&(0,G.jsxs)(`div`,{className:`flex items-center justify-start gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:he,disabled:!Ee||l,children:(0,G.jsx)(Qp,{className:`size-3`})}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground min-w-[3ch] text-center`,children:[f,`/`,De]}),(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:ge,disabled:!Te||l,children:(0,G.jsx)($p,{className:`size-3`})})]}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`共 `,g,` 条`]})]}),(0,G.jsx)(`div`,{className:`space-y-3`,children:l?[1,2,3,4,5].map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 space-y-2`,children:[(0,G.jsx)(Cb,{className:`h-4 w-[95%]`}),(0,G.jsx)(Cb,{className:`h-4 w-[80%]`}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,G.jsx)(Cb,{className:`h-5 w-16`}),(0,G.jsx)(Cb,{className:`h-5 w-12`})]})]},`sk-${e}`)):s.length===0?(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-12 text-center space-y-4`,children:[(0,G.jsx)(_m,{className:`h-12 w-12 text-muted-foreground mx-auto`}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:m||R!==`all`||O!==`all`?`未找到匹配的记忆`:`暂无记忆数据`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m||R!==`all`||O!==`all`?`尝试调整筛选条件或清除搜索`:`开始记录您的第一条记忆吧`})]}),pe.length>0&&(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:me,children:[(0,G.jsx)(Fm,{className:`size-3.5 mr-1.5`}),`清除筛选`]})]}):s.map(e=>{let n=V.has(e.id);return(0,G.jsxs)(`div`,{onClick:()=>W?xe(e.id):de(e.id),className:Tp(`w-full text-left rounded-lg border p-4 cursor-pointer transition-colors relative`,kJ(e.tags,e.visibility)?`border-amber-500/30 bg-amber-500/5 hover:bg-amber-500/10`:`border-border bg-card hover:bg-muted/50`,W&&n&&`ring-2 ring-primary bg-primary/5`),children:[W&&(0,G.jsx)(`div`,{className:`absolute left-3 top-1/2 -translate-y-1/2 z-10`,children:(0,G.jsx)(`input`,{type:`checkbox`,checked:n,onChange:n=>{n.stopPropagation(),xe(e.id)},onClick:e=>e.stopPropagation(),className:`size-4 cursor-pointer`})}),(0,G.jsxs)(`div`,{className:Tp(W&&`pl-8`),children:[(0,G.jsx)(LJ,{memory:e,unlocked:v}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-3 flex-wrap`,children:[(0,G.jsx)(CJ,{variant:`outline`,className:`font-normal text-xs ${AJ(e.category)}`,children:e.category||`未分类`}),(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs ${NJ(e.tier)}`,children:jJ(e.tier)}),kJ(e.tags,e.visibility)&&(0,G.jsxs)(CJ,{variant:`outline`,className:OJ(`私密`,`text-xs`),children:[(0,G.jsx)(Em,{className:`size-2.5 mr-1`}),`私密`]}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-auto flex items-center gap-1.5`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(Jp,{className:`size-3`}),IJ(e.created_at)]}),e.updated_at!==e.created_at&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,G.jsx)(nm,{className:`size-3`}),IJ(e.updated_at)]})]}),!W&&(0,G.jsx)(`button`,{type:`button`,onClick:n=>ye(e.id,n),className:`ml-2 p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors`,title:`删除`,children:(0,G.jsx)(Km,{className:`size-3.5`})})]})]})]},e.id)})}),!l&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`共 `,g,` 条记忆`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:he,disabled:!Ee||l,children:[(0,G.jsx)(Qp,{className:`size-4`}),`上一页`]}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:ge,disabled:!Te||l,children:[`下一页`,(0,G.jsx)($p,{className:`size-4`})]})]})]}),(0,G.jsx)(pJ,{open:!!P,onOpenChange:e=>{!e&&!I&&F(null)},children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除记忆`}),(0,G.jsx)(vJ,{children:`确定要删除这条记忆吗?此操作不可撤销。`})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{onClick:()=>F(null),disabled:I,children:`取消`}),(0,G.jsx)(yJ,{disabled:I,onClick:be,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:I?`删除中...`:`删除`})]})]})}),(0,G.jsx)(pJ,{open:U,onOpenChange:e=>{!e&&!I&&te(!1)},children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认批量删除`}),(0,G.jsxs)(vJ,{children:[`确定要删除选中的 `,V.size,` 条记忆吗?此操作不可撤销。`]})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{onClick:()=>te(!1),disabled:I,children:`取消`}),(0,G.jsx)(yJ,{disabled:I,onClick:e=>{e.preventDefault(),we()},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:I?`删除中...`:`删除 ${V.size} 条`})]})]})})]})}function zJ(e,n){let r=n||{};return(e[e.length-1]===``?[...e,``]:e).join((r.padRight?` `:``)+`,`+(r.padLeft===!1?``:` `)).trim()}var BJ=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,VJ=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,HJ={};function UJ(e,n){return((n||HJ).jsx?VJ:BJ).test(e)}var WJ=/[ \t\n\f\r]/g;function GJ(e){return typeof e==`object`?e.type===`text`?KJ(e.value):!1:KJ(e)}function KJ(e){return e.replace(WJ,``)===``}var qJ=class{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}};qJ.prototype.normal={},qJ.prototype.property={},qJ.prototype.space=void 0;function JJ(e,n){let r={},i={};for(let n of e)Object.assign(r,n.property),Object.assign(i,n.normal);return new qJ(r,i,n)}function YJ(e){return e.toLowerCase()}var XJ=class{constructor(e,n){this.attribute=n,this.property=e}};XJ.prototype.attribute=``,XJ.prototype.booleanish=!1,XJ.prototype.boolean=!1,XJ.prototype.commaOrSpaceSeparated=!1,XJ.prototype.commaSeparated=!1,XJ.prototype.defined=!1,XJ.prototype.mustUseProperty=!1,XJ.prototype.number=!1,XJ.prototype.overloadedBoolean=!1,XJ.prototype.property=``,XJ.prototype.spaceSeparated=!1,XJ.prototype.space=void 0;var ZJ=c({boolean:()=>$J,booleanish:()=>eY,commaOrSpaceSeparated:()=>iY,commaSeparated:()=>rY,number:()=>Q,overloadedBoolean:()=>tY,spaceSeparated:()=>nY}),QJ=0,$J=aY(),eY=aY(),tY=aY(),Q=aY(),nY=aY(),rY=aY(),iY=aY();function aY(){return 2**++QJ}var oY=Object.keys(ZJ),sY=class extends XJ{constructor(e,n,r,i){let a=-1;if(super(e,n),cY(this,`space`,i),typeof r==`number`)for(;++a<oY.length;){let e=oY[a];cY(this,oY[a],(r&ZJ[e])===ZJ[e])}}};sY.prototype.defined=!0;function cY(e,n,r){r&&(e[n]=r)}function lY(e){let n={},r={};for(let[i,a]of Object.entries(e.properties)){let o=new sY(i,e.transform(e.attributes||{},i),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(o.mustUseProperty=!0),n[i]=o,r[YJ(i)]=i,r[YJ(o.attribute)]=i}return new qJ(n,r,e.space)}var uY=lY({properties:{ariaActiveDescendant:null,ariaAtomic:eY,ariaAutoComplete:null,ariaBusy:eY,ariaChecked:eY,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:nY,ariaCurrent:null,ariaDescribedBy:nY,ariaDetails:null,ariaDisabled:eY,ariaDropEffect:nY,ariaErrorMessage:null,ariaExpanded:eY,ariaFlowTo:nY,ariaGrabbed:eY,ariaHasPopup:null,ariaHidden:eY,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:nY,ariaLevel:Q,ariaLive:null,ariaModal:eY,ariaMultiLine:eY,ariaMultiSelectable:eY,ariaOrientation:null,ariaOwns:nY,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:eY,ariaReadOnly:eY,ariaRelevant:null,ariaRequired:eY,ariaRoleDescription:nY,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:eY,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,n){return n===`role`?n:`aria-`+n.slice(4).toLowerCase()}});function dY(e,n){return n in e?e[n]:n}function fY(e,n){return dY(e,n.toLowerCase())}var pY=lY({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:rY,acceptCharset:nY,accessKey:nY,action:null,allow:null,allowFullScreen:$J,allowPaymentRequest:$J,allowUserMedia:$J,alt:null,as:null,async:$J,autoCapitalize:null,autoComplete:nY,autoFocus:$J,autoPlay:$J,blocking:nY,capture:null,charSet:null,checked:$J,cite:null,className:nY,cols:Q,colSpan:null,content:null,contentEditable:eY,controls:$J,controlsList:nY,coords:Q|rY,crossOrigin:null,data:null,dateTime:null,decoding:null,default:$J,defer:$J,dir:null,dirName:null,disabled:$J,download:tY,draggable:eY,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:$J,formTarget:null,headers:nY,height:Q,hidden:tY,high:Q,href:null,hrefLang:null,htmlFor:nY,httpEquiv:nY,id:null,imageSizes:null,imageSrcSet:null,inert:$J,inputMode:null,integrity:null,is:null,isMap:$J,itemId:null,itemProp:nY,itemRef:nY,itemScope:$J,itemType:nY,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:$J,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:$J,muted:$J,name:null,nonce:null,noModule:$J,noValidate:$J,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:$J,optimum:Q,pattern:null,ping:nY,placeholder:null,playsInline:$J,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:$J,referrerPolicy:null,rel:nY,required:$J,reversed:$J,rows:Q,rowSpan:Q,sandbox:nY,scope:null,scoped:$J,seamless:$J,selected:$J,shadowRootClonable:$J,shadowRootDelegatesFocus:$J,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:eY,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:$J,useMap:null,value:eY,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:nY,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:$J,declare:$J,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:$J,noHref:$J,noShade:$J,noWrap:$J,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:eY,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:$J,disableRemotePlayback:$J,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:fY}),mY=lY({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:iY,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:nY,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:$J,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:rY,g2:rY,glyphName:rY,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:iY,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:nY,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:iY,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:iY,rev:iY,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:iY,requiredFeatures:iY,requiredFonts:iY,requiredFormats:iY,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:iY,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:iY,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:iY,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:dY}),hY=lY({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,n){return`xlink:`+n.slice(5).toLowerCase()}}),gY=lY({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:fY}),_Y=lY({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,n){return`xml:`+n.slice(3).toLowerCase()}}),vY={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},yY=/[A-Z]/g,bY=/-[a-z]/g,xY=/^data[-\w.:]+$/i;function SY(e,n){let r=YJ(n),i=n,a=XJ;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&r.slice(0,4)===`data`&&xY.test(n)){if(n.charAt(4)===`-`){let e=n.slice(5).replace(bY,wY);i=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=n.slice(4);if(!bY.test(e)){let r=e.replace(yY,CY);r.charAt(0)!==`-`&&(r=`-`+r),n=`data`+r}}a=sY}return new a(i,n)}function CY(e){return`-`+e.toLowerCase()}function wY(e){return e.charAt(1).toUpperCase()}var TY=JJ([uY,pY,hY,gY,_Y],`html`),EY=JJ([uY,mY,hY,gY,_Y],`svg`);function DY(e){return e.join(` `).trim()}var OY=s(((e,n)=>{var r=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,i=/\n/g,a=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,u=/^\s+|\s+$/g,d=`
|
|
83
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Oq(e,n){if(e){if(typeof e==`string`)return jq(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`)return Array.from(e);if(r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return jq(e,n)}}function kq(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Aq(e){if(Array.isArray(e))return jq(e)}function jq(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function Mq(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function Z(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]==null?{}:arguments[n];n%2?Mq(Object(r),!0).forEach(function(n){Nq(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Mq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Nq(e,n,r){return n=Pq(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function Pq(e){var n=Fq(e,`string`);return cq(n)==`symbol`?n:n+``}function Fq(e,n){if(cq(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(cq(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}var Iq={xAxis:[`bottom`,`top`],yAxis:[`left`,`right`]},Lq={width:`100%`,height:`100%`},Rq={x:0,y:0};function zq(e){return e}var Bq=function(e,n){return n===`horizontal`?e.x:n===`vertical`?e.y:n===`centric`?e.angle:e.radius},Vq=function(e,n,r,i){var a=n.find(function(e){return e&&e.index===r});if(a){if(e===`horizontal`)return{x:a.coordinate,y:i.y};if(e===`vertical`)return{x:i.x,y:a.coordinate};if(e===`centric`){var o=a.coordinate,s=i.radius;return Z(Z(Z({},i),JF(i.cx,i.cy,s,o)),{},{angle:o,radius:s})}var c=a.coordinate,l=i.angle;return Z(Z(Z({},i),JF(i.cx,i.cy,c,l)),{},{angle:l,radius:c})}return Rq},Hq=function(e,n){var r=n.graphicalItems,i=n.dataStartIndex,a=n.dataEndIndex,o=(r??[]).reduce(function(e,n){var r=n.props.data;return r&&r.length?[].concat(Eq(e),Eq(r)):e},[]);return o.length>0?o:e&&e.length&&Y(i)&&Y(a)?e.slice(i,a+1):[]};function Uq(e){return e===`number`?[0,`auto`]:void 0}var Wq=function(e,n,r,i){var a=e.graphicalItems,o=e.tooltipAxis,s=Hq(n,e);return r<0||!a||!a.length||r>=s.length?null:a.reduce(function(a,c){var l=c.props.data??n;l&&e.dataStartIndex+e.dataEndIndex!==0&&e.dataEndIndex-e.dataStartIndex>=r&&(l=l.slice(e.dataStartIndex,e.dataEndIndex+1));var u=o.dataKey&&!o.allowDuplicatedCategory?Ux(l===void 0?s:l,o.dataKey,i):l&&l[r]||s[r];return u?[].concat(Eq(a),[VF(c,u)]):a},[])},Gq=function(e,n,r,i){var a=i||{x:e.chartX,y:e.chartY},o=Bq(a,r),s=e.orderedTooltipTicks,c=e.tooltipAxis,l=e.tooltipTicks,u=rre(o,s,l,c);if(u>=0&&l){var d=l[u]&&l[u].value;return{activeTooltipIndex:u,activeLabel:d,activePayload:Wq(e,n,u,d),activeCoordinate:Vq(r,s,u,a)}}return null},Kq=function(e,n){var r=n.axes,i=n.graphicalItems,a=n.axisType,o=n.axisIdKey,s=n.stackGroups,c=n.dataStartIndex,l=n.dataEndIndex,u=e.layout,d=e.children,f=e.stackOffset,p=wF(u,a);return r.reduce(function(n,r){var m=r.type.defaultProps===void 0?r.props:Z(Z({},r.type.defaultProps),r.props),h=m.type,g=m.dataKey,_=m.allowDataOverflow,v=m.allowDuplicatedCategory,y=m.scale,b=m.ticks,x=m.includeHidden,S=m[o];if(n[S])return n;var C=Hq(e.data,{graphicalItems:i.filter(function(e){return(o in e.props?e.props[o]:e.type.defaultProps?.[o])===S}),dataStartIndex:c,dataEndIndex:l}),w=C.length,T,E,D;YK(m.domain,_,h)&&(T=RF(m.domain,null,_),p&&(h===`number`||y!==`auto`)&&(D=bF(C,g,`category`)));var O=Uq(h);if(!T||T.length===0){var k=m.domain??O;if(g){if(T=bF(C,g,h),h===`category`&&p){var A=Vx(T);v&&A?(E=T,T=(0,VB.default)(0,w)):v||(T=BF(k,T,r).reduce(function(e,n){return e.indexOf(n)>=0?e:[].concat(Eq(e),[n])},[]))}else if(h===`category`)T=v?T.filter(function(e){return e!==``&&!(0,Mx.default)(e)}):BF(k,T,r).reduce(function(e,n){return e.indexOf(n)>=0||n===``||(0,Mx.default)(n)?e:[].concat(Eq(e),[n])},[]);else if(h===`number`){var j=cre(C,i.filter(function(e){var n=o in e.props?e.props[o]:e.type.defaultProps?.[o],r=`hide`in e.props?e.props.hide:e.type.defaultProps?.hide;return n===S&&(x||!r)}),g,a,u);j&&(T=j)}p&&(h===`number`||y!==`auto`)&&(D=bF(C,g,`category`))}else T=p?(0,VB.default)(0,w):s&&s[S]&&s[S].hasStack&&h===`number`?f===`expand`?[0,1]:FF(s[S].stackGroups,c,l):CF(C,i.filter(function(e){var n=o in e.props?e.props[o]:e.type.defaultProps[o],r=`hide`in e.props?e.props.hide:e.type.defaultProps.hide;return n===S&&(x||!r)}),h,u,!0);if(h===`number`)T=RK(d,T,S,a,b),k&&(T=RF(k,T,_));else if(h===`category`&&k){var M=k;T.every(function(e){return M.indexOf(e)>=0})&&(T=M)}}return Z(Z({},n),{},Nq({},S,Z(Z({},m),{},{axisType:a,domain:T,categoricalDomain:D,duplicateDomain:E,originalDomain:m.domain??O,isCategorical:p,layout:u})))},{})},qq=function(e,n){var r=n.graphicalItems,i=n.Axis,a=n.axisType,o=n.axisIdKey,s=n.stackGroups,c=n.dataStartIndex,l=n.dataEndIndex,u=e.layout,d=e.children,f=Hq(e.data,{graphicalItems:r,dataStartIndex:c,dataEndIndex:l}),p=f.length,m=wF(u,a),h=-1;return r.reduce(function(e,n){var g=(n.type.defaultProps===void 0?n.props:Z(Z({},n.type.defaultProps),n.props))[o],_=Uq(`number`);if(!e[g]){h++;var v;return m?v=(0,VB.default)(0,p):s&&s[g]&&s[g].hasStack?(v=FF(s[g].stackGroups,c,l),v=RK(d,v,g,a)):(v=RF(_,CF(f,r.filter(function(e){var n=o in e.props?e.props[o]:e.type.defaultProps?.[o],r=`hide`in e.props?e.props.hide:e.type.defaultProps?.hide;return n===g&&!r}),`number`,u),i.defaultProps.allowDataOverflow),v=RK(d,v,g,a)),Z(Z({},e),{},Nq({},g,Z(Z({axisType:a},i.defaultProps),{},{hide:!0,orientation:(0,Ax.default)(Iq,`${a}.${h%2}`,null),domain:v,originalDomain:_,isCategorical:m,layout:u})))}return e},{})},Jq=function(e,n){var r=n.axisType,i=r===void 0?`xAxis`:r,a=n.AxisComp,o=n.graphicalItems,s=n.stackGroups,c=n.dataStartIndex,l=n.dataEndIndex,u=e.children,d=`${i}Id`,f=mS(u,a),p={};return f&&f.length?p=Kq(e,{axes:f,graphicalItems:o,axisType:i,axisIdKey:d,stackGroups:s,dataStartIndex:c,dataEndIndex:l}):o&&o.length&&(p=qq(e,{Axis:a,graphicalItems:o,axisType:i,axisIdKey:d,stackGroups:s,dataStartIndex:c,dataEndIndex:l})),p},Yq=function(e){var n=Bx(e),r=EF(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:(0,HT.default)(r,function(e){return e.coordinate}),tooltipAxis:n,tooltipAxisBandSize:zF(n,r)}},Xq=function(e){var n=e.children,r=e.defaultShowTooltip,i=hS(n,sV),a=0,o=0;return e.data&&e.data.length!==0&&(o=e.data.length-1),i&&i.props&&(i.props.startIndex>=0&&(a=i.props.startIndex),i.props.endIndex>=0&&(o=i.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:a,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!r}},Zq=function(e){return!e||!e.length?!1:e.some(function(e){var n=uS(e&&e.type);return n&&n.indexOf(`Bar`)>=0})},Qq=function(e){return e===`horizontal`?{numericAxisName:`yAxis`,cateAxisName:`xAxis`}:e===`vertical`?{numericAxisName:`xAxis`,cateAxisName:`yAxis`}:e===`centric`?{numericAxisName:`radiusAxis`,cateAxisName:`angleAxis`}:{numericAxisName:`angleAxis`,cateAxisName:`radiusAxis`}},$q=function(e,n){var r=e.props,i=e.graphicalItems,a=e.xAxisMap,o=a===void 0?{}:a,s=e.yAxisMap,c=s===void 0?{}:s,l=r.width,u=r.height,d=r.children,f=r.margin||{},p=hS(d,sV),m=hS(d,FT),h=Object.keys(c).reduce(function(e,n){var r=c[n],i=r.orientation;return!r.mirror&&!r.hide?Z(Z({},e),{},Nq({},i,e[i]+r.width)):e},{left:f.left||0,right:f.right||0}),g=Z(Z({},Object.keys(o).reduce(function(e,n){var r=o[n],i=r.orientation;return!r.mirror&&!r.hide?Z(Z({},e),{},Nq({},i,(0,Ax.default)(e,`${i}`)+r.height)):e},{top:f.top||0,bottom:f.bottom||0})),h),_=g.bottom;p&&(g.bottom+=p.props.height||sV.defaultProps.height),m&&n&&(g=ore(g,i,r,n));var v=l-g.left-g.right,y=u-g.top-g.bottom;return Z(Z({brushBottom:_},g),{},{width:Math.max(v,0),height:Math.max(y,0)})},eJ=function(e,n){if(n===`xAxis`)return e[n].width;if(n===`yAxis`)return e[n].height},tJ=function(e){var n=e.chartName,r=e.GraphicalChild,i=e.defaultTooltipEventType,a=i===void 0?`axis`:i,o=e.validateTooltipEventTypes,s=o===void 0?[`axis`]:o,c=e.axisComponents,l=e.legendContent,u=e.formatAxisMap,d=e.defaultProps,f=function(e,n){var r=n.graphicalItems,i=n.stackGroups,a=n.offset,o=n.updateId,s=n.dataStartIndex,l=n.dataEndIndex,u=e.barSize,d=e.layout,f=e.barGap,p=e.barCategoryGap,m=e.maxBarSize,h=Qq(d),g=h.numericAxisName,_=h.cateAxisName,v=Zq(r),y=[];return r.forEach(function(r,h){var b=Hq(e.data,{graphicalItems:[r],dataStartIndex:s,dataEndIndex:l}),x=r.type.defaultProps===void 0?r.props:Z(Z({},r.type.defaultProps),r.props),S=x.dataKey,C=x.maxBarSize,w=x[`${g}Id`],T=x[`${_}Id`],E=c.reduce(function(e,r){var i=n[`${r.axisType}Map`],a=x[`${r.axisType}Id`];!(i&&i[a]||r.axisType===`zAxis`)&&YP(!1);var o=i[a];return Z(Z({},e),{},Nq(Nq({},r.axisType,o),`${r.axisType}Ticks`,EF(o)))},{}),D=E[_],O=E[`${_}Ticks`],k=i&&i[w]&&i[w].hasStack&&hre(r,i[w].stackGroups),A=uS(r.type).indexOf(`Bar`)>=0,j=zF(D,O),M=[],N=v&&ire({barSize:u,stackGroups:i,totalSize:eJ(E,_)});if(A){var P=(0,Mx.default)(C)?m:C,F=zF(D,O,!0)??P??0;M=are({barGap:f,barCategoryGap:p,bandSize:F===j?j:F,sizeList:N[T],maxBarSize:P}),F!==j&&(M=M.map(function(e){return Z(Z({},e),{},{position:Z(Z({},e.position),{},{offset:e.position.offset-F/2})})}))}var I=r&&r.type&&r.type.getComposedData;I&&y.push({props:Z(Z({},I(Z(Z({},E),{},{displayedData:b,props:e,dataKey:S,item:r,bandSize:j,barPosition:M,offset:a,stackedData:k,layout:d,dataStartIndex:s,dataEndIndex:l}))),{},Nq(Nq(Nq({key:r.key||`item-${h}`},g,E[g]),_,E[_]),`animationId`,o)),childIndex:ES(r,e.children),item:r})}),y},p=function(e,i){var a=e.props,o=e.dataStartIndex,s=e.dataEndIndex,l=e.updateId;if(!gS({props:a}))return null;var d=a.children,p=a.layout,m=a.stackOffset,h=a.data,g=a.reverseStackOrder,_=Qq(p),v=_.numericAxisName,y=_.cateAxisName,b=mS(d,r),x=pre(h,b,`${v}Id`,`${y}Id`,m,g),S=c.reduce(function(e,n){var r=`${n.axisType}Map`;return Z(Z({},e),{},Nq({},r,Jq(a,Z(Z({},n),{},{graphicalItems:b,stackGroups:n.axisType===v&&x,dataStartIndex:o,dataEndIndex:s}))))},{}),C=$q(Z(Z({},S),{},{props:a,graphicalItems:b}),i?.legendBBox);Object.keys(S).forEach(function(e){S[e]=u(a,S[e],C,e.replace(`Map`,``),n)});var w=S[`${y}Map`],T=Yq(w);return Z(Z({formattedGraphicalItems:f(a,Z(Z({},S),{},{dataStartIndex:o,dataEndIndex:s,updateId:l,graphicalItems:b,stackGroups:x,offset:C})),graphicalItems:b,offset:C,stackGroups:x},T),S)},m=function(e){function r(e){var i;return gq(this,r),i=yq(this,r,[e]),Nq(i,`eventEmitterSymbol`,Symbol(`rechartsEventEmitter`)),Nq(i,`accessibilityManager`,new JK),Nq(i,`handleLegendBBoxUpdate`,function(e){if(e){var n=i.state,r=n.dataStartIndex,a=n.dataEndIndex,o=n.updateId;i.setState(Z({legendBBox:e},p({props:i.props,dataStartIndex:r,dataEndIndex:a,updateId:o},Z(Z({},i.state),{},{legendBBox:e}))))}}),Nq(i,`handleReceiveSyncEvent`,function(e,n,r){if(i.props.syncId===e){if(r===i.eventEmitterSymbol&&typeof i.props.syncMethod!=`function`)return;i.applySyncEvent(n)}}),Nq(i,`handleBrushChange`,function(e){var n=e.startIndex,r=e.endIndex;if(n!==i.state.dataStartIndex||r!==i.state.dataEndIndex){var a=i.state.updateId;i.setState(function(){return Z({dataStartIndex:n,dataEndIndex:r},p({props:i.props,dataStartIndex:n,dataEndIndex:r,updateId:a},i.state))}),i.triggerSyncEvent({dataStartIndex:n,dataEndIndex:r})}}),Nq(i,`handleMouseEnter`,function(e){var n=i.getMouseInfo(e);if(n){var r=Z(Z({},n),{},{isTooltipActive:!0});i.setState(r),i.triggerSyncEvent(r);var a=i.props.onMouseEnter;(0,nS.default)(a)&&a(r,e)}}),Nq(i,`triggeredAfterMouseMove`,function(e){var n=i.getMouseInfo(e),r=n?Z(Z({},n),{},{isTooltipActive:!0}):{isTooltipActive:!1};i.setState(r),i.triggerSyncEvent(r);var a=i.props.onMouseMove;(0,nS.default)(a)&&a(r,e)}),Nq(i,`handleItemMouseEnter`,function(e){i.setState(function(){return{isTooltipActive:!0,activeItem:e,activePayload:e.tooltipPayload,activeCoordinate:e.tooltipPosition||{x:e.cx,y:e.cy}}})}),Nq(i,`handleItemMouseLeave`,function(){i.setState(function(){return{isTooltipActive:!1}})}),Nq(i,`handleMouseMove`,function(e){e.persist(),i.throttleTriggeredAfterMouseMove(e)}),Nq(i,`handleMouseLeave`,function(e){i.throttleTriggeredAfterMouseMove.cancel();var n={isTooltipActive:!1};i.setState(n),i.triggerSyncEvent(n);var r=i.props.onMouseLeave;(0,nS.default)(r)&&r(n,e)}),Nq(i,`handleOuterEvent`,function(e){var n=TS(e),r=(0,Ax.default)(i.props,`${n}`);n&&(0,nS.default)(r)&&r((/.*touch.*/i.test(n)?i.getMouseInfo(e.changedTouches[0]):i.getMouseInfo(e))??{},e)}),Nq(i,`handleClick`,function(e){var n=i.getMouseInfo(e);if(n){var r=Z(Z({},n),{},{isTooltipActive:!0});i.setState(r),i.triggerSyncEvent(r);var a=i.props.onClick;(0,nS.default)(a)&&a(r,e)}}),Nq(i,`handleMouseDown`,function(e){var n=i.props.onMouseDown;(0,nS.default)(n)&&n(i.getMouseInfo(e),e)}),Nq(i,`handleMouseUp`,function(e){var n=i.props.onMouseUp;(0,nS.default)(n)&&n(i.getMouseInfo(e),e)}),Nq(i,`handleTouchMove`,function(e){e.changedTouches!=null&&e.changedTouches.length>0&&i.throttleTriggeredAfterMouseMove(e.changedTouches[0])}),Nq(i,`handleTouchStart`,function(e){e.changedTouches!=null&&e.changedTouches.length>0&&i.handleMouseDown(e.changedTouches[0])}),Nq(i,`handleTouchEnd`,function(e){e.changedTouches!=null&&e.changedTouches.length>0&&i.handleMouseUp(e.changedTouches[0])}),Nq(i,`handleDoubleClick`,function(e){var n=i.props.onDoubleClick;(0,nS.default)(n)&&n(i.getMouseInfo(e),e)}),Nq(i,`handleContextMenu`,function(e){var n=i.props.onContextMenu;(0,nS.default)(n)&&n(i.getMouseInfo(e),e)}),Nq(i,`triggerSyncEvent`,function(e){i.props.syncId!==void 0&&zK.emit(BK,i.props.syncId,e,i.eventEmitterSymbol)}),Nq(i,`applySyncEvent`,function(e){var n=i.props,r=n.layout,a=n.syncMethod,o=i.state.updateId,s=e.dataStartIndex,c=e.dataEndIndex;if(e.dataStartIndex!==void 0||e.dataEndIndex!==void 0)i.setState(Z({dataStartIndex:s,dataEndIndex:c},p({props:i.props,dataStartIndex:s,dataEndIndex:c,updateId:o},i.state)));else if(e.activeTooltipIndex!==void 0){var l=e.chartX,u=e.chartY,d=e.activeTooltipIndex,f=i.state,m=f.offset,h=f.tooltipTicks;if(!m)return;if(typeof a==`function`)d=a(h,e);else if(a===`value`){d=-1;for(var g=0;g<h.length;g++)if(h[g].value===e.activeLabel){d=g;break}}var _=Z(Z({},m),{},{x:m.left,y:m.top}),v=Math.min(l,_.x+_.width),y=Math.min(u,_.y+_.height),b=h[d]&&h[d].value,x=Wq(i.state,i.props.data,d),S=h[d]?{x:r===`horizontal`?h[d].coordinate:v,y:r===`horizontal`?y:h[d].coordinate}:Rq;i.setState(Z(Z({},e),{},{activeLabel:b,activeCoordinate:S,activePayload:x,activeTooltipIndex:d}))}else i.setState(e)}),Nq(i,`renderCursor`,function(e){var r=i.state,a=r.isTooltipActive,o=r.activeCoordinate,s=r.activePayload,c=r.offset,l=r.activeTooltipIndex,u=r.tooltipAxisBandSize,d=i.getTooltipEventType(),f=e.props.active??a,p=i.props.layout,m=e.key||`_recharts-cursor`;return y.createElement(aq,{key:m,activeCoordinate:o,activePayload:s,activeTooltipIndex:l,chartName:n,element:e,isActive:f,layout:p,offset:c,tooltipAxisBandSize:u,tooltipEventType:d})}),Nq(i,`renderPolarAxis`,function(e,n,r){var a=(0,Ax.default)(e,`type.axisType`),o=(0,Ax.default)(i.state,`${a}Map`),s=e.type.defaultProps,c=s===void 0?e.props:Z(Z({},s),e.props),l=o&&o[c[`${a}Id`]];return(0,y.cloneElement)(e,Z(Z({},l),{},{className:Zd(a,l.className),key:e.key||`${n}-${r}`,ticks:EF(l,!0)}))}),Nq(i,`renderPolarGrid`,function(e){var n=e.props,r=n.radialLines,a=n.polarAngles,o=n.polarRadius,s=i.state,c=s.radiusAxisMap,l=s.angleAxisMap,u=Bx(c),d=Bx(l),f=d.cx,p=d.cy,m=d.innerRadius,h=d.outerRadius;return(0,y.cloneElement)(e,{polarAngles:Array.isArray(a)?a:EF(d,!0).map(function(e){return e.coordinate}),polarRadius:Array.isArray(o)?o:EF(u,!0).map(function(e){return e.coordinate}),cx:f,cy:p,innerRadius:m,outerRadius:h,key:e.key||`polar-grid`,radialLines:r})}),Nq(i,`renderLegend`,function(){var e=i.state.formattedGraphicalItems,n=i.props,r=n.children,a=n.width,o=n.height,s=i.props.margin||{},c=lF({children:r,formattedGraphicalItems:e,legendWidth:a-(s.left||0)-(s.right||0),legendContent:l});if(!c)return null;var u=c.item;return(0,y.cloneElement)(u,Z(Z({},mq(c,oq)),{},{chartWidth:a,chartHeight:o,margin:s,onBBoxUpdate:i.handleLegendBBoxUpdate}))}),Nq(i,`renderTooltip`,function(){var e=i.props,n=e.children,r=e.accessibilityLayer,a=hS(n,VE);if(!a)return null;var o=i.state,s=o.isTooltipActive,c=o.activeCoordinate,l=o.activePayload,u=o.activeLabel,d=o.offset,f=a.props.active??s;return(0,y.cloneElement)(a,{viewBox:Z(Z({},d),{},{x:d.left,y:d.top}),active:f,label:u,payload:f?l:[],coordinate:c,accessibilityLayer:r})}),Nq(i,`renderBrush`,function(e){var n=i.props,r=n.margin,a=n.data,o=i.state,s=o.offset,c=o.dataStartIndex,l=o.dataEndIndex,u=o.updateId;return(0,y.cloneElement)(e,{key:e.key||`_recharts-brush`,onChange:OF(i.handleBrushChange,e.props.onChange),data:a,x:Y(e.props.x)?e.props.x:s.left,y:Y(e.props.y)?e.props.y:s.top+s.height+s.brushBottom-(r.bottom||0),width:Y(e.props.width)?e.props.width:s.width,startIndex:c,endIndex:l,updateId:`brush-${u}`})}),Nq(i,`renderReferenceElement`,function(e,n,r){if(!e)return null;var a=i.clipPathId,o=i.state,s=o.xAxisMap,c=o.yAxisMap,l=o.offset,u=e.type.defaultProps||{},d=e.props,f=d.xAxisId,p=f===void 0?u.xAxisId:f,m=d.yAxisId,h=m===void 0?u.yAxisId:m;return(0,y.cloneElement)(e,{key:e.key||`${n}-${r}`,xAxis:s[p],yAxis:c[h],viewBox:{x:l.left,y:l.top,width:l.width,height:l.height},clipPathId:a})}),Nq(i,`renderActivePoints`,function(e){var n=e.item,i=e.activePoint,a=e.basePoint,o=e.childIndex,s=e.isRange,c=[],l=n.props.key,u=n.item.type.defaultProps===void 0?n.item.props:Z(Z({},n.item.type.defaultProps),n.item.props),d=u.activeDot,f=u.dataKey,p=Z(Z({index:o,dataKey:f,cx:i.x,cy:i.y,r:4,fill:xF(n.item),strokeWidth:2,stroke:`#fff`,payload:i.payload,value:i.value},xS(d,!1)),$x(d));return c.push(r.renderActiveDot(d,p,`${l}-activePoint-${o}`)),a?c.push(r.renderActiveDot(d,Z(Z({},p),{},{cx:a.x,cy:a.y}),`${l}-basePoint-${o}`)):s&&c.push(null),c}),Nq(i,`renderGraphicChild`,function(e,n,r){var a=i.filterFormatItem(e,n,r);if(!a)return null;var o=i.getTooltipEventType(),s=i.state,c=s.isTooltipActive,l=s.tooltipAxis,u=s.activeTooltipIndex,d=s.activeLabel,f=i.props.children,p=hS(f,VE),m=a.props,h=m.points,g=m.isRange,_=m.baseLine,v=a.item.type.defaultProps===void 0?a.item.props:Z(Z({},a.item.type.defaultProps),a.item.props),b=v.activeDot,x=v.hide,S=v.activeBar,C=v.activeShape,w=!!(!x&&c&&p&&(b||S||C)),T={};o!==`axis`&&p&&p.props.trigger===`click`?T={onClick:OF(i.handleItemMouseEnter,e.props.onClick)}:o!==`axis`&&(T={onMouseLeave:OF(i.handleItemMouseLeave,e.props.onMouseLeave),onMouseEnter:OF(i.handleItemMouseEnter,e.props.onMouseEnter)});var E=(0,y.cloneElement)(e,Z(Z({},a.props),T));function D(e){return typeof l.dataKey==`function`?l.dataKey(e.payload):null}if(w)if(u>=0){var O,k;if(l.dataKey&&!l.allowDuplicatedCategory){var A=typeof l.dataKey==`function`?D:`payload.${l.dataKey.toString()}`;O=Ux(h,A,d),k=g&&_&&Ux(_,A,d)}else O=h?.[u],k=g&&_&&_[u];if(C||S){var j=e.props.activeIndex===void 0?u:e.props.activeIndex;return[(0,y.cloneElement)(e,Z(Z(Z({},a.props),T),{},{activeIndex:j})),null,null]}if(!(0,Mx.default)(O))return[E].concat(Eq(i.renderActivePoints({item:a,activePoint:O,basePoint:k,childIndex:u,isRange:g})))}else{var M=(i.getItemByXY(i.state.activeCoordinate)??{graphicalItem:E}).graphicalItem,N=M.item,P=N===void 0?e:N,F=M.childIndex;return[(0,y.cloneElement)(P,Z(Z(Z({},a.props),T),{},{activeIndex:F})),null,null]}return g?[E,null,null]:[E,null]}),Nq(i,`renderCustomized`,function(e,n,r){return(0,y.cloneElement)(e,Z(Z({key:`recharts-customized-${r}`},i.props),i.state))}),Nq(i,`renderMap`,{CartesianGrid:{handler:zq,once:!0},ReferenceArea:{handler:i.renderReferenceElement},ReferenceLine:{handler:zq},ReferenceDot:{handler:i.renderReferenceElement},XAxis:{handler:zq},YAxis:{handler:zq},Brush:{handler:i.renderBrush,once:!0},Bar:{handler:i.renderGraphicChild},Line:{handler:i.renderGraphicChild},Area:{handler:i.renderGraphicChild},Radar:{handler:i.renderGraphicChild},RadialBar:{handler:i.renderGraphicChild},Scatter:{handler:i.renderGraphicChild},Pie:{handler:i.renderGraphicChild},Funnel:{handler:i.renderGraphicChild},Tooltip:{handler:i.renderCursor,once:!0},PolarGrid:{handler:i.renderPolarGrid,once:!0},PolarAngleAxis:{handler:i.renderPolarAxis},PolarRadiusAxis:{handler:i.renderPolarAxis},Customized:{handler:i.renderCustomized}}),i.clipPathId=`${e.id??Rx(`recharts`)}-clip`,i.throttleTriggeredAfterMouseMove=(0,qE.default)(i.triggeredAfterMouseMove,e.throttleDelay??1e3/60),i.state={},i}return wq(r,e),vq(r,[{key:`componentDidMount`,value:function(){this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:this.props.margin.left??0,top:this.props.margin.top??0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:`displayDefaultTooltip`,value:function(){var e=this.props,n=e.children,r=e.data,i=e.height,a=e.layout,o=hS(n,VE);if(o){var s=o.props.defaultIndex;if(!(typeof s!=`number`||s<0||s>this.state.tooltipTicks.length-1)){var c=this.state.tooltipTicks[s]&&this.state.tooltipTicks[s].value,l=Wq(this.state,r,s,c),u=this.state.tooltipTicks[s].coordinate,d=(this.state.offset.top+i)/2,f=a===`horizontal`?{x:u,y:d}:{y:u,x:d},p=this.state.formattedGraphicalItems.find(function(e){return e.item.type.name===`Scatter`});p&&(f=Z(Z({},f),p.props.points[s].tooltipPosition),l=p.props.points[s].tooltipPayload);var m={activeTooltipIndex:s,isTooltipActive:!0,activeLabel:c,activePayload:l,activeCoordinate:f};this.setState(m),this.renderCursor(o),this.accessibilityManager.setIndex(s)}}}},{key:`getSnapshotBeforeUpdate`,value:function(e,n){return this.props.accessibilityLayer?(this.state.tooltipTicks!==n.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==e.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==e.margin&&this.accessibilityManager.setDetails({offset:{left:this.props.margin.left??0,top:this.props.margin.top??0}}),null):null}},{key:`componentDidUpdate`,value:function(e){SS([hS(e.children,VE)],[hS(this.props.children,VE)])||this.displayDefaultTooltip()}},{key:`componentWillUnmount`,value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:`getTooltipEventType`,value:function(){var e=hS(this.props.children,VE);if(e&&typeof e.props.shared==`boolean`){var n=e.props.shared?`axis`:`item`;return s.indexOf(n)>=0?n:a}return a}},{key:`getMouseInfo`,value:function(e){if(!this.container)return null;var n=this.container,r=n.getBoundingClientRect(),i=bD(r),a={chartX:Math.round(e.pageX-i.left),chartY:Math.round(e.pageY-i.top)},o=r.width/n.offsetWidth||1,s=this.inRange(a.chartX,a.chartY,o);if(!s)return null;var c=this.state,l=c.xAxisMap,u=c.yAxisMap,d=this.getTooltipEventType(),f=Gq(this.state,this.props.data,this.props.layout,s);if(d!==`axis`&&l&&u){var p=Bx(l).scale,m=Bx(u).scale,h=p&&p.invert?p.invert(a.chartX):null,g=m&&m.invert?m.invert(a.chartY):null;return Z(Z({},a),{},{xValue:h,yValue:g},f)}return f?Z(Z({},a),f):null}},{key:`inRange`,value:function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,i=this.props.layout,a=e/r,o=n/r;if(i===`horizontal`||i===`vertical`){var s=this.state.offset;return a>=s.left&&a<=s.left+s.width&&o>=s.top&&o<=s.top+s.height?{x:a,y:o}:null}var c=this.state,l=c.angleAxisMap,u=c.radiusAxisMap;if(l&&u){var d=Bx(l);return XF({x:a,y:o},d)}return null}},{key:`parseEventsOfWrapper`,value:function(){var e=this.props.children,n=this.getTooltipEventType(),r=hS(e,VE),i={};return r&&n===`axis`&&(i=r.props.trigger===`click`?{onClick:this.handleClick}:{onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu}),Z(Z({},$x(this.props,this.handleOuterEvent)),i)}},{key:`addListener`,value:function(){zK.on(BK,this.handleReceiveSyncEvent)}},{key:`removeListener`,value:function(){zK.removeListener(BK,this.handleReceiveSyncEvent)}},{key:`filterFormatItem`,value:function(e,n,r){for(var i=this.state.formattedGraphicalItems,a=0,o=i.length;a<o;a++){var s=i[a];if(s.item===e||s.props.key===e.key||n===uS(s.item.type)&&r===s.childIndex)return s}return null}},{key:`renderClipPath`,value:function(){var e=this.clipPathId,n=this.state.offset,r=n.left,i=n.top,a=n.height,o=n.width;return y.createElement(`defs`,null,y.createElement(`clipPath`,{id:e},y.createElement(`rect`,{x:r,y:i,height:a,width:o})))}},{key:`getXScales`,value:function(){var e=this.state.xAxisMap;return e?Object.entries(e).reduce(function(e,n){var r=uq(n,2),i=r[0],a=r[1];return Z(Z({},e),{},Nq({},i,a.scale))},{}):null}},{key:`getYScales`,value:function(){var e=this.state.yAxisMap;return e?Object.entries(e).reduce(function(e,n){var r=uq(n,2),i=r[0],a=r[1];return Z(Z({},e),{},Nq({},i,a.scale))},{}):null}},{key:`getXScaleByAxisId`,value:function(e){var n;return(n=this.state.xAxisMap)==null||(n=n[e])==null?void 0:n.scale}},{key:`getYScaleByAxisId`,value:function(e){var n;return(n=this.state.yAxisMap)==null||(n=n[e])==null?void 0:n.scale}},{key:`getItemByXY`,value:function(e){var n=this.state,r=n.formattedGraphicalItems,i=n.activeItem;if(r&&r.length)for(var a=0,o=r.length;a<o;a++){var s=r[a],c=s.props,l=s.item,u=l.type.defaultProps===void 0?l.props:Z(Z({},l.type.defaultProps),l.props),d=uS(l.type);if(d===`Bar`){var f=(c.data||[]).find(function(n){return YL(e,n)});if(f)return{graphicalItem:s,payload:f}}else if(d===`RadialBar`){var p=(c.data||[]).find(function(n){return XF(e,n)});if(p)return{graphicalItem:s,payload:p}}else if(eB(s,i)||tB(s,i)||nB(s,i)){var m=lB({graphicalItem:s,activeTooltipItem:i,itemData:u.data}),h=u.activeIndex===void 0?m:u.activeIndex;return{graphicalItem:Z(Z({},s),{},{childIndex:h}),payload:nB(s,i)?u.data[m]:s.props.data[m]}}}return null}},{key:`render`,value:function(){var e=this;if(!gS(this))return null;var n=this.props,r=n.children,i=n.className,a=n.width,o=n.height,s=n.style,c=n.compact,l=n.title,u=n.desc,d=xS(mq(n,sq),!1);if(c)return y.createElement(OH,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},y.createElement(jS,lq({},d,{width:a,height:o,title:l,desc:u}),this.renderClipPath(),wS(r,this.renderMap)));this.props.accessibilityLayer&&(d.tabIndex=this.props.tabIndex??0,d.role=this.props.role??`application`,d.onKeyDown=function(n){e.accessibilityManager.keyboardEvent(n)},d.onFocus=function(){e.accessibilityManager.focus()});var f=this.parseEventsOfWrapper();return y.createElement(OH,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},y.createElement(`div`,lq({className:Zd(`recharts-wrapper`,i),style:Z({position:`relative`,cursor:`default`,width:a,height:o},s)},f,{ref:function(n){e.container=n}}),y.createElement(jS,lq({},d,{width:a,height:o,title:l,desc:u,style:Lq}),this.renderClipPath(),wS(r,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])}(y.Component);Nq(m,`displayName`,n),Nq(m,`defaultProps`,Z({layout:`horizontal`,stackOffset:`none`,barCategoryGap:`10%`,barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:`index`},d)),Nq(m,`getDerivedStateFromProps`,function(e,n){var r=e.dataKey,i=e.data,a=e.children,o=e.width,s=e.height,c=e.layout,l=e.stackOffset,u=e.margin,d=n.dataStartIndex,f=n.dataEndIndex;if(n.updateId===void 0){var m=Xq(e);return Z(Z(Z({},m),{},{updateId:0},p(Z(Z({props:e},m),{},{updateId:0}),n)),{},{prevDataKey:r,prevData:i,prevWidth:o,prevHeight:s,prevLayout:c,prevStackOffset:l,prevMargin:u,prevChildren:a})}if(r!==n.prevDataKey||i!==n.prevData||o!==n.prevWidth||s!==n.prevHeight||c!==n.prevLayout||l!==n.prevStackOffset||!Gx(u,n.prevMargin)){var h=Xq(e),g={chartX:n.chartX,chartY:n.chartY,isTooltipActive:n.isTooltipActive},_=Z(Z({},Gq(n,i,c)),{},{updateId:n.updateId+1}),v=Z(Z(Z({},h),g),_);return Z(Z(Z({},v),p(Z({props:e},v),n)),{},{prevDataKey:r,prevData:i,prevWidth:o,prevHeight:s,prevLayout:c,prevStackOffset:l,prevMargin:u,prevChildren:a})}if(!SS(a,n.prevChildren)){var y=hS(a,sV),b=y?y.props?.startIndex??d:d,x=y?y.props?.endIndex??f:f,S=b!==d||x!==f,C=!(0,Mx.default)(i)&&!S?n.updateId:n.updateId+1;return Z(Z({updateId:C},p(Z(Z({props:e},n),{},{updateId:C,dataStartIndex:b,dataEndIndex:x}),n)),{},{prevChildren:a,dataStartIndex:b,dataEndIndex:x})}return null}),Nq(m,`renderActiveDot`,function(e,n,r){var i=(0,y.isValidElement)(e)?(0,y.cloneElement)(e,n):(0,nS.default)(e)?e(n):y.createElement(mR,n);return y.createElement(IS,{className:`recharts-active-dot`,key:r},i)});var h=(0,y.forwardRef)(function(e,n){return y.createElement(m,lq({},e,{ref:n}))});return h.displayName=m.displayName,h},nJ=tJ({chartName:`LineChart`,GraphicalChild:OG,axisComponents:[{axisType:`xAxis`,AxisComp:mK},{axisType:`yAxis`,AxisComp:jK}],formatAxisMap:cH}),rJ=tJ({chartName:`BarChart`,GraphicalChild:XV,defaultTooltipEventType:`axis`,validateTooltipEventTypes:[`axis`,`item`],axisComponents:[{axisType:`xAxis`,AxisComp:mK},{axisType:`yAxis`,AxisComp:jK}],formatAxisMap:cH}),iJ=tJ({chartName:`PieChart`,GraphicalChild:OB,validateTooltipEventTypes:[`item`],defaultTooltipEventType:`item`,legendContent:`children`,axisComponents:[{axisType:`angleAxis`,AxisComp:vz},{axisType:`radiusAxis`,AxisComp:QR}],formatAxisMap:Tre,defaultProps:{layout:`centric`,startAngle:0,endAngle:360,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`}}),aJ=tJ({chartName:`AreaChart`,GraphicalChild:ZG,axisComponents:[{axisType:`xAxis`,AxisComp:mK},{axisType:`yAxis`,AxisComp:jK}],formatAxisMap:cH}),oJ=[`#8b5cf6`,`#ec4899`,`#06b6d4`,`#f59e0b`,`#10b981`,`#ef4444`,`#6366f1`,`#f97316`],sJ={episodic:`情景记忆`,semantic:`语义记忆`,procedural:`程序记忆`,emotional:`情感记忆`,working:`工作记忆`},cJ={core:`#8b5cf6`,working:`#06b6d4`,peripheral:`#9ca3af`},lJ={core:`核心`,working:`工作区`,peripheral:`边缘`};function uJ({label:e,value:n,icon:r,loading:i}){return(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:e}),(0,G.jsx)(r,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:i?(0,G.jsx)(Cb,{className:`h-8 w-20`}):n})})]})}function dJ({className:e}){return(0,G.jsxs)(`div`,{className:Tp(`flex flex-col gap-4`,e),children:[(0,G.jsx)(Cb,{className:`h-6 w-32`}),(0,G.jsx)(Cb,{className:`flex-1 min-h-[240px]`})]})}function fJ(){let e=et(),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(!0),[o,s]=(0,y.useState)(null),{users:c,currentUserId:l}=dh(),u=c.find(e=>e.id===l)?.spaceName||`默认`;(0,y.useEffect)(()=>{async function e(){try{a(!0),s(null),r(await ib.get(`/v1/stats`))}catch(e){console.error(`Failed to fetch stats:`,e),s(`加载统计数据失败`)}finally{a(!1)}}e()},[]);let d=()=>{if(!n?.timeline?.length)return 0;let e=new Date().toISOString().split(`T`)[0];return n.timeline.find(n=>n.date===e)?.count??0},f=()=>n?.by_space?Object.keys(n.by_space).length:0,p=()=>n?.by_state?n.by_state.active??n.by_state.活跃??0:0,m=()=>n?.by_tier?n.by_tier.core??0:0,h=(0,y.useMemo)(()=>n?.by_type?Object.entries(n.by_type).map(([e,n])=>({name:sJ[e]||e,value:n,key:e})):[],[n]),g=(0,y.useMemo)(()=>n?.by_tier?Object.entries(n.by_tier).map(([e,n])=>({name:lJ[e]||e,value:n,key:e})):[],[n]),_=(0,y.useMemo)(()=>n?.timeline?.length?n.timeline.slice(-30):[],[n]),v=(0,y.useMemo)(()=>n?.by_category?Object.entries(n.by_category).map(([e,n])=>({name:e,value:n})).sort((e,n)=>n.value-e.value).slice(0,10):[],[n]);return(0,G.jsxs)(`div`,{className:`space-y-8`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`h1`,{className:`text-3xl font-semibold tracking-tight`,children:[u,`空间的记忆库状态`]}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:`概览当前空间的记忆数据`})]}),o&&(0,G.jsx)(`div`,{className:`rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-sm text-destructive`,children:o}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,G.jsxs)(q,{size:`sm`,onClick:()=>e(`/memories/new`),children:[(0,G.jsx)(Nm,{className:`size-4 mr-1.5`}),`新建记忆`]}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>e(`/import`),children:[(0,G.jsx)(Ym,{className:`size-4 mr-1.5`}),`批量导入`]}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>e(`/analytics`),children:[(0,G.jsx)(um,{className:`size-4 mr-1.5`}),`查看统计报告`]})]}),(0,G.jsxs)(`div`,{className:Tp(`grid gap-4`,`grid-cols-1`,`md:grid-cols-2`,`lg:grid-cols-4`),children:[(0,G.jsx)(uJ,{label:`总记忆数`,value:n?.total??0,icon:qp,loading:i}),(0,G.jsx)(uJ,{label:`今日新增`,value:d(),icon:qm,loading:i}),(0,G.jsx)(uJ,{label:`空间数`,value:f(),icon:hm,loading:i}),(0,G.jsx)(uJ,{label:`总访问次数`,value:n?.total_access_count??0,icon:sm,loading:i})]}),(0,G.jsxs)(`div`,{className:Tp(`grid gap-4`,`grid-cols-1`,`md:grid-cols-2`,`lg:grid-cols-4`),children:[(0,G.jsx)(uJ,{label:`平均重要度`,value:n?.avg_importance?`${(n.avg_importance*100).toFixed(0)}%`:`—`,icon:Yp,loading:i}),(0,G.jsx)(uJ,{label:`平均置信度`,value:n?.avg_confidence?`${(n.avg_confidence*100).toFixed(0)}%`:`—`,icon:tm,loading:i}),(0,G.jsx)(uJ,{label:`核心记忆数`,value:m(),icon:Hm,loading:i}),(0,G.jsx)(uJ,{label:`活跃记忆数`,value:p(),icon:zp,loading:i})]}),(0,G.jsxs)(`div`,{className:Tp(`grid gap-4`,`grid-cols-1`,`lg:grid-cols-2`),children:[(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`记忆类型分布`})}),(0,G.jsx)(Sb,{children:i?(0,G.jsx)(dJ,{}):h.length===0?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[240px] text-muted-foreground text-sm`,children:`暂无数据`}):(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(iJ,{children:[(0,G.jsx)(OB,{data:h,cx:`50%`,cy:`50%`,outerRadius:100,dataKey:`value`,label:({name:e,percent:n})=>`${e} ${(n*100).toFixed(0)}%`,children:h.map((e,n)=>(0,G.jsx)(sD,{fill:oJ[n%oJ.length]},`cell-${e.key}`))}),(0,G.jsx)(VE,{})]})})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`记忆等级分布`})}),(0,G.jsx)(Sb,{children:i?(0,G.jsx)(dJ,{}):g.length===0?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[240px] text-muted-foreground text-sm`,children:`暂无数据`}):(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(iJ,{children:[(0,G.jsx)(OB,{data:g,cx:`50%`,cy:`50%`,innerRadius:70,outerRadius:100,paddingAngle:4,dataKey:`value`,children:g.map(e=>(0,G.jsx)(sD,{fill:cJ[e.key]||`#9ca3af`},`tier-${e.key}`))}),(0,G.jsx)(VE,{})]})}),(0,G.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center pointer-events-none`,children:[(0,G.jsx)(`span`,{className:`text-3xl font-bold`,children:n?.total??0}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`总记忆数`})]})]})})]}),(0,G.jsxs)(vb,{className:`lg:col-span-2`,children:[(0,G.jsx)(yb,{children:(0,G.jsxs)(bb,{className:`text-base`,children:[`新增趋势(最近`,_.length,`天)`]})}),(0,G.jsx)(Sb,{children:i?(0,G.jsx)(dJ,{}):_.length===0?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[240px] text-muted-foreground text-sm`,children:`暂无数据`}):(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(aJ,{data:_,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`colorCount`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`5%`,stopColor:`#8b5cf6`,stopOpacity:.3}),(0,G.jsx)(`stop`,{offset:`95%`,stopColor:`#8b5cf6`,stopOpacity:0})]})}),(0,G.jsx)(eG,{strokeDasharray:`3 3`,stroke:`#333`}),(0,G.jsx)(mK,{dataKey:`date`,tick:{fontSize:12},tickFormatter:e=>{let[,n,r]=e.split(`-`);return`${n}-${r}`}}),(0,G.jsx)(jK,{tick:{fontSize:12}}),(0,G.jsx)(VE,{labelFormatter:e=>`日期: ${e}`,formatter:e=>[e,`新增数量`]}),(0,G.jsx)(ZG,{type:`monotone`,dataKey:`count`,stroke:`#8b5cf6`,fillOpacity:1,fill:`url(#colorCount)`,strokeWidth:2})]})})})]}),(0,G.jsxs)(vb,{className:`lg:col-span-2`,children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`分类 TOP10`})}),(0,G.jsx)(Sb,{children:i?(0,G.jsx)(dJ,{}):v.length===0?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-[240px] text-muted-foreground text-sm`,children:`暂无数据`}):(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(rJ,{data:v,layout:`vertical`,children:[(0,G.jsx)(eG,{strokeDasharray:`3 3`,stroke:`#333`}),(0,G.jsx)(mK,{type:`number`,tick:{fontSize:12}}),(0,G.jsx)(jK,{dataKey:`name`,type:`category`,tick:{fontSize:11},width:100}),(0,G.jsx)(VE,{}),(0,G.jsx)(XV,{dataKey:`value`,fill:`#06b6d4`,radius:[0,4,4,0]})]})})})]})]})]})}function pJ({...e}){return(0,G.jsx)(hg,{"data-slot":`alert-dialog`,...e})}function mJ({className:e,children:n,...r}){return(0,G.jsxs)(Zh,{children:[(0,G.jsx)(Eh,{className:`fixed inset-0 isolate z-50 bg-black/20 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`}),(0,G.jsx)(Yh,{"data-slot":`alert-dialog-content`,className:Tp(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] max-h-[90vh] -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto rounded-xl bg-popover p-6 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:n})]})}function hJ({className:e,...n}){return(0,G.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:Tp(`flex flex-col gap-2`,e),...n})}function gJ({className:e,...n}){return(0,G.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:Tp(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...n})}function _J({className:e,...n}){return(0,G.jsx)(gg,{"data-slot":`alert-dialog-title`,className:Tp(`text-base font-semibold leading-none`,e),...n})}function vJ({className:e,...n}){return(0,G.jsx)(Oh,{"data-slot":`alert-dialog-description`,className:Tp(`text-sm text-muted-foreground`,e),...n})}function yJ({className:e,...n}){return(0,G.jsx)(Dh,{children:(0,G.jsx)(q,{"data-slot":`alert-dialog-action`,className:e,...n})})}function bJ({className:e,...n}){return(0,G.jsx)(Dh,{children:(0,G.jsx)(q,{"data-slot":`alert-dialog-cancel`,variant:`outline`,className:e,...n})})}function xJ(e){return Qs(e.defaultTagName??`div`,e,e)}var SJ=bh(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function CJ({className:e,variant:n=`default`,render:r,...i}){return xJ({defaultTagName:`span`,props:Rs({className:Tp(SJ({variant:n}),e)},i),render:r,state:{slot:`badge`,variant:n}})}var wJ={工作:{bg:`bg-blue-500/10`,text:`text-blue-600`,border:`border-blue-500/30`},学习:{bg:`bg-green-500/10`,text:`text-green-600`,border:`border-green-500/30`},生活:{bg:`bg-rose-500/10`,text:`text-rose-600`,border:`border-rose-500/30`},技术:{bg:`bg-violet-500/10`,text:`text-violet-600`,border:`border-violet-500/30`},重要:{bg:`bg-red-500/10`,text:`text-red-600`,border:`border-red-500/30`},待办:{bg:`bg-orange-500/10`,text:`text-orange-600`,border:`border-orange-500/30`},项目:{bg:`bg-indigo-500/10`,text:`text-indigo-600`,border:`border-indigo-500/30`},灵感:{bg:`bg-pink-500/10`,text:`text-pink-600`,border:`border-pink-500/30`},笔记:{bg:`bg-slate-500/10`,text:`text-slate-600`,border:`border-slate-500/30`},私密:{bg:`bg-amber-500/10`,text:`text-amber-600`,border:`border-amber-500/30`}},TJ=[{bg:`bg-cyan-500/10`,text:`text-cyan-600`,border:`border-cyan-500/30`},{bg:`bg-emerald-500/10`,text:`text-emerald-600`,border:`border-emerald-500/30`},{bg:`bg-teal-500/10`,text:`text-teal-600`,border:`border-teal-500/30`},{bg:`bg-sky-500/10`,text:`text-sky-600`,border:`border-sky-500/30`},{bg:`bg-fuchsia-500/10`,text:`text-fuchsia-600`,border:`border-fuchsia-500/30`},{bg:`bg-lime-500/10`,text:`text-lime-600`,border:`border-lime-500/30`},{bg:`bg-yellow-500/10`,text:`text-yellow-600`,border:`border-yellow-500/30`}];function EJ(e){let n=0;for(let r=0;r<e.length;r++)n=(n<<5)-n+e.charCodeAt(r)|0;return Math.abs(n)}function DJ(e){return wJ[e]||TJ[EJ(e)%TJ.length]}function OJ(e,n){let r=DJ(e);return Tp(r.bg,r.text,r.border,`border`,`hover:opacity-80`,n)}function kJ(e,n){return n===`private`?!0:e?.includes(`私密`)||!1}function AJ(e){switch(e?.toLowerCase()){case`profile`:return`bg-violet-500/10 text-violet-600 dark:text-violet-400 border-violet-500/30`;case`preferences`:return`bg-rose-500/10 text-rose-600 dark:text-rose-400 border-rose-500/30`;case`entities`:return`bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/30`;case`patterns`:return`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/30`;case`cases`:return`bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/30`;case`events`:return`bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/30`;case`decisions`:return`bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border-indigo-500/30`;default:return`bg-muted text-muted-foreground border-border`}}function jJ(e){switch(e?.toLowerCase()){case`core`:return`核心`;case`working`:return`工作区`;case`peripheral`:return`边缘`;default:return e||`—`}}function MJ(e){switch(e?.toLowerCase()){case`core`:return`default`;case`working`:return`secondary`;case`peripheral`:return`outline`;default:return`outline`}}function NJ(e){switch(e?.toLowerCase()){case`core`:return`bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/30`;case`working`:return`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/30`;case`peripheral`:return`bg-slate-500/10 text-slate-500 dark:text-slate-400 border-slate-500/30`;default:return`bg-muted text-muted-foreground border-border`}}var PJ=300;function FJ(e,n=120){return e?e.length<=n?e:e.slice(0,n)+`...`:`—`}function IJ(e){return new Date(e).toLocaleString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function LJ({memory:e,unlocked:n}){return kJ(e.tags,e.visibility)?n?(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Tm,{className:`h-3 w-3 text-amber-500`}),(0,G.jsx)(`span`,{className:`text-xs text-amber-500 font-medium`,children:`已解锁`})]}),(0,G.jsx)(`p`,{className:`text-sm text-foreground line-clamp-3`,children:FJ(e.content||e.l0_abstract)})]}):(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,G.jsx)(Em,{className:`h-3.5 w-3.5 text-amber-500`}),(0,G.jsx)(`span`,{children:`🔒 私密记忆 · 已加密`})]}):(0,G.jsx)(`p`,{className:`text-sm text-foreground line-clamp-3`,children:FJ(e.content||e.l0_abstract)})}function RJ(){let e=et(),n=Ze(),[r,i]=Nn(),a=(e,n)=>r.get(e)||n,o=(e,n)=>{let i=r.get(e);return i?parseInt(i,10):n},[s,c]=(0,y.useState)([]),[l,u]=(0,y.useState)(!0),[,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(o(`page`,1)),[m,h]=(0,y.useState)(a(`q`,``)),[g,_]=(0,y.useState)(0),v=ob(e=>e.isUnlocked),b=ob(e=>e.lock),x=ob(e=>e.unlock),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(``),[E,D]=(0,y.useState)(null),[O,k]=(0,y.useState)(a(`tier`,`all`)),[A,j]=(0,y.useState)(a(`sort`,`created_at`)),[M,N]=(0,y.useState)(o(`size`,20)),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(a(`privacy`,`all`)),[ee,B]=(0,y.useState)(a(`q`,``)),[V,H]=(0,y.useState)(new Set),[U,te]=(0,y.useState)(!1),[W,ne]=(0,y.useState)(!1),[re,ie]=(0,y.useState)(0),[ae,oe]=(0,y.useState)(a(`project`,``)),[se,ce]=(0,y.useState)([]),le=(0,y.useRef)(!0);(0,y.useEffect)(()=>{async function e(){try{let e=await ib.get(`/v1/memories/project-paths`);ce(Array.isArray(e)?e:[])}catch{ce([])}}e()},[re]),(0,y.useEffect)(()=>{if(le.current){le.current=!1;return}let e=setTimeout(()=>{p(1),B(m)},PJ);return()=>clearTimeout(e)},[m]);let ue=(0,y.useCallback)(async()=>{try{u(!0),d(null);let e={offset:(f-1)*M,limit:M,sort:A};ee.trim()&&(e.q=ee.trim()),O!==`all`&&(e.tier=O),R===`private`?e.visibility=`private`:R===`global`&&(e.visibility=`global`),ae&&(e.project_path=ae);let n=await ib.get(`/v1/memories`,{params:e});c(n.memories||[]),_(n.total_count||0)}catch(e){console.error(`Failed to fetch memories:`,e),d(`加载记忆列表失败`)}finally{u(!1)}},[f,ee,O,A,M,R,ae]);(0,y.useEffect)(()=>{ue()},[ue,re]),(0,y.useEffect)(()=>{let e=new URLSearchParams;f>1&&e.set(`page`,String(f)),m&&e.set(`q`,m),O!==`all`&&e.set(`tier`,O),A!==`created_at`&&e.set(`sort`,A),M!==20&&e.set(`size`,String(M)),R!==`all`&&e.set(`privacy`,R),ae&&e.set(`project`,ae),i(e,{replace:!0})},[f,m,O,A,M,R,ae,i]);let de=r=>{let i=n.pathname+n.search;sessionStorage.setItem(`memories-list-from`,i),e(`/memories/${r}`,{state:{from:i}})},fe=e=>{h(e.target.value)},pe=[m?{label:`搜索: "${m}"`,onClear:()=>h(``)}:null,O===`all`?null:{label:`分类: ${O}`,onClear:()=>k(`all`)},A===`created_at`?null:{label:`排序: ${A}`,onClear:()=>j(`created_at`)},R===`all`?null:{label:R===`private`?`仅私密`:`仅普通`,onClear:()=>z(`all`)},ae?{label:`项目: ${ae.split(`/`).pop()}`,onClear:()=>{oe(``),p(1)}}:null].filter(Boolean),me=()=>{h(``),k(`all`),j(`created_at`),z(`all`),oe(``),p(1)},he=()=>{f>1&&p(f-1)},ge=()=>{f*M<g&&p(f+1)},_e=async()=>{if(!w.trim()){D(`请输入密码`);return}if(!await x(w)){D(`密码错误`);return}D(null),C(!1),T(``)},ve=()=>{b()},ye=(e,n)=>{n.stopPropagation(),F(e)},be=async()=>{if(!P)return;let e=P;L(!0);try{await ib.delete(`/v1/memories/${e}`),ir.success(`记忆已删除`),F(null),ie(e=>e+1)}catch(e){console.error(`Failed to delete memory:`,e),ir.error(`删除失败,请重试`),F(null)}finally{L(!1)}},xe=e=>{H(n=>{let r=new Set(n);return r.has(e)?r.delete(e):r.add(e),r})},Se=()=>{H(new Set(s.map(e=>e.id)))},Ce=()=>{H(new Set)},we=async()=>{if(V.size===0)return;let e=Array.from(V);L(!0);try{await ib.post(`/v1/memories/batch-delete`,{memory_ids:e,confirm:!0}),ir.success(`已删除 ${e.length} 条记忆`),H(new Set),te(!1),ie(e=>e+1)}catch(e){console.error(`Failed to batch delete:`,e),ir.error(`批量删除失败`)}finally{L(!1)}},Te=f*M<g,Ee=f>1,De=Math.ceil(g/M);return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`记忆列表`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`浏览和管理您的所有记忆`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-4 flex-wrap`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1 max-w-md`,children:[(0,G.jsx)(Lm,{className:`absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground`}),(0,G.jsx)(hb,{type:`text`,placeholder:`搜索记忆内容...`,value:m,onChange:fe,className:`pl-9`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Bm,{className:`size-3.5 text-muted-foreground`}),(0,G.jsxs)(`select`,{value:O,onChange:e=>{k(e.target.value),p(1)},className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[(0,G.jsx)(`option`,{value:`all`,children:`全部分类`}),(0,G.jsx)(`option`,{value:`core`,children:`核心`}),(0,G.jsx)(`option`,{value:`working`,children:`工作区`}),(0,G.jsx)(`option`,{value:`peripheral`,children:`边缘`})]}),(0,G.jsx)(Up,{className:`size-3.5 text-muted-foreground`}),(0,G.jsxs)(`select`,{value:A,onChange:e=>{j(e.target.value),p(1)},className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[(0,G.jsx)(`option`,{value:`updated_at`,children:`按更新时间`}),(0,G.jsx)(`option`,{value:`created_at`,children:`按创建时间`}),(0,G.jsx)(`option`,{value:`importance`,children:`按重要性`}),(0,G.jsx)(`option`,{value:`confidence`,children:`按置信度`}),(0,G.jsx)(`option`,{value:`access_count`,children:`按访问次数`})]}),(0,G.jsxs)(`select`,{value:M,onChange:e=>{N(Number(e.target.value)),p(1)},className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[(0,G.jsx)(`option`,{value:20,children:`20条/页`}),(0,G.jsx)(`option`,{value:50,children:`50条/页`}),(0,G.jsx)(`option`,{value:100,children:`100条/页`})]}),(0,G.jsx)(Em,{className:`size-3.5 text-muted-foreground`}),(0,G.jsxs)(`select`,{value:R,onChange:e=>{z(e.target.value),p(1)},className:`h-9 rounded-md border border-input bg-background px-3 text-sm`,children:[(0,G.jsx)(`option`,{value:`all`,children:`全部记忆`}),(0,G.jsx)(`option`,{value:`global`,children:`普通记忆`}),(0,G.jsx)(`option`,{value:`private`,children:`私密记忆`})]}),se.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(dm,{className:`size-3.5 text-muted-foreground`}),(0,G.jsxs)(`select`,{value:ae,onChange:e=>{oe(e.target.value),p(1)},className:`h-9 rounded-md border border-input bg-background px-3 text-sm max-w-[200px] truncate`,children:[(0,G.jsx)(`option`,{value:``,children:`全部项目`}),se.map(e=>(0,G.jsx)(`option`,{value:e,children:e.split(`/`).pop()||e},e))]})]}),pe.length>0&&(0,G.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:me,className:`text-muted-foreground hover:text-foreground`,children:[(0,G.jsx)(Fm,{className:`size-3.5 mr-1`}),`重置筛选`]})]}),(0,G.jsxs)(q,{size:`sm`,onClick:()=>e(`/memories/new`),children:[(0,G.jsx)(Nm,{className:`size-3.5 mr-1.5`}),`新建`]}),(0,G.jsx)(q,{variant:W?`default`:`outline`,size:`sm`,onClick:()=>{ne(!W),W&&Ce()},children:W?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)($m,{className:`size-3.5 mr-1.5`}),`退出管理`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Bm,{className:`size-3.5 mr-1.5`}),`批量管理`]})}),v?(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:ve,children:[(0,G.jsx)(Em,{className:`size-3.5 mr-1.5`}),`锁定 Vault`]}):(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>C(!S),children:[(0,G.jsx)(Tm,{className:`size-3.5 mr-1.5`}),`解锁 Vault`]})]}),pe.length>0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`活跃筛选:`}),pe.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:e.onClear,className:`inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-primary/10 text-primary hover:bg-primary/20 transition-colors`,children:[e.label,(0,G.jsx)($m,{className:`size-3`})]},e.label))]}),W&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between bg-muted/50 rounded-lg px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`span`,{className:`text-sm font-medium`,children:[`已选择 `,V.size,` 条记忆`]}),V.size>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,onClick:Ce,children:`取消选择`}),(0,G.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,onClick:Se,children:`全选本页`})]})]}),V.size>0&&(0,G.jsxs)(q,{variant:`destructive`,size:`sm`,className:`h-7`,onClick:()=>te(!0),children:[(0,G.jsx)(Km,{className:`size-3.5 mr-1`}),`删除 (`,V.size,`)`]})]}),S&&(0,G.jsxs)(`div`,{className:`space-y-2 max-w-md`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(hb,{type:`password`,placeholder:`输入 Vault 密码...`,value:w,onChange:e=>{T(e.target.value),D(null)},onKeyDown:e=>e.key===`Enter`&&_e(),className:E?`border-destructive flex-1`:`flex-1`}),(0,G.jsx)(q,{size:`sm`,onClick:_e,children:`解锁`})]}),E&&(0,G.jsx)(`p`,{className:`text-xs text-destructive`,children:E})]}),!l&&s.length>0&&De>1&&(0,G.jsxs)(`div`,{className:`flex items-center justify-start gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:he,disabled:!Ee||l,children:(0,G.jsx)(Qp,{className:`size-3`})}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground min-w-[3ch] text-center`,children:[f,`/`,De]}),(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:ge,disabled:!Te||l,children:(0,G.jsx)($p,{className:`size-3`})})]}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`共 `,g,` 条`]})]}),(0,G.jsx)(`div`,{className:`space-y-3`,children:l?[1,2,3,4,5].map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 space-y-2`,children:[(0,G.jsx)(Cb,{className:`h-4 w-[95%]`}),(0,G.jsx)(Cb,{className:`h-4 w-[80%]`}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,G.jsx)(Cb,{className:`h-5 w-16`}),(0,G.jsx)(Cb,{className:`h-5 w-12`})]})]},`sk-${e}`)):s.length===0?(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-12 text-center space-y-4`,children:[(0,G.jsx)(_m,{className:`h-12 w-12 text-muted-foreground mx-auto`}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:m||R!==`all`||O!==`all`?`未找到匹配的记忆`:`暂无记忆数据`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m||R!==`all`||O!==`all`?`尝试调整筛选条件或清除搜索`:`开始记录您的第一条记忆吧`})]}),pe.length>0&&(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:me,children:[(0,G.jsx)(Fm,{className:`size-3.5 mr-1.5`}),`清除筛选`]})]}):s.map(e=>{let n=V.has(e.id);return(0,G.jsxs)(`div`,{onClick:()=>W?xe(e.id):de(e.id),className:Tp(`w-full text-left rounded-lg border p-4 cursor-pointer transition-colors relative`,kJ(e.tags,e.visibility)?`border-amber-500/30 bg-amber-500/5 hover:bg-amber-500/10`:`border-border bg-card hover:bg-muted/50`,W&&n&&`ring-2 ring-primary bg-primary/5`),children:[W&&(0,G.jsx)(`div`,{className:`absolute left-3 top-1/2 -translate-y-1/2 z-10`,children:(0,G.jsx)(`input`,{type:`checkbox`,checked:n,onChange:n=>{n.stopPropagation(),xe(e.id)},onClick:e=>e.stopPropagation(),className:`size-4 cursor-pointer`})}),(0,G.jsxs)(`div`,{className:Tp(W&&`pl-8`),children:[(0,G.jsx)(LJ,{memory:e,unlocked:v}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-3 flex-wrap`,children:[(0,G.jsx)(CJ,{variant:`outline`,className:`font-normal text-xs ${AJ(e.category)}`,children:e.category||`未分类`}),(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs ${NJ(e.tier)}`,children:jJ(e.tier)}),kJ(e.tags,e.visibility)&&(0,G.jsxs)(CJ,{variant:`outline`,className:OJ(`私密`,`text-xs`),children:[(0,G.jsx)(Em,{className:`size-2.5 mr-1`}),`私密`]}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-auto flex items-center gap-1.5`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(Jp,{className:`size-3`}),IJ(e.created_at)]}),e.updated_at!==e.created_at&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,G.jsx)(nm,{className:`size-3`}),IJ(e.updated_at)]})]}),!W&&(0,G.jsx)(`button`,{type:`button`,onClick:n=>ye(e.id,n),className:`ml-2 p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors`,title:`删除`,children:(0,G.jsx)(Km,{className:`size-3.5`})})]})]})]},e.id)})}),!l&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`共 `,g,` 条记忆`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:he,disabled:!Ee||l,children:[(0,G.jsx)(Qp,{className:`size-4`}),`上一页`]}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:ge,disabled:!Te||l,children:[`下一页`,(0,G.jsx)($p,{className:`size-4`})]})]})]}),(0,G.jsx)(pJ,{open:!!P,onOpenChange:e=>{!e&&!I&&F(null)},children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除记忆`}),(0,G.jsx)(vJ,{children:`确定要删除这条记忆吗?此操作不可撤销。`})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{onClick:()=>F(null),disabled:I,children:`取消`}),(0,G.jsx)(yJ,{disabled:I,onClick:be,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:I?`删除中...`:`删除`})]})]})}),(0,G.jsx)(pJ,{open:U,onOpenChange:e=>{!e&&!I&&te(!1)},children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认批量删除`}),(0,G.jsxs)(vJ,{children:[`确定要删除选中的 `,V.size,` 条记忆吗?此操作不可撤销。`]})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{onClick:()=>te(!1),disabled:I,children:`取消`}),(0,G.jsx)(yJ,{disabled:I,onClick:e=>{e.preventDefault(),we()},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:I?`删除中...`:`删除 ${V.size} 条`})]})]})})]})}function zJ(e,n){let r=n||{};return(e[e.length-1]===``?[...e,``]:e).join((r.padRight?` `:``)+`,`+(r.padLeft===!1?``:` `)).trim()}var BJ=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,VJ=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,HJ={};function UJ(e,n){return((n||HJ).jsx?VJ:BJ).test(e)}var WJ=/[ \t\n\f\r]/g;function GJ(e){return typeof e==`object`?e.type===`text`?KJ(e.value):!1:KJ(e)}function KJ(e){return e.replace(WJ,``)===``}var qJ=class{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}};qJ.prototype.normal={},qJ.prototype.property={},qJ.prototype.space=void 0;function JJ(e,n){let r={},i={};for(let n of e)Object.assign(r,n.property),Object.assign(i,n.normal);return new qJ(r,i,n)}function YJ(e){return e.toLowerCase()}var XJ=class{constructor(e,n){this.attribute=n,this.property=e}};XJ.prototype.attribute=``,XJ.prototype.booleanish=!1,XJ.prototype.boolean=!1,XJ.prototype.commaOrSpaceSeparated=!1,XJ.prototype.commaSeparated=!1,XJ.prototype.defined=!1,XJ.prototype.mustUseProperty=!1,XJ.prototype.number=!1,XJ.prototype.overloadedBoolean=!1,XJ.prototype.property=``,XJ.prototype.spaceSeparated=!1,XJ.prototype.space=void 0;var ZJ=c({boolean:()=>$J,booleanish:()=>eY,commaOrSpaceSeparated:()=>iY,commaSeparated:()=>rY,number:()=>Q,overloadedBoolean:()=>tY,spaceSeparated:()=>nY}),QJ=0,$J=aY(),eY=aY(),tY=aY(),Q=aY(),nY=aY(),rY=aY(),iY=aY();function aY(){return 2**++QJ}var oY=Object.keys(ZJ),sY=class extends XJ{constructor(e,n,r,i){let a=-1;if(super(e,n),cY(this,`space`,i),typeof r==`number`)for(;++a<oY.length;){let e=oY[a];cY(this,oY[a],(r&ZJ[e])===ZJ[e])}}};sY.prototype.defined=!0;function cY(e,n,r){r&&(e[n]=r)}function lY(e){let n={},r={};for(let[i,a]of Object.entries(e.properties)){let o=new sY(i,e.transform(e.attributes||{},i),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(o.mustUseProperty=!0),n[i]=o,r[YJ(i)]=i,r[YJ(o.attribute)]=i}return new qJ(n,r,e.space)}var uY=lY({properties:{ariaActiveDescendant:null,ariaAtomic:eY,ariaAutoComplete:null,ariaBusy:eY,ariaChecked:eY,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:nY,ariaCurrent:null,ariaDescribedBy:nY,ariaDetails:null,ariaDisabled:eY,ariaDropEffect:nY,ariaErrorMessage:null,ariaExpanded:eY,ariaFlowTo:nY,ariaGrabbed:eY,ariaHasPopup:null,ariaHidden:eY,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:nY,ariaLevel:Q,ariaLive:null,ariaModal:eY,ariaMultiLine:eY,ariaMultiSelectable:eY,ariaOrientation:null,ariaOwns:nY,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:eY,ariaReadOnly:eY,ariaRelevant:null,ariaRequired:eY,ariaRoleDescription:nY,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:eY,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,n){return n===`role`?n:`aria-`+n.slice(4).toLowerCase()}});function dY(e,n){return n in e?e[n]:n}function fY(e,n){return dY(e,n.toLowerCase())}var pY=lY({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:rY,acceptCharset:nY,accessKey:nY,action:null,allow:null,allowFullScreen:$J,allowPaymentRequest:$J,allowUserMedia:$J,alt:null,as:null,async:$J,autoCapitalize:null,autoComplete:nY,autoFocus:$J,autoPlay:$J,blocking:nY,capture:null,charSet:null,checked:$J,cite:null,className:nY,cols:Q,colSpan:null,content:null,contentEditable:eY,controls:$J,controlsList:nY,coords:Q|rY,crossOrigin:null,data:null,dateTime:null,decoding:null,default:$J,defer:$J,dir:null,dirName:null,disabled:$J,download:tY,draggable:eY,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:$J,formTarget:null,headers:nY,height:Q,hidden:tY,high:Q,href:null,hrefLang:null,htmlFor:nY,httpEquiv:nY,id:null,imageSizes:null,imageSrcSet:null,inert:$J,inputMode:null,integrity:null,is:null,isMap:$J,itemId:null,itemProp:nY,itemRef:nY,itemScope:$J,itemType:nY,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:$J,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:$J,muted:$J,name:null,nonce:null,noModule:$J,noValidate:$J,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:$J,optimum:Q,pattern:null,ping:nY,placeholder:null,playsInline:$J,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:$J,referrerPolicy:null,rel:nY,required:$J,reversed:$J,rows:Q,rowSpan:Q,sandbox:nY,scope:null,scoped:$J,seamless:$J,selected:$J,shadowRootClonable:$J,shadowRootDelegatesFocus:$J,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:eY,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:$J,useMap:null,value:eY,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:nY,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:$J,declare:$J,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:$J,noHref:$J,noShade:$J,noWrap:$J,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:eY,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:$J,disableRemotePlayback:$J,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:fY}),mY=lY({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:iY,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:nY,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:$J,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:rY,g2:rY,glyphName:rY,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:iY,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:nY,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:iY,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:iY,rev:iY,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:iY,requiredFeatures:iY,requiredFonts:iY,requiredFormats:iY,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:iY,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:iY,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:iY,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:dY}),hY=lY({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,n){return`xlink:`+n.slice(5).toLowerCase()}}),gY=lY({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:fY}),_Y=lY({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,n){return`xml:`+n.slice(3).toLowerCase()}}),vY={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},yY=/[A-Z]/g,bY=/-[a-z]/g,xY=/^data[-\w.:]+$/i;function SY(e,n){let r=YJ(n),i=n,a=XJ;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&r.slice(0,4)===`data`&&xY.test(n)){if(n.charAt(4)===`-`){let e=n.slice(5).replace(bY,wY);i=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=n.slice(4);if(!bY.test(e)){let r=e.replace(yY,CY);r.charAt(0)!==`-`&&(r=`-`+r),n=`data`+r}}a=sY}return new a(i,n)}function CY(e){return`-`+e.toLowerCase()}function wY(e){return e.charAt(1).toUpperCase()}var TY=JJ([uY,pY,hY,gY,_Y],`html`),EY=JJ([uY,mY,hY,gY,_Y],`svg`);function DY(e){return e.join(` `).trim()}var OY=s(((e,n)=>{var r=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,i=/\n/g,a=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,u=/^\s+|\s+$/g,d=`
|
|
84
84
|
`,f=`/`,p=`*`,m=``,h=`comment`,g=`declaration`;function _(e,n){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];n||={};var u=1,_=1;function y(e){var n=e.match(i);n&&(u+=n.length);var r=e.lastIndexOf(d);_=~r?e.length-r:_+e.length}function b(){var e={line:u,column:_};return function(n){return n.position=new x(e),w(),n}}function x(e){this.start=e,this.end={line:u,column:_},this.source=n.source}x.prototype.content=e;function S(r){var i=Error(n.source+`:`+u+`:`+_+`: `+r);if(i.reason=r,i.filename=n.source,i.line=u,i.column=_,i.source=e,!n.silent)throw i}function C(n){var r=n.exec(e);if(r){var i=r[0];return y(i),e=e.slice(i.length),r}}function w(){C(a)}function T(e){var n;for(e||=[];n=E();)n!==!1&&e.push(n);return e}function E(){var n=b();if(!(f!=e.charAt(0)||p!=e.charAt(1))){for(var r=2;m!=e.charAt(r)&&(p!=e.charAt(r)||f!=e.charAt(r+1));)++r;if(r+=2,m===e.charAt(r-1))return S(`End of comment missing`);var i=e.slice(2,r-2);return _+=2,y(i),e=e.slice(r),_+=2,n({type:h,comment:i})}}function D(){var e=b(),n=C(o);if(n){if(E(),!C(s))return S(`property missing ':'`);var i=C(c),a=e({type:g,property:v(n[0].replace(r,m)),value:i?v(i[0].replace(r,m)):m});return C(l),a}}function O(){var e=[];T(e);for(var n;n=D();)n!==!1&&(e.push(n),T(e));return e}return w(),O()}function v(e){return e?e.replace(u,m):m}n.exports=_})),kY=s((e=>{var n=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=i;var r=n(OY());function i(e,n){let i=null;if(!e||typeof e!=`string`)return i;let a=(0,r.default)(e),o=typeof n==`function`;return a.forEach(e=>{if(e.type!==`declaration`)return;let{property:r,value:a}=e;o?n(r,a,e):a&&(i||={},i[r]=a)}),i}})),AY=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var n=/^--[a-zA-Z0-9_-]+$/,r=/-([a-z])/g,i=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,s=function(e){return!e||i.test(e)||n.test(e)},c=function(e,n){return n.toUpperCase()},l=function(e,n){return`${n}-`};e.camelCase=function(e,n){return n===void 0&&(n={}),s(e)?e:(e=e.toLowerCase(),e=n.reactCompat?e.replace(o,l):e.replace(a,l),e.replace(r,c))}})),jY=s(((e,n)=>{var r=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(kY()),i=AY();function a(e,n){var a={};return!e||typeof e!=`string`||(0,r.default)(e,function(e,r){e&&r&&(a[(0,i.camelCase)(e,n)]=r)}),a}a.default=a,n.exports=a})),MY=PY(`end`),NY=PY(`start`);function PY(e){return n;function n(n){let r=n&&n.position&&n.position[e]||{};if(typeof r.line==`number`&&r.line>0&&typeof r.column==`number`&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset==`number`&&r.offset>-1?r.offset:void 0}}}function FY(e){let n=NY(e),r=MY(e);if(n&&r)return{start:n,end:r}}function IY(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?RY(e.position):`start`in e||`end`in e?RY(e):`line`in e||`column`in e?LY(e):``}function LY(e){return zY(e&&e.line)+`:`+zY(e&&e.column)}function RY(e){return LY(e&&e.start)+`-`+LY(e&&e.end)}function zY(e){return e&&typeof e==`number`?e:1}var BY=class extends Error{constructor(e,n,r){super(),typeof n==`string`&&(r=n,n=void 0);let i=``,a={},o=!1;if(n&&(a=`line`in n&&`column`in n||`start`in n&&`end`in n?{place:n}:`type`in n?{ancestors:[n],place:n.position}:{...n}),typeof e==`string`?i=e:!a.cause&&e&&(o=!0,i=e.message,a.cause=e),!a.ruleId&&!a.source&&typeof r==`string`){let e=r.indexOf(`:`);e===-1?a.ruleId=r:(a.source=r.slice(0,e),a.ruleId=r.slice(e+1))}if(!a.place&&a.ancestors&&a.ancestors){let e=a.ancestors[a.ancestors.length-1];e&&(a.place=e.position)}let s=a.place&&`start`in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file=``,this.message=i,this.line=s?s.line:void 0,this.name=IY(a.place)||`1:1`,this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack==`string`?a.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};BY.prototype.file=``,BY.prototype.name=``,BY.prototype.reason=``,BY.prototype.message=``,BY.prototype.stack=``,BY.prototype.column=void 0,BY.prototype.line=void 0,BY.prototype.ancestors=void 0,BY.prototype.cause=void 0,BY.prototype.fatal=void 0,BY.prototype.place=void 0,BY.prototype.ruleId=void 0,BY.prototype.source=void 0;var VY=u(jY(),1),HY={}.hasOwnProperty,UY=new Map,WY=/[A-Z]/g,GY=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),KY=new Set([`td`,`th`]),qY=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function JY(e,n){if(!n||n.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let r=n.filePath||void 0,i;if(n.development){if(typeof n.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");i=aX(r,n.jsxDEV)}else{if(typeof n.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof n.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");i=iX(r,n.jsx,n.jsxs)}let a={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:i,elementAttributeNameCase:n.elementAttributeNameCase||`react`,evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space===`svg`?EY:TY,stylePropertyNameCase:n.stylePropertyNameCase||`dom`,tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},o=YY(a,e,void 0);return o&&typeof o!=`string`?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function YY(e,n,r){if(n.type===`element`)return XY(e,n,r);if(n.type===`mdxFlowExpression`||n.type===`mdxTextExpression`)return ZY(e,n);if(n.type===`mdxJsxFlowElement`||n.type===`mdxJsxTextElement`)return $Y(e,n,r);if(n.type===`mdxjsEsm`)return QY(e,n);if(n.type===`root`)return eX(e,n,r);if(n.type===`text`)return tX(e,n)}function XY(e,n,r){let i=e.schema,a=i;n.tagName.toLowerCase()===`svg`&&i.space===`html`&&(a=EY,e.schema=a),e.ancestors.push(n);let o=dX(e,n.tagName,!1),s=oX(e,n),c=cX(e,n);return GY.has(n.tagName)&&(c=c.filter(function(e){return typeof e==`string`?!GJ(e):!0})),nX(e,s,o,n),rX(s,c),e.ancestors.pop(),e.schema=i,e.create(n,o,s,r)}function ZY(e,n){if(n.data&&n.data.estree&&e.evaluater){let r=n.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}fX(e,n.position)}function QY(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);fX(e,n.position)}function $Y(e,n,r){let i=e.schema,a=i;n.name===`svg`&&i.space===`html`&&(a=EY,e.schema=a),e.ancestors.push(n);let o=n.name===null?e.Fragment:dX(e,n.name,!0),s=sX(e,n),c=cX(e,n);return nX(e,s,o,n),rX(s,c),e.ancestors.pop(),e.schema=i,e.create(n,o,s,r)}function eX(e,n,r){let i={};return rX(i,cX(e,n)),e.create(n,e.Fragment,i,r)}function tX(e,n){return n.value}function nX(e,n,r,i){typeof r!=`string`&&r!==e.Fragment&&e.passNode&&(n.node=i)}function rX(e,n){if(n.length>0){let r=n.length>1?n:n[0];r&&(e.children=r)}}function iX(e,n,r){return i;function i(e,i,a,o){let s=Array.isArray(a.children)?r:n;return o?s(i,a,o):s(i,a)}}function aX(e,n){return r;function r(r,i,a,o){let s=Array.isArray(a.children),c=NY(r);return n(i,a,o,s,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function oX(e,n){let r={},i,a;for(a in n.properties)if(a!==`children`&&HY.call(n.properties,a)){let o=lX(e,a,n.properties[a]);if(o){let[a,s]=o;e.tableCellAlignToStyle&&a===`align`&&typeof s==`string`&&KY.has(n.tagName)?i=s:r[a]=s}}if(i){let n=r.style||={};n[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=i}return r}function sX(e,n){let r={};for(let i of n.attributes)if(i.type===`mdxJsxExpressionAttribute`)if(i.data&&i.data.estree&&e.evaluater){let n=i.data.estree.body[0];n.type;let a=n.expression;a.type;let o=a.properties[0];o.type,Object.assign(r,e.evaluater.evaluateExpression(o.argument))}else fX(e,n.position);else{let a=i.name,o;if(i.value&&typeof i.value==`object`)if(i.value.data&&i.value.data.estree&&e.evaluater){let n=i.value.data.estree.body[0];n.type,o=e.evaluater.evaluateExpression(n.expression)}else fX(e,n.position);else o=i.value===null?!0:i.value;r[a]=o}return r}function cX(e,n){let r=[],i=-1,a=e.passKeys?new Map:UY;for(;++i<n.children.length;){let o=n.children[i],s;if(e.passKeys){let e=o.type===`element`?o.tagName:o.type===`mdxJsxFlowElement`||o.type===`mdxJsxTextElement`?o.name:void 0;if(e){let n=a.get(e)||0;s=e+`-`+n,a.set(e,n+1)}}let c=YY(e,o,s);c!==void 0&&r.push(c)}return r}function lX(e,n,r){let i=SY(e.schema,n);if(!(r==null||typeof r==`number`&&Number.isNaN(r))){if(Array.isArray(r)&&(r=i.commaSeparated?zJ(r):DY(r)),i.property===`style`){let n=typeof r==`object`?r:uX(e,String(r));return e.stylePropertyNameCase===`css`&&(n=pX(n)),[`style`,n]}return[e.elementAttributeNameCase===`react`&&i.space?vY[i.property]||i.property:i.attribute,r]}}function uX(e,n){try{return(0,VY.default)(n,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};let r=n,i=new BY("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw i.file=e.filePath||void 0,i.url=qY+`#cannot-parse-style-attribute`,i}}function dX(e,n,r){let i;if(!r)i={type:`Literal`,value:n};else if(n.includes(`.`)){let e=n.split(`.`),r=-1,a;for(;++r<e.length;){let n=UJ(e[r])?{type:`Identifier`,name:e[r]}:{type:`Literal`,value:e[r]};a=a?{type:`MemberExpression`,object:a,property:n,computed:!!(r&&n.type===`Literal`),optional:!1}:n}i=a}else i=UJ(n)&&!/^[a-z]/.test(n)?{type:`Identifier`,name:n}:{type:`Literal`,value:n};if(i.type===`Literal`){let n=i.value;return HY.call(e.components,n)?e.components[n]:n}if(e.evaluater)return e.evaluater.evaluateExpression(i);fX(e)}function fX(e,n){let r=new BY("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:n,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=qY+`#cannot-handle-mdx-estrees-without-createevaluater`,r}function pX(e){let n={},r;for(r in e)HY.call(e,r)&&(n[mX(r)]=e[r]);return n}function mX(e){let n=e.replace(WY,hX);return n.slice(0,3)===`ms-`&&(n=`-`+n),n}function hX(e){return`-`+e.toLowerCase()}var gX={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},_X={};function vX(e,n){let r=n||_X;return yX(e,typeof r.includeImageAlt==`boolean`?r.includeImageAlt:!0,typeof r.includeHtml==`boolean`?r.includeHtml:!0)}function yX(e,n,r){if(xX(e)){if(`value`in e)return e.type===`html`&&!r?``:e.value;if(n&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return bX(e.children,n,r)}return Array.isArray(e)?bX(e,n,r):``}function bX(e,n,r){let i=[],a=-1;for(;++a<e.length;)i[a]=yX(e[a],n,r);return i.join(``)}function xX(e){return!!(e&&typeof e==`object`)}var SX=document.createElement(`i`);function CX(e){let n=`&`+e+`;`;SX.innerHTML=n;let r=SX.textContent;return r.charCodeAt(r.length-1)===59&&e!==`semi`||r===n?!1:r}function wX(e,n,r,i){let a=e.length,o=0,s;if(n=n<0?-n>a?0:a+n:n>a?a:n,r=r>0?r:0,i.length<1e4)s=Array.from(i),s.unshift(n,r),e.splice(...s);else for(r&&e.splice(n,r);o<i.length;)s=i.slice(o,o+1e4),s.unshift(n,0),e.splice(...s),o+=1e4,n+=1e4}function TX(e,n){return e.length>0?(wX(e,e.length,0,n),e):n}var EX={}.hasOwnProperty;function DX(e){let n={},r=-1;for(;++r<e.length;)OX(n,e[r]);return n}function OX(e,n){let r;for(r in n){let i=(EX.call(e,r)?e[r]:void 0)||(e[r]={}),a=n[r],o;if(a)for(o in a){EX.call(i,o)||(i[o]=[]);let e=a[o];kX(i[o],Array.isArray(e)?e:e?[e]:[])}}}function kX(e,n){let r=-1,i=[];for(;++r<n.length;)(n[r].add===`after`?e:i).push(n[r]);wX(e,0,0,i)}function AX(e,n){let r=Number.parseInt(e,n);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)==65535||(r&65535)==65534||r>1114111?`�`:String.fromCodePoint(r)}function jX(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var MX=WX(/[A-Za-z]/),NX=WX(/[\dA-Za-z]/),PX=WX(/[#-'*+\--9=?A-Z^-~]/);function FX(e){return e!==null&&(e<32||e===127)}var IX=WX(/\d/),LX=WX(/[\dA-Fa-f]/),RX=WX(/[!-/:-@[-`{-~]/);function zX(e){return e!==null&&e<-2}function BX(e){return e!==null&&(e<0||e===32)}function VX(e){return e===-2||e===-1||e===32}var HX=WX(/\p{P}|\p{S}/u),UX=WX(/\s/);function WX(e){return n;function n(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function GX(e){let n=[],r=-1,i=0,a=0;for(;++r<e.length;){let o=e.charCodeAt(r),s=``;if(o===37&&NX(e.charCodeAt(r+1))&&NX(e.charCodeAt(r+2)))a=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(s=String.fromCharCode(o));else if(o>55295&&o<57344){let n=e.charCodeAt(r+1);o<56320&&n>56319&&n<57344?(s=String.fromCharCode(o,n),a=1):s=`�`}else s=String.fromCharCode(o);s&&=(n.push(e.slice(i,r),encodeURIComponent(s)),i=r+a+1,``),a&&=(r+=a,0)}return n.join(``)+e.slice(i)}function KX(e,n,r,i){let a=i?i-1:1/0,o=0;return s;function s(i){return VX(i)?(e.enter(r),c(i)):n(i)}function c(i){return VX(i)&&o++<a?(e.consume(i),c):(e.exit(r),n(i))}}var qX={tokenize:JX};function JX(e){let n=e.attempt(this.parser.constructs.contentInitial,i,a),r;return n;function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),KX(e,n,`linePrefix`)}function a(n){return e.enter(`paragraph`),o(n)}function o(n){let i=e.enter(`chunkText`,{contentType:`text`,previous:r});return r&&(r.next=i),r=i,s(n)}function s(n){if(n===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(n);return}return zX(n)?(e.consume(n),e.exit(`chunkText`),o):(e.consume(n),s)}}var YX={tokenize:ZX},XX={tokenize:QX};function ZX(e){let n=this,r=[],i=0,a,o,s;return c;function c(a){if(i<r.length){let o=r[i];return n.containerState=o[1],e.attempt(o[0].continuation,l,u)(a)}return u(a)}function l(e){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,a&&y();let r=n.events.length,o=r,s;for(;o--;)if(n.events[o][0]===`exit`&&n.events[o][1].type===`chunkFlow`){s=n.events[o][1].end;break}v(i);let c=r;for(;c<n.events.length;)n.events[c][1].end={...s},c++;return wX(n.events,o+1,0,n.events.slice(r)),n.events.length=c,u(e)}return c(e)}function u(o){if(i===r.length){if(!a)return p(o);if(a.currentConstruct&&a.currentConstruct.concrete)return h(o);n.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(XX,d,f)(o)}function d(e){return a&&y(),v(i),p(e)}function f(e){return n.parser.lazy[n.now().line]=i!==r.length,s=n.now().offset,h(e)}function p(r){return n.containerState={},e.attempt(XX,m,h)(r)}function m(e){return i++,r.push([n.currentConstruct,n.containerState]),p(e)}function h(r){if(r===null){a&&y(),v(0),e.consume(r);return}return a||=n.parser.flow(n.now()),e.enter(`chunkFlow`,{_tokenizer:a,contentType:`flow`,previous:o}),g(r)}function g(r){if(r===null){_(e.exit(`chunkFlow`),!0),v(0),e.consume(r);return}return zX(r)?(e.consume(r),_(e.exit(`chunkFlow`)),i=0,n.interrupt=void 0,c):(e.consume(r),g)}function _(e,r){let c=n.sliceStream(e);if(r&&c.push(null),e.previous=o,o&&(o.next=e),o=e,a.defineSkip(e.start),a.write(c),n.parser.lazy[e.start.line]){let e=a.events.length;for(;e--;)if(a.events[e][1].start.offset<s&&(!a.events[e][1].end||a.events[e][1].end.offset>s))return;let r=n.events.length,o=r,c,l;for(;o--;)if(n.events[o][0]===`exit`&&n.events[o][1].type===`chunkFlow`){if(c){l=n.events[o][1].end;break}c=!0}for(v(i),e=r;e<n.events.length;)n.events[e][1].end={...l},e++;wX(n.events,o+1,0,n.events.slice(r)),n.events.length=e}}function v(i){let a=r.length;for(;a-- >i;){let i=r[a];n.containerState=i[1],i[0].exit.call(n,e)}r.length=i}function y(){a.write([null]),o=void 0,a=void 0,n.containerState._closeFlow=void 0}}function QX(e,n,r){return KX(e,e.attempt(this.parser.constructs.document,n,r),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function $X(e){if(e===null||BX(e)||UX(e))return 1;if(HX(e))return 2}function eZ(e,n,r){let i=[],a=-1;for(;++a<e.length;){let o=e[a].resolveAll;o&&!i.includes(o)&&(n=o(n,r),i.push(o))}return n}var tZ={name:`attention`,resolveAll:nZ,tokenize:rZ};function nZ(e,n){let r=-1,i,a,o,s,c,l,u,d;for(;++r<e.length;)if(e[r][0]===`enter`&&e[r][1].type===`attentionSequence`&&e[r][1]._close){for(i=r;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&n.sliceSerialize(e[i][1]).charCodeAt(0)===n.sliceSerialize(e[r][1]).charCodeAt(0)){if((e[i][1]._close||e[r][1]._open)&&(e[r][1].end.offset-e[r][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[r][1].end.offset-e[r][1].start.offset)%3))continue;l=e[i][1].end.offset-e[i][1].start.offset>1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;let f={...e[i][1].end},p={...e[r][1].start};iZ(f,-l),iZ(p,l),s={type:l>1?`strongSequence`:`emphasisSequence`,start:f,end:{...e[i][1].end}},c={type:l>1?`strongSequence`:`emphasisSequence`,start:{...e[r][1].start},end:p},o={type:l>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[r][1].start}},a={type:l>1?`strong`:`emphasis`,start:{...s.start},end:{...c.end}},e[i][1].end={...s.start},e[r][1].start={...c.end},u=[],e[i][1].end.offset-e[i][1].start.offset&&(u=TX(u,[[`enter`,e[i][1],n],[`exit`,e[i][1],n]])),u=TX(u,[[`enter`,a,n],[`enter`,s,n],[`exit`,s,n],[`enter`,o,n]]),u=TX(u,eZ(n.parser.constructs.insideSpan.null,e.slice(i+1,r),n)),u=TX(u,[[`exit`,o,n],[`enter`,c,n],[`exit`,c,n],[`exit`,a,n]]),e[r][1].end.offset-e[r][1].start.offset?(d=2,u=TX(u,[[`enter`,e[r][1],n],[`exit`,e[r][1],n]])):d=0,wX(e,i-1,r-i+3,u),r=i+u.length-d-2;break}}for(r=-1;++r<e.length;)e[r][1].type===`attentionSequence`&&(e[r][1].type=`data`);return e}function rZ(e,n){let r=this.parser.constructs.attentionMarkers.null,i=this.previous,a=$X(i),o;return s;function s(n){return o=n,e.enter(`attentionSequence`),c(n)}function c(s){if(s===o)return e.consume(s),c;let l=e.exit(`attentionSequence`),u=$X(s),d=!u||u===2&&a||r.includes(s),f=!a||a===2&&u||r.includes(i);return l._open=!!(o===42?d:d&&(a||!f)),l._close=!!(o===42?f:f&&(u||!d)),n(s)}}function iZ(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}var aZ={name:`autolink`,tokenize:oZ};function oZ(e,n,r){let i=0;return a;function a(n){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),o}function o(n){return MX(n)?(e.consume(n),s):n===64?r(n):u(n)}function s(e){return e===43||e===45||e===46||NX(e)?(i=1,c(e)):u(e)}function c(n){return n===58?(e.consume(n),i=0,l):(n===43||n===45||n===46||NX(n))&&i++<32?(e.consume(n),c):(i=0,u(n))}function l(i){return i===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(i),e.exit(`autolinkMarker`),e.exit(`autolink`),n):i===null||i===32||i===60||FX(i)?r(i):(e.consume(i),l)}function u(n){return n===64?(e.consume(n),d):PX(n)?(e.consume(n),u):r(n)}function d(e){return NX(e)?f(e):r(e)}function f(r){return r===46?(e.consume(r),i=0,d):r===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),n):p(r)}function p(n){if((n===45||NX(n))&&i++<63){let r=n===45?p:f;return e.consume(n),r}return r(n)}}var sZ={partial:!0,tokenize:cZ};function cZ(e,n,r){return i;function i(n){return VX(n)?KX(e,a,`linePrefix`)(n):a(n)}function a(e){return e===null||zX(e)?n(e):r(e)}}var lZ={continuation:{tokenize:dZ},exit:fZ,name:`blockQuote`,tokenize:uZ};function uZ(e,n,r){let i=this;return a;function a(n){if(n===62){let r=i.containerState;return r.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(n),e.exit(`blockQuoteMarker`),o}return r(n)}function o(r){return VX(r)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(r),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),n):(e.exit(`blockQuotePrefix`),n(r))}}function dZ(e,n,r){let i=this;return a;function a(n){return VX(n)?KX(e,o,`linePrefix`,i.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(n):o(n)}function o(i){return e.attempt(lZ,n,r)(i)}}function fZ(e){e.exit(`blockQuote`)}var pZ={name:`characterEscape`,tokenize:mZ};function mZ(e,n,r){return i;function i(n){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(n),e.exit(`escapeMarker`),a}function a(i){return RX(i)?(e.enter(`characterEscapeValue`),e.consume(i),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),n):r(i)}}var hZ={name:`characterReference`,tokenize:gZ};function gZ(e,n,r){let i=this,a=0,o,s;return c;function c(n){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(n),e.exit(`characterReferenceMarker`),l}function l(n){return n===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(n),e.exit(`characterReferenceMarkerNumeric`),u):(e.enter(`characterReferenceValue`),o=31,s=NX,d(n))}function u(n){return n===88||n===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(n),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),o=6,s=LX,d):(e.enter(`characterReferenceValue`),o=7,s=IX,d(n))}function d(c){if(c===59&&a){let a=e.exit(`characterReferenceValue`);return s===NX&&!CX(i.sliceSerialize(a))?r(c):(e.enter(`characterReferenceMarker`),e.consume(c),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),n)}return s(c)&&a++<o?(e.consume(c),d):r(c)}}var _Z={partial:!0,tokenize:bZ},vZ={concrete:!0,name:`codeFenced`,tokenize:yZ};function yZ(e,n,r){let i=this,a={partial:!0,tokenize:S},o=0,s=0,c;return l;function l(e){return u(e)}function u(n){let r=i.events[i.events.length-1];return o=r&&r[1].type===`linePrefix`?r[2].sliceSerialize(r[1],!0).length:0,c=n,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),d(n)}function d(n){return n===c?(s++,e.consume(n),d):s<3?r(n):(e.exit(`codeFencedFenceSequence`),VX(n)?KX(e,f,`whitespace`)(n):f(n))}function f(r){return r===null||zX(r)?(e.exit(`codeFencedFence`),i.interrupt?n(r):e.check(_Z,g,x)(r)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),p(r))}function p(n){return n===null||zX(n)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),f(n)):VX(n)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),KX(e,m,`whitespace`)(n)):n===96&&n===c?r(n):(e.consume(n),p)}function m(n){return n===null||zX(n)?f(n):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),h(n))}function h(n){return n===null||zX(n)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),f(n)):n===96&&n===c?r(n):(e.consume(n),h)}function g(n){return e.attempt(a,x,_)(n)}function _(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),v}function v(n){return o>0&&VX(n)?KX(e,y,`linePrefix`,o+1)(n):y(n)}function y(n){return n===null||zX(n)?e.check(_Z,g,x)(n):(e.enter(`codeFlowValue`),b(n))}function b(n){return n===null||zX(n)?(e.exit(`codeFlowValue`),y(n)):(e.consume(n),b)}function x(r){return e.exit(`codeFenced`),n(r)}function S(e,n,r){let a=0;return o;function o(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),l}function l(n){return e.enter(`codeFencedFence`),VX(n)?KX(e,u,`linePrefix`,i.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(n):u(n)}function u(n){return n===c?(e.enter(`codeFencedFenceSequence`),d(n)):r(n)}function d(n){return n===c?(a++,e.consume(n),d):a>=s?(e.exit(`codeFencedFenceSequence`),VX(n)?KX(e,f,`whitespace`)(n):f(n)):r(n)}function f(i){return i===null||zX(i)?(e.exit(`codeFencedFence`),n(i)):r(i)}}}function bZ(e,n,r){let i=this;return a;function a(n){return n===null?r(n):(e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),o)}function o(e){return i.parser.lazy[i.now().line]?r(e):n(e)}}var xZ={name:`codeIndented`,tokenize:CZ},SZ={partial:!0,tokenize:wZ};function CZ(e,n,r){let i=this;return a;function a(n){return e.enter(`codeIndented`),KX(e,o,`linePrefix`,5)(n)}function o(e){let n=i.events[i.events.length-1];return n&&n[1].type===`linePrefix`&&n[2].sliceSerialize(n[1],!0).length>=4?s(e):r(e)}function s(n){return n===null?l(n):zX(n)?e.attempt(SZ,s,l)(n):(e.enter(`codeFlowValue`),c(n))}function c(n){return n===null||zX(n)?(e.exit(`codeFlowValue`),s(n)):(e.consume(n),c)}function l(r){return e.exit(`codeIndented`),n(r)}}function wZ(e,n,r){let i=this;return a;function a(n){return i.parser.lazy[i.now().line]?r(n):zX(n)?(e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),a):KX(e,o,`linePrefix`,5)(n)}function o(e){let o=i.events[i.events.length-1];return o&&o[1].type===`linePrefix`&&o[2].sliceSerialize(o[1],!0).length>=4?n(e):zX(e)?a(e):r(e)}}var TZ={name:`codeText`,previous:DZ,resolve:EZ,tokenize:OZ};function EZ(e){let n=e.length-4,r=3,i,a;if((e[r][1].type===`lineEnding`||e[r][1].type===`space`)&&(e[n][1].type===`lineEnding`||e[n][1].type===`space`)){for(i=r;++i<n;)if(e[i][1].type===`codeTextData`){e[r][1].type=`codeTextPadding`,e[n][1].type=`codeTextPadding`,r+=2,n-=2;break}}for(i=r-1,n++;++i<=n;)a===void 0?i!==n&&e[i][1].type!==`lineEnding`&&(a=i):(i===n||e[i][1].type===`lineEnding`)&&(e[a][1].type=`codeTextData`,i!==a+2&&(e[a][1].end=e[i-1][1].end,e.splice(a+2,i-a-2),n-=i-a-2,i=a+2),a=void 0);return e}function DZ(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function OZ(e,n,r){let i=0,a,o;return s;function s(n){return e.enter(`codeText`),e.enter(`codeTextSequence`),c(n)}function c(n){return n===96?(e.consume(n),i++,c):(e.exit(`codeTextSequence`),l(n))}function l(n){return n===null?r(n):n===32?(e.enter(`space`),e.consume(n),e.exit(`space`),l):n===96?(o=e.enter(`codeTextSequence`),a=0,d(n)):zX(n)?(e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),l):(e.enter(`codeTextData`),u(n))}function u(n){return n===null||n===32||n===96||zX(n)?(e.exit(`codeTextData`),l(n)):(e.consume(n),u)}function d(r){return r===96?(e.consume(r),a++,d):a===i?(e.exit(`codeTextSequence`),e.exit(`codeText`),n(r)):(o.type=`codeTextData`,u(r))}}var kZ=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){let r=n??1/0;return r<this.left.length?this.left.slice(e,r):e>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(e,n,r){let i=n||0;this.setCursor(Math.trunc(e));let a=this.right.splice(this.right.length-i,1/0);return r&&AZ(this.left,r),a.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),AZ(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),AZ(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let n=this.left.splice(e,1/0);AZ(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-e,1/0);AZ(this.left,n.reverse())}}};function AZ(e,n){let r=0;if(n.length<1e4)e.push(...n);else for(;r<n.length;)e.push(...n.slice(r,r+1e4)),r+=1e4}function jZ(e){let n={},r=-1,i,a,o,s,c,l,u,d=new kZ(e);for(;++r<d.length;){for(;r in n;)r=n[r];if(i=d.get(r),r&&i[1].type===`chunkFlow`&&d.get(r-1)[1].type===`listItemPrefix`&&(l=i[1]._tokenizer.events,o=0,o<l.length&&l[o][1].type===`lineEndingBlank`&&(o+=2),o<l.length&&l[o][1].type===`content`))for(;++o<l.length&&l[o][1].type!==`content`;)l[o][1].type===`chunkText`&&(l[o][1]._isInFirstContentOfListItem=!0,o++);if(i[0]===`enter`)i[1].contentType&&(Object.assign(n,MZ(d,r)),r=n[r],u=!0);else if(i[1]._container){for(o=r,a=void 0;o--;)if(s=d.get(o),s[1].type===`lineEnding`||s[1].type===`lineEndingBlank`)s[0]===`enter`&&(a&&(d.get(a)[1].type=`lineEndingBlank`),s[1].type=`lineEnding`,a=o);else if(!(s[1].type===`linePrefix`||s[1].type===`listItemIndent`))break;a&&(i[1].end={...d.get(a)[1].start},c=d.slice(a,r),c.unshift(i),d.splice(a,r-a+1,c))}}return wX(e,0,1/0,d.slice(0)),!u}function MZ(e,n){let r=e.get(n)[1],i=e.get(n)[2],a=n-1,o=[],s=r._tokenizer;s||(s=i.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));let c=s.events,l=[],u={},d,f,p=-1,m=r,h=0,g=0,_=[g];for(;m;){for(;e.get(++a)[1]!==m;);o.push(a),m._tokenizer||(d=i.sliceStream(m),m.next||d.push(null),f&&s.defineSkip(m.start),m._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(d),m._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),f=m,m=m.next}for(m=r;++p<c.length;)c[p][0]===`exit`&&c[p-1][0]===`enter`&&c[p][1].type===c[p-1][1].type&&c[p][1].start.line!==c[p][1].end.line&&(g=p+1,_.push(g),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(s.events=[],m?(m._tokenizer=void 0,m.previous=void 0):_.pop(),p=_.length;p--;){let n=c.slice(_[p],_[p+1]),r=o.pop();l.push([r,r+n.length-1]),e.splice(r,2,n)}for(l.reverse(),p=-1;++p<l.length;)u[h+l[p][0]]=h+l[p][1],h+=l[p][1]-l[p][0]-1;return u}var NZ={resolve:FZ,tokenize:IZ},PZ={partial:!0,tokenize:LZ};function FZ(e){return jZ(e),e}function IZ(e,n){let r;return i;function i(n){return e.enter(`content`),r=e.enter(`chunkContent`,{contentType:`content`}),a(n)}function a(n){return n===null?o(n):zX(n)?e.check(PZ,s,o)(n):(e.consume(n),a)}function o(r){return e.exit(`chunkContent`),e.exit(`content`),n(r)}function s(n){return e.consume(n),e.exit(`chunkContent`),r.next=e.enter(`chunkContent`,{contentType:`content`,previous:r}),r=r.next,a}}function LZ(e,n,r){let i=this;return a;function a(n){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),KX(e,o,`linePrefix`)}function o(a){if(a===null||zX(a))return r(a);let o=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes(`codeIndented`)&&o&&o[1].type===`linePrefix`&&o[2].sliceSerialize(o[1],!0).length>=4?n(a):e.interrupt(i.parser.constructs.flow,r,n)(a)}}function RZ(e,n,r,i,a,o,s,c,l){let u=l||1/0,d=0;return f;function f(n){return n===60?(e.enter(i),e.enter(a),e.enter(o),e.consume(n),e.exit(o),p):n===null||n===32||n===41||FX(n)?r(n):(e.enter(i),e.enter(s),e.enter(c),e.enter(`chunkString`,{contentType:`string`}),g(n))}function p(r){return r===62?(e.enter(o),e.consume(r),e.exit(o),e.exit(a),e.exit(i),n):(e.enter(c),e.enter(`chunkString`,{contentType:`string`}),m(r))}function m(n){return n===62?(e.exit(`chunkString`),e.exit(c),p(n)):n===null||n===60||zX(n)?r(n):(e.consume(n),n===92?h:m)}function h(n){return n===60||n===62||n===92?(e.consume(n),m):m(n)}function g(a){return!d&&(a===null||a===41||BX(a))?(e.exit(`chunkString`),e.exit(c),e.exit(s),e.exit(i),n(a)):d<u&&a===40?(e.consume(a),d++,g):a===41?(e.consume(a),d--,g):a===null||a===32||a===40||FX(a)?r(a):(e.consume(a),a===92?_:g)}function _(n){return n===40||n===41||n===92?(e.consume(n),g):g(n)}}function zZ(e,n,r,i,a,o){let s=this,c=0,l;return u;function u(n){return e.enter(i),e.enter(a),e.consume(n),e.exit(a),e.enter(o),d}function d(u){return c>999||u===null||u===91||u===93&&!l||u===94&&!c&&`_hiddenFootnoteSupport`in s.parser.constructs?r(u):u===93?(e.exit(o),e.enter(a),e.consume(u),e.exit(a),e.exit(i),n):zX(u)?(e.enter(`lineEnding`),e.consume(u),e.exit(`lineEnding`),d):(e.enter(`chunkString`,{contentType:`string`}),f(u))}function f(n){return n===null||n===91||n===93||zX(n)||c++>999?(e.exit(`chunkString`),d(n)):(e.consume(n),l||=!VX(n),n===92?p:f)}function p(n){return n===91||n===92||n===93?(e.consume(n),c++,f):f(n)}}function BZ(e,n,r,i,a,o){let s;return c;function c(n){return n===34||n===39||n===40?(e.enter(i),e.enter(a),e.consume(n),e.exit(a),s=n===40?41:n,l):r(n)}function l(r){return r===s?(e.enter(a),e.consume(r),e.exit(a),e.exit(i),n):(e.enter(o),u(r))}function u(n){return n===s?(e.exit(o),l(s)):n===null?r(n):zX(n)?(e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),KX(e,u,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),d(n))}function d(n){return n===s||n===null||zX(n)?(e.exit(`chunkString`),u(n)):(e.consume(n),n===92?f:d)}function f(n){return n===s||n===92?(e.consume(n),d):d(n)}}function VZ(e,n){let r;return i;function i(a){return zX(a)?(e.enter(`lineEnding`),e.consume(a),e.exit(`lineEnding`),r=!0,i):VX(a)?KX(e,i,r?`linePrefix`:`lineSuffix`)(a):n(a)}}var HZ={name:`definition`,tokenize:WZ},UZ={partial:!0,tokenize:GZ};function WZ(e,n,r){let i=this,a;return o;function o(n){return e.enter(`definition`),s(n)}function s(n){return zZ.call(i,e,c,r,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(n)}function c(n){return a=jX(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),n===58?(e.enter(`definitionMarker`),e.consume(n),e.exit(`definitionMarker`),l):r(n)}function l(n){return BX(n)?VZ(e,u)(n):u(n)}function u(n){return RZ(e,d,r,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(n)}function d(n){return e.attempt(UZ,f,f)(n)}function f(n){return VX(n)?KX(e,p,`whitespace`)(n):p(n)}function p(o){return o===null||zX(o)?(e.exit(`definition`),i.parser.defined.push(a),n(o)):r(o)}}function GZ(e,n,r){return i;function i(n){return BX(n)?VZ(e,a)(n):r(n)}function a(n){return BZ(e,o,r,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(n)}function o(n){return VX(n)?KX(e,s,`whitespace`)(n):s(n)}function s(e){return e===null||zX(e)?n(e):r(e)}}var KZ={name:`hardBreakEscape`,tokenize:qZ};function qZ(e,n,r){return i;function i(n){return e.enter(`hardBreakEscape`),e.consume(n),a}function a(i){return zX(i)?(e.exit(`hardBreakEscape`),n(i)):r(i)}}var JZ={name:`headingAtx`,resolve:YZ,tokenize:XZ};function YZ(e,n){let r=e.length-2,i=3,a,o;return e[i][1].type===`whitespace`&&(i+=2),r-2>i&&e[r][1].type===`whitespace`&&(r-=2),e[r][1].type===`atxHeadingSequence`&&(i===r-1||r-4>i&&e[r-2][1].type===`whitespace`)&&(r-=i+1===r?2:4),r>i&&(a={type:`atxHeadingText`,start:e[i][1].start,end:e[r][1].end},o={type:`chunkText`,start:e[i][1].start,end:e[r][1].end,contentType:`text`},wX(e,i,r-i+1,[[`enter`,a,n],[`enter`,o,n],[`exit`,o,n],[`exit`,a,n]])),e}function XZ(e,n,r){let i=0;return a;function a(n){return e.enter(`atxHeading`),o(n)}function o(n){return e.enter(`atxHeadingSequence`),s(n)}function s(n){return n===35&&i++<6?(e.consume(n),s):n===null||BX(n)?(e.exit(`atxHeadingSequence`),c(n)):r(n)}function c(r){return r===35?(e.enter(`atxHeadingSequence`),l(r)):r===null||zX(r)?(e.exit(`atxHeading`),n(r)):VX(r)?KX(e,c,`whitespace`)(r):(e.enter(`atxHeadingText`),u(r))}function l(n){return n===35?(e.consume(n),l):(e.exit(`atxHeadingSequence`),c(n))}function u(n){return n===null||n===35||BX(n)?(e.exit(`atxHeadingText`),c(n)):(e.consume(n),u)}}var ZZ=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),QZ=[`pre`,`script`,`style`,`textarea`],$Z={concrete:!0,name:`htmlFlow`,resolveTo:nQ,tokenize:rQ},eQ={partial:!0,tokenize:aQ},tQ={partial:!0,tokenize:iQ};function nQ(e){let n=e.length;for(;n--&&!(e[n][0]===`enter`&&e[n][1].type===`htmlFlow`););return n>1&&e[n-2][1].type===`linePrefix`&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function rQ(e,n,r){let i=this,a,o,s,c,l;return u;function u(e){return d(e)}function d(n){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(n),f}function f(c){return c===33?(e.consume(c),p):c===47?(e.consume(c),o=!0,g):c===63?(e.consume(c),a=3,i.interrupt?n:L):MX(c)?(e.consume(c),s=String.fromCharCode(c),_):r(c)}function p(o){return o===45?(e.consume(o),a=2,m):o===91?(e.consume(o),a=5,c=0,h):MX(o)?(e.consume(o),a=4,i.interrupt?n:L):r(o)}function m(a){return a===45?(e.consume(a),i.interrupt?n:L):r(a)}function h(a){return a===`CDATA[`.charCodeAt(c++)?(e.consume(a),c===6?i.interrupt?n:k:h):r(a)}function g(n){return MX(n)?(e.consume(n),s=String.fromCharCode(n),_):r(n)}function _(c){if(c===null||c===47||c===62||BX(c)){let l=c===47,u=s.toLowerCase();return!l&&!o&&QZ.includes(u)?(a=1,i.interrupt?n(c):k(c)):ZZ.includes(s.toLowerCase())?(a=6,l?(e.consume(c),v):i.interrupt?n(c):k(c)):(a=7,i.interrupt&&!i.parser.lazy[i.now().line]?r(c):o?y(c):b(c))}return c===45||NX(c)?(e.consume(c),s+=String.fromCharCode(c),_):r(c)}function v(a){return a===62?(e.consume(a),i.interrupt?n:k):r(a)}function y(n){return VX(n)?(e.consume(n),y):D(n)}function b(n){return n===47?(e.consume(n),D):n===58||n===95||MX(n)?(e.consume(n),x):VX(n)?(e.consume(n),b):D(n)}function x(n){return n===45||n===46||n===58||n===95||NX(n)?(e.consume(n),x):S(n)}function S(n){return n===61?(e.consume(n),C):VX(n)?(e.consume(n),S):b(n)}function C(n){return n===null||n===60||n===61||n===62||n===96?r(n):n===34||n===39?(e.consume(n),l=n,w):VX(n)?(e.consume(n),C):T(n)}function w(n){return n===l?(e.consume(n),l=null,E):n===null||zX(n)?r(n):(e.consume(n),w)}function T(n){return n===null||n===34||n===39||n===47||n===60||n===61||n===62||n===96||BX(n)?S(n):(e.consume(n),T)}function E(e){return e===47||e===62||VX(e)?b(e):r(e)}function D(n){return n===62?(e.consume(n),O):r(n)}function O(n){return n===null||zX(n)?k(n):VX(n)?(e.consume(n),O):r(n)}function k(n){return n===45&&a===2?(e.consume(n),N):n===60&&a===1?(e.consume(n),P):n===62&&a===4?(e.consume(n),R):n===63&&a===3?(e.consume(n),L):n===93&&a===5?(e.consume(n),I):zX(n)&&(a===6||a===7)?(e.exit(`htmlFlowData`),e.check(eQ,z,A)(n)):n===null||zX(n)?(e.exit(`htmlFlowData`),A(n)):(e.consume(n),k)}function A(n){return e.check(tQ,j,z)(n)}function j(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),M}function M(n){return n===null||zX(n)?A(n):(e.enter(`htmlFlowData`),k(n))}function N(n){return n===45?(e.consume(n),L):k(n)}function P(n){return n===47?(e.consume(n),s=``,F):k(n)}function F(n){if(n===62){let r=s.toLowerCase();return QZ.includes(r)?(e.consume(n),R):k(n)}return MX(n)&&s.length<8?(e.consume(n),s+=String.fromCharCode(n),F):k(n)}function I(n){return n===93?(e.consume(n),L):k(n)}function L(n){return n===62?(e.consume(n),R):n===45&&a===2?(e.consume(n),L):k(n)}function R(n){return n===null||zX(n)?(e.exit(`htmlFlowData`),z(n)):(e.consume(n),R)}function z(r){return e.exit(`htmlFlow`),n(r)}}function iQ(e,n,r){let i=this;return a;function a(n){return zX(n)?(e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),o):r(n)}function o(e){return i.parser.lazy[i.now().line]?r(e):n(e)}}function aQ(e,n,r){return i;function i(i){return e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),e.attempt(sZ,n,r)}}var oQ={name:`htmlText`,tokenize:sQ};function sQ(e,n,r){let i=this,a,o,s;return c;function c(n){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(n),l}function l(n){return n===33?(e.consume(n),u):n===47?(e.consume(n),S):n===63?(e.consume(n),b):MX(n)?(e.consume(n),T):r(n)}function u(n){return n===45?(e.consume(n),d):n===91?(e.consume(n),o=0,h):MX(n)?(e.consume(n),y):r(n)}function d(n){return n===45?(e.consume(n),m):r(n)}function f(n){return n===null?r(n):n===45?(e.consume(n),p):zX(n)?(s=f,P(n)):(e.consume(n),f)}function p(n){return n===45?(e.consume(n),m):f(n)}function m(e){return e===62?N(e):e===45?p(e):f(e)}function h(n){return n===`CDATA[`.charCodeAt(o++)?(e.consume(n),o===6?g:h):r(n)}function g(n){return n===null?r(n):n===93?(e.consume(n),_):zX(n)?(s=g,P(n)):(e.consume(n),g)}function _(n){return n===93?(e.consume(n),v):g(n)}function v(n){return n===62?N(n):n===93?(e.consume(n),v):g(n)}function y(n){return n===null||n===62?N(n):zX(n)?(s=y,P(n)):(e.consume(n),y)}function b(n){return n===null?r(n):n===63?(e.consume(n),x):zX(n)?(s=b,P(n)):(e.consume(n),b)}function x(e){return e===62?N(e):b(e)}function S(n){return MX(n)?(e.consume(n),C):r(n)}function C(n){return n===45||NX(n)?(e.consume(n),C):w(n)}function w(n){return zX(n)?(s=w,P(n)):VX(n)?(e.consume(n),w):N(n)}function T(n){return n===45||NX(n)?(e.consume(n),T):n===47||n===62||BX(n)?E(n):r(n)}function E(n){return n===47?(e.consume(n),N):n===58||n===95||MX(n)?(e.consume(n),D):zX(n)?(s=E,P(n)):VX(n)?(e.consume(n),E):N(n)}function D(n){return n===45||n===46||n===58||n===95||NX(n)?(e.consume(n),D):O(n)}function O(n){return n===61?(e.consume(n),k):zX(n)?(s=O,P(n)):VX(n)?(e.consume(n),O):E(n)}function k(n){return n===null||n===60||n===61||n===62||n===96?r(n):n===34||n===39?(e.consume(n),a=n,A):zX(n)?(s=k,P(n)):VX(n)?(e.consume(n),k):(e.consume(n),j)}function A(n){return n===a?(e.consume(n),a=void 0,M):n===null?r(n):zX(n)?(s=A,P(n)):(e.consume(n),A)}function j(n){return n===null||n===34||n===39||n===60||n===61||n===96?r(n):n===47||n===62||BX(n)?E(n):(e.consume(n),j)}function M(e){return e===47||e===62||BX(e)?E(e):r(e)}function N(i){return i===62?(e.consume(i),e.exit(`htmlTextData`),e.exit(`htmlText`),n):r(i)}function P(n){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),F}function F(n){return VX(n)?KX(e,I,`linePrefix`,i.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(n):I(n)}function I(n){return e.enter(`htmlTextData`),s(n)}}var cQ={name:`labelEnd`,resolveAll:fQ,resolveTo:pQ,tokenize:mQ},lQ={tokenize:hQ},uQ={tokenize:gQ},dQ={tokenize:_Q};function fQ(e){let n=-1,r=[];for(;++n<e.length;){let i=e[n][1];if(r.push(e[n]),i.type===`labelImage`||i.type===`labelLink`||i.type===`labelEnd`){let e=i.type===`labelImage`?4:2;i.type=`data`,n+=e}}return e.length!==r.length&&wX(e,0,e.length,r),e}function pQ(e,n){let r=e.length,i=0,a,o,s,c;for(;r--;)if(a=e[r][1],o){if(a.type===`link`||a.type===`labelLink`&&a._inactive)break;e[r][0]===`enter`&&a.type===`labelLink`&&(a._inactive=!0)}else if(s){if(e[r][0]===`enter`&&(a.type===`labelImage`||a.type===`labelLink`)&&!a._balanced&&(o=r,a.type!==`labelLink`)){i=2;break}}else a.type===`labelEnd`&&(s=r);let l={type:e[o][1].type===`labelLink`?`link`:`image`,start:{...e[o][1].start},end:{...e[e.length-1][1].end}},u={type:`label`,start:{...e[o][1].start},end:{...e[s][1].end}},d={type:`labelText`,start:{...e[o+i+2][1].end},end:{...e[s-2][1].start}};return c=[[`enter`,l,n],[`enter`,u,n]],c=TX(c,e.slice(o+1,o+i+3)),c=TX(c,[[`enter`,d,n]]),c=TX(c,eZ(n.parser.constructs.insideSpan.null,e.slice(o+i+4,s-3),n)),c=TX(c,[[`exit`,d,n],e[s-2],e[s-1],[`exit`,u,n]]),c=TX(c,e.slice(s+1)),c=TX(c,[[`exit`,l,n]]),wX(e,o,e.length,c),e}function mQ(e,n,r){let i=this,a=i.events.length,o,s;for(;a--;)if((i.events[a][1].type===`labelImage`||i.events[a][1].type===`labelLink`)&&!i.events[a][1]._balanced){o=i.events[a][1];break}return c;function c(n){return o?o._inactive?f(n):(s=i.parser.defined.includes(jX(i.sliceSerialize({start:o.end,end:i.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(n),e.exit(`labelMarker`),e.exit(`labelEnd`),l):r(n)}function l(n){return n===40?e.attempt(lQ,d,s?d:f)(n):n===91?e.attempt(uQ,d,s?u:f)(n):s?d(n):f(n)}function u(n){return e.attempt(dQ,d,f)(n)}function d(e){return n(e)}function f(e){return o._balanced=!0,r(e)}}function hQ(e,n,r){return i;function i(n){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(n),e.exit(`resourceMarker`),a}function a(n){return BX(n)?VZ(e,o)(n):o(n)}function o(n){return n===41?d(n):RZ(e,s,c,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(n)}function s(n){return BX(n)?VZ(e,l)(n):d(n)}function c(e){return r(e)}function l(n){return n===34||n===39||n===40?BZ(e,u,r,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(n):d(n)}function u(n){return BX(n)?VZ(e,d)(n):d(n)}function d(i){return i===41?(e.enter(`resourceMarker`),e.consume(i),e.exit(`resourceMarker`),e.exit(`resource`),n):r(i)}}function gQ(e,n,r){let i=this;return a;function a(n){return zZ.call(i,e,o,s,`reference`,`referenceMarker`,`referenceString`)(n)}function o(e){return i.parser.defined.includes(jX(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(e):r(e)}function s(e){return r(e)}}function _Q(e,n,r){return i;function i(n){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(n),e.exit(`referenceMarker`),a}function a(i){return i===93?(e.enter(`referenceMarker`),e.consume(i),e.exit(`referenceMarker`),e.exit(`reference`),n):r(i)}}var vQ={name:`labelStartImage`,resolveAll:cQ.resolveAll,tokenize:yQ};function yQ(e,n,r){let i=this;return a;function a(n){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(n),e.exit(`labelImageMarker`),o}function o(n){return n===91?(e.enter(`labelMarker`),e.consume(n),e.exit(`labelMarker`),e.exit(`labelImage`),s):r(n)}function s(e){return e===94&&`_hiddenFootnoteSupport`in i.parser.constructs?r(e):n(e)}}var bQ={name:`labelStartLink`,resolveAll:cQ.resolveAll,tokenize:xQ};function xQ(e,n,r){let i=this;return a;function a(n){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(n),e.exit(`labelMarker`),e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in i.parser.constructs?r(e):n(e)}}var SQ={name:`lineEnding`,tokenize:CQ};function CQ(e,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),KX(e,n,`linePrefix`)}}var wQ={name:`thematicBreak`,tokenize:TQ};function TQ(e,n,r){let i=0,a;return o;function o(n){return e.enter(`thematicBreak`),s(n)}function s(e){return a=e,c(e)}function c(o){return o===a?(e.enter(`thematicBreakSequence`),l(o)):i>=3&&(o===null||zX(o))?(e.exit(`thematicBreak`),n(o)):r(o)}function l(n){return n===a?(e.consume(n),i++,l):(e.exit(`thematicBreakSequence`),VX(n)?KX(e,c,`whitespace`)(n):c(n))}}var EQ={continuation:{tokenize:AQ},exit:MQ,name:`list`,tokenize:kQ},DQ={partial:!0,tokenize:NQ},OQ={partial:!0,tokenize:jQ};function kQ(e,n,r){let i=this,a=i.events[i.events.length-1],o=a&&a[1].type===`linePrefix`?a[2].sliceSerialize(a[1],!0).length:0,s=0;return c;function c(n){let a=i.containerState.type||(n===42||n===43||n===45?`listUnordered`:`listOrdered`);if(a===`listUnordered`?!i.containerState.marker||n===i.containerState.marker:IX(n)){if(i.containerState.type||(i.containerState.type=a,e.enter(a,{_container:!0})),a===`listUnordered`)return e.enter(`listItemPrefix`),n===42||n===45?e.check(wQ,r,u)(n):u(n);if(!i.interrupt||n===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),l(n)}return r(n)}function l(n){return IX(n)&&++s<10?(e.consume(n),l):(!i.interrupt||s<2)&&(i.containerState.marker?n===i.containerState.marker:n===41||n===46)?(e.exit(`listItemValue`),u(n)):r(n)}function u(n){return e.enter(`listItemMarker`),e.consume(n),e.exit(`listItemMarker`),i.containerState.marker=i.containerState.marker||n,e.check(sZ,i.interrupt?r:d,e.attempt(DQ,p,f))}function d(e){return i.containerState.initialBlankLine=!0,o++,p(e)}function f(n){return VX(n)?(e.enter(`listItemPrefixWhitespace`),e.consume(n),e.exit(`listItemPrefixWhitespace`),p):r(n)}function p(r){return i.containerState.size=o+i.sliceSerialize(e.exit(`listItemPrefix`),!0).length,n(r)}}function AQ(e,n,r){let i=this;return i.containerState._closeFlow=void 0,e.check(sZ,a,o);function a(r){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,KX(e,n,`listItemIndent`,i.containerState.size+1)(r)}function o(r){return i.containerState.furtherBlankLines||!VX(r)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,s(r)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(OQ,n,s)(r))}function s(a){return i.containerState._closeFlow=!0,i.interrupt=void 0,KX(e,e.attempt(EQ,n,r),`linePrefix`,i.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(a)}}function jQ(e,n,r){let i=this;return KX(e,a,`listItemIndent`,i.containerState.size+1);function a(e){let a=i.events[i.events.length-1];return a&&a[1].type===`listItemIndent`&&a[2].sliceSerialize(a[1],!0).length===i.containerState.size?n(e):r(e)}}function MQ(e){e.exit(this.containerState.type)}function NQ(e,n,r){let i=this;return KX(e,a,`listItemPrefixWhitespace`,i.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function a(e){let a=i.events[i.events.length-1];return!VX(e)&&a&&a[1].type===`listItemPrefixWhitespace`?n(e):r(e)}}var PQ={name:`setextUnderline`,resolveTo:FQ,tokenize:IQ};function FQ(e,n){let r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&e.splice(r,1),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(e.splice(a,0,[`enter`,s,n]),e.splice(o+1,0,[`exit`,e[i][1],n]),e[i][1].end={...e[o][1].end}):e[i][1]=s,e.push([`exit`,s,n]),e}function IQ(e,n,r){let i=this,a;return o;function o(n){let o=i.events.length,c;for(;o--;)if(i.events[o][1].type!==`lineEnding`&&i.events[o][1].type!==`linePrefix`&&i.events[o][1].type!==`content`){c=i.events[o][1].type===`paragraph`;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||c)?(e.enter(`setextHeadingLine`),a=n,s(n)):r(n)}function s(n){return e.enter(`setextHeadingLineSequence`),c(n)}function c(n){return n===a?(e.consume(n),c):(e.exit(`setextHeadingLineSequence`),VX(n)?KX(e,l,`lineSuffix`)(n):l(n))}function l(i){return i===null||zX(i)?(e.exit(`setextHeadingLine`),n(i)):r(i)}}var LQ={tokenize:RQ};function RQ(e){let n=this,r=e.attempt(sZ,i,e.attempt(this.parser.constructs.flowInitial,a,KX(e,e.attempt(this.parser.constructs.flow,a,e.attempt(NZ,a)),`linePrefix`)));return r;function i(i){if(i===null){e.consume(i);return}return e.enter(`lineEndingBlank`),e.consume(i),e.exit(`lineEndingBlank`),n.currentConstruct=void 0,r}function a(i){if(i===null){e.consume(i);return}return e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n.currentConstruct=void 0,r}}var zQ={resolveAll:UQ()},BQ=HQ(`string`),VQ=HQ(`text`);function HQ(e){return{resolveAll:UQ(e===`text`?WQ:void 0),tokenize:n};function n(n){let r=this,i=this.parser.constructs[e],a=n.attempt(i,o,s);return o;function o(e){return l(e)?a(e):s(e)}function s(e){if(e===null){n.consume(e);return}return n.enter(`data`),n.consume(e),c}function c(e){return l(e)?(n.exit(`data`),a(e)):(n.consume(e),c)}function l(e){if(e===null)return!0;let n=i[e],a=-1;if(n)for(;++a<n.length;){let e=n[a];if(!e.previous||e.previous.call(r,r.previous))return!0}return!1}}}function UQ(e){return n;function n(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type===`data`&&(a=i,i++):(!n[i]||n[i][1].type!==`data`)&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function WQ(e,n){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=n.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(n._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):(e.splice(r,0,[`enter`,a,n],[`exit`,a,n]),r+=2)}r++}return e}var GQ=c({attentionMarkers:()=>$Q,contentInitial:()=>qQ,disable:()=>e$,document:()=>KQ,flow:()=>YQ,flowInitial:()=>JQ,insideSpan:()=>QQ,string:()=>XQ,text:()=>ZQ}),KQ={42:EQ,43:EQ,45:EQ,48:EQ,49:EQ,50:EQ,51:EQ,52:EQ,53:EQ,54:EQ,55:EQ,56:EQ,57:EQ,62:lZ},qQ={91:HZ},JQ={[-2]:xZ,[-1]:xZ,32:xZ},YQ={35:JZ,42:wQ,45:[PQ,wQ],60:$Z,61:PQ,95:wQ,96:vZ,126:vZ},XQ={38:hZ,92:pZ},ZQ={[-5]:SQ,[-4]:SQ,[-3]:SQ,33:vQ,38:hZ,42:tZ,60:[aZ,oQ],91:bQ,92:[KZ,pZ],93:cQ,95:tZ,96:TZ},QQ={null:[tZ,zQ]},$Q={null:[42,95]},e$={null:[]};function t$(e,n,r){let i={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0},a={},o=[],s=[],c=[],l={attempt:w(S),check:w(C),consume:y,enter:b,exit:x,interrupt:w(C,{interrupt:!0})},u={code:null,containerState:{},defineSkip:g,events:[],now:h,parser:e,previous:null,sliceSerialize:p,sliceStream:m,write:f},d=n.tokenize.call(u,l);return n.resolveAll&&o.push(n),u;function f(e){return s=TX(s,e),_(),s[s.length-1]===null?(T(n,0),u.events=eZ(o,u.events,u),u.events):[]}function p(e,n){return r$(m(e),n)}function m(e){return n$(s,e)}function h(){let{_bufferIndex:e,_index:n,line:r,column:a,offset:o}=i;return{_bufferIndex:e,_index:n,line:r,column:a,offset:o}}function g(e){a[e.line]=e.column,D()}function _(){let e;for(;i._index<s.length;){let n=s[i._index];if(typeof n==`string`)for(e=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===e&&i._bufferIndex<n.length;)v(n.charCodeAt(i._bufferIndex));else v(n)}}function v(e){d=d(e)}function y(e){zX(e)?(i.line++,i.column=1,i.offset+=e===-3?2:1,D()):e!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===s[i._index].length&&(i._bufferIndex=-1,i._index++)),u.previous=e}function b(e,n){let r=n||{};return r.type=e,r.start=h(),u.events.push([`enter`,r,u]),c.push(r),r}function x(e){let n=c.pop();return n.end=h(),u.events.push([`exit`,n,u]),n}function S(e,n){T(e,n.from)}function C(e,n){n.restore()}function w(e,n){return r;function r(r,i,a){let o,s,c,d;return Array.isArray(r)?p(r):`tokenize`in r?p([r]):f(r);function f(e){return n;function n(n){let r=n!==null&&e[n],i=n!==null&&e.null;return p([...Array.isArray(r)?r:r?[r]:[],...Array.isArray(i)?i:i?[i]:[]])(n)}}function p(e){return o=e,s=0,e.length===0?a:m(e[s])}function m(e){return r;function r(r){return d=E(),c=e,e.partial||(u.currentConstruct=e),e.name&&u.parser.constructs.disable.null.includes(e.name)?g(r):e.tokenize.call(n?Object.assign(Object.create(u),n):u,l,h,g)(r)}}function h(n){return e(c,d),i}function g(e){return d.restore(),++s<o.length?m(o[s]):a}}}function T(e,n){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&wX(u.events,n,u.events.length-n,e.resolve(u.events.slice(n),u)),e.resolveTo&&(u.events=e.resolveTo(u.events,u))}function E(){let e=h(),n=u.previous,r=u.currentConstruct,a=u.events.length,o=Array.from(c);return{from:a,restore:s};function s(){i=e,u.previous=n,u.currentConstruct=r,u.events.length=a,c=o,D()}}function D(){i.line in a&&i.column<2&&(i.column=a[i.line],i.offset+=a[i.line]-1)}}function n$(e,n){let r=n.start._index,i=n.start._bufferIndex,a=n.end._index,o=n.end._bufferIndex,s;if(r===a)s=[e[r].slice(i,o)];else{if(s=e.slice(r,a),i>-1){let e=s[0];typeof e==`string`?s[0]=e.slice(i):s.shift()}o>0&&s.push(e[a].slice(0,o))}return s}function r$(e,n){let r=-1,i=[],a;for(;++r<e.length;){let o=e[r],s;if(typeof o==`string`)s=o;else switch(o){case-5:s=`\r`;break;case-4:s=`
|
|
85
85
|
`;break;case-3:s=`\r
|
|
86
86
|
`;break;case-2:s=n?` `:` `;break;case-1:if(!n&&a)continue;s=` `;break;default:s=String.fromCharCode(o)}a=o===-2,i.push(s)}return i.join(``)}function i$(e){let n={constructs:DX([GQ,...(e||{}).extensions||[]]),content:r(qX),defined:[],document:r(YX),flow:r(LQ),lazy:{},string:r(BQ),text:r(VQ)};return n;function r(e){return r;function r(r){return t$(n,e,r)}}}function a$(e){for(;!jZ(e););return e}var o$=/[\0\t\n\r]/g;function s$(){let e=1,n=``,r=!0,i;return a;function a(a,o,s){let c=[],l,u,d,f,p;for(a=n+(typeof a==`string`?a.toString():new TextDecoder(o||void 0).decode(a)),d=0,n=``,r&&=(a.charCodeAt(0)===65279&&d++,void 0);d<a.length;){if(o$.lastIndex=d,l=o$.exec(a),f=l&&l.index!==void 0?l.index:a.length,p=a.charCodeAt(f),!l){n=a.slice(d);break}if(p===10&&d===f&&i)c.push(-3),i=void 0;else switch(i&&=(c.push(-5),void 0),d<f&&(c.push(a.slice(d,f)),e+=f-d),p){case 0:c.push(65533),e++;break;case 9:for(u=Math.ceil(e/4)*4,c.push(-2);e++<u;)c.push(-1);break;case 10:c.push(-4),e=1;break;default:i=!0,e=1}d=f+1}return s&&(i&&c.push(-5),n&&c.push(n),c.push(null)),c}}var c$=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function l$(e){return e.replace(c$,u$)}function u$(e,n,r){if(n)return n;if(r.charCodeAt(0)===35){let e=r.charCodeAt(1),n=e===120||e===88;return AX(r.slice(n?2:1),n?16:10)}return CX(r)||e}var d$={}.hasOwnProperty;function f$(e,n,r){return n&&typeof n==`object`&&(r=n,n=void 0),p$(r)(a$(i$(r).document().write(s$()(e,n,!0))))}function p$(e){let n={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:o(de),autolinkProtocol:E,autolinkEmail:E,atxHeading:o(se),blockQuote:o(ne),characterEscape:E,characterReference:E,codeFenced:o(re),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(re,s),codeText:o(ie,s),codeTextData:E,data:E,codeFlowValue:E,definition:o(ae),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(oe),hardBreakEscape:o(ce),hardBreakTrailing:o(ce),htmlFlow:o(le,s),htmlFlowData:E,htmlText:o(le,s),htmlTextData:E,image:o(ue),label:s,link:o(de),listItem:o(pe),listItemValue:p,listOrdered:o(fe,f),listUnordered:o(fe),paragraph:o(me),reference:ee,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(se),strong:o(he),thematicBreak:o(_e)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:W,autolinkProtocol:te,blockQuote:l(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:V,characterReferenceMarkerNumeric:V,characterReferenceValue:H,characterReference:U,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:D,codeIndented:l(v),codeText:l(M),codeTextData:D,data:D,definition:l(),definitionDestinationString:x,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(k),hardBreakTrailing:l(k),htmlFlow:l(A),htmlFlowData:D,htmlText:l(j),htmlTextData:D,image:l(P),label:I,labelText:F,lineEnding:O,link:l(N),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:B,resourceDestinationString:L,resourceTitleString:R,resource:z,setextHeading:l(T),setextHeadingLineSequence:w,setextHeadingText:C,strong:l(),thematicBreak:l()}};h$(n,(e||{}).mdastExtensions||[]);let r={};return i;function i(e){let i={type:`root`,children:[]},o={stack:[i],tokenStack:[],config:n,enter:c,exit:u,buffer:s,resume:d,data:r},l=[],f=-1;for(;++f<e.length;)(e[f][1].type===`listOrdered`||e[f][1].type===`listUnordered`)&&(e[f][0]===`enter`?l.push(f):f=a(e,l.pop(),f));for(f=-1;++f<e.length;){let r=n[e[f][0]];d$.call(r,e[f][1].type)&&r[e[f][1].type].call(Object.assign({sliceSerialize:e[f][2].sliceSerialize},o),e[f][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||_$).call(o,void 0,e[0])}for(i.position={start:m$(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:m$(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},f=-1;++f<n.transforms.length;)i=n.transforms[f](i)||i;return i}function a(e,n,r){let i=n-1,a=-1,o=!1,s,c,l,u;for(;++i<=r;){let n=e[i];switch(n[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:n[0]===`enter`?a++:a--,u=void 0;break;case`lineEndingBlank`:n[0]===`enter`&&(s&&!u&&!a&&!l&&(l=i),u=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:u=void 0}if(!a&&n[0]===`enter`&&n[1].type===`listItemPrefix`||a===-1&&n[0]===`exit`&&(n[1].type===`listUnordered`||n[1].type===`listOrdered`)){if(s){let a=i;for(c=void 0;a--;){let n=e[a];if(n[1].type===`lineEnding`||n[1].type===`lineEndingBlank`){if(n[0]===`exit`)continue;c&&(e[c][1].type=`lineEndingBlank`,o=!0),n[1].type=`lineEnding`,c=a}else if(!(n[1].type===`linePrefix`||n[1].type===`blockQuotePrefix`||n[1].type===`blockQuotePrefixWhitespace`||n[1].type===`blockQuoteMarker`||n[1].type===`listItemIndent`))break}l&&(!c||l<c)&&(s._spread=!0),s.end=Object.assign({},c?e[c][1].start:n[1].end),e.splice(c||i,0,[`exit`,s,n[2]]),i++,r++}if(n[1].type===`listItemPrefix`){let a={type:`listItem`,_spread:!1,start:Object.assign({},n[1].start),end:void 0};s=a,e.splice(i,0,[`enter`,a,n[2]]),i++,r++,l=void 0,u=!0}}}return e[n][1]._spread=o,r}function o(e,n){return r;function r(r){c.call(this,e(r),r),n&&n.call(this,r)}}function s(){this.stack.push({type:`fragment`,children:[]})}function c(e,n,r){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([n,r||void 0]),e.position={start:m$(n.start),end:void 0}}function l(e){return n;function n(n){e&&e.call(this,n),u.call(this,n)}}function u(e,n){let r=this.stack.pop(),i=this.tokenStack.pop();if(i)i[0].type!==e.type&&(n?n.call(this,e,i[0]):(i[1]||_$).call(this,e,i[0]));else throw Error("Cannot close `"+e.type+"` ("+IY({start:e.start,end:e.end})+`): it’s not open`);r.position.end=m$(e.end)}function d(){return vX(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(e){if(this.data.expectingFirstListItemValue){let n=this.stack[this.stack.length-2];n.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function m(){let e=this.resume(),n=this.stack[this.stack.length-1];n.lang=e}function h(){let e=this.resume(),n=this.stack[this.stack.length-1];n.meta=e}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let e=this.resume(),n=this.stack[this.stack.length-1];n.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function v(){let e=this.resume(),n=this.stack[this.stack.length-1];n.value=e.replace(/(\r?\n|\r)$/g,``)}function y(e){let n=this.resume(),r=this.stack[this.stack.length-1];r.label=n,r.identifier=jX(this.sliceSerialize(e)).toLowerCase()}function b(){let e=this.resume(),n=this.stack[this.stack.length-1];n.title=e}function x(){let e=this.resume(),n=this.stack[this.stack.length-1];n.url=e}function S(e){let n=this.stack[this.stack.length-1];n.depth||=this.sliceSerialize(e).length}function C(){this.data.setextHeadingSlurpLineEnding=!0}function w(e){let n=this.stack[this.stack.length-1];n.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function E(e){let n=this.stack[this.stack.length-1].children,r=n[n.length-1];(!r||r.type!==`text`)&&(r=ge(),r.position={start:m$(e.start),end:void 0},n.push(r)),this.stack.push(r)}function D(e){let n=this.stack.pop();n.value+=this.sliceSerialize(e),n.position.end=m$(e.end)}function O(e){let r=this.stack[this.stack.length-1];if(this.data.atHardBreak){let n=r.children[r.children.length-1];n.position.end=m$(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(r.type)&&(E.call(this,e),D.call(this,e))}function k(){this.data.atHardBreak=!0}function A(){let e=this.resume(),n=this.stack[this.stack.length-1];n.value=e}function j(){let e=this.resume(),n=this.stack[this.stack.length-1];n.value=e}function M(){let e=this.resume(),n=this.stack[this.stack.length-1];n.value=e}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let n=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=n,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let n=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=n,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function F(e){let n=this.sliceSerialize(e),r=this.stack[this.stack.length-2];r.label=l$(n),r.identifier=jX(n).toLowerCase()}function I(){let e=this.stack[this.stack.length-1],n=this.resume(),r=this.stack[this.stack.length-1];this.data.inReference=!0,r.type===`link`?r.children=e.children:r.alt=n}function L(){let e=this.resume(),n=this.stack[this.stack.length-1];n.url=e}function R(){let e=this.resume(),n=this.stack[this.stack.length-1];n.title=e}function z(){this.data.inReference=void 0}function ee(){this.data.referenceType=`collapsed`}function B(e){let n=this.resume(),r=this.stack[this.stack.length-1];r.label=n,r.identifier=jX(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function V(e){this.data.characterReferenceType=e.type}function H(e){let n=this.sliceSerialize(e),r=this.data.characterReferenceType,i;r?(i=AX(n,r===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):i=CX(n);let a=this.stack[this.stack.length-1];a.value+=i}function U(e){let n=this.stack.pop();n.position.end=m$(e.end)}function te(e){D.call(this,e);let n=this.stack[this.stack.length-1];n.url=this.sliceSerialize(e)}function W(e){D.call(this,e);let n=this.stack[this.stack.length-1];n.url=`mailto:`+this.sliceSerialize(e)}function ne(){return{type:`blockquote`,children:[]}}function re(){return{type:`code`,lang:null,meta:null,value:``}}function ie(){return{type:`inlineCode`,value:``}}function ae(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function oe(){return{type:`emphasis`,children:[]}}function se(){return{type:`heading`,depth:0,children:[]}}function ce(){return{type:`break`}}function le(){return{type:`html`,value:``}}function ue(){return{type:`image`,title:null,url:``,alt:null}}function de(){return{type:`link`,title:null,url:``,children:[]}}function fe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function pe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function me(){return{type:`paragraph`,children:[]}}function he(){return{type:`strong`,children:[]}}function ge(){return{type:`text`,value:``}}function _e(){return{type:`thematicBreak`}}}function m$(e){return{line:e.line,column:e.column,offset:e.offset}}function h$(e,n){let r=-1;for(;++r<n.length;){let i=n[r];Array.isArray(i)?h$(e,i):g$(e,i)}}function g$(e,n){let r;for(r in n)if(d$.call(n,r))switch(r){case`canContainEols`:{let i=n[r];i&&e[r].push(...i);break}case`transforms`:{let i=n[r];i&&e[r].push(...i);break}case`enter`:case`exit`:{let i=n[r];i&&Object.assign(e[r],i);break}}}function _$(e,n){throw Error(e?"Cannot close `"+e.type+"` ("+IY({start:e.start,end:e.end})+"): a different token (`"+n.type+"`, "+IY({start:n.start,end:n.end})+`) is open`:"Cannot close document, a token (`"+n.type+"`, "+IY({start:n.start,end:n.end})+`) is still open`)}function v$(e){let n=this;n.parser=r;function r(r){return f$(r,{...n.data(`settings`),...e,extensions:n.data(`micromarkExtensions`)||[],mdastExtensions:n.data(`fromMarkdownExtensions`)||[]})}}function y$(e,n){let r={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(n),!0)};return e.patch(n,r),e.applyData(n,r)}function b$(e,n){let r={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(n,r),[e.applyData(n,r),{type:`text`,value:`
|
|
@@ -161,4 +161,4 @@ $1`).replace(/(\s-\s)/g,`
|
|
|
161
161
|
`)?e:e.replace(/(#{1,3}\s+[^#])/g,`
|
|
162
162
|
$1`).replace(/(\d+\.\s+[^\d])/g,`
|
|
163
163
|
$1`).replace(/(\s-\s)/g,`
|
|
164
|
-
- `).trim()}function Tme(e){return new Date(e).toLocaleString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Eme(e){return e?e.length<=16?e:e.slice(0,8)+`...`+e.slice(-8):`—`}function Dme(e,n=80){return e?e.length<=n?e:e.slice(0,n)+`...`:`—`}function Ome({type:e}){return e===`auto`?(0,G.jsxs)(CJ,{variant:`secondary`,className:`text-xs bg-blue-100 text-blue-700 hover:bg-blue-100 border-blue-200`,children:[(0,G.jsx)(eh,{className:`size-3 mr-1`}),`自动注入`]}):(0,G.jsxs)(CJ,{variant:`outline`,className:`text-xs bg-emerald-50 text-emerald-700 hover:bg-emerald-50 border-emerald-200`,children:[(0,G.jsx)(jm,{className:`size-3 mr-1`}),`手动注入`]})}function kme({category:e}){return(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs font-normal ${AJ(e)}`,children:e||`未分类`})}function k9({label:e,value:n,max:r=1}){let i=Math.max(0,Math.min(n,r))/r*100;return(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,G.jsx)(`span`,{className:`font-medium`,children:n===0?`—`:`${i.toFixed(1)}%`})]}),(0,G.jsx)(`div`,{className:`h-1.5 w-full rounded-full bg-muted overflow-hidden`,children:(0,G.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-all`,style:{width:`${i}%`}})})]})}function Ame({relevance:e,isKept:n}){return n?e?e===`high`?(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs bg-emerald-500/10 text-emerald-600 border-emerald-500/30`,children:`🟢 高相关`}):e===`medium`?(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs bg-yellow-500/10 text-yellow-600 border-yellow-500/30`,children:`🟡 中相关`}):(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs bg-muted text-muted-foreground border-border`,children:e||`—`}):(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs bg-blue-500/10 text-blue-600 border-blue-500/30`,children:`🔵 保留`}):(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs bg-red-500/10 text-red-600 border-red-500/30`,children:`🔴 被精炼掉`})}function jme({item:e,memory:n,memoryLoading:r,vaultUnlocked:i,memoryUnlocked:a,onUnlock:o,onLock:s,onVaultUnlock:c}){let l=!!e.refine_relevance,[u,d]=(0,y.useState)(`raw`),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(``),[g,_]=(0,y.useState)(null),v=ob(e=>e.unlock),b=ob(e=>e.isUnlocked),x=n?.visibility===`private`||(n?.tags||[]).some(e=>e===`私密`||e.toLowerCase()===`private`),S=x&&!a,C=async()=>{n&&(S?i||b?o?.(n.id):p(!0):(s?.(n.id),p(!1)))},w=async()=>{if(!m.trim()){_(`请输入密码`);return}await v(m)?(p(!1),h(``),_(null),c?.(),n&&o?.(n.id)):_(`密码错误`)};return(0,G.jsxs)(`div`,{className:`rounded-md border bg-muted/50 p-3 space-y-3 ${e.is_kept?`border-border`:`border-dashed border-red-500/30 opacity-75`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,G.jsx)(Ame,{relevance:e.refine_relevance,isKept:e.is_kept}),(0,G.jsx)(kme,{category:n?.category}),x&&(0,G.jsxs)(CJ,{variant:`secondary`,className:`text-xs bg-amber-100 text-amber-700 hover:bg-amber-100 border-amber-200`,children:[(0,G.jsx)(Em,{className:`size-3 mr-1`}),`私密`]}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:[e.memory_id?.slice(0,8),`...`]})]}),x&&(0,G.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),C()},className:`text-xs text-amber-500 hover:text-amber-600 flex items-center gap-1 shrink-0`,children:[S?(0,G.jsx)(Em,{className:`size-3`}):(0,G.jsx)(Tm,{className:`size-3`}),S?`解锁`:`锁定`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border pb-1`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>l&&d(`refine`),className:`text-xs px-2 py-1 rounded transition-colors ${l?u===`refine`?`bg-primary/10 text-primary font-medium`:`text-muted-foreground hover:text-foreground`:`text-muted-foreground/40 cursor-not-allowed`}`,children:`精炼`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>d(`raw`),className:`text-xs px-2 py-1 rounded transition-colors ${u===`raw`?`bg-primary/10 text-primary font-medium`:`text-muted-foreground hover:text-foreground`}`,children:`原始`})]}),u===`refine`?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[e.refine_reasoning?(0,G.jsxs)(`div`,{className:`text-sm text-foreground`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`推理说明:`}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:e.refine_reasoning})]}):(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground italic`,children:`未经精炼 · 自动保留`}),(0,G.jsx)(k9,{label:`相似度得分`,value:e.score,max:1})]}):(0,G.jsx)(`div`,{className:`space-y-2`,children:r?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(Cb,{className:`h-4 w-3/4`}),(0,G.jsx)(Cb,{className:`h-4 w-1/2`})]}):n?(0,G.jsx)(G.Fragment,{children:S?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,G.jsx)(Em,{className:`size-4`}),(0,G.jsx)(`span`,{children:`私密记忆内容已隐藏`})]}),f&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(hb,{type:`password`,placeholder:`输入 Vault 密码...`,value:m,onChange:e=>{h(e.target.value),_(null)},onKeyDown:e=>e.key===`Enter`&&w(),className:g?`border-destructive flex-1`:`flex-1`}),(0,G.jsx)(q,{size:`sm`,onClick:w,children:`解锁`})]}),g&&(0,G.jsx)(`p`,{className:`text-xs text-destructive`,children:g})]})]}):(0,G.jsx)(`div`,{className:`prose prose-sm dark:prose-invert max-w-none`,children:(0,G.jsx)(b0,{remarkPlugins:[d3],children:wme(n.content||n.l0_abstract||`—`)})})}):(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`记忆内容加载失败`})})]})}function Mme({event:e,initialItems:n,isLast:r,defaultExpanded:i,vaultUnlocked:a,unlockedMemories:o,manuallyLocked:s,onUnlock:c,onLock:l,onVaultUnlock:u}){let[d,f]=(0,y.useState)(i||!1),[p,m]=(0,y.useState)(!0),[h,g]=(0,y.useState)(n??null),[_,v]=(0,y.useState)(new Map),[b,x]=(0,y.useState)(new Set);(0,y.useEffect)(()=>{n&&h===null&&g(n)},[n,h]);let S=(0,y.useCallback)(async e=>{try{x(n=>new Set(n).add(e));let n=await ib.get(`/v1/memories/${e}`);v(r=>{let i=new Map(r);return i.set(e,n),i})}catch(e){console.error(`Failed to fetch memory:`,e)}finally{x(n=>{let r=new Set(n);return r.delete(e),r})}},[]),C=(0,y.useRef)(new Set);(0,y.useEffect)(()=>{!d||!h||h.length===0||h.forEach(e=>{C.current.has(e.memory_id)||(C.current.add(e.memory_id),S(e.memory_id))})},[d,h,S]);let w=e=>a&&!s.has(e)||o.has(e);return(0,G.jsxs)(`div`,{className:`flex gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,G.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full bg-primary ring-4 ring-primary/20`}),!r&&(0,G.jsx)(`div`,{className:`w-px flex-1 bg-border mt-1`})]}),(0,G.jsx)(`div`,{className:`flex-1 pb-6`,children:(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card transition-colors hover:bg-muted/50`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>f(!d),className:`w-full text-left p-4 cursor-pointer`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,G.jsx)(Ome,{type:e.recall_type}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,G.jsx)(nm,{className:`size-3`}),Tme(e.created_at)]})]}),d?(0,G.jsx)(em,{className:`size-4 text-muted-foreground`}):(0,G.jsx)(Zp,{className:`size-4 text-muted-foreground`})]}),(0,G.jsxs)(`div`,{className:`mt-2 text-sm text-muted-foreground flex items-center gap-1.5`,children:[(0,G.jsx)(Lm,{className:`size-3.5`}),(0,G.jsx)(`span`,{className:`line-clamp-1`,title:e.query_text||`—`,children:Dme(e.query_text)})]})]}),d&&(0,G.jsxs)(`div`,{className:`px-4 pb-4 space-y-4 border-t border-border pt-4`,children:[e.profile_content&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground flex items-center gap-1`,children:[(0,G.jsx)(Kp,{className:`size-3`}),`画像注入内容`]}),(0,G.jsx)(`div`,{className:`rounded-md border border-indigo-500/20 bg-indigo-500/5 p-3`,children:(0,G.jsx)(`div`,{className:`prose prose-sm dark:prose-invert max-w-none text-sm text-indigo-700 dark:text-indigo-300`,children:(0,G.jsx)(b0,{remarkPlugins:[d3],children:e.profile_content.replace(/<\/?cerebro-profile>/g,``).trim()})})})]}),e.injected_content&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>m(!p),className:`flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,children:[(0,G.jsx)(tee,{className:`size-3`}),`注入内容`,p?(0,G.jsx)(em,{className:`size-3`}):(0,G.jsx)(Zp,{className:`size-3`})]}),p&&(0,G.jsx)(`div`,{className:`rounded-md border border-emerald-500/20 bg-emerald-500/5 p-3 max-h-96 overflow-y-auto`,children:(0,G.jsx)(`div`,{className:`prose prose-sm dark:prose-invert max-w-none text-sm text-emerald-700 dark:text-emerald-300`,children:(0,G.jsx)(b0,{remarkPlugins:[d3],children:e.injected_content.replace(/<\/?cerebro-context>/g,``).trim()})})})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,G.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground flex items-center gap-1`,children:[(0,G.jsx)(Kp,{className:`size-3`}),`关联记忆`]})}),h&&h.length>0?(0,G.jsx)(`div`,{className:`space-y-3`,children:h.map(e=>(0,G.jsx)(jme,{item:e,memory:_.get(e.memory_id)||null,memoryLoading:b.has(e.memory_id),vaultUnlocked:a,memoryUnlocked:w(e.memory_id),onUnlock:c,onLock:l,onVaultUnlock:u},e.id))}):(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`暂无召回项`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground flex items-center gap-1`,children:[(0,G.jsx)(Yp,{className:`size-3`}),`匹配指标`]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,G.jsx)(k9,{label:`最大相似度`,value:e.max_score}),(0,G.jsx)(k9,{label:`LLM 置信度`,value:e.llm_confidence})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`统计:`}),(0,G.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[`保留 `,e.kept_count,` 条`]}),e.discarded_count>0&&(0,G.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`精炼掉 `,e.discarded_count,` 条`]}),e.injected_count!=null&&e.injected_count>0&&(0,G.jsxs)(`span`,{className:`text-blue-600 dark:text-blue-400`,children:[`实际注入 `,e.injected_count,` 条`]}),e.profile_injected&&(0,G.jsx)(`span`,{className:`text-indigo-600 dark:text-indigo-400`,children:`👤 画像已注入`})]})]})]})})]})}function Nme(){let{id:e}=it(),n=et(),r=Ze(),i=()=>{let e=r.state;e?.from?n(e.from,{replace:!0}):n(-1)},a=e?decodeURIComponent(e):``,[o,s]=(0,y.useState)([]),[c,l]=(0,y.useState)(new Map),[u,d]=(0,y.useState)(!0),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(1),[g,_]=(0,y.useState)(!1),[v,b]=(0,y.useState)(!1),[x,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(null),T=ob(e=>e.unlock),E=ob(e=>e.lock),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(new Set),[j,M]=(0,y.useState)(new Set),[N,P]=(0,y.useState)(null),F=Math.ceil(o.length/10),I=o.slice((m-1)*10,m*10);(0,y.useEffect)(()=>{if(!a)return;async function e(){try{d(!0),p(null);let e=await ib.get(`/v1/recall-events`,{params:{session_id:a,limit:1e4,offset:0,expand:`items`}});if(s((e?.events||[]).sort((e,n)=>new Date(n.created_at).getTime()-new Date(e.created_at).getTime())),e?.event_items){let n=new Map;e.event_items.forEach(e=>n.set(e.id,e.items||[])),l(n)}}catch(e){console.error(`Failed to fetch session detail:`,e),p(`加载 Session 详情失败`),ir.error(`加载 Session 详情失败`)}finally{d(!1)}}e()},[a]);let L=()=>{_(!0)},R=async()=>{try{await ib.delete(`/v1/session-recalls/session/${a}`),ir.success(`Session 记录已删除`),n(-1)}catch(e){console.error(`Failed to delete session records:`,e),ir.error(`删除失败`)}finally{_(!1)}},z=async()=>{if(!x.trim()){w(`请输入密码`);return}if(!await T(x)){w(`密码错误`);return}O(!0),N&&(A(e=>new Set(e).add(N)),P(null)),w(null),b(!1),S(``)},ee=()=>{O(!1),A(new Set),M(new Set),E()},B=e=>{k.has(e)||D&&!j.has(e)?(M(n=>new Set(n).add(e)),A(n=>{let r=new Set(n);return r.delete(e),r})):D?M(n=>{let r=new Set(n);return r.delete(e),r}):(P(e),b(!0))},V={total:o.length,auto:o.filter(e=>e.recall_type===`auto`).length,manual:o.filter(e=>e.recall_type===`manual`).length,totalKept:o.reduce((e,n)=>e+n.kept_count,0),totalDiscarded:o.reduce((e,n)=>e+n.discarded_count,0)};return u?(0,G.jsxs)(`div`,{className:`space-y-6 max-w-3xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Cb,{className:`h-8 w-8`}),(0,G.jsx)(Cb,{className:`h-6 w-32`})]}),(0,G.jsx)(Cb,{className:`h-4 w-1/2`}),(0,G.jsx)(`div`,{className:`space-y-4`,children:[1,2,3].map(e=>(0,G.jsxs)(`div`,{className:`flex gap-4`,children:[(0,G.jsx)(Cb,{className:`h-3 w-3 rounded-full`}),(0,G.jsx)(`div`,{className:`flex-1 space-y-2`,children:(0,G.jsx)(Cb,{className:`h-20 w-full`})})]},e))})]}):f?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>i(),children:[(0,G.jsx)(Vp,{className:`size-4 mr-1.5`}),`返回`]}),(0,G.jsx)(`div`,{className:`rounded-lg border border-destructive/50 bg-destructive/10 p-6 text-sm text-destructive`,children:f})]}):(0,G.jsxs)(`div`,{className:`space-y-6 max-w-3xl`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>i(),children:[(0,G.jsx)(Vp,{className:`size-4 mr-1.5`}),`返回`]})})}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:[`Session 详情 - `,Eme(a)]}),(0,G.jsx)(`div`,{className:`flex items-center gap-3 text-sm text-muted-foreground flex-wrap`,children:(0,G.jsx)(`code`,{className:`font-mono text-xs bg-muted px-1.5 py-0.5 rounded`,children:a})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,G.jsx)(vb,{children:(0,G.jsxs)(Sb,{className:`pt-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-semibold`,children:V.total}),(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`总召回事件`})]})}),(0,G.jsx)(vb,{children:(0,G.jsxs)(Sb,{className:`pt-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-semibold`,children:V.auto}),(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`自动注入`})]})}),(0,G.jsx)(vb,{children:(0,G.jsxs)(Sb,{className:`pt-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-semibold`,children:V.manual}),(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`手动注入`})]})})]}),V.totalKept>0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[(0,G.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400 font-medium`,children:[`共保留 `,V.totalKept,` 条记忆`]}),V.totalDiscarded>0&&(0,G.jsxs)(`span`,{className:`text-red-600 dark:text-red-400 font-medium`,children:[`共精炼掉 `,V.totalDiscarded,` 条记忆`]})]}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground`,children:`召回事件时间线`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`共 `,o.length,` 个事件`]}),F>1&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>h(e=>Math.max(1,e-1)),disabled:m===1,children:(0,G.jsx)(Qp,{className:`size-3`})}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground min-w-[3ch] text-center`,children:[m,`/`,F]}),(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>h(e=>Math.min(F,e+1)),disabled:m===F,children:(0,G.jsx)($p,{className:`size-3`})})]}),D?(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:ee,children:[(0,G.jsx)(Em,{className:`size-3.5 mr-1`}),`锁定 Vault`]}):(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>b(!v),children:[(0,G.jsx)(Tm,{className:`size-3.5 mr-1`}),`解锁 Vault`]})]})]}),v&&(0,G.jsxs)(`div`,{className:`space-y-2 max-w-md`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(hb,{type:`password`,placeholder:`输入 Vault 密码...`,value:x,onChange:e=>{S(e.target.value),w(null)},onKeyDown:e=>e.key===`Enter`&&z(),className:C?`border-destructive flex-1`:`flex-1`}),(0,G.jsx)(q,{size:`sm`,onClick:z,children:`解锁`})]}),C&&(0,G.jsx)(`p`,{className:`text-xs text-destructive`,children:C})]}),o.length===0?(0,G.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-8 text-center text-sm text-muted-foreground`,children:`暂无召回事件`}):(0,G.jsxs)(G.Fragment,{children:[I.map((e,n)=>(0,G.jsx)(Mme,{event:e,initialItems:c.get(e.id),isLast:n===I.length-1&&m===F,defaultExpanded:n===0&&m===1,vaultUnlocked:D,unlockedMemories:k,manuallyLocked:j,onUnlock:B,onLock:B,onVaultUnlock:()=>O(!0)},e.id)),F>1&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pt-4`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`共 `,o.length,` 个事件`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>h(e=>Math.max(1,e-1)),disabled:m===1,children:(0,G.jsx)(Qp,{className:`size-4`})}),(0,G.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[m,` / `,F]}),(0,G.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>h(e=>Math.min(F,e+1)),disabled:m===F,children:(0,G.jsx)($p,{className:`size-4`})})]})]})]})]}),o.length>0&&(0,G.jsx)(`div`,{className:`pt-4 border-t border-border`,children:(0,G.jsxs)(q,{variant:`outline`,size:`sm`,className:`text-destructive hover:bg-destructive/10 hover:text-destructive`,onClick:L,children:[(0,G.jsx)(Km,{className:`size-3.5 mr-1`}),`删除 Session 所有记录`]})}),(0,G.jsx)(pJ,{open:g,onOpenChange:e=>!e&&_(!1),children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除 Session 记录`}),(0,G.jsx)(vJ,{children:`此操作将删除该 Session 的所有召回记录,不可撤销。确定要继续吗?`})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{onClick:()=>_(!1),children:`取消`}),(0,G.jsx)(yJ,{onClick:R,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`删除`})]})]})})]})}function A9({...e}){return(0,G.jsx)(hg,{"data-slot":`dialog`,...e})}function Pme({...e}){return(0,G.jsx)(_g,{"data-slot":`dialog-trigger`,...e})}function Fme({...e}){return(0,G.jsx)(Zh,{"data-slot":`dialog-portal`,...e})}function Ime({className:e,...n}){return(0,G.jsx)(Eh,{"data-slot":`dialog-overlay`,className:Tp(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...n})}function j9({className:e,children:n,showCloseButton:r=!0,...i}){return(0,G.jsxs)(Fme,{children:[(0,G.jsx)(Ime,{}),(0,G.jsxs)(Yh,{"data-slot":`dialog-content`,className:Tp(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...i,children:[n,r&&(0,G.jsxs)(Dh,{"data-slot":`dialog-close`,render:(0,G.jsx)(q,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,G.jsx)($m,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function M9({className:e,...n}){return(0,G.jsx)(`div`,{"data-slot":`dialog-header`,className:Tp(`flex flex-col gap-2`,e),...n})}function N9({className:e,showCloseButton:n=!1,children:r,...i}){return(0,G.jsxs)(`div`,{"data-slot":`dialog-footer`,className:Tp(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...i,children:[r,n&&(0,G.jsx)(Dh,{render:(0,G.jsx)(q,{variant:`outline`}),children:`Close`})]})}function P9({className:e,...n}){return(0,G.jsx)(gg,{"data-slot":`dialog-title`,className:Tp(`text-base leading-none font-medium`,e),...n})}function F9({className:e,...n}){return(0,G.jsx)(Oh,{"data-slot":`dialog-description`,className:Tp(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...n})}function Lme(){let[e,n]=(0,y.useState)([]),[r,i]=(0,y.useState)(!0),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(`team`),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(`member`),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)({}),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(`member`),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(!1),R=dh(e=>e.currentUserId),z=dh(e=>e.users.find(e=>e.id===R)),ee=e.find(e=>e.id===p),B=e=>z?e.owner_id===z.apiKey||e.members.some(e=>e.user_id===z.apiKey&&(e.role===`admin`||e.role===`Admin`)):!1;(0,y.useEffect)(()=>{async function e(){if(!ee?.members?.length)return;T(!0);let e={};await Promise.all(ee.members.map(async n=>{try{let r=await ib.get(`/v1/tenants/${encodeURIComponent(n.user_id)}`);r&&(e[n.user_id]={name:r.name,created_at:r.created_at})}catch{}})),C(e),T(!1)}p&&e()},[p,ee?.members]),(0,y.useEffect)(()=>{async function e(){try{i(!0),n(await ib.get(`/v1/spaces`)||[])}catch(e){console.error(`Failed to fetch spaces:`,e),ir.error(`加载空间列表失败`)}finally{i(!1)}}e()},[]);async function V(){if(!s.trim()){ir.error(`请输入空间名称`);return}try{await ib.post(`/v1/spaces`,{name:s.trim(),space_type:l}),ir.success(`空间创建成功`),o(!1),c(``),n(await ib.get(`/v1/spaces`)||[])}catch(e){console.error(`Failed to create space:`,e),ir.error(`空间创建失败`)}}async function H(){if(!d)return;let r=e.find(e=>e.id===d)?.members.map(e=>e.user_id).filter(e=>e!==z?.apiKey)||[];try{await ib.delete(`/v1/spaces/${encodeURIComponent(d)}`),ir.success(`空间已删除`),n(e=>e.filter(e=>e.id!==d)),dh.getState().removeUsersByApiKeys(r)}catch(e){console.error(`Failed to delete space:`,e),ir.error(`空间删除失败`)}finally{f(null)}}async function U(){if(p){N(!0);try{let e=await ib.post(`/v1/tenants`,{name:O.trim()||void 0}),r=e.id,i=e.api_key;await ib.post(`/v1/spaces/${encodeURIComponent(p)}/members`,{user_id:r,role:A}),F(i),ir.success(`新用户创建并加入空间成功`),n(await ib.get(`/v1/spaces`)||[])}catch(e){console.error(`Failed to create user:`,e);let n=e.response?.data?.error||e.message||``;ir.error(`创建用户失败:${n||`请稍后重试`}`)}finally{N(!1)}}}async function te(e){if(p)try{await ib.delete(`/v1/spaces/${encodeURIComponent(p)}/members/${encodeURIComponent(e)}`),ir.success(`成员已移除`),n(await ib.get(`/v1/spaces`)||[])}catch(e){console.error(`Failed to remove member:`,e);let n=e.response?.data?.error||e.message||``;ir.error(`移除成员失败:${n||`请稍后重试`}`)}}async function W(){if(!p||!h.trim()){ir.error(`请输入用户ID`);return}let e=h.trim();if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)){ir.error(`用户ID格式不正确,请输入有效的 UUID(如:c60beb98-7aab-4985-8c1d-29ffd6aff75a)`);return}x(!0);try{await ib.post(`/v1/spaces/${encodeURIComponent(p)}/members`,{user_id:e,role:_}),ir.success(`成员添加成功`),g(``),n(await ib.get(`/v1/spaces`)||[])}catch(e){console.error(`Failed to add member:`,e);let n=e.response?.data?.error||e.message||``;n.includes(`not found`)||n.includes(`不存在`)?ir.error(`该用户不存在,请确认用户ID正确`):n.includes(`permission`)||n.includes(`权限`)?ir.error(`您没有权限添加成员`):ir.error(`添加成员失败:${n||`请检查用户ID是否正确`}`)}finally{x(!1)}}return r?(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`空间管理`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`管理您的记忆空间`})]}),(0,G.jsx)(Cb,{className:`h-9 w-24`})]}),(0,G.jsx)(`div`,{className:`grid gap-4`,children:[1,2].map(e=>(0,G.jsx)(Cb,{className:`h-32 w-full`},e))})]}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`空间管理`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`管理您的记忆空间`})]}),(0,G.jsxs)(A9,{open:a,onOpenChange:o,children:[(0,G.jsx)(Pme,{render:(0,G.jsxs)(q,{size:`sm`,children:[(0,G.jsx)(Nm,{className:`size-4 mr-1.5`}),`新建空间`]})}),(0,G.jsxs)(j9,{children:[(0,G.jsx)(M9,{children:(0,G.jsx)(P9,{children:`新建空间`})}),(0,G.jsxs)(`div`,{className:`space-y-4 pt-2`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`空间名称`}),(0,G.jsx)(hb,{placeholder:`输入空间名称`,value:s,onChange:e=>c(e.target.value)})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`空间类型`}),(0,G.jsxs)(_9,{value:l,onValueChange:e=>u(e||`team`),children:[(0,G.jsx)(y9,{children:(0,G.jsx)(v9,{})}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`team`,children:`团队`}),(0,G.jsx)(x9,{value:`personal`,children:`个人`}),(0,G.jsx)(x9,{value:`shared`,children:`共享`})]})]})]}),(0,G.jsx)(q,{className:`w-full`,onClick:V,children:`创建`})]})]})]})]}),e.length===0?(0,G.jsxs)(`div`,{className:`text-center py-12 text-muted-foreground border border-dashed border-border rounded-lg`,children:[(0,G.jsx)(`p`,{children:`暂无空间`}),(0,G.jsx)(`p`,{className:`text-sm mt-1`,children:`点击右上角按钮创建新空间`})]}):(0,G.jsx)(`div`,{className:`grid gap-4`,children:e.map(e=>(0,G.jsxs)(vb,{className:`group transition-colors hover:bg-accent/50`,children:[(0,G.jsx)(yb,{className:`pb-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.name}),(0,G.jsx)(CJ,{variant:`outline`,children:e.space_type})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,G.jsx)(zm,{className:`size-3`}),e.members.length,` 成员`]}),(0,G.jsxs)(q,{variant:`ghost`,size:`sm`,className:`h-7 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>{m(e.id),g(``),v(`member`)},children:[(0,G.jsx)(Xm,{className:`size-3.5 mr-1`}),`管理成员`]}),e.space_type!==`personal`&&B(e)&&(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>f(e.id),children:(0,G.jsx)(Km,{className:`size-3.5 text-destructive`})})]})]})}),(0,G.jsxs)(Sb,{className:`pt-0 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4 text-sm text-muted-foreground flex-wrap`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(Qm,{className:`size-3.5`}),e.members.map(e=>e.role).join(`, `)]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(Jp,{className:`size-3.5`}),new Date(e.created_at).toLocaleDateString(`zh-CN`)]})]}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground font-mono`,children:[`ID: `,e.id]})]})]},e.id))}),(0,G.jsx)(pJ,{open:!!d,onOpenChange:e=>!e&&f(null),children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除空间`}),(0,G.jsx)(vJ,{children:`此操作不可撤销。空间内的数据不会被删除,但空间配置将被移除。`})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{onClick:()=>f(null),children:`取消`}),(0,G.jsx)(yJ,{onClick:H,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`删除`})]})]})}),(0,G.jsx)(A9,{open:!!p,onOpenChange:e=>!e&&m(null),children:(0,G.jsxs)(j9,{style:{width:680,maxWidth:`95vw`},children:[(0,G.jsx)(M9,{children:(0,G.jsxs)(P9,{children:[`管理成员 - `,ee?.name]})}),(0,G.jsxs)(`div`,{className:`space-y-4 pt-2`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`当前成员`}),w&&(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`加载用户信息中...`}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[ee?.members.map(e=>{let n=S[e.user_id];return(0,G.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr_80px_60px] items-center gap-3 text-sm border rounded-md px-3 py-2`,children:[(0,G.jsx)(Zm,{className:`size-3.5 text-muted-foreground`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`font-mono text-xs truncate`,title:e.user_id,children:e.user_id}),n&&(0,G.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[n.name,` · `,new Date(n.created_at).toLocaleDateString(`zh-CN`)]})]}),(0,G.jsx)(CJ,{variant:`outline`,className:`justify-self-center`,children:e.role}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 justify-self-end`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(e.user_id),ir.success(`API Key 已复制`)},className:`text-muted-foreground hover:text-foreground transition-colors`,title:`复制 API Key`,children:(0,G.jsx)(rm,{className:`size-3.5`})}),ee&&B(ee)&&e.user_id!==z?.apiKey&&e.user_id!==ee?.owner_id&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>te(e.user_id),className:`text-muted-foreground hover:text-destructive transition-colors`,title:`移除成员`,children:(0,G.jsx)(Km,{className:`size-3.5`})})]})]},e.user_id)}),(!ee?.members||ee.members.length===0)&&(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`暂无成员`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`添加成员`}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>{D(!0),F(null),k(``),j(`member`)},children:[(0,G.jsx)(ym,{className:`size-3.5 mr-1.5`}),`创建新用户`]})]}),E&&(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-3 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`创建新用户`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{D(!1),F(null)},className:`text-xs text-muted-foreground hover:text-foreground`,children:`取消`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(hb,{placeholder:`用户名(可选)`,value:O,onChange:e=>k(e.target.value),className:`flex-1`}),(0,G.jsxs)(_9,{value:A,onValueChange:e=>j(e||`member`),children:[(0,G.jsx)(y9,{className:`w-28`,children:(0,G.jsx)(v9,{})}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`admin`,children:`管理员`}),(0,G.jsx)(x9,{value:`member`,children:`成员`}),(0,G.jsx)(x9,{value:`reader`,children:`只读`})]})]})]}),(0,G.jsx)(q,{size:`sm`,className:`w-full`,onClick:U,disabled:M,children:M?`生成中...`:`生成用户并添加到空间`}),P&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`新用户 API Key(请复制保存):`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`code`,{className:`flex-1 text-xs bg-background border rounded px-2 py-1.5 font-mono truncate`,children:P}),(0,G.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard.writeText(P),L(!0),setTimeout(()=>L(!1),2e3)},children:I?(0,G.jsx)(Xp,{className:`size-3.5`}):(0,G.jsx)(rm,{className:`size-3.5`})})]})]})]}),!E&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(hb,{placeholder:`输入对方 API Key(UUID格式)`,value:h,onChange:e=>g(e.target.value),className:`flex-1`}),(0,G.jsxs)(_9,{value:_,onValueChange:e=>v(e||`member`),children:[(0,G.jsx)(y9,{className:`w-28`,children:(0,G.jsx)(v9,{})}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`admin`,children:`管理员`}),(0,G.jsx)(x9,{value:`member`,children:`成员`}),(0,G.jsx)(x9,{value:`reader`,children:`只读`})]})]}),(0,G.jsx)(q,{size:`sm`,onClick:W,disabled:b,children:b?`添加中...`:`添加`})]})]})]})]})})]})}var I9=[`#8b5cf6`,`#ec4899`,`#06b6d4`,`#f59e0b`,`#10b981`,`#ef4444`,`#6366f1`,`#f97316`];function L9(e,n){if(!e)return[];let r=Object.entries(e).map(([e,n])=>({name:e,value:n})).sort((e,n)=>n.value-e.value);return n?r.slice(0,n):r}function Rme(){let e=et(),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)([]),[o,s]=(0,y.useState)(!0);(0,y.useEffect)(()=>{async function e(){try{s(!0);let[e,n]=await Promise.all([ib.get(`/v1/stats`),ib.get(`/v1/memories`)]);r(e),a(n?.memories||[])}catch(e){ir.error(`加载统计数据失败: `+e.message)}finally{s(!1)}}e()},[]);let c=(0,y.useMemo)(()=>{if(!n?.timeline?.length)return 0;let e=new Date().toISOString().split(`T`)[0];return n.timeline.find(n=>n.date===e)?.count??0},[n]),l=(0,y.useMemo)(()=>L9(n?.by_category,8),[n]),u=(0,y.useMemo)(()=>L9(n?.by_type),[n]),d=(0,y.useMemo)(()=>L9(n?.by_tier),[n]),f=(0,y.useMemo)(()=>L9(n?.by_state),[n]),p=(0,y.useMemo)(()=>!n||!n.total||!n.total_access_count?`0%`:`${Math.min(100,Math.round(n.total_access_count/Math.max(1,n.total)*100))}%`,[n]),m=(0,y.useMemo)(()=>{let e=[];for(let n of i)if(n.tier_history)try{let r=JSON.parse(n.tier_history);for(let i of r)e.push({memoryId:n.id,...i})}catch{}return e.sort((e,n)=>n.at.localeCompare(e.at)),e.slice(0,50)},[i]),h={access_via_get:`访问触发`,access_via_search:`搜索触发`,access_via_recall:`召回触发`,access_via_cross_space_search:`跨空间搜索触发`,scheduled_evaluation:`定时评估`};return o?(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(Cb,{className:`h-8 w-48`}),(0,G.jsx)(Cb,{className:`h-8 w-24`})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-4`,children:[(0,G.jsx)(Cb,{className:`h-24`}),(0,G.jsx)(Cb,{className:`h-24`}),(0,G.jsx)(Cb,{className:`h-24`}),(0,G.jsx)(Cb,{className:`h-24`})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,G.jsx)(Cb,{className:`h-80`}),(0,G.jsx)(Cb,{className:`h-80`}),(0,G.jsx)(Cb,{className:`h-80`}),(0,G.jsx)(Cb,{className:`h-80`})]})]}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight flex items-center gap-2`,children:[(0,G.jsx)(Yp,{className:`size-5`}),`统计分析`]}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`记忆库数据洞察与可视化`})]}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>e(`/memories`),children:[(0,G.jsx)(Vp,{className:`size-4 mr-1.5`}),`返回记忆`]})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-4`,children:[(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:`总记忆数`}),(0,G.jsx)(qp,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:n?.total??0})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:`今日新增`}),(0,G.jsx)(qm,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:c})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:`空间数`}),(0,G.jsx)(xm,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:n?.total_spaces??Object.keys(n?.by_space??{}).length})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:`活跃度`}),(0,G.jsx)(iee,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:p})})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:`平均重要性`}),(0,G.jsx)(Hm,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:n?.avg_importance?`${(n.avg_importance*100).toFixed(0)}%`:`—`})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:`平均置信度`}),(0,G.jsx)(Yp,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:n?.avg_confidence?`${(n.avg_confidence*100).toFixed(0)}%`:`—`})})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`分类分布`})}),(0,G.jsxs)(Sb,{children:[(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(iJ,{children:[(0,G.jsx)(OB,{data:l,cx:`50%`,cy:`50%`,innerRadius:60,outerRadius:100,paddingAngle:2,dataKey:`value`,children:l.map((e,n)=>(0,G.jsx)(sD,{fill:I9[n%I9.length]},`cell-${e.name}`))}),(0,G.jsx)(VE,{})]})}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2 mt-4 justify-center`,children:l.map((e,n)=>(0,G.jsxs)(CJ,{variant:`secondary`,style:{backgroundColor:`${I9[n%I9.length]}20`,color:I9[n%I9.length]},children:[e.name,` (`,e.value,`)`]},e.name))})]})]}),(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`记忆类型分布`})}),(0,G.jsx)(Sb,{children:(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(rJ,{data:u,children:[(0,G.jsx)(eG,{strokeDasharray:`3 3`,stroke:`#333`}),(0,G.jsx)(mK,{dataKey:`name`,tick:{fontSize:12}}),(0,G.jsx)(jK,{tick:{fontSize:12}}),(0,G.jsx)(VE,{}),(0,G.jsx)(XV,{dataKey:`value`,fill:`#8b5cf6`,radius:[4,4,0,0]})]})})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`层级分布`})}),(0,G.jsx)(Sb,{children:(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(iJ,{children:[(0,G.jsx)(OB,{data:d,cx:`50%`,cy:`50%`,outerRadius:100,dataKey:`value`,label:({name:e,value:n})=>`${e}: ${n}`,children:d.map((e,n)=>(0,G.jsx)(sD,{fill:I9[n%I9.length]},`tier-${e.name}`))}),(0,G.jsx)(VE,{})]})})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`状态分布`})}),(0,G.jsx)(Sb,{children:(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(rJ,{data:f,children:[(0,G.jsx)(eG,{strokeDasharray:`3 3`,stroke:`#333`}),(0,G.jsx)(mK,{dataKey:`name`,tick:{fontSize:12}}),(0,G.jsx)(jK,{tick:{fontSize:12}}),(0,G.jsx)(VE,{}),(0,G.jsx)(XV,{dataKey:`value`,fill:`#10b981`,radius:[4,4,0,0]})]})})})]})]}),(0,G.jsxs)(vb,{className:`mt-4`,children:[(0,G.jsx)(yb,{children:(0,G.jsxs)(bb,{className:`flex items-center gap-1.5 text-base`,children:[(0,G.jsx)(mm,{className:`size-4 text-muted-foreground`}),`Tier 变更日志`]})}),(0,G.jsx)(Sb,{children:m.length===0?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:`暂无变更记录`}):(0,G.jsx)(`div`,{className:`space-y-1`,children:m.map(n=>{let r={peripheral:0,working:1,core:2};return(0,G.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 text-sm py-2 border-b last:border-b-0 hover:bg-muted/50 px-2 rounded cursor-pointer w-full text-left`,onClick:()=>e(`/memories/${n.memoryId}`),children:[(r[n.from]??0)<(r[n.to]??0)?(0,G.jsx)(Wp,{className:`size-4 text-emerald-500 shrink-0`}):(0,G.jsx)(Bp,{className:`size-4 text-red-500 shrink-0`}),(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs w-36 shrink-0`,children:new Date(n.at).toLocaleString(`zh-CN`)}),(0,G.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[n.memoryId.slice(0,8),`...`]}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(n.from),children:jJ(n.from)}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(n.to),children:jJ(n.to)}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:[h[n.reason]||n.reason,` · #`,n.access_count]})]},n.memoryId+n.at)})})})]})]})}var zme={access_via_get:`访问触发`,access_via_search:`搜索触发`,access_via_recall:`召回触发`,access_via_cross_space_search:`跨空间搜索触发`,scheduled_evaluation:`定时评估`},R9=20;function Bme(){let e=et(),n=Ze(),[r,i]=(0,y.useState)([]),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(1),[l,u]=(0,y.useState)(`all`),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(0);(0,y.useEffect)(()=>{n.state?.from===`tier-history`&&n.state?.page&&c(n.state.page)},[n.state]),(0,y.useEffect)(()=>{let e=setTimeout(()=>{m(d)},300);return()=>clearTimeout(e)},[d]);let S=(0,y.useCallback)(async e=>{o(!0);try{let n=(e-1)*R9,r={limit:String(R9),offset:String(n)};l===`promote`?r.filter=`promote`:l===`demote`&&(r.filter=`demote`),p.trim()&&(r.search=p.trim());let a=await ib.get(`/v1/tier-changes`,{params:r});i(a.changes),x(a.totalCount)}catch(e){console.error(`Failed to fetch tier history:`,e)}finally{o(!1)}},[l,p]);(0,y.useEffect)(()=>{S(s)},[S,s]);let C=Math.max(1,Math.ceil(b/R9)),w=Math.min(s,C),T={peripheral:0,working:1,core:2},E=async()=>{if(!h)return;let e=h;v(!0);try{await ib.post(`/v1/tier-changes/delete`,{memory_id:e.memoryId,from:e.from,to:e.to,at:e.at,reason:e.reason}),ir.success(`已删除该条变更记录`),i(n=>n.filter(n=>!(n.memoryId===e.memoryId&&n.from===e.from&&n.to===e.to&&n.at===e.at))),x(e=>Math.max(0,e-1))}catch(e){console.error(`Failed to delete tier history entry:`,e),ir.error(`删除失败`)}finally{v(!1),g(null)}},D=n=>{e(`/memories/${n}`,{state:{from:`tier-history`,page:w}})};return(0,G.jsxs)(`div`,{className:`space-y-6 max-w-5xl mx-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight flex items-center gap-2`,children:[(0,G.jsx)(mm,{className:`size-5`}),`等级变更历史`]}),(0,G.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`共 `,b,` 条记录`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-xs`,children:[(0,G.jsx)(Lm,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 size-4 text-muted-foreground`}),(0,G.jsx)(`input`,{type:`text`,placeholder:`搜索标题、ID、原因...`,value:d,onChange:e=>{f(e.target.value),c(1)},className:`w-full h-9 pl-8 pr-3 rounded-md border border-input bg-background text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]}),(0,G.jsxs)(_9,{value:l,onValueChange:e=>{e&&(u(e),c(1))},children:[(0,G.jsx)(y9,{className:`w-[130px]`,children:(0,G.jsx)(v9,{})}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`all`,children:`全部`}),(0,G.jsx)(x9,{value:`promote`,children:`仅晋升`}),(0,G.jsx)(x9,{value:`demote`,children:`仅降级`})]})]})]}),!a&&r.length>0&&C>1&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`第 `,w,` / `,C,` 页`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(q,{variant:`outline`,size:`sm`,className:`h-7 px-2`,disabled:w<=1,onClick:()=>c(w-1),children:(0,G.jsx)(Qp,{className:`size-4`})}),Array.from({length:C},(e,n)=>n+1).filter(e=>e===1||e===C||Math.abs(e-w)<=2).map((e,n,r)=>(0,G.jsxs)(`span`,{className:`flex items-center`,children:[n>0&&r[n-1]!==e-1&&(0,G.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`}),(0,G.jsx)(q,{variant:e===w?`default`:`outline`,size:`sm`,className:`h-7 w-7 px-0`,onClick:()=>c(e),children:e})]},e)),(0,G.jsx)(q,{variant:`outline`,size:`sm`,className:`h-7 px-2`,disabled:w>=C,onClick:()=>c(w+1),children:(0,G.jsx)($p,{className:`size-4`})})]})]}),(0,G.jsx)(vb,{children:(0,G.jsxs)(Sb,{className:`p-0`,children:[a?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground py-12 text-center`,children:`加载中...`}):r.length===0?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground py-12 text-center`,children:`暂无变更记录`}):(0,G.jsx)(`div`,{className:`divide-y`,children:r.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 hover:bg-muted/30 transition-colors`,children:[(T[e.from]??0)<(T[e.to]??0)?(0,G.jsx)(Wp,{className:`size-4 text-emerald-500 shrink-0`}):(0,G.jsx)(Bp,{className:`size-4 text-red-500 shrink-0`}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground w-36 shrink-0`,children:new Date(e.at).toLocaleString(`zh-CN`)}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(e.from),children:jJ(e.from)}),(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`→`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(e.to),children:jJ(e.to)}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground w-20 shrink-0`,children:zme[e.reason]||e.reason}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground w-16 shrink-0`,children:[`#`,e.accessCount]}),(0,G.jsx)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left text-sm truncate hover:underline cursor-pointer`,onClick:()=>D(e.memoryId),title:e.memoryTitle,children:e.memoryTitle}),(0,G.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground shrink-0`,children:[e.memoryId.slice(0,8),`...`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,G.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,onClick:()=>D(e.memoryId),title:`查看详情`,children:(0,G.jsx)(sm,{className:`size-3.5`})}),(0,G.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-red-500 hover:text-red-600 hover:bg-red-500/10`,onClick:()=>g(e),title:`删除此条记录`,children:(0,G.jsx)(Km,{className:`size-3.5`})})]})]},`${e.memoryId}-${e.at}-${e.from}-${e.to}`))}),C>1&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-t`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`第 `,w,` / `,C,` 页,共 `,b,` 条`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(q,{variant:`outline`,size:`sm`,className:`h-7 px-2`,disabled:w<=1,onClick:()=>c(w-1),children:(0,G.jsx)(Qp,{className:`size-4`})}),Array.from({length:C},(e,n)=>n+1).filter(e=>e===1||e===C||Math.abs(e-w)<=2).map((e,n,r)=>(0,G.jsxs)(`span`,{className:`flex items-center`,children:[n>0&&r[n-1]!==e-1&&(0,G.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`}),(0,G.jsx)(q,{variant:e===w?`default`:`outline`,size:`sm`,className:`h-7 w-7 px-0`,onClick:()=>c(e),children:e})]},e)),(0,G.jsx)(q,{variant:`outline`,size:`sm`,className:`h-7 px-2`,disabled:w>=C,onClick:()=>c(w+1),children:(0,G.jsx)($p,{className:`size-4`})})]})]})]})}),(0,G.jsx)(pJ,{open:!!h,onOpenChange:e=>{e||g(null)},children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除变更记录`}),(0,G.jsxs)(vJ,{children:[`确定要删除这条 `,h&&`${jJ(h.from)} → ${jJ(h.to)}`,` 的变更记录吗?记忆本身不会被删除。`]})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{onClick:()=>g(null),disabled:_,children:`取消`}),(0,G.jsx)(yJ,{disabled:_,onClick:e=>{e.preventDefault(),E()},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:_?`删除中...`:`确认删除`})]})]})})]})}async function Vme(){return ib.get(`/v1/stats/config`)}async function Hme(e=50){return ib.get(`/v1/tier-changes`,{params:{limit:e}})}async function Ume(){return ib.post(`/v1/lifecycle/trigger`,{})}var z9=6,Wme={access_via_get:`访问触发`,access_via_search:`搜索触发`,access_via_recall:`召回触发`,access_via_cross_space_search:`跨空间搜索触发`,scheduled_evaluation:`定时评估`},B9={peripheral:0,working:1,core:2};function Gme(){let e=new Date,n=z9-e.getHours()%z9,r=new Date(e.getTime()+n*36e5);return r.setMinutes(0,0,0),r.toLocaleString(`zh-CN`)}function Kme(e,n){let r=[];for(let i=0;i<=120;i+=2){let a=Math.log(2)/n,o=Math.exp(-a*i**+e);r.push({day:`D${i}`,Core:e<1?Math.max(o,.9):o*.95,Working:o,Peripheral:o*.85})}return r}function qme(){return(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[1,2].map(e=>(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{className:`pb-2`,children:(0,G.jsx)(Cb,{className:`h-4 w-28`})}),(0,G.jsxs)(Sb,{className:`space-y-2`,children:[(0,G.jsx)(Cb,{className:`h-4 w-full`}),(0,G.jsx)(Cb,{className:`h-4 w-3/4`}),(0,G.jsx)(Cb,{className:`h-4 w-1/2`})]})]},e))})}function Jme(){return(0,G.jsx)(`div`,{className:`space-y-2`,children:[1,2,3,4].map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,G.jsx)(Cb,{className:`h-4 w-4`}),(0,G.jsx)(Cb,{className:`h-3 w-24`}),(0,G.jsx)(Cb,{className:`h-5 w-14`}),(0,G.jsx)(Cb,{className:`h-3 w-4`}),(0,G.jsx)(Cb,{className:`h-5 w-14`}),(0,G.jsx)(Cb,{className:`h-3 flex-1`})]},e))})}function Yme(){let[e,n]=(0,y.useState)(null),[r,i]=(0,y.useState)([]),[a,o]=(0,y.useState)(0),[s,c]=(0,y.useState)(!0),[l,u]=(0,y.useState)(!0),[d,f]=(0,y.useState)(20),[p,m]=(0,y.useState)(!1),h=async()=>{try{c(!0),n(await Vme())}catch(e){console.error(`Failed to load lifecycle config:`,e),ir.error(`加载生命周期配置失败`)}finally{c(!1)}},g=async()=>{try{u(!0);let e=await Hme(d);i(e.changes||[]),o(e.totalCount||0)}catch(e){console.error(`Failed to load tier changes:`,e),ir.error(`加载升降级历史失败`)}finally{u(!1)}};(0,y.useEffect)(()=>{h(),g()},[]),(0,y.useEffect)(()=>{g()},[d]);let _=()=>{h(),g()},v=async()=>{try{m(!0);let e=await Ume();ir.success(e.message),h(),g()}catch(e){console.error(`Failed to trigger lifecycle:`,e),ir.error(`触发生命周期失败`)}finally{m(!1)}},b=e?Kme(e.decay.tiers?.working?.beta??1,e.decay.half_life_days):[],x=r.filter(e=>(B9[e.from]??0)<(B9[e.to]??0)).length,S=r.filter(e=>(B9[e.from]??0)>=(B9[e.to]??0)).length;return(0,G.jsxs)(`div`,{className:`space-y-6 max-w-6xl mx-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight flex items-center gap-2`,children:[(0,G.jsx)(Gm,{className:`size-5`}),`生命周期管理`]}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`记忆衰减、升降级、自动遗忘的生命周期策略`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:_,disabled:s&&l,children:[(0,G.jsx)(Fm,{className:`h-4 w-4 mr-1`}),`刷新`]}),(0,G.jsxs)(q,{variant:`default`,size:`sm`,onClick:v,disabled:p,children:[p?(0,G.jsx)(nee,{className:`h-4 w-4 mr-1 animate-spin`}):(0,G.jsx)(eh,{className:`h-4 w-4 mr-1`}),`立即执行`]})]})]}),(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`pb-3`,children:[(0,G.jsxs)(bb,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,G.jsx)(nm,{className:`size-4 text-violet-500`}),`调度器状态`]}),(0,G.jsx)(xb,{children:`自动评估与遗忘任务的运行状态`})]}),(0,G.jsxs)(Sb,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,G.jsxs)(`div`,{className:`p-3 rounded-lg border`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`调度间隔`}),(0,G.jsxs)(`p`,{className:`text-lg font-semibold mt-1`,children:[`每 `,z9,` 小时`]})]}),(0,G.jsxs)(`div`,{className:`p-3 rounded-lg border`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`预计下次运行`}),(0,G.jsx)(`p`,{className:`text-sm font-semibold mt-1`,children:Gme()})]}),(0,G.jsxs)(`div`,{className:`p-3 rounded-lg border`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`启动时运行`}),(0,G.jsx)(`div`,{className:`mt-1`,children:(0,G.jsx)(CJ,{variant:`outline`,className:`bg-emerald-500/10 text-emerald-600 border-emerald-500/30`,children:`已启用`})})]})]}),(0,G.jsx)(`div`,{className:`mt-4 p-3 rounded-lg border border-dashed text-xs text-muted-foreground space-y-1`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(sm,{className:`size-3.5`}),(0,G.jsx)(`span`,{children:`调度器将自动执行:Weibull 衰减计算、Tier 评估升降级、关键词 TTL 检测、Superseded 归档清理`})]})})]})]}),s?(0,G.jsx)(qme,{}):e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{className:`pb-3`,children:(0,G.jsxs)(bb,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,G.jsx)(zp,{className:`size-4 text-blue-500`}),`衰减参数`]})}),(0,G.jsxs)(Sb,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`默认半衰期`}),(0,G.jsxs)(`p`,{className:`font-semibold`,children:[e.decay.half_life_days,` 天`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Stale 阈值`}),(0,G.jsx)(`p`,{className:`font-semibold`,children:`0.3`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`权重分配`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(CJ,{variant:`outline`,className:`bg-blue-500/10 text-blue-600 border-blue-500/30 text-xs`,children:[`时效 `,e.decay.recency_weight]}),(0,G.jsxs)(CJ,{variant:`outline`,className:`bg-emerald-500/10 text-emerald-600 border-emerald-500/30 text-xs`,children:[`频率 `,e.decay.frequency_weight]}),(0,G.jsxs)(CJ,{variant:`outline`,className:`bg-violet-500/10 text-violet-600 border-violet-500/30 text-xs`,children:[`内在 `,e.decay.intrinsic_weight]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Tier 衰减速率 (β)`}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:Object.entries(e.decay.tiers||{}).map(([e,n])=>(0,G.jsxs)(CJ,{variant:`outline`,className:`text-xs ${NJ(e)}`,children:[jJ(e),` β=`,n.beta]},e))})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Tier 底线分数`}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:Object.entries(e.decay.tiers||{}).map(([e,n])=>(0,G.jsxs)(CJ,{variant:`outline`,className:`text-xs ${NJ(e)}`,children:[jJ(e),` ≥`,n.floor]},e))})]})]})]}),(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{className:`pb-3`,children:(0,G.jsxs)(bb,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,G.jsx)(qm,{className:`size-4 text-emerald-500`}),`升降级规则`]})}),(0,G.jsxs)(Sb,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`p-3 rounded-lg border space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,G.jsx)(Wp,{className:`size-4 text-emerald-500`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(`peripheral`),children:jJ(`peripheral`)}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(`working`),children:jJ(`working`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 text-xs`,children:[(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`访问 ≥`,e.promotion.peripheral_to_working.min_access_count,`次`]}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`综合 ≥`,e.promotion.peripheral_to_working.min_composite]})]})]}),(0,G.jsxs)(`div`,{className:`p-3 rounded-lg border space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,G.jsx)(Wp,{className:`size-4 text-emerald-500`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(`working`),children:jJ(`working`)}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(`core`),children:jJ(`core`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 text-xs`,children:[(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`访问 ≥`,e.promotion.working_to_core.min_access_count,`次`]}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`综合 ≥`,e.promotion.working_to_core.min_composite]}),e.promotion.working_to_core.min_importance!=null&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`重要性 ≥`,e.promotion.working_to_core.min_importance]})]})]})]}),(0,G.jsx)(`div`,{className:`p-3 rounded-lg border border-dashed space-y-1 text-xs text-muted-foreground`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Bp,{className:`size-3.5 text-red-400`}),(0,G.jsx)(`span`,{children:`不满足条件时自动降级至低等级`})]})})]})]})]}),b.length>0&&(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`pb-2`,children:[(0,G.jsxs)(bb,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,G.jsx)(eh,{className:`size-4 text-amber-500`}),`衰减曲线预览`]}),(0,G.jsx)(xb,{children:`基于当前配置参数生成的理论衰减趋势`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`h-64`,children:(0,G.jsx)(oD,{width:`100%`,height:`100%`,children:(0,G.jsxs)(nJ,{data:b,children:[(0,G.jsx)(eG,{strokeDasharray:`3 3`,className:`opacity-30`}),(0,G.jsx)(mK,{dataKey:`day`,tick:{fontSize:11},interval:14,label:{value:`天数`,position:`insideBottomRight`,offset:-5,fontSize:11}}),(0,G.jsx)(jK,{domain:[0,1],tick:{fontSize:11},label:{value:`分数`,angle:-90,position:`insideLeft`,fontSize:11}}),(0,G.jsx)(VE,{contentStyle:{fontSize:12,borderRadius:8},formatter:e=>[e.toFixed(3)]}),(0,G.jsx)(FT,{iconType:`line`,wrapperStyle:{fontSize:12}}),(0,G.jsx)(OG,{type:`monotone`,dataKey:`Core`,stroke:`#f59e0b`,strokeWidth:2,dot:!1,name:`核心 (Core)`}),(0,G.jsx)(OG,{type:`monotone`,dataKey:`Working`,stroke:`#10b981`,strokeWidth:2,dot:!1,name:`工作区 (Working)`}),(0,G.jsx)(OG,{type:`monotone`,dataKey:`Peripheral`,stroke:`#94a3b8`,strokeWidth:2,dot:!1,name:`边缘 (Peripheral)`})]})})})})]})]}):(0,G.jsx)(vb,{children:(0,G.jsx)(Sb,{className:`py-8 text-center`,children:(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`无法加载生命周期配置`})})}),(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{className:`pb-2`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(bb,{className:`text-sm font-medium`,children:`升降级历史`}),(0,G.jsx)(xb,{children:`最近的 Tier 变更记录`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(CJ,{variant:`outline`,className:`bg-emerald-500/10 text-emerald-600 border-emerald-500/30 text-xs`,children:[`↑ 升级 `,x]}),(0,G.jsxs)(CJ,{variant:`outline`,className:`bg-red-500/10 text-red-600 border-red-500/30 text-xs`,children:[`↓ 降级 `,S]}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`共 `,a,` 条`]})]})]})}),(0,G.jsx)(Sb,{className:`p-0`,children:l?(0,G.jsx)(Jme,{}):r.length===0?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground py-12 text-center`,children:`暂无变更记录`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y`,children:r.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 hover:bg-muted/30 transition-colors`,children:[(B9[e.from]??0)<(B9[e.to]??0)?(0,G.jsx)(Wp,{className:`size-4 text-emerald-500 shrink-0`}):(0,G.jsx)(Bp,{className:`size-4 text-red-500 shrink-0`}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground w-36 shrink-0`,children:new Date(e.at).toLocaleString(`zh-CN`)}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(e.from),children:jJ(e.from)}),(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`→`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(e.to),children:jJ(e.to)}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground w-20 shrink-0`,children:Wme[e.reason]||e.reason}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground w-12 shrink-0`,children:[`#`,e.accessCount]}),(0,G.jsx)(`span`,{className:`text-xs flex-1 min-w-0 truncate text-muted-foreground`,children:e.memoryTitle||e.memoryId?.slice(0,12)||`—`}),(0,G.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground shrink-0`,children:e.memoryId?`${e.memoryId.slice(0,8)}...`:`—`})]},`${e.memoryId}-${e.at}-${e.from}-${e.to}`))}),r.length<a&&(0,G.jsx)(`div`,{className:`flex items-center justify-center px-4 py-3 border-t`,children:(0,G.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>f(e=>e+20),children:`加载更多`})})]})})]})]})}function V9(){let e=et(),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!1),u=(0,y.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),e.type===`dragenter`||e.type===`dragover`?l(!0):e.type===`dragleave`&&l(!1)},[]),d=(0,y.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),l(!1),e.dataTransfer.files&&e.dataTransfer.files[0]&&(r(e.dataTransfer.files[0]),s(null))},[]);return(0,G.jsxs)(`div`,{className:`space-y-6 max-w-3xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>e(`/memories`),children:(0,G.jsx)(Vp,{className:`h-4 w-4`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`批量导入`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`从 JSON、CSV 或 Markdown 文件导入记忆`})]})]}),(0,G.jsx)(vb,{className:`border-2 border-dashed p-8 transition-colors ${c?`border-primary bg-primary/5`:`border-border`}`,onDragEnter:u,onDragLeave:u,onDragOver:u,onDrop:d,children:(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 text-center`,children:[(0,G.jsx)(Ym,{className:`h-10 w-10 text-muted-foreground`}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:n?n.name:`拖拽文件到此处,或点击选择`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`支持 JSON、CSV、Markdown 格式`})]}),(0,G.jsx)(`input`,{type:`file`,accept:`.json,.csv,.md,.markdown`,onChange:e=>{e.target.files&&e.target.files[0]&&(r(e.target.files[0]),s(null))},className:`hidden`,id:`file-upload`}),(0,G.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>document.getElementById(`file-upload`)?.click(),children:`选择文件`})]})}),n&&(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-card p-4`,children:[(e=>e.endsWith(`.json`)?(0,G.jsx)(cm,{className:`h-8 w-8 text-blue-500`}):e.endsWith(`.csv`)?(0,G.jsx)(lm,{className:`h-8 w-8 text-green-500`}):e.endsWith(`.md`)||e.endsWith(`.markdown`)?(0,G.jsx)(um,{className:`h-8 w-8 text-purple-500`}):(0,G.jsx)(um,{className:`h-8 w-8 text-muted-foreground`}))(n.name),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium truncate`,children:n.name}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(n.size/1024).toFixed(1),` KB`]})]}),(0,G.jsx)(q,{onClick:async()=>{if(!n){ir.error(`请先选择文件`);return}let e=new FormData;e.append(`file`,n);let r=n.name.endsWith(`.json`)?`json`:n.name.endsWith(`.csv`)?`csv`:`md`;e.append(`format`,r),a(!0);try{let n=await ib.post(`/v1/imports`,e,{headers:{"Content-Type":`multipart/form-data`}});s({success:!0,imported:n.imported||0,failed:n.failed||0,errors:n.errors}),ir.success(`成功导入 ${n.imported||0} 条记忆`)}catch(e){let n=e.response?.data?.error||e.message||`导入失败`;s({success:!1,imported:0,failed:0,errors:[n]}),ir.error(n)}finally{a(!1)}},disabled:i,size:`sm`,children:i?`导入中...`:`开始导入`})]}),o&&(0,G.jsxs)(vb,{className:`p-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[o.success?(0,G.jsx)(tm,{className:`h-5 w-5 text-green-500`}):(0,G.jsx)(eee,{className:`h-5 w-5 text-red-500`}),(0,G.jsx)(`h3`,{className:`font-semibold`,children:o.success?`导入成功`:`导入失败`})]}),o.success&&(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg bg-green-500/10 p-4 text-center`,children:[(0,G.jsx)(`p`,{className:`text-2xl font-bold text-green-500`,children:o.imported}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`成功导入`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg bg-red-500/10 p-4 text-center`,children:[(0,G.jsx)(`p`,{className:`text-2xl font-bold text-red-500`,children:o.failed}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`导入失败`})]})]}),o.errors&&o.errors.length>0&&(0,G.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-red-500`,children:`错误信息:`}),o.errors.map(e=>(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e},e))]})]}),(0,G.jsxs)(vb,{className:`p-6`,children:[(0,G.jsx)(`h3`,{className:`font-semibold mb-3`,children:`支持格式说明`}),(0,G.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(cm,{className:`h-4 w-4 text-blue-500 mt-0.5`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium`,children:`JSON`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`标准 JSON 数组格式,每条记忆包含 content, tags, category 等字段`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(lm,{className:`h-4 w-4 text-green-500 mt-0.5`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium`,children:`CSV`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`包含列:content, tags, category, importance, confidence`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(um,{className:`h-4 w-4 text-purple-500 mt-0.5`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium`,children:`Markdown`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`每条记忆用标题分隔,支持 frontmatter 元数据`})]})]})]})]})]})}function Xme(){let{theme:e,setTheme:n}=Cr(),{hasPassword:r,setPassword:i,lock:a}=ob(),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(!1);return(0,G.jsxs)(`div`,{className:`space-y-6 max-w-2xl`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`系统设置`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`管理您的偏好设置和数据`})]}),(0,G.jsxs)(vb,{className:`p-6`,children:[(0,G.jsx)(`h3`,{className:`font-semibold mb-4`,children:`外观`}),(0,G.jsx)(`div`,{className:`space-y-4`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(gb,{className:`text-sm font-medium`,children:`主题模式`}),(0,G.jsxs)(`div`,{className:`flex gap-2 mt-2`,children:[(0,G.jsxs)(q,{variant:e===`light`?`default`:`outline`,size:`sm`,onClick:()=>n(`light`),className:`gap-2`,children:[(0,G.jsx)(Um,{className:`h-4 w-4`}),`亮色`]}),(0,G.jsxs)(q,{variant:e===`dark`?`default`:`outline`,size:`sm`,onClick:()=>n(`dark`),className:`gap-2`,children:[(0,G.jsx)(Am,{className:`h-4 w-4`}),`暗黑`]}),(0,G.jsxs)(q,{variant:e===`system`?`default`:`outline`,size:`sm`,onClick:()=>n(`system`),className:`gap-2`,children:[(0,G.jsx)(km,{className:`h-4 w-4`}),`跟随系统`]})]})]})})]}),(0,G.jsxs)(vb,{className:`p-6`,children:[(0,G.jsx)(`h3`,{className:`font-semibold mb-4`,children:`私密空间 Vault`}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Vault 密码已设置。私密记忆需要输入密码才能查看。`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>l(!c),children:[(0,G.jsx)(Em,{className:`h-4 w-4 mr-2`}),`修改密码`]}),(0,G.jsxs)(q,{variant:`destructive`,size:`sm`,onClick:()=>p(!0),children:[(0,G.jsx)(Km,{className:`h-4 w-4 mr-2`}),`重置 Vault`]})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`尚未设置 Vault 密码。设置后,私密记忆将受到密码保护。`}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>l(!0),children:[(0,G.jsx)(Em,{className:`h-4 w-4 mr-2`}),`设置 Vault 密码`]})]}),c&&(0,G.jsxs)(`div`,{className:`flex gap-2 mt-4`,children:[(0,G.jsx)(`input`,{type:`password`,placeholder:`输入新密码`,value:o,onChange:e=>s(e.target.value),className:`flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm`}),(0,G.jsx)(q,{size:`sm`,onClick:()=>{if(!o||o.length<4){ir.error(`密码至少需要 4 位`);return}i(o),ir.success(`Vault 密码已设置`),s(``),l(!1)},children:`确认`})]})]})]}),(0,G.jsxs)(vb,{className:`p-6`,children:[(0,G.jsx)(`h3`,{className:`font-semibold mb-4`,children:`数据管理`}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:`导出记忆数据`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`从服务端导出所有记忆为 JSON 文件`})]}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:async()=>{d(!0);try{let e=await ib.get(`/v1/memories`,{params:{limit:1e4}}),n={memories:e.memories||[],total_count:e.total_count||0,exportedAt:new Date().toISOString()},r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`omem-memories-${new Date().toISOString().slice(0,10)}.json`,a.click(),URL.revokeObjectURL(i),ir.success(`已导出 ${n.total_count} 条记忆`)}catch(e){console.error(`Failed to export memories:`,e),ir.error(`导出记忆数据失败`)}finally{d(!1)}},disabled:u,children:[(0,G.jsx)(im,{className:`h-4 w-4 mr-2`}),u?`导出中...`:`导出`]})]}),(0,G.jsx)(k7,{}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:`导出本地配置`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`将登录信息、主题等本地设置导出备份`})]}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>{let e={auth:JSON.parse(sessionStorage.getItem(`omem-auth`)||`{}`),vault:`已迁移到服务端存储`,theme:localStorage.getItem(`omem-theme`)||`system`,exportedAt:new Date().toISOString()},n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`omem-config-${new Date().toISOString().slice(0,10)}.json`,i.click(),URL.revokeObjectURL(r),ir.success(`本地配置已导出`)},children:[(0,G.jsx)(am,{className:`h-4 w-4 mr-2`}),`导出`]})]}),(0,G.jsx)(k7,{}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:`清除缓存`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`清除所有本地存储的数据(不可逆)`})]}),(0,G.jsxs)(q,{variant:`destructive`,size:`sm`,onClick:()=>{sessionStorage.clear(),ir.success(`缓存已清除`,{description:`所有本地数据已清除,刷新页面后生效`})},children:[(0,G.jsx)(Km,{className:`h-4 w-4 mr-2`}),`清除`]})]})]})]}),(0,G.jsxs)(vb,{className:`p-6`,children:[(0,G.jsx)(`h3`,{className:`font-semibold mb-4`,children:`关于`}),(0,G.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(vm,{className:`h-4 w-4 text-muted-foreground`}),(0,G.jsx)(`span`,{children:`omem-web v0.1.0`})]}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`omem 自部署版 Web 管理端`}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`备案号:`,(0,G.jsx)(`a`,{href:`https://beian.miit.gov.cn`,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`吉ICP备2026003061号`})]})]})]}),(0,G.jsx)(pJ,{open:f,onOpenChange:p,children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认重置 Vault`}),(0,G.jsx)(vJ,{children:`此操作不可恢复。重置后所有受 Vault 保护的私密记忆将无法访问。`})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{onClick:()=>p(!1),children:`取消`}),(0,G.jsx)(yJ,{onClick:async()=>{try{await ib.delete(`/v1/vault/password`),a(),ir.success(`Vault 已重置`),l(!1),p(!1)}catch{ir.error(`重置 Vault 失败`)}},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`确认重置`})]})]})})]})}function H9(e){return`/v2/profile${e}`}var U9={getPreferences(e){return ib.get(H9(`/preferences`),{params:e?{project_path:e}:void 0})},getPreference(e){return ib.get(H9(`/preferences/${e}`))},createPreference(e){return ib.post(H9(`/preferences`),e)},updatePreference(e,n){return ib.put(H9(`/preferences/${e}`),n)},deletePreference(e){return ib.delete(H9(`/preferences/${e}`))},getStats(e){return ib.get(H9(`/stats`),{params:e?{project_path:e}:void 0})},getInjection(e){return ib.get(H9(`/inject`),{params:e?{project_path:e}:void 0})},triggerInduction(e,n){return ib.post(H9(`/induction/trigger`),{candidate_texts:e??[],project_path:n})},getInductionRuns(e){return ib.get(H9(`/induction/runs`),{params:e?{project_path:e}:void 0})},getVersions(e){return ib.get(H9(`/versions`),{params:e?{project_path:e}:void 0})},getChangelog(e){return ib.get(H9(`/changelog`),{params:e?{project_path:e}:void 0})}};function W9(e){let n=e.toLowerCase();return n.includes(`喜欢`)||n.includes(`偏好`)||n.includes(`习惯`)?{type:`preference`,icon:Cm,color:`text-amber-600 dark:text-amber-400`,bgColor:`bg-amber-50 dark:bg-amber-500/10 border-amber-200 dark:border-amber-500/30`,label:`偏好`}:n.includes(`项目`)||n.includes(`工程`)||n.includes(`开发`)?{type:`project`,icon:eh,color:`text-blue-600 dark:text-blue-400`,bgColor:`bg-blue-50 dark:bg-blue-500/10 border-blue-200 dark:border-blue-500/30`,label:`项目`}:n.includes(`技能`)||n.includes(`能力`)||n.includes(`精通`)||n.includes(`熟练`)?{type:`skill`,icon:Vm,color:`text-violet-600 dark:text-violet-400`,bgColor:`bg-violet-50 dark:bg-violet-500/10 border-violet-200 dark:border-violet-500/30`,label:`技能`}:n.includes(`笔记`)||n.includes(`记录`)||n.includes(`文档`)?{type:`note`,icon:Gp,color:`text-slate-600 dark:text-slate-400`,bgColor:`bg-slate-50 dark:bg-slate-500/10 border-slate-200 dark:border-slate-500/30`,label:`笔记`}:{type:`fact`,icon:Zm,color:`text-emerald-600 dark:text-emerald-400`,bgColor:`bg-emerald-50 dark:bg-emerald-500/10 border-emerald-200 dark:border-emerald-500/30`,label:`事实`}}function Zme(){return{type:`private`,icon:Em,color:`text-amber-600 dark:text-amber-400`,bgColor:`bg-amber-50 dark:bg-amber-500/10 border-amber-200 dark:border-amber-500/30`,label:`私密`}}function G9(e){return e.replace(/^#+\s*/,``).trim()}function Qme(e,n){return n===`private`?!0:e.some(e=>e===`私密`||e.toLowerCase()===`private`)}function $me(e){return new Date(e).toLocaleString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function K9(e){let n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return`刚刚`;if(r<60)return`${r} 分钟前`;let i=Math.floor(r/60);if(i<24)return`${i} 小时前`;let a=Math.floor(i/24);return a<30?`${a} 天前`:$me(e)}function q9({content:e}){let[n,r]=(0,y.useState)(!1),i=(0,y.useRef)(null),[a,o]=(0,y.useState)(!1);return(0,y.useEffect)(()=>{let e=i.current;if(!e)return;let n=new ResizeObserver(()=>o(e.scrollHeight>e.clientHeight));return n.observe(e),()=>n.disconnect()},[]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:Tp(`relative`,!n&&`max-h-60 overflow-hidden`),children:[(0,G.jsx)(`div`,{ref:i,className:`prose prose-sm dark:prose-invert max-w-none`,children:(0,G.jsx)(b0,{remarkPlugins:[d3],children:e})}),!n&&a&&(0,G.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-10 bg-gradient-to-t from-background to-transparent pointer-events-none`})]}),a&&(0,G.jsx)(q,{variant:`ghost`,size:`sm`,className:`mt-1 h-auto py-1 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:()=>r(!n),children:n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(em,{className:`size-3 mr-1`}),`收起`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Zp,{className:`size-3 mr-1`}),`展开全文`]})})]})}var ehe=[{name:`communication_style`,display:`沟通风格`},{name:`tone`,display:`语气偏好`},{name:`code_style`,display:`代码风格`},{name:`error_handling`,display:`错误处理`},{name:`naming_convention`,display:`命名规范`},{name:`testing_strategy`,display:`测试策略`},{name:`workflow_preference`,display:`工作流偏好`},{name:`commit_style`,display:`提交风格`},{name:`emoji_preference`,display:`Emoji偏好`},{name:`self_reference`,display:`自称方式`},{name:`address_style`,display:`称呼方式`},{name:`language`,display:`语言`},{name:`framework_preference`,display:`框架偏好`},{name:`preferred_tools`,display:`工具偏好`}],the={communication_style:`沟通风格`,coding_preferences:`编码偏好`,project_context:`项目上下文`,tool_preferences:`工具偏好`,domain_knowledge:`领域知识`,work_style:`工作风格`,language_preference:`语言偏好`,framework_preferences:`框架偏好`},nhe={communication_style:zp,coding_preferences:eh,project_context:dm,tool_preferences:xm,domain_knowledge:Gp,work_style:Pm,language_preference:Cm,framework_preferences:Vm};function rhe(e){return the[e]||e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function ihe(e){return nhe[e]||xm}var ahe={global:{className:`bg-blue-50 dark:bg-blue-500/10 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-500/30`,label:`全局`},project:{className:`bg-violet-50 dark:bg-violet-500/10 text-violet-700 dark:text-violet-300 border-violet-200 dark:border-violet-500/30`,label:`项目`},session:{className:`bg-emerald-50 dark:bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border-emerald-200 dark:border-emerald-500/30`,label:`会话`}};function ohe(){let e=et(),n=ob(e=>e.unlock),r=ob(e=>e.hasPassword),i=ob(e=>e.isUnlocked),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)([]),[d,f]=(0,y.useState)([]),[p,m]=(0,y.useState)(!0),[h,g]=(0,y.useState)(`preferences`),[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(``),[E,D]=(0,y.useState)(null),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(new Set),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(null),[ee,B]=(0,y.useState)(!1),[V,H]=(0,y.useState)(``),[U,te]=(0,y.useState)(`all`),[W,ne]=(0,y.useState)(1),[re,ie]=(0,y.useState)(1);(0,y.useEffect)(()=>{async function e(){try{m(!0);let e=_||void 0,[n,r,i,a]=await Promise.all([ib.get(`/v1/profile`).catch(()=>null),U9.getStats(e).catch(()=>null),U9.getPreferences(e).catch(()=>[]),U9.getChangelog(e).catch(()=>[])]);n&&o(n),r&&c(r),u(Array.isArray(i)?i:[]),f(Array.isArray(a)?a:[])}catch(e){console.error(`Failed to load profile:`,e),ir.error(`加载画像数据失败`)}finally{m(!1)}}e()},[_]);let ae=async()=>{if(!w.trim()){D(`请输入密码`);return}k(!0);let e=await n(w);if(k(!1),!e){D(`密码错误`);return}S&&j(e=>new Set(e).add(S)),x(!1),C(null),T(``),D(null),ir.success(`已解锁`)},oe=e=>{if(i){j(n=>new Set(n).add(e));return}if(!r){ir.error(`请先在设置中设置密码`);return}C(e),T(``),D(null),x(!0)},se=a?.static_facts||[],ce=a?.dynamic_context||[],le=(0,y.useMemo)(()=>se.map(e=>{let n=Qme(e.tags||[],e.visibility),r=n?Zme():W9(e.content);return{fact:e.content,factObj:e,isPrivate:n,meta:r}}),[se]),ue=(0,y.useMemo)(()=>{let e=new Map;for(let n of l){if(U!==`all`&&n.scope!==U)continue;if(V.trim()){let e=V.toLowerCase();if(!n.value.toLowerCase().includes(e)&&!n.slot.toLowerCase().includes(e)&&!(n.project_path||``).toLowerCase().includes(e))continue}let r=e.get(n.slot)||[];r.push(n),e.set(n.slot,r)}return e},[l,V,U]),de=(0,y.useMemo)(()=>Array.from(ue.entries()),[ue]),fe=Math.max(1,Math.ceil(de.length/5)),pe=(0,y.useMemo)(()=>{let e=(W-1)*5;return de.slice(e,e+5)},[de,W]),me=async()=>{let e=_||void 0,[n,r]=await Promise.all([U9.getPreferences(e),U9.getStats(e).catch(()=>null)]);u(Array.isArray(n)?n:[]),r&&c(r)},he=async e=>{if(!(!(`slot`in e)||!e.slot))try{L(!0),await U9.createPreference(e),ir.success(`偏好已创建`),N(!1),await me()}catch{ir.error(`创建失败`)}finally{L(!1)}},ge=async(e,n)=>{try{L(!0),await U9.updatePreference(e,n),ir.success(`偏好已更新`),F(null);let r=_||void 0,i=await U9.getPreferences(r);u(Array.isArray(i)?i:[])}catch{ir.error(`更新失败`)}finally{L(!1)}},_e=async()=>{if(R)try{B(!0),await U9.deletePreference(R.id),ir.success(`偏好已删除`),z(null),await me()}catch{ir.error(`删除失败`)}finally{B(!1)}},ve=(0,y.useMemo)(()=>{let e=new Set;for(let n of l)n.project_path&&e.add(n.project_path);return Array.from(e).sort()},[l]),ye=l.length;return(0,G.jsxs)(`div`,{className:`min-h-screen bg-gradient-to-b from-background via-background to-muted/30`,children:[(0,G.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-6 space-y-6`,children:[(0,G.jsxs)(q,{variant:`ghost`,size:`sm`,className:`text-muted-foreground hover:text-foreground -ml-2`,onClick:()=>e(-1),children:[(0,G.jsx)(Vp,{className:`size-4 mr-1.5`}),`返回`]}),(0,G.jsxs)(`div`,{className:`relative overflow-hidden rounded-2xl bg-gradient-to-br from-amber-50 via-orange-50 to-rose-50 dark:from-amber-500/10 dark:via-orange-500/5 dark:to-rose-500/10 border border-amber-200/50 dark:border-amber-500/20 p-6 md:p-8`,children:[(0,G.jsx)(`div`,{className:`absolute top-0 right-0 -mt-8 -mr-8 w-48 h-48 bg-amber-400/15 dark:bg-amber-500/10 rounded-full blur-3xl`}),(0,G.jsx)(`div`,{className:`absolute bottom-0 left-0 -mb-6 -ml-6 w-36 h-36 bg-orange-400/10 dark:bg-orange-500/8 rounded-full blur-3xl`}),(0,G.jsxs)(`div`,{className:`relative z-10 flex flex-col md:flex-row md:items-center md:justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-14 rounded-2xl bg-gradient-to-br from-amber-400 to-orange-500 shadow-lg shadow-amber-500/25`,children:(0,G.jsx)(Zm,{className:`size-7 text-white`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl md:text-3xl font-bold tracking-tight text-foreground`,children:`用户画像`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:`偏好 · 记忆 · 洞察`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-2.5 rounded-xl bg-white/80 dark:bg-card/80 border border-amber-200/60 dark:border-amber-500/20 shadow-sm`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-8 rounded-lg bg-amber-100 dark:bg-amber-500/15`,children:(0,G.jsx)(xm,{className:`size-4 text-amber-600 dark:text-amber-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-lg font-bold leading-none text-foreground`,children:ye}),(0,G.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`条偏好`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-2.5 rounded-xl bg-white/80 dark:bg-card/80 border border-orange-200/60 dark:border-orange-500/20 shadow-sm`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-8 rounded-lg bg-orange-100 dark:bg-orange-500/15`,children:(0,G.jsx)(Yp,{className:`size-4 text-orange-600 dark:text-orange-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-lg font-bold leading-none text-foreground`,children:s?.total??0}),(0,G.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`归纳总量`})]})]}),s?.last_induction_at&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-2.5 rounded-xl bg-white/80 dark:bg-card/80 border border-rose-200/60 dark:border-rose-500/20 shadow-sm`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-8 rounded-lg bg-rose-100 dark:bg-rose-500/15`,children:(0,G.jsx)(nm,{className:`size-4 text-rose-600 dark:text-rose-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm font-semibold leading-none text-foreground`,children:K9(s.last_induction_at)}),(0,G.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`最近归纳`})]})]})]})]})]}),(0,G.jsxs)(F7,{value:h,onValueChange:g,className:`space-y-4`,children:[(0,G.jsxs)(I7,{className:`bg-muted/60 p-1 h-auto`,children:[(0,G.jsxs)(L7,{value:`preferences`,className:`data-[state=active]:bg-background data-[state=active]:shadow-sm gap-1.5 px-4 py-2 text-sm`,children:[(0,G.jsx)(Vm,{className:`size-3.5`}),`偏好管理`]}),(0,G.jsxs)(L7,{value:`overview`,className:`data-[state=active]:bg-background data-[state=active]:shadow-sm gap-1.5 px-4 py-2 text-sm`,children:[(0,G.jsx)(Zm,{className:`size-3.5`}),`画像概览`]}),(0,G.jsxs)(L7,{value:`changelog`,className:`data-[state=active]:bg-background data-[state=active]:shadow-sm gap-1.5 px-4 py-2 text-sm`,children:[(0,G.jsx)(mm,{className:`size-3.5`}),`变更历史`]})]}),(0,G.jsxs)(R7,{value:`preferences`,className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-3`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1 w-full sm:max-w-xs`,children:[(0,G.jsx)(Lm,{className:`absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground`}),(0,G.jsx)(hb,{placeholder:`搜索偏好...`,value:V,onChange:e=>{H(e.target.value),ne(1)},className:`pl-9 h-9 bg-muted/40`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ve.length>0&&(0,G.jsxs)(_9,{value:_,onValueChange:e=>e!=null&&v(e),children:[(0,G.jsxs)(y9,{className:`h-9 w-[180px] text-xs`,children:[(0,G.jsx)(dm,{className:`size-3.5 mr-1.5 text-muted-foreground`}),(0,G.jsx)(v9,{placeholder:`全部项目`})]}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`__all__`,children:`全部项目`}),ve.map(e=>(0,G.jsx)(x9,{value:e,children:e.split(`/`).pop()||e},e))]})]}),(0,G.jsxs)(_9,{value:U,onValueChange:e=>{e!=null&&(te(e),ne(1))},children:[(0,G.jsx)(y9,{className:`h-9 w-[100px] text-xs`,children:(0,G.jsx)(v9,{placeholder:`范围`})}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`all`,children:`全部范围`}),(0,G.jsx)(x9,{value:`global`,children:`全局`}),(0,G.jsx)(x9,{value:`project`,children:`项目`}),(0,G.jsx)(x9,{value:`session`,children:`会话`})]})]})]}),(0,G.jsxs)(q,{className:`ml-auto h-9 gap-1.5 bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white shadow-sm`,onClick:()=>N(!0),children:[(0,G.jsx)(Nm,{className:`size-4`}),`新建偏好`]})]}),p?(0,G.jsx)(`div`,{className:`space-y-4`,children:[1,2,3].map(e=>(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(Cb,{className:`h-5 w-24 rounded-md`}),(0,G.jsx)(Cb,{className:`h-24 w-full rounded-xl`})]},e))}):ue.size===0?(0,G.jsx)(vb,{className:`border-dashed`,children:(0,G.jsxs)(Sb,{className:`py-16 flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-2xl bg-muted`,children:(0,G.jsx)(Vm,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:`暂无偏好数据`}),(0,G.jsx)(`p`,{className:`text-xs mt-1`,children:`点击「新建偏好」开始构建你的画像`})]})]})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{id:`pref-slot-list`,className:`space-y-4`,children:pe.map(([e,n])=>(0,G.jsx)(she,{slot:e,preferences:n,onEdit:e=>F(e),onDelete:e=>z(e)},e))}),fe>1&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`第 `,W,` / `,fe,` 页 · 共 `,de.length,` 个分组`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(q,{variant:`outline`,size:`icon`,className:`size-8`,disabled:W<=1,onClick:()=>{ne(e=>Math.max(1,e-1)),document.getElementById(`pref-slot-list`)?.scrollIntoView({behavior:`smooth`,block:`start`})},children:(0,G.jsx)(Qp,{className:`size-4`})}),Array.from({length:fe},(e,n)=>n+1).map(e=>(0,G.jsx)(q,{variant:e===W?`default`:`outline`,size:`icon`,className:Tp(`size-8 text-xs`,e===W&&`bg-gradient-to-r from-amber-500 to-orange-500 text-white border-0`),onClick:()=>{ne(e),document.getElementById(`pref-slot-list`)?.scrollIntoView({behavior:`smooth`,block:`start`})},children:e},e)),(0,G.jsx)(q,{variant:`outline`,size:`icon`,className:`size-8`,disabled:W>=fe,onClick:()=>{ne(e=>Math.min(fe,e+1)),document.getElementById(`pref-slot-list`)?.scrollIntoView({behavior:`smooth`,block:`start`})},children:(0,G.jsx)($p,{className:`size-4`})})]})]})]})]}),(0,G.jsx)(R7,{value:`overview`,className:`space-y-6`,children:p?(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[1,2,3,4].map(e=>(0,G.jsx)(Cb,{className:`h-48 w-full rounded-xl`},e))}):(0,G.jsxs)(G.Fragment,{children:[le.length>0&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(zm,{className:`size-5 text-amber-500`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:`画像特征`}),(0,G.jsxs)(CJ,{variant:`secondary`,className:`text-[10px]`,children:[le.length,` 条`]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:le.map(({fact:e,factObj:n,isPrivate:r,meta:i})=>{let a=i.icon,o=A.has(e),s=r&&o&&n?.l2_content||G9(e);return(0,G.jsx)(vb,{className:Tp(`relative overflow-hidden border transition-all duration-200 hover:shadow-md`,r&&!o&&`border-amber-200 dark:border-amber-500/30`),children:(0,G.jsxs)(Sb,{className:`p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,G.jsx)(`div`,{className:Tp(`flex items-center justify-center size-8 rounded-lg border`,i.bgColor),children:(0,G.jsx)(a,{className:Tp(`size-4`,i.color)})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,G.jsxs)(CJ,{variant:`outline`,className:`text-[10px] gap-1 bg-amber-50 dark:bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-500/30`,children:[(0,G.jsx)(Em,{className:`size-2.5`}),`私密`]}),(0,G.jsx)(CJ,{variant:`outline`,className:Tp(`text-[10px]`,i.bgColor,i.color),children:i.label})]})]}),(0,G.jsx)(`div`,{className:Tp(r&&!o&&`blur-[6px] select-none opacity-40`),children:(0,G.jsx)(q9,{content:s})}),r&&!o&&(0,G.jsx)(`button`,{type:`button`,className:`mt-3 w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg bg-amber-50 dark:bg-amber-500/10 text-amber-700 dark:text-amber-300 text-xs font-medium hover:bg-amber-100 dark:hover:bg-amber-500/20 transition-colors border border-amber-200 dark:border-amber-500/30 cursor-pointer`,onClick:()=>oe(e),children:o?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(om,{className:`size-3.5`}),`已解锁`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Em,{className:`size-3.5`}),`点击解锁私密内容`]})})]})},`sf-${e.slice(0,40)}`)})})]}),ce.length>0&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(k7,{}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(zp,{className:`size-5 text-blue-500`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:`静态偏好`}),(0,G.jsxs)(CJ,{variant:`secondary`,className:`text-[10px]`,children:[ce.length,` 条`]})]}),(0,G.jsxs)(`div`,{className:`relative pl-6 space-y-3`,children:[(0,G.jsx)(`div`,{className:`absolute left-[11px] top-2 bottom-2 w-px bg-gradient-to-b from-blue-300 via-orange-300 to-transparent dark:from-blue-500/40 dark:via-orange-500/40 dark:to-transparent`}),ce.map((e,n)=>{let r=W9(e),i=r.icon;return(0,G.jsxs)(`div`,{className:`relative group`,children:[(0,G.jsx)(`div`,{className:`absolute -left-6 top-2.5 size-[22px] rounded-full bg-gradient-to-br from-blue-400 to-orange-400 ring-[3px] ring-background flex items-center justify-center shadow-sm group-hover:scale-110 transition-transform`,children:(0,G.jsx)(`span`,{className:`text-[9px] font-bold text-white`,children:n+1})}),(0,G.jsx)(vb,{className:`overflow-hidden hover:shadow-sm transition-shadow`,children:(0,G.jsxs)(Sb,{className:`p-3.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,G.jsx)(`div`,{className:Tp(`flex items-center justify-center size-5 rounded-md border`,r.bgColor),children:(0,G.jsx)(i,{className:Tp(`size-3`,r.color)})}),(0,G.jsx)(`span`,{className:Tp(`text-[10px] font-medium px-1.5 py-0.5 rounded border`,r.bgColor,r.color),children:r.label})]}),(0,G.jsx)(q9,{content:G9(e)})]})})]},`dc-${n}`)})]})]}),le.length===0&&ce.length===0&&(0,G.jsx)(vb,{className:`border-dashed`,children:(0,G.jsxs)(Sb,{className:`py-16 flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-2xl bg-muted`,children:(0,G.jsx)(Zm,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:`暂无画像数据`}),(0,G.jsx)(`p`,{className:`text-xs mt-1`,children:`存储更多记忆后,系统将自动构建您的用户画像`})]})]})})]})}),(0,G.jsx)(R7,{value:`changelog`,className:`space-y-4`,children:p?(0,G.jsx)(`div`,{className:`space-y-3`,children:[1,2,3].map(e=>(0,G.jsx)(Cb,{className:`h-20 w-full rounded-xl`},e))}):d.length===0?(0,G.jsx)(vb,{className:`border-dashed`,children:(0,G.jsxs)(Sb,{className:`py-16 flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-2xl bg-muted`,children:(0,G.jsx)(mm,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:`暂无变更记录`}),(0,G.jsx)(`p`,{className:`text-xs mt-1`,children:`偏好变更时将自动记录在这里`})]})]})}):(()=>{let e=Math.ceil(d.length/10),n=d.slice((re-1)*10,re*10);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`relative pl-6 space-y-3`,children:[(0,G.jsx)(`div`,{className:`absolute left-[11px] top-2 bottom-2 w-px bg-gradient-to-b from-violet-300 via-sky-300 to-transparent dark:from-violet-500/40 dark:via-sky-500/40 dark:to-transparent`}),n.map(e=>{let n=e.action===`created`,r=e.action===`updated`,i=n?{bg:`from-emerald-400 to-teal-400`,color:`text-emerald-700 dark:text-emerald-300`,badgeClass:`bg-emerald-50 dark:bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border-emerald-200 dark:border-emerald-500/30`,symbol:`+`,label:`创建`}:r?{bg:`from-blue-400 to-sky-400`,color:`text-blue-700 dark:text-blue-300`,badgeClass:`bg-blue-50 dark:bg-blue-500/10 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-500/30`,symbol:`~`,label:`更新`}:{bg:`from-rose-400 to-red-400`,color:`text-rose-700 dark:text-rose-300`,badgeClass:`bg-rose-50 dark:bg-rose-500/10 text-rose-700 dark:text-rose-300 border-rose-200 dark:border-rose-500/30`,symbol:`−`,label:`删除`};return(0,G.jsxs)(`div`,{className:`relative group min-w-0`,children:[(0,G.jsx)(`div`,{className:Tp(`absolute -left-6 top-2.5 size-[22px] rounded-full bg-gradient-to-br ring-[3px] ring-background flex items-center justify-center shadow-sm group-hover:scale-110 transition-transform`,i.bg),children:(0,G.jsx)(`span`,{className:`text-[9px] font-bold text-white`,children:i.symbol})}),(0,G.jsx)(vb,{className:`overflow-hidden hover:shadow-sm transition-shadow min-w-0`,children:(0,G.jsxs)(Sb,{className:`p-4 space-y-2 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,G.jsxs)(CJ,{variant:`outline`,className:Tp(`text-[10px] gap-1 shrink-0`,i.badgeClass),children:[n?(0,G.jsx)(Nm,{className:`size-2.5`}):r?(0,G.jsx)(Mm,{className:`size-2.5`}):(0,G.jsx)(Km,{className:`size-2.5`}),i.label]}),e.source&&(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate`,children:e.source}),(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto shrink-0`,children:K9(e.created_at)})]}),e.old_value&&(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground line-through break-all`,children:e.old_value}),e.new_value&&(0,G.jsx)(`p`,{className:`text-sm leading-relaxed break-words`,children:e.new_value})]})})]},e.id)})]}),e>1&&(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 pt-2`,children:[(0,G.jsxs)(q,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:re<=1,onClick:()=>ie(e=>Math.max(1,e-1)),children:[(0,G.jsx)(Qp,{className:`size-3`}),`上一页`]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1`,children:Array.from({length:e},(e,n)=>n+1).map(e=>(0,G.jsx)(q,{variant:re===e?`default`:`ghost`,size:`sm`,className:`h-7 w-7 text-xs p-0`,onClick:()=>ie(e),children:e},e))}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:re>=e,onClick:()=>ie(n=>Math.min(e,n+1)),children:[`下一页`,(0,G.jsx)($p,{className:`size-3`})]})]})]})})()})]})]}),(0,G.jsx)(pJ,{open:!!R,onOpenChange:e=>{!e&&!ee&&z(null)},children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除偏好`}),(0,G.jsxs)(vJ,{children:[`确定要删除这条偏好吗?此操作不可撤销。`,R&&(0,G.jsx)(`span`,{className:`block mt-2 px-3 py-2 rounded-lg bg-muted text-sm text-foreground truncate`,children:R.value})]})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{disabled:ee,children:`取消`}),(0,G.jsx)(yJ,{disabled:ee,onClick:_e,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:ee?`删除中...`:`删除`})]})]})}),(0,G.jsx)(J9,{open:M,onOpenChange:N,saving:I,onSubmit:he,title:`新建偏好`}),(0,G.jsx)(J9,{open:!!P,onOpenChange:e=>{e||F(null)},saving:I,onSubmit:e=>{P&&ge(P.id,e)},pref:P,title:`编辑偏好`}),(0,G.jsx)(A9,{open:b,onOpenChange:e=>{e||(x(!1),T(``),D(null))},children:(0,G.jsxs)(j9,{className:`sm:max-w-sm`,children:[(0,G.jsxs)(M9,{children:[(0,G.jsxs)(P9,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Em,{className:`size-4 text-amber-500`}),`解锁私密记忆`]}),(0,G.jsx)(F9,{children:`请输入您的 Vault 密码以解锁受保护的内容。`})]}),(0,G.jsx)(`div`,{className:`space-y-3`,children:(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{className:`text-xs`,children:`密码`}),(0,G.jsx)(hb,{type:`password`,placeholder:`输入 Vault 密码...`,value:w,onChange:e=>{T(e.target.value),D(null)},onKeyDown:e=>e.key===`Enter`&&ae(),className:E?`border-destructive`:``,autoFocus:!0}),E&&(0,G.jsx)(`p`,{className:`text-xs text-destructive`,children:E})]})}),(0,G.jsxs)(N9,{children:[(0,G.jsx)(q,{variant:`outline`,onClick:()=>x(!1),disabled:O,children:`取消`}),(0,G.jsx)(q,{onClick:ae,disabled:O||!w.trim(),children:O?`解锁中...`:`解锁`})]})]})})]})}function she({slot:e,preferences:n,onEdit:r,onDelete:i}){let[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(4),l=ihe(e),u=n.slice(0,s),d=s<n.length;return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2.5 w-full group cursor-pointer text-left border-none bg-transparent p-0`,onClick:()=>{o(!a),c(4)},children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-7 rounded-lg bg-gradient-to-br from-amber-100 to-orange-100 dark:from-amber-500/15 dark:to-orange-500/15 border border-amber-200/60 dark:border-amber-500/20`,children:(0,G.jsx)(l,{className:`size-3.5 text-amber-600 dark:text-amber-400`})}),(0,G.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:rhe(e)}),(0,G.jsx)(CJ,{variant:`secondary`,className:`text-[10px]`,children:n.length}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)($p,{className:Tp(`size-4 text-muted-foreground transition-transform duration-200`,!a&&`rotate-90`)})]}),!a&&(0,G.jsxs)(`div`,{className:`space-y-2.5 pl-9`,children:[(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2.5`,children:u.map(e=>(0,G.jsx)(che,{pref:e,onEdit:r,onDelete:i},e.id))}),d&&(0,G.jsxs)(`button`,{type:`button`,className:`w-full flex items-center justify-center gap-1.5 py-2 text-xs text-muted-foreground hover:text-foreground transition-colors rounded-lg hover:bg-muted/50 cursor-pointer`,onClick:()=>c(e=>Math.min(e+4,n.length)),children:[(0,G.jsx)(Zp,{className:`size-3.5`}),`加载更多(剩余 `,n.length-s,` 条)`]})]})]})}function che({pref:e,onEdit:n,onDelete:r}){let i=ahe[e.scope]||{className:`bg-slate-50 dark:bg-slate-500/10 text-slate-700 dark:text-slate-300 border-slate-200 dark:border-slate-500/30`,label:e.scope};return(0,G.jsx)(vb,{className:`group hover:shadow-md transition-all duration-200 border-border/60`,children:(0,G.jsxs)(Sb,{className:`p-3.5 space-y-2.5`,children:[(0,G.jsx)(`p`,{className:`text-sm leading-relaxed whitespace-pre-wrap break-words`,children:e.value}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,G.jsx)(CJ,{variant:`outline`,className:Tp(`text-[10px] gap-1`,i.className),children:i.label}),e.project_path&&(0,G.jsxs)(CJ,{variant:`outline`,className:`text-[10px] gap-1 bg-violet-50 dark:bg-violet-500/10 text-violet-700 dark:text-violet-300 border-violet-200 dark:border-violet-500/30`,children:[(0,G.jsx)(dm,{className:`size-2.5`}),e.project_path.split(`/`).pop()]}),(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:K9(e.updated_at)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity pt-1 border-t border-border/40`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] text-muted-foreground mr-auto`,children:[`置信度 `,(e.confidence*100).toFixed(0),`%`]}),(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7 text-muted-foreground hover:text-foreground`,onClick:()=>n(e),children:(0,G.jsx)(Mm,{className:`size-3.5`})}),(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7 text-muted-foreground hover:text-destructive`,onClick:()=>r(e),children:(0,G.jsx)(Km,{className:`size-3.5`})})]})]})})}function J9({open:e,onOpenChange:n,saving:r,onSubmit:i,pref:a,title:o}){let s=!!a,[c,l]=(0,y.useState)(a?.slot||``),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(a?.value||``),[m,h]=(0,y.useState)(String(a?.confidence??.8)),[g,_]=(0,y.useState)(a?.scope||`global`),[v,b]=(0,y.useState)(a?.project_path||``);(0,y.useEffect)(()=>{if(e){let e=a?.slot||``;l(e),d(e.startsWith(`custom:`)?e.slice(7):``),p(a?.value||``),h(String(a?.confidence??.8)),_(a?.scope||`global`),b(a?.project_path||``)}},[e,a]);let x=c===`__custom__`;return(0,G.jsx)(A9,{open:e,onOpenChange:n,children:(0,G.jsxs)(j9,{className:`sm:max-w-md`,children:[(0,G.jsxs)(M9,{children:[(0,G.jsxs)(P9,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Vm,{className:`size-4 text-amber-500`}),o]}),(0,G.jsx)(F9,{children:s?`修改偏好信息。`:`添加一条新的偏好。`})]}),(0,G.jsxs)(`div`,{className:`space-y-4 py-1`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{className:`text-xs`,children:`Slot (类别)`}),s?(0,G.jsx)(hb,{value:c,disabled:!0,className:`h-9 bg-muted/60`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(_9,{value:c||void 0,onValueChange:e=>e!=null&&l(e),children:[(0,G.jsx)(y9,{className:`h-9 w-full`,children:(0,G.jsx)(v9,{placeholder:`选择类别...`})}),(0,G.jsxs)(b9,{children:[ehe.map(e=>(0,G.jsx)(x9,{value:e.name,children:e.display},e.name)),(0,G.jsx)(x9,{value:`__custom__`,children:`自定义 (custom:...)`})]})]}),x&&(0,G.jsx)(hb,{placeholder:`自定义 slot 名 (小写字母+数字+下划线)`,value:u,onChange:e=>{d(e.target.value.replace(/[^a-z0-9_]/g,``))},className:`h-9`,maxLength:50})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{className:`text-xs`,children:`范围`}),(0,G.jsxs)(_9,{value:g,onValueChange:e=>e!=null&&_(e),children:[(0,G.jsx)(y9,{className:`h-9`,children:(0,G.jsx)(v9,{})}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`global`,children:`全局`}),(0,G.jsx)(x9,{value:`project`,children:`项目`}),(0,G.jsx)(x9,{value:`session`,children:`会话`})]})]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{className:`text-xs`,children:`内容`}),(0,G.jsx)(T9,{placeholder:`偏好内容...`,value:f,onChange:e=>p(e.target.value),rows:3,className:`resize-none`,maxLength:500})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{className:`text-xs`,children:`置信度 (0-1)`}),(0,G.jsx)(hb,{type:`number`,min:`0`,max:`1`,step:`0.1`,value:m,onChange:e=>h(e.target.value),className:`h-9`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{className:`text-xs`,children:`项目路径 (可选)`}),(0,G.jsx)(hb,{placeholder:`例: /path/to/project`,value:v,onChange:e=>b(e.target.value),className:`h-9`,maxLength:200})]})]})]}),(0,G.jsxs)(N9,{children:[(0,G.jsx)(q,{variant:`outline`,onClick:()=>n(!1),disabled:r,children:`取消`}),(0,G.jsx)(q,{onClick:()=>{let e=x?`custom:${u.trim()}`:c.trim();if(!e||!f.trim()){ir.error(`请填写 Slot 和内容`);return}if(x&&!u.trim()){ir.error(`请填写自定义 Slot 名`);return}if(s){let e={};f!==(a?.value||``)&&(e.value=f.trim()),m!==String(a?.confidence??.8)&&(e.confidence=parseFloat(m)),g!==(a?.scope||`global`)&&(e.scope=g),v!==(a?.project_path||``)&&(e.project_path=v.trim()||void 0),i(e)}else i({slot:e,value:f.trim(),confidence:parseFloat(m)||.8,scope:g,project_path:v.trim()||void 0})},disabled:r||!f.trim()||(x?!u.trim():!c.trim()),className:`bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white`,children:r?s?`保存中...`:`创建中...`:s?`保存`:`创建`})]})]})})}var Y9=y.createContext(void 0);function lhe(){let e=y.useContext(Y9);if(e===void 0)throw Error(Ir(63));return e}var X9=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Z9={...lb,checked(e){return e?{[X9.checked]:``}:{[X9.unchecked]:``}}};function uhe(e,n,r,i=!0,a){let[o,s]=y.useState(),c=yd(a?`${a}-label`:void 0),l=e??n??o;return Pr(()=>{let a=e||n||!i?void 0:dhe(r.current,c);o!==a&&s(a)}),l}function dhe(e,n){let r=fhe(e);if(r)return!r.id&&n&&(r.id=n),r.id||void 0}function fhe(e){if(!e)return;let n=e.parentElement;if(n&&n.tagName===`LABEL`)return n;let r=e.id;if(r){let n=e.nextElementSibling;if(n&&n.htmlFor===r)return n}let i=e.labels;return i&&i[0]}var phe=y.forwardRef(function(e,n){let{checked:r,className:i,defaultChecked:a,"aria-labelledby":o,form:s,id:c,inputRef:l,name:u,nativeButton:d=!1,onCheckedChange:f,readOnly:p=!1,required:m=!1,disabled:h=!1,render:g,uncheckedValue:_,value:v,style:b,...x}=e,{clearErrors:S}=db(),{state:C,setTouched:w,setDirty:T,validityData:E,setFilled:D,setFocused:O,shouldValidateOnChange:k,validationMode:A,disabled:j,name:M,validation:N}=ub(),{labelId:P}=fb(),F=j||h,I=M??u,L=Ca(f),R=y.useRef(null),z=pa(R,l,N.inputRef),ee=y.useRef(null),B=yd(),V=mb({id:c,implicit:!1,controlRef:ee}),H=d?void 0:V,[U,te]=Rg({controlled:r,default:!!a,name:`Switch`,state:`checked`});pb(ee,{id:B,value:U}),Pr(()=>{R.current&&D(R.current.checked)},[R,D]),cg(U,()=>{S(I),T(U!==E.initialValue),D(U),k()?N.commit(U):N.commit(U,!0)});let{getButtonProps:W,buttonRef:ne}=mh({disabled:F,native:d}),re=uhe(o,P,R,!d,H),ie={id:d?V:B,role:`switch`,"aria-checked":U,"aria-readonly":p||void 0,"aria-required":m||void 0,"aria-labelledby":re,onFocus(){F||O(!0)},onBlur(){let e=R.current;!e||F||(w(!0),O(!1),A===`onBlur`&&N.commit(e.checked))},onClick(e){p||F||(e.preventDefault(),R.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},ae=y.useMemo(()=>Rs({checked:U,disabled:F,form:s,id:H,name:I,required:m,style:I?Na:Ma,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:z,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(p){e.preventDefault();return}let n=e.currentTarget.checked,r=Ii(xi,e.nativeEvent);L?.(n,r),!r.isCanceled&&te(n)},onFocus(){ee.current?.focus()}},N.getInputValidationProps,v===void 0?hi:{value:v}),[U,F,s,z,H,I,L,p,m,te,N,v]),oe=y.useMemo(()=>({...C,checked:U,disabled:F,readOnly:p,required:m}),[C,U,F,p,m]),se=Qs(`span`,e,{state:oe,ref:[n,ee,ne],props:[ie,N.getValidationProps,x,W],stateAttributesMapping:Z9});return(0,G.jsxs)(Y9.Provider,{value:oe,children:[se,!U&&I&&_!==void 0&&(0,G.jsx)(`input`,{type:`hidden`,form:s,name:I,value:_}),(0,G.jsx)(`input`,{...ae,suppressHydrationWarning:!0})]})}),mhe=y.forwardRef(function(e,n){let{render:r,className:i,style:a,...o}=e,{state:s}=ub(),c=lhe();return Qs(`span`,e,{state:{...s,...c},ref:n,stateAttributesMapping:Z9,props:o})});function hhe({className:e,size:n=`default`,...r}){return(0,G.jsx)(phe,{"data-slot":`switch`,"data-size":n,className:Tp(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...r,children:(0,G.jsx)(mhe,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}var Q9={list(){return ib.get(`/v1/categories`)},get(e){return ib.get(`/v1/categories/${encodeURIComponent(e)}`)},create(e){return ib.post(`/v1/categories`,e)},update(e,n){return ib.put(`/v1/categories/${encodeURIComponent(e)}`,n)},delete(e){return ib.delete(`/v1/categories/${encodeURIComponent(e)}`)},listAliases(){return ib.get(`/v1/categories/aliases`)},createAlias(e,n){return ib.post(`/v1/categories/aliases`,{alias:e,target:n})},deleteAlias(e){return ib.delete(`/v1/categories/aliases/${encodeURIComponent(e)}`)}},$9={name:``,display_name:``,description:``,decision_rule:``,always_merge:!1,append_only:!1,temporal_versioned:!1,merge_supported:!1,admission_weight:.5,importance_base:.5,prompt_format:``,default_visibility:`global`,default_scope:`global`,default_ttl_days:0,sort_order:100,is_active:!0};function ghe(){let[e,n]=(0,y.useState)([]),[r,i]=(0,y.useState)([]),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)($9),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)(``),[S,C]=(0,y.useState)(null),w=(0,y.useCallback)(async()=>{try{let e=await Q9.list();n(Array.isArray(e)?e:[])}catch{ir.error(`加载分类失败`)}},[]),T=(0,y.useCallback)(async()=>{try{let e=await Q9.listAliases();i(Array.isArray(e)?e:[])}catch{ir.error(`加载别名失败`)}},[]);(0,y.useEffect)(()=>{Promise.all([w(),T()]).finally(()=>o(!1))},[w,T]);let E=()=>{c(null),f($9),u(!0)},D=e=>{c(e),f({name:e.name,display_name:e.display_name,description:e.description,decision_rule:e.decision_rule||``,always_merge:e.always_merge,append_only:e.append_only,temporal_versioned:e.temporal_versioned,merge_supported:e.merge_supported,admission_weight:e.admission_weight,importance_base:e.importance_base,prompt_format:e.prompt_format||``,default_visibility:e.default_visibility,default_scope:e.default_scope,default_ttl_days:e.default_ttl_days||0,sort_order:e.sort_order,is_active:e.is_active}),u(!0)};return a?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-64 text-muted-foreground`,children:`加载中...`}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-bold`,children:`分类字典`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`管理记忆分类和别名映射`})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(q,{variant:`outline`,onClick:()=>g(!0),children:[(0,G.jsx)(wm,{className:`size-4 mr-1`}),`添加别名`]}),(0,G.jsxs)(q,{onClick:E,children:[(0,G.jsx)(Nm,{className:`size-4 mr-1`}),`新建分类`]})]})]}),(0,G.jsx)(k7,{}),r.length>0&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,G.jsx)(wm,{className:`size-4`}),`别名映射 (`,r.length,`)`]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:r.map(e=>(0,G.jsxs)(vb,{className:`p-3 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,G.jsx)(`code`,{className:`bg-muted px-1.5 py-0.5 rounded text-xs`,children:e.alias}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,G.jsx)(`code`,{className:`bg-muted px-1.5 py-0.5 rounded text-xs`,children:e.target})]}),(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7 text-destructive hover:text-destructive`,onClick:()=>C(e.alias),children:(0,G.jsx)($m,{className:`size-3.5`})})]},e.alias))}),(0,G.jsx)(k7,{})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,G.jsx)(Wm,{className:`size-4`}),`分类列表 (`,e.length,`)`]}),(0,G.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,G.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,G.jsx)(`thead`,{className:`bg-muted/50`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`名称`}),(0,G.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`显示名`}),(0,G.jsx)(`th`,{className:`text-left p-3 font-medium hidden md:table-cell`,children:`描述`}),(0,G.jsx)(`th`,{className:`text-center p-3 font-medium`,children:`权重`}),(0,G.jsx)(`th`,{className:`text-center p-3 font-medium`,children:`状态`}),(0,G.jsx)(`th`,{className:`text-right p-3 font-medium`,children:`操作`})]})}),(0,G.jsx)(`tbody`,{className:`divide-y`,children:e.map(e=>(0,G.jsxs)(`tr`,{className:`hover:bg-muted/30`,children:[(0,G.jsx)(`td`,{className:`p-3`,children:(0,G.jsx)(`code`,{className:`bg-muted px-1.5 py-0.5 rounded text-xs`,children:e.name})}),(0,G.jsx)(`td`,{className:`p-3 font-medium`,children:e.display_name}),(0,G.jsx)(`td`,{className:`p-3 text-muted-foreground hidden md:table-cell max-w-[200px] truncate`,children:e.description}),(0,G.jsx)(`td`,{className:`p-3 text-center`,children:(0,G.jsx)(`span`,{className:`text-xs`,children:e.admission_weight.toFixed(2)})}),(0,G.jsx)(`td`,{className:`p-3 text-center`,children:(0,G.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${e.is_active?`bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400`:`bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-400`}`,children:e.is_active?`启用`:`禁用`})}),(0,G.jsx)(`td`,{className:`p-3 text-right`,children:(0,G.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>D(e),children:(0,G.jsx)(ree,{className:`size-3.5`})}),(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7 text-destructive hover:text-destructive`,onClick:()=>m(e.name),children:(0,G.jsx)(Km,{className:`size-3.5`})})]})})]},e.name))})]})})]}),(0,G.jsx)(A9,{open:l,onOpenChange:u,children:(0,G.jsxs)(j9,{className:`max-w-lg max-h-[80vh] overflow-y-auto`,children:[(0,G.jsx)(M9,{children:(0,G.jsx)(P9,{children:s?`编辑分类`:`新建分类`})}),(0,G.jsxs)(`div`,{className:`space-y-4 py-2`,children:[!s&&(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`名称 (name)`}),(0,G.jsx)(hb,{value:d.name,onChange:e=>f(n=>({...n,name:e.target.value.toLowerCase()})),placeholder:`e.g. preferences`,maxLength:50})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`显示名 (display_name)`}),(0,G.jsx)(hb,{value:d.display_name,onChange:e=>f(n=>({...n,display_name:e.target.value})),placeholder:`e.g. 偏好设置`,maxLength:100})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`描述`}),(0,G.jsx)(hb,{value:d.description,onChange:e=>f(n=>({...n,description:e.target.value})),placeholder:`分类描述`,maxLength:500})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`决策规则 (decision_rule)`}),(0,G.jsx)(hb,{value:d.decision_rule,onChange:e=>f(n=>({...n,decision_rule:e.target.value})),placeholder:`可选`,maxLength:200})]}),(0,G.jsx)(k7,{}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`准入权重`}),(0,G.jsx)(hb,{type:`number`,step:.05,min:0,max:1,value:d.admission_weight,onChange:e=>f(n=>({...n,admission_weight:+e.target.value}))})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`重要性基数`}),(0,G.jsx)(hb,{type:`number`,step:.05,min:0,max:1,value:d.importance_base,onChange:e=>f(n=>({...n,importance_base:+e.target.value}))})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`排序`}),(0,G.jsx)(hb,{type:`number`,value:d.sort_order,onChange:e=>f(n=>({...n,sort_order:+e.target.value}))})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`默认TTL (天)`}),(0,G.jsx)(hb,{type:`number`,value:d.default_ttl_days,onChange:e=>f(n=>({...n,default_ttl_days:+e.target.value}))})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`提示格式 (prompt_format)`}),(0,G.jsx)(hb,{value:d.prompt_format,onChange:e=>f(n=>({...n,prompt_format:e.target.value})),placeholder:`可选`,maxLength:500})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`默认可见性`}),(0,G.jsxs)(`select`,{className:`w-full h-9 rounded-md border border-input bg-background px-3 text-sm`,value:d.default_visibility,onChange:e=>f(n=>({...n,default_visibility:e.target.value})),children:[(0,G.jsx)(`option`,{value:`global`,children:`global`}),(0,G.jsx)(`option`,{value:`project`,children:`project`}),(0,G.jsx)(`option`,{value:`private`,children:`private`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`默认作用域`}),(0,G.jsxs)(`select`,{className:`w-full h-9 rounded-md border border-input bg-background px-3 text-sm`,value:d.default_scope,onChange:e=>f(n=>({...n,default_scope:e.target.value})),children:[(0,G.jsx)(`option`,{value:`global`,children:`global`}),(0,G.jsx)(`option`,{value:`project`,children:`project`})]})]})]}),(0,G.jsx)(k7,{}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[[`always_merge`,`始终合并`],[`append_only`,`仅追加`],[`temporal_versioned`,`时序版本`],[`merge_supported`,`支持合并`],[`is_active`,`启用`]].map(([e,n])=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border p-3`,children:[(0,G.jsx)(gb,{className:`text-sm`,children:n}),(0,G.jsx)(hhe,{checked:d[e],onCheckedChange:n=>f(r=>({...r,[e]:n}))})]},e))})]}),(0,G.jsxs)(N9,{children:[(0,G.jsx)(q,{variant:`outline`,onClick:()=>u(!1),children:`取消`}),(0,G.jsx)(q,{onClick:async()=>{if(!d.name.trim()||!d.display_name.trim()){ir.error(`名称和显示名为必填项`);return}try{let e={...d,decision_rule:d.decision_rule||null,prompt_format:d.prompt_format||null,default_ttl_days:d.default_ttl_days||null};s?(await Q9.update(s.name,e),ir.success(`分类已更新`)):(await Q9.create(e),ir.success(`分类已创建`)),u(!1),w()}catch(e){let n=e instanceof Error?e.message:`操作失败`;ir.error(n)}},children:s?`保存`:`创建`})]})]})}),(0,G.jsx)(pJ,{open:!!p,onOpenChange:()=>m(null),children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除分类`}),(0,G.jsxs)(vJ,{children:[`确定要删除分类 "`,p,`" 吗?此操作不可撤销。`]})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{children:`取消`}),(0,G.jsx)(yJ,{onClick:async()=>{if(p)try{await Q9.delete(p),ir.success(`分类已删除`),m(null),w()}catch{ir.error(`删除失败`)}},children:`删除`})]})]})}),(0,G.jsx)(A9,{open:h,onOpenChange:g,children:(0,G.jsxs)(j9,{className:`max-w-sm`,children:[(0,G.jsx)(M9,{children:(0,G.jsx)(P9,{children:`添加别名`})}),(0,G.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`别名`}),(0,G.jsx)(hb,{value:_,onChange:e=>v(e.target.value),placeholder:`e.g. likes`,maxLength:50})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`目标分类`}),(0,G.jsxs)(`select`,{className:`w-full h-9 rounded-md border border-input bg-background px-3 text-sm`,value:b,onChange:e=>x(e.target.value),children:[(0,G.jsx)(`option`,{value:``,children:`选择分类...`}),e.map(e=>(0,G.jsxs)(`option`,{value:e.name,children:[e.display_name,` (`,e.name,`)`]},e.name))]})]})]}),(0,G.jsxs)(N9,{children:[(0,G.jsx)(q,{variant:`outline`,onClick:()=>g(!1),children:`取消`}),(0,G.jsx)(q,{onClick:async()=>{if(!_.trim()||!b.trim()){ir.error(`别名和目标分类为必填项`);return}try{await Q9.createAlias(_,b),ir.success(`别名已创建`),g(!1),v(``),x(``),T()}catch(e){let n=e instanceof Error?e.message:`创建别名失败`;ir.error(n)}},children:`创建`})]})]})}),(0,G.jsx)(pJ,{open:!!S,onOpenChange:()=>C(null),children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除别名`}),(0,G.jsxs)(vJ,{children:[`确定要删除别名 "`,S,`" 吗?`]})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{children:`取消`}),(0,G.jsx)(yJ,{onClick:async()=>{if(S)try{await Q9.deleteAlias(S),ir.success(`别名已删除`),C(null),T()}catch{ir.error(`删除别名失败`)}},children:`删除`})]})]})})]})}function _he(){let e=et();return(0,G.jsx)(`div`,{className:`flex h-screen w-full flex-col items-center justify-center bg-background text-foreground`,children:(0,G.jsxs)(`div`,{className:`text-center space-y-6`,children:[(0,G.jsx)(`div`,{className:`text-8xl font-bold text-muted-foreground/30`,children:`404`}),(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`页面不存在`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-sm`,children:`您访问的页面可能已经删除、移动,或者从未存在过。`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,G.jsxs)(q,{variant:`outline`,onClick:()=>e(-1),children:[(0,G.jsx)(Vp,{className:`h-4 w-4 mr-2`}),`返回上一页`]}),(0,G.jsxs)(q,{onClick:()=>e(`/dashboard`),children:[(0,G.jsx)(hm,{className:`h-4 w-4 mr-2`}),`返回首页`]})]})]})})}var vhe=class extends y.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){console.error(`ErrorBoundary caught an error:`,e,n)}handleRefresh=()=>{window.location.reload()};handleGoHome=()=>{window.location.href=`/`};render(){return this.state.hasError?(0,G.jsx)(`div`,{className:`flex h-screen w-full flex-col items-center justify-center bg-background text-foreground`,children:(0,G.jsxs)(`div`,{className:`text-center space-y-6 max-w-md px-4`,children:[(0,G.jsx)(`div`,{className:`text-6xl font-bold text-destructive/30`,children:`⚠️`}),(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`出错了`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`应用遇到了意外错误。请尝试刷新页面,或返回首页。`}),this.state.error&&(0,G.jsx)(`div`,{className:`rounded-lg bg-muted p-4 text-left`,children:(0,G.jsx)(`p`,{className:`text-xs font-mono text-muted-foreground break-all`,children:this.state.error.message})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,G.jsxs)(q,{variant:`outline`,onClick:this.handleRefresh,children:[(0,G.jsx)(Pm,{className:`h-4 w-4 mr-2`}),`刷新页面`]}),(0,G.jsxs)(q,{onClick:this.handleGoHome,children:[(0,G.jsx)(hm,{className:`h-4 w-4 mr-2`}),`返回首页`]})]})]})}):this.props.children}};function yhe({children:e}){let n=dh(e=>e.isAuthenticated),r=typeof window<`u`&&window.localStorage.getItem(`e2e_bypass_auth`)===`true`;return n||r?e:(0,G.jsx)(Ot,{to:`/login`,replace:!0})}function bhe(){return(0,G.jsx)(vhe,{children:(0,G.jsxs)(Mt,{children:[(0,G.jsx)(At,{path:`/login`,element:(0,G.jsx)(_b,{})}),(0,G.jsxs)(At,{path:`/*`,element:(0,G.jsx)(yhe,{children:(0,G.jsx)(Ree,{})}),children:[(0,G.jsx)(At,{index:!0,element:(0,G.jsx)(Ot,{to:`/dashboard`,replace:!0})}),(0,G.jsx)(At,{path:`dashboard`,element:(0,G.jsx)(fJ,{})}),(0,G.jsx)(At,{path:`memories`,element:(0,G.jsx)(RJ,{})}),(0,G.jsx)(At,{path:`memories/:id`,element:(0,G.jsx)(pme,{})}),(0,G.jsx)(At,{path:`memories/new`,element:(0,G.jsx)(E9,{})}),(0,G.jsx)(At,{path:`memories/:id/edit`,element:(0,G.jsx)(E9,{})}),(0,G.jsx)(At,{path:`memories/:id/edit-insight`,element:(0,G.jsx)(vme,{})}),(0,G.jsx)(At,{path:`vault`,element:(0,G.jsx)(xme,{})}),(0,G.jsx)(At,{path:`spaces`,element:(0,G.jsx)(Lme,{})}),(0,G.jsx)(At,{path:`sessions`,element:(0,G.jsx)(Cme,{})}),(0,G.jsx)(At,{path:`sessions/:id`,element:(0,G.jsx)(Nme,{})}),(0,G.jsx)(At,{path:`analytics`,element:(0,G.jsx)(Rme,{})}),(0,G.jsx)(At,{path:`tier-history`,element:(0,G.jsx)(Bme,{})}),(0,G.jsx)(At,{path:`lifecycle`,element:(0,G.jsx)(Yme,{})}),(0,G.jsx)(At,{path:`import`,element:(0,G.jsx)(V9,{})}),(0,G.jsx)(At,{path:`profile`,element:(0,G.jsx)(ohe,{})}),(0,G.jsx)(At,{path:`settings`,element:(0,G.jsx)(Xme,{})}),(0,G.jsx)(At,{path:`categories`,element:(0,G.jsx)(ghe,{})}),(0,G.jsx)(At,{path:`*`,element:(0,G.jsx)(_he,{})})]})]})})}(0,x.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(y.StrictMode,{children:(0,G.jsx)(Sn,{children:(0,G.jsx)(Sr,{defaultTheme:`dark`,storageKey:`omem-theme`,children:(0,G.jsxs)(Dp,{children:[(0,G.jsx)(jp,{children:(0,G.jsx)(bhe,{})}),(0,G.jsx)(yr,{position:`top-right`,richColors:!0,closeButton:!0})]})})})}));
|
|
164
|
+
- `).trim()}function Tme(e){return new Date(e).toLocaleString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Eme(e){return e?e.length<=16?e:e.slice(0,8)+`...`+e.slice(-8):`—`}function Dme(e,n=80){return e?e.length<=n?e:e.slice(0,n)+`...`:`—`}function Ome({type:e}){return e===`auto`?(0,G.jsxs)(CJ,{variant:`secondary`,className:`text-xs bg-blue-100 text-blue-700 hover:bg-blue-100 border-blue-200`,children:[(0,G.jsx)(eh,{className:`size-3 mr-1`}),`自动注入`]}):(0,G.jsxs)(CJ,{variant:`outline`,className:`text-xs bg-emerald-50 text-emerald-700 hover:bg-emerald-50 border-emerald-200`,children:[(0,G.jsx)(jm,{className:`size-3 mr-1`}),`手动注入`]})}function kme({category:e}){return(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs font-normal ${AJ(e)}`,children:e||`未分类`})}function k9({label:e,value:n,max:r=1}){let i=Math.max(0,Math.min(n,r))/r*100;return(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,G.jsx)(`span`,{className:`font-medium`,children:n===0?`—`:`${i.toFixed(1)}%`})]}),(0,G.jsx)(`div`,{className:`h-1.5 w-full rounded-full bg-muted overflow-hidden`,children:(0,G.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-all`,style:{width:`${i}%`}})})]})}function Ame({relevance:e,isKept:n}){return n?e?e===`high`?(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs bg-emerald-500/10 text-emerald-600 border-emerald-500/30`,children:`🟢 高相关`}):e===`medium`?(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs bg-yellow-500/10 text-yellow-600 border-yellow-500/30`,children:`🟡 中相关`}):(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs bg-muted text-muted-foreground border-border`,children:e||`—`}):(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs bg-blue-500/10 text-blue-600 border-blue-500/30`,children:`🔵 保留`}):(0,G.jsx)(CJ,{variant:`outline`,className:`text-xs bg-red-500/10 text-red-600 border-red-500/30`,children:`🔴 被精炼掉`})}function jme({item:e,memory:n,memoryLoading:r,vaultUnlocked:i,memoryUnlocked:a,onUnlock:o,onLock:s,onVaultUnlock:c}){let l=!!e.refine_relevance,[u,d]=(0,y.useState)(`raw`),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(``),[g,_]=(0,y.useState)(null),v=ob(e=>e.unlock),b=ob(e=>e.isUnlocked),x=n?.visibility===`private`||(n?.tags||[]).some(e=>e===`私密`||e.toLowerCase()===`private`),S=x&&!a,C=async()=>{n&&(S?i||b?o?.(n.id):p(!0):(s?.(n.id),p(!1)))},w=async()=>{if(!m.trim()){_(`请输入密码`);return}await v(m)?(p(!1),h(``),_(null),c?.(),n&&o?.(n.id)):_(`密码错误`)};return(0,G.jsxs)(`div`,{className:`rounded-md border bg-muted/50 p-3 space-y-3 ${e.is_kept?`border-border`:`border-dashed border-red-500/30 opacity-75`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,G.jsx)(Ame,{relevance:e.refine_relevance,isKept:e.is_kept}),(0,G.jsx)(kme,{category:n?.category}),x&&(0,G.jsxs)(CJ,{variant:`secondary`,className:`text-xs bg-amber-100 text-amber-700 hover:bg-amber-100 border-amber-200`,children:[(0,G.jsx)(Em,{className:`size-3 mr-1`}),`私密`]}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:[e.memory_id?.slice(0,8),`...`]})]}),x&&(0,G.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),C()},className:`text-xs text-amber-500 hover:text-amber-600 flex items-center gap-1 shrink-0`,children:[S?(0,G.jsx)(Em,{className:`size-3`}):(0,G.jsx)(Tm,{className:`size-3`}),S?`解锁`:`锁定`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border pb-1`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>l&&d(`refine`),className:`text-xs px-2 py-1 rounded transition-colors ${l?u===`refine`?`bg-primary/10 text-primary font-medium`:`text-muted-foreground hover:text-foreground`:`text-muted-foreground/40 cursor-not-allowed`}`,children:`精炼`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>d(`raw`),className:`text-xs px-2 py-1 rounded transition-colors ${u===`raw`?`bg-primary/10 text-primary font-medium`:`text-muted-foreground hover:text-foreground`}`,children:`原始`})]}),u===`refine`?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[e.refine_reasoning?(0,G.jsxs)(`div`,{className:`text-sm text-foreground`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:`推理说明:`}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:e.refine_reasoning})]}):(0,G.jsx)(`div`,{className:`text-sm text-muted-foreground italic`,children:`未经精炼 · 自动保留`}),(0,G.jsx)(k9,{label:`相似度得分`,value:e.score,max:1})]}):(0,G.jsx)(`div`,{className:`space-y-2`,children:r?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(Cb,{className:`h-4 w-3/4`}),(0,G.jsx)(Cb,{className:`h-4 w-1/2`})]}):n?(0,G.jsx)(G.Fragment,{children:S?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,G.jsx)(Em,{className:`size-4`}),(0,G.jsx)(`span`,{children:`私密记忆内容已隐藏`})]}),f&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(hb,{type:`password`,placeholder:`输入 Vault 密码...`,value:m,onChange:e=>{h(e.target.value),_(null)},onKeyDown:e=>e.key===`Enter`&&w(),className:g?`border-destructive flex-1`:`flex-1`}),(0,G.jsx)(q,{size:`sm`,onClick:w,children:`解锁`})]}),g&&(0,G.jsx)(`p`,{className:`text-xs text-destructive`,children:g})]})]}):(0,G.jsx)(`div`,{className:`prose prose-sm dark:prose-invert max-w-none`,children:(0,G.jsx)(b0,{remarkPlugins:[d3],children:wme(n.content||n.l0_abstract||`—`)})})}):(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`记忆内容加载失败`})})]})}function Mme({event:e,initialItems:n,isLast:r,defaultExpanded:i,vaultUnlocked:a,unlockedMemories:o,manuallyLocked:s,onUnlock:c,onLock:l,onVaultUnlock:u}){let[d,f]=(0,y.useState)(i||!1),[p,m]=(0,y.useState)(!0),[h,g]=(0,y.useState)(n??null),[_,v]=(0,y.useState)(new Map),[b,x]=(0,y.useState)(new Set);(0,y.useEffect)(()=>{n&&h===null&&g(n)},[n,h]);let S=(0,y.useCallback)(async e=>{try{x(n=>new Set(n).add(e));let n=await ib.get(`/v1/memories/${e}`);v(r=>{let i=new Map(r);return i.set(e,n),i})}catch(e){console.error(`Failed to fetch memory:`,e)}finally{x(n=>{let r=new Set(n);return r.delete(e),r})}},[]),C=(0,y.useRef)(new Set);(0,y.useEffect)(()=>{!d||!h||h.length===0||h.forEach(e=>{C.current.has(e.memory_id)||(C.current.add(e.memory_id),S(e.memory_id))})},[d,h,S]);let w=e=>a&&!s.has(e)||o.has(e);return(0,G.jsxs)(`div`,{className:`flex gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,G.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full bg-primary ring-4 ring-primary/20`}),!r&&(0,G.jsx)(`div`,{className:`w-px flex-1 bg-border mt-1`})]}),(0,G.jsx)(`div`,{className:`flex-1 pb-6`,children:(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card transition-colors hover:bg-muted/50`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>f(!d),className:`w-full text-left p-4 cursor-pointer`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,G.jsx)(Ome,{type:e.recall_type}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,G.jsx)(nm,{className:`size-3`}),Tme(e.created_at)]})]}),d?(0,G.jsx)(em,{className:`size-4 text-muted-foreground`}):(0,G.jsx)(Zp,{className:`size-4 text-muted-foreground`})]}),(0,G.jsxs)(`div`,{className:`mt-2 text-sm text-muted-foreground flex items-center gap-1.5`,children:[(0,G.jsx)(Lm,{className:`size-3.5`}),(0,G.jsx)(`span`,{className:`line-clamp-1`,title:e.query_text||`—`,children:Dme(e.query_text)})]})]}),d&&(0,G.jsxs)(`div`,{className:`px-4 pb-4 space-y-4 border-t border-border pt-4`,children:[e.profile_content&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground flex items-center gap-1`,children:[(0,G.jsx)(Kp,{className:`size-3`}),`画像注入内容`]}),(0,G.jsx)(`div`,{className:`rounded-md border border-indigo-500/20 bg-indigo-500/5 p-3`,children:(0,G.jsx)(`div`,{className:`prose prose-sm dark:prose-invert max-w-none text-sm text-indigo-700 dark:text-indigo-300`,children:(0,G.jsx)(b0,{remarkPlugins:[d3],children:e.profile_content.replace(/<\/?cerebro-profile>/g,``).trim()})})})]}),e.injected_content&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>m(!p),className:`flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,children:[(0,G.jsx)(tee,{className:`size-3`}),`注入内容`,p?(0,G.jsx)(em,{className:`size-3`}):(0,G.jsx)(Zp,{className:`size-3`})]}),p&&(0,G.jsx)(`div`,{className:`rounded-md border border-emerald-500/20 bg-emerald-500/5 p-3 max-h-96 overflow-y-auto`,children:(0,G.jsx)(`div`,{className:`prose prose-sm dark:prose-invert max-w-none text-sm text-emerald-700 dark:text-emerald-300`,children:(0,G.jsx)(b0,{remarkPlugins:[d3],children:e.injected_content.replace(/<\/?cerebro-context>/g,``).trim()})})})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,G.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground flex items-center gap-1`,children:[(0,G.jsx)(Kp,{className:`size-3`}),`关联记忆`]})}),h&&h.length>0?(0,G.jsx)(`div`,{className:`space-y-3`,children:h.map(e=>(0,G.jsx)(jme,{item:e,memory:_.get(e.memory_id)||null,memoryLoading:b.has(e.memory_id),vaultUnlocked:a,memoryUnlocked:w(e.memory_id),onUnlock:c,onLock:l,onVaultUnlock:u},e.id))}):(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`暂无召回项`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground flex items-center gap-1`,children:[(0,G.jsx)(Yp,{className:`size-3`}),`匹配指标`]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,G.jsx)(k9,{label:`最大相似度`,value:e.max_score}),(0,G.jsx)(k9,{label:`LLM 置信度`,value:e.llm_confidence})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`统计:`}),(0,G.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[`保留 `,e.kept_count,` 条`]}),e.discarded_count>0&&(0,G.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`精炼掉 `,e.discarded_count,` 条`]}),e.injected_count!=null&&e.injected_count>0&&(0,G.jsxs)(`span`,{className:`text-blue-600 dark:text-blue-400`,children:[`实际注入 `,e.injected_count,` 条`]}),e.profile_injected&&(0,G.jsx)(`span`,{className:`text-indigo-600 dark:text-indigo-400`,children:`👤 画像已注入`})]})]})]})})]})}function Nme(){let{id:e}=it(),n=et(),r=Ze(),i=()=>{let e=r.state;e?.from?n(e.from,{replace:!0}):n(-1)},a=e?decodeURIComponent(e):``,[o,s]=(0,y.useState)([]),[c,l]=(0,y.useState)(new Map),[u,d]=(0,y.useState)(!0),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(1),[g,_]=(0,y.useState)(!1),[v,b]=(0,y.useState)(!1),[x,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(null),T=ob(e=>e.unlock),E=ob(e=>e.lock),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(new Set),[j,M]=(0,y.useState)(new Set),[N,P]=(0,y.useState)(null),F=Math.ceil(o.length/10),I=o.slice((m-1)*10,m*10);(0,y.useEffect)(()=>{if(!a)return;async function e(){try{d(!0),p(null);let e=await ib.get(`/v1/recall-events`,{params:{session_id:a,limit:1e4,offset:0,expand:`items`}});if(s((e?.events||[]).sort((e,n)=>new Date(n.created_at).getTime()-new Date(e.created_at).getTime())),e?.event_items){let n=new Map;e.event_items.forEach(e=>n.set(e.id,e.items||[])),l(n)}}catch(e){console.error(`Failed to fetch session detail:`,e),p(`加载 Session 详情失败`),ir.error(`加载 Session 详情失败`)}finally{d(!1)}}e()},[a]);let L=()=>{_(!0)},R=async()=>{try{await ib.delete(`/v1/session-recalls/session/${a}`),ir.success(`Session 记录已删除`),n(-1)}catch(e){console.error(`Failed to delete session records:`,e),ir.error(`删除失败`)}finally{_(!1)}},z=async()=>{if(!x.trim()){w(`请输入密码`);return}if(!await T(x)){w(`密码错误`);return}O(!0),N&&(A(e=>new Set(e).add(N)),P(null)),w(null),b(!1),S(``)},ee=()=>{O(!1),A(new Set),M(new Set),E()},B=e=>{k.has(e)||D&&!j.has(e)?(M(n=>new Set(n).add(e)),A(n=>{let r=new Set(n);return r.delete(e),r})):D?M(n=>{let r=new Set(n);return r.delete(e),r}):(P(e),b(!0))},V={total:o.length,auto:o.filter(e=>e.recall_type===`auto`).length,manual:o.filter(e=>e.recall_type===`manual`).length,totalKept:o.reduce((e,n)=>e+n.kept_count,0),totalDiscarded:o.reduce((e,n)=>e+n.discarded_count,0)};return u?(0,G.jsxs)(`div`,{className:`space-y-6 max-w-3xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Cb,{className:`h-8 w-8`}),(0,G.jsx)(Cb,{className:`h-6 w-32`})]}),(0,G.jsx)(Cb,{className:`h-4 w-1/2`}),(0,G.jsx)(`div`,{className:`space-y-4`,children:[1,2,3].map(e=>(0,G.jsxs)(`div`,{className:`flex gap-4`,children:[(0,G.jsx)(Cb,{className:`h-3 w-3 rounded-full`}),(0,G.jsx)(`div`,{className:`flex-1 space-y-2`,children:(0,G.jsx)(Cb,{className:`h-20 w-full`})})]},e))})]}):f?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>i(),children:[(0,G.jsx)(Vp,{className:`size-4 mr-1.5`}),`返回`]}),(0,G.jsx)(`div`,{className:`rounded-lg border border-destructive/50 bg-destructive/10 p-6 text-sm text-destructive`,children:f})]}):(0,G.jsxs)(`div`,{className:`space-y-6 max-w-3xl`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>i(),children:[(0,G.jsx)(Vp,{className:`size-4 mr-1.5`}),`返回`]})})}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:[`Session 详情 - `,Eme(a)]}),(0,G.jsx)(`div`,{className:`flex items-center gap-3 text-sm text-muted-foreground flex-wrap`,children:(0,G.jsx)(`code`,{className:`font-mono text-xs bg-muted px-1.5 py-0.5 rounded`,children:a})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,G.jsx)(vb,{children:(0,G.jsxs)(Sb,{className:`pt-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-semibold`,children:V.total}),(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`总召回事件`})]})}),(0,G.jsx)(vb,{children:(0,G.jsxs)(Sb,{className:`pt-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-semibold`,children:V.auto}),(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`自动注入`})]})}),(0,G.jsx)(vb,{children:(0,G.jsxs)(Sb,{className:`pt-4 text-center`,children:[(0,G.jsx)(`div`,{className:`text-2xl font-semibold`,children:V.manual}),(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`手动注入`})]})})]}),V.totalKept>0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[(0,G.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400 font-medium`,children:[`共保留 `,V.totalKept,` 条记忆`]}),V.totalDiscarded>0&&(0,G.jsxs)(`span`,{className:`text-red-600 dark:text-red-400 font-medium`,children:[`共精炼掉 `,V.totalDiscarded,` 条记忆`]})]}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground`,children:`召回事件时间线`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`共 `,o.length,` 个事件`]}),F>1&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>h(e=>Math.max(1,e-1)),disabled:m===1,children:(0,G.jsx)(Qp,{className:`size-3`})}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground min-w-[3ch] text-center`,children:[m,`/`,F]}),(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>h(e=>Math.min(F,e+1)),disabled:m===F,children:(0,G.jsx)($p,{className:`size-3`})})]}),D?(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:ee,children:[(0,G.jsx)(Em,{className:`size-3.5 mr-1`}),`锁定 Vault`]}):(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>b(!v),children:[(0,G.jsx)(Tm,{className:`size-3.5 mr-1`}),`解锁 Vault`]})]})]}),v&&(0,G.jsxs)(`div`,{className:`space-y-2 max-w-md`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(hb,{type:`password`,placeholder:`输入 Vault 密码...`,value:x,onChange:e=>{S(e.target.value),w(null)},onKeyDown:e=>e.key===`Enter`&&z(),className:C?`border-destructive flex-1`:`flex-1`}),(0,G.jsx)(q,{size:`sm`,onClick:z,children:`解锁`})]}),C&&(0,G.jsx)(`p`,{className:`text-xs text-destructive`,children:C})]}),o.length===0?(0,G.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-8 text-center text-sm text-muted-foreground`,children:`暂无召回事件`}):(0,G.jsxs)(G.Fragment,{children:[I.map((e,n)=>(0,G.jsx)(Mme,{event:e,initialItems:c.get(e.id),isLast:n===I.length-1&&m===F,defaultExpanded:n===0&&m===1,vaultUnlocked:D,unlockedMemories:k,manuallyLocked:j,onUnlock:B,onLock:B,onVaultUnlock:()=>O(!0)},e.id)),F>1&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pt-4`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`共 `,o.length,` 个事件`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>h(e=>Math.max(1,e-1)),disabled:m===1,children:(0,G.jsx)(Qp,{className:`size-4`})}),(0,G.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[m,` / `,F]}),(0,G.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>h(e=>Math.min(F,e+1)),disabled:m===F,children:(0,G.jsx)($p,{className:`size-4`})})]})]})]})]}),o.length>0&&(0,G.jsx)(`div`,{className:`pt-4 border-t border-border`,children:(0,G.jsxs)(q,{variant:`outline`,size:`sm`,className:`text-destructive hover:bg-destructive/10 hover:text-destructive`,onClick:L,children:[(0,G.jsx)(Km,{className:`size-3.5 mr-1`}),`删除 Session 所有记录`]})}),(0,G.jsx)(pJ,{open:g,onOpenChange:e=>!e&&_(!1),children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除 Session 记录`}),(0,G.jsx)(vJ,{children:`此操作将删除该 Session 的所有召回记录,不可撤销。确定要继续吗?`})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{onClick:()=>_(!1),children:`取消`}),(0,G.jsx)(yJ,{onClick:R,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`删除`})]})]})})]})}function A9({...e}){return(0,G.jsx)(hg,{"data-slot":`dialog`,...e})}function Pme({...e}){return(0,G.jsx)(_g,{"data-slot":`dialog-trigger`,...e})}function Fme({...e}){return(0,G.jsx)(Zh,{"data-slot":`dialog-portal`,...e})}function Ime({className:e,...n}){return(0,G.jsx)(Eh,{"data-slot":`dialog-overlay`,className:Tp(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...n})}function j9({className:e,children:n,showCloseButton:r=!0,...i}){return(0,G.jsxs)(Fme,{children:[(0,G.jsx)(Ime,{}),(0,G.jsxs)(Yh,{"data-slot":`dialog-content`,className:Tp(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...i,children:[n,r&&(0,G.jsxs)(Dh,{"data-slot":`dialog-close`,render:(0,G.jsx)(q,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,G.jsx)($m,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function M9({className:e,...n}){return(0,G.jsx)(`div`,{"data-slot":`dialog-header`,className:Tp(`flex flex-col gap-2`,e),...n})}function N9({className:e,showCloseButton:n=!1,children:r,...i}){return(0,G.jsxs)(`div`,{"data-slot":`dialog-footer`,className:Tp(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...i,children:[r,n&&(0,G.jsx)(Dh,{render:(0,G.jsx)(q,{variant:`outline`}),children:`Close`})]})}function P9({className:e,...n}){return(0,G.jsx)(gg,{"data-slot":`dialog-title`,className:Tp(`text-base leading-none font-medium`,e),...n})}function F9({className:e,...n}){return(0,G.jsx)(Oh,{"data-slot":`dialog-description`,className:Tp(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...n})}function Lme(){let[e,n]=(0,y.useState)([]),[r,i]=(0,y.useState)(!0),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(`team`),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(`member`),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)({}),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(`member`),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(!1),R=dh(e=>e.currentUserId),z=dh(e=>e.users.find(e=>e.id===R)),ee=e.find(e=>e.id===p),B=e=>z?e.owner_id===z.apiKey||e.members.some(e=>e.user_id===z.apiKey&&(e.role===`admin`||e.role===`Admin`)):!1;(0,y.useEffect)(()=>{async function e(){if(!ee?.members?.length)return;T(!0);let e={};await Promise.all(ee.members.map(async n=>{try{let r=await ib.get(`/v1/tenants/${encodeURIComponent(n.user_id)}`);r&&(e[n.user_id]={name:r.name,created_at:r.created_at})}catch{}})),C(e),T(!1)}p&&e()},[p,ee?.members]),(0,y.useEffect)(()=>{async function e(){try{i(!0),n(await ib.get(`/v1/spaces`)||[])}catch(e){console.error(`Failed to fetch spaces:`,e),ir.error(`加载空间列表失败`)}finally{i(!1)}}e()},[]);async function V(){if(!s.trim()){ir.error(`请输入空间名称`);return}try{await ib.post(`/v1/spaces`,{name:s.trim(),space_type:l}),ir.success(`空间创建成功`),o(!1),c(``),n(await ib.get(`/v1/spaces`)||[])}catch(e){console.error(`Failed to create space:`,e),ir.error(`空间创建失败`)}}async function H(){if(!d)return;let r=e.find(e=>e.id===d)?.members.map(e=>e.user_id).filter(e=>e!==z?.apiKey)||[];try{await ib.delete(`/v1/spaces/${encodeURIComponent(d)}`),ir.success(`空间已删除`),n(e=>e.filter(e=>e.id!==d)),dh.getState().removeUsersByApiKeys(r)}catch(e){console.error(`Failed to delete space:`,e),ir.error(`空间删除失败`)}finally{f(null)}}async function U(){if(p){N(!0);try{let e=await ib.post(`/v1/tenants`,{name:O.trim()||void 0}),r=e.id,i=e.api_key;await ib.post(`/v1/spaces/${encodeURIComponent(p)}/members`,{user_id:r,role:A}),F(i),ir.success(`新用户创建并加入空间成功`),n(await ib.get(`/v1/spaces`)||[])}catch(e){console.error(`Failed to create user:`,e);let n=e.response?.data?.error||e.message||``;ir.error(`创建用户失败:${n||`请稍后重试`}`)}finally{N(!1)}}}async function te(e){if(p)try{await ib.delete(`/v1/spaces/${encodeURIComponent(p)}/members/${encodeURIComponent(e)}`),ir.success(`成员已移除`),n(await ib.get(`/v1/spaces`)||[])}catch(e){console.error(`Failed to remove member:`,e);let n=e.response?.data?.error||e.message||``;ir.error(`移除成员失败:${n||`请稍后重试`}`)}}async function W(){if(!p||!h.trim()){ir.error(`请输入用户ID`);return}let e=h.trim();if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)){ir.error(`用户ID格式不正确,请输入有效的 UUID(如:c60beb98-7aab-4985-8c1d-29ffd6aff75a)`);return}x(!0);try{await ib.post(`/v1/spaces/${encodeURIComponent(p)}/members`,{user_id:e,role:_}),ir.success(`成员添加成功`),g(``),n(await ib.get(`/v1/spaces`)||[])}catch(e){console.error(`Failed to add member:`,e);let n=e.response?.data?.error||e.message||``;n.includes(`not found`)||n.includes(`不存在`)?ir.error(`该用户不存在,请确认用户ID正确`):n.includes(`permission`)||n.includes(`权限`)?ir.error(`您没有权限添加成员`):ir.error(`添加成员失败:${n||`请检查用户ID是否正确`}`)}finally{x(!1)}}return r?(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`空间管理`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`管理您的记忆空间`})]}),(0,G.jsx)(Cb,{className:`h-9 w-24`})]}),(0,G.jsx)(`div`,{className:`grid gap-4`,children:[1,2].map(e=>(0,G.jsx)(Cb,{className:`h-32 w-full`},e))})]}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`空间管理`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`管理您的记忆空间`})]}),(0,G.jsxs)(A9,{open:a,onOpenChange:o,children:[(0,G.jsx)(Pme,{render:(0,G.jsxs)(q,{size:`sm`,children:[(0,G.jsx)(Nm,{className:`size-4 mr-1.5`}),`新建空间`]})}),(0,G.jsxs)(j9,{children:[(0,G.jsx)(M9,{children:(0,G.jsx)(P9,{children:`新建空间`})}),(0,G.jsxs)(`div`,{className:`space-y-4 pt-2`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`空间名称`}),(0,G.jsx)(hb,{placeholder:`输入空间名称`,value:s,onChange:e=>c(e.target.value)})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`空间类型`}),(0,G.jsxs)(_9,{value:l,onValueChange:e=>u(e||`team`),children:[(0,G.jsx)(y9,{children:(0,G.jsx)(v9,{})}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`team`,children:`团队`}),(0,G.jsx)(x9,{value:`personal`,children:`个人`}),(0,G.jsx)(x9,{value:`shared`,children:`共享`})]})]})]}),(0,G.jsx)(q,{className:`w-full`,onClick:V,children:`创建`})]})]})]})]}),e.length===0?(0,G.jsxs)(`div`,{className:`text-center py-12 text-muted-foreground border border-dashed border-border rounded-lg`,children:[(0,G.jsx)(`p`,{children:`暂无空间`}),(0,G.jsx)(`p`,{className:`text-sm mt-1`,children:`点击右上角按钮创建新空间`})]}):(0,G.jsx)(`div`,{className:`grid gap-4`,children:e.map(e=>(0,G.jsxs)(vb,{className:`group transition-colors hover:bg-accent/50`,children:[(0,G.jsx)(yb,{className:`pb-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.name}),(0,G.jsx)(CJ,{variant:`outline`,children:e.space_type})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,G.jsx)(zm,{className:`size-3`}),e.members.length,` 成员`]}),(0,G.jsxs)(q,{variant:`ghost`,size:`sm`,className:`h-7 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>{m(e.id),g(``),v(`member`)},children:[(0,G.jsx)(Xm,{className:`size-3.5 mr-1`}),`管理成员`]}),e.space_type!==`personal`&&B(e)&&(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>f(e.id),children:(0,G.jsx)(Km,{className:`size-3.5 text-destructive`})})]})]})}),(0,G.jsxs)(Sb,{className:`pt-0 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4 text-sm text-muted-foreground flex-wrap`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(Qm,{className:`size-3.5`}),e.members.map(e=>e.role).join(`, `)]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(Jp,{className:`size-3.5`}),new Date(e.created_at).toLocaleDateString(`zh-CN`)]})]}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground font-mono`,children:[`ID: `,e.id]})]})]},e.id))}),(0,G.jsx)(pJ,{open:!!d,onOpenChange:e=>!e&&f(null),children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除空间`}),(0,G.jsx)(vJ,{children:`此操作不可撤销。空间内的数据不会被删除,但空间配置将被移除。`})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{onClick:()=>f(null),children:`取消`}),(0,G.jsx)(yJ,{onClick:H,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`删除`})]})]})}),(0,G.jsx)(A9,{open:!!p,onOpenChange:e=>!e&&m(null),children:(0,G.jsxs)(j9,{style:{width:680,maxWidth:`95vw`},children:[(0,G.jsx)(M9,{children:(0,G.jsxs)(P9,{children:[`管理成员 - `,ee?.name]})}),(0,G.jsxs)(`div`,{className:`space-y-4 pt-2`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`当前成员`}),w&&(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`加载用户信息中...`}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[ee?.members.map(e=>{let n=S[e.user_id];return(0,G.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr_80px_60px] items-center gap-3 text-sm border rounded-md px-3 py-2`,children:[(0,G.jsx)(Zm,{className:`size-3.5 text-muted-foreground`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`font-mono text-xs truncate`,title:e.user_id,children:e.user_id}),n&&(0,G.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[n.name,` · `,new Date(n.created_at).toLocaleDateString(`zh-CN`)]})]}),(0,G.jsx)(CJ,{variant:`outline`,className:`justify-self-center`,children:e.role}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 justify-self-end`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(e.user_id),ir.success(`API Key 已复制`)},className:`text-muted-foreground hover:text-foreground transition-colors`,title:`复制 API Key`,children:(0,G.jsx)(rm,{className:`size-3.5`})}),ee&&B(ee)&&e.user_id!==z?.apiKey&&e.user_id!==ee?.owner_id&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>te(e.user_id),className:`text-muted-foreground hover:text-destructive transition-colors`,title:`移除成员`,children:(0,G.jsx)(Km,{className:`size-3.5`})})]})]},e.user_id)}),(!ee?.members||ee.members.length===0)&&(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`暂无成员`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`添加成员`}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>{D(!0),F(null),k(``),j(`member`)},children:[(0,G.jsx)(ym,{className:`size-3.5 mr-1.5`}),`创建新用户`]})]}),E&&(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-3 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`创建新用户`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{D(!1),F(null)},className:`text-xs text-muted-foreground hover:text-foreground`,children:`取消`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(hb,{placeholder:`用户名(可选)`,value:O,onChange:e=>k(e.target.value),className:`flex-1`}),(0,G.jsxs)(_9,{value:A,onValueChange:e=>j(e||`member`),children:[(0,G.jsx)(y9,{className:`w-28`,children:(0,G.jsx)(v9,{})}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`admin`,children:`管理员`}),(0,G.jsx)(x9,{value:`member`,children:`成员`}),(0,G.jsx)(x9,{value:`reader`,children:`只读`})]})]})]}),(0,G.jsx)(q,{size:`sm`,className:`w-full`,onClick:U,disabled:M,children:M?`生成中...`:`生成用户并添加到空间`}),P&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`新用户 API Key(请复制保存):`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`code`,{className:`flex-1 text-xs bg-background border rounded px-2 py-1.5 font-mono truncate`,children:P}),(0,G.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>{navigator.clipboard.writeText(P),L(!0),setTimeout(()=>L(!1),2e3)},children:I?(0,G.jsx)(Xp,{className:`size-3.5`}):(0,G.jsx)(rm,{className:`size-3.5`})})]})]})]}),!E&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(hb,{placeholder:`输入对方 API Key(UUID格式)`,value:h,onChange:e=>g(e.target.value),className:`flex-1`}),(0,G.jsxs)(_9,{value:_,onValueChange:e=>v(e||`member`),children:[(0,G.jsx)(y9,{className:`w-28`,children:(0,G.jsx)(v9,{})}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`admin`,children:`管理员`}),(0,G.jsx)(x9,{value:`member`,children:`成员`}),(0,G.jsx)(x9,{value:`reader`,children:`只读`})]})]}),(0,G.jsx)(q,{size:`sm`,onClick:W,disabled:b,children:b?`添加中...`:`添加`})]})]})]})]})})]})}var I9=[`#8b5cf6`,`#ec4899`,`#06b6d4`,`#f59e0b`,`#10b981`,`#ef4444`,`#6366f1`,`#f97316`];function L9(e,n){if(!e)return[];let r=Object.entries(e).map(([e,n])=>({name:e,value:n})).sort((e,n)=>n.value-e.value);return n?r.slice(0,n):r}function Rme(){let e=et(),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)([]),[o,s]=(0,y.useState)(!0);(0,y.useEffect)(()=>{async function e(){try{s(!0);let[e,n]=await Promise.all([ib.get(`/v1/stats`),ib.get(`/v1/memories`)]);r(e),a(n?.memories||[])}catch(e){ir.error(`加载统计数据失败: `+e.message)}finally{s(!1)}}e()},[]);let c=(0,y.useMemo)(()=>{if(!n?.timeline?.length)return 0;let e=new Date().toISOString().split(`T`)[0];return n.timeline.find(n=>n.date===e)?.count??0},[n]),l=(0,y.useMemo)(()=>L9(n?.by_category,8),[n]),u=(0,y.useMemo)(()=>L9(n?.by_type),[n]),d=(0,y.useMemo)(()=>L9(n?.by_tier),[n]),f=(0,y.useMemo)(()=>L9(n?.by_state),[n]),p=(0,y.useMemo)(()=>!n||!n.total||!n.total_access_count?`0%`:`${Math.min(100,Math.round(n.total_access_count/Math.max(1,n.total)*100))}%`,[n]),m=(0,y.useMemo)(()=>{let e=[];for(let n of i)if(n.tier_history)try{let r=JSON.parse(n.tier_history);for(let i of r)e.push({memoryId:n.id,...i})}catch{}return e.sort((e,n)=>n.at.localeCompare(e.at)),e.slice(0,50)},[i]),h={access_via_get:`访问触发`,access_via_search:`搜索触发`,access_via_recall:`召回触发`,access_via_cross_space_search:`跨空间搜索触发`,scheduled_evaluation:`定时评估`};return o?(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(Cb,{className:`h-8 w-48`}),(0,G.jsx)(Cb,{className:`h-8 w-24`})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-4`,children:[(0,G.jsx)(Cb,{className:`h-24`}),(0,G.jsx)(Cb,{className:`h-24`}),(0,G.jsx)(Cb,{className:`h-24`}),(0,G.jsx)(Cb,{className:`h-24`})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,G.jsx)(Cb,{className:`h-80`}),(0,G.jsx)(Cb,{className:`h-80`}),(0,G.jsx)(Cb,{className:`h-80`}),(0,G.jsx)(Cb,{className:`h-80`})]})]}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight flex items-center gap-2`,children:[(0,G.jsx)(Yp,{className:`size-5`}),`统计分析`]}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`记忆库数据洞察与可视化`})]}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>e(`/memories`),children:[(0,G.jsx)(Vp,{className:`size-4 mr-1.5`}),`返回记忆`]})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-4`,children:[(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:`总记忆数`}),(0,G.jsx)(qp,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:n?.total??0})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:`今日新增`}),(0,G.jsx)(qm,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:c})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:`空间数`}),(0,G.jsx)(xm,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:n?.total_spaces??Object.keys(n?.by_space??{}).length})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:`活跃度`}),(0,G.jsx)(iee,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:p})})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:`平均重要性`}),(0,G.jsx)(Hm,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:n?.avg_importance?`${(n.avg_importance*100).toFixed(0)}%`:`—`})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(bb,{className:`text-sm font-medium text-muted-foreground`,children:`平均置信度`}),(0,G.jsx)(Yp,{className:`size-4 text-muted-foreground`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`text-2xl font-bold`,children:n?.avg_confidence?`${(n.avg_confidence*100).toFixed(0)}%`:`—`})})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`分类分布`})}),(0,G.jsxs)(Sb,{children:[(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(iJ,{children:[(0,G.jsx)(OB,{data:l,cx:`50%`,cy:`50%`,innerRadius:60,outerRadius:100,paddingAngle:2,dataKey:`value`,children:l.map((e,n)=>(0,G.jsx)(sD,{fill:I9[n%I9.length]},`cell-${e.name}`))}),(0,G.jsx)(VE,{})]})}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2 mt-4 justify-center`,children:l.map((e,n)=>(0,G.jsxs)(CJ,{variant:`secondary`,style:{backgroundColor:`${I9[n%I9.length]}20`,color:I9[n%I9.length]},children:[e.name,` (`,e.value,`)`]},e.name))})]})]}),(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`记忆类型分布`})}),(0,G.jsx)(Sb,{children:(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(rJ,{data:u,children:[(0,G.jsx)(eG,{strokeDasharray:`3 3`,stroke:`#333`}),(0,G.jsx)(mK,{dataKey:`name`,tick:{fontSize:12}}),(0,G.jsx)(jK,{tick:{fontSize:12}}),(0,G.jsx)(VE,{}),(0,G.jsx)(XV,{dataKey:`value`,fill:`#8b5cf6`,radius:[4,4,0,0]})]})})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`层级分布`})}),(0,G.jsx)(Sb,{children:(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(iJ,{children:[(0,G.jsx)(OB,{data:d,cx:`50%`,cy:`50%`,outerRadius:100,dataKey:`value`,label:({name:e,value:n})=>`${e}: ${n}`,children:d.map((e,n)=>(0,G.jsx)(sD,{fill:I9[n%I9.length]},`tier-${e.name}`))}),(0,G.jsx)(VE,{})]})})})]}),(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{children:(0,G.jsx)(bb,{className:`text-base`,children:`状态分布`})}),(0,G.jsx)(Sb,{children:(0,G.jsx)(oD,{width:`100%`,height:280,children:(0,G.jsxs)(rJ,{data:f,children:[(0,G.jsx)(eG,{strokeDasharray:`3 3`,stroke:`#333`}),(0,G.jsx)(mK,{dataKey:`name`,tick:{fontSize:12}}),(0,G.jsx)(jK,{tick:{fontSize:12}}),(0,G.jsx)(VE,{}),(0,G.jsx)(XV,{dataKey:`value`,fill:`#10b981`,radius:[4,4,0,0]})]})})})]})]}),(0,G.jsxs)(vb,{className:`mt-4`,children:[(0,G.jsx)(yb,{children:(0,G.jsxs)(bb,{className:`flex items-center gap-1.5 text-base`,children:[(0,G.jsx)(mm,{className:`size-4 text-muted-foreground`}),`Tier 变更日志`]})}),(0,G.jsx)(Sb,{children:m.length===0?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground py-4 text-center`,children:`暂无变更记录`}):(0,G.jsx)(`div`,{className:`space-y-1`,children:m.map(n=>{let r={peripheral:0,working:1,core:2};return(0,G.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 text-sm py-2 border-b last:border-b-0 hover:bg-muted/50 px-2 rounded cursor-pointer w-full text-left`,onClick:()=>e(`/memories/${n.memoryId}`),children:[(r[n.from]??0)<(r[n.to]??0)?(0,G.jsx)(Wp,{className:`size-4 text-emerald-500 shrink-0`}):(0,G.jsx)(Bp,{className:`size-4 text-red-500 shrink-0`}),(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs w-36 shrink-0`,children:new Date(n.at).toLocaleString(`zh-CN`)}),(0,G.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[n.memoryId.slice(0,8),`...`]}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(n.from),children:jJ(n.from)}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(n.to),children:jJ(n.to)}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:[h[n.reason]||n.reason,` · #`,n.access_count]})]},n.memoryId+n.at)})})})]})]})}var zme={access_via_get:`访问触发`,access_via_search:`搜索触发`,access_via_recall:`召回触发`,access_via_cross_space_search:`跨空间搜索触发`,scheduled_evaluation:`定时评估`},R9=20;function Bme(){let e=et(),n=Ze(),[r,i]=(0,y.useState)([]),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(1),[l,u]=(0,y.useState)(`all`),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(0);(0,y.useEffect)(()=>{n.state?.from===`tier-history`&&n.state?.page&&c(n.state.page)},[n.state]),(0,y.useEffect)(()=>{let e=setTimeout(()=>{m(d)},300);return()=>clearTimeout(e)},[d]);let S=(0,y.useCallback)(async e=>{o(!0);try{let n=(e-1)*R9,r={limit:String(R9),offset:String(n)};l===`promote`?r.filter=`promote`:l===`demote`&&(r.filter=`demote`),p.trim()&&(r.search=p.trim());let a=await ib.get(`/v1/tier-changes`,{params:r});i(a.changes),x(a.totalCount)}catch(e){console.error(`Failed to fetch tier history:`,e)}finally{o(!1)}},[l,p]);(0,y.useEffect)(()=>{S(s)},[S,s]);let C=Math.max(1,Math.ceil(b/R9)),w=Math.min(s,C),T={peripheral:0,working:1,core:2},E=async()=>{if(!h)return;let e=h;v(!0);try{await ib.post(`/v1/tier-changes/delete`,{memory_id:e.memoryId,from:e.from,to:e.to,at:e.at,reason:e.reason}),ir.success(`已删除该条变更记录`),i(n=>n.filter(n=>!(n.memoryId===e.memoryId&&n.from===e.from&&n.to===e.to&&n.at===e.at))),x(e=>Math.max(0,e-1))}catch(e){console.error(`Failed to delete tier history entry:`,e),ir.error(`删除失败`)}finally{v(!1),g(null)}},D=n=>{e(`/memories/${n}`,{state:{from:`tier-history`,page:w}})};return(0,G.jsxs)(`div`,{className:`space-y-6 max-w-5xl mx-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight flex items-center gap-2`,children:[(0,G.jsx)(mm,{className:`size-5`}),`等级变更历史`]}),(0,G.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`共 `,b,` 条记录`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-xs`,children:[(0,G.jsx)(Lm,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 size-4 text-muted-foreground`}),(0,G.jsx)(`input`,{type:`text`,placeholder:`搜索标题、ID、原因...`,value:d,onChange:e=>{f(e.target.value),c(1)},className:`w-full h-9 pl-8 pr-3 rounded-md border border-input bg-background text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]}),(0,G.jsxs)(_9,{value:l,onValueChange:e=>{e&&(u(e),c(1))},children:[(0,G.jsx)(y9,{className:`w-[130px]`,children:(0,G.jsx)(v9,{})}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`all`,children:`全部`}),(0,G.jsx)(x9,{value:`promote`,children:`仅晋升`}),(0,G.jsx)(x9,{value:`demote`,children:`仅降级`})]})]})]}),!a&&r.length>0&&C>1&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`第 `,w,` / `,C,` 页`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(q,{variant:`outline`,size:`sm`,className:`h-7 px-2`,disabled:w<=1,onClick:()=>c(w-1),children:(0,G.jsx)(Qp,{className:`size-4`})}),Array.from({length:C},(e,n)=>n+1).filter(e=>e===1||e===C||Math.abs(e-w)<=2).map((e,n,r)=>(0,G.jsxs)(`span`,{className:`flex items-center`,children:[n>0&&r[n-1]!==e-1&&(0,G.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`}),(0,G.jsx)(q,{variant:e===w?`default`:`outline`,size:`sm`,className:`h-7 w-7 px-0`,onClick:()=>c(e),children:e})]},e)),(0,G.jsx)(q,{variant:`outline`,size:`sm`,className:`h-7 px-2`,disabled:w>=C,onClick:()=>c(w+1),children:(0,G.jsx)($p,{className:`size-4`})})]})]}),(0,G.jsx)(vb,{children:(0,G.jsxs)(Sb,{className:`p-0`,children:[a?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground py-12 text-center`,children:`加载中...`}):r.length===0?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground py-12 text-center`,children:`暂无变更记录`}):(0,G.jsx)(`div`,{className:`divide-y`,children:r.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 hover:bg-muted/30 transition-colors`,children:[(T[e.from]??0)<(T[e.to]??0)?(0,G.jsx)(Wp,{className:`size-4 text-emerald-500 shrink-0`}):(0,G.jsx)(Bp,{className:`size-4 text-red-500 shrink-0`}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground w-36 shrink-0`,children:new Date(e.at).toLocaleString(`zh-CN`)}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(e.from),children:jJ(e.from)}),(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`→`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(e.to),children:jJ(e.to)}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground w-20 shrink-0`,children:zme[e.reason]||e.reason}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground w-16 shrink-0`,children:[`#`,e.accessCount]}),(0,G.jsx)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left text-sm truncate hover:underline cursor-pointer`,onClick:()=>D(e.memoryId),title:e.memoryTitle,children:e.memoryTitle}),(0,G.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground shrink-0`,children:[e.memoryId.slice(0,8),`...`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,G.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,onClick:()=>D(e.memoryId),title:`查看详情`,children:(0,G.jsx)(sm,{className:`size-3.5`})}),(0,G.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-red-500 hover:text-red-600 hover:bg-red-500/10`,onClick:()=>g(e),title:`删除此条记录`,children:(0,G.jsx)(Km,{className:`size-3.5`})})]})]},`${e.memoryId}-${e.at}-${e.from}-${e.to}`))}),C>1&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-t`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`第 `,w,` / `,C,` 页,共 `,b,` 条`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(q,{variant:`outline`,size:`sm`,className:`h-7 px-2`,disabled:w<=1,onClick:()=>c(w-1),children:(0,G.jsx)(Qp,{className:`size-4`})}),Array.from({length:C},(e,n)=>n+1).filter(e=>e===1||e===C||Math.abs(e-w)<=2).map((e,n,r)=>(0,G.jsxs)(`span`,{className:`flex items-center`,children:[n>0&&r[n-1]!==e-1&&(0,G.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`}),(0,G.jsx)(q,{variant:e===w?`default`:`outline`,size:`sm`,className:`h-7 w-7 px-0`,onClick:()=>c(e),children:e})]},e)),(0,G.jsx)(q,{variant:`outline`,size:`sm`,className:`h-7 px-2`,disabled:w>=C,onClick:()=>c(w+1),children:(0,G.jsx)($p,{className:`size-4`})})]})]})]})}),(0,G.jsx)(pJ,{open:!!h,onOpenChange:e=>{e||g(null)},children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除变更记录`}),(0,G.jsxs)(vJ,{children:[`确定要删除这条 `,h&&`${jJ(h.from)} → ${jJ(h.to)}`,` 的变更记录吗?记忆本身不会被删除。`]})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{onClick:()=>g(null),disabled:_,children:`取消`}),(0,G.jsx)(yJ,{disabled:_,onClick:e=>{e.preventDefault(),E()},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:_?`删除中...`:`确认删除`})]})]})})]})}async function Vme(){return ib.get(`/v1/stats/config`)}async function Hme(e=50){return ib.get(`/v1/tier-changes`,{params:{limit:e}})}async function Ume(){return ib.post(`/v1/lifecycle/trigger`,{})}var z9=6,Wme={access_via_get:`访问触发`,access_via_search:`搜索触发`,access_via_recall:`召回触发`,access_via_cross_space_search:`跨空间搜索触发`,scheduled_evaluation:`定时评估`},B9={peripheral:0,working:1,core:2};function Gme(){let e=new Date,n=z9-e.getHours()%z9,r=new Date(e.getTime()+n*36e5);return r.setMinutes(0,0,0),r.toLocaleString(`zh-CN`)}function Kme(e,n){let r=[];for(let i=0;i<=120;i+=2){let a=Math.log(2)/n,o=Math.exp(-a*i**+e);r.push({day:`D${i}`,Core:e<1?Math.max(o,.9):o*.95,Working:o,Peripheral:o*.85})}return r}function qme(){return(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[1,2].map(e=>(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{className:`pb-2`,children:(0,G.jsx)(Cb,{className:`h-4 w-28`})}),(0,G.jsxs)(Sb,{className:`space-y-2`,children:[(0,G.jsx)(Cb,{className:`h-4 w-full`}),(0,G.jsx)(Cb,{className:`h-4 w-3/4`}),(0,G.jsx)(Cb,{className:`h-4 w-1/2`})]})]},e))})}function Jme(){return(0,G.jsx)(`div`,{className:`space-y-2`,children:[1,2,3,4].map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,G.jsx)(Cb,{className:`h-4 w-4`}),(0,G.jsx)(Cb,{className:`h-3 w-24`}),(0,G.jsx)(Cb,{className:`h-5 w-14`}),(0,G.jsx)(Cb,{className:`h-3 w-4`}),(0,G.jsx)(Cb,{className:`h-5 w-14`}),(0,G.jsx)(Cb,{className:`h-3 flex-1`})]},e))})}function Yme(){let[e,n]=(0,y.useState)(null),[r,i]=(0,y.useState)([]),[a,o]=(0,y.useState)(0),[s,c]=(0,y.useState)(!0),[l,u]=(0,y.useState)(!0),[d,f]=(0,y.useState)(20),[p,m]=(0,y.useState)(!1),h=async()=>{try{c(!0),n(await Vme())}catch(e){console.error(`Failed to load lifecycle config:`,e),ir.error(`加载生命周期配置失败`)}finally{c(!1)}},g=async()=>{try{u(!0);let e=await Hme(d);i(e.changes||[]),o(e.totalCount||0)}catch(e){console.error(`Failed to load tier changes:`,e),ir.error(`加载升降级历史失败`)}finally{u(!1)}};(0,y.useEffect)(()=>{h(),g()},[]),(0,y.useEffect)(()=>{g()},[d]);let _=()=>{h(),g()},v=async()=>{try{m(!0);let e=await Ume();ir.success(e.message),h(),g()}catch(e){console.error(`Failed to trigger lifecycle:`,e),ir.error(`触发生命周期失败`)}finally{m(!1)}},b=e?Kme(e.decay.tiers?.working?.beta??1,e.decay.half_life_days):[],x=r.filter(e=>(B9[e.from]??0)<(B9[e.to]??0)).length,S=r.filter(e=>(B9[e.from]??0)>=(B9[e.to]??0)).length;return(0,G.jsxs)(`div`,{className:`space-y-6 max-w-6xl mx-auto`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight flex items-center gap-2`,children:[(0,G.jsx)(Gm,{className:`size-5`}),`生命周期管理`]}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`记忆衰减、升降级、自动遗忘的生命周期策略`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:_,disabled:s&&l,children:[(0,G.jsx)(Fm,{className:`h-4 w-4 mr-1`}),`刷新`]}),(0,G.jsxs)(q,{variant:`default`,size:`sm`,onClick:v,disabled:p,children:[p?(0,G.jsx)(nee,{className:`h-4 w-4 mr-1 animate-spin`}):(0,G.jsx)(eh,{className:`h-4 w-4 mr-1`}),`立即执行`]})]})]}),(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`pb-3`,children:[(0,G.jsxs)(bb,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,G.jsx)(nm,{className:`size-4 text-violet-500`}),`调度器状态`]}),(0,G.jsx)(xb,{children:`自动评估与遗忘任务的运行状态`})]}),(0,G.jsxs)(Sb,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,G.jsxs)(`div`,{className:`p-3 rounded-lg border`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`调度间隔`}),(0,G.jsxs)(`p`,{className:`text-lg font-semibold mt-1`,children:[`每 `,z9,` 小时`]})]}),(0,G.jsxs)(`div`,{className:`p-3 rounded-lg border`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`预计下次运行`}),(0,G.jsx)(`p`,{className:`text-sm font-semibold mt-1`,children:Gme()})]}),(0,G.jsxs)(`div`,{className:`p-3 rounded-lg border`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`启动时运行`}),(0,G.jsx)(`div`,{className:`mt-1`,children:(0,G.jsx)(CJ,{variant:`outline`,className:`bg-emerald-500/10 text-emerald-600 border-emerald-500/30`,children:`已启用`})})]})]}),(0,G.jsx)(`div`,{className:`mt-4 p-3 rounded-lg border border-dashed text-xs text-muted-foreground space-y-1`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(sm,{className:`size-3.5`}),(0,G.jsx)(`span`,{children:`调度器将自动执行:Weibull 衰减计算、Tier 评估升降级、关键词 TTL 检测、Superseded 归档清理`})]})})]})]}),s?(0,G.jsx)(qme,{}):e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{className:`pb-3`,children:(0,G.jsxs)(bb,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,G.jsx)(zp,{className:`size-4 text-blue-500`}),`衰减参数`]})}),(0,G.jsxs)(Sb,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`默认半衰期`}),(0,G.jsxs)(`p`,{className:`font-semibold`,children:[e.decay.half_life_days,` 天`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Stale 阈值`}),(0,G.jsx)(`p`,{className:`font-semibold`,children:`0.3`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`权重分配`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(CJ,{variant:`outline`,className:`bg-blue-500/10 text-blue-600 border-blue-500/30 text-xs`,children:[`时效 `,e.decay.recency_weight]}),(0,G.jsxs)(CJ,{variant:`outline`,className:`bg-emerald-500/10 text-emerald-600 border-emerald-500/30 text-xs`,children:[`频率 `,e.decay.frequency_weight]}),(0,G.jsxs)(CJ,{variant:`outline`,className:`bg-violet-500/10 text-violet-600 border-violet-500/30 text-xs`,children:[`内在 `,e.decay.intrinsic_weight]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Tier 衰减速率 (β)`}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:Object.entries(e.decay.tiers||{}).map(([e,n])=>(0,G.jsxs)(CJ,{variant:`outline`,className:`text-xs ${NJ(e)}`,children:[jJ(e),` β=`,n.beta]},e))})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Tier 底线分数`}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:Object.entries(e.decay.tiers||{}).map(([e,n])=>(0,G.jsxs)(CJ,{variant:`outline`,className:`text-xs ${NJ(e)}`,children:[jJ(e),` ≥`,n.floor]},e))})]})]})]}),(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{className:`pb-3`,children:(0,G.jsxs)(bb,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,G.jsx)(qm,{className:`size-4 text-emerald-500`}),`升降级规则`]})}),(0,G.jsxs)(Sb,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`p-3 rounded-lg border space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,G.jsx)(Wp,{className:`size-4 text-emerald-500`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(`peripheral`),children:jJ(`peripheral`)}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(`working`),children:jJ(`working`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 text-xs`,children:[(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`访问 ≥`,e.promotion.peripheral_to_working.min_access_count,`次`]}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`综合 ≥`,e.promotion.peripheral_to_working.min_composite]})]})]}),(0,G.jsxs)(`div`,{className:`p-3 rounded-lg border space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,G.jsx)(Wp,{className:`size-4 text-emerald-500`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(`working`),children:jJ(`working`)}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(`core`),children:jJ(`core`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 text-xs`,children:[(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`访问 ≥`,e.promotion.working_to_core.min_access_count,`次`]}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`综合 ≥`,e.promotion.working_to_core.min_composite]}),e.promotion.working_to_core.min_importance!=null&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`重要性 ≥`,e.promotion.working_to_core.min_importance]})]})]})]}),(0,G.jsx)(`div`,{className:`p-3 rounded-lg border border-dashed space-y-1 text-xs text-muted-foreground`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Bp,{className:`size-3.5 text-red-400`}),(0,G.jsx)(`span`,{children:`不满足条件时自动降级至低等级`})]})})]})]})]}),b.length>0&&(0,G.jsxs)(vb,{children:[(0,G.jsxs)(yb,{className:`pb-2`,children:[(0,G.jsxs)(bb,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,G.jsx)(eh,{className:`size-4 text-amber-500`}),`衰减曲线预览`]}),(0,G.jsx)(xb,{children:`基于当前配置参数生成的理论衰减趋势`})]}),(0,G.jsx)(Sb,{children:(0,G.jsx)(`div`,{className:`h-64`,children:(0,G.jsx)(oD,{width:`100%`,height:`100%`,children:(0,G.jsxs)(nJ,{data:b,children:[(0,G.jsx)(eG,{strokeDasharray:`3 3`,className:`opacity-30`}),(0,G.jsx)(mK,{dataKey:`day`,tick:{fontSize:11},interval:14,label:{value:`天数`,position:`insideBottomRight`,offset:-5,fontSize:11}}),(0,G.jsx)(jK,{domain:[0,1],tick:{fontSize:11},label:{value:`分数`,angle:-90,position:`insideLeft`,fontSize:11}}),(0,G.jsx)(VE,{contentStyle:{fontSize:12,borderRadius:8},formatter:e=>[e.toFixed(3)]}),(0,G.jsx)(FT,{iconType:`line`,wrapperStyle:{fontSize:12}}),(0,G.jsx)(OG,{type:`monotone`,dataKey:`Core`,stroke:`#f59e0b`,strokeWidth:2,dot:!1,name:`核心 (Core)`}),(0,G.jsx)(OG,{type:`monotone`,dataKey:`Working`,stroke:`#10b981`,strokeWidth:2,dot:!1,name:`工作区 (Working)`}),(0,G.jsx)(OG,{type:`monotone`,dataKey:`Peripheral`,stroke:`#94a3b8`,strokeWidth:2,dot:!1,name:`边缘 (Peripheral)`})]})})})})]})]}):(0,G.jsx)(vb,{children:(0,G.jsx)(Sb,{className:`py-8 text-center`,children:(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`无法加载生命周期配置`})})}),(0,G.jsxs)(vb,{children:[(0,G.jsx)(yb,{className:`pb-2`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(bb,{className:`text-sm font-medium`,children:`升降级历史`}),(0,G.jsx)(xb,{children:`最近的 Tier 变更记录`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(CJ,{variant:`outline`,className:`bg-emerald-500/10 text-emerald-600 border-emerald-500/30 text-xs`,children:[`↑ 升级 `,x]}),(0,G.jsxs)(CJ,{variant:`outline`,className:`bg-red-500/10 text-red-600 border-red-500/30 text-xs`,children:[`↓ 降级 `,S]}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`共 `,a,` 条`]})]})]})}),(0,G.jsx)(Sb,{className:`p-0`,children:l?(0,G.jsx)(Jme,{}):r.length===0?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground py-12 text-center`,children:`暂无变更记录`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y`,children:r.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 hover:bg-muted/30 transition-colors`,children:[(B9[e.from]??0)<(B9[e.to]??0)?(0,G.jsx)(Wp,{className:`size-4 text-emerald-500 shrink-0`}):(0,G.jsx)(Bp,{className:`size-4 text-red-500 shrink-0`}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground w-36 shrink-0`,children:new Date(e.at).toLocaleString(`zh-CN`)}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(e.from),children:jJ(e.from)}),(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`→`}),(0,G.jsx)(CJ,{variant:`outline`,className:NJ(e.to),children:jJ(e.to)}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground w-20 shrink-0`,children:Wme[e.reason]||e.reason}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground w-12 shrink-0`,children:[`#`,e.accessCount]}),(0,G.jsx)(`span`,{className:`text-xs flex-1 min-w-0 truncate text-muted-foreground`,children:e.memoryTitle||e.memoryId?.slice(0,12)||`—`}),(0,G.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground shrink-0`,children:e.memoryId?`${e.memoryId.slice(0,8)}...`:`—`})]},`${e.memoryId}-${e.at}-${e.from}-${e.to}`))}),r.length<a&&(0,G.jsx)(`div`,{className:`flex items-center justify-center px-4 py-3 border-t`,children:(0,G.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>f(e=>e+20),children:`加载更多`})})]})})]})]})}function V9(){let e=et(),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!1),u=(0,y.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),e.type===`dragenter`||e.type===`dragover`?l(!0):e.type===`dragleave`&&l(!1)},[]),d=(0,y.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),l(!1),e.dataTransfer.files&&e.dataTransfer.files[0]&&(r(e.dataTransfer.files[0]),s(null))},[]);return(0,G.jsxs)(`div`,{className:`space-y-6 max-w-3xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>e(`/memories`),children:(0,G.jsx)(Vp,{className:`h-4 w-4`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`批量导入`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`从 JSON、CSV 或 Markdown 文件导入记忆`})]})]}),(0,G.jsx)(vb,{className:`border-2 border-dashed p-8 transition-colors ${c?`border-primary bg-primary/5`:`border-border`}`,onDragEnter:u,onDragLeave:u,onDragOver:u,onDrop:d,children:(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 text-center`,children:[(0,G.jsx)(Ym,{className:`h-10 w-10 text-muted-foreground`}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:n?n.name:`拖拽文件到此处,或点击选择`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`支持 JSON、CSV、Markdown 格式`})]}),(0,G.jsx)(`input`,{type:`file`,accept:`.json,.csv,.md,.markdown`,onChange:e=>{e.target.files&&e.target.files[0]&&(r(e.target.files[0]),s(null))},className:`hidden`,id:`file-upload`}),(0,G.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>document.getElementById(`file-upload`)?.click(),children:`选择文件`})]})}),n&&(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-card p-4`,children:[(e=>e.endsWith(`.json`)?(0,G.jsx)(cm,{className:`h-8 w-8 text-blue-500`}):e.endsWith(`.csv`)?(0,G.jsx)(lm,{className:`h-8 w-8 text-green-500`}):e.endsWith(`.md`)||e.endsWith(`.markdown`)?(0,G.jsx)(um,{className:`h-8 w-8 text-purple-500`}):(0,G.jsx)(um,{className:`h-8 w-8 text-muted-foreground`}))(n.name),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium truncate`,children:n.name}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(n.size/1024).toFixed(1),` KB`]})]}),(0,G.jsx)(q,{onClick:async()=>{if(!n){ir.error(`请先选择文件`);return}let e=new FormData;e.append(`file`,n);let r=n.name.endsWith(`.json`)?`json`:n.name.endsWith(`.csv`)?`csv`:`md`;e.append(`format`,r),a(!0);try{let n=await ib.post(`/v1/imports`,e,{headers:{"Content-Type":`multipart/form-data`}});s({success:!0,imported:n.imported||0,failed:n.failed||0,errors:n.errors}),ir.success(`成功导入 ${n.imported||0} 条记忆`)}catch(e){let n=e.response?.data?.error||e.message||`导入失败`;s({success:!1,imported:0,failed:0,errors:[n]}),ir.error(n)}finally{a(!1)}},disabled:i,size:`sm`,children:i?`导入中...`:`开始导入`})]}),o&&(0,G.jsxs)(vb,{className:`p-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[o.success?(0,G.jsx)(tm,{className:`h-5 w-5 text-green-500`}):(0,G.jsx)(eee,{className:`h-5 w-5 text-red-500`}),(0,G.jsx)(`h3`,{className:`font-semibold`,children:o.success?`导入成功`:`导入失败`})]}),o.success&&(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg bg-green-500/10 p-4 text-center`,children:[(0,G.jsx)(`p`,{className:`text-2xl font-bold text-green-500`,children:o.imported}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`成功导入`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg bg-red-500/10 p-4 text-center`,children:[(0,G.jsx)(`p`,{className:`text-2xl font-bold text-red-500`,children:o.failed}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`导入失败`})]})]}),o.errors&&o.errors.length>0&&(0,G.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-red-500`,children:`错误信息:`}),o.errors.map(e=>(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e},e))]})]}),(0,G.jsxs)(vb,{className:`p-6`,children:[(0,G.jsx)(`h3`,{className:`font-semibold mb-3`,children:`支持格式说明`}),(0,G.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(cm,{className:`h-4 w-4 text-blue-500 mt-0.5`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium`,children:`JSON`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`标准 JSON 数组格式,每条记忆包含 content, tags, category 等字段`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(lm,{className:`h-4 w-4 text-green-500 mt-0.5`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium`,children:`CSV`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`包含列:content, tags, category, importance, confidence`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(um,{className:`h-4 w-4 text-purple-500 mt-0.5`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium`,children:`Markdown`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`每条记忆用标题分隔,支持 frontmatter 元数据`})]})]})]})]})]})}function Xme(){let{theme:e,setTheme:n}=Cr(),{hasPassword:r,setPassword:i,lock:a}=ob(),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(!1);return(0,G.jsxs)(`div`,{className:`space-y-6 max-w-2xl`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`系统设置`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`管理您的偏好设置和数据`})]}),(0,G.jsxs)(vb,{className:`p-6`,children:[(0,G.jsx)(`h3`,{className:`font-semibold mb-4`,children:`外观`}),(0,G.jsx)(`div`,{className:`space-y-4`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(gb,{className:`text-sm font-medium`,children:`主题模式`}),(0,G.jsxs)(`div`,{className:`flex gap-2 mt-2`,children:[(0,G.jsxs)(q,{variant:e===`light`?`default`:`outline`,size:`sm`,onClick:()=>n(`light`),className:`gap-2`,children:[(0,G.jsx)(Um,{className:`h-4 w-4`}),`亮色`]}),(0,G.jsxs)(q,{variant:e===`dark`?`default`:`outline`,size:`sm`,onClick:()=>n(`dark`),className:`gap-2`,children:[(0,G.jsx)(Am,{className:`h-4 w-4`}),`暗黑`]}),(0,G.jsxs)(q,{variant:e===`system`?`default`:`outline`,size:`sm`,onClick:()=>n(`system`),className:`gap-2`,children:[(0,G.jsx)(km,{className:`h-4 w-4`}),`跟随系统`]})]})]})})]}),(0,G.jsxs)(vb,{className:`p-6`,children:[(0,G.jsx)(`h3`,{className:`font-semibold mb-4`,children:`私密空间 Vault`}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Vault 密码已设置。私密记忆需要输入密码才能查看。`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>l(!c),children:[(0,G.jsx)(Em,{className:`h-4 w-4 mr-2`}),`修改密码`]}),(0,G.jsxs)(q,{variant:`destructive`,size:`sm`,onClick:()=>p(!0),children:[(0,G.jsx)(Km,{className:`h-4 w-4 mr-2`}),`重置 Vault`]})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`尚未设置 Vault 密码。设置后,私密记忆将受到密码保护。`}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>l(!0),children:[(0,G.jsx)(Em,{className:`h-4 w-4 mr-2`}),`设置 Vault 密码`]})]}),c&&(0,G.jsxs)(`div`,{className:`flex gap-2 mt-4`,children:[(0,G.jsx)(`input`,{type:`password`,placeholder:`输入新密码`,value:o,onChange:e=>s(e.target.value),className:`flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm`}),(0,G.jsx)(q,{size:`sm`,onClick:()=>{if(!o||o.length<4){ir.error(`密码至少需要 4 位`);return}i(o),ir.success(`Vault 密码已设置`),s(``),l(!1)},children:`确认`})]})]})]}),(0,G.jsxs)(vb,{className:`p-6`,children:[(0,G.jsx)(`h3`,{className:`font-semibold mb-4`,children:`数据管理`}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:`导出记忆数据`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`从服务端导出所有记忆为 JSON 文件`})]}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:async()=>{d(!0);try{let e=await ib.get(`/v1/memories`,{params:{limit:1e4}}),n={memories:e.memories||[],total_count:e.total_count||0,exportedAt:new Date().toISOString()},r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`omem-memories-${new Date().toISOString().slice(0,10)}.json`,a.click(),URL.revokeObjectURL(i),ir.success(`已导出 ${n.total_count} 条记忆`)}catch(e){console.error(`Failed to export memories:`,e),ir.error(`导出记忆数据失败`)}finally{d(!1)}},disabled:u,children:[(0,G.jsx)(im,{className:`h-4 w-4 mr-2`}),u?`导出中...`:`导出`]})]}),(0,G.jsx)(k7,{}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:`导出本地配置`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`将登录信息、主题等本地设置导出备份`})]}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>{let e={auth:JSON.parse(sessionStorage.getItem(`omem-auth`)||`{}`),vault:`已迁移到服务端存储`,theme:localStorage.getItem(`omem-theme`)||`system`,exportedAt:new Date().toISOString()},n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`omem-config-${new Date().toISOString().slice(0,10)}.json`,i.click(),URL.revokeObjectURL(r),ir.success(`本地配置已导出`)},children:[(0,G.jsx)(am,{className:`h-4 w-4 mr-2`}),`导出`]})]}),(0,G.jsx)(k7,{}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:`清除缓存`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`清除所有本地存储的数据(不可逆)`})]}),(0,G.jsxs)(q,{variant:`destructive`,size:`sm`,onClick:()=>{sessionStorage.clear(),ir.success(`缓存已清除`,{description:`所有本地数据已清除,刷新页面后生效`})},children:[(0,G.jsx)(Km,{className:`h-4 w-4 mr-2`}),`清除`]})]})]})]}),(0,G.jsxs)(vb,{className:`p-6`,children:[(0,G.jsx)(`h3`,{className:`font-semibold mb-4`,children:`关于`}),(0,G.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(vm,{className:`h-4 w-4 text-muted-foreground`}),(0,G.jsx)(`span`,{children:`omem-web v0.1.0`})]}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`omem 自部署版 Web 管理端`}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`备案号:`,(0,G.jsx)(`a`,{href:`https://beian.miit.gov.cn`,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`吉ICP备2026003061号`})]})]})]}),(0,G.jsx)(pJ,{open:f,onOpenChange:p,children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认重置 Vault`}),(0,G.jsx)(vJ,{children:`此操作不可恢复。重置后所有受 Vault 保护的私密记忆将无法访问。`})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{onClick:()=>p(!1),children:`取消`}),(0,G.jsx)(yJ,{onClick:async()=>{try{await ib.delete(`/v1/vault/password`),a(),ir.success(`Vault 已重置`),l(!1),p(!1)}catch{ir.error(`重置 Vault 失败`)}},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`确认重置`})]})]})})]})}function H9(e){return`/v2/profile${e}`}var U9={getPreferences(e){return ib.get(H9(`/preferences`),{params:e?{project_path:e}:void 0})},getPreference(e){return ib.get(H9(`/preferences/${e}`))},createPreference(e){return ib.post(H9(`/preferences`),e)},updatePreference(e,n){return ib.put(H9(`/preferences/${e}`),n)},deletePreference(e){return ib.delete(H9(`/preferences/${e}`))},getStats(e){return ib.get(H9(`/stats`),{params:e?{project_path:e}:void 0})},getInjection(e){return ib.get(H9(`/inject`),{params:e?{project_path:e}:void 0})},triggerInduction(e,n){return ib.post(H9(`/induction/trigger`),{candidate_texts:e??[],project_path:n})},getInductionRuns(e){return ib.get(H9(`/induction/runs`),{params:e?{project_path:e}:void 0})},getVersions(e){return ib.get(H9(`/versions`),{params:e?{project_path:e}:void 0})},getChangelog(e){return ib.get(H9(`/changelog`),{params:e?{project_path:e}:void 0})}};function W9(e){let n=e.toLowerCase();return n.includes(`喜欢`)||n.includes(`偏好`)||n.includes(`习惯`)?{type:`preference`,icon:Cm,color:`text-amber-600 dark:text-amber-400`,bgColor:`bg-amber-50 dark:bg-amber-500/10 border-amber-200 dark:border-amber-500/30`,label:`偏好`}:n.includes(`项目`)||n.includes(`工程`)||n.includes(`开发`)?{type:`project`,icon:eh,color:`text-blue-600 dark:text-blue-400`,bgColor:`bg-blue-50 dark:bg-blue-500/10 border-blue-200 dark:border-blue-500/30`,label:`项目`}:n.includes(`技能`)||n.includes(`能力`)||n.includes(`精通`)||n.includes(`熟练`)?{type:`skill`,icon:Vm,color:`text-violet-600 dark:text-violet-400`,bgColor:`bg-violet-50 dark:bg-violet-500/10 border-violet-200 dark:border-violet-500/30`,label:`技能`}:n.includes(`笔记`)||n.includes(`记录`)||n.includes(`文档`)?{type:`note`,icon:Gp,color:`text-slate-600 dark:text-slate-400`,bgColor:`bg-slate-50 dark:bg-slate-500/10 border-slate-200 dark:border-slate-500/30`,label:`笔记`}:{type:`fact`,icon:Zm,color:`text-emerald-600 dark:text-emerald-400`,bgColor:`bg-emerald-50 dark:bg-emerald-500/10 border-emerald-200 dark:border-emerald-500/30`,label:`事实`}}function Zme(){return{type:`private`,icon:Em,color:`text-amber-600 dark:text-amber-400`,bgColor:`bg-amber-50 dark:bg-amber-500/10 border-amber-200 dark:border-amber-500/30`,label:`私密`}}function G9(e){return e.replace(/^#+\s*/,``).trim()}function Qme(e,n){return n===`private`?!0:e.some(e=>e===`私密`||e.toLowerCase()===`private`)}function $me(e){return new Date(e).toLocaleString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function K9(e){let n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return`刚刚`;if(r<60)return`${r} 分钟前`;let i=Math.floor(r/60);if(i<24)return`${i} 小时前`;let a=Math.floor(i/24);return a<30?`${a} 天前`:$me(e)}function q9({content:e}){let[n,r]=(0,y.useState)(!1),i=(0,y.useRef)(null),[a,o]=(0,y.useState)(!1);return(0,y.useEffect)(()=>{let e=i.current;if(!e)return;let n=new ResizeObserver(()=>o(e.scrollHeight>e.clientHeight));return n.observe(e),()=>n.disconnect()},[]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:Tp(`relative`,!n&&`max-h-60 overflow-hidden`),children:[(0,G.jsx)(`div`,{ref:i,className:`prose prose-sm dark:prose-invert max-w-none`,children:(0,G.jsx)(b0,{remarkPlugins:[d3],children:e})}),!n&&a&&(0,G.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-10 bg-gradient-to-t from-background to-transparent pointer-events-none`})]}),a&&(0,G.jsx)(q,{variant:`ghost`,size:`sm`,className:`mt-1 h-auto py-1 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:()=>r(!n),children:n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(em,{className:`size-3 mr-1`}),`收起`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Zp,{className:`size-3 mr-1`}),`展开全文`]})})]})}var ehe=[{name:`communication_style`,display:`沟通风格`},{name:`tone`,display:`语气偏好`},{name:`code_style`,display:`代码风格`},{name:`error_handling`,display:`错误处理`},{name:`naming_convention`,display:`命名规范`},{name:`testing_strategy`,display:`测试策略`},{name:`workflow_preference`,display:`工作流偏好`},{name:`commit_style`,display:`提交风格`},{name:`emoji_preference`,display:`Emoji偏好`},{name:`self_reference`,display:`自称方式`},{name:`address_style`,display:`称呼方式`},{name:`language`,display:`语言`},{name:`framework_preference`,display:`框架偏好`},{name:`preferred_tools`,display:`工具偏好`}],the={communication_style:`沟通风格`,coding_preferences:`编码偏好`,project_context:`项目上下文`,tool_preferences:`工具偏好`,domain_knowledge:`领域知识`,work_style:`工作风格`,language_preference:`语言偏好`,framework_preferences:`框架偏好`},nhe={communication_style:zp,coding_preferences:eh,project_context:dm,tool_preferences:xm,domain_knowledge:Gp,work_style:Pm,language_preference:Cm,framework_preferences:Vm};function rhe(e){return the[e]||e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function ihe(e){return nhe[e]||xm}var ahe={global:{className:`bg-blue-50 dark:bg-blue-500/10 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-500/30`,label:`全局`},project:{className:`bg-violet-50 dark:bg-violet-500/10 text-violet-700 dark:text-violet-300 border-violet-200 dark:border-violet-500/30`,label:`项目`},session:{className:`bg-emerald-50 dark:bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border-emerald-200 dark:border-emerald-500/30`,label:`会话`}};function ohe(){let e=et(),n=ob(e=>e.unlock),r=ob(e=>e.hasPassword),i=ob(e=>e.isUnlocked),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)([]),[d,f]=(0,y.useState)([]),[p,m]=(0,y.useState)(!0),[h,g]=(0,y.useState)(`preferences`),[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(``),[E,D]=(0,y.useState)(null),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(new Set),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(null),[ee,B]=(0,y.useState)(!1),[V,H]=(0,y.useState)(``),[U,te]=(0,y.useState)(`all`),[W,ne]=(0,y.useState)(1),[re,ie]=(0,y.useState)(1);(0,y.useEffect)(()=>{async function e(){try{m(!0);let e=_||void 0,[n,r,i,a]=await Promise.all([ib.get(`/v1/profile`).catch(()=>null),U9.getStats(e).catch(()=>null),U9.getPreferences(e).catch(()=>[]),U9.getChangelog(e).catch(()=>[])]);n&&o(n),r&&c(r),u(Array.isArray(i)?i:[]),f(Array.isArray(a)?a:[])}catch(e){console.error(`Failed to load profile:`,e),ir.error(`加载画像数据失败`)}finally{m(!1)}}e()},[_]);let ae=async()=>{if(!w.trim()){D(`请输入密码`);return}k(!0);let e=await n(w);if(k(!1),!e){D(`密码错误`);return}S&&j(e=>new Set(e).add(S)),x(!1),C(null),T(``),D(null),ir.success(`已解锁`)},oe=e=>{if(i){j(n=>new Set(n).add(e));return}if(!r){ir.error(`请先在设置中设置密码`);return}C(e),T(``),D(null),x(!0)},se=a?.static_facts||[],ce=a?.dynamic_context||[],le=(0,y.useMemo)(()=>se.map(e=>{let n=Qme(e.tags||[],e.visibility),r=n?Zme():W9(e.content);return{fact:e.content,factObj:e,isPrivate:n,meta:r}}),[se]),ue=(0,y.useMemo)(()=>{let e=new Map;for(let n of l){if(U!==`all`&&n.scope!==U)continue;if(V.trim()){let e=V.toLowerCase();if(!n.value.toLowerCase().includes(e)&&!n.slot.toLowerCase().includes(e)&&!(n.project_path||``).toLowerCase().includes(e))continue}let r=e.get(n.slot)||[];r.push(n),e.set(n.slot,r)}return e},[l,V,U]),de=(0,y.useMemo)(()=>Array.from(ue.entries()),[ue]),fe=Math.max(1,Math.ceil(de.length/5)),pe=(0,y.useMemo)(()=>{let e=(W-1)*5;return de.slice(e,e+5)},[de,W]),me=async()=>{let e=_||void 0,[n,r]=await Promise.all([U9.getPreferences(e),U9.getStats(e).catch(()=>null)]);u(Array.isArray(n)?n:[]),r&&c(r)},he=async e=>{if(!(!(`slot`in e)||!e.slot))try{L(!0),await U9.createPreference(e),ir.success(`偏好已创建`),N(!1),await me()}catch{ir.error(`创建失败`)}finally{L(!1)}},ge=async(e,n)=>{try{L(!0),await U9.updatePreference(e,n),ir.success(`偏好已更新`),F(null);let r=_||void 0,i=await U9.getPreferences(r);u(Array.isArray(i)?i:[])}catch{ir.error(`更新失败`)}finally{L(!1)}},_e=async()=>{if(R)try{B(!0),await U9.deletePreference(R.id),ir.success(`偏好已删除`),z(null),await me()}catch{ir.error(`删除失败`)}finally{B(!1)}},ve=(0,y.useMemo)(()=>{let e=new Set;for(let n of l)n.project_path&&e.add(n.project_path);return Array.from(e).sort()},[l]),ye=l.length;return(0,G.jsxs)(`div`,{className:`min-h-screen bg-gradient-to-b from-background via-background to-muted/30`,children:[(0,G.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-6 space-y-6`,children:[(0,G.jsxs)(q,{variant:`ghost`,size:`sm`,className:`text-muted-foreground hover:text-foreground -ml-2`,onClick:()=>e(-1),children:[(0,G.jsx)(Vp,{className:`size-4 mr-1.5`}),`返回`]}),(0,G.jsxs)(`div`,{className:`relative overflow-hidden rounded-2xl bg-gradient-to-br from-amber-50 via-orange-50 to-rose-50 dark:from-amber-500/10 dark:via-orange-500/5 dark:to-rose-500/10 border border-amber-200/50 dark:border-amber-500/20 p-6 md:p-8`,children:[(0,G.jsx)(`div`,{className:`absolute top-0 right-0 -mt-8 -mr-8 w-48 h-48 bg-amber-400/15 dark:bg-amber-500/10 rounded-full blur-3xl`}),(0,G.jsx)(`div`,{className:`absolute bottom-0 left-0 -mb-6 -ml-6 w-36 h-36 bg-orange-400/10 dark:bg-orange-500/8 rounded-full blur-3xl`}),(0,G.jsxs)(`div`,{className:`relative z-10 flex flex-col md:flex-row md:items-center md:justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-14 rounded-2xl bg-gradient-to-br from-amber-400 to-orange-500 shadow-lg shadow-amber-500/25`,children:(0,G.jsx)(Zm,{className:`size-7 text-white`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl md:text-3xl font-bold tracking-tight text-foreground`,children:`用户画像`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:`偏好 · 记忆 · 洞察`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-2.5 rounded-xl bg-white/80 dark:bg-card/80 border border-amber-200/60 dark:border-amber-500/20 shadow-sm`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-8 rounded-lg bg-amber-100 dark:bg-amber-500/15`,children:(0,G.jsx)(xm,{className:`size-4 text-amber-600 dark:text-amber-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-lg font-bold leading-none text-foreground`,children:ye}),(0,G.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`条偏好`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-2.5 rounded-xl bg-white/80 dark:bg-card/80 border border-orange-200/60 dark:border-orange-500/20 shadow-sm`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-8 rounded-lg bg-orange-100 dark:bg-orange-500/15`,children:(0,G.jsx)(Yp,{className:`size-4 text-orange-600 dark:text-orange-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-lg font-bold leading-none text-foreground`,children:s?.total??0}),(0,G.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`归纳总量`})]})]}),s?.last_induction_at&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-2.5 rounded-xl bg-white/80 dark:bg-card/80 border border-rose-200/60 dark:border-rose-500/20 shadow-sm`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-8 rounded-lg bg-rose-100 dark:bg-rose-500/15`,children:(0,G.jsx)(nm,{className:`size-4 text-rose-600 dark:text-rose-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm font-semibold leading-none text-foreground`,children:K9(s.last_induction_at)}),(0,G.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`最近归纳`})]})]})]})]})]}),(0,G.jsxs)(F7,{value:h,onValueChange:g,className:`space-y-4`,children:[(0,G.jsxs)(I7,{className:`bg-muted/60 p-1 h-auto`,children:[(0,G.jsxs)(L7,{value:`preferences`,className:`data-[state=active]:bg-background data-[state=active]:shadow-sm gap-1.5 px-4 py-2 text-sm`,children:[(0,G.jsx)(Vm,{className:`size-3.5`}),`偏好管理`]}),(0,G.jsxs)(L7,{value:`overview`,className:`data-[state=active]:bg-background data-[state=active]:shadow-sm gap-1.5 px-4 py-2 text-sm`,children:[(0,G.jsx)(Zm,{className:`size-3.5`}),`画像概览`]}),(0,G.jsxs)(L7,{value:`changelog`,className:`data-[state=active]:bg-background data-[state=active]:shadow-sm gap-1.5 px-4 py-2 text-sm`,children:[(0,G.jsx)(mm,{className:`size-3.5`}),`变更历史`]})]}),(0,G.jsxs)(R7,{value:`preferences`,className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-3`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1 w-full sm:max-w-xs`,children:[(0,G.jsx)(Lm,{className:`absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground`}),(0,G.jsx)(hb,{placeholder:`搜索偏好...`,value:V,onChange:e=>{H(e.target.value),ne(1)},className:`pl-9 h-9 bg-muted/40`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ve.length>0&&(0,G.jsxs)(_9,{value:_,onValueChange:e=>e!=null&&v(e),children:[(0,G.jsxs)(y9,{className:`h-9 w-[180px] text-xs`,children:[(0,G.jsx)(dm,{className:`size-3.5 mr-1.5 text-muted-foreground`}),(0,G.jsx)(v9,{placeholder:`全部项目`})]}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`__all__`,children:`全部项目`}),ve.map(e=>(0,G.jsx)(x9,{value:e,children:e.split(`/`).pop()||e},e))]})]}),(0,G.jsxs)(_9,{value:U,onValueChange:e=>{e!=null&&(te(e),ne(1))},children:[(0,G.jsx)(y9,{className:`h-9 w-[100px] text-xs`,children:(0,G.jsx)(v9,{placeholder:`范围`})}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`all`,children:`全部范围`}),(0,G.jsx)(x9,{value:`global`,children:`全局`}),(0,G.jsx)(x9,{value:`project`,children:`项目`}),(0,G.jsx)(x9,{value:`session`,children:`会话`})]})]})]}),(0,G.jsxs)(q,{className:`ml-auto h-9 gap-1.5 bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white shadow-sm`,onClick:()=>N(!0),children:[(0,G.jsx)(Nm,{className:`size-4`}),`新建偏好`]})]}),p?(0,G.jsx)(`div`,{className:`space-y-4`,children:[1,2,3].map(e=>(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(Cb,{className:`h-5 w-24 rounded-md`}),(0,G.jsx)(Cb,{className:`h-24 w-full rounded-xl`})]},e))}):ue.size===0?(0,G.jsx)(vb,{className:`border-dashed`,children:(0,G.jsxs)(Sb,{className:`py-16 flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-2xl bg-muted`,children:(0,G.jsx)(Vm,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:`暂无偏好数据`}),(0,G.jsx)(`p`,{className:`text-xs mt-1`,children:`点击「新建偏好」开始构建你的画像`})]})]})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{id:`pref-slot-list`,className:`space-y-4`,children:pe.map(([e,n])=>(0,G.jsx)(she,{slot:e,preferences:n,onEdit:e=>F(e),onDelete:e=>z(e)},e))}),fe>1&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`第 `,W,` / `,fe,` 页 · 共 `,de.length,` 个分组`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(q,{variant:`outline`,size:`icon`,className:`size-8`,disabled:W<=1,onClick:()=>{ne(e=>Math.max(1,e-1)),document.getElementById(`pref-slot-list`)?.scrollIntoView({behavior:`smooth`,block:`start`})},children:(0,G.jsx)(Qp,{className:`size-4`})}),Array.from({length:fe},(e,n)=>n+1).map(e=>(0,G.jsx)(q,{variant:e===W?`default`:`outline`,size:`icon`,className:Tp(`size-8 text-xs`,e===W&&`bg-gradient-to-r from-amber-500 to-orange-500 text-white border-0`),onClick:()=>{ne(e),document.getElementById(`pref-slot-list`)?.scrollIntoView({behavior:`smooth`,block:`start`})},children:e},e)),(0,G.jsx)(q,{variant:`outline`,size:`icon`,className:`size-8`,disabled:W>=fe,onClick:()=>{ne(e=>Math.min(fe,e+1)),document.getElementById(`pref-slot-list`)?.scrollIntoView({behavior:`smooth`,block:`start`})},children:(0,G.jsx)($p,{className:`size-4`})})]})]})]})]}),(0,G.jsx)(R7,{value:`overview`,className:`space-y-6`,children:p?(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[1,2,3,4].map(e=>(0,G.jsx)(Cb,{className:`h-48 w-full rounded-xl`},e))}):(0,G.jsxs)(G.Fragment,{children:[le.length>0&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(zm,{className:`size-5 text-amber-500`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:`画像特征`}),(0,G.jsxs)(CJ,{variant:`secondary`,className:`text-[10px]`,children:[le.length,` 条`]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:le.map(({fact:e,factObj:n,isPrivate:r,meta:i})=>{let a=i.icon,o=A.has(e),s=r&&o&&n?.l2_content||G9(e);return(0,G.jsx)(vb,{className:Tp(`relative overflow-hidden border transition-all duration-200 hover:shadow-md`,r&&!o&&`border-amber-200 dark:border-amber-500/30`),children:(0,G.jsxs)(Sb,{className:`p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,G.jsx)(`div`,{className:Tp(`flex items-center justify-center size-8 rounded-lg border`,i.bgColor),children:(0,G.jsx)(a,{className:Tp(`size-4`,i.color)})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,G.jsxs)(CJ,{variant:`outline`,className:`text-[10px] gap-1 bg-amber-50 dark:bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-500/30`,children:[(0,G.jsx)(Em,{className:`size-2.5`}),`私密`]}),(0,G.jsx)(CJ,{variant:`outline`,className:Tp(`text-[10px]`,i.bgColor,i.color),children:i.label})]})]}),(0,G.jsx)(`div`,{className:Tp(r&&!o&&`blur-[6px] select-none opacity-40`),children:(0,G.jsx)(q9,{content:s})}),r&&!o&&(0,G.jsx)(`button`,{type:`button`,className:`mt-3 w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg bg-amber-50 dark:bg-amber-500/10 text-amber-700 dark:text-amber-300 text-xs font-medium hover:bg-amber-100 dark:hover:bg-amber-500/20 transition-colors border border-amber-200 dark:border-amber-500/30 cursor-pointer`,onClick:()=>oe(e),children:o?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(om,{className:`size-3.5`}),`已解锁`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Em,{className:`size-3.5`}),`点击解锁私密内容`]})})]})},`sf-${e.slice(0,40)}`)})})]}),ce.length>0&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(k7,{}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(zp,{className:`size-5 text-blue-500`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:`静态偏好`}),(0,G.jsxs)(CJ,{variant:`secondary`,className:`text-[10px]`,children:[ce.length,` 条`]})]}),(0,G.jsxs)(`div`,{className:`relative pl-6 space-y-3`,children:[(0,G.jsx)(`div`,{className:`absolute left-[11px] top-2 bottom-2 w-px bg-gradient-to-b from-blue-300 via-orange-300 to-transparent dark:from-blue-500/40 dark:via-orange-500/40 dark:to-transparent`}),ce.map((e,n)=>{let r=W9(e),i=r.icon;return(0,G.jsxs)(`div`,{className:`relative group`,children:[(0,G.jsx)(`div`,{className:`absolute -left-6 top-2.5 size-[22px] rounded-full bg-gradient-to-br from-blue-400 to-orange-400 ring-[3px] ring-background flex items-center justify-center shadow-sm group-hover:scale-110 transition-transform`,children:(0,G.jsx)(`span`,{className:`text-[9px] font-bold text-white`,children:n+1})}),(0,G.jsx)(vb,{className:`overflow-hidden hover:shadow-sm transition-shadow`,children:(0,G.jsxs)(Sb,{className:`p-3.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,G.jsx)(`div`,{className:Tp(`flex items-center justify-center size-5 rounded-md border`,r.bgColor),children:(0,G.jsx)(i,{className:Tp(`size-3`,r.color)})}),(0,G.jsx)(`span`,{className:Tp(`text-[10px] font-medium px-1.5 py-0.5 rounded border`,r.bgColor,r.color),children:r.label})]}),(0,G.jsx)(q9,{content:G9(e)})]})})]},`dc-${n}`)})]})]}),le.length===0&&ce.length===0&&(0,G.jsx)(vb,{className:`border-dashed`,children:(0,G.jsxs)(Sb,{className:`py-16 flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-2xl bg-muted`,children:(0,G.jsx)(Zm,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:`暂无画像数据`}),(0,G.jsx)(`p`,{className:`text-xs mt-1`,children:`存储更多记忆后,系统将自动构建您的用户画像`})]})]})})]})}),(0,G.jsx)(R7,{value:`changelog`,className:`space-y-4`,children:p?(0,G.jsx)(`div`,{className:`space-y-3`,children:[1,2,3].map(e=>(0,G.jsx)(Cb,{className:`h-20 w-full rounded-xl`},e))}):d.length===0?(0,G.jsx)(vb,{className:`border-dashed`,children:(0,G.jsxs)(Sb,{className:`py-16 flex flex-col items-center gap-3 text-muted-foreground`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-2xl bg-muted`,children:(0,G.jsx)(mm,{className:`size-6`})}),(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium`,children:`暂无变更记录`}),(0,G.jsx)(`p`,{className:`text-xs mt-1`,children:`偏好变更时将自动记录在这里`})]})]})}):(()=>{let e=Math.ceil(d.length/10),n=d.slice((re-1)*10,re*10);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`relative pl-6 space-y-3`,children:[(0,G.jsx)(`div`,{className:`absolute left-[11px] top-2 bottom-2 w-px bg-gradient-to-b from-violet-300 via-sky-300 to-transparent dark:from-violet-500/40 dark:via-sky-500/40 dark:to-transparent`}),n.map(e=>{let n=e.action===`created`,r=e.action===`updated`,i=n?{bg:`from-emerald-400 to-teal-400`,color:`text-emerald-700 dark:text-emerald-300`,badgeClass:`bg-emerald-50 dark:bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border-emerald-200 dark:border-emerald-500/30`,symbol:`+`,label:`创建`}:r?{bg:`from-blue-400 to-sky-400`,color:`text-blue-700 dark:text-blue-300`,badgeClass:`bg-blue-50 dark:bg-blue-500/10 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-500/30`,symbol:`~`,label:`更新`}:{bg:`from-rose-400 to-red-400`,color:`text-rose-700 dark:text-rose-300`,badgeClass:`bg-rose-50 dark:bg-rose-500/10 text-rose-700 dark:text-rose-300 border-rose-200 dark:border-rose-500/30`,symbol:`−`,label:`删除`};return(0,G.jsxs)(`div`,{className:`relative group min-w-0`,children:[(0,G.jsx)(`div`,{className:Tp(`absolute -left-6 top-2.5 size-[22px] rounded-full bg-gradient-to-br ring-[3px] ring-background flex items-center justify-center shadow-sm group-hover:scale-110 transition-transform`,i.bg),children:(0,G.jsx)(`span`,{className:`text-[9px] font-bold text-white`,children:i.symbol})}),(0,G.jsx)(vb,{className:`overflow-hidden hover:shadow-sm transition-shadow min-w-0`,children:(0,G.jsxs)(Sb,{className:`p-4 space-y-2 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,G.jsxs)(CJ,{variant:`outline`,className:Tp(`text-[10px] gap-1 shrink-0`,i.badgeClass),children:[n?(0,G.jsx)(Nm,{className:`size-2.5`}):r?(0,G.jsx)(Mm,{className:`size-2.5`}):(0,G.jsx)(Km,{className:`size-2.5`}),i.label]}),e.source&&(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate`,children:e.source}),(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto shrink-0`,children:K9(e.created_at)})]}),e.old_value&&(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground line-through break-all`,children:e.old_value}),e.new_value&&(0,G.jsx)(`p`,{className:`text-sm leading-relaxed break-words`,children:e.new_value})]})})]},e.id)})]}),e>1&&(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 pt-2`,children:[(0,G.jsxs)(q,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:re<=1,onClick:()=>ie(e=>Math.max(1,e-1)),children:[(0,G.jsx)(Qp,{className:`size-3`}),`上一页`]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1`,children:Array.from({length:e},(e,n)=>n+1).map(e=>(0,G.jsx)(q,{variant:re===e?`default`:`ghost`,size:`sm`,className:`h-7 w-7 text-xs p-0`,onClick:()=>ie(e),children:e},e))}),(0,G.jsxs)(q,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:re>=e,onClick:()=>ie(n=>Math.min(e,n+1)),children:[`下一页`,(0,G.jsx)($p,{className:`size-3`})]})]})]})})()})]})]}),(0,G.jsx)(pJ,{open:!!R,onOpenChange:e=>{!e&&!ee&&z(null)},children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除偏好`}),(0,G.jsxs)(vJ,{children:[`确定要删除这条偏好吗?此操作不可撤销。`,R&&(0,G.jsx)(`span`,{className:`block mt-2 px-3 py-2 rounded-lg bg-muted text-sm text-foreground max-h-24 overflow-y-auto break-words`,children:R.value})]})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{disabled:ee,children:`取消`}),(0,G.jsx)(yJ,{disabled:ee,onClick:_e,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:ee?`删除中...`:`删除`})]})]})}),(0,G.jsx)(J9,{open:M,onOpenChange:N,saving:I,onSubmit:he,title:`新建偏好`}),(0,G.jsx)(J9,{open:!!P,onOpenChange:e=>{e||F(null)},saving:I,onSubmit:e=>{P&&ge(P.id,e)},pref:P,title:`编辑偏好`}),(0,G.jsx)(A9,{open:b,onOpenChange:e=>{e||(x(!1),T(``),D(null))},children:(0,G.jsxs)(j9,{className:`sm:max-w-sm`,children:[(0,G.jsxs)(M9,{children:[(0,G.jsxs)(P9,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Em,{className:`size-4 text-amber-500`}),`解锁私密记忆`]}),(0,G.jsx)(F9,{children:`请输入您的 Vault 密码以解锁受保护的内容。`})]}),(0,G.jsx)(`div`,{className:`space-y-3`,children:(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{className:`text-xs`,children:`密码`}),(0,G.jsx)(hb,{type:`password`,placeholder:`输入 Vault 密码...`,value:w,onChange:e=>{T(e.target.value),D(null)},onKeyDown:e=>e.key===`Enter`&&ae(),className:E?`border-destructive`:``,autoFocus:!0}),E&&(0,G.jsx)(`p`,{className:`text-xs text-destructive`,children:E})]})}),(0,G.jsxs)(N9,{children:[(0,G.jsx)(q,{variant:`outline`,onClick:()=>x(!1),disabled:O,children:`取消`}),(0,G.jsx)(q,{onClick:ae,disabled:O||!w.trim(),children:O?`解锁中...`:`解锁`})]})]})})]})}function she({slot:e,preferences:n,onEdit:r,onDelete:i}){let[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(4),l=ihe(e),u=n.slice(0,s),d=s<n.length;return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2.5 w-full group cursor-pointer text-left border-none bg-transparent p-0`,onClick:()=>{o(!a),c(4)},children:[(0,G.jsx)(`div`,{className:`flex items-center justify-center size-7 rounded-lg bg-gradient-to-br from-amber-100 to-orange-100 dark:from-amber-500/15 dark:to-orange-500/15 border border-amber-200/60 dark:border-amber-500/20`,children:(0,G.jsx)(l,{className:`size-3.5 text-amber-600 dark:text-amber-400`})}),(0,G.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:rhe(e)}),(0,G.jsx)(CJ,{variant:`secondary`,className:`text-[10px]`,children:n.length}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)($p,{className:Tp(`size-4 text-muted-foreground transition-transform duration-200`,!a&&`rotate-90`)})]}),!a&&(0,G.jsxs)(`div`,{className:`space-y-2.5 pl-9`,children:[(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2.5`,children:u.map(e=>(0,G.jsx)(che,{pref:e,onEdit:r,onDelete:i},e.id))}),d&&(0,G.jsxs)(`button`,{type:`button`,className:`w-full flex items-center justify-center gap-1.5 py-2 text-xs text-muted-foreground hover:text-foreground transition-colors rounded-lg hover:bg-muted/50 cursor-pointer`,onClick:()=>c(e=>Math.min(e+4,n.length)),children:[(0,G.jsx)(Zp,{className:`size-3.5`}),`加载更多(剩余 `,n.length-s,` 条)`]})]})]})}function che({pref:e,onEdit:n,onDelete:r}){let i=ahe[e.scope]||{className:`bg-slate-50 dark:bg-slate-500/10 text-slate-700 dark:text-slate-300 border-slate-200 dark:border-slate-500/30`,label:e.scope};return(0,G.jsx)(vb,{className:`group hover:shadow-md transition-all duration-200 border-border/60`,children:(0,G.jsxs)(Sb,{className:`p-3.5 space-y-2.5`,children:[(0,G.jsx)(`p`,{className:`text-sm leading-relaxed whitespace-pre-wrap break-words`,children:e.value}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,G.jsx)(CJ,{variant:`outline`,className:Tp(`text-[10px] gap-1`,i.className),children:i.label}),e.project_path&&(0,G.jsxs)(CJ,{variant:`outline`,className:`text-[10px] gap-1 bg-violet-50 dark:bg-violet-500/10 text-violet-700 dark:text-violet-300 border-violet-200 dark:border-violet-500/30`,children:[(0,G.jsx)(dm,{className:`size-2.5`}),e.project_path.split(`/`).pop()]}),(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:K9(e.updated_at)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity pt-1 border-t border-border/40`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] text-muted-foreground mr-auto`,children:[`置信度 `,(e.confidence*100).toFixed(0),`%`]}),(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7 text-muted-foreground hover:text-foreground`,onClick:()=>n(e),children:(0,G.jsx)(Mm,{className:`size-3.5`})}),(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7 text-muted-foreground hover:text-destructive`,onClick:()=>r(e),children:(0,G.jsx)(Km,{className:`size-3.5`})})]})]})})}function J9({open:e,onOpenChange:n,saving:r,onSubmit:i,pref:a,title:o}){let s=!!a,[c,l]=(0,y.useState)(a?.slot||``),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(a?.value||``),[m,h]=(0,y.useState)(String(a?.confidence??.8)),[g,_]=(0,y.useState)(a?.scope||`global`),[v,b]=(0,y.useState)(a?.project_path||``);(0,y.useEffect)(()=>{if(e){let e=a?.slot||``;l(e),d(e.startsWith(`custom:`)?e.slice(7):``),p(a?.value||``),h(String(a?.confidence??.8)),_(a?.scope||`global`),b(a?.project_path||``)}},[e,a]);let x=c===`__custom__`;return(0,G.jsx)(A9,{open:e,onOpenChange:n,children:(0,G.jsxs)(j9,{className:`sm:max-w-md`,children:[(0,G.jsxs)(M9,{children:[(0,G.jsxs)(P9,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Vm,{className:`size-4 text-amber-500`}),o]}),(0,G.jsx)(F9,{children:s?`修改偏好信息。`:`添加一条新的偏好。`})]}),(0,G.jsxs)(`div`,{className:`space-y-4 py-1`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{className:`text-xs`,children:`Slot (类别)`}),s?(0,G.jsx)(hb,{value:c,disabled:!0,className:`h-9 bg-muted/60`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(_9,{value:c||void 0,onValueChange:e=>e!=null&&l(e),children:[(0,G.jsx)(y9,{className:`h-9 w-full`,children:(0,G.jsx)(v9,{placeholder:`选择类别...`})}),(0,G.jsxs)(b9,{children:[ehe.map(e=>(0,G.jsx)(x9,{value:e.name,children:e.display},e.name)),(0,G.jsx)(x9,{value:`__custom__`,children:`自定义 (custom:...)`})]})]}),x&&(0,G.jsx)(hb,{placeholder:`自定义 slot 名 (小写字母+数字+下划线)`,value:u,onChange:e=>{d(e.target.value.replace(/[^a-z0-9_]/g,``))},className:`h-9`,maxLength:50})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{className:`text-xs`,children:`范围`}),(0,G.jsxs)(_9,{value:g,onValueChange:e=>e!=null&&_(e),children:[(0,G.jsx)(y9,{className:`h-9`,children:(0,G.jsx)(v9,{})}),(0,G.jsxs)(b9,{children:[(0,G.jsx)(x9,{value:`global`,children:`全局`}),(0,G.jsx)(x9,{value:`project`,children:`项目`}),(0,G.jsx)(x9,{value:`session`,children:`会话`})]})]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{className:`text-xs`,children:`内容`}),(0,G.jsx)(T9,{placeholder:`偏好内容...`,value:f,onChange:e=>p(e.target.value),rows:3,className:`resize-none`,maxLength:500})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{className:`text-xs`,children:`置信度 (0-1)`}),(0,G.jsx)(hb,{type:`number`,min:`0`,max:`1`,step:`0.1`,value:m,onChange:e=>h(e.target.value),className:`h-9`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{className:`text-xs`,children:`项目路径 (可选)`}),(0,G.jsx)(hb,{placeholder:`例: /path/to/project`,value:v,onChange:e=>b(e.target.value),className:`h-9`,maxLength:200})]})]})]}),(0,G.jsxs)(N9,{children:[(0,G.jsx)(q,{variant:`outline`,onClick:()=>n(!1),disabled:r,children:`取消`}),(0,G.jsx)(q,{onClick:()=>{let e=x?`custom:${u.trim()}`:c.trim();if(!e||!f.trim()){ir.error(`请填写 Slot 和内容`);return}if(x&&!u.trim()){ir.error(`请填写自定义 Slot 名`);return}if(s){let e={};f!==(a?.value||``)&&(e.value=f.trim()),m!==String(a?.confidence??.8)&&(e.confidence=parseFloat(m)),g!==(a?.scope||`global`)&&(e.scope=g),v!==(a?.project_path||``)&&(e.project_path=v.trim()||void 0),i(e)}else i({slot:e,value:f.trim(),confidence:parseFloat(m)||.8,scope:g,project_path:v.trim()||void 0})},disabled:r||!f.trim()||(x?!u.trim():!c.trim()),className:`bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white`,children:r?s?`保存中...`:`创建中...`:s?`保存`:`创建`})]})]})})}var Y9=y.createContext(void 0);function lhe(){let e=y.useContext(Y9);if(e===void 0)throw Error(Ir(63));return e}var X9=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Z9={...lb,checked(e){return e?{[X9.checked]:``}:{[X9.unchecked]:``}}};function uhe(e,n,r,i=!0,a){let[o,s]=y.useState(),c=yd(a?`${a}-label`:void 0),l=e??n??o;return Pr(()=>{let a=e||n||!i?void 0:dhe(r.current,c);o!==a&&s(a)}),l}function dhe(e,n){let r=fhe(e);if(r)return!r.id&&n&&(r.id=n),r.id||void 0}function fhe(e){if(!e)return;let n=e.parentElement;if(n&&n.tagName===`LABEL`)return n;let r=e.id;if(r){let n=e.nextElementSibling;if(n&&n.htmlFor===r)return n}let i=e.labels;return i&&i[0]}var phe=y.forwardRef(function(e,n){let{checked:r,className:i,defaultChecked:a,"aria-labelledby":o,form:s,id:c,inputRef:l,name:u,nativeButton:d=!1,onCheckedChange:f,readOnly:p=!1,required:m=!1,disabled:h=!1,render:g,uncheckedValue:_,value:v,style:b,...x}=e,{clearErrors:S}=db(),{state:C,setTouched:w,setDirty:T,validityData:E,setFilled:D,setFocused:O,shouldValidateOnChange:k,validationMode:A,disabled:j,name:M,validation:N}=ub(),{labelId:P}=fb(),F=j||h,I=M??u,L=Ca(f),R=y.useRef(null),z=pa(R,l,N.inputRef),ee=y.useRef(null),B=yd(),V=mb({id:c,implicit:!1,controlRef:ee}),H=d?void 0:V,[U,te]=Rg({controlled:r,default:!!a,name:`Switch`,state:`checked`});pb(ee,{id:B,value:U}),Pr(()=>{R.current&&D(R.current.checked)},[R,D]),cg(U,()=>{S(I),T(U!==E.initialValue),D(U),k()?N.commit(U):N.commit(U,!0)});let{getButtonProps:W,buttonRef:ne}=mh({disabled:F,native:d}),re=uhe(o,P,R,!d,H),ie={id:d?V:B,role:`switch`,"aria-checked":U,"aria-readonly":p||void 0,"aria-required":m||void 0,"aria-labelledby":re,onFocus(){F||O(!0)},onBlur(){let e=R.current;!e||F||(w(!0),O(!1),A===`onBlur`&&N.commit(e.checked))},onClick(e){p||F||(e.preventDefault(),R.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},ae=y.useMemo(()=>Rs({checked:U,disabled:F,form:s,id:H,name:I,required:m,style:I?Na:Ma,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:z,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(p){e.preventDefault();return}let n=e.currentTarget.checked,r=Ii(xi,e.nativeEvent);L?.(n,r),!r.isCanceled&&te(n)},onFocus(){ee.current?.focus()}},N.getInputValidationProps,v===void 0?hi:{value:v}),[U,F,s,z,H,I,L,p,m,te,N,v]),oe=y.useMemo(()=>({...C,checked:U,disabled:F,readOnly:p,required:m}),[C,U,F,p,m]),se=Qs(`span`,e,{state:oe,ref:[n,ee,ne],props:[ie,N.getValidationProps,x,W],stateAttributesMapping:Z9});return(0,G.jsxs)(Y9.Provider,{value:oe,children:[se,!U&&I&&_!==void 0&&(0,G.jsx)(`input`,{type:`hidden`,form:s,name:I,value:_}),(0,G.jsx)(`input`,{...ae,suppressHydrationWarning:!0})]})}),mhe=y.forwardRef(function(e,n){let{render:r,className:i,style:a,...o}=e,{state:s}=ub(),c=lhe();return Qs(`span`,e,{state:{...s,...c},ref:n,stateAttributesMapping:Z9,props:o})});function hhe({className:e,size:n=`default`,...r}){return(0,G.jsx)(phe,{"data-slot":`switch`,"data-size":n,className:Tp(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...r,children:(0,G.jsx)(mhe,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}var Q9={list(){return ib.get(`/v1/categories`)},get(e){return ib.get(`/v1/categories/${encodeURIComponent(e)}`)},create(e){return ib.post(`/v1/categories`,e)},update(e,n){return ib.put(`/v1/categories/${encodeURIComponent(e)}`,n)},delete(e){return ib.delete(`/v1/categories/${encodeURIComponent(e)}`)},listAliases(){return ib.get(`/v1/categories/aliases`)},createAlias(e,n){return ib.post(`/v1/categories/aliases`,{alias:e,target:n})},deleteAlias(e){return ib.delete(`/v1/categories/aliases/${encodeURIComponent(e)}`)}},$9={name:``,display_name:``,description:``,decision_rule:``,always_merge:!1,append_only:!1,temporal_versioned:!1,merge_supported:!1,admission_weight:.5,importance_base:.5,prompt_format:``,default_visibility:`global`,default_scope:`global`,default_ttl_days:0,sort_order:100,is_active:!0};function ghe(){let[e,n]=(0,y.useState)([]),[r,i]=(0,y.useState)([]),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)($9),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)(``),[S,C]=(0,y.useState)(null),w=(0,y.useCallback)(async()=>{try{let e=await Q9.list();n(Array.isArray(e)?e:[])}catch{ir.error(`加载分类失败`)}},[]),T=(0,y.useCallback)(async()=>{try{let e=await Q9.listAliases();i(Array.isArray(e)?e:[])}catch{ir.error(`加载别名失败`)}},[]);(0,y.useEffect)(()=>{Promise.all([w(),T()]).finally(()=>o(!1))},[w,T]);let E=()=>{c(null),f($9),u(!0)},D=e=>{c(e),f({name:e.name,display_name:e.display_name,description:e.description,decision_rule:e.decision_rule||``,always_merge:e.always_merge,append_only:e.append_only,temporal_versioned:e.temporal_versioned,merge_supported:e.merge_supported,admission_weight:e.admission_weight,importance_base:e.importance_base,prompt_format:e.prompt_format||``,default_visibility:e.default_visibility,default_scope:e.default_scope,default_ttl_days:e.default_ttl_days||0,sort_order:e.sort_order,is_active:e.is_active}),u(!0)};return a?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-64 text-muted-foreground`,children:`加载中...`}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-bold`,children:`分类字典`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`管理记忆分类和别名映射`})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(q,{variant:`outline`,onClick:()=>g(!0),children:[(0,G.jsx)(wm,{className:`size-4 mr-1`}),`添加别名`]}),(0,G.jsxs)(q,{onClick:E,children:[(0,G.jsx)(Nm,{className:`size-4 mr-1`}),`新建分类`]})]})]}),(0,G.jsx)(k7,{}),r.length>0&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,G.jsx)(wm,{className:`size-4`}),`别名映射 (`,r.length,`)`]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:r.map(e=>(0,G.jsxs)(vb,{className:`p-3 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,G.jsx)(`code`,{className:`bg-muted px-1.5 py-0.5 rounded text-xs`,children:e.alias}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,G.jsx)(`code`,{className:`bg-muted px-1.5 py-0.5 rounded text-xs`,children:e.target})]}),(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7 text-destructive hover:text-destructive`,onClick:()=>C(e.alias),children:(0,G.jsx)($m,{className:`size-3.5`})})]},e.alias))}),(0,G.jsx)(k7,{})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2`,children:[(0,G.jsx)(Wm,{className:`size-4`}),`分类列表 (`,e.length,`)`]}),(0,G.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,G.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,G.jsx)(`thead`,{className:`bg-muted/50`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`名称`}),(0,G.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`显示名`}),(0,G.jsx)(`th`,{className:`text-left p-3 font-medium hidden md:table-cell`,children:`描述`}),(0,G.jsx)(`th`,{className:`text-center p-3 font-medium`,children:`权重`}),(0,G.jsx)(`th`,{className:`text-center p-3 font-medium`,children:`状态`}),(0,G.jsx)(`th`,{className:`text-right p-3 font-medium`,children:`操作`})]})}),(0,G.jsx)(`tbody`,{className:`divide-y`,children:e.map(e=>(0,G.jsxs)(`tr`,{className:`hover:bg-muted/30`,children:[(0,G.jsx)(`td`,{className:`p-3`,children:(0,G.jsx)(`code`,{className:`bg-muted px-1.5 py-0.5 rounded text-xs`,children:e.name})}),(0,G.jsx)(`td`,{className:`p-3 font-medium`,children:e.display_name}),(0,G.jsx)(`td`,{className:`p-3 text-muted-foreground hidden md:table-cell max-w-[200px] truncate`,children:e.description}),(0,G.jsx)(`td`,{className:`p-3 text-center`,children:(0,G.jsx)(`span`,{className:`text-xs`,children:e.admission_weight.toFixed(2)})}),(0,G.jsx)(`td`,{className:`p-3 text-center`,children:(0,G.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${e.is_active?`bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400`:`bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-400`}`,children:e.is_active?`启用`:`禁用`})}),(0,G.jsx)(`td`,{className:`p-3 text-right`,children:(0,G.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>D(e),children:(0,G.jsx)(ree,{className:`size-3.5`})}),(0,G.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-7 text-destructive hover:text-destructive`,onClick:()=>m(e.name),children:(0,G.jsx)(Km,{className:`size-3.5`})})]})})]},e.name))})]})})]}),(0,G.jsx)(A9,{open:l,onOpenChange:u,children:(0,G.jsxs)(j9,{className:`max-w-lg max-h-[80vh] overflow-y-auto`,children:[(0,G.jsx)(M9,{children:(0,G.jsx)(P9,{children:s?`编辑分类`:`新建分类`})}),(0,G.jsxs)(`div`,{className:`space-y-4 py-2`,children:[!s&&(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`名称 (name)`}),(0,G.jsx)(hb,{value:d.name,onChange:e=>f(n=>({...n,name:e.target.value.toLowerCase()})),placeholder:`e.g. preferences`,maxLength:50})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`显示名 (display_name)`}),(0,G.jsx)(hb,{value:d.display_name,onChange:e=>f(n=>({...n,display_name:e.target.value})),placeholder:`e.g. 偏好设置`,maxLength:100})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`描述`}),(0,G.jsx)(hb,{value:d.description,onChange:e=>f(n=>({...n,description:e.target.value})),placeholder:`分类描述`,maxLength:500})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`决策规则 (decision_rule)`}),(0,G.jsx)(hb,{value:d.decision_rule,onChange:e=>f(n=>({...n,decision_rule:e.target.value})),placeholder:`可选`,maxLength:200})]}),(0,G.jsx)(k7,{}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`准入权重`}),(0,G.jsx)(hb,{type:`number`,step:.05,min:0,max:1,value:d.admission_weight,onChange:e=>f(n=>({...n,admission_weight:+e.target.value}))})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`重要性基数`}),(0,G.jsx)(hb,{type:`number`,step:.05,min:0,max:1,value:d.importance_base,onChange:e=>f(n=>({...n,importance_base:+e.target.value}))})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`排序`}),(0,G.jsx)(hb,{type:`number`,value:d.sort_order,onChange:e=>f(n=>({...n,sort_order:+e.target.value}))})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`默认TTL (天)`}),(0,G.jsx)(hb,{type:`number`,value:d.default_ttl_days,onChange:e=>f(n=>({...n,default_ttl_days:+e.target.value}))})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`提示格式 (prompt_format)`}),(0,G.jsx)(hb,{value:d.prompt_format,onChange:e=>f(n=>({...n,prompt_format:e.target.value})),placeholder:`可选`,maxLength:500})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`默认可见性`}),(0,G.jsxs)(`select`,{className:`w-full h-9 rounded-md border border-input bg-background px-3 text-sm`,value:d.default_visibility,onChange:e=>f(n=>({...n,default_visibility:e.target.value})),children:[(0,G.jsx)(`option`,{value:`global`,children:`global`}),(0,G.jsx)(`option`,{value:`project`,children:`project`}),(0,G.jsx)(`option`,{value:`private`,children:`private`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`默认作用域`}),(0,G.jsxs)(`select`,{className:`w-full h-9 rounded-md border border-input bg-background px-3 text-sm`,value:d.default_scope,onChange:e=>f(n=>({...n,default_scope:e.target.value})),children:[(0,G.jsx)(`option`,{value:`global`,children:`global`}),(0,G.jsx)(`option`,{value:`project`,children:`project`})]})]})]}),(0,G.jsx)(k7,{}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[[`always_merge`,`始终合并`],[`append_only`,`仅追加`],[`temporal_versioned`,`时序版本`],[`merge_supported`,`支持合并`],[`is_active`,`启用`]].map(([e,n])=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border p-3`,children:[(0,G.jsx)(gb,{className:`text-sm`,children:n}),(0,G.jsx)(hhe,{checked:d[e],onCheckedChange:n=>f(r=>({...r,[e]:n}))})]},e))})]}),(0,G.jsxs)(N9,{children:[(0,G.jsx)(q,{variant:`outline`,onClick:()=>u(!1),children:`取消`}),(0,G.jsx)(q,{onClick:async()=>{if(!d.name.trim()||!d.display_name.trim()){ir.error(`名称和显示名为必填项`);return}try{let e={...d,decision_rule:d.decision_rule||null,prompt_format:d.prompt_format||null,default_ttl_days:d.default_ttl_days||null};s?(await Q9.update(s.name,e),ir.success(`分类已更新`)):(await Q9.create(e),ir.success(`分类已创建`)),u(!1),w()}catch(e){let n=e instanceof Error?e.message:`操作失败`;ir.error(n)}},children:s?`保存`:`创建`})]})]})}),(0,G.jsx)(pJ,{open:!!p,onOpenChange:()=>m(null),children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除分类`}),(0,G.jsxs)(vJ,{children:[`确定要删除分类 "`,p,`" 吗?此操作不可撤销。`]})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{children:`取消`}),(0,G.jsx)(yJ,{onClick:async()=>{if(p)try{await Q9.delete(p),ir.success(`分类已删除`),m(null),w()}catch{ir.error(`删除失败`)}},children:`删除`})]})]})}),(0,G.jsx)(A9,{open:h,onOpenChange:g,children:(0,G.jsxs)(j9,{className:`max-w-sm`,children:[(0,G.jsx)(M9,{children:(0,G.jsx)(P9,{children:`添加别名`})}),(0,G.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`别名`}),(0,G.jsx)(hb,{value:_,onChange:e=>v(e.target.value),placeholder:`e.g. likes`,maxLength:50})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(gb,{children:`目标分类`}),(0,G.jsxs)(`select`,{className:`w-full h-9 rounded-md border border-input bg-background px-3 text-sm`,value:b,onChange:e=>x(e.target.value),children:[(0,G.jsx)(`option`,{value:``,children:`选择分类...`}),e.map(e=>(0,G.jsxs)(`option`,{value:e.name,children:[e.display_name,` (`,e.name,`)`]},e.name))]})]})]}),(0,G.jsxs)(N9,{children:[(0,G.jsx)(q,{variant:`outline`,onClick:()=>g(!1),children:`取消`}),(0,G.jsx)(q,{onClick:async()=>{if(!_.trim()||!b.trim()){ir.error(`别名和目标分类为必填项`);return}try{await Q9.createAlias(_,b),ir.success(`别名已创建`),g(!1),v(``),x(``),T()}catch(e){let n=e instanceof Error?e.message:`创建别名失败`;ir.error(n)}},children:`创建`})]})]})}),(0,G.jsx)(pJ,{open:!!S,onOpenChange:()=>C(null),children:(0,G.jsxs)(mJ,{children:[(0,G.jsxs)(hJ,{children:[(0,G.jsx)(_J,{children:`确认删除别名`}),(0,G.jsxs)(vJ,{children:[`确定要删除别名 "`,S,`" 吗?`]})]}),(0,G.jsxs)(gJ,{children:[(0,G.jsx)(bJ,{children:`取消`}),(0,G.jsx)(yJ,{onClick:async()=>{if(S)try{await Q9.deleteAlias(S),ir.success(`别名已删除`),C(null),T()}catch{ir.error(`删除别名失败`)}},children:`删除`})]})]})})]})}function _he(){let e=et();return(0,G.jsx)(`div`,{className:`flex h-screen w-full flex-col items-center justify-center bg-background text-foreground`,children:(0,G.jsxs)(`div`,{className:`text-center space-y-6`,children:[(0,G.jsx)(`div`,{className:`text-8xl font-bold text-muted-foreground/30`,children:`404`}),(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`页面不存在`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-sm`,children:`您访问的页面可能已经删除、移动,或者从未存在过。`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,G.jsxs)(q,{variant:`outline`,onClick:()=>e(-1),children:[(0,G.jsx)(Vp,{className:`h-4 w-4 mr-2`}),`返回上一页`]}),(0,G.jsxs)(q,{onClick:()=>e(`/dashboard`),children:[(0,G.jsx)(hm,{className:`h-4 w-4 mr-2`}),`返回首页`]})]})]})})}var vhe=class extends y.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,n){console.error(`ErrorBoundary caught an error:`,e,n)}handleRefresh=()=>{window.location.reload()};handleGoHome=()=>{window.location.href=`/`};render(){return this.state.hasError?(0,G.jsx)(`div`,{className:`flex h-screen w-full flex-col items-center justify-center bg-background text-foreground`,children:(0,G.jsxs)(`div`,{className:`text-center space-y-6 max-w-md px-4`,children:[(0,G.jsx)(`div`,{className:`text-6xl font-bold text-destructive/30`,children:`⚠️`}),(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`出错了`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`应用遇到了意外错误。请尝试刷新页面,或返回首页。`}),this.state.error&&(0,G.jsx)(`div`,{className:`rounded-lg bg-muted p-4 text-left`,children:(0,G.jsx)(`p`,{className:`text-xs font-mono text-muted-foreground break-all`,children:this.state.error.message})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,G.jsxs)(q,{variant:`outline`,onClick:this.handleRefresh,children:[(0,G.jsx)(Pm,{className:`h-4 w-4 mr-2`}),`刷新页面`]}),(0,G.jsxs)(q,{onClick:this.handleGoHome,children:[(0,G.jsx)(hm,{className:`h-4 w-4 mr-2`}),`返回首页`]})]})]})}):this.props.children}};function yhe({children:e}){let n=dh(e=>e.isAuthenticated),r=typeof window<`u`&&window.localStorage.getItem(`e2e_bypass_auth`)===`true`;return n||r?e:(0,G.jsx)(Ot,{to:`/login`,replace:!0})}function bhe(){return(0,G.jsx)(vhe,{children:(0,G.jsxs)(Mt,{children:[(0,G.jsx)(At,{path:`/login`,element:(0,G.jsx)(_b,{})}),(0,G.jsxs)(At,{path:`/*`,element:(0,G.jsx)(yhe,{children:(0,G.jsx)(Ree,{})}),children:[(0,G.jsx)(At,{index:!0,element:(0,G.jsx)(Ot,{to:`/dashboard`,replace:!0})}),(0,G.jsx)(At,{path:`dashboard`,element:(0,G.jsx)(fJ,{})}),(0,G.jsx)(At,{path:`memories`,element:(0,G.jsx)(RJ,{})}),(0,G.jsx)(At,{path:`memories/:id`,element:(0,G.jsx)(pme,{})}),(0,G.jsx)(At,{path:`memories/new`,element:(0,G.jsx)(E9,{})}),(0,G.jsx)(At,{path:`memories/:id/edit`,element:(0,G.jsx)(E9,{})}),(0,G.jsx)(At,{path:`memories/:id/edit-insight`,element:(0,G.jsx)(vme,{})}),(0,G.jsx)(At,{path:`vault`,element:(0,G.jsx)(xme,{})}),(0,G.jsx)(At,{path:`spaces`,element:(0,G.jsx)(Lme,{})}),(0,G.jsx)(At,{path:`sessions`,element:(0,G.jsx)(Cme,{})}),(0,G.jsx)(At,{path:`sessions/:id`,element:(0,G.jsx)(Nme,{})}),(0,G.jsx)(At,{path:`analytics`,element:(0,G.jsx)(Rme,{})}),(0,G.jsx)(At,{path:`tier-history`,element:(0,G.jsx)(Bme,{})}),(0,G.jsx)(At,{path:`lifecycle`,element:(0,G.jsx)(Yme,{})}),(0,G.jsx)(At,{path:`import`,element:(0,G.jsx)(V9,{})}),(0,G.jsx)(At,{path:`profile`,element:(0,G.jsx)(ohe,{})}),(0,G.jsx)(At,{path:`settings`,element:(0,G.jsx)(Xme,{})}),(0,G.jsx)(At,{path:`categories`,element:(0,G.jsx)(ghe,{})}),(0,G.jsx)(At,{path:`*`,element:(0,G.jsx)(_he,{})})]})]})})}(0,x.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(y.StrictMode,{children:(0,G.jsx)(Sn,{children:(0,G.jsx)(Sr,{defaultTheme:`dark`,storageKey:`omem-theme`,children:(0,G.jsxs)(Dp,{children:[(0,G.jsx)(jp,{children:(0,G.jsx)(bhe,{})}),(0,G.jsx)(yr,{position:`top-right`,richColors:!0,closeButton:!0})]})})})}));
|