aicodeswitch 3.0.20 → 3.6.2

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.
@@ -67,7 +67,7 @@ Error generating stack: `+a.message+`
67
67
  */function bd(){return bd=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bd.apply(this,arguments)}function $O(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function eR(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function tR(e,t){return e.button===0&&(!t||t==="_self")&&!eR(e)}const nR=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],rR=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],iR="6";try{window.__reactRouterVersion=iR}catch{}const aR=m.createContext({isTransitioning:!1}),oR="startTransition",b1=kP[oR];function lR(e){let{basename:t,children:n,future:r,window:i}=e,a=m.useRef();a.current==null&&(a.current=cL({window:i,v5Compat:!0}));let o=a.current,[l,s]=m.useState({action:o.action,location:o.location}),{v7_startTransition:c}=r||{},d=m.useCallback(f=>{c&&b1?b1(()=>s(f)):s(f)},[s,c]);return m.useLayoutEffect(()=>o.listen(d),[o,d]),m.useEffect(()=>QL(r),[r]),m.createElement(ZL,{basename:t,children:n,location:l.location,navigationType:l.action,navigator:o,future:r})}const sR=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",uR=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,cR=m.forwardRef(function(t,n){let{onClick:r,relative:i,reloadDocument:a,replace:o,state:l,target:s,to:c,preventScrollReset:d,viewTransition:f}=t,p=$O(t,nR),{basename:h}=m.useContext(ha),g,y=!1;if(typeof c=="string"&&uR.test(c)&&(g=c,sR))try{let w=new URL(window.location.href),S=c.startsWith("//")?new URL(w.protocol+c):new URL(c),k=rl(S.pathname,h);S.origin===w.origin&&k!=null?c=k+S.search+S.hash:y=!0}catch{}let x=LL(c,{relative:i}),v=fR(c,{replace:o,state:l,target:s,preventScrollReset:d,relative:i,viewTransition:f});function b(w){r&&r(w),w.defaultPrevented||v(w)}return m.createElement("a",bd({},p,{href:g||x,onClick:y||a?r:b,ref:n,target:s}))}),Mi=m.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:i=!1,className:a="",end:o=!1,style:l,to:s,viewTransition:c,children:d}=t,f=$O(t,rR),p=Kf(s,{relative:f.relative}),h=du(),g=m.useContext(_O),{navigator:y,basename:x}=m.useContext(ha),v=g!=null&&pR(p)&&c===!0,b=y.encodeLocation?y.encodeLocation(p).pathname:p.pathname,w=h.pathname,S=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;i||(w=w.toLowerCase(),S=S?S.toLowerCase():null,b=b.toLowerCase()),S&&x&&(S=rl(S,x)||S);const k=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let j=w===b||!o&&w.startsWith(b)&&w.charAt(k)==="/",C=S!=null&&(S===b||!o&&S.startsWith(b)&&S.charAt(b.length)==="/"),T={isActive:j,isPending:C,isTransitioning:v},M=j?r:void 0,I;typeof a=="function"?I=a(T):I=[a,j?"active":null,C?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let _=typeof l=="function"?l(T):l;return m.createElement(cR,bd({},f,{"aria-current":M,className:I,ref:n,style:_,to:s,viewTransition:c}),typeof d=="function"?d(T):d)});var yg;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(yg||(yg={}));var w1;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(w1||(w1={}));function dR(e){let t=m.useContext(Uf);return t||mt(!1),t}function fR(e,t){let{target:n,replace:r,state:i,preventScrollReset:a,relative:o,viewTransition:l}=t===void 0?{}:t,s=DO(),c=du(),d=Kf(e,{relative:o});return m.useCallback(f=>{if(tR(f,n)){f.preventDefault();let p=r!==void 0?r:xd(c)===xd(d);s(e,{replace:p,state:i,preventScrollReset:a,relative:o,viewTransition:l})}},[c,s,d,r,i,n,e,a,o,l])}function pR(e,t){t===void 0&&(t={});let n=m.useContext(aR);n==null&&mt(!1);let{basename:r}=dR(yg.useViewTransitionState),i=Kf(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=rl(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=rl(n.nextLocation.pathname,r)||n.nextLocation.pathname;return gg(i.pathname,o)!=null||gg(i.pathname,a)!=null}function hR(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const mR=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gR=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,vR={};function S1(e,t){return(vR.jsx?gR:mR).test(e)}const yR=/[ \t\n\f\r]/g;function xR(e){return typeof e=="object"?e.type==="text"?j1(e.value):!1:j1(e)}function j1(e){return e.replace(yR,"")===""}class fu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}fu.prototype.normal={};fu.prototype.property={};fu.prototype.space=void 0;function BO(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new fu(n,r,t)}function xg(e){return e.toLowerCase()}class _n{constructor(t,n){this.attribute=n,this.property=t}}_n.prototype.attribute="";_n.prototype.booleanish=!1;_n.prototype.boolean=!1;_n.prototype.commaOrSpaceSeparated=!1;_n.prototype.commaSeparated=!1;_n.prototype.defined=!1;_n.prototype.mustUseProperty=!1;_n.prototype.number=!1;_n.prototype.overloadedBoolean=!1;_n.prototype.property="";_n.prototype.spaceSeparated=!1;_n.prototype.space=void 0;let bR=0;const Ee=co(),Ot=co(),bg=co(),te=co(),Ge=co(),Ko=co(),Ln=co();function co(){return 2**++bR}const wg=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ee,booleanish:Ot,commaOrSpaceSeparated:Ln,commaSeparated:Ko,number:te,overloadedBoolean:bg,spaceSeparated:Ge},Symbol.toStringTag,{value:"Module"})),Rh=Object.keys(wg);class Ey extends _n{constructor(t,n,r,i){let a=-1;if(super(t,n),k1(this,"space",i),typeof r=="number")for(;++a<Rh.length;){const o=Rh[a];k1(this,Rh[a],(r&wg[o])===wg[o])}}}Ey.prototype.defined=!0;function k1(e,t,n){n&&(e[t]=n)}function hl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const a=new Ey(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[xg(r)]=r,n[xg(a.attribute)]=r}return new fu(t,n,e.space)}const FO=hl({properties:{ariaActiveDescendant:null,ariaAtomic:Ot,ariaAutoComplete:null,ariaBusy:Ot,ariaChecked:Ot,ariaColCount:te,ariaColIndex:te,ariaColSpan:te,ariaControls:Ge,ariaCurrent:null,ariaDescribedBy:Ge,ariaDetails:null,ariaDisabled:Ot,ariaDropEffect:Ge,ariaErrorMessage:null,ariaExpanded:Ot,ariaFlowTo:Ge,ariaGrabbed:Ot,ariaHasPopup:null,ariaHidden:Ot,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ge,ariaLevel:te,ariaLive:null,ariaModal:Ot,ariaMultiLine:Ot,ariaMultiSelectable:Ot,ariaOrientation:null,ariaOwns:Ge,ariaPlaceholder:null,ariaPosInSet:te,ariaPressed:Ot,ariaReadOnly:Ot,ariaRelevant:null,ariaRequired:Ot,ariaRoleDescription:Ge,ariaRowCount:te,ariaRowIndex:te,ariaRowSpan:te,ariaSelected:Ot,ariaSetSize:te,ariaSort:null,ariaValueMax:te,ariaValueMin:te,ariaValueNow:te,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function UO(e,t){return t in e?e[t]:t}function WO(e,t){return UO(e,t.toLowerCase())}const wR=hl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ko,acceptCharset:Ge,accessKey:Ge,action:null,allow:null,allowFullScreen:Ee,allowPaymentRequest:Ee,allowUserMedia:Ee,alt:null,as:null,async:Ee,autoCapitalize:null,autoComplete:Ge,autoFocus:Ee,autoPlay:Ee,blocking:Ge,capture:null,charSet:null,checked:Ee,cite:null,className:Ge,cols:te,colSpan:null,content:null,contentEditable:Ot,controls:Ee,controlsList:Ge,coords:te|Ko,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ee,defer:Ee,dir:null,dirName:null,disabled:Ee,download:bg,draggable:Ot,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ee,formTarget:null,headers:Ge,height:te,hidden:bg,high:te,href:null,hrefLang:null,htmlFor:Ge,httpEquiv:Ge,id:null,imageSizes:null,imageSrcSet:null,inert:Ee,inputMode:null,integrity:null,is:null,isMap:Ee,itemId:null,itemProp:Ge,itemRef:Ge,itemScope:Ee,itemType:Ge,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ee,low:te,manifest:null,max:null,maxLength:te,media:null,method:null,min:null,minLength:te,multiple:Ee,muted:Ee,name:null,nonce:null,noModule:Ee,noValidate:Ee,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:Ee,optimum:te,pattern:null,ping:Ge,placeholder:null,playsInline:Ee,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ee,referrerPolicy:null,rel:Ge,required:Ee,reversed:Ee,rows:te,rowSpan:te,sandbox:Ge,scope:null,scoped:Ee,seamless:Ee,selected:Ee,shadowRootClonable:Ee,shadowRootDelegatesFocus:Ee,shadowRootMode:null,shape:null,size:te,sizes:null,slot:null,span:te,spellCheck:Ot,src:null,srcDoc:null,srcLang:null,srcSet:null,start:te,step:null,style:null,tabIndex:te,target:null,title:null,translate:null,type:null,typeMustMatch:Ee,useMap:null,value:Ot,width:te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ge,axis:null,background:null,bgColor:null,border:te,borderColor:null,bottomMargin:te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ee,declare:Ee,event:null,face:null,frame:null,frameBorder:null,hSpace:te,leftMargin:te,link:null,longDesc:null,lowSrc:null,marginHeight:te,marginWidth:te,noResize:Ee,noHref:Ee,noShade:Ee,noWrap:Ee,object:null,profile:null,prompt:null,rev:null,rightMargin:te,rules:null,scheme:null,scrolling:Ot,standby:null,summary:null,text:null,topMargin:te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:te,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ee,disableRemotePlayback:Ee,prefix:null,property:null,results:te,security:null,unselectable:null},space:"html",transform:WO}),SR=hl({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:Ln,accentHeight:te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:te,amplitude:te,arabicForm:null,ascent:te,attributeName:null,attributeType:null,azimuth:te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:te,by:null,calcMode:null,capHeight:te,className:Ge,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:te,diffuseConstant:te,direction:null,display:null,dur:null,divisor:te,dominantBaseline:null,download:Ee,dx:null,dy:null,edgeMode:null,editable:null,elevation:te,enableBackground:null,end:null,event:null,exponent:te,externalResourcesRequired:null,fill:null,fillOpacity:te,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:Ko,g2:Ko,glyphName:Ko,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:te,horizOriginX:te,horizOriginY:te,id:null,ideographic:te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:te,k:te,k1:te,k2:te,k3:te,k4:te,kernelMatrix:Ln,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:te,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:te,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:te,overlineThickness:te,paintOrder:null,panose1:null,path:null,pathLength:te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ge,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:te,pointsAtY:te,pointsAtZ:te,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ln,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ln,rev:Ln,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ln,requiredFeatures:Ln,requiredFonts:Ln,requiredFormats:Ln,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:te,specularExponent:te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:te,strikethroughThickness:te,string:null,stroke:null,strokeDashArray:Ln,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:te,strokeOpacity:te,strokeWidth:null,style:null,surfaceScale:te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ln,tabIndex:te,tableValues:null,target:null,targetX:te,targetY:te,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ln,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:te,underlineThickness:te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:te,values:null,vAlphabetic:te,vMathematical:te,vectorEffect:null,vHanging:te,vIdeographic:te,version:null,vertAdvY:te,vertOriginX:te,vertOriginY:te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:UO}),KO=hl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),HO=hl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:WO}),VO=hl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),jR={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"},kR=/[A-Z]/g,P1=/-[a-z]/g,PR=/^data[-\w.:]+$/i;function CR(e,t){const n=xg(t);let r=t,i=_n;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&PR.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(P1,ER);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!P1.test(a)){let o=a.replace(kR,OR);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Ey}return new i(r,t)}function OR(e){return"-"+e.toLowerCase()}function ER(e){return e.charAt(1).toUpperCase()}const AR=BO([FO,wR,KO,HO,VO],"html"),Ay=BO([FO,SR,KO,HO,VO],"svg");function TR(e){return e.join(" ").trim()}var Ty={},C1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,IR=/\n/g,_R=/^\s*/,NR=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,MR=/^:\s*/,DR=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,LR=/^[;\s]*/,RR=/^\s+|\s+$/g,zR=`
68
68
  `,O1="/",E1="*",_a="",$R="comment",BR="declaration";function FR(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(g){var y=g.match(IR);y&&(n+=y.length);var x=g.lastIndexOf(zR);r=~x?g.length-x:r+g.length}function a(){var g={line:n,column:r};return function(y){return y.position=new o(g),c(),y}}function o(g){this.start=g,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function l(g){var y=new Error(t.source+":"+n+":"+r+": "+g);if(y.reason=g,y.filename=t.source,y.line=n,y.column=r,y.source=e,!t.silent)throw y}function s(g){var y=g.exec(e);if(y){var x=y[0];return i(x),e=e.slice(x.length),y}}function c(){s(_R)}function d(g){var y;for(g=g||[];y=f();)y!==!1&&g.push(y);return g}function f(){var g=a();if(!(O1!=e.charAt(0)||E1!=e.charAt(1))){for(var y=2;_a!=e.charAt(y)&&(E1!=e.charAt(y)||O1!=e.charAt(y+1));)++y;if(y+=2,_a===e.charAt(y-1))return l("End of comment missing");var x=e.slice(2,y-2);return r+=2,i(x),e=e.slice(y),r+=2,g({type:$R,comment:x})}}function p(){var g=a(),y=s(NR);if(y){if(f(),!s(MR))return l("property missing ':'");var x=s(DR),v=g({type:BR,property:A1(y[0].replace(C1,_a)),value:x?A1(x[0].replace(C1,_a)):_a});return s(LR),v}}function h(){var g=[];d(g);for(var y;y=p();)y!==!1&&(g.push(y),d(g));return g}return c(),h()}function A1(e){return e?e.replace(RR,_a):_a}var UR=FR,WR=Go&&Go.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ty,"__esModule",{value:!0});Ty.default=HR;const KR=WR(UR);function HR(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,KR.default)(e),i=typeof t=="function";return r.forEach(a=>{if(a.type!=="declaration")return;const{property:o,value:l}=a;i?t(o,l,a):l&&(n=n||{},n[o]=l)}),n}var Hf={};Object.defineProperty(Hf,"__esModule",{value:!0});Hf.camelCase=void 0;var VR=/^--[a-zA-Z0-9_-]+$/,qR=/-([a-z])/g,YR=/^[^-]+$/,GR=/^-(webkit|moz|ms|o|khtml)-/,XR=/^-(ms)-/,QR=function(e){return!e||YR.test(e)||VR.test(e)},ZR=function(e,t){return t.toUpperCase()},T1=function(e,t){return"".concat(t,"-")},JR=function(e,t){return t===void 0&&(t={}),QR(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(XR,T1):e=e.replace(GR,T1),e.replace(qR,ZR))};Hf.camelCase=JR;var ez=Go&&Go.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},tz=ez(Ty),nz=Hf;function Sg(e,t){var n={};return!e||typeof e!="string"||(0,tz.default)(e,function(r,i){r&&i&&(n[(0,nz.camelCase)(r,t)]=i)}),n}Sg.default=Sg;var rz=Sg;const iz=Vn(rz),qO=YO("end"),Iy=YO("start");function YO(e){return t;function t(n){const 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 az(e){const t=Iy(e),n=qO(e);if(t&&n)return{start:t,end:n}}function vs(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?I1(e.position):"start"in e||"end"in e?I1(e):"line"in e||"column"in e?jg(e):""}function jg(e){return _1(e&&e.line)+":"+_1(e&&e.column)}function I1(e){return jg(e&&e.start)+"-"+jg(e&&e.end)}function _1(e){return e&&typeof e=="number"?e:1}class fn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",a={},o=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(o=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const s=r.indexOf(":");s===-1?a.ruleId=r:(a.source=r.slice(0,s),a.ruleId=r.slice(s+1))}if(!a.place&&a.ancestors&&a.ancestors){const s=a.ancestors[a.ancestors.length-1];s&&(a.place=s.position)}const l=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=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=vs(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}}fn.prototype.file="";fn.prototype.name="";fn.prototype.reason="";fn.prototype.message="";fn.prototype.stack="";fn.prototype.column=void 0;fn.prototype.line=void 0;fn.prototype.ancestors=void 0;fn.prototype.cause=void 0;fn.prototype.fatal=void 0;fn.prototype.place=void 0;fn.prototype.ruleId=void 0;fn.prototype.source=void 0;const _y={}.hasOwnProperty,oz=new Map,lz=/[A-Z]/g,sz=new Set(["table","tbody","thead","tfoot","tr"]),uz=new Set(["td","th"]),GO="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function cz(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=yz(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=vz(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Ay:AR,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=XO(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function XO(e,t,n){if(t.type==="element")return dz(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return fz(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return hz(e,t,n);if(t.type==="mdxjsEsm")return pz(e,t);if(t.type==="root")return mz(e,t,n);if(t.type==="text")return gz(e,t)}function dz(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Ay,e.schema=i),e.ancestors.push(t);const a=ZO(e,t.tagName,!1),o=xz(e,t);let l=My(e,t);return sz.has(t.tagName)&&(l=l.filter(function(s){return typeof s=="string"?!xR(s):!0})),QO(e,o,a,t),Ny(o,l),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function fz(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Us(e,t.position)}function pz(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Us(e,t.position)}function hz(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Ay,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:ZO(e,t.name,!0),o=bz(e,t),l=My(e,t);return QO(e,o,a,t),Ny(o,l),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function mz(e,t,n){const r={};return Ny(r,My(e,t)),e.create(t,e.Fragment,r,n)}function gz(e,t){return t.value}function QO(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Ny(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function vz(e,t,n){return r;function r(i,a,o,l){const c=Array.isArray(o.children)?n:t;return l?c(a,o,l):c(a,o)}}function yz(e,t){return n;function n(r,i,a,o){const l=Array.isArray(a.children),s=Iy(r);return t(i,a,o,l,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function xz(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&_y.call(t.properties,i)){const a=wz(e,i,t.properties[i]);if(a){const[o,l]=a;e.tableCellAlignToStyle&&o==="align"&&typeof l=="string"&&uz.has(t.tagName)?r=l:n[o]=l}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function bz(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const o=a.expression;o.type;const l=o.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else Us(e,t.position);else{const i=r.name;let a;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,a=e.evaluater.evaluateExpression(l.expression)}else Us(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function My(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:oz;for(;++r<t.children.length;){const a=t.children[r];let o;if(e.passKeys){const s=a.type==="element"?a.tagName:a.type==="mdxJsxFlowElement"||a.type==="mdxJsxTextElement"?a.name:void 0;if(s){const c=i.get(s)||0;o=s+"-"+c,i.set(s,c+1)}}const l=XO(e,a,o);l!==void 0&&n.push(l)}return n}function wz(e,t,n){const r=CR(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?hR(n):TR(n)),r.property==="style"){let i=typeof n=="object"?n:Sz(e,String(n));return e.stylePropertyNameCase==="css"&&(i=jz(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?jR[r.property]||r.property:r.attribute,n]}}function Sz(e,t){try{return iz(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new fn("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=GO+"#cannot-parse-style-attribute",i}}function ZO(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let a=-1,o;for(;++a<i.length;){const l=S1(i[a])?{type:"Identifier",name:i[a]}:{type:"Literal",value:i[a]};o=o?{type:"MemberExpression",object:o,property:l,computed:!!(a&&l.type==="Literal"),optional:!1}:l}r=o}else r=S1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return _y.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Us(e)}function Us(e,t){const n=new fn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=GO+"#cannot-handle-mdx-estrees-without-createevaluater",n}function jz(e){const t={};let n;for(n in e)_y.call(e,n)&&(t[kz(n)]=e[n]);return t}function kz(e){let t=e.replace(lz,Pz);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Pz(e){return"-"+e.toLowerCase()}const zh={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"]},Cz={};function Oz(e,t){const n=Cz,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return JO(e,r,i)}function JO(e,t,n){if(Ez(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return N1(e.children,t,n)}return Array.isArray(e)?N1(e,t,n):""}function N1(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=JO(e[i],t,n);return r.join("")}function Ez(e){return!!(e&&typeof e=="object")}const M1=document.createElement("i");function Dy(e){const t="&"+e+";";M1.innerHTML=t;const n=M1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Vr(e,t,n,r){const i=e.length;let a=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function nr(e,t){return e.length>0?(Vr(e,e.length,0,t),e):t}const D1={}.hasOwnProperty;function Az(e){const t={};let n=-1;for(;++n<e.length;)Tz(t,e[n]);return t}function Tz(e,t){let n;for(n in t){const i=(D1.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){D1.call(i,o)||(i[o]=[]);const l=a[o];Iz(i[o],Array.isArray(l)?l:l?[l]:[])}}}function Iz(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Vr(e,0,0,r)}function eE(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ho(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Br=ma(/[A-Za-z]/),Bn=ma(/[\dA-Za-z]/),_z=ma(/[#-'*+\--9=?A-Z^-~]/);function kg(e){return e!==null&&(e<32||e===127)}const Pg=ma(/\d/),Nz=ma(/[\dA-Fa-f]/),Mz=ma(/[!-/:-@[-`{-~]/);function ke(e){return e!==null&&e<-2}function In(e){return e!==null&&(e<0||e===32)}function Fe(e){return e===-2||e===-1||e===32}const Dz=ma(new RegExp("\\p{P}|\\p{S}","u")),Lz=ma(/\s/);function ma(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ml(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o="";if(a===37&&Bn(e.charCodeAt(n+1))&&Bn(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){const l=e.charCodeAt(n+1);a<56320&&l>56319&&l<57344?(o=String.fromCharCode(a,l),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Ze(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(s){return Fe(s)?(e.enter(n),l(s)):t(s)}function l(s){return Fe(s)&&a++<i?(e.consume(s),l):(e.exit(n),t(s))}}const Rz={tokenize:zz};function zz(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Ze(e,t,"linePrefix")}function i(l){return e.enter("paragraph"),a(l)}function a(l){const s=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=s),n=s,o(l)}function o(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return ke(l)?(e.consume(l),e.exit("chunkText"),a):(e.consume(l),o)}}const $z={tokenize:Bz},L1={tokenize:Fz};function Bz(e){const t=this,n=[];let r=0,i,a,o;return l;function l(w){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,s,c)(w)}return c(w)}function s(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&b();const S=t.events.length;let k=S,j;for(;k--;)if(t.events[k][0]==="exit"&&t.events[k][1].type==="chunkFlow"){j=t.events[k][1].end;break}v(r);let C=S;for(;C<t.events.length;)t.events[C][1].end={...j},C++;return Vr(t.events,k+1,0,t.events.slice(S)),t.events.length=C,c(w)}return l(w)}function c(w){if(r===n.length){if(!i)return p(w);if(i.currentConstruct&&i.currentConstruct.concrete)return g(w);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(L1,d,f)(w)}function d(w){return i&&b(),v(r),p(w)}function f(w){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(w)}function p(w){return t.containerState={},e.attempt(L1,h,g)(w)}function h(w){return r++,n.push([t.currentConstruct,t.containerState]),p(w)}function g(w){if(w===null){i&&b(),v(0),e.consume(w);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:a}),y(w)}function y(w){if(w===null){x(e.exit("chunkFlow"),!0),v(0),e.consume(w);return}return ke(w)?(e.consume(w),x(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(w),y)}function x(w,S){const k=t.sliceStream(w);if(S&&k.push(null),w.previous=a,a&&(a.next=w),a=w,i.defineSkip(w.start),i.write(k),t.parser.lazy[w.start.line]){let j=i.events.length;for(;j--;)if(i.events[j][1].start.offset<o&&(!i.events[j][1].end||i.events[j][1].end.offset>o))return;const C=t.events.length;let T=C,M,I;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(M){I=t.events[T][1].end;break}M=!0}for(v(r),j=C;j<t.events.length;)t.events[j][1].end={...I},j++;Vr(t.events,T+1,0,t.events.slice(C)),t.events.length=j}}function v(w){let S=n.length;for(;S-- >w;){const k=n[S];t.containerState=k[1],k[0].exit.call(t,e)}n.length=w}function b(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Fz(e,t,n){return Ze(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function R1(e){if(e===null||In(e)||Lz(e))return 1;if(Dz(e))return 2}function Ly(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const Cg={name:"attention",resolveAll:Uz,tokenize:Wz};function Uz(e,t){let n=-1,r,i,a,o,l,s,c,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;s=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},p={...e[n][1].start};z1(f,-s),z1(p,s),o={type:s>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},l={type:s>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},a={type:s>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:s>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},e[r][1].end={...o.start},e[n][1].start={...l.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=nr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=nr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",a,t]]),c=nr(c,Ly(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=nr(c,[["exit",a,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,c=nr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Vr(e,r-1,n-r+3,c),n=r+c.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Wz(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=R1(r);let a;return o;function o(s){return a=s,e.enter("attentionSequence"),l(s)}function l(s){if(s===a)return e.consume(s),l;const c=e.exit("attentionSequence"),d=R1(s),f=!d||d===2&&i||n.includes(s),p=!i||i===2&&d||n.includes(r);return c._open=!!(a===42?f:f&&(i||!p)),c._close=!!(a===42?p:p&&(d||!f)),t(s)}}function z1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Kz={name:"autolink",tokenize:Hz};function Hz(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),a}function a(h){return Br(h)?(e.consume(h),o):h===64?n(h):c(h)}function o(h){return h===43||h===45||h===46||Bn(h)?(r=1,l(h)):c(h)}function l(h){return h===58?(e.consume(h),r=0,s):(h===43||h===45||h===46||Bn(h))&&r++<32?(e.consume(h),l):(r=0,c(h))}function s(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||kg(h)?n(h):(e.consume(h),s)}function c(h){return h===64?(e.consume(h),d):_z(h)?(e.consume(h),c):n(h)}function d(h){return Bn(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||Bn(h))&&r++<63){const g=h===45?p:f;return e.consume(h),g}return n(h)}}const Vf={partial:!0,tokenize:Vz};function Vz(e,t,n){return r;function r(a){return Fe(a)?Ze(e,i,"linePrefix")(a):i(a)}function i(a){return a===null||ke(a)?t(a):n(a)}}const tE={continuation:{tokenize:Yz},exit:Gz,name:"blockQuote",tokenize:qz};function qz(e,t,n){const r=this;return i;function i(o){if(o===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),a}return n(o)}function a(o){return Fe(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function Yz(e,t,n){const r=this;return i;function i(o){return Fe(o)?Ze(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):a(o)}function a(o){return e.attempt(tE,t,n)(o)}}function Gz(e){e.exit("blockQuote")}const nE={name:"characterEscape",tokenize:Xz};function Xz(e,t,n){return r;function r(a){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(a),e.exit("escapeMarker"),i}function i(a){return Mz(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}const rE={name:"characterReference",tokenize:Qz};function Qz(e,t,n){const r=this;let i=0,a,o;return l;function l(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),s}function s(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),a=31,o=Bn,d(f))}function c(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,o=Nz,d):(e.enter("characterReferenceValue"),a=7,o=Pg,d(f))}function d(f){if(f===59&&i){const p=e.exit("characterReferenceValue");return o===Bn&&!Dy(r.sliceSerialize(p))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(f)&&i++<a?(e.consume(f),d):n(f)}}const $1={partial:!0,tokenize:Jz},B1={concrete:!0,name:"codeFenced",tokenize:Zz};function Zz(e,t,n){const r=this,i={partial:!0,tokenize:k};let a=0,o=0,l;return s;function s(j){return c(j)}function c(j){const C=r.events[r.events.length-1];return a=C&&C[1].type==="linePrefix"?C[2].sliceSerialize(C[1],!0).length:0,l=j,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(j)}function d(j){return j===l?(o++,e.consume(j),d):o<3?n(j):(e.exit("codeFencedFenceSequence"),Fe(j)?Ze(e,f,"whitespace")(j):f(j))}function f(j){return j===null||ke(j)?(e.exit("codeFencedFence"),r.interrupt?t(j):e.check($1,y,S)(j)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(j))}function p(j){return j===null||ke(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(j)):Fe(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ze(e,h,"whitespace")(j)):j===96&&j===l?n(j):(e.consume(j),p)}function h(j){return j===null||ke(j)?f(j):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(j))}function g(j){return j===null||ke(j)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(j)):j===96&&j===l?n(j):(e.consume(j),g)}function y(j){return e.attempt(i,S,x)(j)}function x(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),v}function v(j){return a>0&&Fe(j)?Ze(e,b,"linePrefix",a+1)(j):b(j)}function b(j){return j===null||ke(j)?e.check($1,y,S)(j):(e.enter("codeFlowValue"),w(j))}function w(j){return j===null||ke(j)?(e.exit("codeFlowValue"),b(j)):(e.consume(j),w)}function S(j){return e.exit("codeFenced"),t(j)}function k(j,C,T){let M=0;return I;function I(O){return j.enter("lineEnding"),j.consume(O),j.exit("lineEnding"),_}function _(O){return j.enter("codeFencedFence"),Fe(O)?Ze(j,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):N(O)}function N(O){return O===l?(j.enter("codeFencedFenceSequence"),V(O)):T(O)}function V(O){return O===l?(M++,j.consume(O),V):M>=o?(j.exit("codeFencedFenceSequence"),Fe(O)?Ze(j,L,"whitespace")(O):L(O)):T(O)}function L(O){return O===null||ke(O)?(j.exit("codeFencedFence"),C(O)):T(O)}}}function Jz(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const $h={name:"codeIndented",tokenize:t$},e$={partial:!0,tokenize:n$};function t$(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),Ze(e,a,"linePrefix",5)(c)}function a(c){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?s(c):ke(c)?e.attempt(e$,o,s)(c):(e.enter("codeFlowValue"),l(c))}function l(c){return c===null||ke(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),l)}function s(c){return e.exit("codeIndented"),t(c)}}function n$(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):ke(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Ze(e,a,"linePrefix",5)(o)}function a(o){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):ke(o)?i(o):n(o)}}const r$={name:"codeText",previous:a$,resolve:i$,tokenize:o$};function i$(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function a$(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function o$(e,t,n){let r=0,i,a;return o;function o(f){return e.enter("codeText"),e.enter("codeTextSequence"),l(f)}function l(f){return f===96?(e.consume(f),r++,l):(e.exit("codeTextSequence"),s(f))}function s(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),s):f===96?(a=e.enter("codeTextSequence"),i=0,d(f)):ke(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),s):(e.enter("codeTextData"),c(f))}function c(f){return f===null||f===32||f===96||ke(f)?(e.exit("codeTextData"),s(f)):(e.consume(f),c)}function d(f){return f===96?(e.consume(f),i++,d):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(a.type="codeTextData",c(f))}}class l${constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Rl(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Rl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Rl(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Rl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Rl(this.left,n.reverse())}}}function Rl(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function iE(e){const t={};let n=-1,r,i,a,o,l,s,c;const d=new l$(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(s=r[1]._tokenizer.events,a=0,a<s.length&&s[a][1].type==="lineEndingBlank"&&(a+=2),a<s.length&&s[a][1].type==="content"))for(;++a<s.length&&s[a][1].type!=="content";)s[a][1].type==="chunkText"&&(s[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,s$(d,n)),n=t[n],c=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=d.get(a),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=a);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...d.get(i)[1].start},l=d.slice(i,n),l.unshift(r),d.splice(i,n-i+1,l))}}return Vr(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!c}function s$(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const l=o.events,s=[],c={};let d,f,p=-1,h=n,g=0,y=0;const x=[y];for(;h;){for(;e.get(++i)[1]!==h;);a.push(i),h._tokenizer||(d=r.sliceStream(h),h.next||d.push(null),f&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(y=p+1,x.push(y),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):x.pop(),p=x.length;p--;){const v=l.slice(x[p],x[p+1]),b=a.pop();s.push([b,b+v.length-1]),e.splice(b,2,v)}for(s.reverse(),p=-1;++p<s.length;)c[g+s[p][0]]=g+s[p][1],g+=s[p][1]-s[p][0]-1;return c}const u$={resolve:d$,tokenize:f$},c$={partial:!0,tokenize:p$};function d$(e){return iE(e),e}function f$(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?a(l):ke(l)?e.check(c$,o,a)(l):(e.consume(l),i)}function a(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function o(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function p$(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ze(e,a,"linePrefix")}function a(o){if(o===null||ke(o))return n(o);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function aE(e,t,n,r,i,a,o,l,s){const c=s||Number.POSITIVE_INFINITY;let d=0;return f;function f(v){return v===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(v),e.exit(a),p):v===null||v===32||v===41||kg(v)?n(v):(e.enter(r),e.enter(o),e.enter(l),e.enter("chunkString",{contentType:"string"}),y(v))}function p(v){return v===62?(e.enter(a),e.consume(v),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),h(v))}function h(v){return v===62?(e.exit("chunkString"),e.exit(l),p(v)):v===null||v===60||ke(v)?n(v):(e.consume(v),v===92?g:h)}function g(v){return v===60||v===62||v===92?(e.consume(v),h):h(v)}function y(v){return!d&&(v===null||v===41||In(v))?(e.exit("chunkString"),e.exit(l),e.exit(o),e.exit(r),t(v)):d<c&&v===40?(e.consume(v),d++,y):v===41?(e.consume(v),d--,y):v===null||v===32||v===40||kg(v)?n(v):(e.consume(v),v===92?x:y)}function x(v){return v===40||v===41||v===92?(e.consume(v),y):y(v)}}function oE(e,t,n,r,i,a){const o=this;let l=0,s;return c;function c(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(a),d}function d(h){return l>999||h===null||h===91||h===93&&!s||h===94&&!l&&"_hiddenFootnoteSupport"in o.parser.constructs?n(h):h===93?(e.exit(a),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):ke(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||ke(h)||l++>999?(e.exit("chunkString"),d(h)):(e.consume(h),s||(s=!Fe(h)),h===92?p:f)}function p(h){return h===91||h===92||h===93?(e.consume(h),l++,f):f(h)}}function lE(e,t,n,r,i,a){let o;return l;function l(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),o=p===40?41:p,s):n(p)}function s(p){return p===o?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(a),c(p))}function c(p){return p===o?(e.exit(a),s(o)):p===null?n(p):ke(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),Ze(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===o||p===null||ke(p)?(e.exit("chunkString"),c(p)):(e.consume(p),p===92?f:d)}function f(p){return p===o||p===92?(e.consume(p),d):d(p)}}function ys(e,t){let n;return r;function r(i){return ke(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Fe(i)?Ze(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const h$={name:"definition",tokenize:g$},m$={partial:!0,tokenize:v$};function g$(e,t,n){const r=this;let i;return a;function a(h){return e.enter("definition"),o(h)}function o(h){return oE.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return i=Ho(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),s):n(h)}function s(h){return In(h)?ys(e,c)(h):c(h)}function c(h){return aE(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(m$,f,f)(h)}function f(h){return Fe(h)?Ze(e,p,"whitespace")(h):p(h)}function p(h){return h===null||ke(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function v$(e,t,n){return r;function r(l){return In(l)?ys(e,i)(l):n(l)}function i(l){return lE(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function a(l){return Fe(l)?Ze(e,o,"whitespace")(l):o(l)}function o(l){return l===null||ke(l)?t(l):n(l)}}const y$={name:"hardBreakEscape",tokenize:x$};function x$(e,t,n){return r;function r(a){return e.enter("hardBreakEscape"),e.consume(a),i}function i(a){return ke(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const b$={name:"headingAtx",resolve:w$,tokenize:S$};function w$(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},a={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Vr(e,r,n-r+1,[["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t]])),e}function S$(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),a(d)}function a(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||In(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),s(d)):d===null||ke(d)?(e.exit("atxHeading"),t(d)):Fe(d)?Ze(e,l,"whitespace")(d):(e.enter("atxHeadingText"),c(d))}function s(d){return d===35?(e.consume(d),s):(e.exit("atxHeadingSequence"),l(d))}function c(d){return d===null||d===35||In(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),c)}}const j$=["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"],F1=["pre","script","style","textarea"],k$={concrete:!0,name:"htmlFlow",resolveTo:O$,tokenize:E$},P$={partial:!0,tokenize:T$},C$={partial:!0,tokenize:A$};function O$(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function E$(e,t,n){const r=this;let i,a,o,l,s;return c;function c(A){return d(A)}function d(A){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(A),f}function f(A){return A===33?(e.consume(A),p):A===47?(e.consume(A),a=!0,y):A===63?(e.consume(A),i=3,r.interrupt?t:P):Br(A)?(e.consume(A),o=String.fromCharCode(A),x):n(A)}function p(A){return A===45?(e.consume(A),i=2,h):A===91?(e.consume(A),i=5,l=0,g):Br(A)?(e.consume(A),i=4,r.interrupt?t:P):n(A)}function h(A){return A===45?(e.consume(A),r.interrupt?t:P):n(A)}function g(A){const ue="CDATA[";return A===ue.charCodeAt(l++)?(e.consume(A),l===ue.length?r.interrupt?t:N:g):n(A)}function y(A){return Br(A)?(e.consume(A),o=String.fromCharCode(A),x):n(A)}function x(A){if(A===null||A===47||A===62||In(A)){const ue=A===47,ge=o.toLowerCase();return!ue&&!a&&F1.includes(ge)?(i=1,r.interrupt?t(A):N(A)):j$.includes(o.toLowerCase())?(i=6,ue?(e.consume(A),v):r.interrupt?t(A):N(A)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(A):a?b(A):w(A))}return A===45||Bn(A)?(e.consume(A),o+=String.fromCharCode(A),x):n(A)}function v(A){return A===62?(e.consume(A),r.interrupt?t:N):n(A)}function b(A){return Fe(A)?(e.consume(A),b):I(A)}function w(A){return A===47?(e.consume(A),I):A===58||A===95||Br(A)?(e.consume(A),S):Fe(A)?(e.consume(A),w):I(A)}function S(A){return A===45||A===46||A===58||A===95||Bn(A)?(e.consume(A),S):k(A)}function k(A){return A===61?(e.consume(A),j):Fe(A)?(e.consume(A),k):w(A)}function j(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),s=A,C):Fe(A)?(e.consume(A),j):T(A)}function C(A){return A===s?(e.consume(A),s=null,M):A===null||ke(A)?n(A):(e.consume(A),C)}function T(A){return A===null||A===34||A===39||A===47||A===60||A===61||A===62||A===96||In(A)?k(A):(e.consume(A),T)}function M(A){return A===47||A===62||Fe(A)?w(A):n(A)}function I(A){return A===62?(e.consume(A),_):n(A)}function _(A){return A===null||ke(A)?N(A):Fe(A)?(e.consume(A),_):n(A)}function N(A){return A===45&&i===2?(e.consume(A),R):A===60&&i===1?(e.consume(A),U):A===62&&i===4?(e.consume(A),Y):A===63&&i===3?(e.consume(A),P):A===93&&i===5?(e.consume(A),z):ke(A)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(P$,Z,V)(A)):A===null||ke(A)?(e.exit("htmlFlowData"),V(A)):(e.consume(A),N)}function V(A){return e.check(C$,L,Z)(A)}function L(A){return e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),O}function O(A){return A===null||ke(A)?V(A):(e.enter("htmlFlowData"),N(A))}function R(A){return A===45?(e.consume(A),P):N(A)}function U(A){return A===47?(e.consume(A),o="",D):N(A)}function D(A){if(A===62){const ue=o.toLowerCase();return F1.includes(ue)?(e.consume(A),Y):N(A)}return Br(A)&&o.length<8?(e.consume(A),o+=String.fromCharCode(A),D):N(A)}function z(A){return A===93?(e.consume(A),P):N(A)}function P(A){return A===62?(e.consume(A),Y):A===45&&i===2?(e.consume(A),P):N(A)}function Y(A){return A===null||ke(A)?(e.exit("htmlFlowData"),Z(A)):(e.consume(A),Y)}function Z(A){return e.exit("htmlFlow"),t(A)}}function A$(e,t,n){const r=this;return i;function i(o){return ke(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function T$(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Vf,t,n)}}const I$={name:"htmlText",tokenize:_$};function _$(e,t,n){const r=this;let i,a,o;return l;function l(P){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(P),s}function s(P){return P===33?(e.consume(P),c):P===47?(e.consume(P),k):P===63?(e.consume(P),w):Br(P)?(e.consume(P),T):n(P)}function c(P){return P===45?(e.consume(P),d):P===91?(e.consume(P),a=0,g):Br(P)?(e.consume(P),b):n(P)}function d(P){return P===45?(e.consume(P),h):n(P)}function f(P){return P===null?n(P):P===45?(e.consume(P),p):ke(P)?(o=f,U(P)):(e.consume(P),f)}function p(P){return P===45?(e.consume(P),h):f(P)}function h(P){return P===62?R(P):P===45?p(P):f(P)}function g(P){const Y="CDATA[";return P===Y.charCodeAt(a++)?(e.consume(P),a===Y.length?y:g):n(P)}function y(P){return P===null?n(P):P===93?(e.consume(P),x):ke(P)?(o=y,U(P)):(e.consume(P),y)}function x(P){return P===93?(e.consume(P),v):y(P)}function v(P){return P===62?R(P):P===93?(e.consume(P),v):y(P)}function b(P){return P===null||P===62?R(P):ke(P)?(o=b,U(P)):(e.consume(P),b)}function w(P){return P===null?n(P):P===63?(e.consume(P),S):ke(P)?(o=w,U(P)):(e.consume(P),w)}function S(P){return P===62?R(P):w(P)}function k(P){return Br(P)?(e.consume(P),j):n(P)}function j(P){return P===45||Bn(P)?(e.consume(P),j):C(P)}function C(P){return ke(P)?(o=C,U(P)):Fe(P)?(e.consume(P),C):R(P)}function T(P){return P===45||Bn(P)?(e.consume(P),T):P===47||P===62||In(P)?M(P):n(P)}function M(P){return P===47?(e.consume(P),R):P===58||P===95||Br(P)?(e.consume(P),I):ke(P)?(o=M,U(P)):Fe(P)?(e.consume(P),M):R(P)}function I(P){return P===45||P===46||P===58||P===95||Bn(P)?(e.consume(P),I):_(P)}function _(P){return P===61?(e.consume(P),N):ke(P)?(o=_,U(P)):Fe(P)?(e.consume(P),_):M(P)}function N(P){return P===null||P===60||P===61||P===62||P===96?n(P):P===34||P===39?(e.consume(P),i=P,V):ke(P)?(o=N,U(P)):Fe(P)?(e.consume(P),N):(e.consume(P),L)}function V(P){return P===i?(e.consume(P),i=void 0,O):P===null?n(P):ke(P)?(o=V,U(P)):(e.consume(P),V)}function L(P){return P===null||P===34||P===39||P===60||P===61||P===96?n(P):P===47||P===62||In(P)?M(P):(e.consume(P),L)}function O(P){return P===47||P===62||In(P)?M(P):n(P)}function R(P){return P===62?(e.consume(P),e.exit("htmlTextData"),e.exit("htmlText"),t):n(P)}function U(P){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),D}function D(P){return Fe(P)?Ze(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):z(P)}function z(P){return e.enter("htmlTextData"),o(P)}}const Ry={name:"labelEnd",resolveAll:L$,resolveTo:R$,tokenize:z$},N$={tokenize:$$},M$={tokenize:B$},D$={tokenize:F$};function L$(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&Vr(e,0,e.length,n),e}function R$(e,t){let n=e.length,r=0,i,a,o,l;for(;n--;)if(i=e[n][1],a){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(a=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const s={type:e[a][1].type==="labelLink"?"link":"image",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[a][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return l=[["enter",s,t],["enter",c,t]],l=nr(l,e.slice(a+1,a+r+3)),l=nr(l,[["enter",d,t]]),l=nr(l,Ly(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),l=nr(l,[["exit",d,t],e[o-2],e[o-1],["exit",c,t]]),l=nr(l,e.slice(o+1)),l=nr(l,[["exit",s,t]]),Vr(e,a,e.length,l),e}function z$(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return l;function l(p){return a?a._inactive?f(p):(o=r.parser.defined.includes(Ho(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),s):n(p)}function s(p){return p===40?e.attempt(N$,d,o?d:f)(p):p===91?e.attempt(M$,d,o?c:f)(p):o?d(p):f(p)}function c(p){return e.attempt(D$,d,f)(p)}function d(p){return t(p)}function f(p){return a._balanced=!0,n(p)}}function $$(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return In(f)?ys(e,a)(f):a(f)}function a(f){return f===41?d(f):aE(e,o,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function o(f){return In(f)?ys(e,s)(f):d(f)}function l(f){return n(f)}function s(f){return f===34||f===39||f===40?lE(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function c(f){return In(f)?ys(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function B$(e,t,n){const r=this;return i;function i(l){return oE.call(r,e,a,o,"reference","referenceMarker","referenceString")(l)}function a(l){return r.parser.defined.includes(Ho(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function o(l){return n(l)}}function F$(e,t,n){return r;function r(a){return e.enter("reference"),e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),i}function i(a){return a===93?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}const U$={name:"labelStartImage",resolveAll:Ry.resolveAll,tokenize:W$};function W$(e,t,n){const r=this;return i;function i(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),a}function a(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),o):n(l)}function o(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const K$={name:"labelStartLink",resolveAll:Ry.resolveAll,tokenize:H$};function H$(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),a}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Bh={name:"lineEnding",tokenize:V$};function V$(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ze(e,t,"linePrefix")}}const Rc={name:"thematicBreak",tokenize:q$};function q$(e,t,n){let r=0,i;return a;function a(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,l(c)}function l(c){return c===i?(e.enter("thematicBreakSequence"),s(c)):r>=3&&(c===null||ke(c))?(e.exit("thematicBreak"),t(c)):n(c)}function s(c){return c===i?(e.consume(c),r++,s):(e.exit("thematicBreakSequence"),Fe(c)?Ze(e,l,"whitespace")(c):l(c))}}const jn={continuation:{tokenize:Q$},exit:J$,name:"list",tokenize:X$},Y$={partial:!0,tokenize:e4},G$={partial:!0,tokenize:Z$};function X$(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return l;function l(h){const g=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Pg(h)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Rc,n,c)(h):c(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),s(h)}return n(h)}function s(h){return Pg(h)&&++o<10?(e.consume(h),s):(!r.interrupt||o<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),c(h)):n(h)}function c(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(Vf,r.interrupt?n:d,e.attempt(Y$,p,f))}function d(h){return r.containerState.initialBlankLine=!0,a++,p(h)}function f(h){return Fe(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function Q$(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Vf,i,a);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ze(e,t,"listItemIndent",r.containerState.size+1)(l)}function a(l){return r.containerState.furtherBlankLines||!Fe(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(G$,t,o)(l))}function o(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ze(e,e.attempt(jn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Z$(e,t,n){const r=this;return Ze(e,i,"listItemIndent",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function J$(e){e.exit(this.containerState.type)}function e4(e,t,n){const r=this;return Ze(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!Fe(a)&&o&&o[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const U1={name:"setextUnderline",resolveTo:t4,tokenize:n4};function t4(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",a?(e.splice(i,0,["enter",o,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function n4(e,t,n){const r=this;let i;return a;function a(c){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),l(c)}function l(c){return c===i?(e.consume(c),l):(e.exit("setextHeadingLineSequence"),Fe(c)?Ze(e,s,"lineSuffix")(c):s(c))}function s(c){return c===null||ke(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const r4={tokenize:i4};function i4(e){const t=this,n=e.attempt(Vf,r,e.attempt(this.parser.constructs.flowInitial,i,Ze(e,e.attempt(this.parser.constructs.flow,i,e.attempt(u$,i)),"linePrefix")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const a4={resolveAll:uE()},o4=sE("string"),l4=sE("text");function sE(e){return{resolveAll:uE(e==="text"?s4:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,l);return o;function o(d){return c(d)?a(d):l(d)}function l(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),s}function s(d){return c(d)?(n.exit("data"),a(d)):(n.consume(d),s)}function c(d){if(d===null)return!0;const f=i[d];let p=-1;if(f)for(;++p<f.length;){const h=f[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function uE(e){return t;function t(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 s4(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,l=0,s;for(;a--;){const c=i[a];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)l++,o--;if(o)break;o=-1}else if(c===-2)s=!0,l++;else if(c!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const c={type:n===e.length||s||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const u4={42:jn,43:jn,45:jn,48:jn,49:jn,50:jn,51:jn,52:jn,53:jn,54:jn,55:jn,56:jn,57:jn,62:tE},c4={91:h$},d4={[-2]:$h,[-1]:$h,32:$h},f4={35:b$,42:Rc,45:[U1,Rc],60:k$,61:U1,95:Rc,96:B1,126:B1},p4={38:rE,92:nE},h4={[-5]:Bh,[-4]:Bh,[-3]:Bh,33:U$,38:rE,42:Cg,60:[Kz,I$],91:K$,92:[y$,nE],93:Ry,95:Cg,96:r$},m4={null:[Cg,a4]},g4={null:[42,95]},v4={null:[]},y4=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:g4,contentInitial:c4,disable:v4,document:u4,flow:f4,flowInitial:d4,insideSpan:m4,string:p4,text:h4},Symbol.toStringTag,{value:"Module"}));function x4(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],l=[];const s={attempt:C(k),check:C(j),consume:b,enter:w,exit:S,interrupt:C(j,{interrupt:!0})},c={code:null,containerState:{},defineSkip:y,events:[],now:g,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:f};let d=t.tokenize.call(c,s);return t.resolveAll&&a.push(t),c;function f(_){return o=nr(o,_),x(),o[o.length-1]!==null?[]:(T(t,0),c.events=Ly(a,c.events,c),c.events)}function p(_,N){return w4(h(_),N)}function h(_){return b4(o,_)}function g(){const{_bufferIndex:_,_index:N,line:V,column:L,offset:O}=r;return{_bufferIndex:_,_index:N,line:V,column:L,offset:O}}function y(_){i[_.line]=_.column,I()}function x(){let _;for(;r._index<o.length;){const N=o[r._index];if(typeof N=="string")for(_=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===_&&r._bufferIndex<N.length;)v(N.charCodeAt(r._bufferIndex));else v(N)}}function v(_){d=d(_)}function b(_){ke(_)?(r.line++,r.column=1,r.offset+=_===-3?2:1,I()):_!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=_}function w(_,N){const V=N||{};return V.type=_,V.start=g(),c.events.push(["enter",V,c]),l.push(V),V}function S(_){const N=l.pop();return N.end=g(),c.events.push(["exit",N,c]),N}function k(_,N){T(_,N.from)}function j(_,N){N.restore()}function C(_,N){return V;function V(L,O,R){let U,D,z,P;return Array.isArray(L)?Z(L):"tokenize"in L?Z([L]):Y(L);function Y(H){return G;function G(de){const W=de!==null&&H[de],ne=de!==null&&H.null,se=[...Array.isArray(W)?W:W?[W]:[],...Array.isArray(ne)?ne:ne?[ne]:[]];return Z(se)(de)}}function Z(H){return U=H,D=0,H.length===0?R:A(H[D])}function A(H){return G;function G(de){return P=M(),z=H,H.partial||(c.currentConstruct=H),H.name&&c.parser.constructs.disable.null.includes(H.name)?ge():H.tokenize.call(N?Object.assign(Object.create(c),N):c,s,ue,ge)(de)}}function ue(H){return _(z,P),O}function ge(H){return P.restore(),++D<U.length?A(U[D]):R}}}function T(_,N){_.resolveAll&&!a.includes(_)&&a.push(_),_.resolve&&Vr(c.events,N,c.events.length-N,_.resolve(c.events.slice(N),c)),_.resolveTo&&(c.events=_.resolveTo(c.events,c))}function M(){const _=g(),N=c.previous,V=c.currentConstruct,L=c.events.length,O=Array.from(l);return{from:L,restore:R};function R(){r=_,c.previous=N,c.currentConstruct=V,c.events.length=L,l=O,I()}}function I(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function b4(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){const l=o[0];typeof l=="string"?o[0]=l.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function w4(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let o;if(typeof a=="string")o=a;else switch(a){case-5:{o="\r";break}case-4:{o=`
69
69
  `;break}case-3:{o=`\r
70
- `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join("")}function S4(e){const r={constructs:Az([y4,...(e||{}).extensions||[]]),content:i(Rz),defined:[],document:i($z),flow:i(r4),lazy:{},string:i(o4),text:i(l4)};return r;function i(a){return o;function o(l){return x4(r,a,l)}}}function j4(e){for(;!iE(e););return e}const W1=/[\0\t\n\r]/g;function k4(){let e=1,t="",n=!0,r;return i;function i(a,o,l){const s=[];let c,d,f,p,h;for(a=t+(typeof a=="string"?a.toString():new TextDecoder(o||void 0).decode(a)),f=0,t="",n&&(a.charCodeAt(0)===65279&&f++,n=void 0);f<a.length;){if(W1.lastIndex=f,c=W1.exec(a),p=c&&c.index!==void 0?c.index:a.length,h=a.charCodeAt(p),!c){t=a.slice(f);break}if(h===10&&f===p&&r)s.push(-3),r=void 0;else switch(r&&(s.push(-5),r=void 0),f<p&&(s.push(a.slice(f,p)),e+=p-f),h){case 0:{s.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,s.push(-2);e++<d;)s.push(-1);break}case 10:{s.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return l&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}const P4=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function C4(e){return e.replace(P4,O4)}function O4(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),a=i===120||i===88;return eE(n.slice(a?2:1),a?16:10)}return Dy(n)||e}const cE={}.hasOwnProperty;function E4(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),A4(n)(j4(S4(n).document().write(k4()(e,t,!0))))}function A4(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(Pt),autolinkProtocol:M,autolinkEmail:M,atxHeading:a(ve),blockQuote:a(ne),characterEscape:M,characterReference:M,codeFenced:a(se),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(se,o),codeText:a(q,o),codeTextData:M,data:M,codeFlowValue:M,definition:a(_e),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(Ce),hardBreakEscape:a(we),hardBreakTrailing:a(we),htmlFlow:a(Pe,o),htmlFlowData:M,htmlText:a(Pe,o),htmlTextData:M,image:a(Mn),label:o,link:a(Pt),listItem:a($t),listItemValue:p,listOrdered:a(xt,f),listUnordered:a(xt),paragraph:a(bt),reference:A,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ve),strong:a(wt),thematicBreak:a(Gt)},exit:{atxHeading:s(),atxHeadingSequence:k,autolink:s(),autolinkEmail:W,autolinkProtocol:de,blockQuote:s(),characterEscapeValue:I,characterReferenceMarkerHexadecimal:ge,characterReferenceMarkerNumeric:ge,characterReferenceValue:H,characterReference:G,codeFenced:s(x),codeFencedFence:y,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:I,codeIndented:s(v),codeText:s(O),codeTextData:I,data:I,definition:s(),definitionDestinationString:S,definitionLabelString:b,definitionTitleString:w,emphasis:s(),hardBreakEscape:s(N),hardBreakTrailing:s(N),htmlFlow:s(V),htmlFlowData:I,htmlText:s(L),htmlTextData:I,image:s(U),label:z,labelText:D,lineEnding:_,link:s(R),listItem:s(),listOrdered:s(),listUnordered:s(),paragraph:s(),referenceString:ue,resourceDestinationString:P,resourceTitleString:Y,resource:Z,setextHeading:s(T),setextHeadingLineSequence:C,setextHeadingText:j,strong:s(),thematicBreak:s()}};dE(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(K){let J={type:"root",children:[]};const xe={stack:[J],tokenStack:[],config:t,enter:l,exit:c,buffer:o,resume:d,data:n},Oe=[];let be=-1;for(;++be<K.length;)if(K[be][1].type==="listOrdered"||K[be][1].type==="listUnordered")if(K[be][0]==="enter")Oe.push(be);else{const F=Oe.pop();be=i(K,F,be)}for(be=-1;++be<K.length;){const F=t[K[be][0]];cE.call(F,K[be][1].type)&&F[K[be][1].type].call(Object.assign({sliceSerialize:K[be][2].sliceSerialize},xe),K[be][1])}if(xe.tokenStack.length>0){const F=xe.tokenStack[xe.tokenStack.length-1];(F[1]||K1).call(xe,void 0,F[0])}for(J.position={start:Di(K.length>0?K[0][1].start:{line:1,column:1,offset:0}),end:Di(K.length>0?K[K.length-2][1].end:{line:1,column:1,offset:0})},be=-1;++be<t.transforms.length;)J=t.transforms[be](J)||J;return J}function i(K,J,xe){let Oe=J-1,be=-1,F=!1,le,ie,Se,$e;for(;++Oe<=xe;){const Ne=K[Oe];switch(Ne[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ne[0]==="enter"?be++:be--,$e=void 0;break}case"lineEndingBlank":{Ne[0]==="enter"&&(le&&!$e&&!be&&!Se&&(Se=Oe),$e=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:$e=void 0}if(!be&&Ne[0]==="enter"&&Ne[1].type==="listItemPrefix"||be===-1&&Ne[0]==="exit"&&(Ne[1].type==="listUnordered"||Ne[1].type==="listOrdered")){if(le){let Ve=Oe;for(ie=void 0;Ve--;){const Me=K[Ve];if(Me[1].type==="lineEnding"||Me[1].type==="lineEndingBlank"){if(Me[0]==="exit")continue;ie&&(K[ie][1].type="lineEndingBlank",F=!0),Me[1].type="lineEnding",ie=Ve}else if(!(Me[1].type==="linePrefix"||Me[1].type==="blockQuotePrefix"||Me[1].type==="blockQuotePrefixWhitespace"||Me[1].type==="blockQuoteMarker"||Me[1].type==="listItemIndent"))break}Se&&(!ie||Se<ie)&&(le._spread=!0),le.end=Object.assign({},ie?K[ie][1].start:Ne[1].end),K.splice(ie||Oe,0,["exit",le,Ne[2]]),Oe++,xe++}if(Ne[1].type==="listItemPrefix"){const Ve={type:"listItem",_spread:!1,start:Object.assign({},Ne[1].start),end:void 0};le=Ve,K.splice(Oe,0,["enter",Ve,Ne[2]]),Oe++,xe++,Se=void 0,$e=!0}}}return K[J][1]._spread=F,xe}function a(K,J){return xe;function xe(Oe){l.call(this,K(Oe),Oe),J&&J.call(this,Oe)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(K,J,xe){this.stack[this.stack.length-1].children.push(K),this.stack.push(K),this.tokenStack.push([J,xe||void 0]),K.position={start:Di(J.start),end:void 0}}function s(K){return J;function J(xe){K&&K.call(this,xe),c.call(this,xe)}}function c(K,J){const xe=this.stack.pop(),Oe=this.tokenStack.pop();if(Oe)Oe[0].type!==K.type&&(J?J.call(this,K,Oe[0]):(Oe[1]||K1).call(this,K,Oe[0]));else throw new Error("Cannot close `"+K.type+"` ("+vs({start:K.start,end:K.end})+"): it’s not open");xe.position.end=Di(K.end)}function d(){return Oz(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(K){if(this.data.expectingFirstListItemValue){const J=this.stack[this.stack.length-2];J.start=Number.parseInt(this.sliceSerialize(K),10),this.data.expectingFirstListItemValue=void 0}}function h(){const K=this.resume(),J=this.stack[this.stack.length-1];J.lang=K}function g(){const K=this.resume(),J=this.stack[this.stack.length-1];J.meta=K}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const K=this.resume(),J=this.stack[this.stack.length-1];J.value=K.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){const K=this.resume(),J=this.stack[this.stack.length-1];J.value=K.replace(/(\r?\n|\r)$/g,"")}function b(K){const J=this.resume(),xe=this.stack[this.stack.length-1];xe.label=J,xe.identifier=Ho(this.sliceSerialize(K)).toLowerCase()}function w(){const K=this.resume(),J=this.stack[this.stack.length-1];J.title=K}function S(){const K=this.resume(),J=this.stack[this.stack.length-1];J.url=K}function k(K){const J=this.stack[this.stack.length-1];if(!J.depth){const xe=this.sliceSerialize(K).length;J.depth=xe}}function j(){this.data.setextHeadingSlurpLineEnding=!0}function C(K){const J=this.stack[this.stack.length-1];J.depth=this.sliceSerialize(K).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function M(K){const xe=this.stack[this.stack.length-1].children;let Oe=xe[xe.length-1];(!Oe||Oe.type!=="text")&&(Oe=It(),Oe.position={start:Di(K.start),end:void 0},xe.push(Oe)),this.stack.push(Oe)}function I(K){const J=this.stack.pop();J.value+=this.sliceSerialize(K),J.position.end=Di(K.end)}function _(K){const J=this.stack[this.stack.length-1];if(this.data.atHardBreak){const xe=J.children[J.children.length-1];xe.position.end=Di(K.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(J.type)&&(M.call(this,K),I.call(this,K))}function N(){this.data.atHardBreak=!0}function V(){const K=this.resume(),J=this.stack[this.stack.length-1];J.value=K}function L(){const K=this.resume(),J=this.stack[this.stack.length-1];J.value=K}function O(){const K=this.resume(),J=this.stack[this.stack.length-1];J.value=K}function R(){const K=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";K.type+="Reference",K.referenceType=J,delete K.url,delete K.title}else delete K.identifier,delete K.label;this.data.referenceType=void 0}function U(){const K=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";K.type+="Reference",K.referenceType=J,delete K.url,delete K.title}else delete K.identifier,delete K.label;this.data.referenceType=void 0}function D(K){const J=this.sliceSerialize(K),xe=this.stack[this.stack.length-2];xe.label=C4(J),xe.identifier=Ho(J).toLowerCase()}function z(){const K=this.stack[this.stack.length-1],J=this.resume(),xe=this.stack[this.stack.length-1];if(this.data.inReference=!0,xe.type==="link"){const Oe=K.children;xe.children=Oe}else xe.alt=J}function P(){const K=this.resume(),J=this.stack[this.stack.length-1];J.url=K}function Y(){const K=this.resume(),J=this.stack[this.stack.length-1];J.title=K}function Z(){this.data.inReference=void 0}function A(){this.data.referenceType="collapsed"}function ue(K){const J=this.resume(),xe=this.stack[this.stack.length-1];xe.label=J,xe.identifier=Ho(this.sliceSerialize(K)).toLowerCase(),this.data.referenceType="full"}function ge(K){this.data.characterReferenceType=K.type}function H(K){const J=this.sliceSerialize(K),xe=this.data.characterReferenceType;let Oe;xe?(Oe=eE(J,xe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Oe=Dy(J);const be=this.stack[this.stack.length-1];be.value+=Oe}function G(K){const J=this.stack.pop();J.position.end=Di(K.end)}function de(K){I.call(this,K);const J=this.stack[this.stack.length-1];J.url=this.sliceSerialize(K)}function W(K){I.call(this,K);const J=this.stack[this.stack.length-1];J.url="mailto:"+this.sliceSerialize(K)}function ne(){return{type:"blockquote",children:[]}}function se(){return{type:"code",lang:null,meta:null,value:""}}function q(){return{type:"inlineCode",value:""}}function _e(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ce(){return{type:"emphasis",children:[]}}function ve(){return{type:"heading",depth:0,children:[]}}function we(){return{type:"break"}}function Pe(){return{type:"html",value:""}}function Mn(){return{type:"image",title:null,url:"",alt:null}}function Pt(){return{type:"link",title:null,url:"",children:[]}}function xt(K){return{type:"list",ordered:K.type==="listOrdered",start:null,spread:K._spread,children:[]}}function $t(K){return{type:"listItem",spread:K._spread,checked:null,children:[]}}function bt(){return{type:"paragraph",children:[]}}function wt(){return{type:"strong",children:[]}}function It(){return{type:"text",value:""}}function Gt(){return{type:"thematicBreak"}}}function Di(e){return{line:e.line,column:e.column,offset:e.offset}}function dE(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?dE(e,r):T4(e,r)}}function T4(e,t){let n;for(n in t)if(cE.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function K1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+vs({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+vs({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+vs({start:t.start,end:t.end})+") is still open")}function I4(e){const t=this;t.parser=n;function n(r){return E4(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function _4(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function N4(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
+ `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join("")}function S4(e){const r={constructs:Az([y4,...(e||{}).extensions||[]]),content:i(Rz),defined:[],document:i($z),flow:i(r4),lazy:{},string:i(o4),text:i(l4)};return r;function i(a){return o;function o(l){return x4(r,a,l)}}}function j4(e){for(;!iE(e););return e}const W1=/[\0\t\n\r]/g;function k4(){let e=1,t="",n=!0,r;return i;function i(a,o,l){const s=[];let c,d,f,p,h;for(a=t+(typeof a=="string"?a.toString():new TextDecoder(o||void 0).decode(a)),f=0,t="",n&&(a.charCodeAt(0)===65279&&f++,n=void 0);f<a.length;){if(W1.lastIndex=f,c=W1.exec(a),p=c&&c.index!==void 0?c.index:a.length,h=a.charCodeAt(p),!c){t=a.slice(f);break}if(h===10&&f===p&&r)s.push(-3),r=void 0;else switch(r&&(s.push(-5),r=void 0),f<p&&(s.push(a.slice(f,p)),e+=p-f),h){case 0:{s.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,s.push(-2);e++<d;)s.push(-1);break}case 10:{s.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return l&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}const P4=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function C4(e){return e.replace(P4,O4)}function O4(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),a=i===120||i===88;return eE(n.slice(a?2:1),a?16:10)}return Dy(n)||e}const cE={}.hasOwnProperty;function E4(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),A4(n)(j4(S4(n).document().write(k4()(e,t,!0))))}function A4(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(Pt),autolinkProtocol:M,autolinkEmail:M,atxHeading:a(ve),blockQuote:a(ne),characterEscape:M,characterReference:M,codeFenced:a(se),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(se,o),codeText:a(q,o),codeTextData:M,data:M,codeFlowValue:M,definition:a(_e),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(Ce),hardBreakEscape:a(we),hardBreakTrailing:a(we),htmlFlow:a(Pe,o),htmlFlowData:M,htmlText:a(Pe,o),htmlTextData:M,image:a(Mn),label:o,link:a(Pt),listItem:a($t),listItemValue:p,listOrdered:a(xt,f),listUnordered:a(xt),paragraph:a(bt),reference:A,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ve),strong:a(wt),thematicBreak:a(Gt)},exit:{atxHeading:s(),atxHeadingSequence:k,autolink:s(),autolinkEmail:W,autolinkProtocol:de,blockQuote:s(),characterEscapeValue:I,characterReferenceMarkerHexadecimal:ge,characterReferenceMarkerNumeric:ge,characterReferenceValue:H,characterReference:G,codeFenced:s(x),codeFencedFence:y,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:I,codeIndented:s(v),codeText:s(O),codeTextData:I,data:I,definition:s(),definitionDestinationString:S,definitionLabelString:b,definitionTitleString:w,emphasis:s(),hardBreakEscape:s(N),hardBreakTrailing:s(N),htmlFlow:s(V),htmlFlowData:I,htmlText:s(L),htmlTextData:I,image:s(U),label:z,labelText:D,lineEnding:_,link:s(R),listItem:s(),listOrdered:s(),listUnordered:s(),paragraph:s(),referenceString:ue,resourceDestinationString:P,resourceTitleString:Y,resource:Z,setextHeading:s(T),setextHeadingLineSequence:C,setextHeadingText:j,strong:s(),thematicBreak:s()}};dE(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(K){let J={type:"root",children:[]};const xe={stack:[J],tokenStack:[],config:t,enter:l,exit:c,buffer:o,resume:d,data:n},Oe=[];let be=-1;for(;++be<K.length;)if(K[be][1].type==="listOrdered"||K[be][1].type==="listUnordered")if(K[be][0]==="enter")Oe.push(be);else{const F=Oe.pop();be=i(K,F,be)}for(be=-1;++be<K.length;){const F=t[K[be][0]];cE.call(F,K[be][1].type)&&F[K[be][1].type].call(Object.assign({sliceSerialize:K[be][2].sliceSerialize},xe),K[be][1])}if(xe.tokenStack.length>0){const F=xe.tokenStack[xe.tokenStack.length-1];(F[1]||K1).call(xe,void 0,F[0])}for(J.position={start:Di(K.length>0?K[0][1].start:{line:1,column:1,offset:0}),end:Di(K.length>0?K[K.length-2][1].end:{line:1,column:1,offset:0})},be=-1;++be<t.transforms.length;)J=t.transforms[be](J)||J;return J}function i(K,J,xe){let Oe=J-1,be=-1,F=!1,ae,ie,Se,$e;for(;++Oe<=xe;){const Ne=K[Oe];switch(Ne[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ne[0]==="enter"?be++:be--,$e=void 0;break}case"lineEndingBlank":{Ne[0]==="enter"&&(ae&&!$e&&!be&&!Se&&(Se=Oe),$e=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:$e=void 0}if(!be&&Ne[0]==="enter"&&Ne[1].type==="listItemPrefix"||be===-1&&Ne[0]==="exit"&&(Ne[1].type==="listUnordered"||Ne[1].type==="listOrdered")){if(ae){let Ve=Oe;for(ie=void 0;Ve--;){const Me=K[Ve];if(Me[1].type==="lineEnding"||Me[1].type==="lineEndingBlank"){if(Me[0]==="exit")continue;ie&&(K[ie][1].type="lineEndingBlank",F=!0),Me[1].type="lineEnding",ie=Ve}else if(!(Me[1].type==="linePrefix"||Me[1].type==="blockQuotePrefix"||Me[1].type==="blockQuotePrefixWhitespace"||Me[1].type==="blockQuoteMarker"||Me[1].type==="listItemIndent"))break}Se&&(!ie||Se<ie)&&(ae._spread=!0),ae.end=Object.assign({},ie?K[ie][1].start:Ne[1].end),K.splice(ie||Oe,0,["exit",ae,Ne[2]]),Oe++,xe++}if(Ne[1].type==="listItemPrefix"){const Ve={type:"listItem",_spread:!1,start:Object.assign({},Ne[1].start),end:void 0};ae=Ve,K.splice(Oe,0,["enter",Ve,Ne[2]]),Oe++,xe++,Se=void 0,$e=!0}}}return K[J][1]._spread=F,xe}function a(K,J){return xe;function xe(Oe){l.call(this,K(Oe),Oe),J&&J.call(this,Oe)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(K,J,xe){this.stack[this.stack.length-1].children.push(K),this.stack.push(K),this.tokenStack.push([J,xe||void 0]),K.position={start:Di(J.start),end:void 0}}function s(K){return J;function J(xe){K&&K.call(this,xe),c.call(this,xe)}}function c(K,J){const xe=this.stack.pop(),Oe=this.tokenStack.pop();if(Oe)Oe[0].type!==K.type&&(J?J.call(this,K,Oe[0]):(Oe[1]||K1).call(this,K,Oe[0]));else throw new Error("Cannot close `"+K.type+"` ("+vs({start:K.start,end:K.end})+"): it’s not open");xe.position.end=Di(K.end)}function d(){return Oz(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(K){if(this.data.expectingFirstListItemValue){const J=this.stack[this.stack.length-2];J.start=Number.parseInt(this.sliceSerialize(K),10),this.data.expectingFirstListItemValue=void 0}}function h(){const K=this.resume(),J=this.stack[this.stack.length-1];J.lang=K}function g(){const K=this.resume(),J=this.stack[this.stack.length-1];J.meta=K}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const K=this.resume(),J=this.stack[this.stack.length-1];J.value=K.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){const K=this.resume(),J=this.stack[this.stack.length-1];J.value=K.replace(/(\r?\n|\r)$/g,"")}function b(K){const J=this.resume(),xe=this.stack[this.stack.length-1];xe.label=J,xe.identifier=Ho(this.sliceSerialize(K)).toLowerCase()}function w(){const K=this.resume(),J=this.stack[this.stack.length-1];J.title=K}function S(){const K=this.resume(),J=this.stack[this.stack.length-1];J.url=K}function k(K){const J=this.stack[this.stack.length-1];if(!J.depth){const xe=this.sliceSerialize(K).length;J.depth=xe}}function j(){this.data.setextHeadingSlurpLineEnding=!0}function C(K){const J=this.stack[this.stack.length-1];J.depth=this.sliceSerialize(K).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function M(K){const xe=this.stack[this.stack.length-1].children;let Oe=xe[xe.length-1];(!Oe||Oe.type!=="text")&&(Oe=It(),Oe.position={start:Di(K.start),end:void 0},xe.push(Oe)),this.stack.push(Oe)}function I(K){const J=this.stack.pop();J.value+=this.sliceSerialize(K),J.position.end=Di(K.end)}function _(K){const J=this.stack[this.stack.length-1];if(this.data.atHardBreak){const xe=J.children[J.children.length-1];xe.position.end=Di(K.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(J.type)&&(M.call(this,K),I.call(this,K))}function N(){this.data.atHardBreak=!0}function V(){const K=this.resume(),J=this.stack[this.stack.length-1];J.value=K}function L(){const K=this.resume(),J=this.stack[this.stack.length-1];J.value=K}function O(){const K=this.resume(),J=this.stack[this.stack.length-1];J.value=K}function R(){const K=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";K.type+="Reference",K.referenceType=J,delete K.url,delete K.title}else delete K.identifier,delete K.label;this.data.referenceType=void 0}function U(){const K=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";K.type+="Reference",K.referenceType=J,delete K.url,delete K.title}else delete K.identifier,delete K.label;this.data.referenceType=void 0}function D(K){const J=this.sliceSerialize(K),xe=this.stack[this.stack.length-2];xe.label=C4(J),xe.identifier=Ho(J).toLowerCase()}function z(){const K=this.stack[this.stack.length-1],J=this.resume(),xe=this.stack[this.stack.length-1];if(this.data.inReference=!0,xe.type==="link"){const Oe=K.children;xe.children=Oe}else xe.alt=J}function P(){const K=this.resume(),J=this.stack[this.stack.length-1];J.url=K}function Y(){const K=this.resume(),J=this.stack[this.stack.length-1];J.title=K}function Z(){this.data.inReference=void 0}function A(){this.data.referenceType="collapsed"}function ue(K){const J=this.resume(),xe=this.stack[this.stack.length-1];xe.label=J,xe.identifier=Ho(this.sliceSerialize(K)).toLowerCase(),this.data.referenceType="full"}function ge(K){this.data.characterReferenceType=K.type}function H(K){const J=this.sliceSerialize(K),xe=this.data.characterReferenceType;let Oe;xe?(Oe=eE(J,xe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Oe=Dy(J);const be=this.stack[this.stack.length-1];be.value+=Oe}function G(K){const J=this.stack.pop();J.position.end=Di(K.end)}function de(K){I.call(this,K);const J=this.stack[this.stack.length-1];J.url=this.sliceSerialize(K)}function W(K){I.call(this,K);const J=this.stack[this.stack.length-1];J.url="mailto:"+this.sliceSerialize(K)}function ne(){return{type:"blockquote",children:[]}}function se(){return{type:"code",lang:null,meta:null,value:""}}function q(){return{type:"inlineCode",value:""}}function _e(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ce(){return{type:"emphasis",children:[]}}function ve(){return{type:"heading",depth:0,children:[]}}function we(){return{type:"break"}}function Pe(){return{type:"html",value:""}}function Mn(){return{type:"image",title:null,url:"",alt:null}}function Pt(){return{type:"link",title:null,url:"",children:[]}}function xt(K){return{type:"list",ordered:K.type==="listOrdered",start:null,spread:K._spread,children:[]}}function $t(K){return{type:"listItem",spread:K._spread,checked:null,children:[]}}function bt(){return{type:"paragraph",children:[]}}function wt(){return{type:"strong",children:[]}}function It(){return{type:"text",value:""}}function Gt(){return{type:"thematicBreak"}}}function Di(e){return{line:e.line,column:e.column,offset:e.offset}}function dE(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?dE(e,r):T4(e,r)}}function T4(e,t){let n;for(n in t)if(cE.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function K1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+vs({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+vs({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+vs({start:t.start,end:t.end})+") is still open")}function I4(e){const t=this;t.parser=n;function n(r){return E4(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function _4(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function N4(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
71
71
  `}]}function M4(e,t){const n=t.value?t.value+`
72
72
  `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:"element",tagName:"pre",properties:{},children:[a]},e.patch(t,a),a}function D4(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function L4(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function R4(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=ml(r.toLowerCase()),a=e.footnoteOrder.indexOf(r);let o,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,l+=1,e.footnoteCounts.set(r,l);const s={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,s);const c={type:"element",tagName:"sup",properties:{},children:[s]};return e.patch(t,c),e.applyData(t,c)}function z4(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $4(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function fE(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),a=i[0];a&&a.type==="text"?a.value="["+a.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function B4(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return fE(e,t);const i={src:ml(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function F4(e,t){const n={src:ml(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function U4(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function W4(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return fE(e,t);const i={href:ml(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function K4(e,t){const n={href:ml(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function H4(e,t,n){const r=e.all(t),i=n?V4(n):pE(t),a={},o=[];if(typeof t.checked=="boolean"){const d=r[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const d=r[l];(i||l!==0||d.type!=="element"||d.tagName!=="p")&&o.push({type:"text",value:`
73
73
  `}),d.type==="element"&&d.tagName==="p"&&!i?o.push(...d.children):o.push(d)}const s=r[r.length-1];s&&(i||s.type!=="element"||s.tagName!=="p")&&o.push({type:"text",value:`
@@ -77,14 +77,14 @@ Error generating stack: `+a.message+`
77
77
  `});++r<e.length;)r&&n.push({type:"text",value:`
78
78
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
79
79
  `}),n}function Z1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function J1(e,t){const n=w3(e,t),r=n.one(e,void 0),i=c3(n),a=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&a.children.push({type:"text",value:`
80
- `},i),a}function C3(e,t){return e&&"run"in e?async function(n,r){const i=J1(n,{file:r,...t});await e.run(i,r)}:function(n,r){return J1(n,{file:r,...e||t})}}function ew(e){if(e)throw e}var zc=Object.prototype.hasOwnProperty,bE=Object.prototype.toString,tw=Object.defineProperty,nw=Object.getOwnPropertyDescriptor,rw=function(t){return typeof Array.isArray=="function"?Array.isArray(t):bE.call(t)==="[object Array]"},iw=function(t){if(!t||bE.call(t)!=="[object Object]")return!1;var n=zc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&zc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var i;for(i in t);return typeof i>"u"||zc.call(t,i)},aw=function(t,n){tw&&n.name==="__proto__"?tw(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},ow=function(t,n){if(n==="__proto__")if(zc.call(t,n)){if(nw)return nw(t,n).value}else return;return t[n]},O3=function e(){var t,n,r,i,a,o,l=arguments[0],s=1,c=arguments.length,d=!1;for(typeof l=="boolean"&&(d=l,l=arguments[1]||{},s=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});s<c;++s)if(t=arguments[s],t!=null)for(n in t)r=ow(l,n),i=ow(t,n),l!==i&&(d&&i&&(iw(i)||(a=rw(i)))?(a?(a=!1,o=r&&rw(r)?r:[]):o=r&&iw(r)?r:{},aw(l,{name:n,newValue:e(d,o,i)})):typeof i<"u"&&aw(l,{name:n,newValue:i}));return l};const Fh=Vn(O3);function Eg(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function E3(){const e=[],t={run:n,use:r};return t;function n(...i){let a=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);l(null,...i);function l(s,...c){const d=e[++a];let f=-1;if(s){o(s);return}for(;++f<i.length;)(c[f]===null||c[f]===void 0)&&(c[f]=i[f]);i=c,d?A3(d,l)(...c):o(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function A3(e,t){let n;return r;function r(...o){const l=e.length>o.length;let s;l&&o.push(i);try{s=e.apply(this,o)}catch(c){const d=c;if(l&&n)throw d;return i(d)}l||(s&&s.then&&typeof s.then=="function"?s.then(a,i):s instanceof Error?i(s):a(s))}function i(o,...l){n||(n=!0,t(o,...l))}function a(o){i(null,o)}}const Rr={basename:T3,dirname:I3,extname:_3,join:N3,sep:"/"};function T3(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');pu(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function I3(e){if(pu(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function _3(e){pu(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){const l=e.codePointAt(t);if(l===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),l===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function N3(...e){let t=-1,n;for(;++t<e.length;)pu(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":M3(n)}function M3(e){pu(e);const t=e.codePointAt(0)===47;let n=D3(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function D3(e,t){let n="",r=0,i=-1,a=0,o=-1,l,s;for(;++o<=e.length;){if(o<e.length)l=e.codePointAt(o);else{if(l===47)break;l=47}if(l===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(s=n.lastIndexOf("/"),s!==n.length-1){s<0?(n="",r=0):(n=n.slice(0,s),r=n.length-1-n.lastIndexOf("/")),i=o,a=0;continue}}else if(n.length>0){n="",r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else l===46&&a>-1?a++:a=-1}return n}function pu(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const L3={cwd:R3};function R3(){return"/"}function Ag(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function z3(e){if(typeof e=="string")e=new URL(e);else if(!Ag(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return $3(e)}function $3(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const Uh=["history","path","basename","stem","extname","dirname"];class wE{constructor(t){let n;t?Ag(t)?n={path:t}:typeof t=="string"||B3(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":L3.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Uh.length;){const a=Uh[r];a in n&&n[a]!==void 0&&n[a]!==null&&(this[a]=a==="history"?[...n[a]]:n[a])}let i;for(i in n)Uh.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Rr.basename(this.path):void 0}set basename(t){Kh(t,"basename"),Wh(t,"basename"),this.path=Rr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Rr.dirname(this.path):void 0}set dirname(t){lw(this.basename,"dirname"),this.path=Rr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Rr.extname(this.path):void 0}set extname(t){if(Wh(t,"extname"),lw(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Rr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ag(t)&&(t=z3(t)),Kh(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Rr.basename(this.path,this.extname):void 0}set stem(t){Kh(t,"stem"),Wh(t,"stem"),this.path=Rr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new fn(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Wh(e,t){if(e&&e.includes(Rr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Rr.sep+"`")}function Kh(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function lw(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function B3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const F3=function(e){const r=this.constructor.prototype,i=r[e],a=function(){return i.apply(a,arguments)};return Object.setPrototypeOf(a,r),a},U3={}.hasOwnProperty;class Uy extends F3{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=E3()}copy(){const t=new Uy;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Fh(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(qh("data",this.frozen),this.namespace[t]=n,this):U3.call(this.namespace,t)&&this.namespace[t]||void 0:t?(qh("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=ic(t),r=this.parser||this.Parser;return Hh("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Hh("process",this.parser||this.Parser),Vh("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(a,o){const l=ic(t),s=r.parse(l);r.run(s,l,function(d,f,p){if(d||!f||!p)return c(d);const h=f,g=r.stringify(h,p);H3(g)?p.value=g:p.result=g,c(d,p)});function c(d,f){d||!f?o(d):a?a(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),Hh("processSync",this.parser||this.Parser),Vh("processSync",this.compiler||this.Compiler),this.process(t,i),uw("processSync","process",n),r;function i(a,o){n=!0,ew(a),r=o}}run(t,n,r){sw(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?a(void 0,r):new Promise(a);function a(o,l){const s=ic(n);i.run(t,s,c);function c(d,f,p){const h=f||t;d?l(d):o?o(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,a),uw("runSync","run",r),i;function a(o,l){ew(o),i=l,r=!0}}stringify(t,n){this.freeze();const r=ic(n),i=this.compiler||this.Compiler;return Vh("stringify",i),sw(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(qh("use",this.frozen),t!=null)if(typeof t=="function")s(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function a(c){if(typeof c=="function")s(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[d,...f]=c;s(d,f)}else o(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function o(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(c.plugins),c.settings&&(i.settings=Fh(!0,i.settings,c.settings))}function l(c){let d=-1;if(c!=null)if(Array.isArray(c))for(;++d<c.length;){const f=c[d];a(f)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function s(c,d){let f=-1,p=-1;for(;++f<r.length;)if(r[f][0]===c){p=f;break}if(p===-1)r.push([c,...d]);else if(d.length>0){let[h,...g]=d;const y=r[p][1];Eg(y)&&Eg(h)&&(h=Fh(!0,y,h)),r[p]=[c,h,...g]}}}}const W3=new Uy().freeze();function Hh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Vh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function qh(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function sw(e){if(!Eg(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function uw(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ic(e){return K3(e)?e:new wE(e)}function K3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function H3(e){return typeof e=="string"||V3(e)}function V3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const q3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",cw=[],dw={allowDangerousHtml:!0},Y3=/^(https?|ircs?|mailto|xmpp)$/i,G3=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function bs(e){const t=X3(e),n=Q3(e);return Z3(t.runSync(t.parse(n),n),e)}function X3(e){const t=e.rehypePlugins||cw,n=e.remarkPlugins||cw,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...dw}:dw;return W3().use(I4).use(n).use(C3,r).use(t)}function Q3(e){const t=e.children||"",n=new wE;return typeof t=="string"&&(n.value=t),n}function Z3(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,l=t.unwrapDisallowed,s=t.urlTransform||J3;for(const d of G3)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+q3+d.id,void 0);return xE(e,c),cz(e,{Fragment:u.Fragment,components:i,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0});function c(d,f,p){if(d.type==="raw"&&p&&typeof f=="number")return o?p.children.splice(f,1):p.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let h;for(h in zh)if(Object.hasOwn(zh,h)&&Object.hasOwn(d.properties,h)){const g=d.properties[h],y=zh[h];(y===null||y.includes(d.tagName))&&(d.properties[h]=s(String(g||""),h,d))}}if(d.type==="element"){let h=n?!n.includes(d.tagName):a?a.includes(d.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(d,f,p)),h&&p&&typeof f=="number")return l&&d.children?p.children.splice(f,1,...d.children):p.children.splice(f,1),f}}}function J3(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Y3.test(e.slice(0,t))?e:""}const ae=(e,t)=>{if(!t)return e;const n=new URLSearchParams;Object.entries(t).forEach(([i,a])=>{a!=null&&a!==""&&n.set(i,String(a))});const r=n.toString();return r?`${e}?${r}`:e},oe=async(e,t={})=>{const n=localStorage.getItem("auth_token"),r=await fetch(e,{...t,headers:{"Content-Type":"application/json",...n?{Authorization:`Bearer ${n}`}:{},...t.headers||{}}});if(!r.ok){if(r.status===401){localStorage.removeItem("auth_token");const l=await r.text(),s=new Error(l||r.statusText);throw s.status=401,s}const a=await r.text();let o=null;try{const l=JSON.parse(a);l.error&&(o=l.error)}catch{}throw new Error(o||a||r.statusText)}return r.status===204?void 0:(r.headers.get("content-type")||"").includes("application/json")?r.json():r.text()},Q={getAuthStatus:()=>oe(ae("/api/auth/status")),login:e=>oe(ae("/api/auth/login"),{method:"POST",body:JSON.stringify({authCode:e})}),checkVersion:()=>oe(ae("/api/version/check")),getVendors:()=>oe(ae("/api/vendors")),createVendor:e=>oe(ae("/api/vendors"),{method:"POST",body:JSON.stringify(e)}),updateVendor:(e,t)=>oe(ae(`/api/vendors/${e}`),{method:"PUT",body:JSON.stringify(t)}),deleteVendor:e=>oe(ae(`/api/vendors/${e}`),{method:"DELETE"}),getAPIServices:e=>oe(ae("/api/services",e?{vendorId:e}:void 0)),createAPIService:e=>oe(ae("/api/services"),{method:"POST",body:JSON.stringify(e)}),updateAPIService:(e,t)=>oe(ae(`/api/services/${e}`),{method:"PUT",body:JSON.stringify(t)}),deleteAPIService:e=>oe(ae(`/api/services/${e}`),{method:"DELETE"}),getRoutes:()=>oe(ae("/api/routes")),createRoute:e=>oe(ae("/api/routes"),{method:"POST",body:JSON.stringify(e)}),updateRoute:(e,t)=>oe(ae(`/api/routes/${e}`),{method:"PUT",body:JSON.stringify(t)}),deleteRoute:e=>oe(ae(`/api/routes/${e}`),{method:"DELETE"}),activateRoute:e=>oe(ae(`/api/routes/${e}/activate`),{method:"POST"}),deactivateRoute:e=>oe(ae(`/api/routes/${e}/deactivate`),{method:"POST"}),getRules:e=>oe(ae("/api/rules",e?{routeId:e}:void 0)),createRule:e=>oe(ae("/api/rules"),{method:"POST",body:JSON.stringify(e)}),updateRule:(e,t)=>oe(ae(`/api/rules/${e}`),{method:"PUT",body:JSON.stringify(t)}),deleteRule:e=>oe(ae(`/api/rules/${e}`),{method:"DELETE"}),resetRuleTokens:e=>oe(ae(`/api/rules/${e}/reset-tokens`),{method:"PUT"}),resetRuleRequests:e=>oe(ae(`/api/rules/${e}/reset-requests`),{method:"PUT"}),clearRuleBlacklist:e=>oe(ae(`/api/rules/${e}/clear-blacklist`),{method:"PUT"}),toggleRuleDisable:e=>oe(ae(`/api/rules/${e}/toggle-disable`),{method:"PUT"}),getRulesBlacklistStatus:e=>oe(ae(`/api/rules/${e}/blacklist-status`)),getLogs:(e,t)=>oe(ae("/api/logs",{limit:e,offset:t})),clearLogs:()=>oe(ae("/api/logs"),{method:"DELETE"}),getErrorLogs:(e,t)=>oe(ae("/api/error-logs",{limit:e,offset:t})),clearErrorLogs:()=>oe(ae("/api/error-logs"),{method:"DELETE"}),getLogsCount:()=>oe(ae("/api/logs/count")),getErrorLogsCount:()=>oe(ae("/api/error-logs/count")),searchLogs:(e,t,n)=>oe(ae("/api/logs/search",{query:e,limit:t,offset:n})),searchLogsCount:e=>oe(ae("/api/logs/search/count",{query:e})),searchErrorLogs:(e,t,n)=>oe(ae("/api/error-logs/search",{query:e,limit:t,offset:n})),searchErrorLogsCount:e=>oe(ae("/api/error-logs/search/count",{query:e})),getStatistics:(e=30)=>oe(ae("/api/statistics",{days:e})),resetStatistics:()=>oe(ae("/api/statistics"),{method:"DELETE"}),getConfig:()=>oe(ae("/api/config")),updateConfig:e=>oe(ae("/api/config"),{method:"PUT",body:JSON.stringify(e)}),exportData:async e=>(await oe(ae("/api/export"),{method:"POST",body:JSON.stringify({password:e})})).data,previewImportData:(e,t)=>oe(ae("/api/import/preview"),{method:"POST",body:JSON.stringify({encryptedData:e,password:t})}),importData:(e,t)=>oe(ae("/api/import"),{method:"POST",body:JSON.stringify({encryptedData:e,password:t})}),writeClaudeConfig:e=>oe(ae("/api/write-config/claude"),{method:"POST",body:JSON.stringify({enableAgentTeams:e})}),writeCodexConfig:()=>oe(ae("/api/write-config/codex"),{method:"POST"}),restoreClaudeConfig:()=>oe(ae("/api/restore-config/claude"),{method:"POST"}),restoreCodexConfig:()=>oe(ae("/api/restore-config/codex"),{method:"POST"}),updateClaudeAgentTeams:e=>oe(ae("/api/update-claude-agent-teams"),{method:"POST",body:JSON.stringify({enableAgentTeams:e})}),checkClaudeBackup:()=>oe(ae("/api/check-backup/claude")),checkCodexBackup:()=>oe(ae("/api/check-backup/codex")),checkClaudeVersion:()=>oe(ae("/api/tools/status")),getClaudeConfigStatus:()=>oe(ae("/api/config-status/claude")),getCodexConfigStatus:()=>oe(ae("/api/config-status/codex")),getSessions:(e,t)=>oe(ae("/api/sessions",{limit:e,offset:t})),getSessionsCount:()=>oe(ae("/api/sessions/count")),getSession:e=>oe(ae(`/api/sessions/${e}`)),getSessionLogs:(e,t)=>oe(ae(`/api/sessions/${e}/logs`,{limit:t})),deleteSession:e=>oe(ae(`/api/sessions/${e}`),{method:"DELETE"}),clearSessions:()=>oe(ae("/api/sessions"),{method:"DELETE"}),getRecommendVendorsMarkdown:()=>oe(ae("/api/docs/recommend-vendors")),getReadmeMarkdown:()=>oe(ae("/api/docs/readme")),getInstalledSkills:()=>oe(ae("/api/skills/installed")),searchSkills:e=>oe(ae("/api/skills/search"),{method:"POST",body:JSON.stringify({query:e})}),getSkillDetails:e=>oe(ae(`/api/skills/${e}/details`)),installSkill:(e,t)=>oe(ae("/api/skills/install"),{method:"POST",body:JSON.stringify({skillId:e.id,name:e.name,description:e.description,tags:e.tags,...t?{targetType:t}:{},githubUrl:e.url})}),enableSkill:(e,t)=>oe(ae(`/api/skills/${e}/enable`),{method:"POST",body:JSON.stringify({targetType:t})}),disableSkill:(e,t)=>oe(ae(`/api/skills/${e}/disable`),{method:"POST",body:JSON.stringify({targetType:t})}),deleteSkill:e=>oe(ae(`/api/skills/${e}`),{method:"DELETE"}),createLocalSkill:e=>oe(ae("/api/skills/create-local"),{method:"POST",body:JSON.stringify(e)}),getUpgradeMarkdown:()=>oe(ae("/api/docs/upgrade")),getUpgrade:()=>oe(ae("/api/upgrade")),acknowledgeUpgrade:()=>oe(ae("/api/upgrade/ack"),{method:"POST"}),getToolsStatus:()=>oe(ae("/api/tools/status")),getMCPs:()=>oe(ae("/api/mcps")),getMCP:e=>oe(ae(`/api/mcps/${e}`)),createMCP:e=>oe(ae("/api/mcps"),{method:"POST",body:JSON.stringify(e)}),updateMCP:(e,t)=>oe(ae(`/api/mcps/${e}`),{method:"PUT",body:JSON.stringify(t)}),deleteMCP:e=>oe(ae(`/api/mcps/${e}`),{method:"DELETE"}),installTool:(e,t)=>{var c;console.log("[API Client] 开始安装工具:",e);const n=window.location.protocol==="https:"?"wss:":"ws:",r=window.location.host,i=`${n}//${r}/api/tools/install`;console.log("[API Client] 连接 WebSocket:",i);let a=null;try{a=new WebSocket(i)}catch(d){return console.error("[API Client] 创建 WebSocket 失败:",d),(c=t.onError)==null||c.call(t,"创建 WebSocket 连接失败"),()=>{}}a.onopen=()=>{console.log("[API Client] WebSocket 连接已建立"),a==null||a.send(JSON.stringify({type:"install",tool:e}))},a.onmessage=d=>{var f,p,h,g,y,x,v,b,w;try{const S=JSON.parse(d.data);switch(console.log("[API Client] 收到消息:",S.type),S.type){case"start":console.log("[API Client] 安装开始:",S.data),(f=t.onStdout)==null||f.call(t,`
80
+ `},i),a}function C3(e,t){return e&&"run"in e?async function(n,r){const i=J1(n,{file:r,...t});await e.run(i,r)}:function(n,r){return J1(n,{file:r,...e||t})}}function ew(e){if(e)throw e}var zc=Object.prototype.hasOwnProperty,bE=Object.prototype.toString,tw=Object.defineProperty,nw=Object.getOwnPropertyDescriptor,rw=function(t){return typeof Array.isArray=="function"?Array.isArray(t):bE.call(t)==="[object Array]"},iw=function(t){if(!t||bE.call(t)!=="[object Object]")return!1;var n=zc.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&zc.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var i;for(i in t);return typeof i>"u"||zc.call(t,i)},aw=function(t,n){tw&&n.name==="__proto__"?tw(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},ow=function(t,n){if(n==="__proto__")if(zc.call(t,n)){if(nw)return nw(t,n).value}else return;return t[n]},O3=function e(){var t,n,r,i,a,o,l=arguments[0],s=1,c=arguments.length,d=!1;for(typeof l=="boolean"&&(d=l,l=arguments[1]||{},s=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});s<c;++s)if(t=arguments[s],t!=null)for(n in t)r=ow(l,n),i=ow(t,n),l!==i&&(d&&i&&(iw(i)||(a=rw(i)))?(a?(a=!1,o=r&&rw(r)?r:[]):o=r&&iw(r)?r:{},aw(l,{name:n,newValue:e(d,o,i)})):typeof i<"u"&&aw(l,{name:n,newValue:i}));return l};const Fh=Vn(O3);function Eg(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function E3(){const e=[],t={run:n,use:r};return t;function n(...i){let a=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);l(null,...i);function l(s,...c){const d=e[++a];let f=-1;if(s){o(s);return}for(;++f<i.length;)(c[f]===null||c[f]===void 0)&&(c[f]=i[f]);i=c,d?A3(d,l)(...c):o(null,...c)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function A3(e,t){let n;return r;function r(...o){const l=e.length>o.length;let s;l&&o.push(i);try{s=e.apply(this,o)}catch(c){const d=c;if(l&&n)throw d;return i(d)}l||(s&&s.then&&typeof s.then=="function"?s.then(a,i):s instanceof Error?i(s):a(s))}function i(o,...l){n||(n=!0,t(o,...l))}function a(o){i(null,o)}}const Rr={basename:T3,dirname:I3,extname:_3,join:N3,sep:"/"};function T3(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');pu(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function I3(e){if(pu(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function _3(e){pu(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){const l=e.codePointAt(t);if(l===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),l===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function N3(...e){let t=-1,n;for(;++t<e.length;)pu(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":M3(n)}function M3(e){pu(e);const t=e.codePointAt(0)===47;let n=D3(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function D3(e,t){let n="",r=0,i=-1,a=0,o=-1,l,s;for(;++o<=e.length;){if(o<e.length)l=e.codePointAt(o);else{if(l===47)break;l=47}if(l===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(s=n.lastIndexOf("/"),s!==n.length-1){s<0?(n="",r=0):(n=n.slice(0,s),r=n.length-1-n.lastIndexOf("/")),i=o,a=0;continue}}else if(n.length>0){n="",r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else l===46&&a>-1?a++:a=-1}return n}function pu(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const L3={cwd:R3};function R3(){return"/"}function Ag(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function z3(e){if(typeof e=="string")e=new URL(e);else if(!Ag(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return $3(e)}function $3(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const Uh=["history","path","basename","stem","extname","dirname"];class wE{constructor(t){let n;t?Ag(t)?n={path:t}:typeof t=="string"||B3(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":L3.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Uh.length;){const a=Uh[r];a in n&&n[a]!==void 0&&n[a]!==null&&(this[a]=a==="history"?[...n[a]]:n[a])}let i;for(i in n)Uh.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Rr.basename(this.path):void 0}set basename(t){Kh(t,"basename"),Wh(t,"basename"),this.path=Rr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Rr.dirname(this.path):void 0}set dirname(t){lw(this.basename,"dirname"),this.path=Rr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Rr.extname(this.path):void 0}set extname(t){if(Wh(t,"extname"),lw(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Rr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ag(t)&&(t=z3(t)),Kh(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Rr.basename(this.path,this.extname):void 0}set stem(t){Kh(t,"stem"),Wh(t,"stem"),this.path=Rr.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new fn(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Wh(e,t){if(e&&e.includes(Rr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Rr.sep+"`")}function Kh(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function lw(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function B3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const F3=function(e){const r=this.constructor.prototype,i=r[e],a=function(){return i.apply(a,arguments)};return Object.setPrototypeOf(a,r),a},U3={}.hasOwnProperty;class Uy extends F3{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=E3()}copy(){const t=new Uy;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Fh(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(qh("data",this.frozen),this.namespace[t]=n,this):U3.call(this.namespace,t)&&this.namespace[t]||void 0:t?(qh("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=ic(t),r=this.parser||this.Parser;return Hh("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Hh("process",this.parser||this.Parser),Vh("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(a,o){const l=ic(t),s=r.parse(l);r.run(s,l,function(d,f,p){if(d||!f||!p)return c(d);const h=f,g=r.stringify(h,p);H3(g)?p.value=g:p.result=g,c(d,p)});function c(d,f){d||!f?o(d):a?a(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),Hh("processSync",this.parser||this.Parser),Vh("processSync",this.compiler||this.Compiler),this.process(t,i),uw("processSync","process",n),r;function i(a,o){n=!0,ew(a),r=o}}run(t,n,r){sw(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?a(void 0,r):new Promise(a);function a(o,l){const s=ic(n);i.run(t,s,c);function c(d,f,p){const h=f||t;d?l(d):o?o(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,i;return this.run(t,n,a),uw("runSync","run",r),i;function a(o,l){ew(o),i=l,r=!0}}stringify(t,n){this.freeze();const r=ic(n),i=this.compiler||this.Compiler;return Vh("stringify",i),sw(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(qh("use",this.frozen),t!=null)if(typeof t=="function")s(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function a(c){if(typeof c=="function")s(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[d,...f]=c;s(d,f)}else o(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function o(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(c.plugins),c.settings&&(i.settings=Fh(!0,i.settings,c.settings))}function l(c){let d=-1;if(c!=null)if(Array.isArray(c))for(;++d<c.length;){const f=c[d];a(f)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function s(c,d){let f=-1,p=-1;for(;++f<r.length;)if(r[f][0]===c){p=f;break}if(p===-1)r.push([c,...d]);else if(d.length>0){let[h,...g]=d;const y=r[p][1];Eg(y)&&Eg(h)&&(h=Fh(!0,y,h)),r[p]=[c,h,...g]}}}}const W3=new Uy().freeze();function Hh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Vh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function qh(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function sw(e){if(!Eg(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function uw(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function ic(e){return K3(e)?e:new wE(e)}function K3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function H3(e){return typeof e=="string"||V3(e)}function V3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const q3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",cw=[],dw={allowDangerousHtml:!0},Y3=/^(https?|ircs?|mailto|xmpp)$/i,G3=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function bs(e){const t=X3(e),n=Q3(e);return Z3(t.runSync(t.parse(n),n),e)}function X3(e){const t=e.rehypePlugins||cw,n=e.remarkPlugins||cw,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...dw}:dw;return W3().use(I4).use(n).use(C3,r).use(t)}function Q3(e){const t=e.children||"",n=new wE;return typeof t=="string"&&(n.value=t),n}function Z3(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,l=t.unwrapDisallowed,s=t.urlTransform||J3;for(const d of G3)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+q3+d.id,void 0);return xE(e,c),cz(e,{Fragment:u.Fragment,components:i,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0});function c(d,f,p){if(d.type==="raw"&&p&&typeof f=="number")return o?p.children.splice(f,1):p.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let h;for(h in zh)if(Object.hasOwn(zh,h)&&Object.hasOwn(d.properties,h)){const g=d.properties[h],y=zh[h];(y===null||y.includes(d.tagName))&&(d.properties[h]=s(String(g||""),h,d))}}if(d.type==="element"){let h=n?!n.includes(d.tagName):a?a.includes(d.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(d,f,p)),h&&p&&typeof f=="number")return l&&d.children?p.children.splice(f,1,...d.children):p.children.splice(f,1),f}}}function J3(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Y3.test(e.slice(0,t))?e:""}const oe=(e,t)=>{if(!t)return e;const n=new URLSearchParams;Object.entries(t).forEach(([i,a])=>{a!=null&&a!==""&&n.set(i,String(a))});const r=n.toString();return r?`${e}?${r}`:e},le=async(e,t={})=>{const n=localStorage.getItem("auth_token"),r=await fetch(e,{...t,headers:{"Content-Type":"application/json",...n?{Authorization:`Bearer ${n}`}:{},...t.headers||{}}});if(!r.ok){if(r.status===401){localStorage.removeItem("auth_token");const l=await r.text(),s=new Error(l||r.statusText);throw s.status=401,s}const a=await r.text();let o=null;try{const l=JSON.parse(a);l.error&&(o=l.error)}catch{}throw new Error(o||a||r.statusText)}return r.status===204?void 0:(r.headers.get("content-type")||"").includes("application/json")?r.json():r.text()},Q={getAuthStatus:()=>le(oe("/api/auth/status")),login:e=>le(oe("/api/auth/login"),{method:"POST",body:JSON.stringify({authCode:e})}),checkVersion:()=>le(oe("/api/version/check")),getVendors:()=>le(oe("/api/vendors")),createVendor:e=>le(oe("/api/vendors"),{method:"POST",body:JSON.stringify(e)}),updateVendor:(e,t)=>le(oe(`/api/vendors/${e}`),{method:"PUT",body:JSON.stringify(t)}),deleteVendor:e=>le(oe(`/api/vendors/${e}`),{method:"DELETE"}),getAPIServices:e=>le(oe("/api/services",e?{vendorId:e}:void 0)),createAPIService:e=>le(oe("/api/services"),{method:"POST",body:JSON.stringify(e)}),updateAPIService:(e,t)=>le(oe(`/api/services/${e}`),{method:"PUT",body:JSON.stringify(t)}),deleteAPIService:e=>le(oe(`/api/services/${e}`),{method:"DELETE"}),getRoutes:()=>le(oe("/api/routes")),createRoute:e=>le(oe("/api/routes"),{method:"POST",body:JSON.stringify(e)}),updateRoute:(e,t)=>le(oe(`/api/routes/${e}`),{method:"PUT",body:JSON.stringify(t)}),deleteRoute:e=>le(oe(`/api/routes/${e}`),{method:"DELETE"}),activateRoute:e=>le(oe(`/api/routes/${e}/activate`),{method:"POST"}),deactivateRoute:e=>le(oe(`/api/routes/${e}/deactivate`),{method:"POST"}),getRules:e=>le(oe("/api/rules",e?{routeId:e}:void 0)),createRule:e=>le(oe("/api/rules"),{method:"POST",body:JSON.stringify(e)}),updateRule:(e,t)=>le(oe(`/api/rules/${e}`),{method:"PUT",body:JSON.stringify(t)}),deleteRule:e=>le(oe(`/api/rules/${e}`),{method:"DELETE"}),resetRuleTokens:e=>le(oe(`/api/rules/${e}/reset-tokens`),{method:"PUT"}),resetRuleRequests:e=>le(oe(`/api/rules/${e}/reset-requests`),{method:"PUT"}),clearRuleBlacklist:e=>le(oe(`/api/rules/${e}/clear-blacklist`),{method:"PUT"}),toggleRuleDisable:e=>le(oe(`/api/rules/${e}/toggle-disable`),{method:"PUT"}),getRulesBlacklistStatus:e=>le(oe(`/api/rules/${e}/blacklist-status`)),getLogs:(e,t)=>le(oe("/api/logs",{limit:e,offset:t})),clearLogs:()=>le(oe("/api/logs"),{method:"DELETE"}),getErrorLogs:(e,t)=>le(oe("/api/error-logs",{limit:e,offset:t})),clearErrorLogs:()=>le(oe("/api/error-logs"),{method:"DELETE"}),getLogsCount:()=>le(oe("/api/logs/count")),getErrorLogsCount:()=>le(oe("/api/error-logs/count")),searchLogs:(e,t,n)=>le(oe("/api/logs/search",{query:e,limit:t,offset:n})),searchLogsCount:e=>le(oe("/api/logs/search/count",{query:e})),searchErrorLogs:(e,t,n)=>le(oe("/api/error-logs/search",{query:e,limit:t,offset:n})),searchErrorLogsCount:e=>le(oe("/api/error-logs/search/count",{query:e})),getStatistics:(e=30)=>le(oe("/api/statistics",{days:e})),resetStatistics:()=>le(oe("/api/statistics"),{method:"DELETE"}),getConfig:()=>le(oe("/api/config")),updateConfig:e=>le(oe("/api/config"),{method:"PUT",body:JSON.stringify(e)}),exportData:async e=>(await le(oe("/api/export"),{method:"POST",body:JSON.stringify({password:e})})).data,previewImportData:(e,t)=>le(oe("/api/import/preview"),{method:"POST",body:JSON.stringify({encryptedData:e,password:t})}),importData:(e,t)=>le(oe("/api/import"),{method:"POST",body:JSON.stringify({encryptedData:e,password:t})}),writeClaudeConfig:e=>le(oe("/api/write-config/claude"),{method:"POST",body:JSON.stringify({enableAgentTeams:e})}),writeCodexConfig:()=>le(oe("/api/write-config/codex"),{method:"POST"}),restoreClaudeConfig:()=>le(oe("/api/restore-config/claude"),{method:"POST"}),restoreCodexConfig:()=>le(oe("/api/restore-config/codex"),{method:"POST"}),updateClaudeAgentTeams:e=>le(oe("/api/update-claude-agent-teams"),{method:"POST",body:JSON.stringify({enableAgentTeams:e})}),checkClaudeBackup:()=>le(oe("/api/check-backup/claude")),checkCodexBackup:()=>le(oe("/api/check-backup/codex")),checkClaudeVersion:()=>le(oe("/api/tools/status")),getClaudeConfigStatus:()=>le(oe("/api/config-status/claude")),getCodexConfigStatus:()=>le(oe("/api/config-status/codex")),getSessions:(e,t)=>le(oe("/api/sessions",{limit:e,offset:t})),getSessionsCount:()=>le(oe("/api/sessions/count")),getSession:e=>le(oe(`/api/sessions/${e}`)),getSessionLogs:(e,t)=>le(oe(`/api/sessions/${e}/logs`,{limit:t})),deleteSession:e=>le(oe(`/api/sessions/${e}`),{method:"DELETE"}),clearSessions:()=>le(oe("/api/sessions"),{method:"DELETE"}),getRecommendVendorsMarkdown:()=>le(oe("/api/docs/recommend-vendors")),getReadmeMarkdown:()=>le(oe("/api/docs/readme")),getInstalledSkills:()=>le(oe("/api/skills/installed")),searchSkills:e=>le(oe("/api/skills/search"),{method:"POST",body:JSON.stringify({query:e})}),getSkillDetails:e=>le(oe(`/api/skills/${e}/details`)),installSkill:(e,t)=>le(oe("/api/skills/install"),{method:"POST",body:JSON.stringify({skillId:e.id,name:e.name,description:e.description,tags:e.tags,...t?{targetType:t}:{},githubUrl:e.url})}),enableSkill:(e,t)=>le(oe(`/api/skills/${e}/enable`),{method:"POST",body:JSON.stringify({targetType:t})}),disableSkill:(e,t)=>le(oe(`/api/skills/${e}/disable`),{method:"POST",body:JSON.stringify({targetType:t})}),deleteSkill:e=>le(oe(`/api/skills/${e}`),{method:"DELETE"}),createLocalSkill:e=>le(oe("/api/skills/create-local"),{method:"POST",body:JSON.stringify(e)}),getUpgradeMarkdown:()=>le(oe("/api/docs/upgrade")),getUpgrade:()=>le(oe("/api/upgrade")),acknowledgeUpgrade:()=>le(oe("/api/upgrade/ack"),{method:"POST"}),getToolsStatus:()=>le(oe("/api/tools/status")),getMCPs:()=>le(oe("/api/mcps")),getMCP:e=>le(oe(`/api/mcps/${e}`)),createMCP:e=>le(oe("/api/mcps"),{method:"POST",body:JSON.stringify(e)}),updateMCP:(e,t)=>le(oe(`/api/mcps/${e}`),{method:"PUT",body:JSON.stringify(t)}),deleteMCP:e=>le(oe(`/api/mcps/${e}`),{method:"DELETE"}),installTool:(e,t)=>{var c;console.log("[API Client] 开始安装工具:",e);const n=window.location.protocol==="https:"?"wss:":"ws:",r=window.location.host,i=`${n}//${r}/api/tools/install`;console.log("[API Client] 连接 WebSocket:",i);let a=null;try{a=new WebSocket(i)}catch(d){return console.error("[API Client] 创建 WebSocket 失败:",d),(c=t.onError)==null||c.call(t,"创建 WebSocket 连接失败"),()=>{}}a.onopen=()=>{console.log("[API Client] WebSocket 连接已建立"),a==null||a.send(JSON.stringify({type:"install",tool:e}))},a.onmessage=d=>{var f,p,h,g,y,x,v,b,w;try{const S=JSON.parse(d.data);switch(console.log("[API Client] 收到消息:",S.type),S.type){case"start":console.log("[API Client] 安装开始:",S.data),(f=t.onStdout)==null||f.call(t,`
81
81
  ========== 开始安装 ${S.data.tool} ==========
82
82
  `),(p=t.onStdout)==null||p.call(t,`操作系统: ${S.data.os}
83
83
  `),(h=t.onStdout)==null||h.call(t,`执行命令: ${S.data.command}
84
84
  `),(g=t.onStdout)==null||g.call(t,`子进程已创建 (PID: ${S.data.pid})
85
85
  `),(y=t.onStdout)==null||y.call(t,`等待 npm 输出...
86
86
 
87
- `);break;case"stdout":(x=t.onStdout)==null||x.call(t,S.data);break;case"stderr":(v=t.onStderr)==null||v.call(t,S.data);break;case"close":console.log("[API Client] 安装完成:",S.data),(b=t.onClose)==null||b.call(t,S.data.code,S.data.success),setTimeout(()=>{a==null||a.close()},1e3);break;case"error":console.error("[API Client] 安装错误:",S.data),(w=t.onError)==null||w.call(t,S.data);break}}catch(S){console.error("[API Client] 解析消息失败:",S,d.data)}},a.onclose=d=>{var f;console.log("[API Client] WebSocket 连接关闭:",d.code,d.reason),d.wasClean||(f=t.onError)==null||f.call(t,"连接意外关闭")},a.onerror=d=>{var f;console.error("[API Client] WebSocket 错误:",d),(f=t.onError)==null||f.call(t,"WebSocket 连接错误")};const o=()=>{console.log("[API Client] 清理 WebSocket 连接"),a&&(a.close(),a=null)},l=d=>{a&&a.readyState===WebSocket.OPEN?(a.send(JSON.stringify({type:"input",data:d})),console.log("[API Client] 发送输入:",d.slice(0,10))):console.warn("[API Client] WebSocket 未连接,无法发送输入")},s=o;return s.sendInput=l,s}};var Zt=(e=>(e.AUTH_TOKEN="authorization",e.API_KEY="x-api-key",e.G_API_KEY="x-goog-api-key",e))(Zt||{});const Dn={minimax:{name:"Minimax",description:"国内优秀的大模型 https://platform.minimaxi.com/subscribe/coding-plan?code=G6xKj7L4YN&source=link",services:[{name:"Coding Plan Claude Code",sourceType:"claude-code",apiUrl:"https://api.minimaxi.com/anthropic",models:"MiniMax-M2.5"},{name:"Coding Plan Codex",sourceType:"openai-chat",apiUrl:"https://api.minimaxi.com/v1",models:"codex-MiniMax-M2.1, codex-MiniMax-M2.5"}]},glm:{name:"GLM",description:"国内优秀的大模型 https://www.bigmodel.cn/glm-coding?ic=5AH7ATEZSC",services:[{name:"Coding Plan Claude Code",sourceType:"claude-code",apiUrl:"https://open.bigmodel.cn/api/anthropic",models:"glm-4.7, glm-4.5-air",modelLimits:{"glm-4.7":131072,"glm-4.5-air":98304}}]},kimi:{name:"Kimi",description:"国内优秀大模型 https://www.kimi.ai/",services:[{name:"Coding Plan Claude Code",sourceType:"claude-code",apiUrl:"https://api.kimi.com/coding"}]},doubao:{name:"火山方舟(豆包)",description:"字节旗下大模型平台。Coding Plan一次性支持GLM、Kimi-K2、Deepseek多个国产模型 https://volcengine.com/L/RcHlm6yxj0w/ 邀请码:Y58X463P",services:[{name:"Coding Plan Claude Code",sourceType:"claude-code",apiUrl:"https://ark.cn-beijing.volces.com/api/coding",models:"ark-code-latest"},{name:"Coding Plan Codex",sourceType:"openai-responses",apiUrl:"https://ark.cn-beijing.volces.com/api/coding/v3",models:"ark-code-latest"},{name:"付费API兼容Claude Code",sourceType:"claude-code",apiUrl:"https://ark.cn-beijing.volces.com/api/compatible",models:"doubao-seed-code-preview-251028"},{name:"付费API兼容Codex",sourceType:"openai-responses",apiUrl:"https://ark.cn-beijing.volces.com/api/v3",models:"doubao-seed-code-preview-251028"}]},qwen:{name:"阿里云百炼(千问)",description:"国内优秀大模型 https://help.aliyun.com/zh/model-studio/coding-plan",services:[{name:"Coding Plan Claude Code",sourceType:"claude-code",apiUrl:"https://coding.dashscope.aliyuncs.com/apps/anthropic",models:"qwen3-max-2026-01-23, qwen3-coder-plus"},{name:"Coding Plan Codex",sourceType:"openai-chat",apiUrl:"https://coding.dashscope.aliyuncs.com/v1",models:"qwen3-max-2026-01-23, qwen3-coder-plus"},{name:"付费API兼容Codex",sourceType:"openai-responses",apiUrl:"https://dashscope.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1",models:"qwen3-max-2026-01-23, qwen3-coder-plus, kimi-k2.5, glm-4.7, MiniMax-M2.1"}]},aicodewith:{name:"AICodeWith",description:"稳定的第三方中转 https://aicodewith.com/login?tab=register&invitation=QCA74W",services:[{name:"claudecode",sourceType:"claude-code",apiUrl:"https://api.aicodewith.com"},{name:"codex",sourceType:"openai-responses",apiUrl:"https://api.aicodewith.com/chatgpt"}]},openai:{name:"OpenAI",description:"OpenAI 官方 API https://platform.openai.com",services:[{name:"GPT",sourceType:"openai-responses",apiUrl:"https://api.openai.com"}],is_oversea:!0},anthropic:{name:"Anthropic",description:"Anthropic 官方 API https://www.anthropic.com",services:[{name:"Claude",sourceType:"claude-code",apiUrl:"https://api.anthropic.com"}],is_oversea:!0},google:{name:"Google AI",description:"Google AI 官方 API",services:[{name:"Gemini",sourceType:"gemini",apiUrl:"https://generativelanguage.googleapis.com"}],is_oversea:!0},openrouter:{name:"OpenRouter",description:"一站式 AI 模型路由平台 https://openrouter.ai",services:[{name:"Claude Code专属接口",sourceType:"claude-code",apiUrl:"https://openrouter.ai/api",models:"anthropic/claude-opus-4.6, anthropic/claude-opus-4.5, anthropic/claude-sonnet-4.5, anthropic/claude-haiku-4.5"},{name:"通用接口",sourceType:"openai-chat",apiUrl:"https://openrouter.ai/api/v1/chat/completions",models:"anthropic/claude-opus-4.5, anthropic/claude-sonnet-4.5, anthropic/claude-haiku-4.5, openai/gpt-5.2-codex, openai/gpt-5.2-chat, openai/gpt-5.2-pro, openai/gpt-5.2, openai/gpt-5.1-codex-max, google/gemini-3-flash-preview, google/gemini-3-pro-preview"}],is_oversea:!0}},ac={"claude-code":"Claude Code",codex:"Codex"},oc={"claude-code":"Claude Code","claude-chat":"Claude Chat","openai-responses":"OpenAI Responses","openai-chat":"OpenAI Chat","deepseek-reasoning-chat":"DeepSeek Reasoning Chat",gemini:"Gemini"},eB={"openai-chat":"填写完整的接口地址,如:https://api.openai.com/v1/chat/completions","openai-responses":"只填写 base 地址(含/v1),如:https://api.openai.com/v1","claude-chat":"填写完整的接口地址,如:https://api.anthropic.com/v1/messages","claude-code":"只填写 base 地址,如:https://api.anthropic.com","deepseek-reasoning-chat":"推理类模型,填写完整的接口地址,如:https://api.deepseek.com/v1/chat/completions",gemini:"只填写 base 地址,如:https://generativelanguage.googleapis.com"},fw={[Zt.AUTH_TOKEN]:"AUTH_TOKEN",[Zt.API_KEY]:"API_KEY",[Zt.G_API_KEY]:"GOOGLE_API_KEY"},tB={[Zt.AUTH_TOKEN]:"使用 Authorization: Bearer <token> 进行认证",[Zt.API_KEY]:"使用 x-api-key: <token> 进行认证",[Zt.G_API_KEY]:"使用 x-goog-api-key: <token> 进行认证"},nB=`#### 🚀 智谱 GLM Coding Plan
87
+ `);break;case"stdout":(x=t.onStdout)==null||x.call(t,S.data);break;case"stderr":(v=t.onStderr)==null||v.call(t,S.data);break;case"close":console.log("[API Client] 安装完成:",S.data),(b=t.onClose)==null||b.call(t,S.data.code,S.data.success),setTimeout(()=>{a==null||a.close()},1e3);break;case"error":console.error("[API Client] 安装错误:",S.data),(w=t.onError)==null||w.call(t,S.data);break}}catch(S){console.error("[API Client] 解析消息失败:",S,d.data)}},a.onclose=d=>{var f;console.log("[API Client] WebSocket 连接关闭:",d.code,d.reason),d.wasClean||(f=t.onError)==null||f.call(t,"连接意外关闭")},a.onerror=d=>{var f;console.error("[API Client] WebSocket 错误:",d),(f=t.onError)==null||f.call(t,"WebSocket 连接错误")};const o=()=>{console.log("[API Client] 清理 WebSocket 连接"),a&&(a.close(),a=null)},l=d=>{a&&a.readyState===WebSocket.OPEN?(a.send(JSON.stringify({type:"input",data:d})),console.log("[API Client] 发送输入:",d.slice(0,10))):console.warn("[API Client] WebSocket 未连接,无法发送输入")},s=o;return s.sendInput=l,s}};var Zt=(e=>(e.AUTH_TOKEN="authorization",e.API_KEY="x-api-key",e.G_API_KEY="x-goog-api-key",e))(Zt||{});const Dn={minimax:{name:"Minimax",description:"国内优秀的大模型 https://platform.minimaxi.com/subscribe/coding-plan?code=G6xKj7L4YN&source=link",services:[{name:"Coding Plan Claude Code",sourceType:"claude",apiUrl:"https://api.minimaxi.com/anthropic",models:"MiniMax-M2.5"},{name:"Coding Plan Codex",sourceType:"openai-chat",apiUrl:"https://api.minimaxi.com/v1",models:"codex-MiniMax-M2.1, codex-MiniMax-M2.5"}]},glm:{name:"GLM",description:"国内优秀的大模型 https://www.bigmodel.cn/glm-coding?ic=5AH7ATEZSC",services:[{name:"Coding Plan Claude Code",sourceType:"claude",apiUrl:"https://open.bigmodel.cn/api/anthropic",models:"glm-4.7, glm-4.5-air",modelLimits:{"glm-4.7":131072,"glm-4.5-air":98304}}]},kimi:{name:"Kimi",description:"国内优秀大模型 https://www.kimi.ai/",services:[{name:"Coding Plan Claude Code",sourceType:"claude",apiUrl:"https://api.kimi.com/coding"}]},doubao:{name:"火山方舟(豆包)",description:"字节旗下大模型平台。Coding Plan一次性支持GLM、Kimi-K2、Deepseek多个国产模型 https://volcengine.com/L/RcHlm6yxj0w/ 邀请码:Y58X463P",services:[{name:"Coding Plan Claude Code",sourceType:"claude",apiUrl:"https://ark.cn-beijing.volces.com/api/coding",models:"ark-code-latest"},{name:"Coding Plan Codex",sourceType:"openai",apiUrl:"https://ark.cn-beijing.volces.com/api/coding/v3",models:"ark-code-latest"},{name:"付费API兼容Claude Code",sourceType:"claude",apiUrl:"https://ark.cn-beijing.volces.com/api/compatible",models:"doubao-seed-code-preview-251028"},{name:"付费API兼容Codex",sourceType:"openai",apiUrl:"https://ark.cn-beijing.volces.com/api/v3",models:"doubao-seed-code-preview-251028"}]},qwen:{name:"阿里云百炼(千问)",description:"国内优秀大模型 https://help.aliyun.com/zh/model-studio/coding-plan",services:[{name:"Coding Plan Claude Code",sourceType:"claude",apiUrl:"https://coding.dashscope.aliyuncs.com/apps/anthropic",models:"qwen3-max-2026-01-23, qwen3-coder-plus"},{name:"Coding Plan Codex",sourceType:"openai-chat",apiUrl:"https://coding.dashscope.aliyuncs.com/v1",models:"qwen3-max-2026-01-23, qwen3-coder-plus"},{name:"付费API兼容Codex",sourceType:"openai",apiUrl:"https://dashscope.aliyuncs.com/api/v2/apps/protocols/compatible-mode/v1",models:"qwen3-max-2026-01-23, qwen3-coder-plus, kimi-k2.5, glm-4.7, MiniMax-M2.1"}]},aicodewith:{name:"AICodeWith",description:"稳定的第三方中转 https://aicodewith.com/login?tab=register&invitation=QCA74W",services:[{name:"claudecode",sourceType:"claude",apiUrl:"https://api.aicodewith.com"},{name:"codex",sourceType:"openai",apiUrl:"https://api.aicodewith.com/chatgpt"}]},openai:{name:"OpenAI",description:"OpenAI 官方 API https://platform.openai.com",services:[{name:"GPT",sourceType:"openai",apiUrl:"https://api.openai.com"}],is_oversea:!0},anthropic:{name:"Anthropic",description:"Anthropic 官方 API https://www.anthropic.com",services:[{name:"Claude",sourceType:"claude",apiUrl:"https://api.anthropic.com"}],is_oversea:!0},google:{name:"Google AI",description:"Google AI 官方 API",services:[{name:"Gemini",sourceType:"gemini",apiUrl:"https://generativelanguage.googleapis.com"}],is_oversea:!0},openrouter:{name:"OpenRouter",description:"一站式 AI 模型路由平台 https://openrouter.ai",services:[{name:"Claude Code专属接口",sourceType:"claude",apiUrl:"https://openrouter.ai/api",models:"anthropic/claude-opus-4.6, anthropic/claude-opus-4.5, anthropic/claude-sonnet-4.5, anthropic/claude-haiku-4.5"},{name:"通用接口",sourceType:"openai-chat",apiUrl:"https://openrouter.ai/api/v1/chat/completions",models:"anthropic/claude-opus-4.5, anthropic/claude-sonnet-4.5, anthropic/claude-haiku-4.5, openai/gpt-5.2-codex, openai/gpt-5.2-chat, openai/gpt-5.2-pro, openai/gpt-5.2, openai/gpt-5.1-codex-max, google/gemini-3-flash-preview, google/gemini-3-pro-preview"}],is_oversea:!0}},ac={"claude-code":"Claude Code",codex:"Codex"},oc={claude:"Claude","claude-chat":"Claude Chat",openai:"OpenAI","openai-chat":"OpenAI Chat","deepseek-reasoning-chat":"DeepSeek Reasoning Chat",gemini:"Gemini","gemini-chat":"Gemini Chat"},eB={"openai-chat":"填写完整的接口地址,如:https://api.openai.com/v1/chat/completions",openai:"只填写 base 地址(含/v1),如:https://api.openai.com/v1","claude-chat":"填写完整的接口地址,如:https://api.anthropic.com/v1/messages",claude:"只填写 base 地址,如:https://api.anthropic.com","deepseek-reasoning-chat":"推理类模型,填写完整的接口地址,如:https://api.deepseek.com/v1/chat/completions",gemini:"只填写 base 地址,如:https://generativelanguage.googleapis.com","gemini-chat":"填写完整的接口地址,如:https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent"},fw={[Zt.AUTH_TOKEN]:"AUTH_TOKEN",[Zt.API_KEY]:"API_KEY",[Zt.G_API_KEY]:"GOOGLE_API_KEY"},tB={[Zt.AUTH_TOKEN]:"使用 Authorization: Bearer <token> 进行认证",[Zt.API_KEY]:"使用 x-api-key: <token> 进行认证",[Zt.G_API_KEY]:"使用 x-goog-api-key: <token> 进行认证"},nB=`#### 🚀 智谱 GLM Coding Plan
88
88
 
89
89
  > 价格便宜,国内速度快,支持多工具(Claude Code等 20+ 大编程工具),而且其中的GLM-4.7是目前国内最强编程模型。适合对模型有一定要求,同时又无法获取国外模型的朋友入手。
90
90
  >
@@ -113,13 +113,13 @@ Error generating stack: `+a.message+`
113
113
  opacity: 1;
114
114
  }
115
115
  }
116
- `}),u.jsx("div",{style:{position:"fixed",top:"20px",right:"20px",zIndex:9999},children:e.map(i=>u.jsxs("div",{style:n(i.type),children:[u.jsx("span",{style:{fontSize:"18px",fontWeight:"bold"},children:r(i.type)}),u.jsx("span",{style:{flex:1},children:i.message}),u.jsx("button",{onClick:()=>PE(i.id),style:{background:"none",border:"none",color:"inherit",cursor:"pointer",fontSize:"18px",padding:"0",marginLeft:"10px",opacity:.6},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity="0.6",children:"×"})]},i.id))})]})}function pw(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0");return`${t}-${n}-${r}T${i}:${a}`}function sB({value:e=[],onChange:t,placeholder:n,inputValue:r,onInputChange:i}){const a=l=>{if(l.key==="Enter"||l.key===","){l.preventDefault();const s=r.trim();s&&!e.includes(s)&&(t([...e,s]),i(""))}else l.key==="Backspace"&&!r&&e.length>0&&t(e.slice(0,-1))},o=l=>{t(e.filter((s,c)=>c!==l))};return u.jsx("div",{style:{border:"1px solid var(--border-primary)",borderRadius:"4px",padding:"8px",minHeight:"40px",background:"var(--bg-secondary)"},children:u.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",alignItems:"center"},children:[e.map((l,s)=>u.jsxs("span",{style:{backgroundColor:"var(--accent-light)",color:"var(--text-primary)",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",display:"flex",alignItems:"center",gap:"4px"},children:[l,u.jsx("button",{type:"button",onClick:()=>o(s),style:{background:"none",border:"none",color:"var(--text-primary)",cursor:"pointer",fontSize:"16px",lineHeight:"1",padding:"0",marginLeft:"4px"},onMouseOver:c=>c.currentTarget.style.color="var(--accent-danger)",onMouseOut:c=>c.currentTarget.style.color="var(--text-primary)",children:"×"})]},s)),u.jsx("input",{type:"text",value:r,onChange:l=>i(l.target.value),onKeyDown:a,placeholder:n,style:{border:"none",outline:"none",flex:"1",minWidth:"120px",fontSize:"14px"}})]})})}function uB(){var Oe,be;const{confirm:e}=Wy(),t=m.useRef(null),[n,r]=m.useState([]),[i,a]=m.useState(null),[o,l]=m.useState(!1),[s,c]=m.useState(!1),[d,f]=m.useState(!1),[p,h]=m.useState(!1),[g,y]=m.useState(null),[x,v]=m.useState(null),[b,w]=m.useState([]),[S,k]=m.useState(""),[j,C]=m.useState({}),[T,M]=m.useState(!1),[I,_]=m.useState(void 0),[N,V]=m.useState(void 0),[L,O]=m.useState(void 0),[R,U]=m.useState(!1),[D,z]=m.useState(void 0),[P,Y]=m.useState(void 0),[Z,A]=m.useState(void 0),[ue,ge]=m.useState("openai-chat"),[H,G]=m.useState(Zt.AUTH_TOKEN),de=F=>{ge(F);let le;F==="gemini"?le=Zt.G_API_KEY:F==="claude-chat"||F==="claude-code"?le=Zt.API_KEY:le=Zt.AUTH_TOKEN,G(le),t.current&&(t.current.value=le)},[W,ne]=m.useState(""),[se,q]=m.useState([]),[_e,Ce]=m.useState(""),ve=rB(),we=m.useMemo(()=>{const F=Object.keys(Dn).filter(ie=>Dn[ie].is_oversea).map(ie=>({...Dn[ie],key:ie}));return[...Object.keys(Dn).filter(ie=>!Dn[ie].is_oversea).map(ie=>({...Dn[ie],key:ie})),null,...F]},[]);m.useEffect(()=>{Pe()},[]),m.useEffect(()=>{const F=new Set(b),le={};Object.entries(j).forEach(([Se,$e])=>{F.has(Se)&&(le[Se]=$e)}),Object.keys(le).length!==Object.keys(j).length&&C(le)},[b]);const Pe=async()=>{const F=await Q.getVendors();return r(F),F.length>0&&!i&&a(F[0]),F},Mn=()=>{y(null),l(!0)},Pt=()=>{f(!0)},xt=F=>{y(F),l(!0)},$t=async F=>{if(await e({message:"确定要删除此供应商吗?",title:"确认删除",type:"danger",confirmText:"删除",cancelText:"取消"}))try{await Q.deleteVendor(F),Pe(),i&&i.id===F&&a(null),re.success("供应商已删除")}catch(ie){const Se=ie instanceof Error?ie.message:"删除失败";re.error(Se)}},bt=async F=>{F.preventDefault();const le=new FormData(F.currentTarget),ie={name:le.get("name"),description:le.get("description"),sortOrder:parseInt(le.get("sortOrder"))||0,services:[]};g?await Q.updateVendor(g.id,ie):await Q.createVendor(ie),l(!1),Pe()},wt=()=>{v(null),w([]),k(""),C({}),M(!1),_(void 0),V(void 0),O(void 0),U(!1),z(void 0),Y(void 0),A(void 0),ge("openai-chat"),G(Zt.AUTH_TOKEN),c(!0)},It=F=>{v(F),w(F.supportedModels||[]),k(""),C(F.modelLimits||{}),M(F.enableTokenLimit||!1),_(F.tokenLimit),V(F.tokenResetInterval),O(F.tokenResetBaseTime?new Date(F.tokenResetBaseTime):void 0),U(F.enableRequestLimit||!1),z(F.requestCountLimit),Y(F.requestResetInterval),A(F.requestResetBaseTime?new Date(F.requestResetBaseTime):void 0);const le=F.sourceType||"openai-chat";if(ge(le),F.authType)G(F.authType);else{let ie;le==="gemini"?ie=Zt.G_API_KEY:le==="claude-chat"||le==="claude-code"?ie=Zt.API_KEY:ie=Zt.AUTH_TOKEN,G(ie)}c(!0)},Gt=async F=>{if(await e({message:"确定要删除此API服务吗?",title:"确认删除",type:"danger",confirmText:"删除",cancelText:"取消"}))try{await Q.deleteAPIService(F);const ie=await Pe();if(i){const Se=ie.find($e=>$e.id===i.id);Se&&a(Se)}re.success("API服务已删除")}catch(ie){const Se=ie instanceof Error?ie.message:"删除失败";re.error(Se)}},K=async F=>{F.preventDefault();let le=[...b];if(S.trim()){const Ve=S.split(",").map(Me=>Me.trim()).filter(Me=>Me&&!le.includes(Me));le=[...le,...Ve]}const ie=new FormData(F.currentTarget),Se={};Object.entries(j).forEach(([Ve,Me])=>{Ve&&Me&&Me>0&&(Se[Ve]=Me)});const $e={vendorId:i.id,name:ie.get("name"),apiUrl:ie.get("apiUrl"),apiKey:ie.get("apiKey"),sourceType:ie.get("sourceType"),authType:ie.get("authType")||void 0,supportedModels:le.length>0?le:void 0,modelLimits:Object.keys(Se).length>0?Se:void 0,enableProxy:ie.get("enableProxy")==="on",enableTokenLimit:T,tokenLimit:I,tokenResetInterval:N,tokenResetBaseTime:L?L.getTime():void 0,enableRequestLimit:R,requestCountLimit:D,requestResetInterval:P,requestResetBaseTime:Z?Z.getTime():void 0};x?await Q.updateAPIService(x.id,$e):await Q.createAPIService($e),c(!1),w([]),k(""),C({}),M(!1),_(void 0),V(void 0),O(void 0),U(!1),z(void 0),Y(void 0),A(void 0);const Ne=await Pe();if(i){const Ve=Ne.find(Me=>Me.id===i.id);Ve&&a(Ve)}},J=F=>{if(F){ne(F);const le=Dn[F];le&&le.services.length>0&&q(le.services.map((ie,Se)=>Se))}else ne(""),q([]);Ce(""),h(!0)},xe=async F=>{F.preventDefault();const le=new FormData(F.currentTarget),ie=le.get("vendorKey"),Se=le.get("apiKey");if(!ie||!Se){re.warning("请填写完整信息");return}if(se.length===0){re.warning("请至少选择一个源类型");return}const $e=Dn[ie];if(!$e){re.error("未找到对应的供应商配置");return}try{const Ne=await Q.createVendor({name:$e.name,description:$e.description,sortOrder:0,services:[]});if(console.log("[一键配置] 供应商创建成功:",Ne),console.log("[一键配置] 供应商 ID:",Ne==null?void 0:Ne.id),!Ne||!Ne.id)throw console.error("[一键配置] 供应商创建失败或缺少 ID:",Ne),new Error("供应商创建失败,缺少 ID");const Ve=$e.services.filter((_t,Ii)=>se.includes(Ii));if(console.log("[一键配置] 准备创建服务:",Ve.length,"个"),console.log("[一键配置] vendorId:",Ne.id),Ve.length===0)throw new Error("没有选择任何服务");const Me=Ve.map(async(_t,Ii)=>{const ka={vendorId:Ne.id,name:_t.name,apiUrl:_t.apiUrl,apiKey:Se,sourceType:_t.sourceType,authType:_t.authType,supportedModels:_t.models?_t.models.split(",").map(ho=>ho.trim()):void 0,modelLimits:_t.modelLimits||{}};console.log(`[一键配置] 创建服务 ${Ii+1}/${Ve.length}:`,{...ka,apiKey:"***"});const Gn=await Q.createAPIService(ka);return console.log(`[一键配置] 服务 ${Ii+1} 创建成功,ID:`,Gn.id),Gn.vendorId||console.error(`[一键配置] 警告:服务 ${Gn.id} 缺少 vendorId!`),Gn}),Sa=await Promise.all(Me);console.log("[一键配置] 所有服务创建完成,数量:",Sa.length);const ja=Sa.filter(_t=>!_t.vendorId);if(ja.length>0)throw console.error("[一键配置] 发现缺少 vendorId 的服务:",ja),new Error(`有 ${ja.length} 个服务缺少 vendorId`);const Tr=(await Pe()).find(_t=>_t.id===Ne.id);a(Tr||{...Ne,services:Sa}),h(!1),re.success(`配置成功! 已创建 ${se.length} 个API服务`)}catch(Ne){console.error("一键配置失败:",Ne),re.error(`配置失败: ${Ne instanceof Error?Ne.message:"未知错误"}`)}};return u.jsxs("div",{className:"vendors-page",children:[u.jsxs("div",{className:"page-header",children:[u.jsx("h1",{children:"供应商管理"}),u.jsx("p",{children:"管理API供应商和服务配置"})]}),u.jsxs("div",{style:{display:"flex",gap:"20px"},children:[u.jsxs("div",{className:"card",style:{flex:"0 0 25%",minWidth:400},children:[u.jsxs("div",{className:"toolbar",children:[u.jsx("h3",{children:"供应商列表"}),u.jsxs("div",{style:{display:"flex",gap:"10px"},children:[u.jsx("button",{className:"btn btn-secondary",style:{background:"#2563EB",color:"#FFFFFF",border:"none",cursor:"pointer"},onClick:Pt,children:"推荐"}),u.jsx("button",{className:"btn btn-primary",onClick:()=>J(),children:"一键配置"}),u.jsx("button",{className:"btn btn-primary",onClick:Mn,children:"新增"})]})]}),n.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无供应商"})}):u.jsx("div",{style:{marginTop:"10px"},children:n.map(F=>u.jsx("div",{onClick:()=>a(F),style:{padding:"12px",marginBottom:"8px",backgroundColor:i&&i.id===F.id?"var(--accent-light)":"var(--bg-secondary)",borderRadius:"4px",cursor:"pointer",border:"1px solid var(--border-secondary)",color:"var(--text-primary)"},children:u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"8px"},children:[u.jsxs("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:[u.jsx("div",{style:{fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:F.name}),F.description&&u.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginTop:"4px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:F.description})]}),u.jsxs("div",{className:"action-buttons",style:{flexShrink:0},children:[u.jsx("button",{className:"btn btn-secondary",style:{padding:"4px 8px",fontSize:"12px"},onClick:le=>{le.stopPropagation(),xt(F)},children:"编辑"}),u.jsx("button",{className:"btn btn-danger",style:{padding:"4px 8px",fontSize:"12px"},onClick:le=>{le.stopPropagation(),$t(F.id)},children:"删除"})]})]})},F.id))})]}),u.jsxs("div",{className:"card",style:{flex:1},children:[u.jsxs("div",{className:"toolbar",children:[u.jsxs("h3",{children:["供应商",i?`(${i.name})`:null,"API服务"]}),i&&u.jsx("button",{className:"btn btn-primary",onClick:wt,children:"新增服务"})]}),i?!i.services||i.services.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无API服务"})}):u.jsxs("table",{style:{fontSize:"smaller"},children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{style:{whiteSpace:"nowrap"},children:"服务名称"}),u.jsx("th",{children:"源类型"}),u.jsx("th",{children:"API地址"}),u.jsx("th",{children:"模型"}),u.jsx("th",{children:"操作"})]})}),u.jsx("tbody",{children:i.services.map(F=>{var le;return u.jsxs("tr",{children:[u.jsx("td",{children:F.name}),u.jsx("td",{children:F.sourceType?oc[F.sourceType]:"-"}),u.jsx("td",{style:{maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:F.apiUrl,children:F.apiUrl}),u.jsx("td",{children:(le=F.supportedModels)!=null&&le.length?`${F.supportedModels.length}个`:"*"}),u.jsx("td",{children:u.jsxs("div",{className:"action-buttons",children:[u.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>It(F),children:"编辑"}),u.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>Gt(F.id),children:"删除"})]})})]},F.id)})})]}):u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"请先选择一个供应商"})})]})]}),o&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>l(!1),"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:g?"编辑供应商":"新增供应商"})}),u.jsxs("form",{onSubmit:bt,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商名称"}),u.jsx("input",{type:"text",name:"name",defaultValue:g?g.name:"",required:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"描述"}),u.jsx("textarea",{name:"description",rows:3,defaultValue:g?g.description:""})]}),u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["排序 ",u.jsx("small",{children:"数值越大越靠前"})]}),u.jsx("input",{type:"number",name:"sortOrder",defaultValue:g&&g.sortOrder||0,min:"0"})]}),u.jsxs("div",{className:"modal-footer",children:[u.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>l(!1),children:"取消"}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})})]}),s&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>c(!1),"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",style:{width:800},children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:x?"编辑供应商API服务":"新增供应商API服务"})}),u.jsxs("form",{onSubmit:K,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"服务名称"}),u.jsx("input",{type:"text",name:"name",defaultValue:x?x.name:"",required:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["数据源类型 ",u.jsx("small",{children:"供应商接口返回的数据格式标准类型"})]}),u.jsxs("select",{name:"sourceType",defaultValue:x&&x.sourceType||"",onChange:F=>de(F.target.value),required:!0,children:[u.jsx("option",{value:"",disabled:!0,children:"请选择源类型"}),Object.keys(oc).map(F=>u.jsx("option",{value:F,children:oc[F]},F))]}),u.jsx("small",{style:{display:"block",marginTop:"4px",color:"var(--text-muted)"},children:eB[ue]||""})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商API地址"}),u.jsx("input",{type:"url",name:"apiUrl",defaultValue:x?x.apiUrl:"",required:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商API密钥"}),u.jsx("input",{type:"password",name:"apiKey",defaultValue:x?x.apiKey:"",required:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["供应商API认证方式 ",u.jsx("small",{children:"请在供应商的文档中查阅相关信息"})]}),u.jsx("select",{ref:t,name:"authType",defaultValue:x&&x.authType||Zt.AUTH_TOKEN,onChange:F=>G(F.target.value),children:Object.keys(fw).map(F=>u.jsx("option",{value:F,children:fw[F]},F))}),u.jsx("small",{style:{display:"block",marginTop:"4px",color:"var(--text-muted)"},children:tB[H]||""})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"支持的模型列表"}),u.jsx(sB,{value:b,onChange:w,inputValue:S,onInputChange:k,placeholder:"输入模型名,按Enter或逗号添加"},(x==null?void 0:x.id)||"new"),u.jsx("div",{style:{display:"block",width:"100%"},children:u.jsx("small",{style:{fontSize:"10px"},children:"留空表示支持所有模型,路由配置中,可直接将模型透传给该供应商服务接口。"})})]}),u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["模型输出限制 ",u.jsx("small",{children:"为支持的模型配置最大输出tokens"})]}),u.jsxs("div",{style:{border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"16px",background:"var(--bg-secondary)",maxHeight:"300px",overflowY:"auto"},children:[Object.keys(j).length===0&&b.length===0?u.jsx("div",{style:{color:"var(--text-muted)",textAlign:"center",padding:"20px",fontSize:"14px"},children:"暂无模型限制配置,可点击下方按钮添加"}):u.jsxs("div",{children:[b.length>0&&u.jsxs("div",{style:{marginBottom:"12px"},children:[u.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginBottom:"8px",fontWeight:500},children:'来自"支持的模型列表"(自动同步)'}),b.map(F=>u.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"8px",alignItems:"center",padding:"8px",background:"var(--bg-primary)",borderRadius:"4px",border:"1px solid var(--accent-light)"},children:[u.jsxs("div",{style:{flex:2,fontSize:"14px",color:"var(--text-primary)",fontWeight:500,display:"flex",alignItems:"center",gap:"6px"},children:[F,u.jsx("span",{style:{fontSize:"10px",padding:"2px 6px",borderRadius:"3px",background:"var(--accent-light)",color:"var(--accent-primary)"},children:"已同步"})]}),u.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("input",{type:"number",value:j[F]||"",onChange:le=>{const ie=le.target.value;if(ie===""){const Se={...j};delete Se[F],C(Se)}else C({...j,[F]:parseInt(ie)||0})},placeholder:"留空不限",min:"1",style:{width:"100%",padding:"6px 8px",border:"1px solid var(--border-primary)",borderRadius:"4px",fontSize:"14px"}}),u.jsx("span",{style:{fontSize:"12px",color:"var(--text-muted)",whiteSpace:"nowrap"},children:"tokens"})]}),u.jsx("button",{type:"button",className:"btn btn-sm btn-secondary",onClick:()=>{const le={...j};delete le[F],C(le)},style:{padding:"4px 8px",fontSize:"12px"},title:"移除此限制(模型仍在支持列表中)",children:"移除限制"})]},`sync-${F}`))]}),Object.keys(j).length>0&&u.jsx("div",{children:Object.entries(j).filter(([F])=>!b.includes(F)).map(([F,le])=>u.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"8px",alignItems:"center",padding:"8px",background:"var(--bg-primary)",borderRadius:"4px",border:"1px solid var(--border-secondary)"},children:[u.jsx("input",{type:"text",value:F,onChange:ie=>{const Se={...j},$e=ie.target.value;delete Se[F],Se[$e]=le,C(Se)},placeholder:"模型名 (如: gpt-4)",style:{flex:2,padding:"6px 8px",border:"1px solid var(--border-primary)",borderRadius:"4px",fontSize:"14px"}}),u.jsx("input",{type:"number",value:le,onChange:ie=>{C({...j,[F]:parseInt(ie.target.value)||0})},placeholder:"最大tokens",min:"1",style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-primary)",borderRadius:"4px",fontSize:"14px"}}),u.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>{const ie={...j};delete ie[F],C(ie)},style:{padding:"4px 8px",fontSize:"12px"},children:"删除"})]},`custom-${F}`))})]}),u.jsx("button",{type:"button",className:"btn btn-sm btn-secondary",onClick:()=>{const F=`model-${Date.now()}`;C({...j,[F]:4096})},style:{marginTop:"8px",width:"100%"},children:"+ 添加模型限制"})]}),u.jsx("div",{style:{display:"block",width:"100%",marginTop:"8px"},children:u.jsxs("small",{style:{fontSize:"10px"},children:[u.jsx("strong",{children:"自动同步:"}),"上方添加的模型会自动在此创建限制配置(默认4096),删除模型会同步移除限制。",u.jsx("strong",{children:"手动添加:"}),"可点击下方按钮为特定模型(如 gpt-4)或前缀(如 gpt-4-*)添加限制。 留空则透传前端工具发送的值。支持精确匹配和前缀匹配。 对于o1等新模型,将自动映射到max_completion_tokens字段。"]})})]}),u.jsx("div",{className:"form-group",children:u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[u.jsx("input",{type:"checkbox",checked:T,onChange:F=>M(F.target.checked),style:{marginRight:"8px",cursor:"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"启用Token超量限制"})]})}),T&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"Token超量值(单位:k)"}),u.jsx("input",{type:"number",value:I||"",onChange:F=>_(F.target.value?parseInt(F.target.value):void 0),min:"1",placeholder:"例如:1000表示1000k tokens"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"自动重置间隔(小时)"}),u.jsx("input",{type:"number",value:N||"",onChange:F=>V(F.target.value?parseInt(F.target.value):void 0),min:"1",placeholder:"例如:720表示30天,168表示7天"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"下一次重置时间基点"}),u.jsx("input",{type:"datetime-local",value:L?pw(L):"",onChange:F=>{F.target.value?O(new Date(F.target.value)):O(void 0)},className:"datetime-picker-input"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"设置下一次重置的精确时间点"})]})]}),u.jsx("div",{className:"form-group",children:u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[u.jsx("input",{type:"checkbox",checked:R,onChange:F=>U(F.target.checked),style:{marginRight:"8px",cursor:"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"启用请求次数超量限制"})]})}),R&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求次数超量值"}),u.jsx("input",{type:"number",value:D||"",onChange:F=>z(F.target.value?parseInt(F.target.value):void 0),min:"1",placeholder:"例如:100"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"自动重置间隔(小时)"}),u.jsx("input",{type:"number",value:P||"",onChange:F=>Y(F.target.value?parseInt(F.target.value):void 0),min:"1",placeholder:"例如:720表示30天,168表示7天"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"下一次重置时间基点"}),u.jsx("input",{type:"datetime-local",value:Z?pw(Z):"",onChange:F=>{F.target.value?A(new Date(F.target.value)):A(void 0)},className:"datetime-picker-input"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"设置下一次重置的精确时间点"})]})]}),u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[u.jsx("input",{type:"checkbox",name:"enableProxy",defaultChecked:(x==null?void 0:x.enableProxy)||!1,style:{marginRight:"8px",cursor:"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"启用代理"})]}),u.jsx("small",{style:{display:"block",marginTop:"6px",color:"#666",fontSize:"12px",marginLeft:"24px"},children:'勾选后,此 API 服务的请求将通过设置的代理转发。请在"设置"页面配置代理。'})]}),u.jsxs("div",{className:"modal-footer",children:[u.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>c(!1),children:"取消"}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})})]}),d&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>f(!1),"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",style:{maxWidth:"800px"},children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:"供应商推荐"})}),u.jsx("div",{className:"modal-body",children:u.jsx("div",{className:"markdown-content",children:u.jsx(bs,{components:{a:({href:F,children:le,title:ie})=>ie&&Dn[ie]?u.jsx("a",{href:"#",style:{color:"#2563EB",borderBottom:"solid 1px #2563EB",cursor:"pointer"},onClick:Se=>{Se.preventDefault(),f(!1),J(ie)},children:le}):u.jsx("a",{href:F,style:{color:"#2563EB",borderBottom:"solid 1px #2563EB"},target:"_blank",rel:"noopener noreferrer",children:le})},children:ve})})}),u.jsx("div",{className:"modal-footer",children:u.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>f(!1),children:"关闭"})})]})})]}),p&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>h(!1),"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:"一键配置供应商"})}),u.jsxs("form",{onSubmit:xe,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商"}),u.jsxs("select",{name:"vendorKey",value:W,onChange:F=>{const le=F.target.value;if(ne(le),le){const ie=Dn[le];ie&&ie.services.length>0&&q(ie.services.map((Se,$e)=>$e))}else q([])},required:!0,children:[u.jsx("option",{value:"",disabled:!0,children:"请选择供应商"}),we.map(F=>F?u.jsx("option",{value:F.key,children:F.name},F.key):u.jsx("option",{value:"",disabled:!0,children:"--"}))]})]}),(Oe=Dn[W])!=null&&Oe.description?u.jsx("div",{style:{fontSize:".8em",marginBottom:16,marginTop:-16},children:Dn[W].description}):null,u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["源类型 ",u.jsx("small",{style:{color:"var(--text-muted)",fontWeight:"normal"},children:"可选择多个"})]}),u.jsx("div",{style:{border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"16px",background:"var(--bg-secondary)",minHeight:"100px",display:"flex",flexDirection:"column",gap:"8px"},children:W?(be=Dn[W])==null?void 0:be.services.map((F,le)=>{const ie=se.includes(le);return u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer",padding:"10px 14px",borderRadius:"6px",background:ie?"var(--accent-light)":"transparent",border:`2px solid ${ie?"var(--accent-primary)":"transparent"}`,transition:"all 0.2s ease",position:"relative",overflow:"hidden"},onMouseEnter:Se=>{ie||(Se.currentTarget.style.background="var(--bg-hover)",Se.currentTarget.style.borderColor="var(--border-secondary)")},onMouseLeave:Se=>{ie||(Se.currentTarget.style.background="transparent",Se.currentTarget.style.borderColor="transparent")},children:[u.jsx("input",{type:"checkbox",checked:ie,onChange:Se=>{Se.target.checked?q([...se,le]):q(se.filter($e=>$e!==le))},style:{width:"18px",height:"18px",marginRight:"12px",cursor:"pointer",accentColor:"var(--accent-primary)"}}),u.jsxs("span",{style:{fontSize:"14px",fontWeight:ie?"600":"400",color:"var(--text-primary)",transition:"all 0.2s ease"},children:[F.name," - ",oc[F.sourceType]]}),ie&&u.jsx("span",{style:{marginLeft:"auto",fontSize:"16px",color:"var(--text-primary)"},children:"✓"})]},le)}):u.jsx("div",{style:{color:"var(--text-muted)",textAlign:"center",padding:"30px 20px",fontSize:"14px"},children:"请先选择供应商"})})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"API Key"}),u.jsx("input",{type:"password",name:"apiKey",value:_e,onChange:F=>Ce(F.target.value),placeholder:"请输入API密钥",required:!0})]}),u.jsxs("div",{className:"modal-footer",children:[u.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>h(!1),children:"取消"}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"确认配置"})]})]})]})})]})]})}function cB(){const e=m.useRef(new Map),t=m.useRef(!1),n=m.useCallback((a,o)=>{var c;const l=o.getBoundingClientRect(),s=(c=o.parentElement)==null?void 0:c.getBoundingClientRect();s&&e.current.set(a,{top:l.top-s.top,left:l.left-s.left,height:l.height,width:l.width})},[]),r=m.useCallback((a,o,l=250)=>{var g;if(t.current)return;const s=e.current.get(a);if(!s)return;const c=o.getBoundingClientRect(),d=(g=o.parentElement)==null?void 0:g.getBoundingClientRect();if(!d)return;const f={top:c.top-d.top,left:c.left-d.left,height:c.height,width:c.width},p=s.top-f.top,h=s.left-f.left;if(Math.abs(p)<1&&Math.abs(h)<1){e.current.delete(a);return}o.style.transform=`translate(${h}px, ${p}px)`,o.style.transition="none",o.style.willChange="transform",t.current=!0,requestAnimationFrame(()=>{o.style.transition=`transform ${l}ms cubic-bezier(0.4, 0, 0.2, 1)`,o.style.transform="",setTimeout(()=>{e.current.delete(a),t.current=!1,o.style.willChange=""},l)})},[]),i=m.useCallback(()=>{e.current.clear()},[]);return{recordPositions:n,applyAnimation:r,clearPositions:i}}const CE=m.createContext(null);let wr=null,ui=null,$c=null,Mo="disconnected",Wi={},Bc=new Set,Fc=new Set;const es=()=>{Fc.forEach(e=>e(Mo))},OE=()=>{Bc.forEach(e=>e(Wi))},dB=()=>{const e=Date.now();let t=!1;Object.keys(Wi).forEach(n=>{e-Wi[n].lastUpdate>6e4&&Wi[n].status==="in_use"&&(Wi[n]={...Wi[n],status:"idle"},t=!0)}),t&&OE()};let ws=null;const EE=()=>{if((wr==null?void 0:wr.readyState)===WebSocket.OPEN)return;Mo="connecting",es();const e=window.location.protocol==="https:"?"wss:":"ws:",t=window.location.host,n=`${e}//${t}/api/rules/status`;try{const r=new WebSocket(n);wr=r,r.onopen=()=>{console.log("[RulesStatus] WebSocket 连接已建立"),Mo="connected",es(),ui&&(clearTimeout(ui),ui=null),pB()},r.onmessage=i=>{try{const a=JSON.parse(i.data);if(a.type==="rule_status"){const{ruleId:o,status:l,totalTokensUsed:s,totalRequestsUsed:c,timestamp:d}=a.data;Wi={...Wi,[o]:{status:l,totalTokensUsed:s,totalRequestsUsed:c,lastUpdate:d}},OE()}}catch(a){console.error("[RulesStatus] 解析消息失败:",a)}},r.onclose=i=>{console.log("[RulesStatus] WebSocket 连接关闭:",i.code,i.reason),Mo="disconnected",es(),kd(),i.code!==1e3&&hw()},r.onerror=i=>{console.error("[RulesStatus] WebSocket 错误:",i)}}catch(r){console.error("[RulesStatus] 创建 WebSocket 失败:",r),Mo="disconnected",es(),hw()}},fB=()=>{ui&&(clearTimeout(ui),ui=null),kd(),wr&&(wr.close(1e3,"主动关闭"),wr=null),Mo="disconnected",es()},hw=()=>{ui||(console.log("[RulesStatus] 5秒后尝试重连..."),ui=setTimeout(()=>{ui=null,EE()},5e3))},pB=()=>{kd(),$c=setInterval(()=>{(wr==null?void 0:wr.readyState)===WebSocket.OPEN?wr.send(JSON.stringify({type:"ping"})):kd()},3e4)},kd=()=>{$c&&(clearInterval($c),$c=null)},hB=()=>{ws||(ws=setInterval(dB,1e4)),EE()},mB=()=>{ws&&(clearInterval(ws),ws=null),fB()};function gB({children:e}){const[t,n]=m.useState("disconnected"),[r,i]=m.useState({});m.useEffect(()=>{const l=c=>{n(c)},s=c=>{i(c)};return Fc.add(l),Bc.add(s),hB(),()=>{Fc.delete(l),Bc.delete(s),Fc.size===0&&Bc.size===0&&mB()}},[]);const o={connectionStatus:t,ruleStatuses:r,getRuleStatus:l=>r[l],isConnected:t==="connected"};return u.jsx(CE.Provider,{value:o,children:e})}function vB(){const e=m.useContext(CE);return e||{connectionStatus:"disconnected",ruleStatuses:{},getRuleStatus:t=>{},isConnected:!1}}const mw=[{value:"default",label:"默认"},{value:"background",label:"后台",icon:"⚙"},{value:"thinking",label:"思考",icon:"💭"},{value:"long-context",label:"长上下文",icon:"📄"},{value:"image-understanding",label:"图像理解",icon:"🖼"},{value:"model-mapping",label:"模型顶替",icon:"🔄"}],gw={default:0,background:1,thinking:2,"long-context":3,"image-understanding":4,"model-mapping":5},vw={background:"🧱",thinking:"💭","long-context":"📄","image-understanding":"🖼️","model-mapping":"🔄"},Yh=[{value:"claude-code",label:"Claude Code"},{value:"codex",label:"Codex"}];function yw(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0");return`${t}-${n}-${r}T${i}:${a}`}const Gh=e=>e==="claude-code"?{write:Q.writeClaudeConfig,restore:Q.restoreClaudeConfig,checkBackup:Q.checkClaudeBackup,toolName:"Claude Code"}:{write:Q.writeCodexConfig,restore:Q.restoreCodexConfig,checkBackup:Q.checkCodexBackup,toolName:"Codex"};function xw(){var eb,tb,nb;const{confirm:e}=Wy(),{ruleStatuses:t}=vB(),[n,r]=m.useState([]),[i,a]=m.useState([]),[o,l]=m.useState([]),[s,c]=m.useState([]),[d,f]=m.useState([]),[p,h]=m.useState([]),[g,y]=m.useState(null),[x,v]=m.useState(!1),[b,w]=m.useState(!1),[S,k]=m.useState(null),[j,C]=m.useState(null),[T,M]=m.useState(""),[I,_]=m.useState(""),[N,V]=m.useState(""),[L,O]=m.useState(""),[R,U]=m.useState(0),[D,z]=m.useState((j==null?void 0:j.contentType)||""),[P,Y]=m.useState(void 0),[Z,A]=m.useState(void 0),[ue,ge]=m.useState(void 0),[H,G]=m.useState(void 0),[de,W]=m.useState(void 0),[ne,se]=m.useState(void 0),[q,_e]=m.useState(void 0),[Ce,ve]=m.useState(void 0),[we,Pe]=m.useState(void 0),[Mn,Pt]=m.useState(null),[xt,$t]=m.useState(!1),[bt,wt]=m.useState(!1),[It,Gt]=m.useState(void 0),[K,J]=m.useState(void 0),[xe,Oe]=m.useState({}),[be,F]=m.useState(!1),[le,ie]=m.useState(""),[Se,$e]=m.useState(!1),[Ne,Ve]=m.useState(!1),[Me,Sa]=m.useState(null),[ja,Ol]=m.useState({"claude-code":!1,codex:!1}),[Tr,_t]=m.useState(null),{recordPositions:Ii,applyAnimation:ka}=cB(),Gn=m.useRef(new Map),ho=m.useRef(null);m.useEffect(()=>{_i(),Ct(),y2(),x2(),zu(),lh()},[]),m.useEffect(()=>{const E=X=>{Tr&&(X.preventDefault(),X.returnValue="正在配置路由,刷新页面可能导致配置不完整。")};return window.addEventListener("beforeunload",E),()=>window.removeEventListener("beforeunload",E)},[Tr]),m.useEffect(()=>{g&&Ae(g.id)},[g]),m.useEffect(()=>{f(T?s.filter(E=>E.vendorId===T):[]),_(""),V("")},[T]);const _i=async()=>{const X=(await Q.getRoutes()).sort((me,ye)=>me.isActive&&!ye.isActive?-1:!me.isActive&&ye.isActive?1:0);r(X),X.length>0&&!g&&y(X[0])},lh=async()=>{try{const E=await Q.checkClaudeVersion();Sa(E)}catch(E){console.error("Failed to check Claude version:",E)}},sh=(E,X)=>{if(!E)return-1;const me=E.split(".").map(Number),ye=X.split(".").map(Number);for(let Le=0;Le<3;Le++){const St=me[Le]||0,Ir=ye[Le]||0;if(St>Ir)return 1;if(St<Ir)return-1}return 0},B=()=>{var E;return(E=Me==null?void 0:Me.claudeCode)!=null&&E.version?sh(Me.claudeCode.version,"2.1.32")>=0:!1},Ae=async E=>{const X=await Q.getRules(E);if(a(X),E)try{const ye=(await Q.getRulesBlacklistStatus(E)).reduce((Le,St)=>(Le[St.ruleId]=St,Le),{});Oe(ye)}catch(me){console.error("Failed to load blacklist status:",me)}},Ct=async()=>{const E=await Q.getVendors();l(E)},y2=async()=>{const E=await Q.getAPIServices();c(E)},x2=async()=>{const E=await Q.getMCPs();h(E)},zu=async()=>{try{const[E,X]=await Promise.all([Q.checkClaudeBackup(),Q.checkCodexBackup()]);Ol({"claude-code":E.exists,codex:X.exists})}catch(E){console.error("检查备份状态失败:",E),Ol({"claude-code":!1,codex:!1})}},b2=async E=>{const X=n.find(Le=>Le.id===E);if(!X)return;await zu();const me=!ja[X.targetType];_t(E);let ye=!1;try{if(me)try{const Le=Gh(X.targetType);X.targetType==="claude-code"?await Q.writeClaudeConfig(X.enableAgentTeams):await Le.write(),ye=!0}catch(Le){throw new Error(`配置文件覆盖失败: ${Le.message||"未知错误"}`)}try{const Le=Gn.current.get(E);Le&&Ii(E,Le),ho.current=E,await Q.activateRoute(E),await _i(),await zu(),Le&&setTimeout(()=>{const St=Gn.current.get(E);St&&ka(E,St,250),ho.current=null},0)}catch(Le){if(ye)try{throw await Gh(X.targetType).restore(),new Error(`路由激活失败,配置文件已回滚: ${Le.message||"未知错误"}`)}catch(St){throw new Error(`路由激活失败且配置回滚失败!请手动检查配置文件。
116
+ `}),u.jsx("div",{style:{position:"fixed",top:"20px",right:"20px",zIndex:9999},children:e.map(i=>u.jsxs("div",{style:n(i.type),children:[u.jsx("span",{style:{fontSize:"18px",fontWeight:"bold"},children:r(i.type)}),u.jsx("span",{style:{flex:1},children:i.message}),u.jsx("button",{onClick:()=>PE(i.id),style:{background:"none",border:"none",color:"inherit",cursor:"pointer",fontSize:"18px",padding:"0",marginLeft:"10px",opacity:.6},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity="0.6",children:"×"})]},i.id))})]})}function pw(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0");return`${t}-${n}-${r}T${i}:${a}`}function sB({value:e=[],onChange:t,placeholder:n,inputValue:r,onInputChange:i}){const a=l=>{if(l.key==="Enter"||l.key===","){l.preventDefault();const s=r.trim();s&&!e.includes(s)&&(t([...e,s]),i(""))}else l.key==="Backspace"&&!r&&e.length>0&&t(e.slice(0,-1))},o=l=>{t(e.filter((s,c)=>c!==l))};return u.jsx("div",{style:{border:"1px solid var(--border-primary)",borderRadius:"4px",padding:"8px",minHeight:"40px",background:"var(--bg-secondary)"},children:u.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",alignItems:"center"},children:[e.map((l,s)=>u.jsxs("span",{style:{backgroundColor:"var(--accent-light)",color:"var(--text-primary)",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",display:"flex",alignItems:"center",gap:"4px"},children:[l,u.jsx("button",{type:"button",onClick:()=>o(s),style:{background:"none",border:"none",color:"var(--text-primary)",cursor:"pointer",fontSize:"16px",lineHeight:"1",padding:"0",marginLeft:"4px"},onMouseOver:c=>c.currentTarget.style.color="var(--accent-danger)",onMouseOut:c=>c.currentTarget.style.color="var(--text-primary)",children:"×"})]},s)),u.jsx("input",{type:"text",value:r,onChange:l=>i(l.target.value),onKeyDown:a,placeholder:n,style:{border:"none",outline:"none",flex:"1",minWidth:"120px",fontSize:"14px"}})]})})}function uB(){var Oe,be;const{confirm:e}=Wy(),t=m.useRef(null),[n,r]=m.useState([]),[i,a]=m.useState(null),[o,l]=m.useState(!1),[s,c]=m.useState(!1),[d,f]=m.useState(!1),[p,h]=m.useState(!1),[g,y]=m.useState(null),[x,v]=m.useState(null),[b,w]=m.useState([]),[S,k]=m.useState(""),[j,C]=m.useState({}),[T,M]=m.useState(!1),[I,_]=m.useState(void 0),[N,V]=m.useState(void 0),[L,O]=m.useState(void 0),[R,U]=m.useState(!1),[D,z]=m.useState(void 0),[P,Y]=m.useState(void 0),[Z,A]=m.useState(void 0),[ue,ge]=m.useState("openai-chat"),[H,G]=m.useState(Zt.AUTH_TOKEN),de=F=>{ge(F);let ae;F==="gemini"||F==="gemini-chat"?ae=Zt.G_API_KEY:F==="claude-chat"||F==="claude-code"?ae=Zt.API_KEY:ae=Zt.AUTH_TOKEN,G(ae),t.current&&(t.current.value=ae)},[W,ne]=m.useState(""),[se,q]=m.useState([]),[_e,Ce]=m.useState(""),ve=rB(),we=m.useMemo(()=>{const F=Object.keys(Dn).filter(ie=>Dn[ie].is_oversea).map(ie=>({...Dn[ie],key:ie}));return[...Object.keys(Dn).filter(ie=>!Dn[ie].is_oversea).map(ie=>({...Dn[ie],key:ie})),null,...F]},[]);m.useEffect(()=>{Pe()},[]),m.useEffect(()=>{const F=new Set(b),ae={};Object.entries(j).forEach(([Se,$e])=>{F.has(Se)&&(ae[Se]=$e)}),Object.keys(ae).length!==Object.keys(j).length&&C(ae)},[b]);const Pe=async()=>{const F=await Q.getVendors();return r(F),F.length>0&&!i&&a(F[0]),F},Mn=()=>{y(null),l(!0)},Pt=()=>{f(!0)},xt=F=>{y(F),l(!0)},$t=async F=>{if(await e({message:"确定要删除此供应商吗?",title:"确认删除",type:"danger",confirmText:"删除",cancelText:"取消"}))try{await Q.deleteVendor(F),Pe(),i&&i.id===F&&a(null),re.success("供应商已删除")}catch(ie){const Se=ie instanceof Error?ie.message:"删除失败";re.error(Se)}},bt=async F=>{F.preventDefault();const ae=new FormData(F.currentTarget),ie={name:ae.get("name"),description:ae.get("description"),sortOrder:parseInt(ae.get("sortOrder"))||0,services:[]};g?await Q.updateVendor(g.id,ie):await Q.createVendor(ie),l(!1),Pe()},wt=()=>{v(null),w([]),k(""),C({}),M(!1),_(void 0),V(void 0),O(void 0),U(!1),z(void 0),Y(void 0),A(void 0),ge("openai-chat"),G(Zt.AUTH_TOKEN),c(!0)},It=F=>{v(F),w(F.supportedModels||[]),k(""),C(F.modelLimits||{}),M(F.enableTokenLimit||!1),_(F.tokenLimit),V(F.tokenResetInterval),O(F.tokenResetBaseTime?new Date(F.tokenResetBaseTime):void 0),U(F.enableRequestLimit||!1),z(F.requestCountLimit),Y(F.requestResetInterval),A(F.requestResetBaseTime?new Date(F.requestResetBaseTime):void 0);const ae=F.sourceType||"openai-chat";if(ge(ae),F.authType)G(F.authType);else{let ie;ae==="gemini"||ae==="gemini-chat"?ie=Zt.G_API_KEY:ae==="claude-chat"||ae==="claude-code"?ie=Zt.API_KEY:ie=Zt.AUTH_TOKEN,G(ie)}c(!0)},Gt=async F=>{if(await e({message:"确定要删除此API服务吗?",title:"确认删除",type:"danger",confirmText:"删除",cancelText:"取消"}))try{await Q.deleteAPIService(F);const ie=await Pe();if(i){const Se=ie.find($e=>$e.id===i.id);Se&&a(Se)}re.success("API服务已删除")}catch(ie){const Se=ie instanceof Error?ie.message:"删除失败";re.error(Se)}},K=async F=>{F.preventDefault();let ae=[...b];if(S.trim()){const Ve=S.split(",").map(Me=>Me.trim()).filter(Me=>Me&&!ae.includes(Me));ae=[...ae,...Ve]}const ie=new FormData(F.currentTarget),Se={};Object.entries(j).forEach(([Ve,Me])=>{Ve&&Me&&Me>0&&(Se[Ve]=Me)});const $e={vendorId:i.id,name:ie.get("name"),apiUrl:ie.get("apiUrl"),apiKey:ie.get("apiKey"),sourceType:ie.get("sourceType"),authType:ie.get("authType")||void 0,supportedModels:ae.length>0?ae:void 0,modelLimits:Object.keys(Se).length>0?Se:void 0,enableProxy:ie.get("enableProxy")==="on",enableTokenLimit:T,tokenLimit:I,tokenResetInterval:N,tokenResetBaseTime:L?L.getTime():void 0,enableRequestLimit:R,requestCountLimit:D,requestResetInterval:P,requestResetBaseTime:Z?Z.getTime():void 0};x?await Q.updateAPIService(x.id,$e):await Q.createAPIService($e),c(!1),w([]),k(""),C({}),M(!1),_(void 0),V(void 0),O(void 0),U(!1),z(void 0),Y(void 0),A(void 0);const Ne=await Pe();if(i){const Ve=Ne.find(Me=>Me.id===i.id);Ve&&a(Ve)}},J=F=>{if(F){ne(F);const ae=Dn[F];ae&&ae.services.length>0&&q(ae.services.map((ie,Se)=>Se))}else ne(""),q([]);Ce(""),h(!0)},xe=async F=>{F.preventDefault();const ae=new FormData(F.currentTarget),ie=ae.get("vendorKey"),Se=ae.get("apiKey");if(!ie||!Se){re.warning("请填写完整信息");return}if(se.length===0){re.warning("请至少选择一个源类型");return}const $e=Dn[ie];if(!$e){re.error("未找到对应的供应商配置");return}try{const Ne=await Q.createVendor({name:$e.name,description:$e.description,sortOrder:0,services:[]});if(console.log("[一键配置] 供应商创建成功:",Ne),console.log("[一键配置] 供应商 ID:",Ne==null?void 0:Ne.id),!Ne||!Ne.id)throw console.error("[一键配置] 供应商创建失败或缺少 ID:",Ne),new Error("供应商创建失败,缺少 ID");const Ve=$e.services.filter((_t,Ii)=>se.includes(Ii));if(console.log("[一键配置] 准备创建服务:",Ve.length,"个"),console.log("[一键配置] vendorId:",Ne.id),Ve.length===0)throw new Error("没有选择任何服务");const Me=Ve.map(async(_t,Ii)=>{const ka={vendorId:Ne.id,name:_t.name,apiUrl:_t.apiUrl,apiKey:Se,sourceType:_t.sourceType,authType:_t.authType,supportedModels:_t.models?_t.models.split(",").map(ho=>ho.trim()):void 0,modelLimits:_t.modelLimits||{}};console.log(`[一键配置] 创建服务 ${Ii+1}/${Ve.length}:`,{...ka,apiKey:"***"});const Gn=await Q.createAPIService(ka);return console.log(`[一键配置] 服务 ${Ii+1} 创建成功,ID:`,Gn.id),Gn.vendorId||console.error(`[一键配置] 警告:服务 ${Gn.id} 缺少 vendorId!`),Gn}),Sa=await Promise.all(Me);console.log("[一键配置] 所有服务创建完成,数量:",Sa.length);const ja=Sa.filter(_t=>!_t.vendorId);if(ja.length>0)throw console.error("[一键配置] 发现缺少 vendorId 的服务:",ja),new Error(`有 ${ja.length} 个服务缺少 vendorId`);const Tr=(await Pe()).find(_t=>_t.id===Ne.id);a(Tr||{...Ne,services:Sa}),h(!1),re.success(`配置成功! 已创建 ${se.length} 个API服务`)}catch(Ne){console.error("一键配置失败:",Ne),re.error(`配置失败: ${Ne instanceof Error?Ne.message:"未知错误"}`)}};return u.jsxs("div",{className:"vendors-page",children:[u.jsxs("div",{className:"page-header",children:[u.jsx("h1",{children:"供应商管理"}),u.jsx("p",{children:"管理API供应商和服务配置"})]}),u.jsxs("div",{style:{display:"flex",gap:"20px"},children:[u.jsxs("div",{className:"card",style:{flex:"0 0 25%",minWidth:400},children:[u.jsxs("div",{className:"toolbar",children:[u.jsx("h3",{children:"供应商列表"}),u.jsxs("div",{style:{display:"flex",gap:"10px"},children:[u.jsx("button",{className:"btn btn-secondary",style:{background:"#2563EB",color:"#FFFFFF",border:"none",cursor:"pointer"},onClick:Pt,children:"推荐"}),u.jsx("button",{className:"btn btn-primary",onClick:()=>J(),children:"一键配置"}),u.jsx("button",{className:"btn btn-primary",onClick:Mn,children:"新增"})]})]}),n.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无供应商"})}):u.jsx("div",{style:{marginTop:"10px"},children:n.map(F=>u.jsx("div",{onClick:()=>a(F),style:{padding:"12px",marginBottom:"8px",backgroundColor:i&&i.id===F.id?"var(--accent-light)":"var(--bg-secondary)",borderRadius:"4px",cursor:"pointer",border:"1px solid var(--border-secondary)",color:"var(--text-primary)"},children:u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"8px"},children:[u.jsxs("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:[u.jsx("div",{style:{fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:F.name}),F.description&&u.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginTop:"4px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:F.description})]}),u.jsxs("div",{className:"action-buttons",style:{flexShrink:0},children:[u.jsx("button",{className:"btn btn-secondary",style:{padding:"4px 8px",fontSize:"12px"},onClick:ae=>{ae.stopPropagation(),xt(F)},children:"编辑"}),u.jsx("button",{className:"btn btn-danger",style:{padding:"4px 8px",fontSize:"12px"},onClick:ae=>{ae.stopPropagation(),$t(F.id)},children:"删除"})]})]})},F.id))})]}),u.jsxs("div",{className:"card",style:{flex:1},children:[u.jsxs("div",{className:"toolbar",children:[u.jsxs("h3",{children:["供应商",i?`(${i.name})`:null,"API服务"]}),i&&u.jsx("button",{className:"btn btn-primary",onClick:wt,children:"新增服务"})]}),i?!i.services||i.services.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无API服务"})}):u.jsxs("table",{style:{fontSize:"smaller"},children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{style:{whiteSpace:"nowrap"},children:"服务名称"}),u.jsx("th",{children:"源类型"}),u.jsx("th",{children:"API地址"}),u.jsx("th",{children:"模型"}),u.jsx("th",{children:"操作"})]})}),u.jsx("tbody",{children:i.services.map(F=>{var ae;return u.jsxs("tr",{children:[u.jsx("td",{children:F.name}),u.jsx("td",{children:F.sourceType?oc[F.sourceType]:"-"}),u.jsx("td",{style:{maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:F.apiUrl,children:F.apiUrl}),u.jsx("td",{children:(ae=F.supportedModels)!=null&&ae.length?`${F.supportedModels.length}个`:"*"}),u.jsx("td",{children:u.jsxs("div",{className:"action-buttons",children:[u.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>It(F),children:"编辑"}),u.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>Gt(F.id),children:"删除"})]})})]},F.id)})})]}):u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"请先选择一个供应商"})})]})]}),o&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>l(!1),"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:g?"编辑供应商":"新增供应商"})}),u.jsxs("form",{onSubmit:bt,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商名称"}),u.jsx("input",{type:"text",name:"name",defaultValue:g?g.name:"",required:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"描述"}),u.jsx("textarea",{name:"description",rows:3,defaultValue:g?g.description:""})]}),u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["排序 ",u.jsx("small",{children:"数值越大越靠前"})]}),u.jsx("input",{type:"number",name:"sortOrder",defaultValue:g&&g.sortOrder||0,min:"0"})]}),u.jsxs("div",{className:"modal-footer",children:[u.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>l(!1),children:"取消"}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})})]}),s&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>c(!1),"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",style:{width:800},children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:x?"编辑供应商API服务":"新增供应商API服务"})}),u.jsxs("form",{onSubmit:K,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"服务名称"}),u.jsx("input",{type:"text",name:"name",defaultValue:x?x.name:"",required:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["数据源类型 ",u.jsx("small",{children:"供应商接口返回的数据格式标准类型"})]}),u.jsxs("select",{name:"sourceType",defaultValue:x&&x.sourceType||"",onChange:F=>de(F.target.value),required:!0,children:[u.jsx("option",{value:"",disabled:!0,children:"请选择源类型"}),Object.keys(oc).map(F=>u.jsx("option",{value:F,children:oc[F]},F))]}),u.jsx("small",{style:{display:"block",marginTop:"4px",color:"var(--text-muted)"},children:eB[ue]||""})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商API地址"}),u.jsx("input",{type:"url",name:"apiUrl",defaultValue:x?x.apiUrl:"",required:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商API密钥"}),u.jsx("input",{type:"password",name:"apiKey",defaultValue:x?x.apiKey:"",required:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["供应商API认证方式 ",u.jsx("small",{children:"请在供应商的文档中查阅相关信息"})]}),u.jsx("select",{ref:t,name:"authType",defaultValue:x&&x.authType||Zt.AUTH_TOKEN,onChange:F=>G(F.target.value),children:Object.keys(fw).map(F=>u.jsx("option",{value:F,children:fw[F]},F))}),u.jsx("small",{style:{display:"block",marginTop:"4px",color:"var(--text-muted)"},children:tB[H]||""})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"支持的模型列表"}),u.jsx(sB,{value:b,onChange:w,inputValue:S,onInputChange:k,placeholder:"输入模型名,按Enter或逗号添加"},(x==null?void 0:x.id)||"new"),u.jsx("div",{style:{display:"block",width:"100%"},children:u.jsx("small",{style:{fontSize:"10px"},children:"留空表示支持所有模型,路由配置中,可直接将模型透传给该供应商服务接口。"})})]}),u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["模型输出限制 ",u.jsx("small",{children:"为支持的模型配置最大输出tokens"})]}),u.jsxs("div",{style:{border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"16px",background:"var(--bg-secondary)",maxHeight:"300px",overflowY:"auto"},children:[Object.keys(j).length===0&&b.length===0?u.jsx("div",{style:{color:"var(--text-muted)",textAlign:"center",padding:"20px",fontSize:"14px"},children:"暂无模型限制配置,可点击下方按钮添加"}):u.jsxs("div",{children:[b.length>0&&u.jsxs("div",{style:{marginBottom:"12px"},children:[u.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginBottom:"8px",fontWeight:500},children:'来自"支持的模型列表"(自动同步)'}),b.map(F=>u.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"8px",alignItems:"center",padding:"8px",background:"var(--bg-primary)",borderRadius:"4px",border:"1px solid var(--accent-light)"},children:[u.jsxs("div",{style:{flex:2,fontSize:"14px",color:"var(--text-primary)",fontWeight:500,display:"flex",alignItems:"center",gap:"6px"},children:[F,u.jsx("span",{style:{fontSize:"10px",padding:"2px 6px",borderRadius:"3px",background:"var(--accent-light)",color:"var(--accent-primary)"},children:"已同步"})]}),u.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("input",{type:"number",value:j[F]||"",onChange:ae=>{const ie=ae.target.value;if(ie===""){const Se={...j};delete Se[F],C(Se)}else C({...j,[F]:parseInt(ie)||0})},placeholder:"留空不限",min:"1",style:{width:"100%",padding:"6px 8px",border:"1px solid var(--border-primary)",borderRadius:"4px",fontSize:"14px"}}),u.jsx("span",{style:{fontSize:"12px",color:"var(--text-muted)",whiteSpace:"nowrap"},children:"tokens"})]}),u.jsx("button",{type:"button",className:"btn btn-sm btn-secondary",onClick:()=>{const ae={...j};delete ae[F],C(ae)},style:{padding:"4px 8px",fontSize:"12px"},title:"移除此限制(模型仍在支持列表中)",children:"移除限制"})]},`sync-${F}`))]}),Object.keys(j).length>0&&u.jsx("div",{children:Object.entries(j).filter(([F])=>!b.includes(F)).map(([F,ae])=>u.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"8px",alignItems:"center",padding:"8px",background:"var(--bg-primary)",borderRadius:"4px",border:"1px solid var(--border-secondary)"},children:[u.jsx("input",{type:"text",value:F,onChange:ie=>{const Se={...j},$e=ie.target.value;delete Se[F],Se[$e]=ae,C(Se)},placeholder:"模型名 (如: gpt-4)",style:{flex:2,padding:"6px 8px",border:"1px solid var(--border-primary)",borderRadius:"4px",fontSize:"14px"}}),u.jsx("input",{type:"number",value:ae,onChange:ie=>{C({...j,[F]:parseInt(ie.target.value)||0})},placeholder:"最大tokens",min:"1",style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-primary)",borderRadius:"4px",fontSize:"14px"}}),u.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>{const ie={...j};delete ie[F],C(ie)},style:{padding:"4px 8px",fontSize:"12px"},children:"删除"})]},`custom-${F}`))})]}),u.jsx("button",{type:"button",className:"btn btn-sm btn-secondary",onClick:()=>{const F=`model-${Date.now()}`;C({...j,[F]:4096})},style:{marginTop:"8px",width:"100%"},children:"+ 添加模型限制"})]}),u.jsx("div",{style:{display:"block",width:"100%",marginTop:"8px"},children:u.jsxs("small",{style:{fontSize:"10px"},children:[u.jsx("strong",{children:"自动同步:"}),"上方添加的模型会自动在此创建限制配置(默认4096),删除模型会同步移除限制。",u.jsx("strong",{children:"手动添加:"}),"可点击下方按钮为特定模型(如 gpt-4)或前缀(如 gpt-4-*)添加限制。 留空则透传前端工具发送的值。支持精确匹配和前缀匹配。 对于o1等新模型,将自动映射到max_completion_tokens字段。"]})})]}),u.jsx("div",{className:"form-group",children:u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[u.jsx("input",{type:"checkbox",checked:T,onChange:F=>M(F.target.checked),style:{marginRight:"8px",cursor:"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"启用Token超量限制"})]})}),T&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"Token超量值(单位:k)"}),u.jsx("input",{type:"number",value:I||"",onChange:F=>_(F.target.value?parseInt(F.target.value):void 0),min:"1",placeholder:"例如:1000表示1000k tokens"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"自动重置间隔(小时)"}),u.jsx("input",{type:"number",value:N||"",onChange:F=>V(F.target.value?parseInt(F.target.value):void 0),min:"1",placeholder:"例如:720表示30天,168表示7天"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"下一次重置时间基点"}),u.jsx("input",{type:"datetime-local",value:L?pw(L):"",onChange:F=>{F.target.value?O(new Date(F.target.value)):O(void 0)},className:"datetime-picker-input"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"设置下一次重置的精确时间点"})]})]}),u.jsx("div",{className:"form-group",children:u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[u.jsx("input",{type:"checkbox",checked:R,onChange:F=>U(F.target.checked),style:{marginRight:"8px",cursor:"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"启用请求次数超量限制"})]})}),R&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求次数超量值"}),u.jsx("input",{type:"number",value:D||"",onChange:F=>z(F.target.value?parseInt(F.target.value):void 0),min:"1",placeholder:"例如:100"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"自动重置间隔(小时)"}),u.jsx("input",{type:"number",value:P||"",onChange:F=>Y(F.target.value?parseInt(F.target.value):void 0),min:"1",placeholder:"例如:720表示30天,168表示7天"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"下一次重置时间基点"}),u.jsx("input",{type:"datetime-local",value:Z?pw(Z):"",onChange:F=>{F.target.value?A(new Date(F.target.value)):A(void 0)},className:"datetime-picker-input"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"设置下一次重置的精确时间点"})]})]}),u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[u.jsx("input",{type:"checkbox",name:"enableProxy",defaultChecked:(x==null?void 0:x.enableProxy)||!1,style:{marginRight:"8px",cursor:"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"启用代理"})]}),u.jsx("small",{style:{display:"block",marginTop:"6px",color:"#666",fontSize:"12px",marginLeft:"24px"},children:'勾选后,此 API 服务的请求将通过设置的代理转发。请在"设置"页面配置代理。'})]}),u.jsxs("div",{className:"modal-footer",children:[u.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>c(!1),children:"取消"}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})})]}),d&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>f(!1),"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",style:{maxWidth:"800px"},children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:"供应商推荐"})}),u.jsx("div",{className:"modal-body",children:u.jsx("div",{className:"markdown-content",children:u.jsx(bs,{components:{a:({href:F,children:ae,title:ie})=>ie&&Dn[ie]?u.jsx("a",{href:"#",style:{color:"#2563EB",borderBottom:"solid 1px #2563EB",cursor:"pointer"},onClick:Se=>{Se.preventDefault(),f(!1),J(ie)},children:ae}):u.jsx("a",{href:F,style:{color:"#2563EB",borderBottom:"solid 1px #2563EB"},target:"_blank",rel:"noopener noreferrer",children:ae})},children:ve})})}),u.jsx("div",{className:"modal-footer",children:u.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>f(!1),children:"关闭"})})]})})]}),p&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>h(!1),"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:"一键配置供应商"})}),u.jsxs("form",{onSubmit:xe,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商"}),u.jsxs("select",{name:"vendorKey",value:W,onChange:F=>{const ae=F.target.value;if(ne(ae),ae){const ie=Dn[ae];ie&&ie.services.length>0&&q(ie.services.map((Se,$e)=>$e))}else q([])},required:!0,children:[u.jsx("option",{value:"",disabled:!0,children:"请选择供应商"}),we.map(F=>F?u.jsx("option",{value:F.key,children:F.name},F.key):u.jsx("option",{value:"",disabled:!0,children:"--"}))]})]}),(Oe=Dn[W])!=null&&Oe.description?u.jsx("div",{style:{fontSize:".8em",marginBottom:16,marginTop:-16},children:Dn[W].description}):null,u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["源类型 ",u.jsx("small",{style:{color:"var(--text-muted)",fontWeight:"normal"},children:"可选择多个"})]}),u.jsx("div",{style:{border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"16px",background:"var(--bg-secondary)",minHeight:"100px",display:"flex",flexDirection:"column",gap:"8px"},children:W?(be=Dn[W])==null?void 0:be.services.map((F,ae)=>{const ie=se.includes(ae);return u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer",padding:"10px 14px",borderRadius:"6px",background:ie?"var(--accent-light)":"transparent",border:`2px solid ${ie?"var(--accent-primary)":"transparent"}`,transition:"all 0.2s ease",position:"relative",overflow:"hidden"},onMouseEnter:Se=>{ie||(Se.currentTarget.style.background="var(--bg-hover)",Se.currentTarget.style.borderColor="var(--border-secondary)")},onMouseLeave:Se=>{ie||(Se.currentTarget.style.background="transparent",Se.currentTarget.style.borderColor="transparent")},children:[u.jsx("input",{type:"checkbox",checked:ie,onChange:Se=>{Se.target.checked?q([...se,ae]):q(se.filter($e=>$e!==ae))},style:{width:"18px",height:"18px",marginRight:"12px",cursor:"pointer",accentColor:"var(--accent-primary)"}}),u.jsxs("span",{style:{fontSize:"14px",fontWeight:ie?"600":"400",color:"var(--text-primary)",transition:"all 0.2s ease"},children:[F.name," - ",oc[F.sourceType]]}),ie&&u.jsx("span",{style:{marginLeft:"auto",fontSize:"16px",color:"var(--text-primary)"},children:"✓"})]},ae)}):u.jsx("div",{style:{color:"var(--text-muted)",textAlign:"center",padding:"30px 20px",fontSize:"14px"},children:"请先选择供应商"})})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"API Key"}),u.jsx("input",{type:"password",name:"apiKey",value:_e,onChange:F=>Ce(F.target.value),placeholder:"请输入API密钥",required:!0})]}),u.jsxs("div",{className:"modal-footer",children:[u.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>h(!1),children:"取消"}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"确认配置"})]})]})]})})]})]})}function cB(){const e=m.useRef(new Map),t=m.useRef(!1),n=m.useCallback((a,o)=>{var c;const l=o.getBoundingClientRect(),s=(c=o.parentElement)==null?void 0:c.getBoundingClientRect();s&&e.current.set(a,{top:l.top-s.top,left:l.left-s.left,height:l.height,width:l.width})},[]),r=m.useCallback((a,o,l=250)=>{var g;if(t.current)return;const s=e.current.get(a);if(!s)return;const c=o.getBoundingClientRect(),d=(g=o.parentElement)==null?void 0:g.getBoundingClientRect();if(!d)return;const f={top:c.top-d.top,left:c.left-d.left,height:c.height,width:c.width},p=s.top-f.top,h=s.left-f.left;if(Math.abs(p)<1&&Math.abs(h)<1){e.current.delete(a);return}o.style.transform=`translate(${h}px, ${p}px)`,o.style.transition="none",o.style.willChange="transform",t.current=!0,requestAnimationFrame(()=>{o.style.transition=`transform ${l}ms cubic-bezier(0.4, 0, 0.2, 1)`,o.style.transform="",setTimeout(()=>{e.current.delete(a),t.current=!1,o.style.willChange=""},l)})},[]),i=m.useCallback(()=>{e.current.clear()},[]);return{recordPositions:n,applyAnimation:r,clearPositions:i}}const CE=m.createContext(null);let wr=null,ui=null,$c=null,Mo="disconnected",Wi={},Bc=new Set,Fc=new Set;const es=()=>{Fc.forEach(e=>e(Mo))},OE=()=>{Bc.forEach(e=>e(Wi))},dB=()=>{const e=Date.now();let t=!1;Object.keys(Wi).forEach(n=>{e-Wi[n].lastUpdate>6e4&&Wi[n].status==="in_use"&&(Wi[n]={...Wi[n],status:"idle"},t=!0)}),t&&OE()};let ws=null;const EE=()=>{if((wr==null?void 0:wr.readyState)===WebSocket.OPEN)return;Mo="connecting",es();const e=window.location.protocol==="https:"?"wss:":"ws:",t=window.location.host,n=`${e}//${t}/api/rules/status`;try{const r=new WebSocket(n);wr=r,r.onopen=()=>{console.log("[RulesStatus] WebSocket 连接已建立"),Mo="connected",es(),ui&&(clearTimeout(ui),ui=null),pB()},r.onmessage=i=>{try{const a=JSON.parse(i.data);if(a.type==="rule_status"){const{ruleId:o,status:l,totalTokensUsed:s,totalRequestsUsed:c,timestamp:d}=a.data;Wi={...Wi,[o]:{status:l,totalTokensUsed:s,totalRequestsUsed:c,lastUpdate:d}},OE()}}catch(a){console.error("[RulesStatus] 解析消息失败:",a)}},r.onclose=i=>{console.log("[RulesStatus] WebSocket 连接关闭:",i.code,i.reason),Mo="disconnected",es(),kd(),i.code!==1e3&&hw()},r.onerror=i=>{console.error("[RulesStatus] WebSocket 错误:",i)}}catch(r){console.error("[RulesStatus] 创建 WebSocket 失败:",r),Mo="disconnected",es(),hw()}},fB=()=>{ui&&(clearTimeout(ui),ui=null),kd(),wr&&(wr.close(1e3,"主动关闭"),wr=null),Mo="disconnected",es()},hw=()=>{ui||(console.log("[RulesStatus] 5秒后尝试重连..."),ui=setTimeout(()=>{ui=null,EE()},5e3))},pB=()=>{kd(),$c=setInterval(()=>{(wr==null?void 0:wr.readyState)===WebSocket.OPEN?wr.send(JSON.stringify({type:"ping"})):kd()},3e4)},kd=()=>{$c&&(clearInterval($c),$c=null)},hB=()=>{ws||(ws=setInterval(dB,1e4)),EE()},mB=()=>{ws&&(clearInterval(ws),ws=null),fB()};function gB({children:e}){const[t,n]=m.useState("disconnected"),[r,i]=m.useState({});m.useEffect(()=>{const l=c=>{n(c)},s=c=>{i(c)};return Fc.add(l),Bc.add(s),hB(),()=>{Fc.delete(l),Bc.delete(s),Fc.size===0&&Bc.size===0&&mB()}},[]);const o={connectionStatus:t,ruleStatuses:r,getRuleStatus:l=>r[l],isConnected:t==="connected"};return u.jsx(CE.Provider,{value:o,children:e})}function vB(){const e=m.useContext(CE);return e||{connectionStatus:"disconnected",ruleStatuses:{},getRuleStatus:t=>{},isConnected:!1}}const mw=[{value:"default",label:"默认"},{value:"background",label:"后台",icon:"⚙"},{value:"thinking",label:"思考",icon:"💭"},{value:"high-iq",label:"高智商",icon:"🧠"},{value:"long-context",label:"长上下文",icon:"📄"},{value:"image-understanding",label:"图像理解",icon:"🖼"},{value:"model-mapping",label:"模型顶替",icon:"🔄"}],gw={default:0,background:1,thinking:2,"high-iq":3,"long-context":4,"image-understanding":5,"model-mapping":6},vw={background:"🧱",thinking:"💭","high-iq":"🧠","long-context":"📄","image-understanding":"🖼️","model-mapping":"🔄"},Yh=[{value:"claude-code",label:"Claude Code"},{value:"codex",label:"Codex"}];function yw(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),i=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0");return`${t}-${n}-${r}T${i}:${a}`}const Gh=e=>e==="claude-code"?{write:Q.writeClaudeConfig,restore:Q.restoreClaudeConfig,checkBackup:Q.checkClaudeBackup,toolName:"Claude Code"}:{write:Q.writeCodexConfig,restore:Q.restoreCodexConfig,checkBackup:Q.checkCodexBackup,toolName:"Codex"};function xw(){var eb,tb,nb;const{confirm:e}=Wy(),{ruleStatuses:t}=vB(),[n,r]=m.useState([]),[i,a]=m.useState([]),[o,l]=m.useState([]),[s,c]=m.useState([]),[d,f]=m.useState([]),[p,h]=m.useState([]),[g,y]=m.useState(null),[x,v]=m.useState(!1),[b,w]=m.useState(!1),[S,k]=m.useState(null),[j,C]=m.useState(null),[T,M]=m.useState(""),[I,_]=m.useState(""),[N,V]=m.useState(""),[L,O]=m.useState(""),[R,U]=m.useState(0),[D,z]=m.useState((j==null?void 0:j.contentType)||""),[P,Y]=m.useState(void 0),[Z,A]=m.useState(void 0),[ue,ge]=m.useState(void 0),[H,G]=m.useState(void 0),[de,W]=m.useState(void 0),[ne,se]=m.useState(void 0),[q,_e]=m.useState(void 0),[Ce,ve]=m.useState(void 0),[we,Pe]=m.useState(void 0),[Mn,Pt]=m.useState(null),[xt,$t]=m.useState(!1),[bt,wt]=m.useState(!1),[It,Gt]=m.useState(void 0),[K,J]=m.useState(void 0),[xe,Oe]=m.useState({}),[be,F]=m.useState(!1),[ae,ie]=m.useState(""),[Se,$e]=m.useState(!1),[Ne,Ve]=m.useState(!1),[Me,Sa]=m.useState(null),[ja,Ol]=m.useState({"claude-code":!1,codex:!1}),[Tr,_t]=m.useState(null),{recordPositions:Ii,applyAnimation:ka}=cB(),Gn=m.useRef(new Map),ho=m.useRef(null);m.useEffect(()=>{_i(),Ct(),y2(),x2(),zu(),lh()},[]),m.useEffect(()=>{const E=X=>{Tr&&(X.preventDefault(),X.returnValue="")};return window.addEventListener("beforeunload",E),()=>window.removeEventListener("beforeunload",E)},[Tr]),m.useEffect(()=>{g&&Ae(g.id)},[g]),m.useEffect(()=>{f(T?s.filter(E=>E.vendorId===T):[]),_(""),V("")},[T]);const _i=async()=>{const X=(await Q.getRoutes()).sort((me,ye)=>me.isActive&&!ye.isActive?-1:!me.isActive&&ye.isActive?1:0);r(X),X.length>0&&!g&&y(X[0])},lh=async()=>{try{const E=await Q.checkClaudeVersion();Sa(E)}catch(E){console.error("Failed to check Claude version:",E)}},sh=(E,X)=>{if(!E)return-1;const me=E.split(".").map(Number),ye=X.split(".").map(Number);for(let Le=0;Le<3;Le++){const St=me[Le]||0,Ir=ye[Le]||0;if(St>Ir)return 1;if(St<Ir)return-1}return 0},B=()=>{var E;return(E=Me==null?void 0:Me.claudeCode)!=null&&E.version?sh(Me.claudeCode.version,"2.1.32")>=0:!1},Ae=async E=>{const X=await Q.getRules(E);if(a(X),E)try{const ye=(await Q.getRulesBlacklistStatus(E)).reduce((Le,St)=>(Le[St.ruleId]=St,Le),{});Oe(ye)}catch(me){console.error("Failed to load blacklist status:",me)}},Ct=async()=>{const E=await Q.getVendors();l(E)},y2=async()=>{const E=await Q.getAPIServices();c(E)},x2=async()=>{const E=await Q.getMCPs();h(E)},zu=async()=>{try{const[E,X]=await Promise.all([Q.checkClaudeBackup(),Q.checkCodexBackup()]);Ol({"claude-code":E.exists,codex:X.exists})}catch(E){console.error("检查备份状态失败:",E),Ol({"claude-code":!1,codex:!1})}},b2=async E=>{const X=n.find(Le=>Le.id===E);if(!X)return;await zu();const me=!ja[X.targetType];_t(E);let ye=!1;try{if(me)try{const Le=Gh(X.targetType);X.targetType==="claude-code"?await Q.writeClaudeConfig(X.enableAgentTeams):await Le.write(),ye=!0}catch(Le){throw new Error(`配置文件覆盖失败: ${Le.message||"未知错误"}`)}try{const Le=Gn.current.get(E);Le&&Ii(E,Le),ho.current=E,await Q.activateRoute(E),await _i(),await zu(),Le&&setTimeout(()=>{const St=Gn.current.get(E);St&&ka(E,St,250),ho.current=null},0)}catch(Le){if(ye)try{throw await Gh(X.targetType).restore(),new Error(`路由激活失败,配置文件已回滚: ${Le.message||"未知错误"}`)}catch(St){throw new Error(`路由激活失败且配置回滚失败!请手动检查配置文件。
117
117
  激活错误: ${Le.message}
118
118
  回滚错误: ${St.message}`)}throw new Error(`路由激活失败: ${Le.message||"未知错误"}`)}}catch(Le){console.error("激活路由失败:",Le),re.error(Le.message)}finally{_t(null)}},w2=async E=>{const X=n.find(ye=>ye.id===E);if(!X)return;const me=Gh(X.targetType);_t(E);try{try{await me.restore()}catch(ye){throw new Error(`配置文件恢复失败: ${ye.message||"未知错误"}
119
119
 
120
120
  路由未停用,请检查配置文件权限。`)}try{await Q.deactivateRoute(E),await _i(),await zu()}catch(ye){throw new Error(`配置文件已恢复,但路由停用失败: ${ye.message||"未知错误"}
121
121
 
122
- 请刷新页面后重试。`)}}catch(ye){console.error("停用路由失败:",ye),re.error(ye.message)}finally{_t(null)}},S2=async E=>{E.preventDefault();const X=new FormData(E.currentTarget),me={name:X.get("name"),description:X.get("description"),targetType:X.get("targetType"),isActive:!1};S?await Q.updateRoute(S.id,me):await Q.createRoute(me),v(!1),_i()},j2=async E=>{await e({message:"确定要删除此路由吗?",title:"确认删除",type:"danger",confirmText:"删除",cancelText:"取消"})&&(await Q.deleteRoute(E),_i(),g&&g.id===E&&(y(null),a([])),re.success("路由已删除"))},k2=async E=>{if(E.preventDefault(),D==="image-understanding"&&be&&!le){re.warning("请选择一个MCP工具");return}if(!be&&!I){re.warning("请选择供应商API服务");return}if(!be&&P!==void 0&&It!==void 0&&P>It){re.warning(`Token超量值 (${P}k) 不能超过API服务的限制 (${It}k)`);return}if(!be&&de!==void 0&&K!==void 0&&de>K){re.warning(`请求次数超量值 (${de}) 不能超过API服务的限制 (${K})`);return}const X=new FormData(E.currentTarget),me={routeId:g.id,contentType:X.get("contentType"),targetServiceId:be?"":I,targetModel:be?void 0:N||void 0,replacedModel:L||void 0,sortOrder:R,timeout:H?H*1e3:void 0,tokenLimit:be?void 0:P||void 0,resetInterval:be?void 0:Z,tokenResetBaseTime:be?void 0:ue?ue.getTime():void 0,requestCountLimit:be?void 0:de,requestResetInterval:be?void 0:ne,requestResetBaseTime:be?void 0:q?q.getTime():void 0,frequencyLimit:Ce,frequencyWindow:we,useMCP:D==="image-understanding"?be:!1,mcpId:D==="image-understanding"&&be?le:void 0};j?await Q.updateRule(j.id,me):await Q.createRule(me),w(!1),g&&Ae(g.id)},P2=async E=>{await e({message:"确定要删除此路由吗?",title:"确认删除",type:"danger",confirmText:"删除",cancelText:"取消"})&&(await Q.deleteRule(E),g&&Ae(g.id),re.success("规则已删除"))},C2=async E=>{try{await Q.clearRuleBlacklist(E),g&&Ae(g.id),re.success("已恢复")}catch(X){re.error("恢复失败: "+X.message)}},O2=async E=>{try{const X=await Q.toggleRuleDisable(E);g&&Ae(g.id),re.success(X.isDisabled?"规则已屏蔽":"规则已启用")}catch(X){re.error("操作失败: "+X.message)}},E2=async E=>{try{const X=i.find(ye=>ye.id===E);if(!X)return;const me=(X.sortOrder||0)+1;await Q.updateRule(E,{sortOrder:me}),g&&Ae(g.id),re.success("优先级已提升")}catch(X){re.error("操作失败: "+X.message)}},A2=async E=>{try{const X=i.find(ye=>ye.id===E);if(!X)return;const me=Math.max(0,(X.sortOrder||0)-1);await Q.updateRule(E,{sortOrder:me}),g&&Ae(g.id),re.success("优先级已降低")}catch(X){re.error("操作失败: "+X.message)}},T2=async E=>{if(g){if(E&&!B()){re.error("当前 Claude Code 版本不支持 Agent Teams 功能,需要版本 ≥ 2.1.32");return}try{g.isActive?(await Q.updateClaudeAgentTeams(E),await Q.updateRoute(g.id,{enableAgentTeams:E}),re.success(E?"Agent Teams 功能已开启":"Agent Teams 功能已关闭")):(await Q.updateRoute(g.id,{enableAgentTeams:E}),re.success(E?"Agent Teams 设置已保存(将在激活时生效)":"Agent Teams 设置已取消")),y({...g,enableAgentTeams:E}),await _i()}catch(X){re.error("更新失败: "+X.message)}}},I2=()=>mw,_2=E=>{C(E),z(E.contentType),F(E.useMCP||!1),ie(E.mcpId||"");const X=s.find(me=>me.id===E.targetServiceId);X?(X.vendorId&&(M(X.vendorId),f(s.filter(me=>me.vendorId===X.vendorId))),setTimeout(()=>{if(_(X.id),V(E.targetModel||""),O(E.replacedModel||""),U(E.sortOrder||0),G(E.timeout?E.timeout/1e3:void 0),Y(E.tokenLimit||void 0),A(E.resetInterval),ge(E.tokenResetBaseTime?new Date(E.tokenResetBaseTime):void 0),W(E.requestCountLimit),se(E.requestResetInterval),_e(E.requestResetBaseTime?new Date(E.requestResetBaseTime):void 0),ve(E.frequencyLimit),Pe(E.frequencyWindow),X.enableTokenLimit&&X.tokenLimit){Gt(X.tokenLimit);const me=E.tokenLimit===X.tokenLimit&&E.resetInterval===(X.tokenResetInterval||void 0)&&E.tokenLimit!==null&&E.resetInterval!==null;$t(me)}else Gt(void 0),$t(!1);if(X.enableRequestLimit&&X.requestCountLimit){J(X.requestCountLimit);const me=E.requestCountLimit===X.requestCountLimit&&E.requestResetInterval===(X.requestResetInterval||void 0)&&E.requestCountLimit!==null&&E.requestResetInterval!==null;wt(me)}else J(void 0),wt(!1);$e(!!E.tokenLimit),Ve(!!E.requestCountLimit)},0)):E.useMCP&&(M(""),_(""),V(""),O(""),U(E.sortOrder||0),G(E.timeout?E.timeout/1e3:void 0),$e(!1),Ve(!1)),w(!0)},N2=E=>{var El;const X=xe[E.id],me=[],ye=t[E.id];if((ye==null?void 0:ye.status)==="in_use")return{status:"in_use",label:"使用中",reason:"正在处理请求"};if(X!=null&&X.isBlacklisted){const je=X.blacklistEntry;(je==null?void 0:je.errorType)==="timeout"?me.push("请求超时"):je!=null&&je.lastStatusCode&&me.push(`HTTP ${je.lastStatusCode}错误`)}const Le=(ye==null?void 0:ye.totalTokensUsed)!==void 0?ye.totalTokensUsed:E.totalTokensUsed;E.tokenLimit&&Le!==void 0&&Le>=E.tokenLimit*1e3&&me.push("Token超限");const St=(ye==null?void 0:ye.totalRequestsUsed)!==void 0?ye.totalRequestsUsed:E.totalRequestsUsed;if(E.requestCountLimit&&St!==void 0&&St>=E.requestCountLimit&&me.push("次数超限"),me.length>0)return{status:"error",label:X!=null&&X.isBlacklisted?((El=X.blacklistEntry)==null?void 0:El.errorType)==="timeout"?"超时":"服务错误":me[0],reason:me.join(", ")};const Ir=[];if(E.tokenLimit&&Le!==void 0){const je=Le/(E.tokenLimit*1e3)*100;je>=80&&Ir.push(`Token ${je.toFixed(0)}%`)}if(E.requestCountLimit&&St!==void 0){const je=St/E.requestCountLimit*100;je>=80&&Ir.push(`次数 ${je.toFixed(0)}%`)}return Ir.length>0?{status:"warning",label:"接近限制",reason:Ir.join(", ")}:{status:"success",label:"正常",reason:""}},M2=()=>{C(null),z("default"),M(""),_(""),V(""),O(""),U(0),G(void 0),Y(void 0),A(void 0),ge(void 0),W(void 0),se(void 0),_e(void 0),$t(!1),wt(!1),Gt(void 0),J(void 0),$e(!1),Ve(!1),F(!1),ie(""),w(!0)};return u.jsxs("div",{className:"routes-page",children:[u.jsxs("div",{className:"page-header",children:[u.jsx("h1",{children:"路由管理"}),u.jsx("p",{children:"管理API路由和路由配置"})]}),u.jsx("div",{style:{display:"flex",flexDirection:"column"},children:u.jsxs("div",{style:{display:"flex",gap:"20px"},children:[u.jsxs("div",{className:"card",style:{flex:"0 0 25%",minWidth:300},children:[u.jsxs("div",{className:"toolbar",children:[u.jsx("h3",{children:"路由"}),u.jsx("button",{className:"btn btn-primary",onClick:()=>v(!0),children:"新建"})]}),n.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无路由"})}):u.jsx("div",{style:{marginTop:"10px"},children:n.map(E=>{var X,me;return u.jsx("div",{ref:ye=>{ye?Gn.current.set(E.id,ye):Gn.current.delete(E.id)},onClick:()=>y(E),style:{padding:"12px",marginBottom:"8px",backgroundColor:g&&g.id===E.id?"var(--bg-route-item-selected)":"var(--bg-route-item)",borderRadius:"8px",cursor:"pointer",border:"1px solid var(--border-primary)",position:"relative"},children:u.jsxs("div",{children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[u.jsx("div",{style:{fontWeight:500},children:E.name}),E.isActive&&u.jsxs("span",{className:`badge ${E.targetType==="claude-code"?"badge-claude-code":"badge-codex"}`,style:{position:"absolute",top:-16,right:-8},children:[(X=Yh.find(ye=>ye.value===E.targetType))==null?void 0:X.label," 已激活"]})]}),u.jsxs("div",{style:{fontSize:"12px",color:"var(--text-route-muted)",marginTop:"2px"},children:["客户端工具: ",(me=Yh.find(ye=>ye.value===E.targetType))==null?void 0:me.label]}),u.jsxs("div",{className:"action-buttons",style:{marginTop:"8px"},children:[E.isActive?u.jsx("button",{className:"btn btn-warning",style:{padding:"4px 8px",fontSize:"12px"},onClick:ye=>{ye.stopPropagation(),w2(E.id)},disabled:Tr!==null,children:Tr===E.id?"处理中...":"停用"}):u.jsx("button",{className:"btn btn-success",style:{padding:"4px 8px",fontSize:"12px"},onClick:ye=>{ye.stopPropagation(),b2(E.id)},disabled:Tr!==null,children:Tr===E.id?"处理中...":"激活"}),u.jsx("button",{className:"btn btn-secondary",style:{padding:"4px 8px",fontSize:"12px"},onClick:ye=>{ye.stopPropagation(),k(E),v(!0)},children:"编辑"}),u.jsx("button",{className:"btn btn-danger",style:{padding:"4px 8px",fontSize:"12px"},onClick:ye=>{ye.stopPropagation(),j2(E.id)},disabled:E.isActive,children:"删除"})]})]})},E.id)})})]}),u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:[u.jsxs("div",{className:"card",style:{flex:1},children:[u.jsxs("div",{className:"toolbar",children:[u.jsx("h3",{children:"规则列表"}),g&&u.jsx("button",{className:"btn btn-primary",onClick:M2,children:"新建规则"})]}),g?i.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无路由"})}):u.jsxs("table",{className:"rules-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{className:"col-priority",children:"优先级"}),u.jsx("th",{children:"类型"}),u.jsx("th",{children:"API服务"}),u.jsx("th",{children:"状态"}),u.jsx("th",{children:"用量情况"}),u.jsx("th",{children:"操作"})]})}),u.jsx("tbody",{children:[...i].sort((E,X)=>{const me=E.sortOrder||0,ye=X.sortOrder||0;if(me!==ye)return ye-me;const Le=gw[E.contentType]??999,St=gw[X.contentType]??999;return Le-St}).map(E=>{var Le,St,Ir,El;const X=s.find(je=>je.id===E.targetServiceId),me=o.find(je=>je.id===(X==null?void 0:X.vendorId)),ye=(Le=mw.find(je=>je.value===E.contentType))==null?void 0:Le.label;return u.jsxs("tr",{children:[u.jsx("td",{className:"col-priority",children:u.jsxs("div",{className:"col-priority-box",children:[u.jsx("span",{children:E.sortOrder||0}),u.jsx("button",{className:"priority-arrow-btn",onClick:()=>A2(E.id),title:"降低优先级",children:"↓"}),u.jsx("button",{className:"priority-arrow-btn",onClick:()=>E2(E.id),title:"提升优先级",children:"↑"})]})}),u.jsx("td",{children:u.jsxs("div",{style:{fontSize:"12px",whiteSpace:"nowrap"},children:[E.contentType!=="default"&&vw[E.contentType]&&u.jsx("span",{style:{fontSize:"14px"},children:vw[E.contentType]}),u.jsx("span",{children:ye}),E.contentType==="model-mapping"&&E.replacedModel&&u.jsxs("div",{style:{position:"relative",display:"inline-block"},onMouseEnter:()=>Pt(E.id),onMouseLeave:()=>Pt(null),children:[u.jsx("span",{style:{cursor:"help",fontSize:"14px",color:"var(--text-info)",fontWeight:"bold"},children:"ⓘ"}),Mn===E.id&&u.jsxs("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:"calc(100% + 8px)",backgroundColor:"var(--bg-popover, #333)",color:"var(--text-popover, #fff)",padding:"6px 10px",borderRadius:"4px",fontSize:"12px",whiteSpace:"nowrap",zIndex:1e3,boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:["被顶替的模型是: ",E.replacedModel,u.jsx("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:"-4px",width:"0",height:"0",borderLeft:"4px solid transparent",borderRight:"4px solid transparent",borderTop:"4px solid var(--bg-popover, #333)"}})]})]})]})}),u.jsx("td",{children:u.jsx("div",{className:"vendor-sevices-col",style:{fontSize:"0.6em"},children:E.useMCP?u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:["MCP:",((St=p.find(je=>je.id===E.mcpId))==null?void 0:St.name)||"Unknown"]}),u.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)"},children:"使用MCP工具"})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:["供应商:",me?me.name:"Unknown"]}),u.jsxs("div",{children:["服务:",X?X.name:"Unknown"]}),u.jsxs("div",{children:["模型:",E.targetModel||"透传模型"]})]})})}),u.jsx("td",{style:{whiteSpace:"nowrap"},children:(()=>{var rb,ib;const je=N2(E),pn=xe[E.id],D2=(pn==null?void 0:pn.isBlacklisted)&&!((rb=je.reason)!=null&&rb.includes("Token超限"))&&!((ib=je.reason)!=null&&ib.includes("次数超限"));return E.isDisabled?u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[u.jsx("span",{style:{color:"#6c757d",fontWeight:"bold",fontSize:"14px"},children:"⊘"}),u.jsx("span",{style:{fontSize:"13px",color:"#6c757d",fontWeight:"bold"},children:"已屏蔽"})]}):u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[je.status==="success"&&u.jsx("span",{style:{color:"#28a745",fontWeight:"bold",fontSize:"14px"},children:"✓"}),je.status==="warning"&&u.jsx("span",{style:{color:"#ffc107",fontWeight:"bold",fontSize:"14px"},children:"⚠"}),je.status==="error"&&u.jsx("span",{style:{color:"#dc3545",fontWeight:"bold",fontSize:"14px"},children:"✗"}),je.status==="in_use"&&u.jsx(u.Fragment,{children:u.jsx("span",{style:{color:"#007bff",fontWeight:"bold",fontSize:"14px",animation:"pulse 1.5s ease-in-out infinite"},children:"●"})}),u.jsx("span",{style:{fontSize:"13px",color:je.status==="success"?"#28a745":je.status==="warning"?"#ffc107":je.status==="in_use"?"#007bff":"#dc3545",fontWeight:je.status!=="success"?"bold":"normal"},children:je.label}),je.reason&&u.jsxs("div",{style:{position:"relative",display:"inline-block",cursor:"help"},onMouseEnter:()=>Pt(E.id+"-status"),onMouseLeave:()=>Pt(null),children:[u.jsx("span",{style:{fontSize:"12px",color:"#999",marginLeft:"4px"},children:" ⓘ"}),Mn===E.id+"-status"&&u.jsxs("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:"calc(100% + 8px)",backgroundColor:"var(--bg-popover, #333)",color:"var(--text-popover, #fff)",padding:"6px 10px",borderRadius:"4px",fontSize:"12px",whiteSpace:"nowrap",zIndex:1e3,boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:[je.reason,u.jsx("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:"-4px",width:"0",height:"0",borderLeft:"4px solid transparent",borderRight:"4px solid transparent",borderTop:"4px solid var(--bg-popover, #333)"}})]})]})]}),D2&&u.jsx("button",{className:"btn btn-info",style:{padding:"2px 8px",fontSize:"11px"},onClick:()=>C2(E.id),children:"恢复"})]})})()}),u.jsx("td",{children:E.tokenLimit||E.requestCountLimit?u.jsxs("div",{style:{fontSize:"13px"},children:[E.tokenLimit&&u.jsxs("div",{style:{whiteSpace:"nowrap"},children:[u.jsx("span",{style:{fontWeight:"bold",fontSize:"12px"},children:"Tokens:"}),u.jsxs(u.Fragment,{children:[u.jsxs("span",{style:{color:(()=>{var pn;const je=((pn=t[E.id])==null?void 0:pn.totalTokensUsed)??E.totalTokensUsed;return je&&E.tokenLimit&&je>=E.tokenLimit*1e3?"red":"inherit"})()},children:[(((((Ir=t[E.id])==null?void 0:Ir.totalTokensUsed)??E.totalTokensUsed)||0)/1e3).toFixed(1),"K/",E.tokenLimit.toFixed(0),"K"]}),(()=>{var pn;const je=((pn=t[E.id])==null?void 0:pn.totalTokensUsed)??E.totalTokensUsed;return je&&E.tokenLimit&&je>=E.tokenLimit*1e3?u.jsx("span",{style:{color:"red",marginLeft:"4px",fontWeight:"bold",fontSize:"11px"},children:"超限"}):null})()]})]}),E.requestCountLimit&&u.jsxs("div",{style:{marginTop:E.tokenLimit?"6px":0},children:[u.jsx("span",{style:{fontWeight:"bold",fontSize:"12px"},children:"次数:"}),u.jsxs(u.Fragment,{children:[u.jsxs("span",{style:{color:(()=>{var pn;const je=((pn=t[E.id])==null?void 0:pn.totalRequestsUsed)??E.totalRequestsUsed;return je&&E.requestCountLimit&&je>=E.requestCountLimit?"red":"inherit"})()},children:[(((El=t[E.id])==null?void 0:El.totalRequestsUsed)??E.totalTokensUsed)||0,"/",E.requestCountLimit]}),(()=>{var pn;const je=((pn=t[E.id])==null?void 0:pn.totalRequestsUsed)??E.totalRequestsUsed;return je&&E.requestCountLimit&&je>=E.requestCountLimit?u.jsx("span",{style:{color:"red",marginLeft:"4px",fontWeight:"bold",fontSize:"11px"},children:"超限"}):null})()]})]})]}):u.jsx("span",{style:{color:"#999",fontSize:"12px"},children:"不限制"})}),u.jsx("td",{children:u.jsxs("div",{className:"action-buttons",style:{justifyContent:"flex-end"},children:[u.jsx("button",{className:`btn ${E.isDisabled?"btn-success":"btn-warning"}`,onClick:()=>O2(E.id),title:E.isDisabled?"启用规则":"临时屏蔽规则",children:E.isDisabled?"启用":"屏蔽"}),u.jsx("button",{className:"btn btn-secondary",onClick:()=>_2(E),children:"编辑"}),u.jsx("button",{className:"btn btn-danger",onClick:()=>P2(E.id),children:"删除"})]})})]},E.id)})})]}):u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"请先选择一个路由"})}),g&&i.length>0&&u.jsxs("div",{style:{fontSize:"12px",color:"var(--text-info-box)",marginTop:"16px",padding:"12px",backgroundColor:"var(--bg-info-box)",borderRadius:"6px",border:"1px solid var(--border-info-box)",lineHeight:"1.6"},children:[u.jsx("strong",{children:"💡 智能故障切换机制"}),u.jsxs("div",{style:{marginTop:"6px"},children:["• 当同一请求类型配置多个规则时,系统会按排序优先使用第一个",u.jsx("br",{}),"• 如果某个服务报错(4xx/5xx)或请求超时,将自动切换到下一个可用服务",u.jsx("br",{}),"• 报错或超时的服务会被标记为不可用,有效期10分钟",u.jsx("br",{}),"• 10分钟后自动解除标记,如果再次报错或超时则重新标记",u.jsx("br",{}),"• 确保您的请求始终路由到稳定可用的服务",u.jsx("br",{}),"• 规则状态列会实时显示每个规则的可用性状态",u.jsx("br",{}),"• 如不需要此功能,可在",u.jsx("strong",{children:"设置"}),'页面关闭"启用智能故障切换"选项']})]})]}),g&&g.targetType==="claude-code"&&u.jsxs("div",{className:"card",children:[u.jsx("div",{className:"toolbar",children:u.jsx("h3",{children:"Claude Code 配置"})}),u.jsxs("div",{style:{padding:"20px"},children:[!B()&&((eb=Me==null?void 0:Me.claudeCode)==null?void 0:eb.version)&&u.jsxs("div",{style:{backgroundColor:"var(--bg-warning, #fff3cd)",border:"1px solid var(--border-warning, #ffc107)",borderRadius:"6px",padding:"12px",marginBottom:"12px",fontSize:"13px",color:"var(--text-warning, #856404)"},children:["⚠️ 当前 Claude Code 版本 (",Me.claudeCode.version,") 不支持 Agent Teams 功能。",u.jsx("br",{}),"Agent Teams 功能需要 Claude Code 版本 ≥ 2.1.32。请升级 Claude Code 后再使用此功能。"]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[u.jsx("input",{type:"checkbox",id:"agent-teams-toggle",checked:g.enableAgentTeams||!1,onChange:E=>T2(E.target.checked),disabled:!B(),style:{cursor:B()?"pointer":"not-allowed",width:"16px",height:"16px"}}),u.jsx("label",{htmlFor:"agent-teams-toggle",style:{cursor:B()?"pointer":"not-allowed",fontSize:"14px",userSelect:"none",color:B()?"inherit":"var(--text-muted)"},children:"开启 Agent Teams 功能"})]}),u.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginTop:"12px"},children:B()?g.isActive?"开启后将在 Claude Code 中启用 Agent Teams 实验性功能,已立即生效。":"开启后将在激活此路由时启用 Agent Teams 实验性功能。":"Agent Teams 功能需要 Claude Code 版本 ≥ 2.1.32。请升级 Claude Code 后再使用此功能。"})]})]})]})]})}),u.jsxs("div",{className:"card",style:{marginTop:"20px"},children:[u.jsx("div",{className:"toolbar",children:u.jsx("h3",{children:"📝 配置文件自动管理"})}),u.jsxs("div",{style:{padding:"20px",lineHeight:"1.8"},children:[u.jsxs("div",{style:{background:"var(--bg-info-blue)",padding:"15px",borderRadius:"8px",marginBottom:"15px",borderLeft:"4px solid var(--border-info-blue)"},children:[u.jsx("strong",{children:"💡 工作原理"}),u.jsx("p",{style:{marginTop:"8px",marginBottom:"0"},children:"激活路由时,系统会自动修改编程工具的配置文件,使其通过本代理服务器访问AI服务。 停用路由时,系统会自动恢复原始配置。"})]}),u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"15px"},children:[u.jsxs("div",{style:{background:"var(--bg-info-green)",padding:"15px",borderRadius:"8px",borderLeft:"4px solid var(--border-info-green)"},children:[u.jsx("strong",{children:"✓ 激活路由"}),u.jsxs("ul",{style:{marginTop:"8px",paddingLeft:"20px",marginBottom:"0"},children:[u.jsx("li",{children:"首次激活:自动备份并覆盖配置文件"}),u.jsx("li",{children:"再次激活:仅切换路由,不重复覆盖"})]})]}),u.jsxs("div",{style:{background:"var(--bg-info-orange)",padding:"15px",borderRadius:"8px",borderLeft:"4px solid var(--border-info-orange)"},children:[u.jsx("strong",{children:"○ 停用路由"}),u.jsxs("ul",{style:{marginTop:"8px",paddingLeft:"20px",marginBottom:"0"},children:[u.jsx("li",{children:"自动恢复原始配置文件"}),u.jsx("li",{children:"删除备份文件"})]})]})]}),u.jsxs("div",{style:{marginTop:"15px",padding:"12px 15px",background:"var(--bg-info-yellow)",borderRadius:"8px",borderLeft:"4px solid var(--border-info-yellow)"},children:[u.jsx("strong",{children:"⚠️ 重要提示"}),u.jsxs("ul",{style:{marginTop:"8px",paddingLeft:"20px",marginBottom:"0"},children:[u.jsxs("li",{children:["激活(首次)/停用路由后,",u.jsx("strong",{children:"必须重启对应的编程工具"}),"才能使配置生效"]}),u.jsx("li",{children:"操作前建议关闭编程工具,避免配置冲突"})]})]}),u.jsxs("details",{style:{marginTop:"15px",cursor:"pointer"},children:[u.jsx("summary",{style:{fontWeight:"bold",color:"#666"},children:"📂 配置文件位置(点击展开)"}),u.jsxs("ul",{style:{marginTop:"8px",paddingLeft:"20px",color:"#666"},children:[u.jsxs("li",{children:[u.jsx("strong",{children:"Claude Code:"})," ~/.claude/settings.json, ~/.claude.json"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Codex:"})," ~/.codex/config.toml, ~/.codex/auth.json"]})]})]})]})]}),x&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>v(!1),"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:S?"编辑路由":"新建路由"})}),u.jsxs("form",{onSubmit:S2,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"路由名称"}),u.jsx("input",{type:"text",name:"name",defaultValue:S?S.name:"",required:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"描述"}),u.jsx("textarea",{name:"description",rows:3,defaultValue:S?S.description:""})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"客户端工具"}),u.jsx("select",{name:"targetType",defaultValue:S?S.targetType:"claude-code",required:!0,children:Yh.map(E=>u.jsx("option",{value:E.value,children:E.label},E.value))})]}),u.jsxs("div",{className:"modal-footer",children:[u.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>v(!1),children:"取消"}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})})]}),b&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>w(!1),"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:j?"编辑规则":"新建规则"})}),u.jsxs("form",{onSubmit:k2,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"对象请求类型"}),u.jsx("select",{name:"contentType",value:D,required:!0,onChange:E=>{z(E.target.value)},children:I2().map(E=>u.jsx("option",{value:E.value,children:E.label},E.value))})]}),D==="model-mapping"&&u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["被顶替模型 ",u.jsx("small",{children:"(可在日志中找出想要顶替的模型名)"})]}),u.jsx("input",{type:"text",value:L,onChange:E=>O(E.target.value),placeholder:"例如:gpt-4"})]}),D==="image-understanding"&&u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[u.jsx("input",{type:"checkbox",checked:be,onChange:E=>F(E.target.checked),style:{marginRight:"8px",cursor:"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"使用MCP"})]}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"开启后,将使用MCP工具处理图像理解请求,而不是直接调用API服务"})]}),D==="image-understanding"&&be&&u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["选择MCP工具 ",u.jsx("span",{className:"required",children:"*"})]}),u.jsx("div",{style:{maxHeight:"300px",overflowY:"auto",border:"1px solid var(--border-primary)",borderRadius:"6px",padding:"8px"},children:p.length===0?u.jsx("div",{style:{padding:"12px",textAlign:"center",color:"var(--text-muted)"},children:"暂无MCP工具,请先在MCP管理页面添加"}):p.map(E=>u.jsxs("div",{onClick:()=>ie(E.id),style:{padding:"12px",marginBottom:"8px",border:`2px solid ${le===E.id?"var(--primary-color)":"var(--border-primary)"}`,borderRadius:"6px",cursor:"pointer",backgroundColor:le===E.id?"var(--bg-info-blue)":"var(--bg-card)",transition:"all 0.2s ease"},children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[u.jsx("div",{style:{fontWeight:600,fontSize:"14px"},children:E.name}),u.jsx("div",{className:"badge badge-secondary",style:{fontSize:"11px"},children:E.type==="stdio"?"命令行":E.type.toUpperCase()})]}),E.description&&u.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginTop:"4px"},children:E.description})]},E.id))})]}),!be&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商"}),u.jsxs("select",{value:T,onChange:E=>M(E.target.value),required:!0,children:[u.jsx("option",{value:"",disabled:!0,children:"请选择供应商"}),o.map(E=>u.jsx("option",{value:E.id,children:E.name},E.id))]})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商API服务"}),u.jsxs("select",{value:I,onChange:E=>{const X=E.target.value;_(X),V("");const me=s.find(ye=>ye.id===X);me&&(me.enableTokenLimit&&me.tokenLimit?(Y(me.tokenLimit),A(me.tokenResetInterval),ge(me.tokenResetBaseTime?new Date(me.tokenResetBaseTime):void 0),Gt(me.tokenLimit),$t(!0),$e(!0)):(Gt(void 0),$t(!1),$e(!1)),me.enableRequestLimit&&me.requestCountLimit?(W(me.requestCountLimit),se(me.requestResetInterval),_e(me.requestResetBaseTime?new Date(me.requestResetBaseTime):void 0),J(me.requestCountLimit),wt(!0),Ve(!0)):(J(void 0),wt(!1),Ve(!1)))},required:!0,disabled:!T,children:[u.jsx("option",{value:"",disabled:!0,children:"请选择API服务"}),d.map(E=>u.jsx("option",{value:E.id,children:E.name},E.id))]})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商模型"}),u.jsxs("select",{value:N,onChange:E=>V(E.target.value),disabled:!I,children:[u.jsx("option",{value:"",children:"透传模型名"}),(nb=(tb=s.find(E=>E.id===I))==null?void 0:tb.supportedModels)==null?void 0:nb.map(E=>u.jsx("option",{value:E,children:E},E))]})]}),u.jsx("div",{className:"form-group",children:u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:xt?"not-allowed":"pointer"},children:[u.jsx("input",{type:"checkbox",checked:Se,onChange:E=>$e(E.target.checked),disabled:xt,style:{marginRight:"8px",cursor:xt?"not-allowed":"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"启用Tokens超量限制"}),xt&&u.jsx("small",{style:{color:"#999",fontSize:"12px",marginLeft:"8px"},children:"(从API服务继承)"})]}),xt&&u.jsx("button",{type:"button",className:"btn btn-sm btn-secondary",onClick:()=>$t(!1),style:{padding:"4px 12px",fontSize:"12px"},children:"自定义限制"})]})}),Se&&!xt&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"Tokens超量(单位:k)"}),u.jsx("input",{type:"number",value:P||"",onChange:E=>{const X=E.target.value?parseInt(E.target.value):void 0;if(X!==void 0&&It!==void 0&&X>It){re.warning(`Token超量值不能超过API服务的限制 (${It}k)`);return}Y(X),xt&&X!==It&&$t(!1)},min:"0",max:It,placeholder:It?`最大 ${It}k`:"不限制",disabled:xt}),It&&u.jsxs("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:["⚠️ API服务限制:最大 ",It,"k,当前值不能超过此限制"]}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"当编程工具的请求tokens达到这个量时,在配置了其他规则的情况下,本条规则将失效,从而保护你的余额。例如:输入100表示100k即100,000个tokens"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"Tokens超量自动重置间隔(小时)"}),u.jsx("input",{type:"number",value:Z||"",onChange:E=>{A(E.target.value?parseInt(E.target.value):void 0),xt&&$t(!1)},min:"1",placeholder:"不自动重置",disabled:xt}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"设置后,系统将每隔指定小时数自动重置token计数。例如设置5小时,则每5小时重置一次"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"Token下一次重置时间基点"}),u.jsx("input",{type:"datetime-local",value:ue?yw(ue):"",onChange:E=>{E.target.value?ge(new Date(E.target.value)):ge(void 0),xt&&$t(!1)},disabled:!Z||xt,className:"datetime-picker-input"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:'配合"Tokens超量自动重置间隔"使用,设置下一次重置的精确时间点。例如,每月1日0点重置(间隔720小时),或每周一0点重置(间隔168小时)。设置后,系统会基于此时间点自动计算后续重置周期'})]})]}),u.jsx("div",{className:"form-group",children:u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:bt?"not-allowed":"pointer"},children:[u.jsx("input",{type:"checkbox",checked:Ne,onChange:E=>Ve(E.target.checked),disabled:bt,style:{marginRight:"8px",cursor:bt?"not-allowed":"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"启用请求次数超量限制"}),bt&&u.jsx("small",{style:{color:"#999",fontSize:"12px",marginLeft:"8px"},children:"(从API服务继承)"})]}),bt&&u.jsx("button",{type:"button",className:"btn btn-sm btn-secondary",onClick:()=>wt(!1),style:{padding:"4px 12px",fontSize:"12px"},children:"自定义限制"})]})}),Ne&&!bt&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求次数超量"}),u.jsx("input",{type:"number",value:de||"",onChange:E=>{const X=E.target.value?parseInt(E.target.value):void 0;if(X!==void 0&&K!==void 0&&X>K){re.warning(`请求次数超量值不能超过API服务的限制 (${K})`);return}W(X),bt&&X!==K&&wt(!1)},min:"0",max:K,placeholder:K?`最大 ${K}`:"不限制",disabled:bt}),K&&u.jsxs("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:["⚠️ API服务限制:最大 ",K,",当前值不能超过此限制"]}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"当请求次数达到这个量时,在配置了其他规则的情况下,本条规则将失效"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求次数自动重置间隔(小时)"}),u.jsx("input",{type:"number",value:ne||"",onChange:E=>{se(E.target.value?parseInt(E.target.value):void 0),bt&&wt(!1)},min:"1",placeholder:"不自动重置",disabled:bt}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"设置后,系统将每隔指定小时数自动重置请求次数计数。例如设置24小时,则每24小时重置一次"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"下一次重置时间基点"}),u.jsx("input",{type:"datetime-local",value:q?yw(q):"",onChange:E=>{E.target.value?_e(new Date(E.target.value)):_e(void 0),bt&&wt(!1)},disabled:!ne||bt,className:"datetime-picker-input"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:'配合"请求次数自动重置间隔"使用,设置下一次重置的精确时间点。例如,每月1日0点重置(间隔720小时),或每周一0点重置(间隔168小时)。设置后,系统会基于此时间点自动计算后续重置周期'})]})]})]}),u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[u.jsx("input",{type:"checkbox",checked:!!Ce,onChange:E=>{E.target.checked?(ve(10),Pe(0)):(ve(void 0),Pe(void 0))},style:{marginRight:"8px",cursor:"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"启用请求频率限制"})]}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"启用后,当同一内容类型的请求频率超过限制时,系统会自动切换到其他同类型规则"})]}),Ce&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"频率限制次数(并发数)"}),u.jsx("input",{type:"number",value:Ce||"",onChange:E=>ve(E.target.value?parseInt(E.target.value):void 0),min:"1",placeholder:"例如: 10"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"在指定时间窗口内允许的最大请求次数"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"频率限制时间窗口(秒,0=同一时刻)"}),u.jsx("input",{type:"number",value:we===0?0:we||"",onChange:E=>{const X=E.target.value?parseInt(E.target.value):void 0;Pe(X===0?0:X)},min:"0",placeholder:"0 表示同一时刻"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"时间窗口大小。0 表示同一时刻(并发数),持续累积;设置为 60 则在 60 秒内最多允许 N 次请求"})]})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"超时时间(秒)"}),u.jsx("input",{type:"number",value:H||"",onChange:E=>G(E.target.value?parseInt(E.target.value):void 0),min:"1",placeholder:"默认300秒"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"设置此规则的API请求超时时间。不设置则使用默认值300秒(5分钟)"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"排序(值越大优先级越高)"}),u.jsx("input",{type:"number",value:R,onChange:E=>U(parseInt(E.target.value)||0),min:"0",max:"1000"})]}),u.jsxs("div",{className:"modal-footer",children:[u.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>w(!1),children:"取消"}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})})]})]})}var AE={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Go,function(){var n=1e3,r=6e4,i=36e5,a="millisecond",o="second",l="minute",s="hour",c="day",d="week",f="month",p="quarter",h="year",g="date",y="Invalid Date",x=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(L){var O=["th","st","nd","rd"],R=L%100;return"["+L+(O[(R-20)%10]||O[R]||O[0])+"]"}},w=function(L,O,R){var U=String(L);return!U||U.length>=O?L:""+Array(O+1-U.length).join(R)+L},S={s:w,z:function(L){var O=-L.utcOffset(),R=Math.abs(O),U=Math.floor(R/60),D=R%60;return(O<=0?"+":"-")+w(U,2,"0")+":"+w(D,2,"0")},m:function L(O,R){if(O.date()<R.date())return-L(R,O);var U=12*(R.year()-O.year())+(R.month()-O.month()),D=O.clone().add(U,f),z=R-D<0,P=O.clone().add(U+(z?-1:1),f);return+(-(U+(R-D)/(z?D-P:P-D))||0)},a:function(L){return L<0?Math.ceil(L)||0:Math.floor(L)},p:function(L){return{M:f,y:h,w:d,d:c,D:g,h:s,m:l,s:o,ms:a,Q:p}[L]||String(L||"").toLowerCase().replace(/s$/,"")},u:function(L){return L===void 0}},k="en",j={};j[k]=b;var C="$isDayjsObject",T=function(L){return L instanceof N||!(!L||!L[C])},M=function L(O,R,U){var D;if(!O)return k;if(typeof O=="string"){var z=O.toLowerCase();j[z]&&(D=z),R&&(j[z]=R,D=z);var P=O.split("-");if(!D&&P.length>1)return L(P[0])}else{var Y=O.name;j[Y]=O,D=Y}return!U&&D&&(k=D),D||!U&&k},I=function(L,O){if(T(L))return L.clone();var R=typeof O=="object"?O:{};return R.date=L,R.args=arguments,new N(R)},_=S;_.l=M,_.i=T,_.w=function(L,O){return I(L,{locale:O.$L,utc:O.$u,x:O.$x,$offset:O.$offset})};var N=function(){function L(R){this.$L=M(R.locale,null,!0),this.parse(R),this.$x=this.$x||R.x||{},this[C]=!0}var O=L.prototype;return O.parse=function(R){this.$d=function(U){var D=U.date,z=U.utc;if(D===null)return new Date(NaN);if(_.u(D))return new Date;if(D instanceof Date)return new Date(D);if(typeof D=="string"&&!/Z$/i.test(D)){var P=D.match(x);if(P){var Y=P[2]-1||0,Z=(P[7]||"0").substring(0,3);return z?new Date(Date.UTC(P[1],Y,P[3]||1,P[4]||0,P[5]||0,P[6]||0,Z)):new Date(P[1],Y,P[3]||1,P[4]||0,P[5]||0,P[6]||0,Z)}}return new Date(D)}(R),this.init()},O.init=function(){var R=this.$d;this.$y=R.getFullYear(),this.$M=R.getMonth(),this.$D=R.getDate(),this.$W=R.getDay(),this.$H=R.getHours(),this.$m=R.getMinutes(),this.$s=R.getSeconds(),this.$ms=R.getMilliseconds()},O.$utils=function(){return _},O.isValid=function(){return this.$d.toString()!==y},O.isSame=function(R,U){var D=I(R);return this.startOf(U)<=D&&D<=this.endOf(U)},O.isAfter=function(R,U){return I(R)<this.startOf(U)},O.isBefore=function(R,U){return this.endOf(U)<I(R)},O.$g=function(R,U,D){return _.u(R)?this[U]:this.set(D,R)},O.unix=function(){return Math.floor(this.valueOf()/1e3)},O.valueOf=function(){return this.$d.getTime()},O.startOf=function(R,U){var D=this,z=!!_.u(U)||U,P=_.p(R),Y=function(W,ne){var se=_.w(D.$u?Date.UTC(D.$y,ne,W):new Date(D.$y,ne,W),D);return z?se:se.endOf(c)},Z=function(W,ne){return _.w(D.toDate()[W].apply(D.toDate("s"),(z?[0,0,0,0]:[23,59,59,999]).slice(ne)),D)},A=this.$W,ue=this.$M,ge=this.$D,H="set"+(this.$u?"UTC":"");switch(P){case h:return z?Y(1,0):Y(31,11);case f:return z?Y(1,ue):Y(0,ue+1);case d:var G=this.$locale().weekStart||0,de=(A<G?A+7:A)-G;return Y(z?ge-de:ge+(6-de),ue);case c:case g:return Z(H+"Hours",0);case s:return Z(H+"Minutes",1);case l:return Z(H+"Seconds",2);case o:return Z(H+"Milliseconds",3);default:return this.clone()}},O.endOf=function(R){return this.startOf(R,!1)},O.$set=function(R,U){var D,z=_.p(R),P="set"+(this.$u?"UTC":""),Y=(D={},D[c]=P+"Date",D[g]=P+"Date",D[f]=P+"Month",D[h]=P+"FullYear",D[s]=P+"Hours",D[l]=P+"Minutes",D[o]=P+"Seconds",D[a]=P+"Milliseconds",D)[z],Z=z===c?this.$D+(U-this.$W):U;if(z===f||z===h){var A=this.clone().set(g,1);A.$d[Y](Z),A.init(),this.$d=A.set(g,Math.min(this.$D,A.daysInMonth())).$d}else Y&&this.$d[Y](Z);return this.init(),this},O.set=function(R,U){return this.clone().$set(R,U)},O.get=function(R){return this[_.p(R)]()},O.add=function(R,U){var D,z=this;R=Number(R);var P=_.p(U),Y=function(ue){var ge=I(z);return _.w(ge.date(ge.date()+Math.round(ue*R)),z)};if(P===f)return this.set(f,this.$M+R);if(P===h)return this.set(h,this.$y+R);if(P===c)return Y(1);if(P===d)return Y(7);var Z=(D={},D[l]=r,D[s]=i,D[o]=n,D)[P]||1,A=this.$d.getTime()+R*Z;return _.w(A,this)},O.subtract=function(R,U){return this.add(-1*R,U)},O.format=function(R){var U=this,D=this.$locale();if(!this.isValid())return D.invalidDate||y;var z=R||"YYYY-MM-DDTHH:mm:ssZ",P=_.z(this),Y=this.$H,Z=this.$m,A=this.$M,ue=D.weekdays,ge=D.months,H=D.meridiem,G=function(ne,se,q,_e){return ne&&(ne[se]||ne(U,z))||q[se].slice(0,_e)},de=function(ne){return _.s(Y%12||12,ne,"0")},W=H||function(ne,se,q){var _e=ne<12?"AM":"PM";return q?_e.toLowerCase():_e};return z.replace(v,function(ne,se){return se||function(q){switch(q){case"YY":return String(U.$y).slice(-2);case"YYYY":return _.s(U.$y,4,"0");case"M":return A+1;case"MM":return _.s(A+1,2,"0");case"MMM":return G(D.monthsShort,A,ge,3);case"MMMM":return G(ge,A);case"D":return U.$D;case"DD":return _.s(U.$D,2,"0");case"d":return String(U.$W);case"dd":return G(D.weekdaysMin,U.$W,ue,2);case"ddd":return G(D.weekdaysShort,U.$W,ue,3);case"dddd":return ue[U.$W];case"H":return String(Y);case"HH":return _.s(Y,2,"0");case"h":return de(1);case"hh":return de(2);case"a":return W(Y,Z,!0);case"A":return W(Y,Z,!1);case"m":return String(Z);case"mm":return _.s(Z,2,"0");case"s":return String(U.$s);case"ss":return _.s(U.$s,2,"0");case"SSS":return _.s(U.$ms,3,"0");case"Z":return P}return null}(ne)||P.replace(":","")})},O.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},O.diff=function(R,U,D){var z,P=this,Y=_.p(U),Z=I(R),A=(Z.utcOffset()-this.utcOffset())*r,ue=this-Z,ge=function(){return _.m(P,Z)};switch(Y){case h:z=ge()/12;break;case f:z=ge();break;case p:z=ge()/3;break;case d:z=(ue-A)/6048e5;break;case c:z=(ue-A)/864e5;break;case s:z=ue/i;break;case l:z=ue/r;break;case o:z=ue/n;break;default:z=ue}return D?z:_.a(z)},O.daysInMonth=function(){return this.endOf(f).$D},O.$locale=function(){return j[this.$L]},O.locale=function(R,U){if(!R)return this.$L;var D=this.clone(),z=M(R,U,!0);return z&&(D.$L=z),D},O.clone=function(){return _.w(this.$d,this)},O.toDate=function(){return new Date(this.valueOf())},O.toJSON=function(){return this.isValid()?this.toISOString():null},O.toISOString=function(){return this.$d.toISOString()},O.toString=function(){return this.$d.toUTCString()},L}(),V=N.prototype;return I.prototype=V,[["$ms",a],["$s",o],["$m",l],["$H",s],["$W",c],["$M",f],["$y",h],["$D",g]].forEach(function(L){V[L[1]]=function(O){return this.$g(O,L[0],L[1])}}),I.extend=function(L,O){return L.$i||(L(O,N,I),L.$i=!0),I},I.locale=M,I.isDayjs=T,I.unix=function(L){return I(1e3*L)},I.en=j[k],I.Ls=j,I.p={},I})})(AE);var yB=AE.exports;const on=Vn(yB);var TE={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Go,function(){return function(n,r,i){n=n||{};var a=r.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function l(c,d,f,p){return a.fromToBase(c,d,f,p)}i.en.relativeTime=o,a.fromToBase=function(c,d,f,p,h){for(var g,y,x,v=f.$locale().relativeTime||o,b=n.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],w=b.length,S=0;S<w;S+=1){var k=b[S];k.d&&(g=p?i(c).diff(f,k.d,!0):f.diff(c,k.d,!0));var j=(n.rounding||Math.round)(Math.abs(g));if(x=g>0,j<=k.r||!k.r){j<=1&&S>0&&(k=b[S-1]);var C=v[k.l];h&&(j=h(""+j)),y=typeof C=="string"?C.replace("%d",j):C(j,d,k.l,x);break}}if(d)return y;var T=x?v.future:v.past;return typeof T=="function"?T(y):T.replace("%s",y)},a.to=function(c,d){return l(c,d,this,!0)},a.from=function(c,d){return l(c,d,this)};var s=function(c){return c.$u?i.utc():i()};a.toNow=function(c){return this.to(s(this),c)},a.fromNow=function(c){return this.from(s(this),c)}}})})(TE);var xB=TE.exports;const bB=Vn(xB),wB=["authorization","x-api-key","api-key","apikey","x-auth-token","auth-token","secret","password","api_secret","jwt","csrf_token","xsrf_token","auth_token","session_token","private_key","client_secret"],SB=e=>{const t=e.toLowerCase();return!!(wB.some(n=>t===n)||t.startsWith("api_")&&(t.endsWith("_key")||t.endsWith("_secret"))||(t.endsWith("_token")||t.endsWith("_key")||t.endsWith("_secret"))&&!["max_tokens","input_tokens","output_tokens","completion_tokens","prompt_tokens","cachereadinputtokens","totaltokens"].some(r=>t.replace(/_/g,"").includes(r.replace(/_/g,""))))},jB=e=>!e||e.length<=8?"***":`${e.slice(0,4)}${"*".repeat(Math.min(e.length-8,20))}${e.slice(-4)}`,Ig=e=>{if(e==null)return e;if(Array.isArray(e))return e.map(t=>Ig(t));if(typeof e=="object"){const t={};for(const[n,r]of Object.entries(e))SB(n)?t[n]=typeof r=="string"?jB(r):"***":typeof r=="object"?t[n]=Ig(r):t[n]=r;return t}return e},pr=({data:e,title:t,collapsed:n=!1})=>{const[r,i]=m.useState(!n),[a,o]=m.useState(!1),l=d=>{try{let f;typeof d=="string"?f=JSON.parse(d):f=d;const p=Ig(f);return JSON.stringify(p,null,2)}catch{return typeof d=="string"?d:String(d)}},s=()=>{const d=l(e);navigator.clipboard.writeText(d).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)}).catch(f=>{console.error("Failed to copy JSON:",f)})},c=l(e);return u.jsxs("div",{className:"json-viewer",children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[t&&u.jsx("h4",{style:{margin:0,fontSize:"14px",color:"var(--text-primary)"},children:t}),u.jsxs("div",{style:{display:"flex",gap:"8px"},children:[u.jsx("button",{onClick:()=>i(!r),className:"btn btn-sm btn-secondary",style:{fontSize:"12px",padding:"2px 8px"},children:r?"折叠":"展开"}),u.jsx("button",{onClick:s,className:"btn btn-sm btn-primary",style:{fontSize:"12px",padding:"2px 8px"},children:a?"已复制":"复制"})]})]}),r&&u.jsx("pre",{style:{background:"var(--bg-code)",border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"12px",overflowX:"auto",fontSize:"12px",lineHeight:"1.4",color:"var(--text-primary)",maxHeight:"400px",overflowY:"auto",margin:0},children:u.jsx("code",{children:c})})]})},Xh=({currentPage:e,totalItems:t,pageSize:n,onPageChange:r,onPageSizeChange:i,pageSizeOptions:a=[10,20,50,100]})=>{const o=Math.max(1,Math.ceil(t/n)),l=e===1,s=e>=o,c=()=>{l||r(1)},d=()=>{l||r(e-1)},f=()=>{s||r(e+1)},p=()=>{s||r(o)},h=g=>{const y=parseInt(g.target.value,10);i(y)};return u.jsxs("div",{className:"pagination",children:[u.jsxs("div",{className:"pagination-info",children:["共 ",t," 条"]}),u.jsxs("div",{className:"pagination-controls",children:[u.jsx("button",{className:"pagination-btn",onClick:c,disabled:l,children:"首页"}),u.jsx("button",{className:"pagination-btn",onClick:d,disabled:l,children:"上一页"}),u.jsxs("span",{className:"pagination-info",children:["第 ",e," / ",o," 页"]}),u.jsx("button",{className:"pagination-btn",onClick:f,disabled:s,children:"下一页"}),u.jsx("button",{className:"pagination-btn",onClick:p,disabled:s,children:"尾页"})]}),u.jsx("div",{className:"pagination-size",children:u.jsxs("label",{children:["每页显示",u.jsx("select",{className:"pagination-select",value:n,onChange:h,children:a.map(g=>u.jsx("option",{value:g,children:g},g))}),"条"]})})]})};on.extend(bB);function kB(e){const t=[];let n={dataLines:[],rawLines:[]};for(const r of e){const i=r.split(`
122
+ 请刷新页面后重试。`)}}catch(ye){console.error("停用路由失败:",ye),re.error(ye.message)}finally{_t(null)}},S2=async E=>{E.preventDefault();const X=new FormData(E.currentTarget),me={name:X.get("name"),description:X.get("description"),targetType:X.get("targetType"),isActive:!1};S?await Q.updateRoute(S.id,me):await Q.createRoute(me),v(!1),_i()},j2=async E=>{await e({message:"确定要删除此路由吗?",title:"确认删除",type:"danger",confirmText:"删除",cancelText:"取消"})&&(await Q.deleteRoute(E),_i(),g&&g.id===E&&(y(null),a([])),re.success("路由已删除"))},k2=async E=>{if(E.preventDefault(),D==="image-understanding"&&be&&!ae){re.warning("请选择一个MCP工具");return}if(!be&&!I){re.warning("请选择供应商API服务");return}if(!be&&P!==void 0&&It!==void 0&&P>It){re.warning(`Token超量值 (${P}k) 不能超过API服务的限制 (${It}k)`);return}if(!be&&de!==void 0&&K!==void 0&&de>K){re.warning(`请求次数超量值 (${de}) 不能超过API服务的限制 (${K})`);return}const X=new FormData(E.currentTarget),me={routeId:g.id,contentType:X.get("contentType"),targetServiceId:be?"":I,targetModel:be?void 0:N||void 0,replacedModel:L||void 0,sortOrder:R,timeout:H?H*1e3:void 0,tokenLimit:be?void 0:P||void 0,resetInterval:be?void 0:Z,tokenResetBaseTime:be?void 0:ue?ue.getTime():void 0,requestCountLimit:be?void 0:de,requestResetInterval:be?void 0:ne,requestResetBaseTime:be?void 0:q?q.getTime():void 0,frequencyLimit:Ce,frequencyWindow:we,useMCP:D==="image-understanding"?be:!1,mcpId:D==="image-understanding"&&be?ae:void 0};j?await Q.updateRule(j.id,me):await Q.createRule(me),w(!1),g&&Ae(g.id)},P2=async E=>{await e({message:"确定要删除此路由吗?",title:"确认删除",type:"danger",confirmText:"删除",cancelText:"取消"})&&(await Q.deleteRule(E),g&&Ae(g.id),re.success("规则已删除"))},C2=async E=>{try{await Q.clearRuleBlacklist(E),g&&Ae(g.id),re.success("已恢复")}catch(X){re.error("恢复失败: "+X.message)}},O2=async E=>{try{const X=await Q.toggleRuleDisable(E);g&&Ae(g.id),re.success(X.isDisabled?"规则已屏蔽":"规则已启用")}catch(X){re.error("操作失败: "+X.message)}},E2=async E=>{try{const X=i.find(ye=>ye.id===E);if(!X)return;const me=(X.sortOrder||0)+1;await Q.updateRule(E,{sortOrder:me}),g&&Ae(g.id),re.success("优先级已提升")}catch(X){re.error("操作失败: "+X.message)}},A2=async E=>{try{const X=i.find(ye=>ye.id===E);if(!X)return;const me=Math.max(0,(X.sortOrder||0)-1);await Q.updateRule(E,{sortOrder:me}),g&&Ae(g.id),re.success("优先级已降低")}catch(X){re.error("操作失败: "+X.message)}},T2=async E=>{if(g){if(E&&!B()){re.error("当前 Claude Code 版本不支持 Agent Teams 功能,需要版本 ≥ 2.1.32");return}try{g.isActive?(await Q.updateClaudeAgentTeams(E),await Q.updateRoute(g.id,{enableAgentTeams:E}),re.success(E?"Agent Teams 功能已开启":"Agent Teams 功能已关闭")):(await Q.updateRoute(g.id,{enableAgentTeams:E}),re.success(E?"Agent Teams 设置已保存(将在激活时生效)":"Agent Teams 设置已取消")),y({...g,enableAgentTeams:E}),await _i()}catch(X){re.error("更新失败: "+X.message)}}},I2=()=>mw,_2=E=>{C(E),z(E.contentType),F(E.useMCP||!1),ie(E.mcpId||"");const X=s.find(me=>me.id===E.targetServiceId);X?(X.vendorId&&(M(X.vendorId),f(s.filter(me=>me.vendorId===X.vendorId))),setTimeout(()=>{if(_(X.id),V(E.targetModel||""),O(E.replacedModel||""),U(E.sortOrder||0),G(E.timeout?E.timeout/1e3:void 0),Y(E.tokenLimit||void 0),A(E.resetInterval),ge(E.tokenResetBaseTime?new Date(E.tokenResetBaseTime):void 0),W(E.requestCountLimit),se(E.requestResetInterval),_e(E.requestResetBaseTime?new Date(E.requestResetBaseTime):void 0),ve(E.frequencyLimit),Pe(E.frequencyWindow),X.enableTokenLimit&&X.tokenLimit){Gt(X.tokenLimit);const me=E.tokenLimit===X.tokenLimit&&E.resetInterval===(X.tokenResetInterval||void 0)&&E.tokenLimit!==null&&E.resetInterval!==null;$t(me)}else Gt(void 0),$t(!1);if(X.enableRequestLimit&&X.requestCountLimit){J(X.requestCountLimit);const me=E.requestCountLimit===X.requestCountLimit&&E.requestResetInterval===(X.requestResetInterval||void 0)&&E.requestCountLimit!==null&&E.requestResetInterval!==null;wt(me)}else J(void 0),wt(!1);$e(!!E.tokenLimit),Ve(!!E.requestCountLimit)},0)):E.useMCP&&(M(""),_(""),V(""),O(""),U(E.sortOrder||0),G(E.timeout?E.timeout/1e3:void 0),$e(!1),Ve(!1)),w(!0)},N2=E=>{var El;const X=xe[E.id],me=[],ye=t[E.id];if((ye==null?void 0:ye.status)==="in_use")return{status:"in_use",label:"使用中",reason:"正在处理请求"};if(X!=null&&X.isBlacklisted){const je=X.blacklistEntry;(je==null?void 0:je.errorType)==="timeout"?me.push("请求超时"):je!=null&&je.lastStatusCode&&me.push(`HTTP ${je.lastStatusCode}错误`)}const Le=(ye==null?void 0:ye.totalTokensUsed)!==void 0?ye.totalTokensUsed:E.totalTokensUsed;E.tokenLimit&&Le!==void 0&&Le>=E.tokenLimit*1e3&&me.push("Token超限");const St=(ye==null?void 0:ye.totalRequestsUsed)!==void 0?ye.totalRequestsUsed:E.totalRequestsUsed;if(E.requestCountLimit&&St!==void 0&&St>=E.requestCountLimit&&me.push("次数超限"),me.length>0)return{status:"error",label:X!=null&&X.isBlacklisted?((El=X.blacklistEntry)==null?void 0:El.errorType)==="timeout"?"超时":"服务错误":me[0],reason:me.join(", ")};const Ir=[];if(E.tokenLimit&&Le!==void 0){const je=Le/(E.tokenLimit*1e3)*100;je>=80&&Ir.push(`Token ${je.toFixed(0)}%`)}if(E.requestCountLimit&&St!==void 0){const je=St/E.requestCountLimit*100;je>=80&&Ir.push(`次数 ${je.toFixed(0)}%`)}return Ir.length>0?{status:"warning",label:"接近限制",reason:Ir.join(", ")}:{status:"success",label:"正常",reason:""}},M2=()=>{C(null),z("default"),M(""),_(""),V(""),O(""),U(0),G(void 0),Y(void 0),A(void 0),ge(void 0),W(void 0),se(void 0),_e(void 0),$t(!1),wt(!1),Gt(void 0),J(void 0),$e(!1),Ve(!1),F(!1),ie(""),w(!0)};return u.jsxs("div",{className:"routes-page",children:[u.jsxs("div",{className:"page-header",children:[u.jsx("h1",{children:"路由管理"}),u.jsx("p",{children:"管理API路由和路由配置"})]}),u.jsx("div",{style:{display:"flex",flexDirection:"column"},children:u.jsxs("div",{style:{display:"flex",gap:"20px"},children:[u.jsxs("div",{className:"card",style:{flex:"0 0 25%",minWidth:300},children:[u.jsxs("div",{className:"toolbar",children:[u.jsx("h3",{children:"路由"}),u.jsx("button",{className:"btn btn-primary",onClick:()=>v(!0),children:"新建"})]}),n.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无路由"})}):u.jsx("div",{style:{marginTop:"10px"},children:n.map(E=>{var X,me;return u.jsx("div",{ref:ye=>{ye?Gn.current.set(E.id,ye):Gn.current.delete(E.id)},onClick:()=>y(E),style:{padding:"12px",marginBottom:"8px",backgroundColor:g&&g.id===E.id?"var(--bg-route-item-selected)":"var(--bg-route-item)",borderRadius:"8px",cursor:"pointer",border:"1px solid var(--border-primary)",position:"relative"},children:u.jsxs("div",{children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[u.jsx("div",{style:{fontWeight:500},children:E.name}),E.isActive&&u.jsxs("span",{className:`badge ${E.targetType==="claude-code"?"badge-claude-code":"badge-codex"}`,style:{position:"absolute",top:-16,right:-8},children:[(X=Yh.find(ye=>ye.value===E.targetType))==null?void 0:X.label," 已激活"]})]}),u.jsxs("div",{style:{fontSize:"12px",color:"var(--text-route-muted)",marginTop:"2px"},children:["客户端工具: ",(me=Yh.find(ye=>ye.value===E.targetType))==null?void 0:me.label]}),u.jsxs("div",{className:"action-buttons",style:{marginTop:"8px"},children:[E.isActive?u.jsx("button",{className:"btn btn-warning",style:{padding:"4px 8px",fontSize:"12px"},onClick:ye=>{ye.stopPropagation(),w2(E.id)},disabled:Tr!==null,children:Tr===E.id?"处理中...":"停用"}):u.jsx("button",{className:"btn btn-success",style:{padding:"4px 8px",fontSize:"12px"},onClick:ye=>{ye.stopPropagation(),b2(E.id)},disabled:Tr!==null,children:Tr===E.id?"处理中...":"激活"}),u.jsx("button",{className:"btn btn-secondary",style:{padding:"4px 8px",fontSize:"12px"},onClick:ye=>{ye.stopPropagation(),k(E),v(!0)},children:"编辑"}),u.jsx("button",{className:"btn btn-danger",style:{padding:"4px 8px",fontSize:"12px"},onClick:ye=>{ye.stopPropagation(),j2(E.id)},disabled:E.isActive,children:"删除"})]})]})},E.id)})})]}),u.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:[u.jsxs("div",{className:"card",style:{flex:1},children:[u.jsxs("div",{className:"toolbar",children:[u.jsx("h3",{children:"规则列表"}),g&&u.jsx("button",{className:"btn btn-primary",onClick:M2,children:"新建规则"})]}),g?i.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无路由"})}):u.jsxs("table",{className:"rules-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{className:"col-priority",children:"优先级"}),u.jsx("th",{children:"类型"}),u.jsx("th",{children:"API服务"}),u.jsx("th",{children:"状态"}),u.jsx("th",{children:"用量情况"}),u.jsx("th",{children:"操作"})]})}),u.jsx("tbody",{children:[...i].sort((E,X)=>{const me=E.sortOrder||0,ye=X.sortOrder||0;if(me!==ye)return ye-me;const Le=gw[E.contentType]??999,St=gw[X.contentType]??999;return Le-St}).map(E=>{var Le,St,Ir,El;const X=s.find(je=>je.id===E.targetServiceId),me=o.find(je=>je.id===(X==null?void 0:X.vendorId)),ye=(Le=mw.find(je=>je.value===E.contentType))==null?void 0:Le.label;return u.jsxs("tr",{children:[u.jsx("td",{className:"col-priority",children:u.jsxs("div",{className:"col-priority-box",children:[u.jsx("span",{children:E.sortOrder||0}),u.jsx("button",{className:"priority-arrow-btn",onClick:()=>A2(E.id),title:"降低优先级",children:"↓"}),u.jsx("button",{className:"priority-arrow-btn",onClick:()=>E2(E.id),title:"提升优先级",children:"↑"})]})}),u.jsx("td",{children:u.jsxs("div",{style:{fontSize:"12px",whiteSpace:"nowrap"},children:[E.contentType!=="default"&&vw[E.contentType]&&u.jsx("span",{style:{fontSize:"14px"},children:vw[E.contentType]}),u.jsx("span",{children:ye}),E.contentType==="model-mapping"&&E.replacedModel&&u.jsxs("div",{style:{position:"relative",display:"inline-block"},onMouseEnter:()=>Pt(E.id),onMouseLeave:()=>Pt(null),children:[u.jsx("span",{style:{cursor:"help",fontSize:"14px",color:"var(--text-info)",fontWeight:"bold"},children:"ⓘ"}),Mn===E.id&&u.jsxs("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:"calc(100% + 8px)",backgroundColor:"var(--bg-popover, #333)",color:"var(--text-popover, #fff)",padding:"6px 10px",borderRadius:"4px",fontSize:"12px",whiteSpace:"nowrap",zIndex:1e3,boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:["被顶替的模型是: ",E.replacedModel,u.jsx("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:"-4px",width:"0",height:"0",borderLeft:"4px solid transparent",borderRight:"4px solid transparent",borderTop:"4px solid var(--bg-popover, #333)"}})]})]})]})}),u.jsx("td",{children:u.jsx("div",{className:"vendor-sevices-col",style:{fontSize:"0.6em"},children:E.useMCP?u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:["MCP:",((St=p.find(je=>je.id===E.mcpId))==null?void 0:St.name)||"Unknown"]}),u.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)"},children:"使用MCP工具"})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{children:["供应商:",me?me.name:"Unknown"]}),u.jsxs("div",{children:["服务:",X?X.name:"Unknown"]}),u.jsxs("div",{children:["模型:",E.targetModel||"透传模型"]})]})})}),u.jsx("td",{style:{whiteSpace:"nowrap"},children:(()=>{var rb,ib;const je=N2(E),pn=xe[E.id],D2=(pn==null?void 0:pn.isBlacklisted)&&!((rb=je.reason)!=null&&rb.includes("Token超限"))&&!((ib=je.reason)!=null&&ib.includes("次数超限"));return E.isDisabled?u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[u.jsx("span",{style:{color:"#6c757d",fontWeight:"bold",fontSize:"14px"},children:"⊘"}),u.jsx("span",{style:{fontSize:"13px",color:"#6c757d",fontWeight:"bold"},children:"已屏蔽"})]}):u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[je.status==="success"&&u.jsx("span",{style:{color:"#28a745",fontWeight:"bold",fontSize:"14px"},children:"✓"}),je.status==="warning"&&u.jsx("span",{style:{color:"#ffc107",fontWeight:"bold",fontSize:"14px"},children:"⚠"}),je.status==="error"&&u.jsx("span",{style:{color:"#dc3545",fontWeight:"bold",fontSize:"14px"},children:"✗"}),je.status==="in_use"&&u.jsx(u.Fragment,{children:u.jsx("span",{style:{color:"#007bff",fontWeight:"bold",fontSize:"14px",animation:"pulse 1.5s ease-in-out infinite"},children:"●"})}),u.jsx("span",{style:{fontSize:"13px",color:je.status==="success"?"#28a745":je.status==="warning"?"#ffc107":je.status==="in_use"?"#007bff":"#dc3545",fontWeight:je.status!=="success"?"bold":"normal"},children:je.label}),je.reason&&u.jsxs("div",{style:{position:"relative",display:"inline-block",cursor:"help"},onMouseEnter:()=>Pt(E.id+"-status"),onMouseLeave:()=>Pt(null),children:[u.jsx("span",{style:{fontSize:"12px",color:"#999",marginLeft:"4px"},children:" ⓘ"}),Mn===E.id+"-status"&&u.jsxs("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:"calc(100% + 8px)",backgroundColor:"var(--bg-popover, #333)",color:"var(--text-popover, #fff)",padding:"6px 10px",borderRadius:"4px",fontSize:"12px",whiteSpace:"nowrap",zIndex:1e3,boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:[je.reason,u.jsx("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:"-4px",width:"0",height:"0",borderLeft:"4px solid transparent",borderRight:"4px solid transparent",borderTop:"4px solid var(--bg-popover, #333)"}})]})]})]}),D2&&u.jsx("button",{className:"btn btn-info",style:{padding:"2px 8px",fontSize:"11px"},onClick:()=>C2(E.id),children:"恢复"})]})})()}),u.jsx("td",{children:E.tokenLimit||E.requestCountLimit?u.jsxs("div",{style:{fontSize:"13px"},children:[E.tokenLimit&&u.jsxs("div",{style:{whiteSpace:"nowrap"},children:[u.jsx("span",{style:{fontWeight:"bold",fontSize:"12px"},children:"Tokens:"}),u.jsxs(u.Fragment,{children:[u.jsxs("span",{style:{color:(()=>{var pn;const je=((pn=t[E.id])==null?void 0:pn.totalTokensUsed)??E.totalTokensUsed;return je&&E.tokenLimit&&je>=E.tokenLimit*1e3?"red":"inherit"})()},children:[(((((Ir=t[E.id])==null?void 0:Ir.totalTokensUsed)??E.totalTokensUsed)||0)/1e3).toFixed(1),"K/",E.tokenLimit.toFixed(0),"K"]}),(()=>{var pn;const je=((pn=t[E.id])==null?void 0:pn.totalTokensUsed)??E.totalTokensUsed;return je&&E.tokenLimit&&je>=E.tokenLimit*1e3?u.jsx("span",{style:{color:"red",marginLeft:"4px",fontWeight:"bold",fontSize:"11px"},children:"超限"}):null})()]})]}),E.requestCountLimit&&u.jsxs("div",{style:{marginTop:E.tokenLimit?"6px":0},children:[u.jsx("span",{style:{fontWeight:"bold",fontSize:"12px"},children:"次数:"}),u.jsxs(u.Fragment,{children:[u.jsxs("span",{style:{color:(()=>{var pn;const je=((pn=t[E.id])==null?void 0:pn.totalRequestsUsed)??E.totalRequestsUsed;return je&&E.requestCountLimit&&je>=E.requestCountLimit?"red":"inherit"})()},children:[(((El=t[E.id])==null?void 0:El.totalRequestsUsed)??E.totalTokensUsed)||0,"/",E.requestCountLimit]}),(()=>{var pn;const je=((pn=t[E.id])==null?void 0:pn.totalRequestsUsed)??E.totalRequestsUsed;return je&&E.requestCountLimit&&je>=E.requestCountLimit?u.jsx("span",{style:{color:"red",marginLeft:"4px",fontWeight:"bold",fontSize:"11px"},children:"超限"}):null})()]})]})]}):u.jsx("span",{style:{color:"#999",fontSize:"12px"},children:"不限制"})}),u.jsx("td",{children:u.jsxs("div",{className:"action-buttons",style:{justifyContent:"flex-end"},children:[u.jsx("button",{className:`btn ${E.isDisabled?"btn-success":"btn-warning"}`,onClick:()=>O2(E.id),title:E.isDisabled?"启用规则":"临时屏蔽规则",children:E.isDisabled?"启用":"屏蔽"}),u.jsx("button",{className:"btn btn-secondary",onClick:()=>_2(E),children:"编辑"}),u.jsx("button",{className:"btn btn-danger",onClick:()=>P2(E.id),children:"删除"})]})})]},E.id)})})]}):u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"请先选择一个路由"})}),g&&i.length>0&&u.jsxs("div",{style:{fontSize:"12px",color:"var(--text-info-box)",marginTop:"16px",padding:"12px",backgroundColor:"var(--bg-info-box)",borderRadius:"6px",border:"1px solid var(--border-info-box)",lineHeight:"1.6"},children:[u.jsx("strong",{children:"💡 智能故障切换机制"}),u.jsxs("div",{style:{marginTop:"6px"},children:["• 当同一请求类型配置多个规则时,系统会按排序优先使用第一个",u.jsx("br",{}),"• 如果某个服务报错(4xx/5xx)或请求超时,将自动切换到下一个可用服务",u.jsx("br",{}),"• 报错或超时的服务会被标记为不可用,有效期10分钟",u.jsx("br",{}),"• 10分钟后自动解除标记,如果再次报错或超时则重新标记",u.jsx("br",{}),"• 确保您的请求始终路由到稳定可用的服务",u.jsx("br",{}),"• 规则状态列会实时显示每个规则的可用性状态",u.jsx("br",{}),"• 如不需要此功能,可在",u.jsx("strong",{children:"设置"}),'页面关闭"启用智能故障切换"选项']})]})]}),g&&g.targetType==="claude-code"&&u.jsxs("div",{className:"card",children:[u.jsx("div",{className:"toolbar",children:u.jsx("h3",{children:"Claude Code 配置"})}),u.jsxs("div",{style:{padding:"20px"},children:[!B()&&((eb=Me==null?void 0:Me.claudeCode)==null?void 0:eb.version)&&u.jsxs("div",{style:{backgroundColor:"var(--bg-warning, #fff3cd)",border:"1px solid var(--border-warning, #ffc107)",borderRadius:"6px",padding:"12px",marginBottom:"12px",fontSize:"13px",color:"var(--text-warning, #856404)"},children:["⚠️ 当前 Claude Code 版本 (",Me.claudeCode.version,") 不支持 Agent Teams 功能。",u.jsx("br",{}),"Agent Teams 功能需要 Claude Code 版本 ≥ 2.1.32。请升级 Claude Code 后再使用此功能。"]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[u.jsx("input",{type:"checkbox",id:"agent-teams-toggle",checked:g.enableAgentTeams||!1,onChange:E=>T2(E.target.checked),disabled:!B(),style:{cursor:B()?"pointer":"not-allowed",width:"16px",height:"16px"}}),u.jsx("label",{htmlFor:"agent-teams-toggle",style:{cursor:B()?"pointer":"not-allowed",fontSize:"14px",userSelect:"none",color:B()?"inherit":"var(--text-muted)"},children:"开启 Agent Teams 功能"})]}),u.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginTop:"12px"},children:B()?g.isActive?"开启后将在 Claude Code 中启用 Agent Teams 实验性功能,已立即生效。":"开启后将在激活此路由时启用 Agent Teams 实验性功能。":"Agent Teams 功能需要 Claude Code 版本 ≥ 2.1.32。请升级 Claude Code 后再使用此功能。"})]})]})]})]})}),u.jsxs("div",{className:"card",style:{marginTop:"20px"},children:[u.jsx("div",{className:"toolbar",children:u.jsx("h3",{children:"📝 配置文件自动管理"})}),u.jsxs("div",{style:{padding:"20px",lineHeight:"1.8"},children:[u.jsxs("div",{style:{background:"var(--bg-info-blue)",padding:"15px",borderRadius:"8px",marginBottom:"15px",borderLeft:"4px solid var(--border-info-blue)"},children:[u.jsx("strong",{children:"💡 工作原理"}),u.jsx("p",{style:{marginTop:"8px",marginBottom:"0"},children:"激活路由时,系统会自动修改编程工具的配置文件,使其通过本代理服务器访问AI服务。 停用路由时,系统会自动恢复原始配置。"})]}),u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"15px"},children:[u.jsxs("div",{style:{background:"var(--bg-info-green)",padding:"15px",borderRadius:"8px",borderLeft:"4px solid var(--border-info-green)"},children:[u.jsx("strong",{children:"✓ 激活路由"}),u.jsxs("ul",{style:{marginTop:"8px",paddingLeft:"20px",marginBottom:"0"},children:[u.jsx("li",{children:"首次激活:自动备份并覆盖配置文件"}),u.jsx("li",{children:"再次激活:仅切换路由,不重复覆盖"})]})]}),u.jsxs("div",{style:{background:"var(--bg-info-orange)",padding:"15px",borderRadius:"8px",borderLeft:"4px solid var(--border-info-orange)"},children:[u.jsx("strong",{children:"○ 停用路由"}),u.jsxs("ul",{style:{marginTop:"8px",paddingLeft:"20px",marginBottom:"0"},children:[u.jsx("li",{children:"自动恢复原始配置文件"}),u.jsx("li",{children:"删除备份文件"})]})]})]}),u.jsxs("div",{style:{marginTop:"15px",padding:"12px 15px",background:"var(--bg-info-yellow)",borderRadius:"8px",borderLeft:"4px solid var(--border-info-yellow)"},children:[u.jsx("strong",{children:"⚠️ 重要提示"}),u.jsxs("ul",{style:{marginTop:"8px",paddingLeft:"20px",marginBottom:"0"},children:[u.jsxs("li",{children:["激活(首次)/停用路由后,",u.jsx("strong",{children:"必须重启对应的编程工具"}),"才能使配置生效"]}),u.jsx("li",{children:"操作前建议关闭编程工具,避免配置冲突"})]})]}),u.jsxs("details",{style:{marginTop:"15px",cursor:"pointer"},children:[u.jsx("summary",{style:{fontWeight:"bold",color:"#666"},children:"📂 配置文件位置(点击展开)"}),u.jsxs("ul",{style:{marginTop:"8px",paddingLeft:"20px",color:"#666"},children:[u.jsxs("li",{children:[u.jsx("strong",{children:"Claude Code:"})," ~/.claude/settings.json, ~/.claude.json"]}),u.jsxs("li",{children:[u.jsx("strong",{children:"Codex:"})," ~/.codex/config.toml, ~/.codex/auth.json"]})]})]})]})]}),x&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>v(!1),"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:S?"编辑路由":"新建路由"})}),u.jsxs("form",{onSubmit:S2,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"路由名称"}),u.jsx("input",{type:"text",name:"name",defaultValue:S?S.name:"",required:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"描述"}),u.jsx("textarea",{name:"description",rows:3,defaultValue:S?S.description:""})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"客户端工具"}),u.jsx("select",{name:"targetType",defaultValue:S?S.targetType:"claude-code",required:!0,children:Yh.map(E=>u.jsx("option",{value:E.value,children:E.label},E.value))})]}),u.jsxs("div",{className:"modal-footer",children:[u.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>v(!1),children:"取消"}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})})]}),b&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>w(!1),"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:j?"编辑规则":"新建规则"})}),u.jsxs("form",{onSubmit:k2,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"对象请求类型"}),u.jsx("select",{name:"contentType",value:D,required:!0,onChange:E=>{z(E.target.value)},children:I2().map(E=>u.jsx("option",{value:E.value,children:E.label},E.value))})]}),D==="high-iq"&&u.jsxs("div",{style:{background:"var(--bg-info-blue)",padding:"12px",borderRadius:"6px",borderLeft:"4px solid var(--border-info-blue)",marginBottom:"16px"},children:[u.jsx("div",{style:{fontSize:"13px",fontWeight:"bold",marginBottom:"6px"},children:"💡 高智商请求使用方法"}),u.jsxs("div",{style:{fontSize:"12px",color:"var(--text-muted)",lineHeight:"1.6"},children:["在编程工具中输入提示词时:",u.jsxs("ul",{style:{marginTop:"8px",paddingLeft:"20px",lineHeight:"1.8"},children:[u.jsxs("li",{children:["使用 ",u.jsx("code",{style:{background:"var(--bg-code-inline, #f5f5f5)",padding:"2px 6px",borderRadius:"3px",fontFamily:"monospace",fontSize:"12px"},children:"!!"})," 开启高智商模式(整个会话持续使用)"]}),u.jsxs("li",{children:["使用 ",u.jsx("code",{style:{background:"var(--bg-code-inline, #f5f5f5)",padding:"2px 6px",borderRadius:"3px",fontFamily:"monospace",fontSize:"12px"},children:"!x"})," 关闭高智商模式"]})]})]}),u.jsxs("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginTop:"8px",lineHeight:"1.6"},children:[u.jsx("strong",{children:"示例:"}),u.jsx("br",{}),"• ",u.jsx("code",{style:{background:"var(--bg-code-inline, #f5f5f5)",padding:"2px 6px",borderRadius:"3px",fontFamily:"monospace",fontSize:"12px"},children:"!! 重构A模块"}),u.jsx("br",{}),"• ",u.jsx("code",{style:{background:"var(--bg-code-inline, #f5f5f5)",padding:"2px 6px",borderRadius:"3px",fontFamily:"monospace",fontSize:"12px"},children:"!x 继续正常对话"})]})]}),D==="model-mapping"&&u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["被顶替模型 ",u.jsx("small",{children:"(可在日志中找出想要顶替的模型名)"})]}),u.jsx("input",{type:"text",value:L,onChange:E=>O(E.target.value),placeholder:"例如:gpt-4"})]}),D==="image-understanding"&&u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[u.jsx("input",{type:"checkbox",checked:be,onChange:E=>F(E.target.checked),style:{marginRight:"8px",cursor:"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"使用MCP"})]}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"开启后,将使用MCP工具处理图像理解请求,而不是直接调用API服务"})]}),D==="image-understanding"&&be&&u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["选择MCP工具 ",u.jsx("span",{className:"required",children:"*"})]}),u.jsx("div",{style:{maxHeight:"300px",overflowY:"auto",border:"1px solid var(--border-primary)",borderRadius:"6px",padding:"8px"},children:p.length===0?u.jsx("div",{style:{padding:"12px",textAlign:"center",color:"var(--text-muted)"},children:"暂无MCP工具,请先在MCP管理页面添加"}):p.map(E=>u.jsxs("div",{onClick:()=>ie(E.id),style:{padding:"12px",marginBottom:"8px",border:`2px solid ${ae===E.id?"var(--primary-color)":"var(--border-primary)"}`,borderRadius:"6px",cursor:"pointer",backgroundColor:ae===E.id?"var(--bg-info-blue)":"var(--bg-card)",transition:"all 0.2s ease"},children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[u.jsx("div",{style:{fontWeight:600,fontSize:"14px"},children:E.name}),u.jsx("div",{className:"badge badge-secondary",style:{fontSize:"11px"},children:E.type==="stdio"?"命令行":E.type.toUpperCase()})]}),E.description&&u.jsx("div",{style:{fontSize:"12px",color:"var(--text-muted)",marginTop:"4px"},children:E.description})]},E.id))})]}),!be&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商"}),u.jsxs("select",{value:T,onChange:E=>M(E.target.value),required:!0,children:[u.jsx("option",{value:"",disabled:!0,children:"请选择供应商"}),o.map(E=>u.jsx("option",{value:E.id,children:E.name},E.id))]})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商API服务"}),u.jsxs("select",{value:I,onChange:E=>{const X=E.target.value;_(X),V("");const me=s.find(ye=>ye.id===X);me&&(me.enableTokenLimit&&me.tokenLimit?(Y(me.tokenLimit),A(me.tokenResetInterval),ge(me.tokenResetBaseTime?new Date(me.tokenResetBaseTime):void 0),Gt(me.tokenLimit),$t(!0),$e(!0)):(Gt(void 0),$t(!1),$e(!1)),me.enableRequestLimit&&me.requestCountLimit?(W(me.requestCountLimit),se(me.requestResetInterval),_e(me.requestResetBaseTime?new Date(me.requestResetBaseTime):void 0),J(me.requestCountLimit),wt(!0),Ve(!0)):(J(void 0),wt(!1),Ve(!1)))},required:!0,disabled:!T,children:[u.jsx("option",{value:"",disabled:!0,children:"请选择API服务"}),d.map(E=>u.jsx("option",{value:E.id,children:E.name},E.id))]})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商模型"}),u.jsxs("select",{value:N,onChange:E=>V(E.target.value),disabled:!I,children:[u.jsx("option",{value:"",children:"透传模型名"}),(nb=(tb=s.find(E=>E.id===I))==null?void 0:tb.supportedModels)==null?void 0:nb.map(E=>u.jsx("option",{value:E,children:E},E))]})]}),u.jsx("div",{className:"form-group",children:u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:xt?"not-allowed":"pointer"},children:[u.jsx("input",{type:"checkbox",checked:Se,onChange:E=>$e(E.target.checked),disabled:xt,style:{marginRight:"8px",cursor:xt?"not-allowed":"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"启用Tokens超量限制"}),xt&&u.jsx("small",{style:{color:"#999",fontSize:"12px",marginLeft:"8px"},children:"(从API服务继承)"})]}),xt&&u.jsx("button",{type:"button",className:"btn btn-sm btn-secondary",onClick:()=>$t(!1),style:{padding:"4px 12px",fontSize:"12px"},children:"自定义限制"})]})}),Se&&!xt&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"Tokens超量(单位:k)"}),u.jsx("input",{type:"number",value:P||"",onChange:E=>{const X=E.target.value?parseInt(E.target.value):void 0;if(X!==void 0&&It!==void 0&&X>It){re.warning(`Token超量值不能超过API服务的限制 (${It}k)`);return}Y(X),xt&&X!==It&&$t(!1)},min:"0",max:It,placeholder:It?`最大 ${It}k`:"不限制",disabled:xt}),It&&u.jsxs("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:["⚠️ API服务限制:最大 ",It,"k,当前值不能超过此限制"]}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"当编程工具的请求tokens达到这个量时,在配置了其他规则的情况下,本条规则将失效,从而保护你的余额。例如:输入100表示100k即100,000个tokens"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"Tokens超量自动重置间隔(小时)"}),u.jsx("input",{type:"number",value:Z||"",onChange:E=>{A(E.target.value?parseInt(E.target.value):void 0),xt&&$t(!1)},min:"1",placeholder:"不自动重置",disabled:xt}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"设置后,系统将每隔指定小时数自动重置token计数。例如设置5小时,则每5小时重置一次"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"Token下一次重置时间基点"}),u.jsx("input",{type:"datetime-local",value:ue?yw(ue):"",onChange:E=>{E.target.value?ge(new Date(E.target.value)):ge(void 0),xt&&$t(!1)},disabled:!Z||xt,className:"datetime-picker-input"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:'配合"Tokens超量自动重置间隔"使用,设置下一次重置的精确时间点。例如,每月1日0点重置(间隔720小时),或每周一0点重置(间隔168小时)。设置后,系统会基于此时间点自动计算后续重置周期'})]})]}),u.jsx("div",{className:"form-group",children:u.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:bt?"not-allowed":"pointer"},children:[u.jsx("input",{type:"checkbox",checked:Ne,onChange:E=>Ve(E.target.checked),disabled:bt,style:{marginRight:"8px",cursor:bt?"not-allowed":"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"启用请求次数超量限制"}),bt&&u.jsx("small",{style:{color:"#999",fontSize:"12px",marginLeft:"8px"},children:"(从API服务继承)"})]}),bt&&u.jsx("button",{type:"button",className:"btn btn-sm btn-secondary",onClick:()=>wt(!1),style:{padding:"4px 12px",fontSize:"12px"},children:"自定义限制"})]})}),Ne&&!bt&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求次数超量"}),u.jsx("input",{type:"number",value:de||"",onChange:E=>{const X=E.target.value?parseInt(E.target.value):void 0;if(X!==void 0&&K!==void 0&&X>K){re.warning(`请求次数超量值不能超过API服务的限制 (${K})`);return}W(X),bt&&X!==K&&wt(!1)},min:"0",max:K,placeholder:K?`最大 ${K}`:"不限制",disabled:bt}),K&&u.jsxs("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:["⚠️ API服务限制:最大 ",K,",当前值不能超过此限制"]}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"当请求次数达到这个量时,在配置了其他规则的情况下,本条规则将失效"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求次数自动重置间隔(小时)"}),u.jsx("input",{type:"number",value:ne||"",onChange:E=>{se(E.target.value?parseInt(E.target.value):void 0),bt&&wt(!1)},min:"1",placeholder:"不自动重置",disabled:bt}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"设置后,系统将每隔指定小时数自动重置请求次数计数。例如设置24小时,则每24小时重置一次"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"下一次重置时间基点"}),u.jsx("input",{type:"datetime-local",value:q?yw(q):"",onChange:E=>{E.target.value?_e(new Date(E.target.value)):_e(void 0),bt&&wt(!1)},disabled:!ne||bt,className:"datetime-picker-input"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:'配合"请求次数自动重置间隔"使用,设置下一次重置的精确时间点。例如,每月1日0点重置(间隔720小时),或每周一0点重置(间隔168小时)。设置后,系统会基于此时间点自动计算后续重置周期'})]})]})]}),u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[u.jsx("input",{type:"checkbox",checked:!!Ce,onChange:E=>{E.target.checked?(ve(10),Pe(0)):(ve(void 0),Pe(void 0))},style:{marginRight:"8px",cursor:"pointer",width:"16px",height:"16px"}}),u.jsx("span",{children:"启用请求频率限制"})]}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"启用后,当同一内容类型的请求频率超过限制时,系统会自动切换到其他同类型规则"})]}),Ce&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"频率限制次数(并发数)"}),u.jsx("input",{type:"number",value:Ce||"",onChange:E=>ve(E.target.value?parseInt(E.target.value):void 0),min:"1",placeholder:"例如: 10"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"在指定时间窗口内允许的最大请求次数"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"频率限制时间窗口(秒,0=同一时刻)"}),u.jsx("input",{type:"number",value:we===0?0:we||"",onChange:E=>{const X=E.target.value?parseInt(E.target.value):void 0;Pe(X===0?0:X)},min:"0",placeholder:"0 表示同一时刻"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"时间窗口大小。0 表示同一时刻(并发数),持续累积;设置为 60 则在 60 秒内最多允许 N 次请求"})]})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"超时时间(秒)"}),u.jsx("input",{type:"number",value:H||"",onChange:E=>G(E.target.value?parseInt(E.target.value):void 0),min:"1",placeholder:"默认300秒"}),u.jsx("small",{style:{color:"#666",fontSize:"12px",marginTop:"4px",display:"block"},children:"设置此规则的API请求超时时间。不设置则使用默认值300秒(5分钟)"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"排序(值越大优先级越高)"}),u.jsx("input",{type:"number",value:R,onChange:E=>U(parseInt(E.target.value)||0),min:"0",max:"1000"})]}),u.jsxs("div",{className:"modal-footer",children:[u.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>w(!1),children:"取消"}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存"})]})]})]})})]})]})}var AE={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Go,function(){var n=1e3,r=6e4,i=36e5,a="millisecond",o="second",l="minute",s="hour",c="day",d="week",f="month",p="quarter",h="year",g="date",y="Invalid Date",x=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(L){var O=["th","st","nd","rd"],R=L%100;return"["+L+(O[(R-20)%10]||O[R]||O[0])+"]"}},w=function(L,O,R){var U=String(L);return!U||U.length>=O?L:""+Array(O+1-U.length).join(R)+L},S={s:w,z:function(L){var O=-L.utcOffset(),R=Math.abs(O),U=Math.floor(R/60),D=R%60;return(O<=0?"+":"-")+w(U,2,"0")+":"+w(D,2,"0")},m:function L(O,R){if(O.date()<R.date())return-L(R,O);var U=12*(R.year()-O.year())+(R.month()-O.month()),D=O.clone().add(U,f),z=R-D<0,P=O.clone().add(U+(z?-1:1),f);return+(-(U+(R-D)/(z?D-P:P-D))||0)},a:function(L){return L<0?Math.ceil(L)||0:Math.floor(L)},p:function(L){return{M:f,y:h,w:d,d:c,D:g,h:s,m:l,s:o,ms:a,Q:p}[L]||String(L||"").toLowerCase().replace(/s$/,"")},u:function(L){return L===void 0}},k="en",j={};j[k]=b;var C="$isDayjsObject",T=function(L){return L instanceof N||!(!L||!L[C])},M=function L(O,R,U){var D;if(!O)return k;if(typeof O=="string"){var z=O.toLowerCase();j[z]&&(D=z),R&&(j[z]=R,D=z);var P=O.split("-");if(!D&&P.length>1)return L(P[0])}else{var Y=O.name;j[Y]=O,D=Y}return!U&&D&&(k=D),D||!U&&k},I=function(L,O){if(T(L))return L.clone();var R=typeof O=="object"?O:{};return R.date=L,R.args=arguments,new N(R)},_=S;_.l=M,_.i=T,_.w=function(L,O){return I(L,{locale:O.$L,utc:O.$u,x:O.$x,$offset:O.$offset})};var N=function(){function L(R){this.$L=M(R.locale,null,!0),this.parse(R),this.$x=this.$x||R.x||{},this[C]=!0}var O=L.prototype;return O.parse=function(R){this.$d=function(U){var D=U.date,z=U.utc;if(D===null)return new Date(NaN);if(_.u(D))return new Date;if(D instanceof Date)return new Date(D);if(typeof D=="string"&&!/Z$/i.test(D)){var P=D.match(x);if(P){var Y=P[2]-1||0,Z=(P[7]||"0").substring(0,3);return z?new Date(Date.UTC(P[1],Y,P[3]||1,P[4]||0,P[5]||0,P[6]||0,Z)):new Date(P[1],Y,P[3]||1,P[4]||0,P[5]||0,P[6]||0,Z)}}return new Date(D)}(R),this.init()},O.init=function(){var R=this.$d;this.$y=R.getFullYear(),this.$M=R.getMonth(),this.$D=R.getDate(),this.$W=R.getDay(),this.$H=R.getHours(),this.$m=R.getMinutes(),this.$s=R.getSeconds(),this.$ms=R.getMilliseconds()},O.$utils=function(){return _},O.isValid=function(){return this.$d.toString()!==y},O.isSame=function(R,U){var D=I(R);return this.startOf(U)<=D&&D<=this.endOf(U)},O.isAfter=function(R,U){return I(R)<this.startOf(U)},O.isBefore=function(R,U){return this.endOf(U)<I(R)},O.$g=function(R,U,D){return _.u(R)?this[U]:this.set(D,R)},O.unix=function(){return Math.floor(this.valueOf()/1e3)},O.valueOf=function(){return this.$d.getTime()},O.startOf=function(R,U){var D=this,z=!!_.u(U)||U,P=_.p(R),Y=function(W,ne){var se=_.w(D.$u?Date.UTC(D.$y,ne,W):new Date(D.$y,ne,W),D);return z?se:se.endOf(c)},Z=function(W,ne){return _.w(D.toDate()[W].apply(D.toDate("s"),(z?[0,0,0,0]:[23,59,59,999]).slice(ne)),D)},A=this.$W,ue=this.$M,ge=this.$D,H="set"+(this.$u?"UTC":"");switch(P){case h:return z?Y(1,0):Y(31,11);case f:return z?Y(1,ue):Y(0,ue+1);case d:var G=this.$locale().weekStart||0,de=(A<G?A+7:A)-G;return Y(z?ge-de:ge+(6-de),ue);case c:case g:return Z(H+"Hours",0);case s:return Z(H+"Minutes",1);case l:return Z(H+"Seconds",2);case o:return Z(H+"Milliseconds",3);default:return this.clone()}},O.endOf=function(R){return this.startOf(R,!1)},O.$set=function(R,U){var D,z=_.p(R),P="set"+(this.$u?"UTC":""),Y=(D={},D[c]=P+"Date",D[g]=P+"Date",D[f]=P+"Month",D[h]=P+"FullYear",D[s]=P+"Hours",D[l]=P+"Minutes",D[o]=P+"Seconds",D[a]=P+"Milliseconds",D)[z],Z=z===c?this.$D+(U-this.$W):U;if(z===f||z===h){var A=this.clone().set(g,1);A.$d[Y](Z),A.init(),this.$d=A.set(g,Math.min(this.$D,A.daysInMonth())).$d}else Y&&this.$d[Y](Z);return this.init(),this},O.set=function(R,U){return this.clone().$set(R,U)},O.get=function(R){return this[_.p(R)]()},O.add=function(R,U){var D,z=this;R=Number(R);var P=_.p(U),Y=function(ue){var ge=I(z);return _.w(ge.date(ge.date()+Math.round(ue*R)),z)};if(P===f)return this.set(f,this.$M+R);if(P===h)return this.set(h,this.$y+R);if(P===c)return Y(1);if(P===d)return Y(7);var Z=(D={},D[l]=r,D[s]=i,D[o]=n,D)[P]||1,A=this.$d.getTime()+R*Z;return _.w(A,this)},O.subtract=function(R,U){return this.add(-1*R,U)},O.format=function(R){var U=this,D=this.$locale();if(!this.isValid())return D.invalidDate||y;var z=R||"YYYY-MM-DDTHH:mm:ssZ",P=_.z(this),Y=this.$H,Z=this.$m,A=this.$M,ue=D.weekdays,ge=D.months,H=D.meridiem,G=function(ne,se,q,_e){return ne&&(ne[se]||ne(U,z))||q[se].slice(0,_e)},de=function(ne){return _.s(Y%12||12,ne,"0")},W=H||function(ne,se,q){var _e=ne<12?"AM":"PM";return q?_e.toLowerCase():_e};return z.replace(v,function(ne,se){return se||function(q){switch(q){case"YY":return String(U.$y).slice(-2);case"YYYY":return _.s(U.$y,4,"0");case"M":return A+1;case"MM":return _.s(A+1,2,"0");case"MMM":return G(D.monthsShort,A,ge,3);case"MMMM":return G(ge,A);case"D":return U.$D;case"DD":return _.s(U.$D,2,"0");case"d":return String(U.$W);case"dd":return G(D.weekdaysMin,U.$W,ue,2);case"ddd":return G(D.weekdaysShort,U.$W,ue,3);case"dddd":return ue[U.$W];case"H":return String(Y);case"HH":return _.s(Y,2,"0");case"h":return de(1);case"hh":return de(2);case"a":return W(Y,Z,!0);case"A":return W(Y,Z,!1);case"m":return String(Z);case"mm":return _.s(Z,2,"0");case"s":return String(U.$s);case"ss":return _.s(U.$s,2,"0");case"SSS":return _.s(U.$ms,3,"0");case"Z":return P}return null}(ne)||P.replace(":","")})},O.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},O.diff=function(R,U,D){var z,P=this,Y=_.p(U),Z=I(R),A=(Z.utcOffset()-this.utcOffset())*r,ue=this-Z,ge=function(){return _.m(P,Z)};switch(Y){case h:z=ge()/12;break;case f:z=ge();break;case p:z=ge()/3;break;case d:z=(ue-A)/6048e5;break;case c:z=(ue-A)/864e5;break;case s:z=ue/i;break;case l:z=ue/r;break;case o:z=ue/n;break;default:z=ue}return D?z:_.a(z)},O.daysInMonth=function(){return this.endOf(f).$D},O.$locale=function(){return j[this.$L]},O.locale=function(R,U){if(!R)return this.$L;var D=this.clone(),z=M(R,U,!0);return z&&(D.$L=z),D},O.clone=function(){return _.w(this.$d,this)},O.toDate=function(){return new Date(this.valueOf())},O.toJSON=function(){return this.isValid()?this.toISOString():null},O.toISOString=function(){return this.$d.toISOString()},O.toString=function(){return this.$d.toUTCString()},L}(),V=N.prototype;return I.prototype=V,[["$ms",a],["$s",o],["$m",l],["$H",s],["$W",c],["$M",f],["$y",h],["$D",g]].forEach(function(L){V[L[1]]=function(O){return this.$g(O,L[0],L[1])}}),I.extend=function(L,O){return L.$i||(L(O,N,I),L.$i=!0),I},I.locale=M,I.isDayjs=T,I.unix=function(L){return I(1e3*L)},I.en=j[k],I.Ls=j,I.p={},I})})(AE);var yB=AE.exports;const on=Vn(yB);var TE={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(Go,function(){return function(n,r,i){n=n||{};var a=r.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function l(c,d,f,p){return a.fromToBase(c,d,f,p)}i.en.relativeTime=o,a.fromToBase=function(c,d,f,p,h){for(var g,y,x,v=f.$locale().relativeTime||o,b=n.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],w=b.length,S=0;S<w;S+=1){var k=b[S];k.d&&(g=p?i(c).diff(f,k.d,!0):f.diff(c,k.d,!0));var j=(n.rounding||Math.round)(Math.abs(g));if(x=g>0,j<=k.r||!k.r){j<=1&&S>0&&(k=b[S-1]);var C=v[k.l];h&&(j=h(""+j)),y=typeof C=="string"?C.replace("%d",j):C(j,d,k.l,x);break}}if(d)return y;var T=x?v.future:v.past;return typeof T=="function"?T(y):T.replace("%s",y)},a.to=function(c,d){return l(c,d,this,!0)},a.from=function(c,d){return l(c,d,this)};var s=function(c){return c.$u?i.utc():i()};a.toNow=function(c){return this.to(s(this),c)},a.fromNow=function(c){return this.from(s(this),c)}}})})(TE);var xB=TE.exports;const bB=Vn(xB),wB=["authorization","x-api-key","api-key","apikey","x-auth-token","auth-token","secret","password","api_secret","jwt","csrf_token","xsrf_token","auth_token","session_token","private_key","client_secret"],SB=e=>{const t=e.toLowerCase();return!!(wB.some(n=>t===n)||t.startsWith("api_")&&(t.endsWith("_key")||t.endsWith("_secret"))||(t.endsWith("_token")||t.endsWith("_key")||t.endsWith("_secret"))&&!["max_tokens","input_tokens","output_tokens","completion_tokens","prompt_tokens","cachereadinputtokens","totaltokens"].some(r=>t.replace(/_/g,"").includes(r.replace(/_/g,""))))},jB=e=>!e||e.length<=8?"***":`${e.slice(0,4)}${"*".repeat(Math.min(e.length-8,20))}${e.slice(-4)}`,Ig=e=>{if(e==null)return e;if(Array.isArray(e))return e.map(t=>Ig(t));if(typeof e=="object"){const t={};for(const[n,r]of Object.entries(e))SB(n)?t[n]=typeof r=="string"?jB(r):"***":typeof r=="object"?t[n]=Ig(r):t[n]=r;return t}return e},pr=({data:e,title:t,collapsed:n=!1})=>{const[r,i]=m.useState(!n),[a,o]=m.useState(!1),l=d=>{try{let f;typeof d=="string"?f=JSON.parse(d):f=d;const p=Ig(f);return JSON.stringify(p,null,2)}catch{return typeof d=="string"?d:String(d)}},s=()=>{const d=l(e);navigator.clipboard.writeText(d).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)}).catch(f=>{console.error("Failed to copy JSON:",f)})},c=l(e);return u.jsxs("div",{className:"json-viewer",children:[u.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[t&&u.jsx("h4",{style:{margin:0,fontSize:"14px",color:"var(--text-primary)"},children:t}),u.jsxs("div",{style:{display:"flex",gap:"8px"},children:[u.jsx("button",{onClick:()=>i(!r),className:"btn btn-sm btn-secondary",style:{fontSize:"12px",padding:"2px 8px"},children:r?"折叠":"展开"}),u.jsx("button",{onClick:s,className:"btn btn-sm btn-primary",style:{fontSize:"12px",padding:"2px 8px"},children:a?"已复制":"复制"})]})]}),r&&u.jsx("pre",{style:{background:"var(--bg-code)",border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"12px",overflowX:"auto",fontSize:"12px",lineHeight:"1.4",color:"var(--text-primary)",maxHeight:"400px",overflowY:"auto",margin:0},children:u.jsx("code",{children:c})})]})},Xh=({currentPage:e,totalItems:t,pageSize:n,onPageChange:r,onPageSizeChange:i,pageSizeOptions:a=[10,20,50,100]})=>{const o=Math.max(1,Math.ceil(t/n)),l=e===1,s=e>=o,c=()=>{l||r(1)},d=()=>{l||r(e-1)},f=()=>{s||r(e+1)},p=()=>{s||r(o)},h=g=>{const y=parseInt(g.target.value,10);i(y)};return u.jsxs("div",{className:"pagination",children:[u.jsxs("div",{className:"pagination-info",children:["共 ",t," 条"]}),u.jsxs("div",{className:"pagination-controls",children:[u.jsx("button",{className:"pagination-btn",onClick:c,disabled:l,children:"首页"}),u.jsx("button",{className:"pagination-btn",onClick:d,disabled:l,children:"上一页"}),u.jsxs("span",{className:"pagination-info",children:["第 ",e," / ",o," 页"]}),u.jsx("button",{className:"pagination-btn",onClick:f,disabled:s,children:"下一页"}),u.jsx("button",{className:"pagination-btn",onClick:p,disabled:s,children:"尾页"})]}),u.jsx("div",{className:"pagination-size",children:u.jsxs("label",{children:["每页显示",u.jsx("select",{className:"pagination-select",value:n,onChange:h,children:a.map(g=>u.jsx("option",{value:g,children:g},g))}),"条"]})})]})};on.extend(bB);function kB(e){const t=[];let n={dataLines:[],rawLines:[]};for(const r of e){const i=r.split(`
123
123
  `);for(const a of i){if(n.rawLines.push(a),!a.trim()){if(n.event||n.dataLines.length>0){const o=n.dataLines.length>0?n.dataLines.join(`
124
124
  `):void 0,l={event:n.event,raw:n.rawLines.join(`
125
125
  `)};if(o)try{l.data=JSON.parse(o)}catch{l.data=o}t.push(l)}n={dataLines:[],rawLines:[]};continue}a.startsWith("event:")?n.event=a.slice(6).trim():a.startsWith("data:")&&n.dataLines.push(a.slice(5).trim())}}if(n.event||n.dataLines.length>0){const r=n.dataLines.length>0?n.dataLines.join(`
@@ -131,10 +131,10 @@ Error generating stack: `+a.message+`
131
131
  2. 相关的统计数据也会被清空
132
132
  3. 此操作不可撤销
133
133
 
134
- 是否继续?`,title:"确认清空全部日志",type:"danger",confirmText:"确认清空",cancelText:"取消"}))try{await Promise.all([Q.clearLogs(),Q.clearErrorLogs(),Q.clearSessions()]),i([]),s(null),L(1),D(0),o([]),d(null),P(1),ue(0),x([]),b(null),S([]),T(1),j(0),re.success("所有日志已清空")}catch(Ct){console.error("清空日志失败:",Ct),re.error("清空日志失败,请重试")}},le=B=>B?B>=200&&B<300?"badge-success":B>=400&&B<500?"badge-warning":"badge-danger":"badge-danger",ie=B=>{Mn(B),xt(""),bt("")},Se=B=>{xt(B),bt("")},$e=()=>Pe?_e.filter(B=>B.vendorId===Pe):[],Ne=()=>{if(!Pt)return[];const B=_e.find(Ae=>Ae.id===Pt);return(B==null?void 0:B.supportedModels)||[]},Me=(B=>B.filter(Ae=>!(ve&&Ae.targetType!==ve||Pe&&Ae.vendorId!==Pe||Pt&&Ae.targetServiceId!==Pt||$t&&Ae.targetModel!==$t)))(r),Sa=B=>{L(B)},ja=B=>{R(B),L(1)},Ol=B=>{P(B)},Tr=B=>{Z(B),P(1)},_t=B=>{T(B)},Ii=B=>{I(B),T(1)},ka=async B=>{b(B),N(!0);try{const Ae=await Q.getSessionLogs(B.id,100);S(Ae)}catch(Ae){console.error("Failed to load session logs:",Ae)}finally{N(!1)}},Gn=(B,Ae)=>{const Ct=Ae-B;return Ct<6e4?`${Math.floor(Ct/1e3)}秒`:Ct<36e5?`${Math.floor(Ct/6e4)}分钟`:`${Math.floor(Ct/36e5)}小时`},ho=B=>B==="claude-code"?u.jsx("span",{className:"badge badge-claude-code",children:"Claude Code"}):B==="codex"?u.jsx("span",{className:"badge badge-codex",children:"Codex"}):u.jsx("span",{className:"badge",children:B}),_i=()=>y.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无会话记录"})}):u.jsxs("table",{children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"标题"}),u.jsx("th",{children:"客户端类型"}),u.jsx("th",{children:"请求数"}),u.jsx("th",{children:"Tokens"}),u.jsx("th",{children:"首次请求"}),u.jsx("th",{children:"最后请求"}),u.jsx("th",{children:"时长"}),u.jsx("th",{children:"操作"})]})}),u.jsx("tbody",{children:y.map(B=>u.jsxs("tr",{onClick:()=>ka(B),style:{cursor:"pointer",backgroundColor:(v==null?void 0:v.id)===B.id?"var(--bg-selected)":void 0},children:[u.jsx("td",{style:{maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B.title||B.id.slice(0,8)}),u.jsx("td",{children:ho(B.targetType)}),u.jsx("td",{children:B.requestCount}),u.jsx("td",{children:B.totalTokens.toLocaleString()}),u.jsx("td",{children:on(B.firstRequestAt).format("MM-DD HH:mm")}),u.jsx("td",{children:on(B.lastRequestAt).format("MM-DD HH:mm")}),u.jsx("td",{children:Gn(B.firstRequestAt,B.lastRequestAt)}),u.jsx("td",{children:u.jsx("button",{className:"btn btn-sm btn-secondary",onClick:Ae=>{Ae.stopPropagation(),ka(B)},children:"查看"})})]},B.id))})]}),lh=()=>Me.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无请求日志"})}):u.jsxs("table",{children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"时间"}),u.jsx("th",{children:"客户端类型"}),u.jsx("th",{children:"路径"}),u.jsx("th",{children:"状态"}),u.jsx("th",{children:"响应时间"}),u.jsx("th",{children:"Tokens信息"}),u.jsx("th",{children:"操作"})]})}),u.jsx("tbody",{children:Me.map(B=>u.jsxs("tr",{children:[u.jsx("td",{children:on(B.timestamp).format("YYYY-MM-DD HH:mm:ss")}),u.jsx("td",{children:ac[B.targetType]?u.jsx("span",{className:`badge ${B.targetType==="claude-code"?"badge-claude-code":B.targetType==="codex"?"badge-codex":"badge-info"}`,children:ac[B.targetType]}):"-"}),u.jsx("td",{children:B.path}),u.jsx("td",{children:u.jsx("span",{className:`badge ${le(B.statusCode)}`,children:B.statusCode||"Error"})}),u.jsx("td",{children:B.responseTime?`${B.responseTime}ms`:"-"}),u.jsx("td",{children:B.usage?u.jsxs("span",{children:[B.usage.totalTokens?B.usage.totalTokens:B.usage.inputTokens+B.usage.outputTokens," tokens"]}):"-"}),u.jsx("td",{children:u.jsx("button",{className:"btn btn-secondary",onClick:()=>s(B),children:"详情"})})]},B.id))})]}),sh=()=>a.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无错误日志"})}):u.jsxs("table",{children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"时间"}),u.jsx("th",{children:"方法"}),u.jsx("th",{children:"路径"}),u.jsx("th",{children:"状态"}),u.jsx("th",{children:"错误信息"}),u.jsx("th",{children:"操作"})]})}),u.jsx("tbody",{children:a.map(B=>u.jsxs("tr",{children:[u.jsx("td",{children:on(B.timestamp).format("YYYY-MM-DD HH:mm:ss")}),u.jsx("td",{children:u.jsx("span",{className:"badge badge-danger",children:B.method})}),u.jsx("td",{children:B.path}),u.jsx("td",{children:u.jsx("span",{className:"badge badge-danger",children:B.statusCode||"-"})}),u.jsx("td",{style:{maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#e74c3c"},children:B.errorMessage}),u.jsx("td",{children:u.jsx("button",{className:"btn btn-secondary",onClick:()=>d(B),children:"详情"})})]},B.id))})]});return u.jsxs("div",{className:"logs-page",children:[u.jsx("div",{className:"page-header",children:u.jsxs("div",{className:"page-header-content",children:[u.jsxs("div",{className:"page-header-text",children:[u.jsx("h1",{children:"日志"}),u.jsx("p",{children:"查看所有API请求日志"})]}),u.jsx("button",{className:"btn btn-danger",onClick:F,children:"清空全部日志"})]})}),u.jsxs("div",{className:"card",children:[u.jsx("div",{style:{borderBottom:"1px solid #ecf0f1",marginBottom:"20px"},children:u.jsxs("div",{style:{display:"flex",gap:"0"},children:[u.jsxs("button",{onClick:()=>n("request"),style:{padding:"12px 24px",border:"none",background:t==="request"?"#3498db":"transparent",color:t==="request"?"white":"#7f8c8d",cursor:"pointer",borderBottom:t==="request"?"2px solid #2980b9":"2px solid transparent",fontWeight:t==="request"?"bold":"normal"},children:["请求日志 (",U,")"]}),u.jsxs("button",{onClick:()=>n("error"),style:{padding:"12px 24px",border:"none",background:t==="error"?"#e74c3c":"transparent",color:t==="error"?"white":"#7f8c8d",cursor:"pointer",borderBottom:t==="error"?"2px solid #c0392b":"2px solid transparent",fontWeight:t==="error"?"bold":"normal"},children:["错误日志 (",A,")"]}),u.jsxs("button",{onClick:()=>n("sessions"),style:{padding:"12px 24px",border:"none",background:t==="sessions"?"#9b59b6":"transparent",color:t==="sessions"?"white":"#7f8c8d",cursor:"pointer",borderBottom:t==="sessions"?"2px solid #8e44ad":"2px solid transparent",fontWeight:t==="sessions"?"bold":"normal"},children:["会话 (",k,")"]})]})}),u.jsxs("div",{className:"toolbar",children:[u.jsxs("h3",{children:[t==="error"&&"错误日志列表",t==="request"&&"请求日志列表",t==="sessions"&&"会话列表"]}),u.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center"},children:[t==="request"&&u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("input",{type:"text",placeholder:"搜索日志内容...",value:wt,onChange:B=>{It(B.target.value),L(1)},onKeyDown:B=>{B.key==="Enter"&&xe()},style:{padding:"6px 12px",borderRadius:"8px",border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-primary)",width:"200px",fontSize:"14px"}}),wt&&u.jsx("button",{onClick:()=>{It(""),L(1)},style:{padding:"6px 10px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px"},children:"清除"})]}),t==="error"&&u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("input",{type:"text",placeholder:"搜索错误日志...",value:Gt,onChange:B=>{K(B.target.value),P(1)},onKeyDown:B=>{B.key==="Enter"&&xe()},style:{padding:"6px 12px",borderRadius:"8px",border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-primary)",width:"200px",fontSize:"14px"}}),Gt&&u.jsx("button",{onClick:()=>{K(""),P(1)},style:{padding:"6px 10px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px"},children:"清除"})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"0 12px",background:"var(--bg-secondary)",borderRadius:"8px"},children:[u.jsx("input",{type:"checkbox",id:"auto-refresh",checked:G,onChange:B=>{de(B.target.checked),B.target.checked&&ne(10)},style:{cursor:"pointer"}}),u.jsxs("label",{htmlFor:"auto-refresh",style:{cursor:"pointer",fontSize:"14px",color:"var(--text-primary)",userSelect:"none"},children:["自动刷新 ",G&&`(⏱ ${W}s)`]})]}),u.jsx("button",{className:"btn btn-primary",onClick:()=>{xe(),be(),ne(10)},children:"刷新"})]})]}),t==="request"&&u.jsxs("div",{style:{padding:"15px",background:"var(--bg-secondary)",borderRadius:"12px",marginBottom:"20px",display:"flex",gap:"15px",alignItems:"center",flexWrap:"wrap",border:"1px solid var(--border-primary)"},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"来源类型:"}),u.jsxs("select",{value:ve,onChange:B=>we(B.target.value),style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-primary)"},children:[u.jsx("option",{value:"",children:"全部"}),u.jsx("option",{value:"claude-code",children:"Claude Code"}),u.jsx("option",{value:"codex",children:"Codex"})]})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"供应商:"}),u.jsxs("select",{value:Pe,onChange:B=>ie(B.target.value),style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",minWidth:"150px",background:"var(--bg-card)",color:"var(--text-primary)"},children:[u.jsx("option",{value:"",children:"全部供应商"}),se.map(B=>u.jsx("option",{value:B.id,children:B.name},B.id))]})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"API服务:"}),u.jsxs("select",{value:Pt,onChange:B=>Se(B.target.value),disabled:!Pe,style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",minWidth:"150px",background:Pe?"var(--bg-card)":"var(--bg-secondary)",color:"var(--text-primary)",cursor:Pe?"pointer":"not-allowed",opacity:Pe?1:.6},children:[u.jsx("option",{value:"",children:"全部服务"}),$e().map(B=>u.jsx("option",{value:B.id,children:B.name},B.id))]})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"模型:"}),u.jsxs("select",{value:$t,onChange:B=>bt(B.target.value),disabled:!Pt,style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",minWidth:"150px",background:Pt?"var(--bg-card)":"var(--bg-secondary)",color:"var(--text-primary)",cursor:Pt?"pointer":"not-allowed",opacity:Pt?1:.6},children:[u.jsx("option",{value:"",children:"全部模型"}),Ne().map(B=>u.jsx("option",{value:B,children:B},B))]})]}),(ve||Pe||Pt||$t)&&u.jsx("button",{onClick:()=>{we(""),Mn(""),xt(""),bt("")},style:{padding:"6px 12px",borderRadius:"8px",border:"1px solid var(--accent-danger)",background:"var(--accent-danger)",color:"white",cursor:"pointer",fontSize:"14px"},children:"清除筛选"}),u.jsxs("div",{style:{marginLeft:"auto",color:"var(--text-muted)",fontSize:"14px"},children:["显示 ",Me.length," / ",r.length," 条"]})]}),t==="request"&&u.jsxs(u.Fragment,{children:[ge?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"加载中..."})}):lh(),!ge&&u.jsx(Xh,{currentPage:V,totalItems:U,pageSize:O,onPageChange:Sa,onPageSizeChange:ja})]}),t==="error"&&u.jsxs(u.Fragment,{children:[ge?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"加载中..."})}):sh(),!ge&&u.jsx(Xh,{currentPage:z,totalItems:A,pageSize:Y,onPageChange:Ol,onPageSizeChange:Tr})]}),t==="sessions"&&u.jsxs(u.Fragment,{children:[ge?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"加载中..."})}):_i(),!ge&&u.jsx(Xh,{currentPage:C,totalItems:k,pageSize:M,onPageChange:_t,onPageSizeChange:Ii})]})]}),l&&u.jsxs("div",{className:"modal-overlay",style:{zIndex:J},children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>s(null),"aria-label":"关闭",style:{zIndex:J+1},children:"×"}),u.jsx("div",{className:"modal",style:{width:"800px",zIndex:J},children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:"请求详情"})}),u.jsxs("div",{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"日志ID"}),u.jsx("input",{type:"text",value:l.id,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"时间"}),u.jsx("input",{type:"text",value:on(l.timestamp).format("YYYY-MM-DD HH:mm:ss"),readOnly:!0})]}),l.targetType&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"客户端类型"}),u.jsx("input",{type:"text",value:ac[l.targetType]||"-",readOnly:!0})]}),l.requestModel&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求模型"}),u.jsx("input",{type:"text",value:l.requestModel,readOnly:!0})]}),l.vendorName&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商"}),u.jsx("input",{type:"text",value:l.vendorName,readOnly:!0})]}),l.targetServiceName&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商API服务"}),u.jsx("input",{type:"text",value:l.targetServiceName,readOnly:!0})]}),l.targetModel&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商模型"}),u.jsx("input",{type:"text",value:l.targetModel,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求方法"}),u.jsx("input",{type:"text",value:l.method,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求路径"}),u.jsx("input",{type:"text",value:l.path,readOnly:!0})]}),l.headers&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求头"}),u.jsx(pr,{data:l.headers,collapsed:!0})]}),l.body&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求体"}),u.jsx(pr,{data:l.body})]}),l.upstreamRequest&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"实际转发信息"}),u.jsx(pr,{data:l.upstreamRequest})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"状态码"}),u.jsx("input",{type:"text",value:l.statusCode||"Error",readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应时间"}),u.jsx("input",{type:"text",value:l.responseTime?`${l.responseTime}ms`:"-",readOnly:!0})]}),l.responseHeaders&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应头"}),u.jsx(pr,{data:l.responseHeaders,collapsed:!0})]}),(()=>{const B=CB(l);return console.log("[RequestLogDetail] assembledBody:",B),B?u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应体"}),u.jsx(pr,{data:B})]}):u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应体"}),u.jsxs("div",{style:{padding:"10px",color:"#7f8c8d",fontStyle:"italic"},children:["无响应体数据",l.streamChunks===void 0&&l.responseBody===void 0&&u.jsx("div",{style:{marginTop:"5px",fontSize:"12px",color:"#e74c3c"},children:"⚠️ 该日志不包含响应数据(可能是旧版本记录)"})]})]})})(),l.streamChunks&&l.streamChunks.length>0&&u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["Stream Chunks (",l.streamChunks.length,"个)",u.jsx("button",{onClick:()=>p(!f),style:{marginLeft:"10px",padding:"2px 8px",fontSize:"12px"},className:"btn btn-sm btn-secondary",children:f?"折叠":"展开"}),u.jsx("button",{onClick:()=>g(!h),style:{marginLeft:"5px",padding:"2px 8px",fontSize:"12px"},className:"btn btn-sm btn-primary",children:h?"隐藏拼装结果":"查看拼装结果"})]}),f&&u.jsx("div",{style:{maxHeight:"400px",overflowY:"auto",border:"1px solid #ddd",padding:"10px",borderRadius:"4px"},children:l.streamChunks.map((B,Ae)=>u.jsxs("div",{style:{marginBottom:"10px"},children:[u.jsxs("div",{style:{fontWeight:"bold",fontSize:"12px",color:"#7f8c8d",marginBottom:"4px"},children:["Chunk #",Ae+1]}),u.jsx(pr,{data:B,collapsed:!0})]},Ae))}),h&&u.jsx("div",{style:{marginTop:"10px",maxHeight:"400px",overflowY:"auto",border:"1px solid var(--border-secondary)",padding:"10px",borderRadius:"4px",backgroundColor:"var(--bg-assembled-text)"},children:u.jsx(AB,{chunks:l.streamChunks,targetType:l.targetType})})]}),l.usage&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"Token 使用"}),u.jsx("textarea",{rows:4,value:`输入: ${l.usage.inputTokens}
134
+ 是否继续?`,title:"确认清空全部日志",type:"danger",confirmText:"确认清空",cancelText:"取消"}))try{await Promise.all([Q.clearLogs(),Q.clearErrorLogs(),Q.clearSessions()]),i([]),s(null),L(1),D(0),o([]),d(null),P(1),ue(0),x([]),b(null),S([]),T(1),j(0),re.success("所有日志已清空")}catch(Ct){console.error("清空日志失败:",Ct),re.error("清空日志失败,请重试")}},ae=B=>B?B>=200&&B<300?"badge-success":B>=400&&B<500?"badge-warning":"badge-danger":"badge-danger",ie=B=>{Mn(B),xt(""),bt("")},Se=B=>{xt(B),bt("")},$e=()=>Pe?_e.filter(B=>B.vendorId===Pe):[],Ne=()=>{if(!Pt)return[];const B=_e.find(Ae=>Ae.id===Pt);return(B==null?void 0:B.supportedModels)||[]},Me=(B=>B.filter(Ae=>!(ve&&Ae.targetType!==ve||Pe&&Ae.vendorId!==Pe||Pt&&Ae.targetServiceId!==Pt||$t&&Ae.targetModel!==$t)))(r),Sa=B=>{L(B)},ja=B=>{R(B),L(1)},Ol=B=>{P(B)},Tr=B=>{Z(B),P(1)},_t=B=>{T(B)},Ii=B=>{I(B),T(1)},ka=async B=>{b(B),N(!0);try{const Ae=await Q.getSessionLogs(B.id,100);S(Ae)}catch(Ae){console.error("Failed to load session logs:",Ae)}finally{N(!1)}},Gn=(B,Ae)=>{const Ct=Ae-B;return Ct<6e4?`${Math.floor(Ct/1e3)}秒`:Ct<36e5?`${Math.floor(Ct/6e4)}分钟`:`${Math.floor(Ct/36e5)}小时`},ho=B=>B==="claude-code"?u.jsx("span",{className:"badge badge-claude-code",children:"Claude Code"}):B==="codex"?u.jsx("span",{className:"badge badge-codex",children:"Codex"}):u.jsx("span",{className:"badge",children:B}),_i=()=>y.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无会话记录"})}):u.jsxs("table",{children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"标题"}),u.jsx("th",{children:"客户端类型"}),u.jsx("th",{children:"请求数"}),u.jsx("th",{children:"Tokens"}),u.jsx("th",{children:"首次请求"}),u.jsx("th",{children:"最后请求"}),u.jsx("th",{children:"时长"}),u.jsx("th",{children:"操作"})]})}),u.jsx("tbody",{children:y.map(B=>u.jsxs("tr",{onClick:()=>ka(B),style:{cursor:"pointer",backgroundColor:(v==null?void 0:v.id)===B.id?"var(--bg-selected)":void 0},children:[u.jsx("td",{style:{maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B.title||B.id.slice(0,8)}),u.jsx("td",{children:ho(B.targetType)}),u.jsx("td",{children:B.requestCount}),u.jsx("td",{children:B.totalTokens.toLocaleString()}),u.jsx("td",{children:on(B.firstRequestAt).format("MM-DD HH:mm")}),u.jsx("td",{children:on(B.lastRequestAt).format("MM-DD HH:mm")}),u.jsx("td",{children:Gn(B.firstRequestAt,B.lastRequestAt)}),u.jsx("td",{children:u.jsx("button",{className:"btn btn-sm btn-secondary",onClick:Ae=>{Ae.stopPropagation(),ka(B)},children:"查看"})})]},B.id))})]}),lh=()=>Me.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无请求日志"})}):u.jsxs("table",{children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"时间"}),u.jsx("th",{children:"客户端类型"}),u.jsx("th",{children:"路径"}),u.jsx("th",{children:"状态"}),u.jsx("th",{children:"响应时间"}),u.jsx("th",{children:"Tokens信息"}),u.jsx("th",{children:"操作"})]})}),u.jsx("tbody",{children:Me.map(B=>u.jsxs("tr",{children:[u.jsx("td",{children:on(B.timestamp).format("YYYY-MM-DD HH:mm:ss")}),u.jsx("td",{children:ac[B.targetType]?u.jsx("span",{className:`badge ${B.targetType==="claude-code"?"badge-claude-code":B.targetType==="codex"?"badge-codex":"badge-info"}`,children:ac[B.targetType]}):"-"}),u.jsx("td",{children:B.path}),u.jsx("td",{children:u.jsx("span",{className:`badge ${ae(B.statusCode)}`,children:B.statusCode||"Error"})}),u.jsx("td",{children:B.responseTime?`${B.responseTime}ms`:"-"}),u.jsx("td",{children:B.usage?u.jsxs("span",{children:[B.usage.totalTokens?B.usage.totalTokens:B.usage.inputTokens+B.usage.outputTokens," tokens"]}):"-"}),u.jsx("td",{children:u.jsx("button",{className:"btn btn-secondary",onClick:()=>s(B),children:"详情"})})]},B.id))})]}),sh=()=>a.length===0?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"暂无错误日志"})}):u.jsxs("table",{children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"时间"}),u.jsx("th",{children:"方法"}),u.jsx("th",{children:"路径"}),u.jsx("th",{children:"状态"}),u.jsx("th",{children:"错误信息"}),u.jsx("th",{children:"操作"})]})}),u.jsx("tbody",{children:a.map(B=>u.jsxs("tr",{children:[u.jsx("td",{children:on(B.timestamp).format("YYYY-MM-DD HH:mm:ss")}),u.jsx("td",{children:u.jsx("span",{className:"badge badge-danger",children:B.method})}),u.jsx("td",{children:B.path}),u.jsx("td",{children:u.jsx("span",{className:"badge badge-danger",children:B.statusCode||"-"})}),u.jsx("td",{style:{maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#e74c3c"},children:B.errorMessage}),u.jsx("td",{children:u.jsx("button",{className:"btn btn-secondary",onClick:()=>d(B),children:"详情"})})]},B.id))})]});return u.jsxs("div",{className:"logs-page",children:[u.jsx("div",{className:"page-header",children:u.jsxs("div",{className:"page-header-content",children:[u.jsxs("div",{className:"page-header-text",children:[u.jsx("h1",{children:"日志"}),u.jsx("p",{children:"查看所有API请求日志"})]}),u.jsx("button",{className:"btn btn-danger",onClick:F,children:"清空全部日志"})]})}),u.jsxs("div",{className:"card",children:[u.jsx("div",{style:{borderBottom:"1px solid #ecf0f1",marginBottom:"20px"},children:u.jsxs("div",{style:{display:"flex",gap:"0"},children:[u.jsxs("button",{onClick:()=>n("request"),style:{padding:"12px 24px",border:"none",background:t==="request"?"#3498db":"transparent",color:t==="request"?"white":"#7f8c8d",cursor:"pointer",borderBottom:t==="request"?"2px solid #2980b9":"2px solid transparent",fontWeight:t==="request"?"bold":"normal"},children:["请求日志 (",U,")"]}),u.jsxs("button",{onClick:()=>n("error"),style:{padding:"12px 24px",border:"none",background:t==="error"?"#e74c3c":"transparent",color:t==="error"?"white":"#7f8c8d",cursor:"pointer",borderBottom:t==="error"?"2px solid #c0392b":"2px solid transparent",fontWeight:t==="error"?"bold":"normal"},children:["错误日志 (",A,")"]}),u.jsxs("button",{onClick:()=>n("sessions"),style:{padding:"12px 24px",border:"none",background:t==="sessions"?"#9b59b6":"transparent",color:t==="sessions"?"white":"#7f8c8d",cursor:"pointer",borderBottom:t==="sessions"?"2px solid #8e44ad":"2px solid transparent",fontWeight:t==="sessions"?"bold":"normal"},children:["会话 (",k,")"]})]})}),u.jsxs("div",{className:"toolbar",children:[u.jsxs("h3",{children:[t==="error"&&"错误日志列表",t==="request"&&"请求日志列表",t==="sessions"&&"会话列表"]}),u.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center"},children:[t==="request"&&u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("input",{type:"text",placeholder:"搜索日志内容...",value:wt,onChange:B=>{It(B.target.value),L(1)},onKeyDown:B=>{B.key==="Enter"&&xe()},style:{padding:"6px 12px",borderRadius:"8px",border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-primary)",width:"200px",fontSize:"14px"}}),wt&&u.jsx("button",{onClick:()=>{It(""),L(1)},style:{padding:"6px 10px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px"},children:"清除"})]}),t==="error"&&u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("input",{type:"text",placeholder:"搜索错误日志...",value:Gt,onChange:B=>{K(B.target.value),P(1)},onKeyDown:B=>{B.key==="Enter"&&xe()},style:{padding:"6px 12px",borderRadius:"8px",border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-primary)",width:"200px",fontSize:"14px"}}),Gt&&u.jsx("button",{onClick:()=>{K(""),P(1)},style:{padding:"6px 10px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px"},children:"清除"})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"0 12px",background:"var(--bg-secondary)",borderRadius:"8px"},children:[u.jsx("input",{type:"checkbox",id:"auto-refresh",checked:G,onChange:B=>{de(B.target.checked),B.target.checked&&ne(10)},style:{cursor:"pointer"}}),u.jsxs("label",{htmlFor:"auto-refresh",style:{cursor:"pointer",fontSize:"14px",color:"var(--text-primary)",userSelect:"none"},children:["自动刷新 ",G&&`(⏱ ${W}s)`]})]}),u.jsx("button",{className:"btn btn-primary",onClick:()=>{xe(),be(),ne(10)},children:"刷新"})]})]}),t==="request"&&u.jsxs("div",{style:{padding:"15px",background:"var(--bg-secondary)",borderRadius:"12px",marginBottom:"20px",display:"flex",gap:"15px",alignItems:"center",flexWrap:"wrap",border:"1px solid var(--border-primary)"},children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"来源类型:"}),u.jsxs("select",{value:ve,onChange:B=>we(B.target.value),style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",background:"var(--bg-card)",color:"var(--text-primary)"},children:[u.jsx("option",{value:"",children:"全部"}),u.jsx("option",{value:"claude-code",children:"Claude Code"}),u.jsx("option",{value:"codex",children:"Codex"})]})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"供应商:"}),u.jsxs("select",{value:Pe,onChange:B=>ie(B.target.value),style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",minWidth:"150px",background:"var(--bg-card)",color:"var(--text-primary)"},children:[u.jsx("option",{value:"",children:"全部供应商"}),se.map(B=>u.jsx("option",{value:B.id,children:B.name},B.id))]})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"API服务:"}),u.jsxs("select",{value:Pt,onChange:B=>Se(B.target.value),disabled:!Pe,style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",minWidth:"150px",background:Pe?"var(--bg-card)":"var(--bg-secondary)",color:"var(--text-primary)",cursor:Pe?"pointer":"not-allowed",opacity:Pe?1:.6},children:[u.jsx("option",{value:"",children:"全部服务"}),$e().map(B=>u.jsx("option",{value:B.id,children:B.name},B.id))]})]}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u.jsx("label",{style:{fontWeight:"bold",minWidth:"80px",color:"var(--text-primary)"},children:"模型:"}),u.jsxs("select",{value:$t,onChange:B=>bt(B.target.value),disabled:!Pt,style:{padding:"6px 10px",borderRadius:"8px",border:"1px solid var(--border-primary)",minWidth:"150px",background:Pt?"var(--bg-card)":"var(--bg-secondary)",color:"var(--text-primary)",cursor:Pt?"pointer":"not-allowed",opacity:Pt?1:.6},children:[u.jsx("option",{value:"",children:"全部模型"}),Ne().map(B=>u.jsx("option",{value:B,children:B},B))]})]}),(ve||Pe||Pt||$t)&&u.jsx("button",{onClick:()=>{we(""),Mn(""),xt(""),bt("")},style:{padding:"6px 12px",borderRadius:"8px",border:"1px solid var(--accent-danger)",background:"var(--accent-danger)",color:"white",cursor:"pointer",fontSize:"14px"},children:"清除筛选"}),u.jsxs("div",{style:{marginLeft:"auto",color:"var(--text-muted)",fontSize:"14px"},children:["显示 ",Me.length," / ",r.length," 条"]})]}),t==="request"&&u.jsxs(u.Fragment,{children:[ge?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"加载中..."})}):lh(),!ge&&u.jsx(Xh,{currentPage:V,totalItems:U,pageSize:O,onPageChange:Sa,onPageSizeChange:ja})]}),t==="error"&&u.jsxs(u.Fragment,{children:[ge?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"加载中..."})}):sh(),!ge&&u.jsx(Xh,{currentPage:z,totalItems:A,pageSize:Y,onPageChange:Ol,onPageSizeChange:Tr})]}),t==="sessions"&&u.jsxs(u.Fragment,{children:[ge?u.jsx("div",{className:"empty-state",children:u.jsx("p",{children:"加载中..."})}):_i(),!ge&&u.jsx(Xh,{currentPage:C,totalItems:k,pageSize:M,onPageChange:_t,onPageSizeChange:Ii})]})]}),l&&u.jsxs("div",{className:"modal-overlay",style:{zIndex:J},children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>s(null),"aria-label":"关闭",style:{zIndex:J+1},children:"×"}),u.jsx("div",{className:"modal",style:{width:"800px",zIndex:J},children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:"请求详情"})}),u.jsxs("div",{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"日志ID"}),u.jsx("input",{type:"text",value:l.id,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"时间"}),u.jsx("input",{type:"text",value:on(l.timestamp).format("YYYY-MM-DD HH:mm:ss"),readOnly:!0})]}),l.targetType&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"客户端类型"}),u.jsx("input",{type:"text",value:ac[l.targetType]||"-",readOnly:!0})]}),l.requestModel&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求模型"}),u.jsx("input",{type:"text",value:l.requestModel,readOnly:!0})]}),l.vendorName&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商"}),u.jsx("input",{type:"text",value:l.vendorName,readOnly:!0})]}),l.targetServiceName&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商API服务"}),u.jsx("input",{type:"text",value:l.targetServiceName,readOnly:!0})]}),l.targetModel&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商模型"}),u.jsx("input",{type:"text",value:l.targetModel,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求方法"}),u.jsx("input",{type:"text",value:l.method,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求路径"}),u.jsx("input",{type:"text",value:l.path,readOnly:!0})]}),l.headers&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求头"}),u.jsx(pr,{data:l.headers,collapsed:!0})]}),l.body&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求体"}),u.jsx(pr,{data:l.body})]}),l.upstreamRequest&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"实际转发信息"}),u.jsx(pr,{data:l.upstreamRequest})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"状态码"}),u.jsx("input",{type:"text",value:l.statusCode||"Error",readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应时间"}),u.jsx("input",{type:"text",value:l.responseTime?`${l.responseTime}ms`:"-",readOnly:!0})]}),l.responseHeaders&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应头"}),u.jsx(pr,{data:l.responseHeaders,collapsed:!0})]}),(()=>{const B=CB(l);return console.log("[RequestLogDetail] assembledBody:",B),B?u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应体"}),u.jsx(pr,{data:B})]}):u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应体"}),u.jsxs("div",{style:{padding:"10px",color:"#7f8c8d",fontStyle:"italic"},children:["无响应体数据",l.streamChunks===void 0&&l.responseBody===void 0&&u.jsx("div",{style:{marginTop:"5px",fontSize:"12px",color:"#e74c3c"},children:"⚠️ 该日志不包含响应数据(可能是旧版本记录)"})]})]})})(),l.streamChunks&&l.streamChunks.length>0&&u.jsxs("div",{className:"form-group",children:[u.jsxs("label",{children:["Stream Chunks (",l.streamChunks.length,"个)",u.jsx("button",{onClick:()=>p(!f),style:{marginLeft:"10px",padding:"2px 8px",fontSize:"12px"},className:"btn btn-sm btn-secondary",children:f?"折叠":"展开"}),u.jsx("button",{onClick:()=>g(!h),style:{marginLeft:"5px",padding:"2px 8px",fontSize:"12px"},className:"btn btn-sm btn-primary",children:h?"隐藏拼装结果":"查看拼装结果"})]}),f&&u.jsx("div",{style:{maxHeight:"400px",overflowY:"auto",border:"1px solid #ddd",padding:"10px",borderRadius:"4px"},children:l.streamChunks.map((B,Ae)=>u.jsxs("div",{style:{marginBottom:"10px"},children:[u.jsxs("div",{style:{fontWeight:"bold",fontSize:"12px",color:"#7f8c8d",marginBottom:"4px"},children:["Chunk #",Ae+1]}),u.jsx(pr,{data:B,collapsed:!0})]},Ae))}),h&&u.jsx("div",{style:{marginTop:"10px",maxHeight:"400px",overflowY:"auto",border:"1px solid var(--border-secondary)",padding:"10px",borderRadius:"4px",backgroundColor:"var(--bg-assembled-text)"},children:u.jsx(AB,{chunks:l.streamChunks,targetType:l.targetType})})]}),l.usage&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"Token 使用"}),u.jsx("textarea",{rows:4,value:`输入: ${l.usage.inputTokens}
135
135
  输出: ${l.usage.outputTokens}
136
136
  `+(l.usage.totalTokens!==void 0?`总计: ${l.usage.totalTokens}
137
- `:"")+(l.usage.cacheReadInputTokens!==void 0?`缓存读取: ${l.usage.cacheReadInputTokens}`:""),readOnly:!0})]}),l.error&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"错误信息"}),u.jsx("textarea",{rows:4,value:l.error,readOnly:!0,style:{color:"red"}})]})]}),u.jsx("div",{className:"modal-footer",children:u.jsx("button",{className:"btn btn-secondary",onClick:()=>s(null),children:"关闭"})})]})})]}),c&&u.jsxs("div",{className:"modal-overlay",style:{zIndex:J},children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>d(null),"aria-label":"关闭",style:{zIndex:J+1},children:"×"}),u.jsx("div",{className:"modal",style:{minWidth:"600px",zIndex:J},children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:"错误日志详情"})}),u.jsxs("div",{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"ID"}),u.jsx("input",{type:"text",value:c.id,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"时间"}),u.jsx("input",{type:"text",value:on(c.timestamp).format("YYYY-MM-DD HH:mm:ss"),readOnly:!0})]}),c.targetType&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"客户端类型"}),u.jsx("input",{type:"text",value:ac[c.targetType]||"-",readOnly:!0})]}),c.requestModel&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求模型"}),u.jsx("input",{type:"text",value:c.requestModel,readOnly:!0})]}),c.vendorName&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商"}),u.jsx("input",{type:"text",value:c.vendorName,readOnly:!0})]}),c.targetServiceName&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商API服务"}),u.jsx("input",{type:"text",value:c.targetServiceName,readOnly:!0})]}),c.targetModel&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商模型"}),u.jsx("input",{type:"text",value:c.targetModel,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求方法"}),u.jsx("input",{type:"text",value:c.method,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求路径"}),u.jsx("input",{type:"text",value:c.path,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"状态码"}),u.jsx("input",{type:"text",value:c.statusCode||"-",readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应时间"}),u.jsx("input",{type:"text",value:c.responseTime?`${c.responseTime}ms`:"-",readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"错误信息"}),u.jsx("textarea",{rows:4,value:c.errorMessage,readOnly:!0,style:{color:"#e74c3c"}})]}),c.errorStack&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"错误堆栈"}),u.jsx("textarea",{rows:8,value:c.errorStack,readOnly:!0,style:{fontSize:"12px",color:"#7f8c8d"}})]}),c.requestHeaders&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求头"}),u.jsx(pr,{data:c.requestHeaders})]}),c.requestBody&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求体"}),u.jsx(pr,{data:c.requestBody})]}),c.upstreamRequest&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"实际转发信息"}),u.jsx(pr,{data:c.upstreamRequest})]}),c.responseHeaders&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应头"}),u.jsx(pr,{data:c.responseHeaders,collapsed:!0})]}),c.responseBody&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应体"}),u.jsx(pr,{data:c.responseBody})]})]}),u.jsx("div",{className:"modal-footer",children:u.jsx("button",{className:"btn btn-secondary",onClick:()=>d(null),children:"关闭"})})]})})]}),v&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>{b(null),S([])},"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",style:{width:"900px",maxWidth:"90vw"},children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:"会话详情"})}),u.jsxs("div",{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"会话ID"}),u.jsx("input",{type:"text",value:v.id,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"标题"}),u.jsx("input",{type:"text",value:v.title||"(无标题)",readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"客户端类型"}),u.jsx("input",{type:"text",value:v.targetType==="claude-code"?"Claude Code":"Codex",readOnly:!0})]}),u.jsxs("div",{style:{display:"flex",gap:"15px"},children:[u.jsxs("div",{className:"form-group",style:{flex:1},children:[u.jsx("label",{children:"请求数"}),u.jsx("input",{type:"text",value:v.requestCount.toString(),readOnly:!0})]}),u.jsxs("div",{className:"form-group",style:{flex:1},children:[u.jsx("label",{children:"Tokens"}),u.jsx("input",{type:"text",value:v.totalTokens.toLocaleString(),readOnly:!0})]}),u.jsxs("div",{className:"form-group",style:{flex:1},children:[u.jsx("label",{children:"时长"}),u.jsx("input",{type:"text",value:Gn(v.firstRequestAt,v.lastRequestAt),readOnly:!0})]})]}),u.jsxs("div",{style:{display:"flex",gap:"15px"},children:[u.jsxs("div",{className:"form-group",style:{flex:1},children:[u.jsx("label",{children:"首次请求"}),u.jsx("input",{type:"text",value:on(v.firstRequestAt).format("YYYY-MM-DD HH:mm:ss"),readOnly:!0})]}),u.jsxs("div",{className:"form-group",style:{flex:1},children:[u.jsx("label",{children:"最后请求"}),u.jsx("input",{type:"text",value:on(v.lastRequestAt).format("YYYY-MM-DD HH:mm:ss"),readOnly:!0})]})]}),u.jsxs("h3",{style:{marginTop:"20px",marginBottom:"10px"},children:["会话日志 (",w.length,")"]}),_?u.jsx("div",{style:{textAlign:"center",padding:"20px"},children:"加载中..."}):w.length===0?u.jsx("div",{style:{textAlign:"center",padding:"20px",color:"#7f8c8d"},children:"暂无日志"}):u.jsx("div",{style:{maxHeight:"400px",overflowY:"auto",border:"1px solid var(--border-color)",borderRadius:"8px"},children:u.jsxs("table",{style:{fontSize:"14px"},children:[u.jsx("thead",{style:{position:"sticky",top:0,background:"var(--bg-card)"},children:u.jsxs("tr",{children:[u.jsx("th",{children:"时间"}),u.jsx("th",{children:"状态"}),u.jsx("th",{children:"响应时间"}),u.jsx("th",{children:"Tokens"}),u.jsx("th",{children:"操作"})]})}),u.jsx("tbody",{children:w.map(B=>u.jsxs("tr",{children:[u.jsx("td",{children:on(B.timestamp).format("HH:mm:ss")}),u.jsx("td",{children:u.jsx("span",{className:`badge ${le(B.statusCode)}`,children:B.statusCode||"Error"})}),u.jsx("td",{children:B.responseTime?`${B.responseTime}ms`:"-"}),u.jsx("td",{children:B.usage?u.jsx("span",{children:B.usage.totalTokens||B.usage.inputTokens+B.usage.outputTokens}):"-"}),u.jsx("td",{children:u.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>s(B),children:"详情"})})]},B.id))})]})})]}),u.jsx("div",{className:"modal-footer",children:u.jsx("button",{className:"btn btn-secondary",onClick:()=>{b(null),S([])},children:"关闭"})})]})})]})]})}function AB({chunks:e,targetType:t}){const{text:n,thinking:r}=m.useMemo(()=>IE(e),[e,t]);return!n&&!r?u.jsx("div",{style:{color:"#7f8c8d",fontStyle:"italic"},children:"无法解析出文本内容"}):u.jsxs("div",{className:"assembled-text-view",children:[r&&u.jsxs("details",{style:{marginBottom:"15px",border:"1px solid var(--border-thinking-box)",borderRadius:"8px",padding:"10px",backgroundColor:"var(--bg-thinking-box)"},open:!0,children:[u.jsxs("summary",{style:{cursor:"pointer",fontWeight:"bold",color:"var(--text-thinking-title)",userSelect:"none"},children:["思考内容 (",r.length," 字符)"]}),u.jsx("pre",{style:{marginTop:"10px",whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"monospace",fontSize:"13px",color:"var(--text-thinking-content)",backgroundColor:"var(--bg-thinking-content)",padding:"10px",borderRadius:"4px",border:"1px solid var(--border-thinking-content)"},children:r})]}),n&&u.jsxs("div",{children:[u.jsxs("div",{style:{fontWeight:"bold",marginBottom:"8px",color:"var(--text-reply-title)"},children:["回复内容 (",n.length," 字符)"]}),u.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"monospace",fontSize:"13px",color:"var(--text-reply-content)",backgroundColor:"var(--bg-reply-content)",padding:"10px",borderRadius:"4px",border:"1px solid var(--border-reply-content)"},children:n})]})]})}function NE({checked:e,onChange:t,disabled:n,label:r,labelPosition:i="right"}){const a=u.jsx("button",{type:"button",role:"switch","aria-checked":e,className:`switch ${e?"active":""}`,onClick:()=>!n&&t(!e),disabled:n,children:u.jsx("span",{className:"switch-thumb",style:{position:"absolute",top:"2px",left:e?"22px":"2px",width:"20px",height:"20px",borderRadius:"10px",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})});return r?i==="left"?u.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:n?"not-allowed":"pointer"},children:[u.jsx("span",{style:{fontSize:"14px",color:"var(--text-muted)"},children:r}),a]}):u.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:n?"not-allowed":"pointer"},children:[a,u.jsx("span",{style:{fontSize:"14px",color:"var(--text-muted)"},children:r})]}):a}function bw({skillId:e,targetType:t,enabled:n,onChange:r,disabled:i}){const a=t==="claude-code"?"Claude Code":"Codex";return u.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:u.jsx(NE,{checked:n,onChange:o=>r(e,t,o),disabled:i,label:a,labelPosition:"right"})})}function TB(){var T,M,I,_,N,V;const[e,t]=m.useState(null),[n,r]=m.useState(""),[i,a]=m.useState(""),[o,l]=m.useState(""),[s,c]=m.useState({proxyEnabled:!1,proxyUrl:"",proxyUsername:"",proxyPassword:""}),[d,f]=m.useState(null),[p,h]=m.useState(!1),[g,y]=m.useState(!1);m.useEffect(()=>{x()},[]);const x=async()=>{const L=await Q.getConfig();t(L),c({proxyEnabled:L.proxyEnabled||!1,proxyUrl:L.proxyUrl||"",proxyUsername:L.proxyUsername||"",proxyPassword:L.proxyPassword||""})},v=async L=>{L.preventDefault();const O=new FormData(L.currentTarget),R={...e,apiKey:O.get("apiKey"),enableFailover:O.get("enableFailover")==="true"};await Q.updateConfig(R)?(re.success("配置保存成功"),x()):re.error("配置保存失败")},b=async L=>{L.preventDefault();const O=new FormData(L.currentTarget),R={...e,enableLogging:O.get("enableLogging")==="true",logRetentionDays:parseInt(O.get("logRetentionDays")),maxLogSize:parseInt(O.get("maxLogSize"))};await Q.updateConfig(R)?(re.success("日志配置保存成功"),x()):re.error("日志配置保存失败")},w=async L=>{L.preventDefault();const O=new FormData(L.currentTarget),R={...e,proxyEnabled:O.get("proxyEnabled")==="true",proxyUrl:O.get("proxyUrl"),proxyUsername:O.get("proxyUsername"),proxyPassword:O.get("proxyPassword")};await Q.updateConfig(R)?(re.success("代理配置保存成功"),x()):re.error("代理配置保存失败")},S=async()=>{if(!n){re.warning("请输入密码");return}try{const L=await Q.exportData(n);l(L),re.success("导出成功,请复制下方数据")}catch(L){re.error("导出失败: "+L.message)}},k=async()=>{if(!n||!i){re.warning("请输入密码和导入数据");return}h(!0);try{const L=await Q.previewImportData(i,n);f(L),L.success||re.error(L.message||"预览失败")}catch(L){re.error("预览失败: "+L.message),f({success:!1,message:L.message})}finally{h(!1)}},j=async()=>{if(!n||!i||!(d!=null&&d.success)){re.warning("请先预览数据并确认无误");return}y(!0);try{const L=await Q.importData(i,n);L.success?(re.success(L.message+(L.details?` (${L.details})`:"")),a(""),r(""),f(null)):re.error(L.message+(L.details?`: ${L.details}`:""))}catch(L){re.error("导入失败: "+L.message)}finally{y(!1)}},C=()=>{f(null),a(""),r("")};return e?u.jsxs("div",{children:[u.jsxs("div",{className:"page-header",children:[u.jsx("h1",{children:"设置"}),u.jsx("p",{children:"管理应用配置和数据导入导出"})]}),u.jsxs("div",{className:"card",children:[u.jsx("h3",{children:"应用配置"}),u.jsxs("form",{onSubmit:v,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"API Key"}),u.jsx("input",{type:"password",name:"apiKey",defaultValue:e.apiKey}),u.jsx("small",{style:{display:"block",marginTop:"4px",color:"#666",fontSize:"12px"},children:"当编程工具连接到aicodeswitch时,需要使用此API Key进行认证"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"启用智能故障切换"}),u.jsxs("select",{name:"enableFailover",defaultValue:e.enableFailover!==!1?"true":"false",children:[u.jsx("option",{value:"true",children:"是"}),u.jsx("option",{value:"false",children:"否"})]}),u.jsx("small",{style:{display:"block",marginTop:"4px",color:"#666",fontSize:"12px"},children:"启用后,当某个服务报错时会自动切换到备用服务,并将报错服务标记为不可用10分钟"})]}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存配置"})]})]}),u.jsxs("div",{className:"card",style:{marginTop:"20px"},children:[u.jsx("h3",{children:"日志设置"}),u.jsx("p",{style:{color:"#7f8c8d",fontSize:"14px"},children:"配置请求日志的记录和保留策略。"}),u.jsxs("form",{onSubmit:b,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"启用日志"}),u.jsxs("select",{name:"enableLogging",defaultValue:e.enableLogging?"true":"false",children:[u.jsx("option",{value:"true",children:"是"}),u.jsx("option",{value:"false",children:"否"})]})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"日志保留天数"}),u.jsx("input",{type:"number",name:"logRetentionDays",defaultValue:e.logRetentionDays,required:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"最大日志数量"}),u.jsx("input",{type:"number",name:"maxLogSize",defaultValue:e.maxLogSize,required:!0})]}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存日志配置"})]})]}),u.jsxs("div",{className:"card",style:{marginTop:"20px"},children:[u.jsx("h3",{children:"代理设置"}),u.jsx("p",{style:{color:"#7f8c8d",fontSize:"14px"},children:"配置代理服务器,API 服务可选择是否通过代理转发请求。"}),u.jsxs("form",{onSubmit:w,children:[u.jsx("input",{type:"hidden",name:"proxyEnabled",value:s.proxyEnabled?"true":"false"}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"启用代理"}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[u.jsx(NE,{checked:s.proxyEnabled,onChange:L=>c(O=>({...O,proxyEnabled:L}))}),u.jsx("span",{style:{fontSize:"14px",color:"#666"},children:s.proxyEnabled?"已启用":"未启用"})]})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"代理地址"}),u.jsx("input",{type:"text",name:"proxyUrl",value:s.proxyUrl,onChange:L=>c(O=>({...O,proxyUrl:L.target.value})),placeholder:"例如: proxy.example.com:8080 或 http://proxy.example.com:8080"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"代理用户名(可选)"}),u.jsx("input",{type:"text",name:"proxyUsername",value:s.proxyUsername,onChange:L=>c(O=>({...O,proxyUsername:L.target.value})),placeholder:"如果代理需要认证"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"代理密码(可选)"}),u.jsx("input",{type:"password",name:"proxyPassword",value:s.proxyPassword,onChange:L=>c(O=>({...O,proxyPassword:L.target.value})),placeholder:"如果代理需要认证"})]}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存代理配置"})]})]}),u.jsxs("div",{className:"card",style:{marginTop:"20px"},children:[u.jsx("h3",{children:"数据导出"}),u.jsx("p",{style:{color:"#7f8c8d",fontSize:"14px"},children:"导出所有配置数据,包括供应商、API服务、路由等。数据将使用密码加密。"}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"加密密码"}),u.jsx("input",{type:"password",value:n,onChange:L=>r(L.target.value),placeholder:"用于加密导出数据"})]}),u.jsx("button",{className:"btn btn-primary",onClick:S,children:"导出数据"}),o&&u.jsxs("div",{className:"form-group",style:{marginTop:"20px"},children:[u.jsx("label",{children:"导出的数据(请复制保存)"}),u.jsx("textarea",{rows:6,value:o,readOnly:!0,style:{fontFamily:"monospace",fontSize:"12px"}}),u.jsx("button",{className:"btn btn-secondary",style:{marginTop:"10px"},onClick:()=>{navigator.clipboard.writeText(o),re.success("已复制到剪贴板")},children:"复制到剪贴板"})]})]}),u.jsxs("div",{className:"card",style:{marginTop:"20px"},children:[u.jsx("h3",{children:"数据导入"}),u.jsx("p",{style:{color:"#e74c3c",fontSize:"14px",fontWeight:500},children:"警告:导入数据将覆盖所有现有配置!请确保已备份重要数据。"}),d!=null&&d.success?u.jsxs(u.Fragment,{children:[u.jsxs("div",{style:{marginTop:"15px",padding:"15px",backgroundColor:"#e8f4fd",borderRadius:"6px",border:"1px solid #bee5eb"},children:[u.jsx("h4",{style:{margin:"0 0 12px 0",color:"#0c5460",fontSize:"16px"},children:"数据预览"}),u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"10px",marginBottom:"12px"},children:[u.jsxs("div",{style:{padding:"10px",backgroundColor:"white",borderRadius:"4px"},children:[u.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"供应商"}),u.jsx("div",{style:{fontSize:"20px",fontWeight:"bold",color:"#333"},children:((T=d.data)==null?void 0:T.vendors)||0})]}),u.jsxs("div",{style:{padding:"10px",backgroundColor:"white",borderRadius:"4px"},children:[u.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"API服务"}),u.jsx("div",{style:{fontSize:"20px",fontWeight:"bold",color:"#333"},children:((M=d.data)==null?void 0:M.services)||0})]}),u.jsxs("div",{style:{padding:"10px",backgroundColor:"white",borderRadius:"4px"},children:[u.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"路由"}),u.jsx("div",{style:{fontSize:"20px",fontWeight:"bold",color:"#333"},children:((I=d.data)==null?void 0:I.routes)||0})]}),u.jsxs("div",{style:{padding:"10px",backgroundColor:"white",borderRadius:"4px"},children:[u.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"规则"}),u.jsx("div",{style:{fontSize:"20px",fontWeight:"bold",color:"#333"},children:((_=d.data)==null?void 0:_.rules)||0})]})]}),u.jsxs("div",{style:{fontSize:"12px",color:"#666",marginTop:"8px"},children:[u.jsxs("div",{children:["数据版本: ",(N=d.data)==null?void 0:N.version]}),u.jsxs("div",{children:["导出时间: ",(V=d.data)!=null&&V.exportDate?new Date(d.data.exportDate).toLocaleString("zh-CN"):"-"]})]})]}),u.jsxs("div",{style:{marginTop:"15px",padding:"12px",backgroundColor:"#fff3cd",borderRadius:"4px",border:"1px solid #ffeaa7",color:"#856404"},children:[u.jsx("strong",{children:"确认导入?"})," 此操作将覆盖所有现有的供应商、服务、路由和规则配置,且无法撤销。"]}),u.jsxs("div",{style:{marginTop:"15px",display:"flex",gap:"10px"},children:[u.jsx("button",{className:"btn btn-danger",onClick:j,disabled:g,children:g?"导入中...":"确认导入"}),u.jsx("button",{className:"btn btn-secondary",onClick:C,disabled:g,children:"取消"})]})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"解密密码"}),u.jsx("input",{type:"password",value:n,onChange:L=>r(L.target.value),placeholder:"用于解密导入数据"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"导入数据"}),u.jsx("textarea",{rows:6,value:i,onChange:L=>a(L.target.value),placeholder:"粘贴导出的加密数据",style:{fontFamily:"monospace",fontSize:"12px"}})]}),u.jsx("button",{className:"btn btn-primary",onClick:k,disabled:p||!n||!i,children:p?"预览中...":"预览数据"}),(d==null?void 0:d.success)===!1&&u.jsxs("div",{style:{marginTop:"10px",padding:"10px",backgroundColor:"#fdeaea",borderRadius:"4px",color:"#e74c3c"},children:[u.jsx("strong",{children:"预览失败:"}),d.message]})]})]})]}):u.jsx("div",{children:"加载中..."})}function IB(){var p,h,g,y,x,v,b,w;const[e,t]=m.useState({claude:!1,codex:!1}),[n,r]=m.useState({claude:!1,codex:!1}),[i,a]=m.useState({claude:null,codex:null}),[o,l]=m.useState("");m.useEffect(()=>{s()},[]);const s=async()=>{try{const[S,k]=await Promise.all([Q.getClaudeConfigStatus(),Q.getCodexConfigStatus()]);a({claude:S,codex:k})}catch(S){console.error("Failed to check config status:",S)}},c=async S=>{t(k=>({...k,[S]:!0})),l("");try{(S==="claude"?await Q.writeClaudeConfig():await Q.writeCodexConfig())?(l(`${S==="claude"?"Claude Code":"Codex"}配置文件写入成功!原始文件已备份为 .aicodeswitch_backup 文件。`),await s()):l("写入失败: 操作未成功")}catch(k){l(`写入失败: ${k.message}`)}finally{t(k=>({...k,[S]:!1}))}},d=async S=>{r(k=>({...k,[S]:!0})),l("");try{(S==="claude"?await Q.restoreClaudeConfig():await Q.restoreCodexConfig())?(l(`${S==="claude"?"Claude Code":"Codex"}配置文件已从备份恢复!`),await s()):l("恢复失败: 操作未成功")}catch(k){l(`恢复失败: ${k.message}`)}finally{r(k=>({...k,[S]:!1}))}},f=S=>{const k=i[S];if(!k)return null;const j=S==="claude"?"Claude Code":"Codex";return k.isOverwritten&&k.isModified?u.jsxs("p",{style:{color:"#f39c12",fontSize:"12px",marginTop:"10px"},children:["⚠️ 检测到",j,"配置已被修改,但备份文件仍然存在。建议先恢复原始配置,再重新写入以确保配置正确。"]}):k.isOverwritten&&!k.isModified?u.jsxs("p",{style:{color:"#27ae60",fontSize:"12px",marginTop:"10px"},children:["✓ ",j,"配置已正确设置为代理模式,且未被修改。"]}):!k.isOverwritten&&k.hasBackup?u.jsx("p",{style:{color:"#e74c3c",fontSize:"12px",marginTop:"10px"},children:"⚠️ 检测到配置状态不一致。备份文件存在但当前配置不是代理配置,请先恢复或手动删除备份文件。"}):null};return u.jsxs("div",{children:[u.jsxs("div",{className:"page-header",children:[u.jsx("h1",{children:"写入配置"}),u.jsx("p",{children:"将Claude Code和Codex的配置文件写入到用户目录"})]}),u.jsxs("div",{className:"card",style:{marginBottom:"20px"},children:[u.jsx("h3",{children:"Claude Code配置"}),u.jsx("p",{style:{color:"#7f8c8d",marginBottom:"15px"},children:"为Claude Code工具写入配置文件。原始文件将被备份为.aicodeswitch_backup文件。"}),u.jsxs("div",{style:{marginBottom:"15px"},children:[u.jsx("h4",{children:"配置文件:"}),u.jsxs("ul",{style:{color:"#7f8c8d",lineHeight:"1.6"},children:[u.jsxs("li",{children:[u.jsx("code",{children:"~/.claude/settings.json"})," - Claude Code设置"]}),u.jsxs("li",{children:[u.jsx("code",{children:"~/.claude.json"})," - Claude Code初始化设置"]})]})]}),u.jsxs("div",{style:{display:"flex",gap:"10px"},children:[u.jsx("button",{className:"btn btn-primary",onClick:()=>c("claude"),disabled:e.claude||(((p=i.claude)==null?void 0:p.isOverwritten)??!1),children:e.claude?"写入中...":"写入Claude Code配置"}),u.jsx("button",{className:"btn btn-secondary",onClick:()=>d("claude"),disabled:n.claude||!(((h=i.claude)==null?void 0:h.hasBackup)??!1),children:n.claude?"恢复中...":"恢复Claude Code配置"})]}),f("claude"),((g=i.claude)==null?void 0:g.isOverwritten)&&!((y=i.claude)!=null&&y.isModified)&&u.jsx("p",{style:{color:"#e74c3c",fontSize:"12px",marginTop:"10px"},children:"⚠️ 配置已被覆盖,如需重新写入请先恢复原始配置"})]}),u.jsxs("div",{className:"card",children:[u.jsx("h3",{children:"Codex配置"}),u.jsx("p",{style:{color:"#7f8c8d",marginBottom:"15px"},children:"为Codex工具写入配置文件。原始文件将被备份为.aicodeswitch_backup文件。"}),u.jsxs("div",{style:{marginBottom:"15px"},children:[u.jsx("h4",{children:"配置文件:"}),u.jsxs("ul",{style:{color:"#7f8c8d",lineHeight:"1.6"},children:[u.jsxs("li",{children:[u.jsx("code",{children:"~/.codex/config.toml"})," - Codex配置"]}),u.jsxs("li",{children:[u.jsx("code",{children:"~/.codex/auth.json"})," - Codex认证信息"]})]})]}),u.jsxs("div",{style:{display:"flex",gap:"10px"},children:[u.jsx("button",{className:"btn btn-primary",onClick:()=>c("codex"),disabled:e.codex||(((x=i.codex)==null?void 0:x.isOverwritten)??!1),children:e.codex?"写入中...":"写入Codex配置"}),u.jsx("button",{className:"btn btn-secondary",onClick:()=>d("codex"),disabled:n.codex||!(((v=i.codex)==null?void 0:v.hasBackup)??!1),children:n.codex?"恢复中...":"恢复Codex配置"})]}),f("codex"),((b=i.codex)==null?void 0:b.isOverwritten)&&!((w=i.codex)!=null&&w.isModified)&&u.jsx("p",{style:{color:"#e74c3c",fontSize:"12px",marginTop:"10px"},children:"⚠️ 配置已被覆盖,如需重新写入请先恢复原始配置"})]}),o&&u.jsx("div",{style:{marginTop:"20px",padding:"10px",borderRadius:"4px",backgroundColor:o.includes("成功")?"#d4edda":"#f8d7da",color:o.includes("成功")?"#155724":"#721c24",border:`1px solid ${o.includes("成功")?"#c3e6cb":"#f5c6cb"}`},children:o})]})}const _B=`# AI Code Switch
137
+ `:"")+(l.usage.cacheReadInputTokens!==void 0?`缓存读取: ${l.usage.cacheReadInputTokens}`:""),readOnly:!0})]}),l.error&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"错误信息"}),u.jsx("textarea",{rows:4,value:l.error,readOnly:!0,style:{color:"red"}})]})]}),u.jsx("div",{className:"modal-footer",children:u.jsx("button",{className:"btn btn-secondary",onClick:()=>s(null),children:"关闭"})})]})})]}),c&&u.jsxs("div",{className:"modal-overlay",style:{zIndex:J},children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>d(null),"aria-label":"关闭",style:{zIndex:J+1},children:"×"}),u.jsx("div",{className:"modal",style:{minWidth:"600px",zIndex:J},children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:"错误日志详情"})}),u.jsxs("div",{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"ID"}),u.jsx("input",{type:"text",value:c.id,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"时间"}),u.jsx("input",{type:"text",value:on(c.timestamp).format("YYYY-MM-DD HH:mm:ss"),readOnly:!0})]}),c.targetType&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"客户端类型"}),u.jsx("input",{type:"text",value:ac[c.targetType]||"-",readOnly:!0})]}),c.requestModel&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求模型"}),u.jsx("input",{type:"text",value:c.requestModel,readOnly:!0})]}),c.vendorName&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商"}),u.jsx("input",{type:"text",value:c.vendorName,readOnly:!0})]}),c.targetServiceName&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商API服务"}),u.jsx("input",{type:"text",value:c.targetServiceName,readOnly:!0})]}),c.targetModel&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"供应商模型"}),u.jsx("input",{type:"text",value:c.targetModel,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求方法"}),u.jsx("input",{type:"text",value:c.method,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求路径"}),u.jsx("input",{type:"text",value:c.path,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"状态码"}),u.jsx("input",{type:"text",value:c.statusCode||"-",readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应时间"}),u.jsx("input",{type:"text",value:c.responseTime?`${c.responseTime}ms`:"-",readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"错误信息"}),u.jsx("textarea",{rows:4,value:c.errorMessage,readOnly:!0,style:{color:"#e74c3c"}})]}),c.errorStack&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"错误堆栈"}),u.jsx("textarea",{rows:8,value:c.errorStack,readOnly:!0,style:{fontSize:"12px",color:"#7f8c8d"}})]}),c.requestHeaders&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求头"}),u.jsx(pr,{data:c.requestHeaders})]}),c.requestBody&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"请求体"}),u.jsx(pr,{data:c.requestBody})]}),c.upstreamRequest&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"实际转发信息"}),u.jsx(pr,{data:c.upstreamRequest})]}),c.responseHeaders&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应头"}),u.jsx(pr,{data:c.responseHeaders,collapsed:!0})]}),c.responseBody&&u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"响应体"}),u.jsx(pr,{data:c.responseBody})]})]}),u.jsx("div",{className:"modal-footer",children:u.jsx("button",{className:"btn btn-secondary",onClick:()=>d(null),children:"关闭"})})]})})]}),v&&u.jsxs("div",{className:"modal-overlay",children:[u.jsx("button",{type:"button",className:"modal-close-btn",onClick:()=>{b(null),S([])},"aria-label":"关闭",children:"×"}),u.jsx("div",{className:"modal",style:{width:"900px",maxWidth:"90vw"},children:u.jsxs("div",{className:"modal-container",children:[u.jsx("div",{className:"modal-header",children:u.jsx("h2",{children:"会话详情"})}),u.jsxs("div",{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"会话ID"}),u.jsx("input",{type:"text",value:v.id,readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"标题"}),u.jsx("input",{type:"text",value:v.title||"(无标题)",readOnly:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"客户端类型"}),u.jsx("input",{type:"text",value:v.targetType==="claude-code"?"Claude Code":"Codex",readOnly:!0})]}),u.jsxs("div",{style:{display:"flex",gap:"15px"},children:[u.jsxs("div",{className:"form-group",style:{flex:1},children:[u.jsx("label",{children:"请求数"}),u.jsx("input",{type:"text",value:v.requestCount.toString(),readOnly:!0})]}),u.jsxs("div",{className:"form-group",style:{flex:1},children:[u.jsx("label",{children:"Tokens"}),u.jsx("input",{type:"text",value:v.totalTokens.toLocaleString(),readOnly:!0})]}),u.jsxs("div",{className:"form-group",style:{flex:1},children:[u.jsx("label",{children:"时长"}),u.jsx("input",{type:"text",value:Gn(v.firstRequestAt,v.lastRequestAt),readOnly:!0})]})]}),u.jsxs("div",{style:{display:"flex",gap:"15px"},children:[u.jsxs("div",{className:"form-group",style:{flex:1},children:[u.jsx("label",{children:"首次请求"}),u.jsx("input",{type:"text",value:on(v.firstRequestAt).format("YYYY-MM-DD HH:mm:ss"),readOnly:!0})]}),u.jsxs("div",{className:"form-group",style:{flex:1},children:[u.jsx("label",{children:"最后请求"}),u.jsx("input",{type:"text",value:on(v.lastRequestAt).format("YYYY-MM-DD HH:mm:ss"),readOnly:!0})]})]}),u.jsxs("h3",{style:{marginTop:"20px",marginBottom:"10px"},children:["会话日志 (",w.length,")"]}),_?u.jsx("div",{style:{textAlign:"center",padding:"20px"},children:"加载中..."}):w.length===0?u.jsx("div",{style:{textAlign:"center",padding:"20px",color:"#7f8c8d"},children:"暂无日志"}):u.jsx("div",{style:{maxHeight:"400px",overflowY:"auto",border:"1px solid var(--border-color)",borderRadius:"8px"},children:u.jsxs("table",{style:{fontSize:"14px"},children:[u.jsx("thead",{style:{position:"sticky",top:0,background:"var(--bg-card)"},children:u.jsxs("tr",{children:[u.jsx("th",{children:"时间"}),u.jsx("th",{children:"状态"}),u.jsx("th",{children:"响应时间"}),u.jsx("th",{children:"Tokens"}),u.jsx("th",{children:"操作"})]})}),u.jsx("tbody",{children:w.map(B=>u.jsxs("tr",{children:[u.jsx("td",{children:on(B.timestamp).format("HH:mm:ss")}),u.jsx("td",{children:u.jsx("span",{className:`badge ${ae(B.statusCode)}`,children:B.statusCode||"Error"})}),u.jsx("td",{children:B.responseTime?`${B.responseTime}ms`:"-"}),u.jsx("td",{children:B.usage?u.jsx("span",{children:B.usage.totalTokens||B.usage.inputTokens+B.usage.outputTokens}):"-"}),u.jsx("td",{children:u.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>s(B),children:"详情"})})]},B.id))})]})})]}),u.jsx("div",{className:"modal-footer",children:u.jsx("button",{className:"btn btn-secondary",onClick:()=>{b(null),S([])},children:"关闭"})})]})})]})]})}function AB({chunks:e,targetType:t}){const{text:n,thinking:r}=m.useMemo(()=>IE(e),[e,t]);return!n&&!r?u.jsx("div",{style:{color:"#7f8c8d",fontStyle:"italic"},children:"无法解析出文本内容"}):u.jsxs("div",{className:"assembled-text-view",children:[r&&u.jsxs("details",{style:{marginBottom:"15px",border:"1px solid var(--border-thinking-box)",borderRadius:"8px",padding:"10px",backgroundColor:"var(--bg-thinking-box)"},open:!0,children:[u.jsxs("summary",{style:{cursor:"pointer",fontWeight:"bold",color:"var(--text-thinking-title)",userSelect:"none"},children:["思考内容 (",r.length," 字符)"]}),u.jsx("pre",{style:{marginTop:"10px",whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"monospace",fontSize:"13px",color:"var(--text-thinking-content)",backgroundColor:"var(--bg-thinking-content)",padding:"10px",borderRadius:"4px",border:"1px solid var(--border-thinking-content)"},children:r})]}),n&&u.jsxs("div",{children:[u.jsxs("div",{style:{fontWeight:"bold",marginBottom:"8px",color:"var(--text-reply-title)"},children:["回复内容 (",n.length," 字符)"]}),u.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"monospace",fontSize:"13px",color:"var(--text-reply-content)",backgroundColor:"var(--bg-reply-content)",padding:"10px",borderRadius:"4px",border:"1px solid var(--border-reply-content)"},children:n})]})]})}function NE({checked:e,onChange:t,disabled:n,label:r,labelPosition:i="right"}){const a=u.jsx("button",{type:"button",role:"switch","aria-checked":e,className:`switch ${e?"active":""}`,onClick:()=>!n&&t(!e),disabled:n,children:u.jsx("span",{className:"switch-thumb",style:{position:"absolute",top:"2px",left:e?"22px":"2px",width:"20px",height:"20px",borderRadius:"10px",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})});return r?i==="left"?u.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:n?"not-allowed":"pointer"},children:[u.jsx("span",{style:{fontSize:"14px",color:"var(--text-muted)"},children:r}),a]}):u.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:n?"not-allowed":"pointer"},children:[a,u.jsx("span",{style:{fontSize:"14px",color:"var(--text-muted)"},children:r})]}):a}function bw({skillId:e,targetType:t,enabled:n,onChange:r,disabled:i}){const a=t==="claude-code"?"Claude Code":"Codex";return u.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:u.jsx(NE,{checked:n,onChange:o=>r(e,t,o),disabled:i,label:a,labelPosition:"right"})})}function TB(){var T,M,I,_,N,V;const[e,t]=m.useState(null),[n,r]=m.useState(""),[i,a]=m.useState(""),[o,l]=m.useState(""),[s,c]=m.useState({proxyEnabled:!1,proxyUrl:"",proxyUsername:"",proxyPassword:""}),[d,f]=m.useState(null),[p,h]=m.useState(!1),[g,y]=m.useState(!1);m.useEffect(()=>{x()},[]);const x=async()=>{const L=await Q.getConfig();t(L),c({proxyEnabled:L.proxyEnabled||!1,proxyUrl:L.proxyUrl||"",proxyUsername:L.proxyUsername||"",proxyPassword:L.proxyPassword||""})},v=async L=>{L.preventDefault();const O=new FormData(L.currentTarget),R={...e,apiKey:O.get("apiKey"),enableFailover:O.get("enableFailover")==="true"};await Q.updateConfig(R)?(re.success("配置保存成功"),x()):re.error("配置保存失败")},b=async L=>{L.preventDefault();const O=new FormData(L.currentTarget),R={...e,enableLogging:O.get("enableLogging")==="true",logRetentionDays:parseInt(O.get("logRetentionDays")),maxLogSize:parseInt(O.get("maxLogSize"))};await Q.updateConfig(R)?(re.success("日志配置保存成功"),x()):re.error("日志配置保存失败")},w=async L=>{L.preventDefault();const O=new FormData(L.currentTarget),R={...e,proxyEnabled:O.get("proxyEnabled")==="true",proxyUrl:O.get("proxyUrl"),proxyUsername:O.get("proxyUsername"),proxyPassword:O.get("proxyPassword")};await Q.updateConfig(R)?(re.success("代理配置保存成功"),x()):re.error("代理配置保存失败")},S=async()=>{if(!n){re.warning("请输入密码");return}try{const L=await Q.exportData(n);l(L),re.success("导出成功,请复制下方数据")}catch(L){re.error("导出失败: "+L.message)}},k=async()=>{if(!n||!i){re.warning("请输入密码和导入数据");return}h(!0);try{const L=await Q.previewImportData(i,n);f(L),L.success||re.error(L.message||"预览失败")}catch(L){re.error("预览失败: "+L.message),f({success:!1,message:L.message})}finally{h(!1)}},j=async()=>{if(!n||!i||!(d!=null&&d.success)){re.warning("请先预览数据并确认无误");return}y(!0);try{const L=await Q.importData(i,n);L.success?(re.success(L.message+(L.details?` (${L.details})`:"")),a(""),r(""),f(null)):re.error(L.message+(L.details?`: ${L.details}`:""))}catch(L){re.error("导入失败: "+L.message)}finally{y(!1)}},C=()=>{f(null),a(""),r("")};return e?u.jsxs("div",{children:[u.jsxs("div",{className:"page-header",children:[u.jsx("h1",{children:"设置"}),u.jsx("p",{children:"管理应用配置和数据导入导出"})]}),u.jsxs("div",{className:"card",children:[u.jsx("h3",{children:"应用配置"}),u.jsxs("form",{onSubmit:v,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"API Key"}),u.jsx("input",{type:"password",name:"apiKey",defaultValue:e.apiKey}),u.jsx("small",{style:{display:"block",marginTop:"4px",color:"#666",fontSize:"12px"},children:"当编程工具连接到aicodeswitch时,需要使用此API Key进行认证"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"启用智能故障切换"}),u.jsxs("select",{name:"enableFailover",defaultValue:e.enableFailover!==!1?"true":"false",children:[u.jsx("option",{value:"true",children:"是"}),u.jsx("option",{value:"false",children:"否"})]}),u.jsx("small",{style:{display:"block",marginTop:"4px",color:"#666",fontSize:"12px"},children:"启用后,当某个服务报错时会自动切换到备用服务,并将报错服务标记为不可用10分钟"})]}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存配置"})]})]}),u.jsxs("div",{className:"card",style:{marginTop:"20px"},children:[u.jsx("h3",{children:"日志设置"}),u.jsx("p",{style:{color:"#7f8c8d",fontSize:"14px"},children:"配置请求日志的记录和保留策略。"}),u.jsxs("form",{onSubmit:b,children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"启用日志"}),u.jsxs("select",{name:"enableLogging",defaultValue:e.enableLogging?"true":"false",children:[u.jsx("option",{value:"true",children:"是"}),u.jsx("option",{value:"false",children:"否"})]})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"日志保留天数"}),u.jsx("input",{type:"number",name:"logRetentionDays",defaultValue:e.logRetentionDays,required:!0})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"最大日志数量"}),u.jsx("input",{type:"number",name:"maxLogSize",defaultValue:e.maxLogSize,required:!0})]}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存日志配置"})]})]}),u.jsxs("div",{className:"card",style:{marginTop:"20px"},children:[u.jsx("h3",{children:"代理设置"}),u.jsx("p",{style:{color:"#7f8c8d",fontSize:"14px"},children:"配置代理服务器,API 服务可选择是否通过代理转发请求。"}),u.jsxs("form",{onSubmit:w,children:[u.jsx("input",{type:"hidden",name:"proxyEnabled",value:s.proxyEnabled?"true":"false"}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"启用代理"}),u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[u.jsx(NE,{checked:s.proxyEnabled,onChange:L=>c(O=>({...O,proxyEnabled:L}))}),u.jsx("span",{style:{fontSize:"14px",color:"#666"},children:s.proxyEnabled?"已启用":"未启用"})]})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"代理地址"}),u.jsx("input",{type:"text",name:"proxyUrl",value:s.proxyUrl,onChange:L=>c(O=>({...O,proxyUrl:L.target.value})),placeholder:"例如: proxy.example.com:8080 或 http://proxy.example.com:8080"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"代理用户名(可选)"}),u.jsx("input",{type:"text",name:"proxyUsername",value:s.proxyUsername,onChange:L=>c(O=>({...O,proxyUsername:L.target.value})),placeholder:"如果代理需要认证"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"代理密码(可选)"}),u.jsx("input",{type:"password",name:"proxyPassword",value:s.proxyPassword,onChange:L=>c(O=>({...O,proxyPassword:L.target.value})),placeholder:"如果代理需要认证"})]}),u.jsx("button",{type:"submit",className:"btn btn-primary",children:"保存代理配置"})]})]}),u.jsxs("div",{className:"card",style:{marginTop:"20px"},children:[u.jsx("h3",{children:"数据导出"}),u.jsx("p",{style:{color:"#7f8c8d",fontSize:"14px"},children:"导出所有配置数据,包括供应商、API服务、路由等。数据将使用密码加密。"}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"加密密码"}),u.jsx("input",{type:"password",value:n,onChange:L=>r(L.target.value),placeholder:"用于加密导出数据"})]}),u.jsx("button",{className:"btn btn-primary",onClick:S,children:"导出数据"}),o&&u.jsxs("div",{className:"form-group",style:{marginTop:"20px"},children:[u.jsx("label",{children:"导出的数据(请复制保存)"}),u.jsx("textarea",{rows:6,value:o,readOnly:!0,style:{fontFamily:"monospace",fontSize:"12px"}}),u.jsx("button",{className:"btn btn-secondary",style:{marginTop:"10px"},onClick:()=>{navigator.clipboard.writeText(o),re.success("已复制到剪贴板")},children:"复制到剪贴板"})]})]}),u.jsxs("div",{className:"card",style:{marginTop:"20px"},children:[u.jsx("h3",{children:"数据导入"}),u.jsx("p",{style:{color:"#e74c3c",fontSize:"14px",fontWeight:500},children:"警告:导入数据将覆盖所有现有配置!请确保已备份重要数据。"}),d!=null&&d.success?u.jsxs(u.Fragment,{children:[u.jsxs("div",{style:{marginTop:"15px",padding:"15px",backgroundColor:"#e8f4fd",borderRadius:"6px",border:"1px solid #bee5eb"},children:[u.jsx("h4",{style:{margin:"0 0 12px 0",color:"#0c5460",fontSize:"16px"},children:"数据预览"}),u.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"10px",marginBottom:"12px"},children:[u.jsxs("div",{style:{padding:"10px",backgroundColor:"white",borderRadius:"4px"},children:[u.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"供应商"}),u.jsx("div",{style:{fontSize:"20px",fontWeight:"bold",color:"#333"},children:((T=d.data)==null?void 0:T.vendors)||0})]}),u.jsxs("div",{style:{padding:"10px",backgroundColor:"white",borderRadius:"4px"},children:[u.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"API服务"}),u.jsx("div",{style:{fontSize:"20px",fontWeight:"bold",color:"#333"},children:((M=d.data)==null?void 0:M.services)||0})]}),u.jsxs("div",{style:{padding:"10px",backgroundColor:"white",borderRadius:"4px"},children:[u.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"路由"}),u.jsx("div",{style:{fontSize:"20px",fontWeight:"bold",color:"#333"},children:((I=d.data)==null?void 0:I.routes)||0})]}),u.jsxs("div",{style:{padding:"10px",backgroundColor:"white",borderRadius:"4px"},children:[u.jsx("div",{style:{fontSize:"12px",color:"#666"},children:"规则"}),u.jsx("div",{style:{fontSize:"20px",fontWeight:"bold",color:"#333"},children:((_=d.data)==null?void 0:_.rules)||0})]})]}),u.jsxs("div",{style:{fontSize:"12px",color:"#666",marginTop:"8px"},children:[u.jsxs("div",{children:["数据版本: ",(N=d.data)==null?void 0:N.version]}),u.jsxs("div",{children:["导出时间: ",(V=d.data)!=null&&V.exportDate?new Date(d.data.exportDate).toLocaleString("zh-CN"):"-"]})]})]}),u.jsxs("div",{style:{marginTop:"15px",padding:"12px",backgroundColor:"#fff3cd",borderRadius:"4px",border:"1px solid #ffeaa7",color:"#856404"},children:[u.jsx("strong",{children:"确认导入?"})," 此操作将覆盖所有现有的供应商、服务、路由和规则配置,且无法撤销。"]}),u.jsxs("div",{style:{marginTop:"15px",display:"flex",gap:"10px"},children:[u.jsx("button",{className:"btn btn-danger",onClick:j,disabled:g,children:g?"导入中...":"确认导入"}),u.jsx("button",{className:"btn btn-secondary",onClick:C,disabled:g,children:"取消"})]})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"解密密码"}),u.jsx("input",{type:"password",value:n,onChange:L=>r(L.target.value),placeholder:"用于解密导入数据"})]}),u.jsxs("div",{className:"form-group",children:[u.jsx("label",{children:"导入数据"}),u.jsx("textarea",{rows:6,value:i,onChange:L=>a(L.target.value),placeholder:"粘贴导出的加密数据",style:{fontFamily:"monospace",fontSize:"12px"}})]}),u.jsx("button",{className:"btn btn-primary",onClick:k,disabled:p||!n||!i,children:p?"预览中...":"预览数据"}),(d==null?void 0:d.success)===!1&&u.jsxs("div",{style:{marginTop:"10px",padding:"10px",backgroundColor:"#fdeaea",borderRadius:"4px",color:"#e74c3c"},children:[u.jsx("strong",{children:"预览失败:"}),d.message]})]})]})]}):u.jsx("div",{children:"加载中..."})}function IB(){var p,h,g,y,x,v,b,w;const[e,t]=m.useState({claude:!1,codex:!1}),[n,r]=m.useState({claude:!1,codex:!1}),[i,a]=m.useState({claude:null,codex:null}),[o,l]=m.useState("");m.useEffect(()=>{s()},[]);const s=async()=>{try{const[S,k]=await Promise.all([Q.getClaudeConfigStatus(),Q.getCodexConfigStatus()]);a({claude:S,codex:k})}catch(S){console.error("Failed to check config status:",S)}},c=async S=>{t(k=>({...k,[S]:!0})),l("");try{(S==="claude"?await Q.writeClaudeConfig():await Q.writeCodexConfig())?(l(`${S==="claude"?"Claude Code":"Codex"}配置文件写入成功!原始文件已备份为 .aicodeswitch_backup 文件。`),await s()):l("写入失败: 操作未成功")}catch(k){l(`写入失败: ${k.message}`)}finally{t(k=>({...k,[S]:!1}))}},d=async S=>{r(k=>({...k,[S]:!0})),l("");try{(S==="claude"?await Q.restoreClaudeConfig():await Q.restoreCodexConfig())?(l(`${S==="claude"?"Claude Code":"Codex"}配置文件已从备份恢复!`),await s()):l("恢复失败: 操作未成功")}catch(k){l(`恢复失败: ${k.message}`)}finally{r(k=>({...k,[S]:!1}))}},f=S=>{const k=i[S];if(!k)return null;const j=S==="claude"?"Claude Code":"Codex";return k.isOverwritten&&k.isModified?u.jsxs("p",{style:{color:"#f39c12",fontSize:"12px",marginTop:"10px"},children:["⚠️ 检测到",j,"配置已被修改,但备份文件仍然存在。建议先恢复原始配置,再重新写入以确保配置正确。"]}):k.isOverwritten&&!k.isModified?u.jsxs("p",{style:{color:"#27ae60",fontSize:"12px",marginTop:"10px"},children:["✓ ",j,"配置已正确设置为代理模式,且未被修改。"]}):!k.isOverwritten&&k.hasBackup?u.jsx("p",{style:{color:"#e74c3c",fontSize:"12px",marginTop:"10px"},children:"⚠️ 检测到配置状态不一致。备份文件存在但当前配置不是代理配置,请先恢复或手动删除备份文件。"}):null};return u.jsxs("div",{children:[u.jsxs("div",{className:"page-header",children:[u.jsx("h1",{children:"写入配置"}),u.jsx("p",{children:"将Claude Code和Codex的配置文件写入到用户目录"})]}),u.jsxs("div",{className:"card",style:{marginBottom:"20px"},children:[u.jsx("h3",{children:"Claude Code配置"}),u.jsx("p",{style:{color:"#7f8c8d",marginBottom:"15px"},children:"为Claude Code工具写入配置文件。原始文件将被备份为.aicodeswitch_backup文件。"}),u.jsxs("div",{style:{marginBottom:"15px"},children:[u.jsx("h4",{children:"配置文件:"}),u.jsxs("ul",{style:{color:"#7f8c8d",lineHeight:"1.6"},children:[u.jsxs("li",{children:[u.jsx("code",{children:"~/.claude/settings.json"})," - Claude Code设置"]}),u.jsxs("li",{children:[u.jsx("code",{children:"~/.claude.json"})," - Claude Code初始化设置"]})]})]}),u.jsxs("div",{style:{display:"flex",gap:"10px"},children:[u.jsx("button",{className:"btn btn-primary",onClick:()=>c("claude"),disabled:e.claude||(((p=i.claude)==null?void 0:p.isOverwritten)??!1),children:e.claude?"写入中...":"写入Claude Code配置"}),u.jsx("button",{className:"btn btn-secondary",onClick:()=>d("claude"),disabled:n.claude||!(((h=i.claude)==null?void 0:h.hasBackup)??!1),children:n.claude?"恢复中...":"恢复Claude Code配置"})]}),f("claude"),((g=i.claude)==null?void 0:g.isOverwritten)&&!((y=i.claude)!=null&&y.isModified)&&u.jsx("p",{style:{color:"#e74c3c",fontSize:"12px",marginTop:"10px"},children:"⚠️ 配置已被覆盖,如需重新写入请先恢复原始配置"})]}),u.jsxs("div",{className:"card",children:[u.jsx("h3",{children:"Codex配置"}),u.jsx("p",{style:{color:"#7f8c8d",marginBottom:"15px"},children:"为Codex工具写入配置文件。原始文件将被备份为.aicodeswitch_backup文件。"}),u.jsxs("div",{style:{marginBottom:"15px"},children:[u.jsx("h4",{children:"配置文件:"}),u.jsxs("ul",{style:{color:"#7f8c8d",lineHeight:"1.6"},children:[u.jsxs("li",{children:[u.jsx("code",{children:"~/.codex/config.toml"})," - Codex配置"]}),u.jsxs("li",{children:[u.jsx("code",{children:"~/.codex/auth.json"})," - Codex认证信息"]})]})]}),u.jsxs("div",{style:{display:"flex",gap:"10px"},children:[u.jsx("button",{className:"btn btn-primary",onClick:()=>c("codex"),disabled:e.codex||(((x=i.codex)==null?void 0:x.isOverwritten)??!1),children:e.codex?"写入中...":"写入Codex配置"}),u.jsx("button",{className:"btn btn-secondary",onClick:()=>d("codex"),disabled:n.codex||!(((v=i.codex)==null?void 0:v.hasBackup)??!1),children:n.codex?"恢复中...":"恢复Codex配置"})]}),f("codex"),((b=i.codex)==null?void 0:b.isOverwritten)&&!((w=i.codex)!=null&&w.isModified)&&u.jsx("p",{style:{color:"#e74c3c",fontSize:"12px",marginTop:"10px"},children:"⚠️ 配置已被覆盖,如需重新写入请先恢复原始配置"})]}),o&&u.jsx("div",{style:{marginTop:"20px",padding:"10px",borderRadius:"4px",backgroundColor:o.includes("成功")?"#d4edda":"#f8d7da",color:o.includes("成功")?"#155724":"#721c24",border:`1px solid ${o.includes("成功")?"#c3e6cb":"#f5c6cb"}`},children:o})]})}const _B=`# AI Code Switch
138
138
 
139
139
  ## 简介
140
140
 
@@ -165,6 +165,7 @@ AI Code Switch 是帮助你在本地管理 AI 编程工具接入大模型的工
165
165
  * 导入和导出:一键备份数据,在多太电脑间共享aicodeswitch配置
166
166
  * 自定义API Key,支持B/S架构,让aicodeswitch成为在线服务,提供给团队使用
167
167
  * 数据完全本地,自主可控
168
+ * 特殊语法:在发送的提示词最前面添加!!来直接切换为高智商模型服务,简单快捷
168
169
 
169
170
  ## 桌面客户端
170
171