diff --git a/.management-html-version b/.management-html-version
index f0b77c1..257d138 100644
--- a/.management-html-version
+++ b/.management-html-version
@@ -1 +1 @@
-v1.7.7
+v1.7.8
diff --git a/management.html b/management.html
index 91c3b77..6914954 100644
--- a/management.html
+++ b/management.html
@@ -5,179 +5,180 @@
CLI Proxy API Management Center
-
-
+`,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const n=k_(e),i=Au(n);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const n=k_(e),i=Au(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function Ove(t){const e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Nve||null,prettyErrors:e}}function vm(t,e={}){const{lineCounter:n,prettyErrors:i}=Ove(e),s=new Mve(n?.addNewLine),a=new wve(e);let o=null;for(const r of a.compose(s.parse(t),!0,t.length))if(!o)o=r;else if(o.options.logLevel!=="silent"){o.errors.push(new _f(r.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&n&&(o.errors.forEach(Uj(t,n)),o.warnings.forEach(Uj(t,n))),o}function AF(t,e,n){let i;const s=vm(t,n);if(!s)return null;if(s.warnings.forEach(a=>J8(s.options.logLevel,a)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:i},n))}function Yo({title:t,description:e,className:n,children:i}){return h.jsxs(At,{title:t,className:n,children:[e&&h.jsx("p",{style:{margin:"-4px 0 16px 0",color:"var(--text-secondary)",fontSize:13},children:e}),i]})}const Lve="VisualConfigEditor-module__payloadRuleModelRow___VKBv1",Eve="VisualConfigEditor-module__payloadRuleModelRowProtocolFirst___OaJ2F",Pve="VisualConfigEditor-module__payloadRuleParamRow___KZJW-",jve="VisualConfigEditor-module__payloadRuleParamGroup___1QLNQ",Rve="VisualConfigEditor-module__payloadJsonInput___ewOqz",Dve="VisualConfigEditor-module__payloadParamError___wGWdg",Fve="VisualConfigEditor-module__payloadFilterModelRow___MeP9-",Uve="VisualConfigEditor-module__apiKeyModalInputRow___08QmU",Ive="VisualConfigEditor-module__payloadRowActionButton___8Fdka",Fa={payloadRuleModelRow:Lve,payloadRuleModelRowProtocolFirst:Eve,payloadRuleParamRow:Pve,payloadRuleParamGroup:jve,payloadJsonInput:Rve,payloadParamError:Dve,payloadFilterModelRow:Fve,apiKeyModalInputRow:Uve,payloadRowActionButton:Ive},za=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,Hj={host:"",port:"",tlsEnable:!1,tlsCert:"",tlsKey:"",rmAllowRemote:!1,rmSecretKey:"",rmDisableControlPanel:!1,rmPanelRepo:"",authDir:"",apiKeysText:"",debug:!1,commercialMode:!1,loggingToFile:!1,logsMaxTotalSizeMb:"",usageStatisticsEnabled:!1,proxyUrl:"",forceModelPrefix:!1,requestRetry:"",maxRetryInterval:"",quotaSwitchProject:!0,quotaSwitchPreviewModel:!0,routingStrategy:"round-robin",wsAuth:!1,payloadDefaultRules:[],payloadOverrideRules:[],payloadFilterRules:[],streaming:{keepaliveSeconds:"",bootstrapRetries:"",nonstreamKeepaliveInterval:""}};function ei(t){return t===null||typeof t!="object"||Array.isArray(t)?null:t}function Bve(t){if(typeof t=="string"){const i=t.trim();return i||null}const e=ei(t);if(!e)return null;const n=[e["api-key"],e.apiKey,e.key,e.Key];for(const i of n)if(typeof i=="string"){const s=i.trim();if(s)return s}return null}function Vj(t){if(!Array.isArray(t))return"";const e=[];for(const n of t){const i=Bve(n);i&&e.push(i)}return e.join(`
+`)}function Wj(t,e){const n=ei(t);return n?"api-key"in n?{...n,"api-key":e}:"apiKey"in n?{...n,apiKey:e}:"key"in n?{...n,key:e}:"Key"in n?{...n,Key:e}:{...n,"api-key":e}:e}function qve(t,e){return t.map((n,i)=>{const s=e.originalEntries[i];if(e.entryMode==="object"){const o=Wj(s,n);return ei(o)??{"api-key":n}}const a=ei(s);return a?{...a,...Wj(a,n)}:n})}function Kve(t){const e=Array.isArray(t["api-keys"])?t["api-keys"]:[],n=ei(t.auth),i=ei(n?.providers),s=ei(i?.["config-api-key"]);if(s){const a=Array.isArray(s["api-key-entries"])?s["api-key-entries"]:Array.isArray(s["api-keys"])?s["api-keys"]:[],o=Array.isArray(s["api-key-entries"])?"api-key-entries":"api-keys";return{text:Vj(a),metadata:{source:"auth-provider",providerListKey:o,entryMode:o==="api-key-entries"||a.some(r=>!!ei(r))?"object":"string",originalEntries:a,syncLegacy:e.length>0}}}return{text:Vj(e),metadata:{source:"legacy",entryMode:e.some(a=>!!ei(a))?"object":"string",originalEntries:e,syncLegacy:!1}}}const zve={source:"legacy",entryMode:"string",originalEntries:[],syncLegacy:!1};function Hi(t,e){return t.hasIn(e)}function Jo(t,e){const n=t.getIn(e,!0);vl(n)||t.setIn(e,{})}function Zo(t,e){const n=t.getIn(e,!0);vl(n)&&n.items.length===0&&t.deleteIn(e)}function er(t,e,n){if(n){t.setIn(e,!0);return}Hi(t,e)&&t.setIn(e,!1)}function Wl(t,e,n){const i=typeof n=="string"?n:"";if(i.trim()!==""){t.setIn(e,i);return}Hi(t,e)&&t.setIn(e,"")}function Gl(t,e,n){const s=(typeof n=="string"?n:"").trim();if(s===""){Hi(t,e)&&t.deleteIn(e);return}if(!/^-?\d+$/.test(s))return;const a=Number(s);if(Number.isFinite(a)){t.setIn(e,a);return}}function Tu(t){const e=t.trim();if(e)return/^-?\d+$/.test(e)&&Number(e)>=0?void 0:"non_negative_integer"}function Hve(t){const e=t.trim();if(!e)return;if(!/^\d+$/.test(e))return"port_range";const n=Number(e);return n>=1&&n<=65535?void 0:"port_range"}function Vve(t){return{port:Hve(t.port),logsMaxTotalSizeMb:Tu(t.logsMaxTotalSizeMb),requestRetry:Tu(t.requestRetry),maxRetryInterval:Tu(t.maxRetryInterval),"streaming.keepaliveSeconds":Tu(t.streaming.keepaliveSeconds),"streaming.bootstrapRetries":Tu(t.streaming.bootstrapRetries),"streaming.nonstreamKeepaliveInterval":Tu(t.streaming.nonstreamKeepaliveInterval)}}function TF(t){const e=t.value.trim();switch(t.valueType){case"number":{if(!e)return"payload_invalid_number";const n=Number(e);return Number.isFinite(n)?void 0:"payload_invalid_number"}case"boolean":{const n=e.toLowerCase();return n==="true"||n==="false"?void 0:"payload_invalid_boolean"}case"json":{if(!e)return"payload_invalid_json";try{JSON.parse(t.value);return}catch{return"payload_invalid_json"}}default:return}}function Gj(t){return t.some(e=>e.params.some(n=>!!TF(n)))}function Wve(t){return typeof structuredClone=="function"?structuredClone(t):JSON.parse(JSON.stringify(t))}function Gve(t){if(typeof t=="number")return{valueType:"number",value:String(t)};if(typeof t=="boolean")return{valueType:"boolean",value:String(t)};if(t===null||typeof t=="object")try{return{valueType:"json",value:JSON.stringify(t,null,2)??"null"}}catch{return{valueType:"json",value:String(t)}}return{valueType:"string",value:String(t??"")}}const $ve=["openai","openai-response","gemini","claude","codex","antigravity"];function NF(t){if(typeof t=="string")return $ve.includes(t)?t:void 0}function $j(t){return Array.isArray(t)?t.map((e,n)=>{const i=ei(e)??{},s=i.models,a=Array.isArray(s)?s.map((c,d)=>{const f=ei(c),p=typeof c=="string"?c:f?.name??f?.id??"",g=typeof p=="string"?p:String(p??"");return{id:`model-${n}-${d}`,name:g,protocol:NF(f?.protocol)}}):[],o=ei(i.params),r=o?Object.entries(o).map(([c,d],f)=>{const p=Gve(d);return{id:`param-${n}-${f}`,path:c,valueType:p.valueType,value:p.value}}):[];return{id:`payload-rule-${n}`,models:a,params:r}}):[]}function Xve(t){return Array.isArray(t)?t.map((e,n)=>{const i=ei(e)??{},s=i.models,a=Array.isArray(s)?s.map((c,d)=>{const f=ei(c),p=typeof c=="string"?c:f?.name??f?.id??"",g=typeof p=="string"?p:String(p??"");return{id:`filter-model-${n}-${d}`,name:g,protocol:NF(f?.protocol)}}):[],o=i.params,r=Array.isArray(o)?o.map(String):[];return{id:`payload-filter-rule-${n}`,models:a,params:r}}):[]}function Xj(t){return t.map(e=>{const n=(e.models||[]).filter(s=>s.name?.trim()).map(s=>{const a={name:s.name.trim()};return s.protocol&&(a.protocol=s.protocol),a}),i={};for(const s of e.params||[]){if(!s.path?.trim())continue;let a=s.value;if(s.valueType==="number"){const o=Number(s.value);a=Number.isFinite(o)?o:s.value}else if(s.valueType==="boolean")a=s.value==="true";else if(s.valueType==="json")try{a=JSON.parse(s.value)}catch{a=s.value}i[s.path.trim()]=a}return{models:n,params:i}}).filter(e=>e.models.length>0)}function Qve(t){return t.map(e=>{const n=(e.models||[]).filter(s=>s.name?.trim()).map(s=>{const a={name:s.name.trim()};return s.protocol&&(a.protocol=s.protocol),a}),i=(Array.isArray(e.params)?e.params:[]).map(s=>String(s).trim()).filter(Boolean);return{models:n,params:i}}).filter(e=>e.models.length>0)}function Yve(){const[t,e]=w.useState({...Hj}),[n,i]=w.useState({...Hj}),[s,a]=w.useState(null),[o,r]=w.useState(zve),c=w.useMemo(()=>Vve(t),[t]),d=w.useMemo(()=>Gj(t.payloadDefaultRules)||Gj(t.payloadOverrideRules),[t.payloadDefaultRules,t.payloadOverrideRules]),f=w.useMemo(()=>JSON.stringify(t)!==JSON.stringify(n),[n,t]),p=w.useCallback(b=>{try{const x=vm(b);if(x.errors.length>0)throw new Error(x.errors[0]?.message??"Invalid YAML");const v=AF(b)||{},k=ei(v)??{},A=ei(k.tls),T=ei(k["remote-management"]),L=ei(k["quota-exceeded"]),N=ei(k.routing),O=ei(k.payload),M=ei(k.streaming),E=Kve(k),j={host:typeof k.host=="string"?k.host:"",port:String(k.port??""),tlsEnable:!!A?.enable,tlsCert:typeof A?.cert=="string"?A.cert:"",tlsKey:typeof A?.key=="string"?A.key:"",rmAllowRemote:!!T?.["allow-remote"],rmSecretKey:typeof T?.["secret-key"]=="string"?T["secret-key"]:"",rmDisableControlPanel:!!T?.["disable-control-panel"],rmPanelRepo:typeof T?.["panel-github-repository"]=="string"?T["panel-github-repository"]:typeof T?.["panel-repo"]=="string"?T["panel-repo"]:"",authDir:typeof k["auth-dir"]=="string"?k["auth-dir"]:"",apiKeysText:E.text,debug:!!k.debug,commercialMode:!!k["commercial-mode"],loggingToFile:!!k["logging-to-file"],logsMaxTotalSizeMb:String(k["logs-max-total-size-mb"]??""),usageStatisticsEnabled:!!k["usage-statistics-enabled"],proxyUrl:typeof k["proxy-url"]=="string"?k["proxy-url"]:"",forceModelPrefix:!!k["force-model-prefix"],requestRetry:String(k["request-retry"]??""),maxRetryInterval:String(k["max-retry-interval"]??""),wsAuth:!!k["ws-auth"],quotaSwitchProject:!!(L?.["switch-project"]??!0),quotaSwitchPreviewModel:!!(L?.["switch-preview-model"]??!0),routingStrategy:N?.strategy==="fill-first"?"fill-first":"round-robin",payloadDefaultRules:$j(O?.default),payloadOverrideRules:$j(O?.override),payloadFilterRules:Xve(O?.filter),streaming:{keepaliveSeconds:String(M?.["keepalive-seconds"]??""),bootstrapRetries:String(M?.["bootstrap-retries"]??""),nonstreamKeepaliveInterval:String(k["nonstream-keepalive-interval"]??"")}};return e(j),i(Wve(j)),r(E.metadata),a(null),{ok:!0}}catch(x){const v=x instanceof Error?x.message:"Invalid YAML";return a(v),{ok:!1,error:v}}},[]),g=w.useCallback(b=>{try{const x=vm(b);if(x.errors.length>0)return b;vl(x.contents)||(x.contents=x.createNode({}));const v=t;if(Wl(x,["host"],v.host),Gl(x,["port"],v.port),(Hi(x,["tls"])||v.tlsEnable||v.tlsCert.trim()||v.tlsKey.trim())&&(Jo(x,["tls"]),er(x,["tls","enable"],v.tlsEnable),Wl(x,["tls","cert"],v.tlsCert),Wl(x,["tls","key"],v.tlsKey),Zo(x,["tls"])),(Hi(x,["remote-management"])||v.rmAllowRemote||v.rmSecretKey.trim()||v.rmDisableControlPanel||v.rmPanelRepo.trim())&&(Jo(x,["remote-management"]),er(x,["remote-management","allow-remote"],v.rmAllowRemote),Wl(x,["remote-management","secret-key"],v.rmSecretKey),er(x,["remote-management","disable-control-panel"],v.rmDisableControlPanel),Wl(x,["remote-management","panel-github-repository"],v.rmPanelRepo),Hi(x,["remote-management","panel-repo"])&&x.deleteIn(["remote-management","panel-repo"]),Zo(x,["remote-management"])),Wl(x,["auth-dir"],v.authDir),v.apiKeysText!==n.apiKeysText){const N=v.apiKeysText.split(`
+`).map(M=>M.trim()).filter(Boolean),O=qve(N,o);if(o.source==="auth-provider"){Jo(x,["auth"]),Jo(x,["auth","providers"]),Jo(x,["auth","providers","config-api-key"]);const E=["auth","providers","config-api-key",o.providerListKey??"api-key-entries"];N.length>0?x.setIn(E,O):Hi(x,E)&&x.deleteIn(E),Zo(x,["auth","providers","config-api-key"]),Zo(x,["auth","providers"]),Zo(x,["auth"]),o.syncLegacy&&(N.length>0?x.setIn(["api-keys"],N):Hi(x,["api-keys"])&&x.deleteIn(["api-keys"]))}else N.length>0?x.setIn(["api-keys"],O):Hi(x,["api-keys"])&&x.deleteIn(["api-keys"])}er(x,["debug"],v.debug),er(x,["commercial-mode"],v.commercialMode),er(x,["logging-to-file"],v.loggingToFile),Gl(x,["logs-max-total-size-mb"],v.logsMaxTotalSizeMb),er(x,["usage-statistics-enabled"],v.usageStatisticsEnabled),Wl(x,["proxy-url"],v.proxyUrl),er(x,["force-model-prefix"],v.forceModelPrefix),Gl(x,["request-retry"],v.requestRetry),Gl(x,["max-retry-interval"],v.maxRetryInterval),er(x,["ws-auth"],v.wsAuth),(Hi(x,["quota-exceeded"])||!v.quotaSwitchProject||!v.quotaSwitchPreviewModel)&&(Jo(x,["quota-exceeded"]),x.setIn(["quota-exceeded","switch-project"],v.quotaSwitchProject),x.setIn(["quota-exceeded","switch-preview-model"],v.quotaSwitchPreviewModel),Zo(x,["quota-exceeded"])),(Hi(x,["routing"])||v.routingStrategy!=="round-robin")&&(Jo(x,["routing"]),x.setIn(["routing","strategy"],v.routingStrategy),Zo(x,["routing"]));const k=typeof v.streaming?.keepaliveSeconds=="string"?v.streaming.keepaliveSeconds:"",A=typeof v.streaming?.bootstrapRetries=="string"?v.streaming.bootstrapRetries:"",T=typeof v.streaming?.nonstreamKeepaliveInterval=="string"?v.streaming.nonstreamKeepaliveInterval:"";return(Hi(x,["streaming"])||k.trim()||A.trim())&&(Jo(x,["streaming"]),Gl(x,["streaming","keepalive-seconds"],k),Gl(x,["streaming","bootstrap-retries"],A),Zo(x,["streaming"])),Gl(x,["nonstream-keepalive-interval"],T),(Hi(x,["payload"])||v.payloadDefaultRules.length>0||v.payloadOverrideRules.length>0||v.payloadFilterRules.length>0)&&(Jo(x,["payload"]),v.payloadDefaultRules.length>0?x.setIn(["payload","default"],Xj(v.payloadDefaultRules)):Hi(x,["payload","default"])&&x.deleteIn(["payload","default"]),v.payloadOverrideRules.length>0?x.setIn(["payload","override"],Xj(v.payloadOverrideRules)):Hi(x,["payload","override"])&&x.deleteIn(["payload","override"]),v.payloadFilterRules.length>0?x.setIn(["payload","filter"],Qve(v.payloadFilterRules)):Hi(x,["payload","filter"])&&x.deleteIn(["payload","filter"]),Zo(x,["payload"])),x.toString({indent:2,lineWidth:120,minContentWidth:0})}catch{return b}},[o,n,t]),y=w.useCallback(b=>{e(x=>{const v={...x,...b};return b.streaming&&(v.streaming={...x.streaming,...b.streaming}),v})},[]);return{visualValues:t,visualDirty:f,visualParseError:s,visualValidationErrors:c,visualHasPayloadValidationErrors:d,loadVisualValuesFromYaml:p,applyVisualChangesToYaml:g,setVisualValues:y}}const MF=[{value:"",labelKey:"config_management.visual.payload_rules.provider_default",defaultLabel:"Default"},{value:"openai",labelKey:"config_management.visual.payload_rules.provider_openai",defaultLabel:"OpenAI"},{value:"openai-response",labelKey:"config_management.visual.payload_rules.provider_openai_response",defaultLabel:"OpenAI Response"},{value:"gemini",labelKey:"config_management.visual.payload_rules.provider_gemini",defaultLabel:"Gemini"},{value:"claude",labelKey:"config_management.visual.payload_rules.provider_claude",defaultLabel:"Claude"},{value:"codex",labelKey:"config_management.visual.payload_rules.provider_codex",defaultLabel:"Codex"},{value:"antigravity",labelKey:"config_management.visual.payload_rules.provider_antigravity",defaultLabel:"Antigravity"}],Jve=[{value:"string",labelKey:"config_management.visual.payload_rules.value_type_string",defaultLabel:"String"},{value:"number",labelKey:"config_management.visual.payload_rules.value_type_number",defaultLabel:"Number"},{value:"boolean",labelKey:"config_management.visual.payload_rules.value_type_boolean",defaultLabel:"Boolean"},{value:"json",labelKey:"config_management.visual.payload_rules.value_type_json",defaultLabel:"JSON"}];function Zve(t){return t?/^[\x21-\x7E]+$/.test(t):!1}function e1e(t,e){if(e)return t(`config_management.visual.validation.${e}`)}const t1e=w.memo(function({value:e,disabled:n,onChange:i}){const{t:s}=Ye(),a=un(G=>G.showNotification),o=w.useMemo(()=>e.split(`
+`).map(G=>G.trim()).filter(Boolean),[e]),[r,c]=w.useState(()=>o.map(()=>za())),d=w.useMemo(()=>r.length===o.length?r:r.length>o.length?r.slice(0,o.length):[...r,...Array.from({length:o.length-r.length},()=>za())],[r,o.length]),f=w.useId(),p=`${f}-hint`,g=`${f}-error`,[y,b]=w.useState(!1),[x,v]=w.useState(null),[k,A]=w.useState(""),[T,L]=w.useState("");function N(){const G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Q=new Uint8Array(17);return crypto.getRandomValues(Q),"sk-"+Array.from(Q,B=>G[B%G.length]).join("")}const O=()=>{v(null),A(""),L(""),b(!0)},M=G=>{const Q=d.findIndex(B=>B===G);v(G),A(o[Q]??""),L(""),b(!0)},E=()=>{b(!1),A(""),v(null),L("")},j=G=>{i(G.join(`
+`))},P=G=>{const Q=d.findIndex(B=>B===G);Q<0||(c(d.filter(B=>B!==G)),j(o.filter((B,W)=>W!==Q)))},F=()=>{const G=k.trim();if(!G){L(s("config_management.visual.api_keys.error_empty"));return}if(!Zve(G)){L(s("config_management.visual.api_keys.error_invalid"));return}const Q=x?d.findIndex(W=>W===x):-1,B=x===null?[...o,G]:o.map((W,$)=>$===Q?G:W);x===null&&c([...d,za()]),j(B),E()},D=async G=>{const Q=await gy(G);a(s(Q?"notification.link_copied":"notification.copy_failed"),Q?"success":"error")},z=()=>{A(N()),L("")};return h.jsxs("div",{className:"form-group",style:{marginBottom:0},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[h.jsx("label",{style:{margin:0},children:s("config_management.visual.api_keys.label")}),h.jsx(de,{size:"sm",onClick:O,disabled:n,children:s("config_management.visual.api_keys.add")})]}),o.length===0?h.jsx("div",{style:{border:"1px dashed var(--border-color)",borderRadius:12,padding:16,color:"var(--text-secondary)",textAlign:"center"},children:s("config_management.visual.api_keys.empty")}):h.jsx("div",{className:"item-list",style:{marginTop:4},children:o.map((G,Q)=>h.jsxs("div",{className:"item-row",children:[h.jsxs("div",{className:"item-meta",children:[h.jsxs("div",{className:"pill",children:["#",Q+1]}),h.jsx("div",{className:"item-title",children:s("config_management.visual.api_keys.input_label")}),h.jsx("div",{className:"item-subtitle",children:Sa(String(G||""))})]}),h.jsxs("div",{className:"item-actions",children:[h.jsx(de,{variant:"secondary",size:"sm",onClick:()=>D(G),disabled:n,children:s("common.copy")}),h.jsx(de,{variant:"secondary",size:"sm",onClick:()=>M(d[Q]??""),disabled:n,children:s("config_management.visual.common.edit")}),h.jsx(de,{variant:"danger",size:"sm",onClick:()=>P(d[Q]??""),disabled:n,children:s("config_management.visual.common.delete")})]})]},d[Q]??`${G}-${Q}`))}),h.jsx("div",{className:"hint",children:s("config_management.visual.api_keys.hint")}),h.jsx(ns,{open:y,onClose:E,title:s(x!==null?"config_management.visual.api_keys.edit_title":"config_management.visual.api_keys.add_title"),footer:h.jsxs(h.Fragment,{children:[h.jsx(de,{variant:"secondary",onClick:E,disabled:n,children:s("config_management.visual.common.cancel")}),h.jsx(de,{onClick:F,disabled:n,children:s(x!==null?"config_management.visual.common.update":"config_management.visual.common.add")})]}),children:h.jsxs("div",{className:"form-group",children:[h.jsx("label",{htmlFor:f,children:s("config_management.visual.api_keys.input_label")}),h.jsxs("div",{className:Fa.apiKeyModalInputRow,children:[h.jsx("input",{id:f,className:"input",placeholder:s("config_management.visual.api_keys.input_placeholder"),value:k,onChange:G=>A(G.target.value),disabled:n,"aria-describedby":T?`${g} ${p}`:p,"aria-invalid":!!T}),h.jsx(de,{type:"button",variant:"secondary",size:"sm",onClick:z,disabled:n,children:s("config_management.visual.api_keys.generate")})]}),h.jsx("div",{id:p,className:"hint",children:s("config_management.visual.api_keys.input_hint")}),T&&h.jsx("div",{id:g,className:"error-box",children:T})]})})]})}),n1e=w.memo(function({value:e,disabled:n,placeholder:i,inputAriaLabel:s,onChange:a}){const{t:o}=Ye(),r=e.length?e:[],[c,d]=w.useState(()=>r.map(()=>za())),f=w.useMemo(()=>c.length===r.length?c:c.length>r.length?c.slice(0,r.length):[...c,...Array.from({length:r.length-c.length},()=>za())],[c,r.length]),p=(b,x)=>a(r.map((v,k)=>k===b?x:v)),g=()=>{d([...f,za()]),a([...r,""])},y=b=>{d(f.filter((x,v)=>v!==b)),a(r.filter((x,v)=>v!==b))};return h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.map((b,x)=>h.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[h.jsx("input",{className:"input",placeholder:i,"aria-label":s??i,value:b,onChange:v=>p(x,v.target.value),disabled:n,style:{flex:1}}),h.jsx(de,{variant:"ghost",size:"sm",onClick:()=>y(x),disabled:n,children:o("config_management.visual.common.delete")})]},f[x]??`item-${x}`)),h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx(de,{variant:"secondary",size:"sm",onClick:g,disabled:n,children:o("config_management.visual.common.add")})})]})}),Qj=w.memo(function({value:e,disabled:n,protocolFirst:i=!1,onChange:s}){const{t:a}=Ye(),o=e.length?e:[],r=w.useMemo(()=>MF.map(O=>({value:O.value,label:a(O.labelKey,{defaultValue:O.defaultLabel})})),[a]),c=w.useMemo(()=>Jve.map(O=>({value:O.value,label:a(O.labelKey,{defaultValue:O.defaultLabel})})),[a]),d=w.useMemo(()=>[{value:"true",label:a("config_management.visual.payload_rules.boolean_true")},{value:"false",label:a("config_management.visual.payload_rules.boolean_false")}],[a]),f=()=>s([...o,{id:za(),models:[],params:[]}]),p=O=>s(o.filter((M,E)=>E!==O)),g=(O,M)=>s(o.map((E,j)=>j===O?{...E,...M}:E)),y=O=>{const M=o[O],E={id:za(),name:"",protocol:void 0};g(O,{models:[...M.models,E]})},b=(O,M)=>{const E=o[O];g(O,{models:E.models.filter((j,P)=>P!==M)})},x=(O,M,E)=>{const j=o[O];g(O,{models:j.models.map((P,F)=>F===M?{...P,...E}:P)})},v=O=>{const M=o[O],E={id:za(),path:"",valueType:"string",value:""};g(O,{params:[...M.params,E]})},k=(O,M)=>{const E=o[O];g(O,{params:E.params.filter((j,P)=>P!==M)})},A=(O,M,E)=>{const j=o[O];g(O,{params:j.params.map((P,F)=>F===M?{...P,...E}:P)})},T=O=>{switch(O){case"string":return a("config_management.visual.payload_rules.value_string");case"number":return a("config_management.visual.payload_rules.value_number");case"boolean":return a("config_management.visual.payload_rules.value_boolean");case"json":return a("config_management.visual.payload_rules.value_json");default:return a("config_management.visual.payload_rules.value_default")}},L=O=>{const M=TF(O);return e1e(a,M)},N=(O,M,E)=>E.valueType==="boolean"?h.jsx(Yi,{value:E.value.toLowerCase()==="true"||E.value.toLowerCase()==="false"?E.value.toLowerCase():"",options:d,placeholder:a("config_management.visual.payload_rules.value_boolean"),disabled:n,ariaLabel:a("config_management.visual.payload_rules.param_value"),onChange:j=>A(O,M,{value:j})}):E.valueType==="json"?h.jsx("textarea",{className:`input ${Fa.payloadJsonInput}`,placeholder:T(E.valueType),"aria-label":a("config_management.visual.payload_rules.param_value"),value:E.value,onChange:j=>A(O,M,{value:j.target.value}),disabled:n}):h.jsx("input",{className:"input",placeholder:T(E.valueType),"aria-label":a("config_management.visual.payload_rules.param_value"),value:E.value,onChange:j=>A(O,M,{value:j.target.value}),disabled:n});return h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[o.map((O,M)=>h.jsxs("div",{style:{border:"1px solid var(--border-color)",borderRadius:12,padding:12,display:"flex",flexDirection:"column",gap:12},children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:12,flexWrap:"wrap"},children:[h.jsxs("div",{style:{fontWeight:700,color:"var(--text-primary)"},children:[a("config_management.visual.payload_rules.rule")," ",M+1]}),h.jsx(de,{variant:"ghost",size:"sm",onClick:()=>p(M),disabled:n,children:a("config_management.visual.common.delete")})]}),h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[h.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-secondary)"},children:a("config_management.visual.payload_rules.models")}),(O.models.length?O.models:[]).map((E,j)=>h.jsxs("div",{className:[Fa.payloadRuleModelRow,i?Fa.payloadRuleModelRowProtocolFirst:""].filter(Boolean).join(" "),children:[i?h.jsxs(h.Fragment,{children:[h.jsx(Yi,{value:E.protocol??"",options:r,disabled:n,ariaLabel:a("config_management.visual.payload_rules.provider_type"),onChange:P=>x(M,j,{protocol:P||void 0})}),h.jsx("input",{className:"input",placeholder:a("config_management.visual.payload_rules.model_name"),"aria-label":a("config_management.visual.payload_rules.model_name"),value:E.name,onChange:P=>x(M,j,{name:P.target.value}),disabled:n})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{className:"input",placeholder:a("config_management.visual.payload_rules.model_name"),"aria-label":a("config_management.visual.payload_rules.model_name"),value:E.name,onChange:P=>x(M,j,{name:P.target.value}),disabled:n}),h.jsx(Yi,{value:E.protocol??"",options:r,disabled:n,ariaLabel:a("config_management.visual.payload_rules.provider_type"),onChange:P=>x(M,j,{protocol:P||void 0})})]}),h.jsx(de,{variant:"ghost",size:"sm",className:Fa.payloadRowActionButton,onClick:()=>b(M,j),disabled:n,children:a("config_management.visual.common.delete")})]},E.id)),h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx(de,{variant:"secondary",size:"sm",onClick:()=>y(M),disabled:n,children:a("config_management.visual.payload_rules.add_model")})})]}),h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[h.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-secondary)"},children:a("config_management.visual.payload_rules.params")}),(O.params.length?O.params:[]).map((E,j)=>{const P=L(E);return h.jsxs("div",{className:Fa.payloadRuleParamGroup,children:[h.jsxs("div",{className:Fa.payloadRuleParamRow,children:[h.jsx("input",{className:"input",placeholder:a("config_management.visual.payload_rules.json_path"),"aria-label":a("config_management.visual.payload_rules.json_path"),value:E.path,onChange:F=>A(M,j,{path:F.target.value}),disabled:n}),h.jsx(Yi,{value:E.valueType,options:c,disabled:n,ariaLabel:a("config_management.visual.payload_rules.param_type"),onChange:F=>A(M,j,{valueType:F,value:F==="boolean"?"true":F==="json"&&E.value.trim()===""?"{}":E.value})}),N(M,j,E),h.jsx(de,{variant:"ghost",size:"sm",className:Fa.payloadRowActionButton,onClick:()=>k(M,j),disabled:n,children:a("config_management.visual.common.delete")})]}),P&&h.jsx("div",{className:`error-box ${Fa.payloadParamError}`,children:P})]},E.id)}),h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx(de,{variant:"secondary",size:"sm",onClick:()=>v(M),disabled:n,children:a("config_management.visual.payload_rules.add_param")})})]})]},O.id)),o.length===0&&h.jsx("div",{style:{border:"1px dashed var(--border-color)",borderRadius:12,padding:16,color:"var(--text-secondary)",textAlign:"center"},children:a("config_management.visual.payload_rules.no_rules")}),h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx(de,{variant:"secondary",size:"sm",onClick:f,disabled:n,children:a("config_management.visual.payload_rules.add_rule")})})]})}),i1e=w.memo(function({value:e,disabled:n,onChange:i}){const{t:s}=Ye(),a=e.length?e:[],o=w.useMemo(()=>MF.map(y=>({value:y.value,label:s(y.labelKey,{defaultValue:y.defaultLabel})})),[s]),r=()=>i([...a,{id:za(),models:[],params:[]}]),c=y=>i(a.filter((b,x)=>x!==y)),d=(y,b)=>i(a.map((x,v)=>v===y?{...x,...b}:x)),f=y=>{const b=a[y],x={id:za(),name:"",protocol:void 0};d(y,{models:[...b.models,x]})},p=(y,b)=>{const x=a[y];d(y,{models:x.models.filter((v,k)=>k!==b)})},g=(y,b,x)=>{const v=a[y];d(y,{models:v.models.map((k,A)=>A===b?{...k,...x}:k)})};return h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[a.map((y,b)=>h.jsxs("div",{style:{border:"1px solid var(--border-color)",borderRadius:12,padding:12,display:"flex",flexDirection:"column",gap:12},children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:12,flexWrap:"wrap"},children:[h.jsxs("div",{style:{fontWeight:700,color:"var(--text-primary)"},children:[s("config_management.visual.payload_rules.rule")," ",b+1]}),h.jsx(de,{variant:"ghost",size:"sm",onClick:()=>c(b),disabled:n,children:s("config_management.visual.common.delete")})]}),h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[h.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-secondary)"},children:s("config_management.visual.payload_rules.models")}),y.models.map((x,v)=>h.jsxs("div",{className:Fa.payloadFilterModelRow,children:[h.jsx("input",{className:"input",placeholder:s("config_management.visual.payload_rules.model_name"),"aria-label":s("config_management.visual.payload_rules.model_name"),value:x.name,onChange:k=>g(b,v,{name:k.target.value}),disabled:n}),h.jsx(Yi,{value:x.protocol??"",options:o,disabled:n,ariaLabel:s("config_management.visual.payload_rules.provider_type"),onChange:k=>g(b,v,{protocol:k||void 0})}),h.jsx(de,{variant:"ghost",size:"sm",className:Fa.payloadRowActionButton,onClick:()=>p(b,v),disabled:n,children:s("config_management.visual.common.delete")})]},x.id)),h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx(de,{variant:"secondary",size:"sm",onClick:()=>f(b),disabled:n,children:s("config_management.visual.payload_rules.add_model")})})]}),h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[h.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-secondary)"},children:s("config_management.visual.payload_rules.remove_params")}),h.jsx(n1e,{value:y.params,disabled:n,placeholder:s("config_management.visual.payload_rules.json_path_filter"),inputAriaLabel:s("config_management.visual.payload_rules.json_path_filter"),onChange:x=>d(b,{params:x})})]})]},y.id)),a.length===0&&h.jsx("div",{style:{border:"1px dashed var(--border-color)",borderRadius:12,padding:16,color:"var(--text-secondary)",textAlign:"center"},children:s("config_management.visual.payload_rules.no_rules")}),h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx(de,{variant:"secondary",size:"sm",onClick:r,disabled:n,children:s("config_management.visual.payload_rules.add_rule")})})]})});function $l(t,e){if(e)return t(`config_management.visual.validation.${e}`)}function Ea({title:t,description:e,checked:n,disabled:i,onChange:s}){return h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,flexWrap:"wrap"},children:[h.jsxs("div",{style:{minWidth:220},children:[h.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)"},children:t}),e&&h.jsx("div",{style:{marginTop:4,fontSize:13,color:"var(--text-secondary)"},children:e})]}),h.jsx(fi,{checked:n,onChange:s,disabled:i,ariaLabel:t})]})}function Xr({children:t}){return h.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(240px, 1fr))",gap:16},children:t})}function s1e(){return h.jsx("div",{style:{height:1,background:"var(--border-color)",margin:"16px 0"}})}function a1e({values:t,validationErrors:e,disabled:n=!1,onChange:i}){const{t:s}=Ye(),a=w.useId(),o=`${a}-hint`,r=w.useId(),c=`${r}-hint`,d=`${r}-error`,f=w.useId(),p=`${f}-hint`,g=`${f}-error`,y=t.streaming.keepaliveSeconds===""||t.streaming.keepaliveSeconds==="0",b=t.streaming.nonstreamKeepaliveInterval===""||t.streaming.nonstreamKeepaliveInterval==="0",x=$l(s,e?.port),v=$l(s,e?.logsMaxTotalSizeMb),k=$l(s,e?.requestRetry),A=$l(s,e?.maxRetryInterval),T=$l(s,e?.["streaming.keepaliveSeconds"]),L=$l(s,e?.["streaming.bootstrapRetries"]),N=$l(s,e?.["streaming.nonstreamKeepaliveInterval"]),O=w.useCallback(P=>i({apiKeysText:P}),[i]),M=w.useCallback(P=>i({payloadDefaultRules:P}),[i]),E=w.useCallback(P=>i({payloadOverrideRules:P}),[i]),j=w.useCallback(P=>i({payloadFilterRules:P}),[i]);return h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[h.jsx(Yo,{title:s("config_management.visual.sections.server.title"),description:s("config_management.visual.sections.server.description"),children:h.jsxs(Xr,{children:[h.jsx(st,{label:s("config_management.visual.sections.server.host"),placeholder:"0.0.0.0",value:t.host,onChange:P=>i({host:P.target.value}),disabled:n}),h.jsx(st,{label:s("config_management.visual.sections.server.port"),type:"number",placeholder:"8317",value:t.port,onChange:P=>i({port:P.target.value}),disabled:n,error:x})]})}),h.jsx(Yo,{title:s("config_management.visual.sections.tls.title"),description:s("config_management.visual.sections.tls.description"),children:h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[h.jsx(Ea,{title:s("config_management.visual.sections.tls.enable"),description:s("config_management.visual.sections.tls.enable_desc"),checked:t.tlsEnable,disabled:n,onChange:P=>i({tlsEnable:P})}),t.tlsEnable&&h.jsxs(h.Fragment,{children:[h.jsx(s1e,{}),h.jsxs(Xr,{children:[h.jsx(st,{label:s("config_management.visual.sections.tls.cert"),placeholder:"/path/to/cert.pem",value:t.tlsCert,onChange:P=>i({tlsCert:P.target.value}),disabled:n}),h.jsx(st,{label:s("config_management.visual.sections.tls.key"),placeholder:"/path/to/key.pem",value:t.tlsKey,onChange:P=>i({tlsKey:P.target.value}),disabled:n})]})]})]})}),h.jsx(Yo,{title:s("config_management.visual.sections.remote.title"),description:s("config_management.visual.sections.remote.description"),children:h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[h.jsx(Ea,{title:s("config_management.visual.sections.remote.allow_remote"),description:s("config_management.visual.sections.remote.allow_remote_desc"),checked:t.rmAllowRemote,disabled:n,onChange:P=>i({rmAllowRemote:P})}),h.jsx(Ea,{title:s("config_management.visual.sections.remote.disable_panel"),description:s("config_management.visual.sections.remote.disable_panel_desc"),checked:t.rmDisableControlPanel,disabled:n,onChange:P=>i({rmDisableControlPanel:P})}),h.jsxs(Xr,{children:[h.jsx(st,{label:s("config_management.visual.sections.remote.secret_key"),type:"password",placeholder:s("config_management.visual.sections.remote.secret_key_placeholder"),value:t.rmSecretKey,onChange:P=>i({rmSecretKey:P.target.value}),disabled:n}),h.jsx(st,{label:s("config_management.visual.sections.remote.panel_repo"),placeholder:"https://github.com/router-for-me/Cli-Proxy-API-Management-Center",value:t.rmPanelRepo,onChange:P=>i({rmPanelRepo:P.target.value}),disabled:n})]})]})}),h.jsx(Yo,{title:s("config_management.visual.sections.auth.title"),description:s("config_management.visual.sections.auth.description"),children:h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[h.jsx(st,{label:s("config_management.visual.sections.auth.auth_dir"),placeholder:"~/.cli-proxy-api",value:t.authDir,onChange:P=>i({authDir:P.target.value}),disabled:n,hint:s("config_management.visual.sections.auth.auth_dir_hint")}),h.jsx(t1e,{value:t.apiKeysText,disabled:n,onChange:O})]})}),h.jsx(Yo,{title:s("config_management.visual.sections.system.title"),description:s("config_management.visual.sections.system.description"),children:h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[h.jsxs(Xr,{children:[h.jsx(Ea,{title:s("config_management.visual.sections.system.debug"),description:s("config_management.visual.sections.system.debug_desc"),checked:t.debug,disabled:n,onChange:P=>i({debug:P})}),h.jsx(Ea,{title:s("config_management.visual.sections.system.commercial_mode"),description:s("config_management.visual.sections.system.commercial_mode_desc"),checked:t.commercialMode,disabled:n,onChange:P=>i({commercialMode:P})}),h.jsx(Ea,{title:s("config_management.visual.sections.system.logging_to_file"),description:s("config_management.visual.sections.system.logging_to_file_desc"),checked:t.loggingToFile,disabled:n,onChange:P=>i({loggingToFile:P})}),h.jsx(Ea,{title:s("config_management.visual.sections.system.usage_statistics"),description:s("config_management.visual.sections.system.usage_statistics_desc"),checked:t.usageStatisticsEnabled,disabled:n,onChange:P=>i({usageStatisticsEnabled:P})})]}),h.jsx(Xr,{children:h.jsx(st,{label:s("config_management.visual.sections.system.logs_max_size"),type:"number",placeholder:"0",value:t.logsMaxTotalSizeMb,onChange:P=>i({logsMaxTotalSizeMb:P.target.value}),disabled:n,error:v})})]})}),h.jsx(Yo,{title:s("config_management.visual.sections.network.title"),description:s("config_management.visual.sections.network.description"),children:h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[h.jsxs(Xr,{children:[h.jsx(st,{label:s("config_management.visual.sections.network.proxy_url"),placeholder:"socks5://user:pass@127.0.0.1:1080/",value:t.proxyUrl,onChange:P=>i({proxyUrl:P.target.value}),disabled:n}),h.jsx(st,{label:s("config_management.visual.sections.network.request_retry"),type:"number",placeholder:"3",value:t.requestRetry,onChange:P=>i({requestRetry:P.target.value}),disabled:n,error:k}),h.jsx(st,{label:s("config_management.visual.sections.network.max_retry_interval"),type:"number",placeholder:"30",value:t.maxRetryInterval,onChange:P=>i({maxRetryInterval:P.target.value}),disabled:n,error:A}),h.jsxs("div",{className:"form-group",children:[h.jsx("label",{id:a,htmlFor:`${a}-select`,children:s("config_management.visual.sections.network.routing_strategy")}),h.jsx(Yi,{value:t.routingStrategy,options:[{value:"round-robin",label:s("config_management.visual.sections.network.strategy_round_robin")},{value:"fill-first",label:s("config_management.visual.sections.network.strategy_fill_first")}],id:`${a}-select`,disabled:n,ariaLabelledBy:a,ariaDescribedBy:o,onChange:P=>i({routingStrategy:P})}),h.jsx("div",{id:o,className:"hint",children:s("config_management.visual.sections.network.routing_strategy_hint")})]})]}),h.jsx(Ea,{title:s("config_management.visual.sections.network.force_model_prefix"),description:s("config_management.visual.sections.network.force_model_prefix_desc"),checked:t.forceModelPrefix,disabled:n,onChange:P=>i({forceModelPrefix:P})}),h.jsx(Ea,{title:s("config_management.visual.sections.network.ws_auth"),description:s("config_management.visual.sections.network.ws_auth_desc"),checked:t.wsAuth,disabled:n,onChange:P=>i({wsAuth:P})})]})}),h.jsx(Yo,{title:s("config_management.visual.sections.quota.title"),description:s("config_management.visual.sections.quota.description"),children:h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[h.jsx(Ea,{title:s("config_management.visual.sections.quota.switch_project"),description:s("config_management.visual.sections.quota.switch_project_desc"),checked:t.quotaSwitchProject,disabled:n,onChange:P=>i({quotaSwitchProject:P})}),h.jsx(Ea,{title:s("config_management.visual.sections.quota.switch_preview_model"),description:s("config_management.visual.sections.quota.switch_preview_model_desc"),checked:t.quotaSwitchPreviewModel,disabled:n,onChange:P=>i({quotaSwitchPreviewModel:P})})]})}),h.jsx(Yo,{title:s("config_management.visual.sections.streaming.title"),description:s("config_management.visual.sections.streaming.description"),children:h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[h.jsxs(Xr,{children:[h.jsxs("div",{className:"form-group",children:[h.jsx("label",{htmlFor:r,children:s("config_management.visual.sections.streaming.keepalive_seconds")}),h.jsxs("div",{style:{position:"relative"},children:[h.jsx("input",{id:r,className:"input",type:"number",placeholder:"0",value:t.streaming.keepaliveSeconds,onChange:P=>i({streaming:{...t.streaming,keepaliveSeconds:P.target.value}}),disabled:n}),y&&h.jsx("span",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",fontSize:12,color:"var(--text-secondary)",background:"var(--bg-secondary)",padding:"2px 8px",borderRadius:999,border:"1px solid var(--border-color)"},children:s("config_management.visual.sections.streaming.disabled")})]}),T&&h.jsx("div",{id:d,className:"error-box",children:T}),h.jsx("div",{id:c,className:"hint",children:s("config_management.visual.sections.streaming.keepalive_hint")})]}),h.jsx(st,{label:s("config_management.visual.sections.streaming.bootstrap_retries"),type:"number",placeholder:"1",value:t.streaming.bootstrapRetries,onChange:P=>i({streaming:{...t.streaming,bootstrapRetries:P.target.value}}),disabled:n,hint:s("config_management.visual.sections.streaming.bootstrap_hint"),error:L})]}),h.jsx(Xr,{children:h.jsxs("div",{className:"form-group",children:[h.jsx("label",{htmlFor:f,children:s("config_management.visual.sections.streaming.nonstream_keepalive")}),h.jsxs("div",{style:{position:"relative"},children:[h.jsx("input",{className:"input",type:"number",placeholder:"0",value:t.streaming.nonstreamKeepaliveInterval,onChange:P=>i({streaming:{...t.streaming,nonstreamKeepaliveInterval:P.target.value}}),disabled:n}),b&&h.jsx("span",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",fontSize:12,color:"var(--text-secondary)",background:"var(--bg-secondary)",padding:"2px 8px",borderRadius:999,border:"1px solid var(--border-color)"},children:s("config_management.visual.sections.streaming.disabled")})]}),N&&h.jsx("div",{id:g,className:"error-box",children:N}),h.jsx("div",{id:p,className:"hint",children:s("config_management.visual.sections.streaming.nonstream_keepalive_hint")})]})})]})}),h.jsx(Yo,{title:s("config_management.visual.sections.payload.title"),description:s("config_management.visual.sections.payload.description"),children:h.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:700,color:"var(--text-primary)",marginBottom:6},children:s("config_management.visual.sections.payload.default_rules")}),h.jsx("div",{style:{fontSize:13,color:"var(--text-secondary)",marginBottom:12},children:s("config_management.visual.sections.payload.default_rules_desc")}),h.jsx(Qj,{value:t.payloadDefaultRules,disabled:n,onChange:M})]}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:700,color:"var(--text-primary)",marginBottom:6},children:s("config_management.visual.sections.payload.override_rules")}),h.jsx("div",{style:{fontSize:13,color:"var(--text-secondary)",marginBottom:12},children:s("config_management.visual.sections.payload.override_rules_desc")}),h.jsx(Qj,{value:t.payloadOverrideRules,disabled:n,protocolFirst:!0,onChange:E})]}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:700,color:"var(--text-primary)",marginBottom:6},children:s("config_management.visual.sections.payload.filter_rules")}),h.jsx("div",{style:{fontSize:13,color:"var(--text-secondary)",marginBottom:12},children:s("config_management.visual.sections.payload.filter_rules_desc")}),h.jsx(i1e,{value:t.payloadFilterRules,disabled:n,onChange:j})]})]})})]})}class di{constructor(e,n,i,s){this.fromA=e,this.toA=n,this.fromB=i,this.toB=s}offset(e,n=e){return new di(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function Oc(t,e,n,i,s,a){if(t==i)return[];let o=Rk(t,e,n,i,s,a),r=Dk(t,e+o,n,i,s+o,a);e+=o,n-=r,s+=o,a-=r;let c=n-e,d=a-s;if(!c||!d)return[new di(e,n,s,a)];if(c>d){let p=t.slice(e,n).indexOf(i.slice(s,a));if(p>-1)return[new di(e,e+p,s,s),new di(e+p+d,n,a,a)]}else if(d>c){let p=i.slice(s,a).indexOf(t.slice(e,n));if(p>-1)return[new di(e,e,s,s+p),new di(n,n,s+p+c,a)]}if(c==1||d==1)return[new di(e,n,s,a)];let f=EF(t,e,n,i,s,a);if(f){let[p,g,y]=f;return Oc(t,e,p,i,s,g).concat(Oc(t,p+y,n,i,g+y,a))}return o1e(t,e,n,i,s,a)}let yf=1e9,bf=0,jk=!1;function o1e(t,e,n,i,s,a){let o=n-e,r=a-s;if(yf<1e9&&Math.min(o,r)>yf*16||bf>0&&Date.now()>bf)return Math.min(o,r)>yf*64?[new di(e,n,s,a)]:Yj(t,e,n,i,s,a);let c=Math.ceil((o+r)/2);I1.reset(c),B1.reset(c);let d=(y,b)=>t.charCodeAt(e+y)==i.charCodeAt(s+b),f=(y,b)=>t.charCodeAt(n-y-1)==i.charCodeAt(a-b-1),p=(o-r)%2!=0?B1:null,g=p?null:I1;for(let y=0;yyf||bf>0&&!(y&63)&&Date.now()>bf)return Yj(t,e,n,i,s,a);let b=I1.advance(y,o,r,c,p,!1,d)||B1.advance(y,o,r,c,g,!0,f);if(b)return r1e(t,e,n,e+b[0],i,s,a,s+b[1])}return[new di(e,n,s,a)]}class OF{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;nn)this.end+=2;else if(p>i)this.start+=2;else if(a){let g=s+(n-i)-c;if(g>=0&&g=n-f)return[y,s+y-g]}else{let y=n-a.vec[g];if(f>=y)return[f,p]}}}return null}}const I1=new OF,B1=new OF;function r1e(t,e,n,i,s,a,o,r){let c=!1;return!vd(t,i)&&++i==n&&(c=!0),!vd(s,r)&&++r==o&&(c=!0),c?[new di(e,n,a,o)]:Oc(t,e,i,s,a,r).concat(Oc(t,i,n,s,r,o))}function LF(t,e){let n=1,i=Math.min(t,e);for(;nn||f>a||t.slice(r,d)!=i.slice(c,f)){if(o==1)return r-e-(vd(t,r)?0:1);o=o>>1}else{if(d==n||f==a)return d-e;r=d,c=f}}}function Dk(t,e,n,i,s,a){if(e==n||s==a||t.charCodeAt(n-1)!=i.charCodeAt(a-1))return 0;let o=LF(n-e,a-s);for(let r=n,c=a;;){let d=r-o,f=c-o;if(d>1}else{if(d==e||f==s)return n-d;r=d,c=f}}}function DS(t,e,n,i,s,a,o,r){let c=i.slice(s,a),d=null;for(;;){if(d||o=n)break;let g=t.slice(f,p),y=-1;for(;(y=c.indexOf(g,y+1))!=-1;){let b=Rk(t,p,n,i,s+y+g.length,a),x=Dk(t,e,f,i,s,s+y),v=g.length+b+x;(!d||d[2]>1}}function EF(t,e,n,i,s,a){let o=n-e,r=a-s;if(os.fromA-e&&i.toB>s.fromB-e&&(t[n-1]=new di(i.fromA,s.toA,i.fromB,s.toB),t.splice(n--,1))}}function l1e(t,e,n){for(;;){PF(n,1);let i=!1;for(let s=0;s3||r>3){let c=s==t.length-1?e.length:t[s+1].fromA,d=a.fromA-i,f=c-a.toA,p=Zj(e,a.fromA,d),g=Jj(e,a.toA,f),y=a.fromA-p,b=g-a.toA;if((!o||!r)&&y&&b){let x=Math.max(o,r),[v,k,A]=o?[e,a.fromA,a.toA]:[n,a.fromB,a.toB];x>y&&e.slice(p,a.fromA)==v.slice(A-y,A)?(a=t[s]=new di(p,p+o,a.fromB-y,a.toB-y),p=a.fromA,g=Jj(e,a.toA,c-a.toA)):x>b&&e.slice(a.toA,g)==v.slice(k,k+b)&&(a=t[s]=new di(g-o,g,a.fromB+b,a.toB+b),g=a.toA,p=Zj(e,a.fromA,a.fromA-i)),y=a.fromA-p,b=g-a.toA}if(y||b)a=t[s]=new di(a.fromA-y,a.toA+b,a.fromB-y,a.toB+b);else if(o){if(!r){let x=tR(e,a.fromA,a.toA),v,k=x<0?-1:eR(e,a.toA,a.fromA);x>-1&&(v=x-a.fromA)<=f&&e.slice(a.fromA,x)==e.slice(a.toA,a.toA+v)?a=t[s]=a.offset(v):k>-1&&(v=a.toA-k)<=d&&e.slice(a.fromA-v,a.fromA)==e.slice(k,a.toA)&&(a=t[s]=a.offset(-v))}}else{let x=tR(n,a.fromB,a.toB),v,k=x<0?-1:eR(n,a.toB,a.fromB);x>-1&&(v=x-a.fromB)<=f&&n.slice(a.fromB,x)==n.slice(a.toB,a.toB+v)?a=t[s]=a.offset(v):k>-1&&(v=a.toB-k)<=d&&n.slice(a.fromB-v,a.fromB)==n.slice(k,a.toB)&&(a=t[s]=a.offset(-v))}}i=a.toA}return PF(t,3),t}let bc;try{bc=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function jF(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function RF(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?jF(n)?1:0:bc?!UF(n)||e==t.length-1?bc.test(String.fromCharCode(n))?1:0:bc.test(t.slice(e,e+2))?2:0:0}function DF(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?jF(n)?1:0:bc?!IF(n)||e==1?bc.test(String.fromCharCode(n))?1:0:bc.test(t.slice(e-2,e))?2:0:0}const FF=8;function Jj(t,e,n){if(e==t.length||!DF(t,e))return e;for(let i=e,s=e+n,a=0;as)return i;i+=o}return e}function Zj(t,e,n){if(!e||!RF(t,e))return e;for(let i=e,s=e-n,a=0;at>=55296&&t<=56319,IF=t=>t>=56320&&t<=57343;function vd(t,e){return!e||e==t.length||!UF(t.charCodeAt(e-1))||!IF(t.charCodeAt(e))}function u1e(t,e,n){var i;let s=n?.override;return s?s(t,e):(yf=((i=n?.scanLimit)!==null&&i!==void 0?i:1e9)>>1,bf=n?.timeout?Date.now()+n.timeout:0,jk=!1,l1e(t,e,Oc(t,0,t.length,e,0,e.length)))}function BF(){return!jk}function qF(t,e,n){return c1e(u1e(t,e,n),t,e)}class $y{constructor(e,n,i,s,a,o=!0){this.changes=e,this.fromA=n,this.toA=i,this.fromB=s,this.toB=a,this.precise=o}offset(e,n){return e||n?new $y(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,i){let s=qF(e.toString(),n.toString(),i);return KF(s,e,n,0,0,BF())}static updateA(e,n,i,s,a){return oR(aR(e,s,!0,i.length),e,n,i,a)}static updateB(e,n,i,s,a){return oR(aR(e,s,!1,n.length),e,n,i,a)}}function nR(t,e,n,i){let s=n.lineAt(t),a=i.lineAt(e);return s.to==t&&a.to==e&&tp+1&&v>g+1)break;y.push(b.offset(-d+i,-f+s)),[p,g]=iR(b.toA+i,b.toB+s,e,n),r++}o.push(new $y(y,d,Math.max(d,p),f,Math.max(f,g),a))}return o}const C_=1e3;function sR(t,e,n,i){let s=0,a=t.length;for(;;){if(s==a){let f=0,p=0;s&&({toA:f,toB:p}=t[s-1]);let g=e-(n?f:p);return[f+g,p+g]}let o=s+a>>1,r=t[o],[c,d]=n?[r.fromA,r.toA]:[r.fromB,r.toB];if(c>e)a=o;else if(d<=e)s=o+1;else return i?[r.fromA,r.fromB]:[r.toA,r.toB]}}function aR(t,e,n,i){let s=[];return e.iterChangedRanges((a,o,r,c)=>{let d=0,f=n?e.length:i,p=0,g=n?i:e.length;a>C_&&([d,p]=sR(t,a-C_,n,!0)),o=d?s[s.length-1]={fromA:b.fromA,fromB:b.fromB,toA:f,toB:g,diffA:b.diffA+x,diffB:b.diffB+v}:s.push({fromA:d,toA:f,fromB:p,toB:g,diffA:x,diffB:v})}),s}function oR(t,e,n,i,s){if(!t.length)return e;let a=[];for(let o=0,r=0,c=0,d=0;;o++){let f=o==t.length?null:t[o],p=f?f.fromA+r:n.length,g=f?f.fromB+c:i.length;for(;dp||v.endB+c>g)break;a.push(v.offset(r,c)),d++}if(!f)break;let y=f.toA+r+f.diffA,b=f.toB+c+f.diffB,x=qF(n.sliceString(p,y),i.sliceString(g,b),s);for(let v of KF(x,n,i,p,g,BF()))a.push(v);for(r+=f.diffA,c+=f.diffB;dy&&v.fromB+c>b)break;d++}}return a}const d1e="DiffModal-module__diffModal___v1LSh",h1e="DiffModal-module__content___CqXvC",f1e="DiffModal-module__emptyState___gS4Kg",m1e="DiffModal-module__diffContainer___AoJKb",p1e="DiffModal-module__fileHeader___7jkN4",g1e="DiffModal-module__fileIcon___OxYTx",_1e="DiffModal-module__fileName___2ylCY",y1e="DiffModal-module__fileStats___bN8WB",b1e="DiffModal-module__statAdditions___EKdp8",x1e="DiffModal-module__statDeletions___Py0Xg",v1e="DiffModal-module__statBar___tR7TQ",S1e="DiffModal-module__statBlock___4qKhG",w1e="DiffModal-module__statBlockAdd___VI4yX",k1e="DiffModal-module__statBlockDel___39sMa",C1e="DiffModal-module__diffBody___9dIqe",A1e="DiffModal-module__hunk___AcNIC",T1e="DiffModal-module__hunkHeader___xUVgg",N1e="DiffModal-module__hunkGutter___QVKqi",M1e="DiffModal-module__hunkExpandIcon___zbAx-",O1e="DiffModal-module__hunkText___iPVut",L1e="DiffModal-module__diffLine___9KzZK",E1e="DiffModal-module__lineNum___VXwKE",P1e="DiffModal-module__lineNumEmpty___I-5AK",j1e="DiffModal-module__linePrefix___ofp2Q",R1e="DiffModal-module__lineText___Zdyo3",D1e="DiffModal-module__context___RnJqZ",F1e="DiffModal-module__deletion___rms8N",U1e="DiffModal-module__addition___a6g2h",gn={diffModal:d1e,content:h1e,emptyState:f1e,diffContainer:m1e,fileHeader:p1e,fileIcon:g1e,fileName:_1e,fileStats:y1e,statAdditions:b1e,statDeletions:x1e,statBar:v1e,statBlock:S1e,statBlockAdd:w1e,statBlockDel:k1e,diffBody:C1e,hunk:A1e,hunkHeader:T1e,hunkGutter:N1e,hunkExpandIcon:M1e,hunkText:O1e,diffLine:L1e,lineNum:E1e,lineNumEmpty:P1e,linePrefix:j1e,lineText:R1e,context:D1e,deletion:F1e,addition:U1e},q1=3,rR=(t,e)=>Math.max(0,Math.min(e,t.length));function I1e(t,e){const n=en.of(t.split(`
+`)),i=en.of(e.split(`
+`)),s=$y.build(n,i);let a=0,o=0;return{hunks:s.map(c=>{const d=[],f=c.fromA0;P--){const F=b-P+1,D=v-P+1;F>=1&&D>=1&&F<=n.lines&&d.push({type:"context",oldNum:F,newNum:D,text:n.line(F).text})}for(const P of g)d.push({type:"deletion",oldNum:P.num,newNum:null,text:P.text});for(const P of y)d.push({type:"addition",oldNum:null,newNum:P.num,text:P.text});const T=Math.max(0,Math.min(q1,n.lines-x+1)),L=Math.max(0,Math.min(q1,i.lines-k+1)),N=Math.min(T,L);for(let P=0;P=1&&F<=n.lines&&D>=1&&D<=i.lines&&d.push({type:"context",oldNum:F,newNum:D,text:n.line(F).text})}const O=d.find(P=>P.oldNum!==null)?.oldNum??1,M=d.find(P=>P.newNum!==null)?.newNum??1,E=d.filter(P=>P.type!=="addition").length,j=d.filter(P=>P.type!=="deletion").length;return{oldStart:O,oldCount:E,newStart:M,newCount:j,lines:d}}),additions:a,deletions:o}}const lR=5;function B1e({additions:t,deletions:e}){const n=t+e;if(n===0)return null;const i=Math.round(t/n*lR);return h.jsx("span",{className:gn.statBar,children:Array.from({length:lR},(s,a)=>h.jsx("span",{className:`${gn.statBlock} ${aI1e(e,n),[e,n]);return h.jsx(ns,{open:t,title:o("config_management.diff.title"),onClose:s,width:"min(1200px, 90vw)",className:gn.diffModal,closeDisabled:a,footer:h.jsxs(h.Fragment,{children:[h.jsx(de,{variant:"secondary",onClick:s,disabled:a,children:o("common.cancel")}),h.jsx(de,{onClick:i,loading:a,disabled:a,children:o("config_management.diff.confirm")})]}),children:h.jsx("div",{className:gn.content,children:r.hunks.length===0?h.jsx("div",{className:gn.emptyState,children:o("config_management.diff.no_changes")}):h.jsxs("div",{className:gn.diffContainer,children:[h.jsxs("div",{className:gn.fileHeader,children:[h.jsx("svg",{className:gn.fileIcon,viewBox:"0 0 16 16",width:"16",height:"16",children:h.jsx("path",{fillRule:"evenodd",d:"M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z",fill:"currentColor"})}),h.jsx("span",{className:gn.fileName,children:"config.yaml"}),h.jsxs("span",{className:gn.fileStats,children:[h.jsxs("span",{className:gn.statAdditions,children:["+",r.additions]}),h.jsxs("span",{className:gn.statDeletions,children:["-",r.deletions]}),h.jsx(B1e,{additions:r.additions,deletions:r.deletions})]})]}),h.jsx("div",{className:gn.diffBody,children:r.hunks.map((c,d)=>h.jsxs("div",{className:gn.hunk,children:[h.jsxs("div",{className:gn.hunkHeader,children:[h.jsx("span",{className:gn.hunkGutter,children:h.jsx("svg",{className:gn.hunkExpandIcon,viewBox:"0 0 16 16",width:"12",height:"12",children:h.jsx("path",{d:"M8.177 1.677l2.896 2.896a.25.25 0 01-.177.427H8.75v1.25a.75.75 0 01-1.5 0V5H5.104a.25.25 0 01-.177-.427l2.896-2.896a.25.25 0 01.354 0zM7.25 11.75a.75.75 0 011.5 0V13h2.146a.25.25 0 01.177.427l-2.896 2.896a.25.25 0 01-.354 0l-2.896-2.896A.25.25 0 015.104 13H7.25v-1.25z",fill:"currentColor"})})}),h.jsx("span",{className:gn.hunkGutter}),h.jsxs("span",{className:gn.hunkText,children:["@@ -",c.oldStart,",",c.oldCount," +",c.newStart,",",c.newCount," @@"]})]}),c.lines.map((f,p)=>h.jsxs("div",{className:`${gn.diffLine} ${gn[f.type]}`,children:[h.jsx("span",{className:`${gn.lineNum} ${f.oldNum===null?gn.lineNumEmpty:""}`,children:f.oldNum??""}),h.jsx("span",{className:`${gn.lineNum} ${f.newNum===null?gn.lineNumEmpty:""}`,children:f.newNum??""}),h.jsx("span",{className:gn.linePrefix,children:f.type==="deletion"?"-":f.type==="addition"?"+":" "}),h.jsx("code",{className:gn.lineText,children:f.text||" "})]},`${d}-${p}`))]},d))})]})})})}const K1e="ConfigPage-module__container___5kN-Y",z1e="ConfigPage-module__pageTitle___BoVLE",H1e="ConfigPage-module__description___qruwQ",V1e="ConfigPage-module__tabBar___PelpE",W1e="ConfigPage-module__tabItem___Uj1rU",G1e="ConfigPage-module__tabActive___sZLh-",$1e="ConfigPage-module__content___PgFbt",X1e="ConfigPage-module__searchInputWrapper___-GeEQ",Q1e="ConfigPage-module__searchInput___ock8o",Y1e="ConfigPage-module__searchCount___AIry7",J1e="ConfigPage-module__searchRight___pwWBV",Z1e="ConfigPage-module__searchButton___GRbfi",e2e="ConfigPage-module__searchActions___ZGITa",t2e="ConfigPage-module__controls___OTpD4",n2e="ConfigPage-module__status___QYXYr",i2e="ConfigPage-module__modified___4mzgT",s2e="ConfigPage-module__saved___zmZx2",a2e="ConfigPage-module__error___qlpX1",o2e="ConfigPage-module__editorWrapper___yBudn",r2e="ConfigPage-module__floatingControls___RqBnu",l2e="ConfigPage-module__configCard___DdVq0",c2e="ConfigPage-module__floatingActionContainer___3ZQ-z",u2e="ConfigPage-module__floatingActionList___ky8bV",d2e="ConfigPage-module__floatingStatus___u8zOi",h2e="ConfigPage-module__floatingActionButton___Htxmz",f2e="ConfigPage-module__dirtyDot___zXEnD",fn={container:K1e,pageTitle:z1e,description:H1e,tabBar:V1e,tabItem:W1e,tabActive:G1e,content:$1e,searchInputWrapper:X1e,searchInput:Q1e,searchCount:Y1e,searchRight:J1e,searchButton:Z1e,searchActions:e2e,controls:t2e,status:n2e,modified:i2e,saved:s2e,error:a2e,editorWrapper:o2e,floatingControls:r2e,configCard:l2e,floatingActionContainer:c2e,floatingActionList:u2e,floatingStatus:d2e,floatingActionButton:h2e,dirtyDot:f2e};function cR(t){try{const e=AF(t);return!e||typeof e!="object"||Array.isArray(e)?!1:!!e["commercial-mode"]}catch{return!1}}function m2e(){const{t}=Ye(),e=un(ke=>ke.showNotification),n=un(ke=>ke.showConfirmation),i=Vt(ke=>ke.connectionStatus),s=ga(ke=>ke.resolvedTheme),{visualValues:a,visualDirty:o,visualParseError:r,visualValidationErrors:c,visualHasPayloadValidationErrors:d,loadVisualValuesFromYaml:f,applyVisualChangesToYaml:p,setVisualValues:g}=Yve(),[y,b]=w.useState(()=>{const ke=localStorage.getItem("config-management:tab");return ke==="visual"||ke==="source"?ke:"visual"}),[x,v]=w.useState(""),[k,A]=w.useState(!0),[T,L]=w.useState(!1),[N,O]=w.useState(""),[M,E]=w.useState(!1),[j,P]=w.useState(!1),[F,D]=w.useState(""),[z,G]=w.useState(""),[Q,B]=w.useState(""),[W,$]=w.useState({current:0,total:0}),[Z,H]=w.useState(""),U=w.useRef(null),I=w.useRef(null),V=w.useRef(null),Y=w.useRef(null),ne=i!=="connected",X=M||o,le=!!r,J=y==="visual"&&(Object.values(c).some(Boolean)||d),ae=w.useCallback(async()=>{A(!0),O("");try{const ke=await af.fetchConfigYaml();v(ke),E(!1),P(!1),D(ke),G(ke),f(ke)}catch(ke){const We=ke instanceof Error?ke.message:t("notification.refresh_failed");O(We)}finally{A(!1)}},[f,t]);w.useEffect(()=>{ae()},[ae]),w.useEffect(()=>{y!=="visual"||!r||(b("source"),localStorage.setItem("config-management:tab","source"),e(t("config_management.visual_mode_unavailable_detail",{message:r}),"error"))},[y,e,t,r]);const te=async()=>{L(!0);try{const ke=cR(F),We=cR(z),Ze=ke!==We;await af.saveConfigYaml(z);const ct=await af.fetchConfigYaml();E(!1),P(!1),v(ct),D(ct),G(ct),f(ct),e(t("config_management.save_success"),"success"),Ze&&e(t("notification.commercial_mode_restart_required"),"warning")}catch(ke){const We=ke instanceof Error?ke.message:"";e(`${t("notification.save_failed")}: ${We}`,"error")}finally{L(!1)}},Ae=async()=>{if(y==="visual"&&r){e(t("config_management.visual_mode_save_blocked"),"error");return}L(!0);try{const ke=await af.fetchConfigYaml();if(y!=="source"){const ct=vm(ke);if(ct.errors.length>0){e(t("config_management.visual_mode_latest_yaml_invalid",{message:ct.errors[0]?.message??t("config_management.visual_mode_save_blocked")}),"error");return}}const We=y==="source"?x:p(ke);let Ze=ke;if(y!=="source")try{Ze=vm(ke).toString({indent:2,lineWidth:120,minContentWidth:0})}catch{}if(Ze===We){E(!1),v(ke),D(ke),G(We),f(ke),e(t("config_management.diff.no_changes"),"info");return}D(Ze),G(We),P(!0)}catch(ke){const We=ke instanceof Error?ke.message:"";e(`${t("notification.save_failed")}: ${We}`,"error")}finally{L(!1)}},me=w.useCallback(ke=>{v(ke),E(!0)},[]),Ke=w.useCallback(ke=>{if(ke!==y){if(ke==="source"){if(o){const We=p(x);We!==x&&(v(We),E(!0))}}else{const We=f(x);if(!We.ok){e(t("config_management.visual_mode_unavailable_detail",{message:We.error}),"error");return}}b(ke),localStorage.setItem("config-management:tab",ke)}},[y,p,x,f,e,t,o]),it=w.useCallback((ke,We="next")=>{if(!ke||!U.current?.view)return;const Ze=U.current.view,ct=Ze.state.doc.toString(),Ut=[],rn=ke.toLowerCase(),xi=ct.toLowerCase();let vi=0;for(;vife){Ie=ln;break}ln===Ut.length-1&&(Ie=0)}else for(let ln=Ut.length-1;ln>=0;ln--){if(Ut[ln]{B(ke),ke?$({current:0,total:0}):($({current:0,total:0}),H(""))},[]),Pe=w.useCallback((ke="next")=>{Q&&(H(Q),it(Q,ke))},[Q,it]),at=w.useCallback(ke=>{ke.key==="Enter"&&(ke.preventDefault(),Pe(ke.shiftKey?"prev":"next"))},[Pe]),kt=w.useCallback(()=>{Z&&it(Z,"prev")},[Z,it]),we=w.useCallback(()=>{Z&&it(Z,"next")},[Z,it]);w.useLayoutEffect(()=>{if(y!=="source")return;const ke=I.current,We=V.current;if(!ke||!We)return;const Ze=()=>{const Ut=ke.getBoundingClientRect().height;We.style.setProperty("--floating-controls-height",`${Ut}px`)};Ze(),window.addEventListener("resize",Ze);const ct=typeof ResizeObserver>"u"?null:new ResizeObserver(Ze);return ct?.observe(ke),()=>{ct?.disconnect(),window.removeEventListener("resize",Ze)}},[y]),w.useLayoutEffect(()=>{if(typeof window>"u")return;const ke=Y.current;if(!ke)return;const We=()=>{const ct=ke.getBoundingClientRect().height;document.documentElement.style.setProperty("--config-action-bar-height",`${ct}px`)};We(),window.addEventListener("resize",We);const Ze=typeof ResizeObserver>"u"?null:new ResizeObserver(We);return Ze?.observe(ke),()=>{Ze?.disconnect(),window.removeEventListener("resize",We),document.documentElement.style.removeProperty("--config-action-bar-height")}},[]);const dt=w.useMemo(()=>[Sxe(),sye(),f8(),Xm.of(x8)],[]),ft=()=>t(ne?"config_management.status_disconnected":k?"config_management.status_loading":N?"config_management.status_load_failed":le?"config_management.visual_mode_unavailable":J?"config_management.visual.validation.validation_blocked":T?"config_management.status_saving":X?"config_management.status_dirty":"config_management.status_loaded"),bt=!ne&&!k&&!N&&!T&&!X&&!le&&!J,ce=()=>N||le||J?fn.error:X?fn.modified:!k&&!T?fn.saved:"",_e=w.useCallback(()=>{if(!X){ae();return}n({title:t("common.unsaved_changes_title"),message:t("config_management.reload_confirm_message"),confirmText:t("config_management.reload"),cancelText:t("common.cancel"),variant:"danger",onConfirm:async()=>{await ae()}})},[X,ae,n,t]),De=h.jsx("div",{className:fn.floatingActionContainer,ref:Y,children:h.jsxs("div",{className:fn.floatingActionList,children:[h.jsx("div",{className:`${fn.floatingStatus} ${fn.status} ${ce()}`,children:ft()}),h.jsx("button",{type:"button",className:fn.floatingActionButton,onClick:_e,disabled:k||T,title:t("config_management.reload"),"aria-label":t("config_management.reload"),children:h.jsx(QS,{size:16})}),h.jsxs("button",{type:"button",className:fn.floatingActionButton,onClick:Ae,disabled:ne||k||T||!X||j||le||J,title:t("config_management.save"),"aria-label":t("config_management.save"),children:[h.jsx(JS,{size:16}),X&&h.jsx("span",{className:fn.dirtyDot,"aria-hidden":"true"})]})]})});return h.jsxs("div",{className:fn.container,children:[h.jsx("h1",{className:fn.pageTitle,children:t("config_management.title")}),h.jsx("p",{className:fn.description,children:t("config_management.description")}),h.jsxs("div",{className:fn.tabBar,children:[h.jsx("button",{type:"button",className:`${fn.tabItem} ${y==="visual"?fn.tabActive:""}`,onClick:()=>Ke("visual"),disabled:T||k,children:t("config_management.tabs.visual",{defaultValue:"可视化编辑"})}),h.jsx("button",{type:"button",className:`${fn.tabItem} ${y==="source"?fn.tabActive:""}`,onClick:()=>Ke("source"),disabled:T||k,children:t("config_management.tabs.source",{defaultValue:"源代码编辑"})})]}),h.jsx(At,{className:fn.configCard,children:h.jsxs("div",{className:fn.content,children:[N&&h.jsx("div",{className:"error-box",children:N}),!N&&r&&h.jsx("div",{className:"error-box",children:t("config_management.visual_mode_unavailable_detail",{message:r})}),y==="visual"?h.jsx(a1e,{values:a,validationErrors:c,disabled:ne||k,onChange:g}):h.jsxs("div",{className:fn.editorWrapper,ref:V,children:[h.jsxs("div",{className:fn.floatingControls,ref:I,children:[h.jsx("div",{className:fn.searchInputWrapper,children:h.jsx(st,{value:Q,onChange:ke=>St(ke.target.value),onKeyDown:at,placeholder:t("config_management.search_placeholder",{defaultValue:"搜索配置内容..."}),disabled:ne||k,className:fn.searchInput,rightElement:h.jsxs("div",{className:fn.searchRight,children:[Q&&Z===Q&&h.jsx("span",{className:fn.searchCount,children:W.total>0?`${W.current} / ${W.total}`:t("config_management.search_no_results",{defaultValue:"无结果"})}),h.jsx("button",{type:"button",className:fn.searchButton,onClick:()=>Pe("next"),disabled:!Q||ne||k,title:t("config_management.search_button",{defaultValue:"搜索"}),children:h.jsx(d3,{size:16})})]})})}),h.jsxs("div",{className:fn.searchActions,children:[h.jsx(de,{variant:"secondary",size:"sm",onClick:kt,disabled:!Q||Z!==Q||W.total===0,title:t("config_management.search_prev",{defaultValue:"上一个"}),children:h.jsx(YS,{size:16})}),h.jsx(de,{variant:"secondary",size:"sm",onClick:we,disabled:!Q||Z!==Q||W.total===0,title:t("config_management.search_next",{defaultValue:"下一个"}),children:h.jsx(ay,{size:16})})]})]}),h.jsx(R8,{ref:U,value:x,onChange:me,extensions:dt,theme:s,editable:!ne&&!k,placeholder:t("config_management.editor_placeholder"),height:"100%",style:{height:"100%"},basicSetup:{lineNumbers:!0,highlightActiveLineGutter:!0,highlightActiveLine:!0,foldGutter:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!1,rectangularSelection:!0,crosshairCursor:!1,highlightSelectionMatches:!0,closeBracketsKeymap:!0,searchKeymap:!0,foldKeymap:!0,completionKeymap:!1,lintKeymap:!0}})]}),h.jsx("div",{className:fn.controls,children:!bt&&h.jsx("span",{className:`${fn.status} ${ce()}`,children:ft()})})]})}),typeof document<"u"?Ec.createPortal(De,document.body):null,h.jsx(q1e,{open:j,original:F,modified:z,onConfirm:te,onCancel:()=>P(!1),loading:T})]})}function p2e(t,e){const[n,i]=w.useState(()=>{try{const a=window.localStorage.getItem(t);return a?JSON.parse(a):e}catch(a){return console.error(`Error reading localStorage key "${t}":`,a),e}});return[n,a=>{try{const o=a instanceof Function?a(n):a;i(o),window.localStorage.setItem(t,JSON.stringify(o))}catch(o){console.error(`Error setting localStorage key "${t}":`,o)}}]}const Fk=["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"],g2e=["2xx","3xx","4xx","5xx"],zF=t=>{if(typeof t=="number"){if(t>=200&&t<300)return"2xx";if(t>=300&&t<400)return"3xx";if(t>=400&&t<500)return"4xx";if(t>=500&&t<600)return"5xx"}},_2e=new RegExp(`\\b(${Fk.join("|")})\\b`),y2e=/^\[?(\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?)\]?/,b2e=/^\[?(trace|debug|info|warn|warning|error|fatal)\s*\]?(?=\s|\[|$)\s*/i,K1=/^\[([^\]]+)\]/,HF=/\b(?:\d+(?:\.\d+)?\s*(?:µs|us|ms|s|m))(?:\s*\d+(?:\.\d+)?\s*(?:µs|us|ms|s|m))*\b/i,x2e=/\b(?:\d{1,3}\.){3}\d{1,3}\b/,v2e=/\b(?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}\b/i,uR=/^([a-f0-9]{8}|--------)$/i,S2e=/^\d{1,2}:\d{2}:\d{2}(?:\.\d{1,3})?$/,z1=/^\[GIN\]\s+(\d{4})\/(\d{2})\/(\d{2})\s*-\s*(\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?)\s*$/,w2e=[/\|\s*([1-5]\d{2})\s*\|/,/\b([1-5]\d{2})\s*-/,new RegExp(`\\b(?:${Fk.join("|")})\\s+\\S+\\s+([1-5]\\d{2})\\b`),/\b(?:status|code|http)[:\s]+([1-5]\d{2})\b/i,/\b([1-5]\d{2})\s+(?:OK|Created|Accepted|No Content|Moved|Found|Bad Request|Unauthorized|Forbidden|Not Found|Method Not Allowed|Internal Server Error|Bad Gateway|Service Unavailable|Gateway Timeout)\b/i],k2e=t=>{for(const e of w2e){const n=t.match(e);if(!n)continue;const i=Number.parseInt(n[1],10);if(Number.isFinite(i)&&i>=100&&i<=599)return i}},H1=t=>{const e=t.match(x2e);if(e)return e[0];const n=t.match(v2e);if(!n)return;const i=n[0];if(!S2e.test(i)&&!(!i.includes("::")&&i.split(":").length!==8))return i},A_=t=>{const e=t.trim(),n=e.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}:\d{2})/);return n?`${n[1]} ${n[2]}`:e},dR=t=>{const e=t.match(HF);if(e)return e[0].replace(/\s+/g,"")},C2e=t=>{const e=t.trim().toLowerCase();if(e==="warning"||e==="warn")return"warn";if(e==="info")return"info";if(e==="error")return"error";if(e==="fatal")return"fatal";if(e==="debug")return"debug";if(e==="trace")return"trace"},A2e=t=>{const e=t.toLowerCase();if(/\bfatal\b/.test(e))return"fatal";if(/\berror\b/.test(e))return"error";if(/\bwarn(?:ing)?\b/.test(e)||t.includes("警告"))return"warn";if(/\binfo\b/.test(e))return"info";if(/\bdebug\b/.test(e))return"debug";if(/\btrace\b/.test(e))return"trace"},V1=t=>{const e=t.match(_2e);if(!e)return{};const n=e[1],i=e.index??0,s=t.slice(i+e[0].length).trim(),a=s?s.split(/\s+/)[0]:void 0;return{method:n,path:a}},T2e=t=>{let e=t.trim(),n;const i=e.match(y2e);i&&(n=i[1],e=e.slice(i[0].length).trim());let s;const a=e.match(/^\[([a-f0-9]{8}|--------)\]\s*/i);if(a){const v=a[1];/^-+$/.test(v)||(s=v),e=e.slice(a[0].length).trim()}let o;const r=e.match(b2e);r&&(o=C2e(r[1]),e=e.slice(r[0].length).trim());let c;const d=e.match(K1);d&&(c=d[1],e=e.slice(d[0].length).trim());let f,p,g,y,b,x=e;if(e.includes("|")){const v=e.split("|").map(j=>j.trim()).filter(Boolean),k=new Set,A=v.findIndex(j=>z1.test(j));if(A>=0){const j=v[A].match(z1);if(j){const P=`${j[1]}-${j[2]}-${j[3]} ${j[4]}`,F=A_(P),D=n?A_(n):void 0;n?D===F&&k.add(A):(n=P,k.add(A))}}const T=v.findIndex(j=>uR.test(j));if(T>=0){const j=v[T].match(uR);if(j){const P=j[1];/^-+$/.test(P)||(s=P),k.add(T)}}const L=v.findIndex(j=>/^\d{3}$/.test(j));if(L>=0){const j=v[L].match(/^(\d{3})$/);if(j){const P=Number.parseInt(j[1],10);P>=100&&P<=599&&(f=P,k.add(L))}}const N=v.findIndex(j=>HF.test(j));if(N>=0){const j=dR(v[N]);j&&(p=j,k.add(N))}const O=v.findIndex(j=>!!H1(j));if(O>=0){const j=H1(v[O]);j&&(g=j,k.add(O))}const M=v.findIndex(j=>{const{method:P}=V1(j);return!!P});if(M>=0){const j=V1(v[M]);y=j.method,b=j.path,k.add(M)}const E=v.findIndex(j=>K1.test(j));if(E>=0){const j=v[E].match(K1);j&&(c=j[1],k.add(E))}x=v.filter((j,P)=>!k.has(P)).join(" | ")}else{f=k2e(e);const v=dR(e);v&&(p=v),g=H1(e);const k=V1(e);y=k.method,b=k.path}if(o||(o=A2e(t)),x){const v=x.match(z1);if(v){const k=`${v[1]}-${v[2]}-${v[3]} ${v[4]}`;n||(n=k),A_(n)===A_(k)&&(x="")}}return{raw:t,timestamp:n,level:o,source:c,requestId:s,statusCode:f,latency:p,ip:g,method:y,path:b,message:x}},N2e=12;function M2e(t){const{parsedLines:e}=t,[n,i]=w.useState([]),[s,a]=w.useState([]),[o,r]=w.useState([]),c=w.useMemo(()=>new Set(n),[n]),d=w.useMemo(()=>new Set(s),[s]),f=w.useMemo(()=>new Set(o),[o]),p=n.length>0||s.length>0||o.length>0,g=w.useMemo(()=>{const T={};return e.forEach(L=>{L.method&&(T[L.method]=(T[L.method]??0)+1)}),T},[e]),y=w.useMemo(()=>{const T={};return e.forEach(L=>{const N=zF(L.statusCode);N&&(T[N]=(T[N]??0)+1)}),T},[e]),b=w.useMemo(()=>{const T=new Map;return e.forEach(L=>{L.path&&T.set(L.path,(T.get(L.path)??0)+1)}),Array.from(T.entries()).sort((L,N)=>N[1]-L[1]||L[0].localeCompare(N[0])).slice(0,N2e).map(([L,N])=>({path:L,count:N}))},[e]);return w.useEffect(()=>{const T=new Set(b.map(L=>L.path));r(L=>{if(L.length===0)return L;const N=L.filter(O=>T.has(O));return N.length===L.length?L:N})},[b]),{methodFilters:n,statusFilters:s,pathFilters:o,methodFilterSet:c,statusFilterSet:d,pathFilterSet:f,hasStructuredFilters:p,methodCounts:g,statusCounts:y,pathOptions:b,toggleMethodFilter:T=>{i(L=>L.includes(T)?L.filter(N=>N!==T):[...L,T])},toggleStatusFilter:T=>{a(L=>L.includes(T)?L.filter(N=>N!==T):[...L,T])},togglePathFilter:T=>{r(L=>L.includes(T)?L.filter(N=>N!==T):[...L,T])},clearStructuredFilters:()=>{i([]),a([]),r([])}}}const O2e=200,L2e=72,E2e=t=>t?t.scrollHeight-t.scrollTop-t.clientHeight<=24:!0;function P2e(t){const{logState:e,setLogState:n,loading:i,isSearching:s,filteredLineCount:a,hasStructuredFilters:o,showRawLogs:r}=t,c=w.useRef(null),d=w.useRef(!1),f=w.useRef(null),p=!s&&e.visibleFrom>0,g=w.useCallback(()=>{const k=c.current;k&&(k.scrollTop=k.scrollHeight)},[]),y=w.useCallback(()=>{d.current=!0},[]),b=w.useCallback(()=>{const k=c.current;k&&(f.current||s||n(A=>A.visibleFrom<=0?A:(f.current={scrollHeight:k.scrollHeight,scrollTop:k.scrollTop},{...A,visibleFrom:Math.max(A.visibleFrom-O2e,0)})))},[s,n]),x=w.useCallback(k=>{const A=c.current;A&&(s||p&&(f.current||A.scrollTop>L2e||b()))},[p,s,b]);w.useLayoutEffect(()=>{const k=c.current,A=f.current;if(!k||!A)return;const T=k.scrollHeight-A.scrollHeight;k.scrollTop=A.scrollTop+T,f.current=null},[e.visibleFrom]);const v=w.useCallback(()=>{const k=c.current;!k||!p||s||f.current||k.scrollHeight>k.clientHeight+1||b()},[p,s,b]);return w.useEffect(()=>{if(i||!c.current)return;const A=window.requestAnimationFrame(()=>{v()});return()=>{window.cancelAnimationFrame(A)}},[a,o,i,e.visibleFrom,r,v]),w.useEffect(()=>{const k=()=>{window.requestAnimationFrame(()=>{v()})};return window.addEventListener("resize",k),()=>{window.removeEventListener("resize",k)}},[v]),w.useEffect(()=>{d.current&&(i||c.current&&(g(),d.current=!1))},[i,e.buffer,e.visibleFrom,g]),{logViewerRef:c,canLoadMore:p,handleLogScroll:x,scrollToBottom:g,requestScrollToBottom:y}}const j2e=60*1e3,R2e=5,D2e=new Set(["/v1/chat/completions","/v1/messages","/v1/responses"]),F2e=["/v1beta/models"],FS=t=>String(t??"").replace(/^"+|"+$/g,"").split("?")[0].trim(),U2e=t=>{const e=FS(t);return!e||e==="/"?e:e.replace(/\/+$/,"")},VF=t=>{const e=U2e(t);return e?D2e.has(e)?!0:F2e.some(n=>e.startsWith(n)):!1},I2e=/\bmodel[=:]\s*"?([a-zA-Z0-9._\-/]+)"?/i,B2e=t=>t&&t.match(I2e)?.[1]||void 0,q2e=(t,e)=>!t||!e?!1:t===e||t.startsWith(e)||e.startsWith(t),K2e=t=>{if(t instanceof Error)return t.message;if(typeof t=="string")return t;if(typeof t!="object"||t===null||!("message"in t))return"";const e=t.message;return typeof e=="string"?e:""};function z2e(t){const{traceScopeKey:e,connectionStatus:n,config:i,requestLogDownloading:s}=t,{t:a}=Ye(),o=Xi(z=>z.usage),r=Xi(z=>z.scopeKey),c=Xi(z=>z.loadUsageStats),[d,f]=w.useState(null),[p,g]=w.useState(new Map),[y,b]=w.useState(!1),[x,v]=w.useState(""),k=w.useRef(0),A=w.useRef(""),T=r===e?o:null,L=w.useMemo(()=>CW(T),[T]),N=w.useMemo(()=>C5(i??{}),[i]),O=w.useCallback(async z=>{if(A.current!==e&&(A.current=e,k.current=0,g(new Map),v("")),y)return;const G=Date.now(),Q=k.current>0&&G-k.currentnull)]);if(B!==null){const W=Array.isArray(B)?B:B?.files;if(Array.isArray(W)){const $=new Map;W.forEach(Z=>{const H=ts(Z.auth_index??Z.authIndex);H&&$.set(H,{name:Z.name||H,type:(Z.type||Z.provider||"").toString()})}),g($),k.current=Date.now()}}}catch(B){v(K2e(B)||a("logs.trace_usage_load_error"))}finally{b(!1)}},[c,a,y,e]),M=w.useCallback(async()=>{await O(!1)},[O]),E=w.useCallback(async()=>{await O(!0)},[O]);w.useEffect(()=>{n==="connected"&&(A.current=e,k.current=0,g(new Map),b(!1),v(""))},[n,e]);const j=w.useMemo(()=>{if(!d)return[];const z=FS(d.path);if(!z)return[];const G=d.timestamp?Date.parse(d.timestamp):Number.NaN,Q=L.filter(H=>q2e(z,FS(H.__endpointPath)));if(Q.length===0)return[];const B=B2e(d.message),W=B?Q.filter(H=>H.__modelName?.toLowerCase()===B.toLowerCase()):[],$=W.length>0;return($?W:Q).map(H=>{const U=!Number.isNaN(G)&&H.__timestampMs>0?Math.abs(G-H.__timestampMs):null;return{detail:H,modelMatched:$,timeDeltaMs:U}}).sort((H,U)=>(U.detail.__timestampMs||0)-(H.detail.__timestampMs||0)).slice(0,R2e)},[d,L]),P=w.useCallback((z,G)=>A5(z,G,N,p),[p,N]),F=w.useCallback(z=>{VF(z.path)&&(v(""),f(z),M())},[M]),D=w.useCallback(()=>{s||f(null)},[s]);return{traceLogLine:d,traceLoading:y,traceError:x,traceCandidates:j,resolveTraceSourceInfo:P,loadTraceUsageDetails:M,refreshTraceUsageDetails:E,openTraceModal:F,closeTraceModal:D}}const H2e="LogsPage-module__container___aQ0JL",V2e="LogsPage-module__pageTitle___vZY55",W2e="LogsPage-module__tabBar___bI3hW",G2e="LogsPage-module__tabItem___5tb4J",$2e="LogsPage-module__tabActive___JjbWX",X2e="LogsPage-module__content___hGaGn",Q2e="LogsPage-module__logCard___KG4Jd",Y2e="LogsPage-module__toolbar___9dY5F",J2e="LogsPage-module__filters___nUahU",Z2e="LogsPage-module__searchWrapper___mrEmr",eSe="LogsPage-module__filterPanelHeader___Oi5tO",tSe="LogsPage-module__filterPanelToggle___ADZED",nSe="LogsPage-module__filterPanelButtonContent___sgOCp",iSe="LogsPage-module__filterPanelCount___kAJ5-",sSe="LogsPage-module__structuredFilters___fW4v7",aSe="LogsPage-module__filterChipGroup___bbPoy",oSe="LogsPage-module__filterChipLabel___jy0D3",rSe="LogsPage-module__filterChipList___hHeOY",lSe="LogsPage-module__filterChip___Efqh7",cSe="LogsPage-module__filterChipActive___8S8ki",uSe="LogsPage-module__filterChipHint___shcVo",dSe="LogsPage-module__searchInput___eoPij",hSe="LogsPage-module__searchIcon___73cvF",fSe="LogsPage-module__searchClear___yTM1y",mSe="LogsPage-module__actionButton___aYJPR",pSe="LogsPage-module__buttonContent___qjHrB",gSe="LogsPage-module__switchLabel___EfB3d",_Se="LogsPage-module__logPanel___2wjiP",ySe="LogsPage-module__errorPanel___0w-se",bSe="LogsPage-module__loadMoreBanner___BUD0t",xSe="LogsPage-module__loadMoreCount___UsdBd",vSe="LogsPage-module__loadMoreStats___e9bVk",SSe="LogsPage-module__logList___lFt6f",wSe="LogsPage-module__rawLog___F5YBd",kSe="LogsPage-module__logRow___rxZS5",CSe="LogsPage-module__rowWarn___Lhg4M",ASe="LogsPage-module__rowError___XQ3Qi",TSe="LogsPage-module__timestamp___TZvLq",NSe="LogsPage-module__rowMain___f--We",MSe="LogsPage-module__badge___tR566",OSe="LogsPage-module__pill___vGA2z",LSe="LogsPage-module__source___nv7Zu",ESe="LogsPage-module__requestIdBadge___yPO1b",PSe="LogsPage-module__statusBadge___hj08j",jSe="LogsPage-module__statusSuccess___3llcn",RSe="LogsPage-module__statusInfo___B6DaE",DSe="LogsPage-module__statusWarn___1Dwki",FSe="LogsPage-module__statusError___xxTDc",USe="LogsPage-module__levelInfo___oZMOp",ISe="LogsPage-module__levelWarn___DsCD0",BSe="LogsPage-module__levelError___8VjWc",qSe="LogsPage-module__levelDebug___l-5yk",KSe="LogsPage-module__levelTrace___XvRLF",zSe="LogsPage-module__methodBadge___Cf9jC",HSe="LogsPage-module__path___frHAs",VSe="LogsPage-module__message___bNHRw",WSe="LogsPage-module__traceButton___TpMAt",GSe="LogsPage-module__tracePanel___qLlvU",$Se="LogsPage-module__traceNotice___brNFz",XSe="LogsPage-module__traceSectionTitle___oZ-a0",QSe="LogsPage-module__traceCandidatesHeader___b8sav",YSe="LogsPage-module__traceInfoGrid___7bY40",JSe="LogsPage-module__traceInfoItem___ydd7g",ZSe="LogsPage-module__traceInfoItemWide___pmNic",ewe="LogsPage-module__traceInfoLabel___zidDI",twe="LogsPage-module__traceInfoValue___3AiSj",nwe="LogsPage-module__traceSourceType___4TLzV",iwe="LogsPage-module__traceCandidates___TbNAE",swe="LogsPage-module__traceCandidate___jBw7W",awe="LogsPage-module__traceCandidateHeader___daeEH",owe="LogsPage-module__traceModelBadge___iJzwF",rwe="LogsPage-module__traceDelta___gfgPb",lwe="LogsPage-module__traceCandidateGrid___qPwow",Se={container:H2e,pageTitle:V2e,tabBar:W2e,tabItem:G2e,tabActive:$2e,content:X2e,logCard:Q2e,toolbar:Y2e,filters:J2e,searchWrapper:Z2e,filterPanelHeader:eSe,filterPanelToggle:tSe,filterPanelButtonContent:nSe,filterPanelCount:iSe,structuredFilters:sSe,filterChipGroup:aSe,filterChipLabel:oSe,filterChipList:rSe,filterChip:lSe,filterChipActive:cSe,filterChipHint:uSe,searchInput:dSe,searchIcon:hSe,searchClear:fSe,actionButton:mSe,buttonContent:pSe,switchLabel:gSe,logPanel:_Se,errorPanel:ySe,loadMoreBanner:bSe,loadMoreCount:xSe,loadMoreStats:vSe,logList:SSe,rawLog:wSe,logRow:kSe,rowWarn:CSe,rowError:ASe,timestamp:TSe,rowMain:NSe,badge:MSe,pill:OSe,source:LSe,requestIdBadge:ESe,statusBadge:PSe,statusSuccess:jSe,statusInfo:RSe,statusWarn:DSe,statusError:FSe,levelInfo:USe,levelWarn:ISe,levelError:BSe,levelDebug:qSe,levelTrace:KSe,methodBadge:zSe,path:HSe,message:VSe,traceButton:WSe,tracePanel:GSe,traceNotice:$Se,traceSectionTitle:XSe,traceCandidatesHeader:QSe,traceInfoGrid:YSe,traceInfoItem:JSe,traceInfoItemWide:ZSe,traceInfoLabel:ewe,traceInfoValue:twe,traceSourceType:nwe,traceCandidates:iwe,traceCandidate:swe,traceCandidateHeader:awe,traceModelBadge:owe,traceDelta:rwe,traceCandidateGrid:lwe},cwe=100,hR=1e4,uwe=650,fR=10,tf=t=>{if(t instanceof Error)return t.message;if(typeof t=="string")return t;if(typeof t!="object"||t===null||!("message"in t))return"";const e=t.message;return typeof e=="string"?e:""};function dwe(){const{t}=Ye(),{showNotification:e,showConfirmation:n}=un(),i=Vt(fe=>fe.connectionStatus),s=Vt(fe=>fe.apiBase),a=Vt(fe=>fe.managementKey),o=`${s}::${a}`,r=Ft(fe=>fe.config),c=r?.requestLog??!1,[d,f]=w.useState("logs"),[p,g]=w.useState({buffer:[],visibleFrom:0}),[y,b]=w.useState(!0),[x,v]=w.useState(""),[k,A]=w.useState(!1),[T,L]=w.useState(""),N=w.useDeferredValue(T),[O,M]=w.useState(!0),[E,j]=w.useState(!1),[P,F]=p2e("logsPage.structuredFiltersExpanded",!0),[D,z]=w.useState([]),[G,Q]=w.useState(!1),[B,W]=w.useState(""),[$,Z]=w.useState(null),[H,U]=w.useState(!1),I=z2e({traceScopeKey:o,connectionStatus:i,config:r,requestLogDownloading:H}),V=w.useRef(null),Y=w.useRef(null),ne=w.useRef(!1),X=w.useRef(!1),le=w.useRef(0),J=i!=="connected",ae=async(fe=!1)=>{if(i!=="connected"){b(!1);return}if(ne.current){fe||(X.current=!0);return}ne.current=!0,fe||b(!0),v("");try{const Ie=V.current,It=!fe||E2e(Ie?.logViewerRef.current??null);It&&Ie?.requestScrollToBottom();const ln=fe&&le.current>0?{after:le.current}:{},Si=await Ph.fetchLogs(ln);Si["latest-timestamp"]&&(le.current=Si["latest-timestamp"]);const wi=Array.isArray(Si.lines)?Si.lines:[];if(fe&&wi.length>0)g(mi=>{const qi=mi.buffer.length-mi.visibleFrom,Oi=[...mi.buffer,...wi],os=Math.max(Oi.length-hR,0),gs=os>0?Oi.slice(os):Oi;let Te=Math.max(mi.visibleFrom-os,0);return It&&(Te=Math.max(gs.length-qi,0)),{buffer:gs,visibleFrom:Te}});else if(!fe){const mi=wi.slice(-hR),qi=Math.max(mi.length-cwe,0);g({buffer:mi,visibleFrom:qi})}}catch(Ie){console.error("Failed to load logs:",Ie),fe||v(tf(Ie)||t("logs.load_error"))}finally{fe||b(!1),ne.current=!1,X.current&&(X.current=!1,ae(!1))}};Im(()=>ae(!1));const te=async()=>{n({title:t("logs.clear_confirm_title",{defaultValue:"Clear Logs"}),message:t("logs.clear_confirm"),variant:"danger",confirmText:t("common.confirm"),onConfirm:async()=>{try{await Ph.clearLogs(),g({buffer:[],visibleFrom:0}),le.current=0,e(t("logs.clear_success"),"success")}catch(fe){const Ie=tf(fe);e(`${t("notification.delete_failed")}${Ie?`: ${Ie}`:""}`,"error")}}})},Ae=()=>{const fe=p.buffer.join(`
+`);pc({filename:"logs.txt",blob:new Blob([fe],{type:"text/plain"})}),e(t("logs.download_success"),"success")},me=async()=>{if(i!=="connected"){Q(!1);return}Q(!0),W("");try{const fe=await Ph.fetchErrorLogs();z(Array.isArray(fe.files)?fe.files:[])}catch(fe){console.error("Failed to load error logs:",fe),z([]);const Ie=tf(fe);W(Ie?`${t("logs.error_logs_load_error")}: ${Ie}`:t("logs.error_logs_load_error"))}finally{Q(!1)}},Ke=async fe=>{try{const Ie=await Ph.downloadErrorLog(fe);pc({filename:fe,blob:new Blob([Ie.data],{type:"text/plain"})}),e(t("logs.error_log_download_success"),"success")}catch(Ie){const It=tf(Ie);e(`${t("notification.download_failed")}${It?`: ${It}`:""}`,"error")}};w.useEffect(()=>{i==="connected"&&(le.current=0,ae(!1))},[i]),w.useEffect(()=>{d==="errors"&&i==="connected"&&me()},[d,i,c]),w.useEffect(()=>{if(!k||i!=="connected")return;const fe=window.setInterval(()=>{ae(!0)},8e3);return()=>window.clearInterval(fe)},[k,i]);const it=w.useMemo(()=>p.buffer.slice(p.visibleFrom),[p.buffer,p.visibleFrom]),St=N.trim(),Pe=St.length>0,at=Pe?p.buffer:it,kt=w.useMemo(()=>{let fe=at;if(O&&(fe=fe.filter(Ie=>!Ie.includes(t2))),St){const Ie=St.toLowerCase();fe=fe.filter(It=>It.toLowerCase().includes(Ie))}return fe.map(Ie=>T2e(Ie))},[at,O,St]),we=M2e({parsedLines:kt}),dt="logs-structured-filters",ft=we.methodFilters.length+we.statusFilters.length+we.pathFilters.length,{filteredParsedLines:bt,filteredLines:ce,removedCount:_e}=w.useMemo(()=>{const fe=kt.filter(Ie=>{if(we.methodFilterSet.size>0&&(!Ie.method||!we.methodFilterSet.has(Ie.method)))return!1;const It=zF(Ie.statusCode);return!(we.statusFilterSet.size>0&&(!It||!we.statusFilterSet.has(It))||we.pathFilterSet.size>0&&(!Ie.path||!we.pathFilterSet.has(Ie.path)))});return{filteredParsedLines:fe,filteredLines:fe.map(Ie=>Ie.raw),removedCount:Math.max(at.length-fe.length,0)}},[at,we.methodFilterSet,we.pathFilterSet,we.statusFilterSet,kt]),De=w.useMemo(()=>E?[]:bt,[bt,E]),ke=w.useMemo(()=>ce.join(`
+`),[ce]),We=P2e({logState:p,setLogState:g,loading:y,isSearching:Pe,filteredLineCount:ce.length,hasStructuredFilters:we.hasStructuredFilters,showRawLogs:E});V.current=We;const Ze=async fe=>{await gy(fe)?e(t("logs.copy_success",{defaultValue:"Copied to clipboard"}),"success"):e(t("logs.copy_failed",{defaultValue:"Copy failed"}),"error")},ct=()=>{Y.current?.timer&&(window.clearTimeout(Y.current.timer),Y.current.timer=null)},Ut=(fe,Ie)=>{c&&Ie&&($||(ct(),Y.current={timer:window.setTimeout(()=>{Z(Ie),Y.current&&(Y.current.fired=!0,Y.current.timer=null)},uwe),startX:fe.clientX,startY:fe.clientY,fired:!1}))},rn=()=>{ct(),Y.current=null},xi=fe=>{const Ie=Y.current;if(!Ie||Ie.timer===null||Ie.fired)return;const It=Math.abs(fe.clientX-Ie.startX),ln=Math.abs(fe.clientY-Ie.startY);(It>fR||ln>fR)&&rn()},vi=()=>{H||Z(null)},Wt=async fe=>{U(!0);try{const Ie=await Ph.downloadRequestLogById(fe);pc({filename:`request-${fe}.log`,blob:new Blob([Ie.data],{type:"text/plain"})}),e(t("logs.request_log_download_success"),"success"),Z(null)}catch(Ie){const It=tf(Ie);e(`${t("notification.download_failed")}${It?`: ${It}`:""}`,"error")}finally{U(!1)}};return w.useEffect(()=>()=>{Y.current?.timer&&(window.clearTimeout(Y.current.timer),Y.current.timer=null)},[]),h.jsxs("div",{className:Se.container,children:[h.jsx("h1",{className:Se.pageTitle,children:t("logs.title")}),h.jsxs("div",{className:Se.tabBar,children:[h.jsx("button",{type:"button",className:`${Se.tabItem} ${d==="logs"?Se.tabActive:""}`,onClick:()=>f("logs"),children:t("logs.log_content")}),h.jsx("button",{type:"button",className:`${Se.tabItem} ${d==="errors"?Se.tabActive:""}`,onClick:()=>f("errors"),children:t("logs.error_logs_modal_title")})]}),h.jsxs("div",{className:Se.content,children:[d==="logs"&&h.jsxs(At,{className:Se.logCard,children:[x&&h.jsx("div",{className:"error-box",children:x}),h.jsxs("div",{className:Se.filters,children:[h.jsx("div",{className:Se.searchWrapper,children:h.jsx(st,{value:T,onChange:fe=>L(fe.target.value),placeholder:t("logs.search_placeholder"),className:Se.searchInput,rightElement:T?h.jsx("button",{type:"button",className:Se.searchClear,onClick:()=>L(""),title:"Clear","aria-label":"Clear",children:h.jsx(Pc,{size:16})}):h.jsx(d3,{size:16,className:Se.searchIcon})})}),h.jsx("div",{className:Se.filterPanelHeader,children:h.jsx(de,{type:"button",variant:"secondary",size:"sm",className:Se.filterPanelToggle,onClick:()=>F(fe=>!fe),"aria-expanded":P,"aria-controls":dt,title:t(P?"logs.filter_panel_collapse":"logs.filter_panel_expand"),children:h.jsxs("span",{className:Se.filterPanelButtonContent,children:[h.jsx(Pq,{size:16}),h.jsx("span",{children:t("logs.filter_panel_title")}),ft>0&&h.jsx("span",{className:Se.filterPanelCount,children:t("logs.filter_panel_active_count",{count:ft})}),P?h.jsx(YS,{size:16}):h.jsx(ay,{size:16})]})})}),P&&h.jsxs("div",{id:dt,className:Se.structuredFilters,children:[h.jsxs("div",{className:Se.filterChipGroup,children:[h.jsx("span",{className:Se.filterChipLabel,children:t("logs.filter_method")}),h.jsx("div",{className:Se.filterChipList,children:Fk.map(fe=>{const Ie=we.methodFilters.includes(fe),It=we.methodCounts[fe]??0;return h.jsxs("button",{type:"button",className:`${Se.filterChip} ${Ie?Se.filterChipActive:""}`,onClick:()=>we.toggleMethodFilter(fe),disabled:It===0&&!Ie,"aria-pressed":Ie,children:[fe," (",It,")"]},fe)})})]}),h.jsxs("div",{className:Se.filterChipGroup,children:[h.jsx("span",{className:Se.filterChipLabel,children:t("logs.filter_status")}),h.jsx("div",{className:Se.filterChipList,children:g2e.map(fe=>{const Ie=we.statusFilters.includes(fe),It=we.statusCounts[fe]??0;return h.jsxs("button",{type:"button",className:`${Se.filterChip} ${Ie?Se.filterChipActive:""}`,onClick:()=>we.toggleStatusFilter(fe),disabled:It===0&&!Ie,"aria-pressed":Ie,children:[t(`logs.filter_status_${fe}`)," (",It,")"]},fe)})})]}),h.jsxs("div",{className:Se.filterChipGroup,children:[h.jsx("span",{className:Se.filterChipLabel,children:t("logs.filter_path")}),h.jsx("div",{className:Se.filterChipList,children:we.pathOptions.length===0?h.jsx("span",{className:Se.filterChipHint,children:t("logs.filter_path_empty")}):we.pathOptions.map(({path:fe,count:Ie})=>{const It=we.pathFilters.includes(fe);return h.jsxs("button",{type:"button",className:`${Se.filterChip} ${It?Se.filterChipActive:""}`,onClick:()=>we.togglePathFilter(fe),"aria-pressed":It,title:fe,children:[fe," (",Ie,")"]},fe)})})]}),h.jsx(de,{variant:"ghost",size:"sm",onClick:we.clearStructuredFilters,disabled:!we.hasStructuredFilters,children:t("logs.clear_filters")})]}),h.jsx(fi,{checked:O,onChange:M,label:h.jsxs("span",{className:Se.switchLabel,children:[h.jsx(h3,{size:16}),t("logs.hide_management_logs",{prefix:t2})]})}),h.jsx(fi,{checked:E,onChange:j,label:h.jsxs("span",{className:Se.switchLabel,title:t("logs.show_raw_logs_hint",{defaultValue:"Show original log text for easier multi-line copy"}),children:[h.jsx(ew,{size:16}),t("logs.show_raw_logs",{defaultValue:"Show raw logs"})]})}),h.jsxs("div",{className:Se.toolbar,children:[h.jsx(de,{variant:"secondary",size:"sm",onClick:()=>ae(!1),disabled:J||y,className:Se.actionButton,children:h.jsxs("span",{className:Se.buttonContent,children:[h.jsx(QS,{size:16}),t("logs.refresh_button")]})}),h.jsx(fi,{checked:k,onChange:fe=>A(fe),disabled:J,label:h.jsxs("span",{className:Se.switchLabel,children:[h.jsx(ZS,{size:16}),t("logs.auto_refresh")]})}),h.jsx(de,{variant:"secondary",size:"sm",onClick:Ae,disabled:p.buffer.length===0,className:Se.actionButton,children:h.jsxs("span",{className:Se.buttonContent,children:[h.jsx(u3,{size:16}),t("logs.download_button")]})}),h.jsx(de,{variant:"danger",size:"sm",onClick:te,disabled:J,className:Se.actionButton,children:h.jsxs("span",{className:Se.buttonContent,children:[h.jsx(sy,{size:16}),t("logs.clear_button")]})})]})]}),y?h.jsx("div",{className:"hint",children:t("logs.loading")}):p.buffer.length>0&&ce.length>0?h.jsxs("div",{ref:We.logViewerRef,className:Se.logPanel,onScroll:We.handleLogScroll,children:[We.canLoadMore&&h.jsxs("div",{className:Se.loadMoreBanner,children:[h.jsx("span",{children:t("logs.load_more_hint")}),h.jsxs("div",{className:Se.loadMoreStats,children:[h.jsx("span",{children:t("logs.loaded_lines",{count:ce.length})}),_e>0&&h.jsx("span",{className:Se.loadMoreCount,children:t("logs.filtered_lines",{count:_e})}),h.jsx("span",{className:Se.loadMoreCount,children:t("logs.hidden_lines",{count:p.visibleFrom})})]})]}),E?h.jsx("pre",{className:Se.rawLog,spellCheck:!1,children:ke}):h.jsx("div",{className:Se.logList,children:De.map((fe,Ie)=>{const It=VF(fe.path),ln=[Se.logRow];return fe.level==="warn"&&ln.push(Se.rowWarn),(fe.level==="error"||fe.level==="fatal")&&ln.push(Se.rowError),h.jsxs("div",{className:ln.join(" "),onDoubleClick:()=>{Ze(fe.raw)},onPointerDown:Si=>Ut(Si,fe.requestId),onPointerUp:rn,onPointerLeave:rn,onPointerCancel:rn,onPointerMove:xi,title:t("logs.double_click_copy_hint",{defaultValue:"Double-click to copy"}),children:[h.jsx("div",{className:Se.timestamp,children:fe.timestamp||""}),h.jsxs("div",{className:Se.rowMain,children:[fe.level&&h.jsx("span",{className:[Se.badge,fe.level==="info"?Se.levelInfo:"",fe.level==="warn"?Se.levelWarn:"",fe.level==="error"||fe.level==="fatal"?Se.levelError:"",fe.level==="debug"?Se.levelDebug:"",fe.level==="trace"?Se.levelTrace:""].filter(Boolean).join(" "),children:fe.level.toUpperCase()}),fe.source&&h.jsx("span",{className:Se.source,title:fe.source,children:fe.source}),fe.requestId&&h.jsx("span",{className:[Se.badge,Se.requestIdBadge].join(" "),title:fe.requestId,children:fe.requestId}),typeof fe.statusCode=="number"&&h.jsx("span",{className:[Se.badge,Se.statusBadge,fe.statusCode>=200&&fe.statusCode<300?Se.statusSuccess:fe.statusCode>=300&&fe.statusCode<400?Se.statusInfo:fe.statusCode>=400&&fe.statusCode<500?Se.statusWarn:Se.statusError].join(" "),children:fe.statusCode}),fe.latency&&h.jsx("span",{className:Se.pill,children:fe.latency}),fe.ip&&h.jsx("span",{className:Se.pill,children:fe.ip}),fe.method&&h.jsx("span",{className:[Se.badge,Se.methodBadge].join(" "),children:fe.method}),fe.path&&h.jsx("span",{className:Se.path,title:fe.path,children:fe.path}),fe.message&&h.jsx("span",{className:Se.message,children:fe.message}),It&&h.jsx("button",{type:"button",className:Se.traceButton,onClick:Si=>{Si.stopPropagation(),rn(),I.openTraceModal(fe)},title:t("logs.trace_button"),children:t("logs.trace_button")})]})]},`${p.visibleFrom+Ie}-${fe.raw}`)})})]}):p.buffer.length>0?h.jsx(es,{title:t("logs.search_empty_title"),description:t("logs.search_empty_desc")}):h.jsx(es,{title:t("logs.empty_title"),description:t("logs.empty_desc")})]}),d==="errors"&&h.jsx(At,{extra:h.jsx(de,{variant:"secondary",size:"sm",onClick:me,loading:G,disabled:J,children:t("common.refresh")}),children:h.jsxs("div",{className:"stack",children:[h.jsx("div",{className:"hint",children:t("logs.error_logs_description")}),c&&h.jsx("div",{children:h.jsx("div",{className:"status-badge warning",children:t("logs.error_logs_request_log_enabled")})}),B&&h.jsx("div",{className:"error-box",children:B}),h.jsx("div",{className:Se.errorPanel,children:G?h.jsx("div",{className:"hint",children:t("common.loading")}):D.length===0?h.jsx("div",{className:"hint",children:t("logs.error_logs_empty")}):h.jsx("div",{className:"item-list",children:D.map(fe=>h.jsxs("div",{className:"item-row",children:[h.jsxs("div",{className:"item-meta",children:[h.jsx("div",{className:"item-title",children:fe.name}),h.jsxs("div",{className:"item-subtitle",children:[fe.size?`${(fe.size/1024).toFixed(1)} KB`:""," ",fe.modified?yW(fe.modified):""]})]}),h.jsx("div",{className:"item-actions",children:h.jsx(de,{variant:"secondary",size:"sm",onClick:()=>Ke(fe.name),disabled:J,children:t("logs.error_logs_download")})})]},fe.name))})})]})})]}),h.jsx(ns,{open:!!I.traceLogLine,onClose:I.closeTraceModal,title:t("logs.trace_title"),footer:h.jsxs(h.Fragment,{children:[I.traceLogLine?.requestId&&h.jsx(de,{variant:"secondary",onClick:()=>{I.traceLogLine?.requestId&&Wt(I.traceLogLine.requestId)},loading:H,children:t("logs.trace_download_request_log")}),h.jsx(de,{variant:"secondary",onClick:I.closeTraceModal,disabled:H,children:t("common.close")})]}),children:I.traceLogLine&&h.jsxs("div",{className:Se.tracePanel,children:[h.jsx("div",{className:Se.traceNotice,children:t("logs.trace_notice")}),h.jsx("h3",{className:Se.traceSectionTitle,children:t("logs.trace_log_info")}),h.jsxs("div",{className:Se.traceInfoGrid,children:[h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_request_id")}),h.jsx("span",{className:Se.traceInfoValue,children:I.traceLogLine.requestId||"-"})]}),h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_method")}),h.jsx("span",{className:Se.traceInfoValue,children:I.traceLogLine.method||"-"})]}),h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_path")}),h.jsx("span",{className:Se.traceInfoValue,children:I.traceLogLine.path||"-"})]}),h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_status_code")}),h.jsx("span",{className:Se.traceInfoValue,children:typeof I.traceLogLine.statusCode=="number"?I.traceLogLine.statusCode:"-"})]}),h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_latency")}),h.jsx("span",{className:Se.traceInfoValue,children:I.traceLogLine.latency||"-"})]}),h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_ip")}),h.jsx("span",{className:Se.traceInfoValue,children:I.traceLogLine.ip||"-"})]}),h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_timestamp")}),h.jsx("span",{className:Se.traceInfoValue,children:I.traceLogLine.timestamp||"-"})]}),h.jsxs("div",{className:`${Se.traceInfoItem} ${Se.traceInfoItemWide}`,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_message")}),h.jsx("span",{className:Se.traceInfoValue,children:I.traceLogLine.message||"-"})]})]}),h.jsxs("div",{className:Se.traceCandidatesHeader,children:[h.jsx("h3",{className:Se.traceSectionTitle,children:t("logs.trace_candidates_title")}),h.jsx(de,{variant:"secondary",size:"sm",onClick:()=>{I.refreshTraceUsageDetails().catch(()=>{})},loading:I.traceLoading,disabled:H,children:t("common.refresh")})]}),I.traceLoading?h.jsx("div",{className:"hint",children:t("logs.trace_loading")}):I.traceError?h.jsx("div",{className:"error-box",children:I.traceError}):I.traceCandidates.length===0?h.jsx("div",{className:"hint",children:t("logs.trace_no_match")}):h.jsx("div",{className:Se.traceCandidates,children:I.traceCandidates.map(fe=>{const Ie=I.resolveTraceSourceInfo(String(fe.detail.source??""),fe.detail.auth_index);return h.jsxs("div",{className:Se.traceCandidate,children:[h.jsxs("div",{className:Se.traceCandidateHeader,children:[fe.modelMatched&&h.jsx("span",{className:Se.traceModelBadge,children:t("logs.trace_model_matched")}),fe.timeDeltaMs!==null&&h.jsx("span",{className:Se.traceDelta,children:t("logs.trace_delta_seconds",{seconds:(fe.timeDeltaMs/1e3).toFixed(2)})})]}),h.jsxs("div",{className:Se.traceCandidateGrid,children:[h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_endpoint")}),h.jsx("span",{className:Se.traceInfoValue,children:fe.detail.__endpoint})]}),h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_model")}),h.jsx("span",{className:Se.traceInfoValue,children:fe.detail.__modelName||"-"})]}),h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_source")}),h.jsxs("span",{className:Se.traceInfoValue,title:String(fe.detail.source||"-"),children:[h.jsx("span",{children:Ie.displayName}),Ie.type&&h.jsx("span",{className:Se.traceSourceType,children:Ie.type})]})]}),h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_auth_index")}),h.jsx("span",{className:Se.traceInfoValue,children:fe.detail.auth_index??"-"})]}),h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_timestamp")}),h.jsx("span",{className:Se.traceInfoValue,children:fe.detail.timestamp||"-"})]}),h.jsxs("div",{className:Se.traceInfoItem,children:[h.jsx("span",{className:Se.traceInfoLabel,children:t("logs.trace_result")}),h.jsx("span",{className:Se.traceInfoValue,children:fe.detail.failed?t("stats.failure"):t("stats.success")})]})]})]},`${fe.detail.__endpoint}-${fe.detail.__modelName}-${fe.detail.timestamp}-${fe.detail.source}`)})})]})}),h.jsx(ns,{open:!!$,onClose:vi,title:t("logs.request_log_download_title"),footer:h.jsxs(h.Fragment,{children:[h.jsx(de,{variant:"secondary",onClick:vi,disabled:H,children:t("common.cancel")}),h.jsx(de,{onClick:()=>{$&&Wt($)},loading:H,disabled:!$,children:t("common.confirm")})]}),children:$?t("logs.request_log_download_confirm",{id:$}):null})]})}const hwe="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eZhipu%3c/title%3e%3cpath%20d='M11.991%2023.503a.24.24%200%2000-.244.248.24.24%200%2000.244.249.24.24%200%2000.245-.249.24.24%200%2000-.22-.247l-.025-.001zM9.671%205.365a1.697%201.697%200%20011.099%202.132l-.071.172-.016.04-.018.054c-.07.16-.104.32-.104.498-.035.71.47%201.279%201.186%201.314h.366c1.309.053%202.338%201.173%202.286%202.523-.052%201.332-1.152%202.38-2.478%202.327h-.174c-.715.018-1.274.64-1.239%201.368%200%20.124.018.23.053.337.209.373.54.658.96.8.75.23%201.517-.125%201.9-.782l.018-.035c.402-.64%201.17-.96%201.92-.711.854.284%201.378%201.226%201.099%202.167a1.661%201.661%200%2001-2.077%201.102%201.711%201.711%200%2001-.907-.711l-.017-.035c-.2-.323-.463-.58-.851-.711l-.056-.018a1.646%201.646%200%2000-1.954.746%201.66%201.66%200%2001-1.065.764%201.677%201.677%200%2001-1.989-1.279c-.209-.906.332-1.83%201.257-2.043a1.51%201.51%200%2001.296-.035h.018c.68-.071%201.151-.622%201.116-1.333a1.307%201.307%200%2000-.227-.693%202.515%202.515%200%2001-.366-1.403%202.39%202.39%200%2001.366-1.208c.14-.195.21-.444.227-.693.018-.71-.506-1.261-1.186-1.332l-.07-.018a1.43%201.43%200%2001-.299-.07l-.05-.019a1.7%201.7%200%2001-1.047-2.114%201.68%201.68%200%20012.094-1.101zm-5.575%2010.11c.26-.264.639-.367.994-.27.355.096.633.379.728.74.095.362-.007.748-.267%201.013-.402.41-1.053.41-1.455%200a1.062%201.062%200%20010-1.482zm14.845-.294c.359-.09.738.024.992.297.254.274.344.665.237%201.025-.107.36-.396.634-.756.718-.551.128-1.1-.22-1.23-.781a1.05%201.05%200%2001.757-1.26zm-.064-4.39c.314.32.49.753.49%201.206%200%20.452-.176.886-.49%201.206-.315.32-.74.5-1.185.5-.444%200-.87-.18-1.184-.5a1.727%201.727%200%20010-2.412%201.654%201.654%200%20012.369%200zm-11.243.163c.364.484.447%201.128.218%201.691a1.665%201.665%200%2001-2.188.923c-.855-.36-1.26-1.358-.907-2.228a1.68%201.68%200%20011.33-1.038c.593-.08%201.183.169%201.547.652zm11.545-4.221c.368%200%20.708.2.892.524.184.324.184.724%200%201.048a1.026%201.026%200%2001-.892.524c-.568%200-1.03-.47-1.03-1.048%200-.579.462-1.048%201.03-1.048zm-14.358%200c.368%200%20.707.2.891.524.184.324.184.724%200%201.048a1.026%201.026%200%2001-.891.524c-.569%200-1.03-.47-1.03-1.048%200-.579.461-1.048%201.03-1.048zm10.031-1.475c.925%200%201.675.764%201.675%201.706s-.75%201.705-1.675%201.705-1.674-.763-1.674-1.705c0-.942.75-1.706%201.674-1.706zm-2.626-.684c.362-.082.653-.356.761-.718a1.062%201.062%200%2000-.238-1.028%201.017%201.017%200%2000-.996-.294c-.547.14-.881.7-.752%201.257.13.558.675.907%201.225.783zm0%2016.876c.359-.087.644-.36.75-.72a1.062%201.062%200%2000-.237-1.019%201.018%201.018%200%2000-.985-.301%201.037%201.037%200%2000-.762.717c-.108.361-.017.754.239%201.028.245.263.606.377.953.305l.043-.01zM17.19%203.5a.631.631%200%2000.628-.64c0-.355-.279-.64-.628-.64a.631.631%200%2000-.628.64c0%20.355.28.64.628.64zm-10.38%200a.631.631%200%2000.628-.64c0-.355-.28-.64-.628-.64a.631.631%200%2000-.628.64c0%20.355.279.64.628.64zm-5.182%207.852a.631.631%200%2000-.628.64c0%20.354.28.639.628.639a.63.63%200%2000.627-.606l.001-.034a.62.62%200%2000-.628-.64zm5.182%209.13a.631.631%200%2000-.628.64c0%20.355.279.64.628.64a.631.631%200%2000.628-.64c0-.355-.28-.64-.628-.64zm10.38.018a.631.631%200%2000-.628.64c0%20.355.28.64.628.64a.631.631%200%2000.628-.64c0-.355-.279-.64-.628-.64zm5.182-9.148a.631.631%200%2000-.628.64c0%20.354.279.639.628.639a.631.631%200%2000.628-.64c0-.355-.28-.64-.628-.64zm-.384-4.992a.24.24%200%2000.244-.249.24.24%200%2000-.244-.249.24.24%200%2000-.244.249c0%20.142.122.249.244.249zM11.991.497a.24.24%200%2000.245-.248A.24.24%200%200011.99%200a.24.24%200%2000-.244.249c0%20.133.108.236.223.247l.021.001zM2.011%206.36a.24.24%200%2000.245-.249.24.24%200%2000-.244-.249.24.24%200%2000-.244.249.24.24%200%2000.244.249zm0%2011.263a.24.24%200%2000-.243.248.24.24%200%2000.244.249.24.24%200%2000.244-.249.252.252%200%2000-.244-.248zm19.995-.018a.24.24%200%2000-.245.248.24.24%200%2000.245.25.24.24%200%2000.244-.25.252.252%200%2000-.244-.248z'%20fill='%233859FF'%20fill-rule='nonzero'%3e%3c/path%3e%3c/svg%3e",fwe="data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eGrok%3c/title%3e%3cpath%20d='M9.27%2015.29l7.978-5.897c.391-.29.95-.177%201.137.272.98%202.369.542%205.215-1.41%207.169-1.951%201.954-4.667%202.382-7.149%201.406l-2.711%201.257c3.889%202.661%208.611%202.003%2011.562-.953%202.341-2.344%203.066-5.539%202.388-8.42l.006.007c-.983-4.232.242-5.924%202.75-9.383.06-.082.12-.164.179-.248l-3.301%203.305v-.01L9.267%2015.292M7.623%2016.723c-2.792-2.67-2.31-6.801.071-9.184%201.761-1.763%204.647-2.483%207.166-1.425l2.705-1.25a7.808%207.808%200%2000-1.829-1A8.975%208.975%200%20005.984%205.83c-2.533%202.536-3.33%206.436-1.962%209.764%201.022%202.487-.653%204.246-2.34%206.022-.599.63-1.199%201.259-1.682%201.925l7.62-6.815'%3e%3c/path%3e%3c/svg%3e",mwe="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDeepSeek%3c/title%3e%3cpath%20d='M23.748%204.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434%201.202-.422%201.84.027%201.436.633%202.58%201.838%203.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526%205.526%200%2001-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365%2011.365%200%2000-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055%203.055%200%2001-.465.137%209.597%209.597%200%2000-2.883-.102c-1.885.21-3.39%201.102-4.497%202.623C.082%208.606-.231%2010.684.152%2012.85c.403%202.284%201.569%204.175%203.36%205.653%201.858%201.533%203.997%202.284%206.438%202.14%201.482-.085%203.133-.284%204.994-1.86.47.234.962.327%201.78.397.63.059%201.236-.03%201.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926%201.096-1.296%202.746-2.642%203.392-7.003.05-.347.007-.565%200-.845-.004-.17.035-.237.23-.256a4.173%204.173%200%20001.545-.475c1.396-.763%201.96-2.015%202.093-3.517.02-.23-.004-.467-.247-.588zM11.581%2018c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696%204.696%200%20011.529-.039c2.132.312%203.946%201.265%205.468%202.774.868.86%201.525%201.887%202.202%202.891.72%201.066%201.494%202.082%202.48%202.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306%200%2001.415-.287.302.302%200%2001.2.288.306.306%200%2001-.31.307.303.303%200%2001-.304-.308zm3.11%201.596c-.2.081-.399.151-.59.16a1.245%201.245%200%2001-.798-.254c-.274-.23-.47-.358-.552-.758a1.73%201.73%200%2001.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559%200%2001-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136%201.146.016.352.144.618.408%201.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z'%20fill='%234D6BFE'%3e%3c/path%3e%3c/svg%3e",pwe="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMinimax%3c/title%3e%3cdefs%3e%3clinearGradient%20id='lobe-icons-minimax-fill'%20x1='0%25'%20x2='100.182%25'%20y1='50.057%25'%20y2='50.057%25'%3e%3cstop%20offset='0%25'%20stop-color='%23E2167E'%3e%3c/stop%3e%3cstop%20offset='100%25'%20stop-color='%23FE603C'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20d='M16.278%202c1.156%200%202.093.927%202.093%202.07v12.501a.74.74%200%2000.744.709.74.74%200%2000.743-.709V9.099a2.06%202.06%200%20012.071-2.049A2.06%202.06%200%200124%209.1v6.561a.649.649%200%2001-.652.645.649.649%200%2001-.653-.645V9.1a.762.762%200%2000-.766-.758.762.762%200%2000-.766.758v7.472a2.037%202.037%200%2001-2.048%202.026%202.037%202.037%200%2001-2.048-2.026v-12.5a.785.785%200%2000-.788-.753.785.785%200%2000-.789.752l-.001%2015.904A2.037%202.037%200%200113.441%2022a2.037%202.037%200%2001-2.048-2.026V18.04c0-.356.292-.645.652-.645.36%200%20.652.289.652.645v1.934c0%20.263.142.506.372.638.23.131.514.131.744%200a.734.734%200%2000.372-.638V4.07c0-1.143.937-2.07%202.093-2.07zm-5.674%200c1.156%200%202.093.927%202.093%202.07v11.523a.648.648%200%2001-.652.645.648.648%200%2001-.652-.645V4.07a.785.785%200%2000-.789-.78.785.785%200%2000-.789.78v14.013a2.06%202.06%200%2001-2.07%202.048%202.06%202.06%200%2001-2.071-2.048V9.1a.762.762%200%2000-.766-.758.762.762%200%2000-.766.758v3.8a2.06%202.06%200%2001-2.071%202.049A2.06%202.06%200%20010%2012.9v-1.378c0-.357.292-.646.652-.646.36%200%20.653.29.653.646V12.9c0%20.418.343.757.766.757s.766-.339.766-.757V9.099a2.06%202.06%200%20012.07-2.048%202.06%202.06%200%20012.071%202.048v8.984c0%20.419.343.758.767.758.423%200%20.766-.339.766-.758V4.07c0-1.143.937-2.07%202.093-2.07z'%20fill='url(%23lobe-icons-minimax-fill)'%20fill-rule='nonzero'%3e%3c/path%3e%3c/svg%3e",gwe="SystemPage-module__container___KAydo",_we="SystemPage-module__pageTitle___DiF5E",ywe="SystemPage-module__content___SauLn",bwe="SystemPage-module__aboutCard___v2-ui",xwe="SystemPage-module__aboutHeader___hT4-J",vwe="SystemPage-module__aboutLogo___KXoLr",Swe="SystemPage-module__aboutTitle___BTLGy",wwe="SystemPage-module__aboutInfoGrid___b7AR0",kwe="SystemPage-module__infoTile___6AuIY",Cwe="SystemPage-module__tapTile___-9SaX",Awe="SystemPage-module__tileLabel___eMn4v",Twe="SystemPage-module__tileValue___Up02X",Nwe="SystemPage-module__tileSub___ysVDj",Mwe="SystemPage-module__aboutActions___AicFv",Owe="SystemPage-module__sectionDescription___nI7Jo",Lwe="SystemPage-module__clearLoginActions___4ek-m",Ewe="SystemPage-module__modelTags___M0sci",Pwe="SystemPage-module__groupTitle___bTqIN",jwe="SystemPage-module__groupIcon___-XXrb",Rwe="SystemPage-module__modelTag___5Ar53",Dwe="SystemPage-module__modelName___LKdAK",Fwe="SystemPage-module__modelAlias___zioM-",Uwe="SystemPage-module__quickLinks___QTmT3",Iwe="SystemPage-module__linkCard___iSrVF",Bwe="SystemPage-module__linkIcon___gNqz2",qwe="SystemPage-module__github___V8I3m",Kwe="SystemPage-module__docs___cA-rG",zwe="SystemPage-module__linkContent___Rfh7h",Hwe="SystemPage-module__linkTitle___Zpr4Q",Vwe="SystemPage-module__linkDesc___KKavC",pt={container:gwe,pageTitle:_we,content:ywe,aboutCard:bwe,aboutHeader:xwe,aboutLogo:vwe,aboutTitle:Swe,aboutInfoGrid:wwe,infoTile:kwe,tapTile:Cwe,tileLabel:Awe,tileValue:Twe,tileSub:Nwe,aboutActions:Mwe,sectionDescription:Owe,clearLoginActions:Lwe,modelTags:Ewe,groupTitle:Pwe,groupIcon:jwe,modelTag:Rwe,modelName:Dwe,modelAlias:Fwe,quickLinks:Uwe,linkCard:Iwe,linkIcon:Bwe,github:qwe,docs:Kwe,linkContent:zwe,linkTitle:Hwe,linkDesc:Vwe},Wwe={gpt:{light:bw,dark:xw},claude:my,gemini:py,qwen:E4,kimi:{light:O4,dark:L4},glm:hwe,grok:fwe,deepseek:mwe,minimax:pwe};function Gwe(){const{t,i18n:e}=Ye(),{showNotification:n,showConfirmation:i}=un(),s=ga(J=>J.resolvedTheme),a=Vt(),o=Ft(J=>J.config),r=Ft(J=>J.fetchConfig),c=Ft(J=>J.clearCache),d=Ft(J=>J.updateConfigValue),f=ac(J=>J.models),p=ac(J=>J.loading),g=ac(J=>J.error),y=ac(J=>J.fetchModels),[b,x]=w.useState(),[v,k]=w.useState(!1),[A,T]=w.useState(!1),[L,N]=w.useState(!1),[O,M]=w.useState(!1),E=w.useRef([]),j=w.useRef(0),P=w.useRef(null),F=w.useMemo(()=>e.language?.toLowerCase().startsWith("zh")?"其他":"Other",[e.language]),D=w.useMemo(()=>VW(f,{otherLabel:F}),[f,F]),z=o?.requestLog??!1,G=A!==z,Q=a.connectionStatus==="connected"&&!!o,B="v1.7.8",W=a.serverVersion||t("system_info.version_unknown"),$=a.serverBuildDate?new Date(a.serverBuildDate).toLocaleString(e.language):t("system_info.version_unknown"),Z=J=>{const ae=Wwe[J];return ae?typeof ae=="string"?ae:s==="dark"?ae.dark:ae.light:null},H=J=>{if(!Array.isArray(J))return[];const ae=new Set,te=[];return J.forEach(Ae=>{const me=Ae!==null&&typeof Ae=="object"&&!Array.isArray(Ae)?Ae:null,Ke=typeof Ae=="string"?Ae:me?me["api-key"]??me.apiKey??me.key??me.Key:"",it=String(Ke??"").trim();!it||ae.has(it)||(ae.add(it),te.push(it))}),te},U=w.useCallback(async()=>{if(E.current.length)return E.current;const J=H(o?.apiKeys);if(J.length)return E.current=J,J;try{const ae=await c2.list(),te=H(ae);return te.length&&(E.current=te),te}catch(ae){return console.warn("Auto loading API keys for models failed:",ae),[]}},[o?.apiKeys]),I=async({forceRefresh:J=!1}={})=>{if(a.connectionStatus!=="connected"){x({type:"warning",message:t("notification.connection_required")});return}if(!a.apiBase){n(t("notification.connection_required"),"warning");return}J&&(E.current=[]),x({type:"muted",message:t("system_info.models_loading")});try{const te=(await U())[0],Ae=await y(a.apiBase,te,J),me=Ae.length>0;x({type:me?"success":"warning",message:me?t("system_info.models_count",{count:Ae.length}):t("system_info.models_empty")})}catch(ae){const te=ae instanceof Error?ae.message:typeof ae=="string"?ae:"",Ae=te?`: ${te}`:"",me=`${t("system_info.models_error")}${Ae}`;x({type:"error",message:me})}},V=()=>{i({title:t("system_info.clear_login_title",{defaultValue:"Clear Login Storage"}),message:t("system_info.clear_login_confirm"),variant:"danger",confirmText:t("common.confirm"),onConfirm:()=>{if(a.logout(),typeof localStorage>"u")return;[p3,"isLoggedIn","apiBase","apiUrl","managementKey"].forEach(ae=>localStorage.removeItem(ae)),n(t("notification.login_storage_cleared"),"success")}})},Y=w.useCallback(()=>{N(!1),T(z),k(!0)},[z]),ne=w.useCallback(()=>{if(j.current+=1,P.current&&clearTimeout(P.current),j.current>=7){j.current=0,P.current=null,Y();return}P.current=setTimeout(()=>{j.current=0,P.current=null},1500)},[Y]),X=w.useCallback(()=>{k(!1),N(!1)},[]),le=async()=>{if(!Q)return;if(!G){k(!1);return}const J=z;M(!0),d("request-log",A);try{await Y3.updateRequestLog(A),c("request-log"),n(t("notification.request_log_updated"),"success"),k(!1)}catch(ae){const te=ae instanceof Error?ae.message:typeof ae=="string"?ae:"";d("request-log",J),n(`${t("notification.update_failed")}${te?`: ${te}`:""}`,"error")}finally{M(!1)}};return w.useEffect(()=>{r().catch(()=>{})},[r]),w.useEffect(()=>{v&&!L&&T(z)},[v,L,z]),w.useEffect(()=>()=>{P.current&&clearTimeout(P.current)},[]),w.useEffect(()=>{I()},[a.connectionStatus,a.apiBase]),h.jsxs("div",{className:pt.container,children:[h.jsx("h1",{className:pt.pageTitle,children:t("system_info.title")}),h.jsxs("div",{className:pt.content,children:[h.jsxs(At,{className:pt.aboutCard,children:[h.jsxs("div",{className:pt.aboutHeader,children:[h.jsx("img",{src:id,alt:"CPAMC",className:pt.aboutLogo}),h.jsx("div",{className:pt.aboutTitle,children:t("system_info.about_title")})]}),h.jsxs("div",{className:pt.aboutInfoGrid,children:[h.jsxs("button",{type:"button",className:`${pt.infoTile} ${pt.tapTile}`,onClick:ne,children:[h.jsx("div",{className:pt.tileLabel,children:t("footer.version")}),h.jsx("div",{className:pt.tileValue,children:B})]}),h.jsxs("div",{className:pt.infoTile,children:[h.jsx("div",{className:pt.tileLabel,children:t("footer.api_version")}),h.jsx("div",{className:pt.tileValue,children:W})]}),h.jsxs("div",{className:pt.infoTile,children:[h.jsx("div",{className:pt.tileLabel,children:t("footer.build_date")}),h.jsx("div",{className:pt.tileValue,children:$})]}),h.jsxs("div",{className:pt.infoTile,children:[h.jsx("div",{className:pt.tileLabel,children:t("connection.status")}),h.jsx("div",{className:pt.tileValue,children:t(`common.${a.connectionStatus}_status`)}),h.jsx("div",{className:pt.tileSub,children:a.apiBase||"-"})]})]}),h.jsx("div",{className:pt.aboutActions,children:h.jsx(de,{variant:"secondary",size:"sm",onClick:()=>r(void 0,!0),children:t("common.refresh")})})]}),h.jsxs(At,{title:t("system_info.quick_links_title"),children:[h.jsx("p",{className:pt.sectionDescription,children:t("system_info.quick_links_desc")}),h.jsxs("div",{className:pt.quickLinks,children:[h.jsxs("a",{href:"https://github.com/router-for-me/CLIProxyAPI",target:"_blank",rel:"noopener noreferrer",className:pt.linkCard,children:[h.jsx("div",{className:`${pt.linkIcon} ${pt.github}`,children:h.jsx(Vq,{size:22})}),h.jsxs("div",{className:pt.linkContent,children:[h.jsxs("div",{className:pt.linkTitle,children:[t("system_info.link_main_repo"),h.jsx(yv,{size:14})]}),h.jsx("div",{className:pt.linkDesc,children:t("system_info.link_main_repo_desc")})]})]}),h.jsxs("a",{href:"https://github.com/router-for-me/Cli-Proxy-API-Management-Center",target:"_blank",rel:"noopener noreferrer",className:pt.linkCard,children:[h.jsx("div",{className:`${pt.linkIcon} ${pt.github}`,children:h.jsx(ew,{size:22})}),h.jsxs("div",{className:pt.linkContent,children:[h.jsxs("div",{className:pt.linkTitle,children:[t("system_info.link_webui_repo"),h.jsx(yv,{size:14})]}),h.jsx("div",{className:pt.linkDesc,children:t("system_info.link_webui_repo_desc")})]})]}),h.jsxs("a",{href:"https://help.router-for.me/",target:"_blank",rel:"noopener noreferrer",className:pt.linkCard,children:[h.jsx("div",{className:`${pt.linkIcon} ${pt.docs}`,children:h.jsx(Wq,{size:22})}),h.jsxs("div",{className:pt.linkContent,children:[h.jsxs("div",{className:pt.linkTitle,children:[t("system_info.link_docs"),h.jsx(yv,{size:14})]}),h.jsx("div",{className:pt.linkDesc,children:t("system_info.link_docs_desc")})]})]})]})]}),h.jsxs(At,{title:t("system_info.models_title"),extra:h.jsx(de,{variant:"secondary",size:"sm",onClick:()=>I({forceRefresh:!0}),loading:p,children:t("common.refresh")}),children:[h.jsx("p",{className:pt.sectionDescription,children:t("system_info.models_desc")}),b&&h.jsx("div",{className:`status-badge ${b.type}`,children:b.message}),g&&h.jsx("div",{className:"error-box",children:g}),p?h.jsx("div",{className:"hint",children:t("common.loading")}):f.length===0?h.jsx("div",{className:"hint",children:t("system_info.models_empty")}):h.jsx("div",{className:"item-list",children:D.map(J=>{const ae=Z(J.id);return h.jsxs("div",{className:"item-row",children:[h.jsxs("div",{className:"item-meta",children:[h.jsxs("div",{className:pt.groupTitle,children:[ae&&h.jsx("img",{src:ae,alt:"",className:pt.groupIcon}),h.jsx("span",{className:"item-title",children:J.label})]}),h.jsx("div",{className:"item-subtitle",children:t("system_info.models_count",{count:J.items.length})})]}),h.jsx("div",{className:pt.modelTags,children:J.items.map(te=>h.jsxs("span",{className:pt.modelTag,title:te.description||"",children:[h.jsx("span",{className:pt.modelName,children:te.name}),te.alias&&h.jsx("span",{className:pt.modelAlias,children:te.alias})]},`${te.name}-${te.alias??"default"}`))})]},J.id)})})]}),h.jsxs(At,{title:t("system_info.clear_login_title"),children:[h.jsx("p",{className:pt.sectionDescription,children:t("system_info.clear_login_desc")}),h.jsx("div",{className:pt.clearLoginActions,children:h.jsx(de,{variant:"danger",onClick:V,children:t("system_info.clear_login_button")})})]})]}),h.jsx(ns,{open:v,onClose:X,title:t("basic_settings.request_log_title"),footer:h.jsxs(h.Fragment,{children:[h.jsx(de,{variant:"secondary",onClick:X,disabled:O,children:t("common.cancel")}),h.jsx(de,{onClick:le,loading:O,disabled:!Q||!G,children:t("common.save")})]}),children:h.jsxs("div",{className:"request-log-modal",children:[h.jsx("div",{className:"status-badge warning",children:t("basic_settings.request_log_warning")}),h.jsx(fi,{label:t("basic_settings.request_log_enable"),labelPosition:"left",checked:A,disabled:!Q||O,onChange:J=>{T(J),N(!0)}})]})})]})}const $we=[{path:"/",element:h.jsx(AO,{})},{path:"/dashboard",element:h.jsx(AO,{})},{path:"/settings",element:h.jsx(vf,{to:"/config",replace:!0})},{path:"/api-keys",element:h.jsx(vf,{to:"/config",replace:!0})},{path:"/ai-providers/gemini/new",element:h.jsx(BO,{})},{path:"/ai-providers/gemini/:index",element:h.jsx(BO,{})},{path:"/ai-providers/codex/new",element:h.jsx(IO,{})},{path:"/ai-providers/codex/:index",element:h.jsx(IO,{})},{path:"/ai-providers/claude/new",element:h.jsx(PO,{}),children:[{index:!0,element:h.jsx(FO,{})},{path:"models",element:h.jsx(UO,{})}]},{path:"/ai-providers/claude/:index",element:h.jsx(PO,{}),children:[{index:!0,element:h.jsx(FO,{})},{path:"models",element:h.jsx(UO,{})}]},{path:"/ai-providers/vertex/new",element:h.jsx(GO,{})},{path:"/ai-providers/vertex/:index",element:h.jsx(GO,{})},{path:"/ai-providers/openai/new",element:h.jsx(zO,{}),children:[{index:!0,element:h.jsx(VO,{})},{path:"models",element:h.jsx(WO,{})}]},{path:"/ai-providers/openai/:index",element:h.jsx(zO,{}),children:[{index:!0,element:h.jsx(VO,{})},{path:"models",element:h.jsx(WO,{})}]},{path:"/ai-providers/ampcode",element:h.jsx(KY,{})},{path:"/ai-providers",element:h.jsx(MO,{})},{path:"/ai-providers/*",element:h.jsx(MO,{})},{path:"/auth-files",element:h.jsx(Dse,{})},{path:"/auth-files/oauth-excluded",element:h.jsx(oae,{})},{path:"/auth-files/oauth-model-alias",element:h.jsx(Oae,{})},{path:"/oauth",element:h.jsx(coe,{})},{path:"/quota",element:h.jsx(uoe,{})},{path:"/usage",element:h.jsx(Sfe,{})},{path:"/config",element:h.jsx(m2e,{})},{path:"/logs",element:h.jsx(dwe,{})},{path:"/system",element:h.jsx(Gwe,{})},{path:"*",element:h.jsx(vf,{to:"/",replace:!0})}];function Xwe({location:t}){return L7($we,t)}const tr={dashboard:h.jsx(Gq,{size:18}),aiProviders:h.jsx(XS,{size:18}),authFiles:h.jsx(c3,{size:18}),oauth:h.jsx(Rq,{size:18}),quota:h.jsx(ZS,{size:18}),usage:h.jsx(Dq,{size:18}),config:h.jsx(Fq,{size:18}),logs:h.jsx(Uq,{size:18}),system:h.jsx(iy,{size:18})},Pa={width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},ja={refresh:h.jsxs("svg",{...Pa,children:[h.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),h.jsx("path",{d:"M21 3v5h-5"})]}),update:h.jsxs("svg",{...Pa,children:[h.jsx("path",{d:"M12 19V5"}),h.jsx("path",{d:"m5 12 7-7 7 7"})]}),menu:h.jsxs("svg",{...Pa,children:[h.jsx("path",{d:"M4 7h16"}),h.jsx("path",{d:"M4 12h16"}),h.jsx("path",{d:"M4 17h16"})]}),chevronLeft:h.jsx("svg",{...Pa,children:h.jsx("path",{d:"m14 18-6-6 6-6"})}),chevronRight:h.jsx("svg",{...Pa,children:h.jsx("path",{d:"m10 6 6 6-6 6"})}),language:h.jsxs("svg",{...Pa,children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("path",{d:"M2 12h20"}),h.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),sun:h.jsxs("svg",{...Pa,children:[h.jsx("circle",{cx:"12",cy:"12",r:"4"}),h.jsx("path",{d:"M12 2v2"}),h.jsx("path",{d:"M12 20v2"}),h.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),h.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),h.jsx("path",{d:"M2 12h2"}),h.jsx("path",{d:"M20 12h2"}),h.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),h.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]}),moon:h.jsx("svg",{...Pa,children:h.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9z"})}),whiteTheme:h.jsxs("svg",{...Pa,children:[h.jsx("circle",{cx:"12",cy:"12",r:"7"}),h.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"})]}),autoTheme:h.jsxs("svg",{...Pa,children:[h.jsx("defs",{children:h.jsx("clipPath",{id:"mainLayoutAutoThemeSunLeftHalf",children:h.jsx("rect",{x:"0",y:"0",width:"12",height:"24"})})}),h.jsx("circle",{cx:"12",cy:"12",r:"4"}),h.jsx("circle",{cx:"12",cy:"12",r:"4",clipPath:"url(#mainLayoutAutoThemeSunLeftHalf)",fill:"currentColor"}),h.jsx("path",{d:"M12 2v2"}),h.jsx("path",{d:"M12 20v2"}),h.jsx("path",{d:"M4.93 4.93l1.41 1.41"}),h.jsx("path",{d:"M17.66 17.66l1.41 1.41"}),h.jsx("path",{d:"M2 12h2"}),h.jsx("path",{d:"M20 12h2"}),h.jsx("path",{d:"M6.34 17.66l-1.41 1.41"}),h.jsx("path",{d:"M19.07 4.93l-1.41 1.41"})]}),logout:h.jsxs("svg",{...Pa,children:[h.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),h.jsx("path",{d:"m16 17 5-5-5-5"}),h.jsx("path",{d:"M21 12H9"})]})},Qwe=[{key:"auto",labelKey:"theme.auto",colors:{bg:"linear-gradient(135deg, #faf9f5 0 50%, #151412 50% 100%)",card:"linear-gradient(135deg, #f0eee8 0 50%, #1d1b18 50% 100%)",border:"#bdb6ae",text:"#2d2a26",textMuted:"linear-gradient(135deg, #a29c95 0 50%, #9c958d 50% 100%)"}},{key:"white",labelKey:"theme.white",colors:{bg:"#ffffff",card:"#ffffff",border:"#e5e5e5",text:"#2d2a26",textMuted:"#a29c95"}},{key:"light",labelKey:"theme.light",colors:{bg:"#faf9f5",card:"#f0eee8",border:"#e3e1db",text:"#2d2a26",textMuted:"#a29c95"}},{key:"dark",labelKey:"theme.dark",colors:{bg:"#151412",card:"#1d1b18",border:"#3a3530",text:"#f6f4f1",textMuted:"#9c958d"}}],mR=t=>{if(!t)return null;const e=t.trim().replace(/^v/i,"");if(!e)return null;const n=e.split(/[^0-9]+/).filter(Boolean).map(i=>Number.parseInt(i,10)).filter(Number.isFinite);return n.length?n:null},Ywe=(t,e)=>{const n=mR(t),i=mR(e);if(!n||!i)return null;const s=Math.max(n.length,i.length);for(let a=0;ar)return 1;if(ote.apiBase),s=Vt(te=>te.serverVersion),a=Vt(te=>te.connectionStatus),o=Vt(te=>te.logout),r=Ft(te=>te.config),c=Ft(te=>te.fetchConfig),d=Ft(te=>te.clearCache),f=ga(te=>te.theme),p=ga(te=>te.setTheme),g=ad(te=>te.language),y=ad(te=>te.setLanguage),[b,x]=w.useState(!1),[v,k]=w.useState(!1),[A,T]=w.useState(!1),[L,N]=w.useState(!1),[O,M]=w.useState(!1),[E,j]=w.useState(!0),P=w.useRef(null),F=w.useRef(null),D=w.useRef(null),z=w.useRef(null),G=w.useRef(null),Q="CLI Proxy API Management Center",B=t("title.abbr"),W=n.pathname.startsWith("/logs");w.useLayoutEffect(()=>{const te=()=>{const me=G.current?.offsetHeight;me&&document.documentElement.style.setProperty("--header-height",`${me}px`)};te();const Ae=typeof ResizeObserver<"u"&&G.current?new ResizeObserver(te):null;return Ae&&G.current&&Ae.observe(G.current),window.addEventListener("resize",te),()=>{Ae&&Ae.disconnect(),window.removeEventListener("resize",te)}},[]),w.useLayoutEffect(()=>{const te=()=>{const me=P.current;if(!me)return;const Ke=me.getBoundingClientRect(),it=Ke.left+Ke.width/2;document.documentElement.style.setProperty("--content-center-x",`${it}px`)};te();const Ae=typeof ResizeObserver<"u"&&P.current?new ResizeObserver(te):null;return Ae&&P.current&&Ae.observe(P.current),window.addEventListener("resize",te),()=>{Ae&&Ae.disconnect(),window.removeEventListener("resize",te),document.documentElement.style.removeProperty("--content-center-x")}},[]),w.useEffect(()=>(z.current=setTimeout(()=>{j(!1)},5e3),()=>{z.current&&clearTimeout(z.current)}),[]),w.useEffect(()=>{if(!L)return;const te=me=>{F.current?.contains(me.target)||N(!1)},Ae=me=>{me.key==="Escape"&&N(!1)};return document.addEventListener("mousedown",te),document.addEventListener("keydown",Ae),()=>{document.removeEventListener("mousedown",te),document.removeEventListener("keydown",Ae)}},[L]),w.useEffect(()=>{if(!O)return;const te=me=>{D.current?.contains(me.target)||M(!1)},Ae=me=>{me.key==="Escape"&&M(!1)};return document.addEventListener("mousedown",te),document.addEventListener("keydown",Ae),()=>{document.removeEventListener("mousedown",te),document.removeEventListener("keydown",Ae)}},[O]);const $=w.useCallback(()=>{E||(j(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{j(!1)},5e3))},[E]),Z=w.useCallback(()=>{N(te=>!te),M(!1)},[]),H=w.useCallback(()=>{M(te=>!te),N(!1)},[]),U=w.useCallback(te=>{p(te),M(!1)},[p]),I=w.useCallback(te=>{sd(te)&&(y(te),N(!1))},[y]);w.useEffect(()=>{c().catch(()=>{})},[c]);const V=a==="connected"?"success":a==="connecting"?"warning":a==="error"?"error":"muted",Y=[{path:"/",label:t("nav.dashboard"),icon:tr.dashboard},{path:"/config",label:t("nav.config_management"),icon:tr.config},{path:"/ai-providers",label:t("nav.ai_providers"),icon:tr.aiProviders},{path:"/auth-files",label:t("nav.auth_files"),icon:tr.authFiles},{path:"/oauth",label:t("nav.oauth",{defaultValue:"OAuth"}),icon:tr.oauth},{path:"/quota",label:t("nav.quota_management"),icon:tr.quota},{path:"/usage",label:t("nav.usage_stats"),icon:tr.usage},...r?.loggingToFile?[{path:"/logs",label:t("nav.logs"),icon:tr.logs}]:[],{path:"/system",label:t("nav.system_info"),icon:tr.system}],ne=Y.map(te=>te.path),X=te=>{const Ae=te.length>1&&te.endsWith("/")?te.slice(0,-1):te,me=Ae==="/dashboard"?"/":Ae,Ke=ne.indexOf("/ai-providers");if(Ke!==-1){if(me==="/ai-providers")return Ke;if(me.startsWith("/ai-providers/"))return me.startsWith("/ai-providers/gemini")?Ke+.1:me.startsWith("/ai-providers/codex")?Ke+.2:me.startsWith("/ai-providers/claude")?Ke+.3:me.startsWith("/ai-providers/vertex")?Ke+.4:me.startsWith("/ai-providers/ampcode")?Ke+.5:me.startsWith("/ai-providers/openai")?Ke+.6:Ke+.05}const it=ne.indexOf("/auth-files");if(it!==-1){if(me==="/auth-files")return it;if(me.startsWith("/auth-files/"))return me.startsWith("/auth-files/oauth-excluded")?it+.1:me.startsWith("/auth-files/oauth-model-alias")?it+.2:it+.05}const St=ne.indexOf(me);if(St!==-1)return St;const Pe=ne.findIndex(at=>at!=="/"&&me.startsWith(`${at}/`));return Pe===-1?null:Pe},le=w.useCallback((te,Ae)=>{const me=at=>{const kt=at.length>1&&at.endsWith("/")?at.slice(0,-1):at;return kt==="/dashboard"?"/":kt},Ke=me(te),it=me(Ae),St=at=>at==="/auth-files"||at.startsWith("/auth-files/"),Pe=at=>at==="/ai-providers"||at.startsWith("/ai-providers/");return St(Ke)&&St(it)||Pe(Ke)&&Pe(it)?"ios":"vertical"},[]),J=async()=>{d();const Ae=(await Promise.allSettled([c(void 0,!0),p4()])).find(me=>me.status==="rejected");if(Ae&&Ae.status==="rejected"){const me=Ae.reason,Ke=typeof me=="string"?me:me instanceof Error?me.message:"";e(`${t("notification.refresh_failed")}${Ke?`: ${Ke}`:""}`,"error");return}e(t("notification.data_refreshed"),"success")},ae=async()=>{T(!0);try{const te=await zW.checkLatest(),Ae=te?.["latest-version"]??te?.latest_version??te?.latest??"",me=typeof Ae=="string"?Ae:String(Ae??""),Ke=Ywe(me,s);if(!me){e(t("system_info.version_check_error"),"error");return}if(Ke===null){e(t("system_info.version_current_missing"),"warning");return}Ke>0?e(t("system_info.version_update_available",{version:me}),"warning"):e(t("system_info.version_is_latest"),"success")}catch(te){const Ae=te instanceof Error?te.message:typeof te=="string"?te:"",me=Ae?`: ${Ae}`:"";e(`${t("system_info.version_check_error")}${me}`,"error")}finally{T(!1)}};return h.jsxs("div",{className:"app-shell",children:[h.jsxs("header",{className:"main-header",ref:G,children:[h.jsxs("div",{className:"left",children:[h.jsx("button",{className:"sidebar-toggle-header",onClick:()=>k(te=>!te),title:v?t("sidebar.expand",{defaultValue:"展开"}):t("sidebar.collapse",{defaultValue:"收起"}),children:v?ja.chevronRight:ja.chevronLeft}),h.jsx("img",{src:id,alt:"CPAMC logo",className:"brand-logo"}),h.jsxs("div",{className:`brand-header ${E?"expanded":"collapsed"}`,onClick:$,title:E?void 0:Q,children:[h.jsx("span",{className:"brand-full",children:Q}),h.jsx("span",{className:"brand-abbr",children:B})]})]}),h.jsxs("div",{className:"right",children:[h.jsxs("div",{className:"connection",children:[h.jsx("span",{className:`status-badge ${V}`,children:t(a==="connected"?"common.connected_status":a==="connecting"?"common.connecting_status":"common.disconnected_status")}),h.jsx("span",{className:"base",children:i||"-"})]}),h.jsxs("div",{className:"header-actions",children:[h.jsx(de,{className:"mobile-menu-btn",variant:"ghost",size:"sm",onClick:()=>x(te=>!te),children:ja.menu}),h.jsx(de,{variant:"ghost",size:"sm",onClick:J,title:t("header.refresh_all"),children:ja.refresh}),h.jsx(de,{variant:"ghost",size:"sm",onClick:ae,loading:A,title:t("system_info.version_check_button"),children:ja.update}),h.jsxs("div",{className:`language-menu ${L?"open":""}`,ref:F,children:[h.jsx(de,{variant:"ghost",size:"sm",onClick:Z,title:t("language.switch"),"aria-label":t("language.switch"),"aria-haspopup":"menu","aria-expanded":L,children:ja.language}),L&&h.jsx("div",{className:"notification entering language-menu-popover",role:"menu","aria-label":t("language.switch"),children:Hu.map(te=>h.jsxs("button",{type:"button",className:`language-menu-option ${g===te?"active":""}`,onClick:()=>I(te),role:"menuitemradio","aria-checked":g===te,children:[h.jsx("span",{children:t(_3[te])}),g===te?h.jsx("span",{className:"language-menu-check",children:"✓"}):null]},te))})]}),h.jsxs("div",{className:`theme-menu ${O?"open":""}`,ref:D,children:[h.jsx(de,{variant:"ghost",size:"sm",onClick:H,title:t("theme.switch"),"aria-label":t("theme.switch"),"aria-haspopup":"menu","aria-expanded":O,children:f==="auto"?ja.autoTheme:f==="dark"?ja.moon:f==="white"?ja.whiteTheme:ja.sun}),O&&h.jsx("div",{className:"notification entering theme-menu-popover",role:"menu","aria-label":t("theme.switch"),children:Qwe.map(te=>h.jsxs("button",{type:"button",className:`theme-card ${f===te.key?"active":""}`,onClick:()=>U(te.key),role:"menuitemradio","aria-checked":f===te.key,children:[h.jsxs("div",{className:"theme-card-preview",style:{background:te.colors.bg,border:`1px solid ${te.colors.border}`},children:[h.jsx("div",{className:"theme-card-header",style:{background:te.colors.card,borderBottom:`1px solid ${te.colors.border}`}}),h.jsxs("div",{className:"theme-card-body",children:[h.jsx("div",{className:"theme-card-sidebar",style:{background:te.colors.card,borderRight:`1px solid ${te.colors.border}`}}),h.jsxs("div",{className:"theme-card-content",style:{background:te.colors.bg},children:[h.jsx("div",{className:"theme-card-line",style:{background:te.colors.textMuted}}),h.jsx("div",{className:"theme-card-line short",style:{background:te.colors.textMuted}})]})]})]}),h.jsx("span",{className:"theme-card-label",children:t(te.labelKey)})]},te.key))})]}),h.jsx(de,{variant:"ghost",size:"sm",onClick:o,title:t("header.logout"),children:ja.logout})]})]})]}),h.jsxs("div",{className:"main-body",children:[h.jsx("aside",{className:`sidebar ${b?"open":""} ${v?"collapsed":""}`,children:h.jsx("div",{className:"nav-section",children:Y.map(te=>h.jsxs(QR,{to:te.path,className:({isActive:Ae})=>`nav-item ${Ae?"active":""}`,onClick:()=>x(!1),title:v?te.label:void 0,children:[h.jsx("span",{className:"nav-icon",children:te.icon}),!v&&h.jsx("span",{className:"nav-label",children:te.label})]},te.path))})}),h.jsx("div",{className:`content${W?" content-logs":""}`,ref:P,children:h.jsx("main",{className:`main-content${W?" main-content-logs":""}`,children:h.jsx(k$,{render:te=>h.jsx(Xwe,{location:te}),getRouteOrder:X,getTransitionVariant:le,scrollContainerRef:P})})})]})]})}function Zwe({children:t}){const e=Hn(),n=Vt(c=>c.isAuthenticated),i=Vt(c=>c.managementKey),s=Vt(c=>c.apiBase),a=Vt(c=>c.checkAuth),[o,r]=w.useState(!1);return w.useEffect(()=>{(async()=>{if(!n&&i&&s){r(!0);try{await a()}finally{r(!1)}}})()},[s,n,i,a]),o?h.jsx("div",{className:"main-content",children:h.jsx(vc,{})}):n?t:h.jsx(vf,{to:"/login",replace:!0,state:{from:e}})}function eke(){return h.jsxs(h.Fragment,{children:[h.jsx(UG,{}),h.jsx(HG,{}),h.jsx(VS,{})]})}const tke=w9([{element:h.jsx(eke,{}),children:[{path:"/login",element:h.jsx(FG,{})},{path:"/*",element:h.jsx(Zwe,{children:h.jsx(Jwe,{})})}]}]);function nke(){const t=ga(i=>i.initializeTheme),e=ad(i=>i.language),n=ad(i=>i.setLanguage);return w.useEffect(()=>t(),[t]),w.useEffect(()=>{n(e)},[]),w.useEffect(()=>{document.documentElement.lang=e},[e]),h.jsx(j9,{router:tke})}document.title="CLI Proxy API Management Center";const W1=document.querySelector('link[rel="icon"]');if(W1)W1.href=id,W1.type="image/jpeg";else{const t=document.createElement("link");t.rel="icon",t.type="image/jpeg",t.href=id,document.head.appendChild(t)}uB.createRoot(document.getElementById("root")).render(h.jsx(w.StrictMode,{children:h.jsx(nke,{})}));
+