1import{r as e,j as t,u as s}from"./vendor-react-DejgYtBM.js";import{u as l,a,A as i,s as r,B as n,w as o,O as c,v as d,aS as h,aT as m,aU as p,aV as u,a1 as x,aj as g,N as y,aM as _,Z as f,aW as j}from"./index-BeIIFw6E.js";import{C as v,M as b}from"./channel.constants-BcDm5HEb.js";import{f as w,i as k,z as S,k as C,M as N,j as z,B as T,u as I,v as O,l as A,E,y as R,W as B,p as $,o as M,m as L,A as J,R as P,C as W,Z as D,aQ as F,V,aR as K,H as q,J as U,K as H,F as G,r as Y,a1 as Z,P as X,D as Q,T as ee,a as te}from"./vendor-semi-D8d7bTtM.js";import{R as se,bB as le,T as ae,x as ie,w as re,ag as ne,a7 as oe,n as ce,b as de,bw as he,S as me,ba as pe,bG as ue,U as xe,bH as ge,e as ye,b9 as _e,X as fe,bI as je}from"./vendor-icons-EJvJ5X-w.js";import{u as ve}from"./useTableCompactMode-DWLN7NUj.js";import{G as be}from"./iconBase-SIM2SzwB.js";import{C as we}from"./CardTable-Cq0lqlnD.js";import{V as ke}from"./vendor-charts-CKochBGt.js";import"./vendor-motion-Chfy_MiU.js";import"./useIsMobile-D_kfVI0u.js";const{Text:Se}=w,Ce=[{value:"token",label:"Token"},{value:"video_size",label:"æè§é¢å°ºå¯¸"},{value:"per_call",label:"ææ¬¡"},{value:"duration",label:"æç§"},{value:"pixel",label:"æåç´ "},{value:"step",label:"é¶æ¢¯"},{value:"free",label:"å
è´¹"}],Ne={token:"USD/1M",video_size:"USD/1M",per_call:"USD/次",duration:"USD/ç§",pixel:"USD/Mpx",step:"é¶æ¢¯",free:"å
è´¹"},ze=[{key:"prompt_step_cost",label:"Prompt",tip:"base prompt åä»·ï¼USD/1M tokensï¼ï¼> 0 å¿
å¡«"},{key:"completion_step_cost",label:"Completion",tip:"completion åä»·ï¼USD/1M tokensï¼"},{key:"cache_step_cost",label:"ç¼è¯»",tip:"cache_read åä»·ï¼0 æ¶åé Promptï¼"},{key:"cache_creation_step_cost",label:"ç¼å",tip:"cache_creation åä»·ï¼Claude ç¼åï¼0 æ¶åé Promptï¼"},{key:"image_step_cost",label:"å¾å",tip:"夿¨¡æå¾å token åä»·ï¼0 æ¶åé Promptï¼"},{key:"audio_input_step_cost",label:"é³é¢",tip:"Gemini é³é¢è¾å
¥åä»·ï¼0 æ¶ä¸è®¡ç®ï¼"}],Te=(e,t="token")=>({model_name:e,billing_type:t,cost_config:{input:0,output:0,cache_creation:0,cache_read:0,audio_input:0,audio_output:0,unit_cost:0,steps:[]},dirty:!1}),Ie=({value:e,onChange:s,disabled:l})=>t.jsx(I,{min:0,step:1e-4,precision:4,size:"small",innerButtons:!0,value:e||0,onChange:e=>s(Number(e)||0),disabled:l,style:{width:"100%"}}),Oe=({visible:s,onClose:a,channelId:c,modelName:d,steps:h,onSave:m})=>{const{t:p}=l(),[u,x]=e.useState([]),[g,y]=e.useState(!1);e.useEffect(()=>{s&&x(Array.isArray(h)&&h.length>0?h.map(e=>({step_size:-1,completion_step_size:-1,prompt_step_cost:0,completion_step_cost:0,cache_step_cost:0,cache_creation_step_cost:0,image_step_cost:0,audio_input_step_cost:0,...e})):[])},[s,h]);const _=(e,t)=>{x(s=>s.map((s,l)=>l===e?{...s,...t}:s))};return t.jsxs(B,{visible:s,onCancel:a,title:t.jsxs("span",{children:[p("é¶æ¢¯ææ¬é
ç½®"),d&&t.jsx(k,{color:"blue",size:"small",style:{marginLeft:8},children:d})]}),placement:"right",width:1100,bodyStyle:{padding:16,overflow:"auto"},footer:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8},children:[t.jsxs(z,{children:[t.jsx(T,{icon:t.jsx(ie,{size:14}),size:"small",onClick:()=>{x(e=>[...e,{step_size:-1,completion_step_size:-1,prompt_step_cost:0,completion_step_cost:0,cache_step_cost:0,cache_creation_step_cost:0,image_step_cost:0,audio_input_step_cost:0}])},children:p("æ°å¢æ¡£")}),t.jsx(T,{icon:t.jsx(re,{size:14}),size:"small",type:"tertiary",onClick:async()=>{if(c&&d){y(!0);try{const e=await i.get(`/api/channel/${c}/model-cost-suggest`,{params:{model:d}});if(e?.data?.success){const t=e.data.data?.default_cost_config?.steps;Array.isArray(t)&&t.length>0?(x(t.map(e=>({step_size:-1,completion_step_size:-1,prompt_step_cost:0,completion_step_cost:0,cache_step_cost:0,cache_creation_step_cost:0,image_step_cost:0,audio_input_step_cost:0,...e}))),o(p("已导å
¥ {{n}} æ¡£ï¼æ¥èª global StepRatioï¼",{n:t.length}))):n(p("该模åå¨ global StepRatio 䏿²¡æé¶æ¢¯é
ç½®"))}else r(e?.data?.message||p("导å
¥å¤±è´¥"))}catch(e){r(e?.message||p("导å
¥å¤±è´¥"))}y(!1)}else r(p("ç¼ºå° channel æ model ä¸ä¸æ"))},loading:g,children:p("æ global StepRatio ä¸é®å¯¼å
¥")})]}),t.jsxs(z,{children:[t.jsx(T,{onClick:a,children:p("åæ¶")}),t.jsx(T,{type:"primary",theme:"solid",onClick:()=>{const e=(e=>{if(0===e.length)return p("è³å°éè¦ä¸æ¡£");let t=-1/0,s=-1/0;for(let l=0;l<e.length;l++){const a=e[l];
1if((a.prompt_step_cost||0)<0||(a.completion_step_cost||0)<0||(a.cache_step_cost||0)<0||(a.cache_creation_step_cost||0)<0||(a.image_step_cost||0)<0||(a.audio_input_step_cost||0)<0)return p("第 {{n}} æ¡£ï¼åä»·ä¸è½ä¸ºè´",{n:l+1});if(a.step_size<=0){if(l!==e.length-1)return p("第 {{n}} æ¡£ï¼å
åºæ¡£ï¼step_size <= 0ï¼å¿
é¡»æ¾å¨æå",{n:l+1})}else{if(a.step_size<t)return p("第 {{n}} æ¡£ï¼step_size å¿
é¡»ååºæå",{n:l+1});if(a.step_size===t)if(a.completion_step_size<=0);else{if(s<=0)return p("第 {{n}} æ¡£ï¼å step_size ä¸ï¼æ éå¶ completion_step_size å¿
é¡»æ¾æå",{n:l+1});if(a.completion_step_size<s)return p("第 {{n}} æ¡£ï¼å step_size ä¸ completion_step_size å¿
é¡»ååº",{n:l+1})}else s=-1/0;t=a.step_size,s=a.completion_step_size}}return e.some(e=>(e.prompt_step_cost||0)>0||(e.completion_step_cost||0)>0)?null:p("è³å°æä¸æ¡£ç Prompt æ Completion åä»· > 0")})(u);e?r(e):(m?.(u),a?.())},children:p("ä¿åå°ææ¬è¡¨")})]})]}),children:[t.jsx($,{type:"info",closeIcon:null,description:p("æ¡£ä½æ (è¾å
¥ token, è¾åº token) äºç»´å¹é
ï¼è§åä¸ç³»ç»è®¾ç½®âåçè®¾ç½®âæ¨¡åé¶æ¢¯è®¡è´¹ä¸è´ãstep_size = -1 表示æ éå¶ï¼å
åºæ¡£ï¼ï¼åä»·åä½ USD / 1M tokensï¼ç¼è¯»/ç¼å/å¾å å价为 0 æ¶åéå° Prompt å价计ç®ï¼é³é¢å价为 0 æ¶ä¸è®¡å
¥ææ¬ã"),style:{marginBottom:12}}),0===u.length?t.jsx(E,{title:p("å°æ æ¡£ä½"),description:p("ç¹å»ãæ°å¢æ¡£ãæãä¸é®å¯¼å
¥ãå¼å§é
ç½®")}):t.jsx("div",{style:{overflowX:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"var(--semi-color-fill-0)"},children:[t.jsx("th",{style:Ae,children:"#"}),t.jsx("th",{style:Ae,children:t.jsx(S,{content:p("è¾å
¥ token ä¸éï¼-1 表示æ éå¶ï¼å
åºæ¡£ï¼"),children:t.jsx("span",{children:"step_size"})})}),t.jsx("th",{style:Ae,children:t.jsx(S,{content:p("å step_size ä¸è¾åº token ä¸éï¼-1 表示æ éå¶"),children:t.jsx("span",{children:"completion_step_size"})})}),ze.map(e=>t.jsx("th",{style:Ae,children:t.jsx(S,{content:p(e.tip),children:t.jsx("span",{children:p(e.label)})})},e.key)),t.jsx("th",{style:{...Ae,width:40}})]})}),t.jsx("tbody",{children:u.map((e,s)=>t.jsxs("tr",{children:[t.jsx("td",{style:Ee,children:t.jsx(Se,{type:"tertiary",children:s+1})}),t.jsx("td",{style:Ee,children:t.jsx(I,{size:"small",step:1,precision:0,value:e.step_size,onChange:e=>_(s,{step_size:Number(e)}),style:{width:110}})}),t.jsx("td",{style:Ee,children:t.jsx(I,{size:"small",step:1,precision:0,value:e.completion_step_size,onChange:e=>_(s,{completion_step_size:Number(e)}),style:{width:130}})}),ze.map(l=>t.jsx("td",{style:Ee,children:t.jsx(I,{size:"small",min:0,step:1e-4,precision:4,innerButtons:!0,value:e[l.key]||0,onChange:e=>_(s,{[l.key]:Number(e)||0}),style:{width:110}})},l.key)),t.jsx("td",{style:Ee,children:t.jsx(T,{icon:t.jsx(ae,{size:12}),size:"small",type:"danger",theme:"borderless",onClick:()=>(e=>{x(t=>t.filter((t,s)=>s!==e))})(s)})})]},s))})]})})]})},Ae={padding:"6px 8px",textAlign:"left",borderBottom:"1px solid var(--semi-color-border)",fontWeight:600,whiteSpace:"nowrap"},Ee={padding:"6px 8px",borderBottom:"1px solid var(--semi-color-border)",verticalAlign:"middle"},Re=({channelId:s,models:c,isEdit:d,visible:h,onClose:m})=>{const{t:p}=l(),u=a(),[x,g]=e.useState([]),[y,_]=e.useState(!1),[f,j]=e.useState(!1),[v,b]=e.useState(!1),[w,B]=e.useState(!1),[$,M]=e.useState(null),[L,J]=e.useState(!1),[P,W]=e.useState(null),D=e.useCallback(async()=>{if(d&&s){_(!0);try{const e=await i.get(`/api/channel/${s}/model-costs`);e?.data?.success?g(function(e,t){const s=new Map;for(const l of e||[])s.set(l.model_name,{model_name:l.model_name,billing_type:l.billing_type||"token",cost_config:l.cost_config||{},dirty:!1});for(const l of t||[])s.has(l)||s.set(l,Te(l));return Array.from(s.values()).sort((e,t)=>e.model_name.localeCompare(t.model_name))}(e.data.data,c)):r(e?.data?.message||p("å è½½ææ¬é
置失败"))}catch(e){r(e?.message||p("å è½½ææ¬é
置失败"))}_(!1)}},[s,d,c,p]);e.useEffect(()=>{h&&d&&s&&D()},[h,d,s,c?.length]);const F=(e,t)=>{g(s=>s.map(s=>s.model_name===e?{...s,...t,cost_config:t.cost_config?{...s.cost_config,...t.cost_config}:s.cost_config,dirty:!0}:s))},V=e=>{const t=e.cost_config||{};return"free"===e.billing_type||("token"===e.billing_type?(t.input||0)>0||(t.output||0)>0||(t.cache_creation||0)>0||(t.cache_read||0)>0||(t.audio_input||0)>0||(t.audio_output||0)>0:"video_size"===e.billing_type?(t.input||0)>0||(t.output||0)>0:"step"===e.billing_type?(t.steps||[]).length>0:(t.unit_cost||0)>0)},K=x.some(e=>e.dirty),q=async(e,l)=>{if(d&&s){B(!0);try{const a={mode:e};"ratio"===e&&(a.ratio=l);const n=await i.post(`/api/channel/${s}/model-costs/suggest-batch`,a);if(n?.data?.success){const s=n.data.data||{},l="ratio"===e&&!L,{filled:a,skippedExisting:i}=((e,t)=>{const s=new Map(x.map(e=>[e.model_name,e])),l=new Map;let a=0;for(const i of e||[]){const e=s.get(i.model_name);e&&(t&&V(e)?a++:l.set(i.model_name,i))}return l.size>0&&g(e=>e.map(e=>{const t=l.get(e.model_name);return t?{...e,billing_type:t.billing_type||e.billing_type,cost_config:t.cost_config||{},dirty:!0}:e})),{filled:l.size,skippedExisting:a}})(s.items,l),r=s.mismatched||[],c=s.skipped||[];o(p("å·²åå¡« {{count}} ä¸ªæ¨¡åææ¬ï¼æªä¿åï¼è¯·æ ¸å¯¹åä¿åï¼",{count:a})),(r.length>0||i>0||c.length>0)&&N.info({title:p("èªå¨é
ç½®ç»æ"),content:t.jsxs("div",{style:{fontSize:13,lineHeight:1.6},children:[t.jsx("div",{children:p("å·²åå¡« {{count}} 个模åï¼è¯·æ ¸å¯¹åç¹ãä¿åå
¨é¨ææ¬é
ç½®ãã",{count:a})}),i>0&&t.jsx("div",{style:{marginTop:6},children:t.jsx(Se,{type:"tertiary",children:p("è·³è¿ {{count}} 个已é
ç½®ï¼æªè¦çï¼ãå¦ééå¡«å¯å¾éãè¦çå·²é
ç½®ãã",{count:i})})}),r.length>0&&t.jsxs("div",{style:{marginTop:10},children:[t.jsx(Se,{strong:!0,type:"warning",children:p("䏿¸¸ä»·ä¸ææ¹åç对ä¸é½ï¼å·²æä¸æ¸¸åå¡«ï¼è¯·éç¹æ ¸å¯¹ï¼ï¼")}),t.jsx("div",{style:{maxHeight:160,overflow:"auto",marginTop:4},children:r.map(e=>t.jsxs("div",{children:[e.model_name,"ï¼",p("ææ¹")," ",e.our_ratio," / ",p("䏿¸¸")," ",e.upstream_ratio,"ï¼"]},e.model_name))})]}),c.length>0&&t.jsxs("div",{style:{marginTop:10},children:[t.jsx(Se,{strong:!0,type:"tertiary",children:p("ratio"===e?"以䏿¨¡åææ¹æ å®ä»·ï¼æªå¡«å
ï¼è¯·æå¨é
ç½®ï¼ï¼":"æªèªå¨é
ç½®ï¼è¯·ç¨ãæåçå¡«å
ãææå¨ï¼ï¼")}),t.jsx("div",{style:{maxHeight:160,overflow:"auto",marginTop:4},children:c.join("ã")})]})]})})}else r(n?.data?.message||p("èªå¨é
置失败"))}catch(a){r(a?.message||p("èªå¨é
置失败"))}B(!1)}else r(p("请å
ä¿åæ¸ éåºç¡ä¿¡æ¯åé
ç½®ææ¬"))},U=(e,t)=>{if("free"===e)return{field:null,disabled:!0};if("token"===e){const e={input:"input",output:"output",cache_w:"cache_creation",cache_r:"cache_read",audio_in:"audio_input",audio_out:"audio_output"};return{field:e[t],disabled:!e[t]}}return"video_size"===e?"input"===t?{field:"input",disabled:!1}:"output"===t?{field:"output",disabled:!1}:{field:null,disabled:!0}:"input"===t?{field:"unit_cost",disabled:!1}:{field:null,disabled:!0}},H=e.useMemo(()=>[{title:p("模å"),dataIndex:"model_name",width:220,render:(e,s)=>{const l=!c?.includes(e),a=V(s);return t.jsxs("div",{style:{lineHeight:"20px"},children:[t.jsx(Se,{strong:!0,ellipsis:{showTooltip:!0},style:{maxWidth:180,display:"inline-block",fontSize:13},children:e}),!a&&t.jsx(k,{color:"red",size:"small",style:{marginLeft:4},children:p("æªé
")}),l&&t.jsx(S,{content:p("该模åä¸å¨æ¸ éå½å模åå表ï¼ä½æå岿æ¬é
ç½®"),children:t.jsx(k,{color:"orange",size:"small",style:{marginLeft:4},children:p("å¤å¿")})}),s.dirty&&!a&&t.jsx(k,{color:"blue",size:"small",style:{marginLeft:4},children:p("æ¹")})]})}},{title:p("ç±»å"),dataIndex:"billing_type",width:105,render:(e,s)=>t.jsx(C,{value:e,size:"small",optionList:Ce.map(e=>({value:e.value,label:p(e.label)})),onChange:e=>F(s.model_name,{billing_type:e}),style:{width:"100%"}})},{title:t.jsx(S,{content:p("token / æè§é¢å°ºå¯¸: input åä»·ï¼ææ¬¡/æç§/æåç´ : unit_costï¼é¶æ¢¯: ç¹å»è¿å
¥æ¡£ä½ç¼è¾"),children:t.jsx("span",{children:p("Input / åä»·")})}),dataIndex:"_input",width:130,render:(e,s)=>{if("step"===s.billing_type)return(e=>{const s=(e.cost_config?.steps||[]).length;return t.jsx(S,{content:p("ç¹å»ç¼è¾é¶æ¢¯æ¡£ä½"),children:t.jsx(k,{color:"orange",size:"small",onClick:()=>W({modelName:e.model_name,steps:e.cost_config?.steps||[]}),style:{cursor:"pointer"},children:p("é¶æ¢¯ Ã{{n}}",{n:s})})})})(s);if("free"===s.billing_type)return t.jsx(S,{content:p("ææ¬æä¸º 0ï¼ä»
ç»è®¡ç¨éï¼æ¯å©=ç¨æ·ä»ï¼"),children:t.jsx(k,{color:"green",size:"small",children:p("å
è´¹")})});const l=U(s.billing_type,"input");return t.jsx(Ie,{value:s.cost_config?.[l.field]||0,onChange:e=>F(s.model_name,{cost_config:{[l.field]:e}}),disabled:l.disabled})}},{title:p("Output"),dataIndex:"_output",width:130,render:(e,s)=>{const l=U(s.billing_type,"output");return l.disabled||"step"===s.billing_type?t.jsx(Se,{type:"quaternary",children:"â"}):t.jsx(Ie,{value:s.cost_config?.[l.field]||0,onChange:e=>F(s.model_name,{cost_config:{[l.field]:e}}),disabled:l.disabled})}},{title:t.jsx(S,{content:"cache_creation (cache write)",children:t.jsx("span",{children:p("ç¼å")})}
1),dataIndex:"_cache_w",width:120,render:(e,s)=>{const l=U(s.billing_type,"cache_w");return l.disabled||"step"===s.billing_type?t.jsx(Se,{type:"quaternary",children:"â"}):t.jsx(Ie,{value:s.cost_config?.[l.field]||0,onChange:e=>F(s.model_name,{cost_config:{[l.field]:e}}),disabled:l.disabled})}},{title:t.jsx(S,{content:"cache_read",children:t.jsx("span",{children:p("ç¼è¯»")})}),dataIndex:"_cache_r",width:120,render:(e,s)=>{const l=U(s.billing_type,"cache_r");return l.disabled||"step"===s.billing_type?t.jsx(Se,{type:"quaternary",children:"â"}):t.jsx(Ie,{value:s.cost_config?.[l.field]||0,onChange:e=>F(s.model_name,{cost_config:{[l.field]:e}}),disabled:l.disabled})}},{title:t.jsx(S,{content:p("é³é¢è¾å
¥ä»·æ ¼ï¼USD/1M tokensï¼ä¸å®ä»·ç«¯ AudioRatio åä¹ï¼æªå¡«åé³é¢ææ¬è®¡ 0ï¼"),children:t.jsx("span",{children:p("é³é¢è¾å
¥")})}),dataIndex:"_audio_in",width:120,render:(e,s)=>{const l=U(s.billing_type,"audio_in");return l.disabled||"step"===s.billing_type?t.jsx(Se,{type:"quaternary",children:"â"}):t.jsx(Ie,{value:s.cost_config?.[l.field]||0,onChange:e=>F(s.model_name,{cost_config:{[l.field]:e}}),disabled:l.disabled})}},{title:t.jsx(S,{content:p("é³é¢è¡¥å
¨ä»·æ ¼ï¼USD/1M tokensï¼ä¸å®ä»·ç«¯ AudioCompletionRatio åä¹ï¼æªå¡«åé³é¢è¡¥å
¨ææ¬æ output å价计ï¼"),children:t.jsx("span",{children:p("é³é¢è¡¥å
¨")})}),dataIndex:"_audio_out",width:120,render:(e,s)=>{const l=U(s.billing_type,"audio_out");return l.disabled||"step"===s.billing_type?t.jsx(Se,{type:"quaternary",children:"â"}):t.jsx(Ie,{value:s.cost_config?.[l.field]||0,onChange:e=>F(s.model_name,{cost_config:{[l.field]:e}}),disabled:l.disabled})}},{title:p("åä½"),dataIndex:"_unit",width:80,render:(e,s)=>t.jsx(k,{color:"grey",size:"small",children:Ne[s.billing_type]||"â"})}],[c,p]),G=x.filter(e=>!V(e)).length,Y=K&&G>0;return t.jsxs(N,{visible:h,onCancel:()=>{K?N.confirm({title:p("ææªä¿åçä¿®æ¹"),content:p("å
³éåä¿®æ¹å°ä¸¢å¤±ï¼æ¯å¦ç»§ç»ï¼"),onOk:m}):m?.()},title:t.jsxs("span",{children:[p("æ¨¡åææ¬é
ç½®"),G>0&&t.jsx(k,{color:"red",size:"small",style:{marginLeft:8},children:p("{{count}} 个æªé
",{count:G})})]}),width:u?"100%":960,fullScreen:u,closeOnEsc:!K,bodyStyle:{padding:u?"8px 12px":"12px 20px",overflow:u?"auto":void 0},footer:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:8},children:[t.jsxs(z,{wrap:!0,children:[t.jsx(O,{checked:v,onChange:e=>b(e.target.checked),children:p("åå°ä¿®æ£ï¼ä¸çåå²çæ¬ï¼")}),Y&&t.jsx(k,{color:"red",size:"small",children:p("æ {{count}} ä¸ªæ¨¡åæªé
ç½®ææ¬",{count:G})})]}),t.jsx(T,{icon:t.jsx(le,{size:16}),type:"primary",theme:"solid",onClick:async()=>{if(!d||!s)return void r(p("请å
ä¿åæ¸ éåºç¡ä¿¡æ¯åé
ç½®ææ¬"));const e=x.filter(e=>V(e)).map(e=>({model_name:e.model_name,billing_type:e.billing_type,cost_config:e.cost_config}));if(0!==e.length){j(!0);try{const t=await i.post(`/api/channel/${s}/model-costs`,{items:e,correct_in_place:v});t?.data?.success?(o(p("å·²ä¿å {{count}} æ¡ææ¬é
ç½®",{count:t.data.data?.saved??e.length})),D()):r(t?.data?.message||p("ä¿åææ¬é
置失败"))}catch(t){r(t?.message||p("ä¿åææ¬é
置失败"))}j(!1)}else n(p("没æå¯ä¿åçææ¬é
ç½®"))},loading:f,children:p("ä¿åå
¨é¨ææ¬é
ç½®")})]}),children:[t.jsx(Se,{type:"tertiary",style:{fontSize:12,display:"block",marginBottom:6},children:p('为æ¯ä¸ªæ¨¡åå½å
¥"æä»¬çç宿¿è´§ä»·"ï¼ä¸åä¸ç¨æ·æ£è´¹ï¼ä»
è®°å½å° cost_logs ç¨äºåå°å¯¹è´¦')}),t.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:8,flexWrap:"wrap",gap:8},children:[t.jsxs(z,{wrap:!0,children:[t.jsx(S,{content:p("ææ¬ = (䏿¸¸å¯¹ä¸é½æ¶å䏿¸¸ï¼å¦åææ¹) åç à 2 à æåºä»·æ ¼(å
弿±çÃåç»åç)ï¼ç¼å/è¾åºæææ¹åçå
³ç³»èªå¨æ¨ç®ãä»
token / é¶æ¢¯çæã"),children:t.jsx(T,{size:"small",type:"primary",theme:"solid",onClick:()=>{N.confirm({title:p("ä¸é®èªå¨é
ææ¬"),content:p("ä»
对 token / é¶æ¢¯ 模åæå
¬å¼åå¡«ææ¬ä»·ï¼ææ¬ = 䏿¸¸å¯¹ä¸é½æ¶å䏿¸¸å¦åææ¹ åç à 2 à æåºä»·æ ¼ï¼ç¼å/è¾åºæææ¹åçèªå¨æ¨ç®ï¼ãå
¶ä½æ¨¡å请ç¨ãæåçå¡«å
ãææå¨é
ç½®ãåå¡«ç»æå¯æå¨ä¿®æ¹ååä¿åã"),onOk:()=>q("auto")})},loading:w,disabled:!d,children:p("ä¸é®èªå¨é
ææ¬")})}),t.jsx(S,{content:p("ææ¬ä»· = æä»¬çä»·æ ¼ à æ¤åçï¼ä¾ï¼0.7 = æä»¬çä»·æ ¼ç 7 æï¼ãé»è®¤åªå¡«æªé
ç½®çæ¨¡åï¼ä¸è¦çå·²é
ï¼å¾éãè¦çå·²é
ç½®ãå¯å
¨è¡¨éå¡«ã"),children:t.jsx(I,{size:"small",min:0,step:.1,precision:4,placeholder:p("ææ¬åç"),value:$,onChange:M,disabled:!d,style:{width:120}})}),t.jsx(T,{size:"small",onClick:()=>{$>0?q("ratio",$):n(p("请å
å¡«åææ¬åçï¼éå¤§äº 0ï¼"))},loading:w,disabled:!d,children:p("æåçå¡«å
")}),t.jsx(S,{content:p("é»è®¤åªå¡«æªé
ç½®ï¼ç©ºç½ï¼ç模åï¼ä¸è¦çä¸é®èªå¨é
/å·²ä¿å/æå¡«çå¼ï¼å¾éåæåçéå¡«å
¨é¨æ¨¡åã"),children:t.jsx(O,{checked:L,onChange:e=>J(e.target.checked),disabled:!d,children:p("è¦çå·²é
ç½®")})})]}),t.jsx("div",{style:{flex:1}}),t.jsx(T,{icon:t.jsx(se,{size:12}),size:"small",type:"tertiary",onClick:D,loading:y,children:p("å·æ°")})]}),t.jsx(A,{spinning:y,children:u?x.length>0?t.jsx("div",{children:x.map(e=>{const s=e.cost_config||{},l=V(e),a=!c?.includes(e.model_name),i="token"===e.billing_type,r="video_size"===e.billing_type,n="step"===e.billing_type,o={min:0,step:1e-4,precision:4,size:"small",innerButtons:!0,style:{width:"100%"}};return t.jsxs("div",{style:{border:"1px solid var(--semi-color-border)",borderRadius:8,padding:12,marginBottom:8,background:e.dirty?"var(--semi-color-primary-light-default)":void 0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:4,marginBottom:8},children:[t.jsx(Se,{strong:!0,style:{fontSize:13,wordBreak:"break-all"},children:e.model_name}),!l&&t.jsx(k,{color:"red",size:"small",children:p("æªé
")}),a&&t.jsx(k,{color:"orange",size:"small",children:p("å¤å¿")}),e.dirty&&!l&&t.jsx(k,{color:"blue",size:"small",children:p("æ¹")})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[t.jsx(Se,{type:"tertiary",style:{fontSize:12,flexShrink:0},children:p("ç±»å")}),t.jsx(C,{value:e.billing_type,size:"small",optionList:Ce.map(e=>({value:e.value,label:p(e.label)})),onChange:t=>F(e.model_name,{billing_type:t}),style:{flex:1}}),t.jsx(k,{color:"grey",size:"small",children:Ne[e.billing_type]||"â"})]}),n?t.jsx(T,{size:"small",type:"tertiary",onClick:()=>W({modelName:e.model_name,steps:s.steps||[]}),style:{width:"100%"},children:p("ç¼è¾é¶æ¢¯ï¼Ã{{n}}ï¼",{n:(s.steps||[]).length})}):i?t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[t.jsxs("div",{children:[t.jsx(Se,{type:"tertiary",style:{fontSize:11},children:"Input"}),t.jsx(I,{...o,value:s.input||0,onChange:t=>F(e.model_name,{cost_config:{input:Number(t)||0}})})]}),t.jsxs("div",{children:[t.jsx(Se,{type:"tertiary",style:{fontSize:11},children:"Output"}),t.jsx(I,{...o,value:s.output||0,onChange:t=>F(e.model_name,{cost_config:{output:Number(t)||0}})})]}),t.jsxs("div",{children:[t.jsx(Se,{type:"tertiary",style:{fontSize:11},children:p("ç¼å")}),t.jsx(I,{...o,value:s.cache_creation||0,onChange:t=>F(e.model_name,{cost_config:{cache_creation:Number(t)||0}})})]}),t.jsxs("div",{children:[t.jsx(Se,{type:"tertiary",style:{fontSize:11},children:p("ç¼è¯»")}),t.jsx(I,{...o,value:s.cache_read||0,onChange:t=>F(e.model_name,{cost_config:{cache_read:Number(t)||0}})})]}),t.jsxs("div",{children:[t.jsx(Se,{type:"tertiary",style:{fontSize:11},children:p("é³é¢è¾å
¥")}),t.jsx(I,{...o,value:s.audio_input||0,onChange:t=>F(e.model_name,{cost_config:{audio_input:Number(t)||0}})})]}),t.jsxs("div",{children:[t.jsx(Se,{type:"tertiary",style:{fontSize:11},children:p("é³é¢è¡¥å
¨")}),t.jsx(I,{...o,value:s.audio_output||0,onChange:t=>F(e.model_name,{cost_config:{audio_output:Number(t)||0}})})]})]}):r?t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[t.jsxs("div",{children:[t.jsx(Se,{type:"tertiary",style:{fontSize:11},children:"Input"}),t.jsx(I,{...o,value:s.input||0,onChange:t=>F(e.model_name,{cost_config:{input:Number(t)||0}})})]}),t.jsxs("div",{children:[t.jsx(Se,{type:"tertiary",style:{fontSize:11},children:"Output"}),t.jsx(I,{...o,value:s.output||0,onChange:t=>F(e.model_name,{cost_config:{output:Number(t)||0}})})]})]}):t.jsxs("div",{children:[t.jsx(Se,{type:"tertiary",style:{fontSize:11},children:p("åä»·")}),t.jsx(I,{...o,value:s.unit_cost||0,onChange:t=>F(e.model_name,{cost_config:{unit_cost:Number(t)||0}})})]})]},e.model_name)})}):t.jsx(E,{title:p("ææ å¯é
置模å"),description:p('请å
å¨ä¸æ¹"模å"åºæ·»å 模å')}):t.jsx(R,{columns:H,dataSource:x,rowKey:"model_name",pagination:{pageSize:100,showSizeChanger:!0,pageSizeOpts:[50,100,200]},size:"small",bordered:!0,empty:t.jsx(E,{title:p("ææ å¯é
置模å"),description:p('请å
å¨ä¸æ¹"模å"åºæ·»å 模å')})})}),t.jsx(Oe,{visible:!!P,onClose:()=>W(null),channelId:s,modelName:P?.modelName,steps:P?.steps||[],onSave:e=>{P?.modelName&&F(P.modelName,{cost_config:{steps:e}})}})]})};Re.checkCostConfigured=async e=>{try{const t=await i.get(`/api/channel/${e}/model-costs`);if(!t?.data?.success)return{configured:!0,total:0,missing:0};const s=t.data.data||[],l=s.length,a=s.filter(e=>{const t=e.cost_config||{};return"token"===e.billing_type?(t.input||0)<=0&&(t.output||0)<=0&&(t.cache_creation||0)<=0&&(t.cache_read||0)<=0&&(t.audio_input||0)<=0&&(t.audio_output||0)<=0:"video_size"===e.billing_type?(t.input||0)<=0&&(t.output||0)<=0:"step"===e.billing_type?
10===(t.steps||[]).length:(t.unit_cost||0)<=0}).length;return{configured:0===a&&l>0,total:l,missing:a}}catch{return{configured:!0,total:0,missing:0}}};const{Text:Be,Title:$e}=w,Me={"gpt-3.5-turbo":"gpt-3.5-turbo-0125"},Le={"gpt-4o":"gpt-4o-2024-08-06","gpt-3.5-turbo":"gpt-3.5-turbo-0125","gpt-4o-mini":"gpt-4o-mini-2024-07-18","o1-mini":"o1-mini-2024-09-12","o1-preview":"o1-preview-2024-09-12","gpt-4-turbo":"gpt-4-turbo-2024-04-09"},Je={400:"500"},Pe={default:"us-central1","claude-3-5-sonnet-20240620":"europe-west1"},We={"gpt-4o-2024-11-20":60},De={prompt_filter_results:!0,"choices.0.content_filter_results":!0},Fe={ChannelRequestRateLimitEnabled:!0,ChannelRequestRateLimitDurationMinutes:1,ChannelRequestRateLimitCount:1e3,ChannelRequestRateLimitSuccessCount:1e3,ChannelRequestRateLimitFailureCount:1e3};function Ve(e){switch(e){case 15:return"æç
§å¦ä¸æ ¼å¼è¾å
¥ï¼APIKey|SecretKey";case 18:return"æç
§å¦ä¸æ ¼å¼è¾å
¥ï¼APPID|APISecret|APIKey";case 22:return"æç
§å¦ä¸æ ¼å¼è¾å
¥ï¼APIKey-AppIdï¼ä¾å¦ï¼fastgpt-0sp2gtvfdgyi4k30jwlgwf1i-64f335d84283f05518e9e041";case 23:return"æç
§å¦ä¸æ ¼å¼è¾å
¥ï¼AppId|SecretId|SecretKey";case 33:return"æç
§å¦ä¸æ ¼å¼è¾å
¥ï¼Ak|Sk|Region";case 50:case 101:return"æç
§å¦ä¸æ ¼å¼è¾å
¥: AccessKey|SecretKeyï¼å®æ¹APIï¼æ sk-xxxxxï¼ç¬¬ä¸æ¹ä»£çï¼";case 111:return"æç
§å¦ä¸æ ¼å¼è¾å
¥ï¼Token|Region";case 51:return"æç
§å¦ä¸æ ¼å¼è¾å
¥: Access Key ID|Secret Access Key";case 110:return"æç
§å¦ä¸æ ¼å¼è¾å
¥: SubAppId|SecretId|SecretKeyï¼å®æ¹APIï¼æ sk-xxxxxï¼ç¬¬ä¸æ¹ä»£çï¼";default:return"请è¾å
¥æ¸ é对åºçé´æå¯é¥"}}const Ke={touchAction:"pan-y",WebkitUserSelect:"none",userSelect:"none"},qe="edit-channel-select-dropdown",Ue={maxWidth:"calc(100vw - 32px)",boxSizing:"border-box"},He=x=>{const{t:g}=l();s();const y=x.editingChannel.id,_=void 0!==y,[f,j]=e.useState(!1),[b,w]=e.useState(!1),S=a(),[C,I]=e.useState(),E=e.useRef(null),R=e.useMemo(()=>{if(S)return{...Ue,...C?{width:C,minWidth:C}:{}}},[C,S]),V=e=>{S&&(E.current&&cancelAnimationFrame(E.current),e&&(E.current=requestAnimationFrame(()=>{const e=document.querySelector(".semi-select-open"),t=Math.floor(e?.getBoundingClientRect().width||0);t>0&&I(e=>e===t?e:t),E.current=null})))},K=()=>{x.handleClose()},q={name:"",type:1,key:"",openai_organization:"",max_input_tokens:0,base_url:"",other:"",model_mapping:"",return_model_mapping:"",model_timeout_mapping:"",status_code_mapping:"",models:[],auto_ban:!0,failure_timeout_ban_limit:50,test_model:"",test_prompt:"",test_path:"",groups:["default"],priority:0,weight:0,tag:"",price:1,recharge_price:1,group_ratio:1,setting:"",param_override:"",header_override:"",multi_key_mode:"random",force_format:!1,thinking_to_content:!1,proxy:"",pass_through_body_enabled:!1,system_prompt:"",system_prompt_override:!1,filter_fields:"",retry_on_content_filter:!1,channel_rate_limit:"",trust_upstream_token:!0,claude_beta_filters:"",bedrock_compat:!1,vertex_key_type:"json",allow_service_tier:!1,disable_store:!1,settings:""},[U,H]=e.useState(!1),[G,Y]=e.useState(!1),[Z,X]=e.useState("random"),[Q,ee]=e.useState(!0),[te,se]=e.useState(q),[ae,ie]=e.useState([]),[re,ue]=e.useState([]),[xe,ge]=e.useState([]),[ye,_e]=e.useState([]),[fe,je]=e.useState([]),[ve,be]=e.useState(""),[we,ke]=e.useState(""),[Se,Ce]=e.useState(!1),Ne=e.useRef(null),[ze,Te]=e.useState([]),[Ie,Oe]=e.useState([]),Ae=e.useRef(new Set),[Ee,He]=e.useState(!1),[Ge,Ye]=e.useState(""),[Ze,Xe]=e.useState(!1),Qe=e.useRef(0),et=e.useRef(x.visible),tt=e.useRef(y);et.current=x.visible,tt.current=y;const st=()=>({...q}),lt=e=>{se(e),Ne.current?.setValues(e)},at=()=>
1{Xe(!1),Te([]),Oe([]),Ae.current.clear(),He(!1),H(!1),Y(!1),X("random")};e.useEffect(()=>()=>{E.current&&cancelAnimationFrame(E.current)},[]);const it=(e,t)=>{Ne.current&&Ne.current.setValue(e,t),se(s=>({...s,[e]:t}))},rt=(e,t)=>{Ne.current&&Ne.current.setValue(e,t),se(s=>({...s,[e]:t}));let s={};if(te.settings)try{s=JSON.parse(te.settings)}catch(a){console.error("è§£æè®¾ç½®å¤±è´¥:",a)}s[e]=t;const l=JSON.stringify(s);ot("settings",l)},nt=e=>{Ne.current&&(Ne.current.setValue("type",e),Ne.current.setValue("other","")),se(t=>({...t,type:e,other:""}));let t=[];switch(e){case 2:t=["mj_imagine","mj_variation","mj_reroll","mj_blend","mj_upscale","mj_describe","mj_uploads"];break;case 5:t=["swap_face","mj_imagine","mj_video","mj_edits","mj_variation","mj_reroll","mj_blend","mj_upscale","mj_describe","mj_zoom","mj_shorten","mj_modal","mj_inpaint","mj_custom_zoom","mj_high_variation","mj_low_variation","mj_pan","mj_uploads"];break;case 36:t=["suno_music","suno_music_open","suno_lyrics"];break;default:t=h(e)}0===te.models.length&&(Ne.current?.setValue("models",t),se(e=>({...e,models:t}))),_e(t),Xe(!1)},ot=(e,t)=>{if("type"===e){const e=void 0!==te.other&&null!==te.other&&""!==String(te.other).trim();return t!==te.type&&e?void N.confirm({title:g("è¦å"),content:g("åæ¢æ¸ éç±»å伿¸
空å½å已填åçé¢å¤åæ°ï¼é¨ç½²å°åº/模åçæ¬/ç¥è¯åºID/Account ID çï¼ä¸åç±»åä¸å«ä¹ä¸åï¼ï¼æ¯å¦ç»§ç»ï¼"),onOk:()=>nt(t),onCancel:()=>{Ne.current&&Ne.current.setValue("type",te.type)}}):void nt(t)}Ne.current&&Ne.current.setValue(e,t),"models"===e&&Array.isArray(t)&&(t=Array.from(new Set(t.map(e=>(e||"").trim())))),"base_url"===e&&t.endsWith("/v1")?N.confirm({title:g("è¦å"),content:"ä¸éè¦å¨æ«å°¾å /v1ï¼New APIä¼èªå¨å¤çï¼æ·»å åå¯è½å¯¼è´è¯·æ±å¤±è´¥ï¼æ¯å¦ç»§ç»ï¼",onOk:()=>{se(s=>({...s,[e]:t}))}}):se(s=>({...s,[e]:t}))};e.useEffect(()=>{const e=new Map;ae.forEach(t=>{const s=(t.value||"").trim();e.has(s)||e.set(s,t)}),te.models.forEach(t=>{const s=(t||"").trim();e.has(s)||e.set(s,{key:s,label:s,value:s})});const s=c(g),l=Array.from(e.values()).map(e=>{const l=e.value;let a=null;for(const[t,i]of Object.entries(s))if("all"!==t&&i.filter({model_name:l})){a=i.icon;break}return{...e,label:t.jsxs("span",{className:"flex items-center gap-1",children:[a,l]})}});ue(l)},[ae,te.models,g]),e.useEffect(()=>{(async()=>{try{let e=await i.get("/api/channel/models");const t=e.data.data.map(e=>{const t=(e.id||"").trim();return{key:t,label:t,value:t}});ie(t),je(e.data.data.map(e=>e.id)),_e(e.data.data.filter(e=>e.id.startsWith("gpt-")||e.id.startsWith("text-")).map(e=>e.id))}catch(e){r(e.message)}})().then(),(async()=>{try{let e=await i.get("/api/group/");if(void 0===e)return;const t=e.data.data;if(t&&t.groups){const{groups:e,ratios:s={},descriptions:l={}}=t;ge(e.map(e=>({label:e,value:e,ratio:s[e]||1,description:l[e]||""})))}else Array.isArray(t)&&ge(t.map(e=>({label:e,value:e,ratio:1,description:""})))}catch(e){r(e.message)}})().then()},[]),e.useEffect(()=>{x.visible?_?(at(),ee(q.auto_ban),j(!0),lt(st()),(async()=>{const e=++Qe.current,t=y;j(!0);try{let l=await i.get(`/api/channel/${t}`);if(e!==Qe.current||!et.current||tt.current!==t)return;if(void 0===l)return;const{success:a,message:n,data:o}=l.data;if(a){if(""===o.models?o.models=[]:o.models=o.models.split(","),""===o.group?o.groups=[]:o.groups=o.group.split(","),""!==o.model_mapping&&(o.model_mapping=JSON.stringify(JSON.parse(o.model_mapping),null,2)),""!==o.return_model_mapping&&(o.return_model_mapping=JSON.stringify(JSON.parse(o.return_model_mapping),null,2)),""!==o.model_timeout_mapping&&(o.model_timeout_mapping=JSON.stringify(JSON.parse(o.model_timeout_mapping),null,2)),o.param_override&&""!==o.param_override)try{o.param_override=JSON.stringify(JSON.parse(o.param_override),null,2)}catch(s){console.error("è§£æåæ°è¦ç失败:",s),o.param_override=""}if(o.header_override&&""!==o.header_override)try{o.header_override=JSON.stringify(JSON.parse(o.header_override),null,2)}catch(s){console.error("è§£æè¯·æ±å¤´è¦ç失败:",s),o.header_override=""}if(""!==o.setting)try{const e=JSON.parse(o.setting);o.force_format=e.force_format||!1,o.thinking_to_content=e.thinking_to_content||!1,o.proxy=e.proxy||"",o.pass_through_body_enabled=e.pass_through_body_enabled||!1,o.system_prompt=e.system_prompt||"",o.system_prompt_override=e.system_prompt_override||!1,o.filter_fields=e.filter_fields?JSON.stringify(e.filter_fields,null,2):"",o.retry_on_content_filter=e.retry_on_content_filter||!1,o.channel_rate_limit=e.channel_rate_limit?JSON.stringify(e.channel_rate_limit,null,2):"",o.trust_upstream_token=!1!==e.trust_upstream_token,o.claude_beta_filters=e.claude_beta_filters?e.claude_beta_filters.join(","):"",o.bedrock_compat=e.bedrock_compat||!1,o.test_prompt=e.test_prompt||"",o.test_path=e.test_path||""}catch(s){console.error("è§£ææ¸ éé¢å¤è®¾ç½®å¤±è´¥:",s),o.force_format=!1,o.thinking_to_content=!1,o.proxy="",o.pass_through_body_enabled=!1}if(o.settings)try{const e=JSON.parse(o.settings);o.vertex_key_type=e.vertex_key_type||"json",o.allow_service_tier=e.allow_service_tier||!1,o.disable_store=e.disable_store||!1}catch(s){console.error("è§£æå
¶ä»è®¾ç½®å¤±è´¥:",s),o.vertex_key_type="json",o.allow_service_tier=!1,o.disable_store=!1}else o.vertex_key_type="json",o.allow_service_tier=!1,o.disable_store=!1;const e=o.channel_info||{},t=!0===e.is_multi_key;if(He(t),t){H(!0),Y(!0);const t=e.multi_key_mode||"random";X(t),o.multi_key_mode=t}else H(!1),Y(!1);const l={...o,auto_ban:0!==o.auto_ban};lt(l),ee(l.auto_ban),_e(h(l.type))}else r(n)}catch(s){if(e!==Qe.current||!et.current||tt.current!==t)return;console.error("å è½½æ¸ é详æ
失败:",s),s?.isAxiosError||r(g("å è½½æ¸ é详æ
失败"))}finally{e===Qe.current&&j(!1)}})()):(()=>{at();const e=st(),t=h(e.type);e.models=t,_e(t),ee(e.auto_ban),lt(e),j(!1)})():(at(),ee(q.auto_ban),_e(h(q.type)),j(!1),se(st()),Ne.current?.reset())},[x.visible,_,y]),e.useEffect(()=>{x.visible&&Ne.current&&void 0!==te.other&&te.other!==Ne.current.getValue("other")&&Ne.current.setValue("other",te.other)},[te.type,te.other,x.visible]),e.useEffect(()=>{if(!x.visible)return;const e=[document.body,document.getElementById("app-outer-layout"),document.getElementById("main-content")].filter(
1Boolean).map(e=>({element:e,overflow:e.style.overflow,overflowY:e.style.overflowY,overscrollBehavior:e.style.overscrollBehavior}));e.forEach(({element:e})=>{e.style.overflow="hidden",e.style.overflowY="hidden",e.style.overscrollBehavior="none"});const t=e=>{const t=e.target;t instanceof Element&&(t.closest(".semi-sidesheet-mask:not(.semi-sidesheet-mask-hidden)")||t.closest(`.${qe}`)&&!t.closest(".semi-select-option-list"))&&e.preventDefault()},s=e=>{const t=e.target;if(!(t instanceof Element))return;const s=document.querySelector(`.${qe}`),l=document.querySelector(".semi-select-open");s&&l&&!s.contains(t)&&!l.contains(t)&&t.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window}))};return document.addEventListener("wheel",t,{passive:!1,capture:!0}),document.addEventListener("touchmove",t,{passive:!1,capture:!0}),document.addEventListener("touchstart",s,{passive:!0,capture:!0}),()=>{document.removeEventListener("wheel",t,!0),document.removeEventListener("touchmove",t,!0),document.removeEventListener("touchstart",s,!0),e.forEach(({element:e,overflow:t,overflowY:s,overscrollBehavior:l})=>{e.style.overflow=t,e.style.overflowY=s,e.style.overscrollBehavior=l})}},[x.visible]);const ct=({fileList:e})=>{Ae.current.clear(),(async()=>{let t=[],s=[];const l=[];for(const i of e){const e=i.fileInstance;if(e)try{const l=await e.text();s.push(JSON.parse(l)),t.push(i)}catch(a){Ae.current.has(i.name)||(l.push(i.name),Ae.current.add(i.name))}}!U&&t.length>1&&(t=[t[t.length-1]],s=[s[s.length-1]]),Te(s),Oe(t),Ne.current&&Ne.current.setValue("vertex_files",t),se(e=>({...e,vertex_files:t})),l.length>0&&r(g("ä»¥ä¸æä»¶è§£æå¤±è´¥ï¼å·²å¿½ç¥ï¼{{list}}",{list:l.join(", ")}))})()},dt=()=>{if(""===ve.trim())return;const e=ve.split(",").map(e=>e.trim());let t=[...te.models],s=[...re];const l=[];e.forEach(e=>{e&&!t.includes(e)&&(t.push(e),s.push({key:e,label:e,value:e}),l.push(e))}),ue(s),be(""),ot("models",t),l.length>0?o(g("å·²æ°å¢ {{count}} 个模åï¼{{list}}",{count:l.length,list:l.join(", ")})):n(g("æªåç°æ°å¢æ¨¡å"))},ht=!_||Ee?t.jsxs(z,{children:[!_&&t.jsx(O,{disabled:_,checked:U,onChange:e=>{const t=e.target.checked;!t&&Ie.length>1?N.confirm({title:g("åæ¢ä¸ºåå¯é¥æ¨¡å¼"),content:g("å°ä»
ä¿ç第ä¸ä¸ªå¯é¥æä»¶ï¼å
¶ä½æä»¶å°è¢«ç§»é¤ï¼æ¯å¦ç»§ç»ï¼"),onOk:()=>{const e=Ie[0],t=ze[0]?[ze[0]]:[];Oe([e]),Te(t),Ne.current?.setValue("vertex_files",[e]),se(t=>({...t,vertex_files:[e]})),H(!1),Y(!1),X("random")},onCancel:()=>{H(!0)},centered:!0}):(H(t),t?(Xe(!1),41===te.type&&(Ne.current&&Ne.current.setValue("key",""),ot("key",""))):(Y(!1),X("random")))},children:g("æ¹éå建")}),U&&t.jsxs(t.Fragment,{children:[t.jsx(O,{disabled:_,checked:G,onChange:()=>{Y(e=>{const t=!e;return Ne.current?.setValue("multi_key_mode",t?Z:void 0),se(e=>{const s={...e};return t?s.multi_key_mode=Z:delete s.multi_key_mode,s}),t})},children:g("å¯é¥è忍¡å¼")}),41!==te.type&&t.jsx(T,{size:"small",type:"tertiary",theme:"outline",onClick:()=>{const e=Ne.current?.getValue("key")||te.key||"";if(!e.trim())return void n(g("请å
è¾å
¥å¯é¥"));const t=e.split("\n"),s=t.length,l=new Set,a=[];t.forEach(e=>{const t=e.trim();t&&!l.has(t)&&(l.add(t),a.push(t))});const i=a.length,r=a.join("\n");Ne.current&&Ne.current.setValue("key",r),ot("key",r);const c=g("å»é宿ï¼å»éå {{before}} 个å¯é¥ï¼å»éå {{after}} 个å¯é¥",{before:s,after:i});s===i?n(g("æªåç°éå¤å¯é¥")):o(c)},style:{textDecoration:"underline"},children:g("å¯é¥å»é")})]})]}):null,mt=e.useMemo(()=>v.map(e=>({...e,label:e.label})),[]),pt=e=>{const{disabled:s,selected:l,label:a,value:i,focused:r,className:n,style:o,onMouseEnter:c,onClick:d,...h}=e,m=Ge?[Ge]:[],p=["flex items-center gap-3 px-3 py-2 transition-all duration-200 rounded-lg mx-2 my-1",r&&"bg-blue-50 shadow-sm",l&&"bg-blue-100 text-blue-700 shadow-lg ring-2 ring-blue-200 ring-opacity-50",s&&"opacity-50 cursor-not-allowed",!s&&"hover:bg-gray-50 hover:shadow-md cursor-pointer",n].filter(Boolean).join(" ");return t.jsx("div",{style:{...o,...Ke},className:p,onClick:()=>!s&&d(),onPointerEnter:e=>{"touch"!==e.pointerType&&c()},children:t.jsxs("div",{className:"flex items-center gap-3 w-full",children:[t.jsx("div",{className:"flex-shrink-0 w-5 h-5 flex items-center justify-center",children:u(i)}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx(F,{sourceString:a,searchWords:m,className:"text-sm font-medium truncate"})}),l&&t.jsx("div",{className:"flex-shrink-0 text-blue-600",children:t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})})})]})})};return t.jsx(t.Fragment,{children:t.jsxs(B,{placement:_?"right":"left",title:t.jsxs(z,{children:[t.jsx(k,{color:"blue",shape:"circle",children:g(_?"ç¼è¾":"æ°å»º")}),t.jsx($e,{heading:4,className:"m-0",children:g(_?"æ´æ°æ¸ éä¿¡æ¯":"å建æ°çæ¸ é")})]}),bodyStyle:{padding:"0"},maskStyle:{touchAction:"none",overscrollBehavior:"none"},visible:x.visible,width:S?"100%":600,footer:t.jsx("div",{className:"flex justify-end bg-white",children:t.jsxs(z,{children:[t.jsx(T,{theme:"solid",onClick:()=>
1Ne.current?.submitForm(),icon:t.jsx(le,{size:16}),children:g("æäº¤")}),t.jsx(T,{theme:"light",type:"primary",onClick:K,icon:t.jsx(pe,{size:16}),children:g("åæ¶")})]})}),closeIcon:null,onCancel:()=>K(),children:[t.jsx(M,{initValues:q,getFormApi:e=>Ne.current=e,onSubmit:async()=>{let e={...Ne.current?Ne.current.getValues():{}};if(41===e.type)if("api_key"===(e.vertex_key_type||"json")){if(!(_||e.key&&""!==e.key.trim()))return void n(g("请è¾å
¥å¯é¥")+"ï¼")}else if(Ze){if(e.key&&""!==e.key.trim())try{const t=JSON.parse(e.key);e.key=JSON.stringify(t)}catch(h){return void r(g("å¯é¥æ ¼å¼æ æï¼è¯·è¾å
¥ææç JSON æ ¼å¼å¯é¥"))}else if(!_)return void n(g("请è¾å
¥å¯é¥")+"ï¼")}else{let t=ze;if(0===t.length&&Ie.length>0)try{t=(await Promise.all(Ie.map(async e=>{const t=e.fileInstance;if(!t)return null;const s=await t.text();return JSON.parse(s)}))).filter(Boolean)}catch(h){return void r(g("è§£æå¯é¥æä»¶å¤±è´¥: {{msg}}",{msg:h.message}))}if(0===t.length){if(!_)return void n(g("请ä¸ä¼ å¯é¥æä»¶")+"ï¼");delete e.key}else e.key=U?JSON.stringify(t):JSON.stringify(t[0])}if(!_||e.key&&""!==e.key.trim()||delete e.key,delete e.vertex_files,!(_||e.name&&e.key))return void n(g("è¯·å¡«åæ¸ éåç§°åæ¸ éå¯é¥ï¼"));if(!Array.isArray(e.models)||0===e.models.length)return void n(g("请è³å°éæ©ä¸ä¸ªæ¨¡å")+"ï¼");if(_&&y){const e=await Re.checkCostConfigured(y);e.configured||m(g("æç¤ºï¼è¿æ {{count}} ä¸ªæ¨¡åæªé
ç½®ææ¬ï¼å¯¹è´¦æ°æ®ä¼ç¼ºå¤±ï¼å»ºè®®å°½å¿«è¡¥å
¨",{count:e.missing||e.total||"é¨å"}))}if(e.model_mapping&&""!==e.model_mapping&&!p(e.model_mapping))return void n(g("æ¨¡åæ å°å¿
é¡»æ¯åæ³ç JSON æ ¼å¼ï¼"));if(e.return_model_mapping&&""!==e.return_model_mapping&&!p(e.return_model_mapping))return void n(g("è¿å模åéå®åå¿
é¡»æ¯åæ³ç JSON æ ¼å¼ï¼"));if(e.model_timeout_mapping&&""!==e.model_timeout_mapping&&!p(e.model_timeout_mapping))return void n(g("模åè¶
æ¶éå¶å¿
é¡»æ¯åæ³ç JSON æ ¼å¼ï¼"));if(e.param_override&&""!==e.param_override&&!p(e.param_override))return void n(g("åæ°è¦çå¿
é¡»æ¯åæ³ç JSON æ ¼å¼ï¼"));if(e.header_override&&""!==e.header_override&&!p(e.header_override))return void n(g("请æ±å¤´è¦çå¿
é¡»æ¯åæ³ç JSON æ ¼å¼ï¼"));const t={force_format:e.force_format||!1,thinking_to_content:e.thinking_to_content||!1,proxy:e.proxy||"",pass_through_body_enabled:e.pass_through_body_enabled||!1,system_prompt:e.system_prompt||"",system_prompt_override:e.system_prompt_override||!1};if(e.filter_fields&&""!==e.filter_fields.trim())try{t.filter_fields=JSON.parse(e.filter_fields)}catch(u){return void n(g("è¿æ»¤å段设置å¿
é¡»æ¯åæ³ç JSON æ ¼å¼ï¼"))}if(e.retry_on_content_filter&&(t.retry_on_content_filter=!0),e.channel_rate_limit&&""!==e.channel_rate_limit.trim())try{t.channel_rate_limit=JSON.parse(e.channel_rate_limit)}catch(u){return void n(g("æ¸ ééæµè®¾ç½®å¿
é¡»æ¯åæ³ç JSON æ ¼å¼ï¼"))}let s;!1===e.trust_upstream_token&&(t.trust_upstream_token=!1),e.claude_beta_filters&&""!==e.claude_beta_filters.trim()&&(t.claude_beta_filters=e.claude_beta_filters.split(",").map(e=>e.trim()).filter(e=>e)),e.bedrock_compat&&(t.bedrock_compat=!0),e.test_prompt&&""!==e.test_prompt.trim()&&(t.test_prompt=e.test_prompt.trim()),e.test_path&&""!==e.test_path.trim()&&(t.test_path=e.test_path.trim()),e.setting=JSON.stringify(t),delete e.vertex_key_type,delete e.allow_service_tier,delete e.disable_store,e.base_url&&e.base_url.endsWith("/")&&(e.base_url=e.base_url.slice(0,e.base_url.length-1)),18===e.type&&""===e.other&&(e.other="v2.1"),e.auto_ban=e.auto_ban?1:0,e.failure_timeout_ban_limit=e.failure_timeout_ban_limit||50,e.models=e.models.join(","),e.group=(e.groups||[]).join(",");let l="single";U&&(l=G?"multi_to_single":"batch"),s=_?await i.put("/api/channel/",{...e,id:parseInt(y)}):await i.post("/api/channel/",{mode:l,multi_key_mode:"multi_to_single"===l?Z:void 0,channel:e});const{success:a,message:c,data:d}=s.data;a?(_?d&&d.price_changed?o(g(`ä»·æ ¼åå¨ï¼åæ¸ é #${d.old_channel_id} 已彿¡£ï¼æ°æ¸ é #${d.new_channel_id} å·²å建`)):o(g("æ¸ éæ´æ°æåï¼")):o(g("æ¸ éå建æåï¼")),x.refresh(),x.handleClose()):r(c)},children:()=>t.jsx(A,{spinning:f,children:t.jsxs("div",{className:"p-2",children:[t.jsxs(L,{className:"!rounded-2xl shadow-sm border-0 mb-6",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx(J,{size:14,color:"blue",className:"mr-2 shadow-md",children:t.jsx(ne,{size:16})}),t.jsxs("div",{children:[t.jsx(Be,{className:"text-lg font-medium",children:g("åºæ¬ä¿¡æ¯")}),t.jsx("div",{className:"text-xs text-gray-600",children:g("æ¸ éçåºæ¬é
置信æ¯")})]})]}),t.jsx(M.Select,{field:"type",label:g("ç±»å"),placeholder:g("è¯·éæ©æ¸ éç±»å"),rules:[{required:!0,message:g("è¯·éæ©æ¸ éç±»å")}],dropdownClassName:qe,dropdownMatchSelectWidth:!0,dropdownStyle:R,autoAdjustOverflow:!0,onDropdownVisibleChange:V,optionList:mt,style:{width:"100%"},filter:!0,searchPosition:"dropdown",onSearch:e=>Ye(e),renderOptionItem:pt,onChange:e=>ot("type",e)}),t.jsx(M.Input,{field:"name",label:g("åç§°"),placeholder:g("è¯·ä¸ºæ¸ éå½å"),rules:[{required:!0,message:g("è¯·ä¸ºæ¸ éå½å")}],showClear:!0,onChange:e=>ot("name",e),autoComplete:"new-password"}),41===te.type&&t.jsx(M.Select,{field:"vertex_key_type",label:g("å¯é¥æ ¼å¼"),placeholder:g("è¯·éæ©å¯é¥æ ¼å¼"),dropdownClassName:qe,dropdownMatchSelectWidth:!0,dropdownStyle:R,autoAdjustOverflow:!0,onDropdownVisibleChange:V,optionList:[{label:"JSON",value:"json"},{label:"API Key",value:"api_key"}],style:{width:"100%"},value:te.vertex_key_type||"json",onChange:e=>
1{rt("vertex_key_type",e),"api_key"===e&&(H(!1),Xe(!1),Te([]),Oe([]),Ne.current&&Ne.current.setValue("vertex_files",[]),se(e=>({...e,vertex_files:[]})))},extraText:"api_key"===te.vertex_key_type?g("API Key 模å¼ä¸ä¸æ¯ææ¹éå建"):g("JSON æ¨¡å¼æ¯ææå¨è¾å
¥æä¸ä¼ æå¡è´¦å· JSON")}),U?41===te.type&&"json"===(te.vertex_key_type||"json")?t.jsx(M.Upload,{field:"vertex_files",label:g("å¯é¥æä»¶ (.json)"),accept:".json",multiple:!0,draggable:!0,dragIcon:t.jsx(oe,{size:16}),dragMainText:g("ç¹å»ä¸ä¼ æä»¶æææ½æä»¶å°è¿é"),dragSubText:g("ä»
æ¯æ JSON æä»¶ï¼æ¯æå¤æä»¶"),style:{marginTop:10},uploadTrigger:"custom",beforeUpload:()=>!1,onChange:ct,fileList:Ie,rules:_?[]:[{required:!0,message:g("请ä¸ä¼ å¯é¥æä»¶")}],extraText:ht}):t.jsx(M.TextArea,{field:"key",label:g("å¯é¥"),placeholder:g("请è¾å
¥å¯é¥ï¼ä¸è¡ä¸ä¸ª"),rules:_?[]:[{required:!0,message:g("请è¾å
¥å¯é¥")}],autosize:!0,autoComplete:"new-password",onChange:e=>ot("key",e),extraText:ht,showClear:!0}):t.jsx(t.Fragment,{children:41===te.type&&"json"===(te.vertex_key_type||"json")?t.jsxs(t.Fragment,{children:[!U&&t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx(Be,{className:"text-sm font-medium",children:g("å¯é¥è¾å
¥æ¹å¼")}),t.jsxs(z,{children:[t.jsx(T,{size:"small",type:Ze?"tertiary":"primary",onClick:()=>{Xe(!1),Ne.current&&Ne.current.setValue("key",""),ot("key","")},children:g("æä»¶ä¸ä¼ ")}),t.jsx(T,{size:"small",type:Ze?"primary":"tertiary",onClick:()=>
1{Xe(!0),Te([]),Oe([]),Ne.current&&Ne.current.setValue("vertex_files",[]),se(e=>({...e,vertex_files:[]}))},children:g("æå¨è¾å
¥")})]})]}),U&&t.jsx($,{type:"info",description:g("æ¹éå建模å¼ä¸ä»
æ¯ææä»¶ä¸ä¼ ï¼ä¸æ¯ææå¨è¾å
¥"),className:"!rounded-lg mb-3"}),Ze&&!U?t.jsx(M.TextArea,{field:"key",label:g(_?"å¯é¥ï¼ç¼è¾æ¨¡å¼ä¸ï¼ä¿åçå¯é¥ä¸ä¼æ¾ç¤ºï¼":"å¯é¥"),placeholder:g("channel_placeholder_005"),rules:_?[]:[{required:!0,message:g("请è¾å
¥å¯é¥")}],autoComplete:"new-password",onChange:e=>ot("key",e),extraText:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Be,{type:"tertiary",size:"small",children:g("请è¾å
¥å®æ´ç JSON æ ¼å¼å¯é¥å
容")}),ht]}),autosize:!0,showClear:!0}):t.jsx(M.Upload,{field:"vertex_files",label:g("å¯é¥æä»¶ (.json)"),accept:".json",draggable:!0,dragIcon:t.jsx(oe,{size:16}),dragMainText:g("ç¹å»ä¸ä¼ æä»¶æææ½æä»¶å°è¿é"),dragSubText:g("ä»
æ¯æ JSON æä»¶"),style:{marginTop:10},uploadTrigger:"custom",beforeUpload:()=>!1,onChange:ct,fileList:Ie,rules:_?[]:[{required:!0,message:g("请ä¸ä¼ å¯é¥æä»¶")}],extraText:ht})]}):t.jsx(M.Input,{field:"key",label:g(_?"å¯é¥ï¼ç¼è¾æ¨¡å¼ä¸ï¼ä¿åçå¯é¥ä¸ä¼æ¾ç¤ºï¼":"å¯é¥"),placeholder:g(Ve(te.type)),rules:_?[]:[{required:!0,message:g("请è¾å
¥å¯é¥")}],autoComplete:"new-password",onChange:e=>ot("key",e),extraText:ht,showClear:!0})}),U&&G&&t.jsxs(t.Fragment,{children:[t.jsx(M.Select,{field:"multi_key_mode",label:g("å¯é¥è忍¡å¼"),placeholder:g("è¯·éæ©å¤å¯é¥ä½¿ç¨çç¥"),dropdownClassName:qe,dropdownMatchSelectWidth:!0,dropdownStyle:R,autoAdjustOverflow:!0,onDropdownVisibleChange:V,optionList:[{label:g("éæº"),value:"random"},{label:g("轮询"),value:"polling"}],style:{width:"100%"},value:te.multi_key_mode||"random",onChange:e=>{X(e),ot("multi_key_mode",e)}}),"polling"===te.multi_key_mode&&t.jsx($,{type:"warning",description:g("轮询模å¼å¿
é¡»æé
Redisåå
åç¼ååè½ä½¿ç¨ï¼å¦åæ§è½å°å¤§å¹
éä½ï¼å¹¶ä¸æ æ³å®ç°è½®è¯¢åè½"),className:"!rounded-lg mt-2"})]}),18===te.type&&t.jsx(M.Input,{field:"other",label:g("模åçæ¬"),placeholder:"请è¾å
¥æç«å¤§æ¨¡åçæ¬ï¼æ³¨ææ¯æ¥å£å°åä¸ççæ¬å·ï¼ä¾å¦ï¼v2.1",onChange:e=>ot("other",e),showClear:!0}),41===te.type&&t.jsx(M.TextArea,{field:"other",label:g("é¨ç½²å°åº"),placeholder:g("channel_placeholder_006"),autosize:!0,onChange:e=>ot("other",e),rules:[{required:!0,message:g("请填åé¨ç½²å°åº")}],extraText:t.jsx(Be,{className:"!text-primary cursor-pointer",onClick:()=>ot("other",JSON.stringify(Pe,null,2)),children:g("å¡«å
¥æ¨¡æ¿")}),showClear:!0}),21===te.type&&t.jsx(M.Input,{field:"other",label:g("ç¥è¯åº ID"),placeholder:"请è¾å
¥ç¥è¯åº IDï¼ä¾å¦ï¼123456",onChange:e=>ot("other",e),showClear:!0}),39===te.type&&t.jsx(M.Input,{field:"other",label:"Account ID",placeholder:"请è¾å
¥Account IDï¼ä¾å¦ï¼d6b5da8hk1awo8nap34ube6gh",onChange:e=>ot("other",e),showClear:!0}),49===te.type&&t.jsx(M.Input,{field:"other",label:g("æºè½ä½ID"),placeholder:"请è¾å
¥æºè½ä½IDï¼ä¾å¦ï¼7342866812345",onChange:e=>ot("other",e),showClear:!0}),1===te.type&&t.jsx(M.Input,{field:"openai_organization",label:g("ç»ç»"),placeholder:g("请è¾å
¥ç»ç»org-xxx"),showClear:!0,helpText:g("ç»ç»ï¼ä¸å¡«å为é»è®¤ç»ç»"),onChange:e=>ot("openai_organization",e)})]}),t.jsxs(L,{className:"!rounded-2xl shadow-sm border-0 mb-6",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx(J,{size:14,color:"green",className:"mr-2 shadow-md",children:t.jsx(ce,{size:16})}),t.jsxs("div",{children:[t.jsx(Be,{className:"text-lg font-medium",children:g("API é
ç½®")}),t.jsx("div",{className:"text-xs text-gray-600",children:g("API å°ååç¸å
³é
ç½®")})]})]}),40===te.type&&t.jsx($,{type:"info",description:t.jsxs("div",{children:[t.jsxs(Be,{strong:!0,children:[g("éè¯·é¾æ¥"),":"]}),t.jsx(Be,{link:!0,underline:!0,className:"ml-2 cursor-pointer",onClick:()=>window.open("https://cloud.siliconflow.cn/i/hij0YNTZ"),children:"https://cloud.siliconflow.cn/i/hij0YNTZ"})]}),className:"!rounded-lg"}),3===te.type&&t.jsxs(t.Fragment,{children:[t.jsx($,{type:"warning",description:g('2025å¹´5æ10æ¥åæ·»å çæ¸ éï¼ä¸éè¦åå¨é¨ç½²çæ¶åç§»é¤æ¨¡ååç§°ä¸ç"."'),className:"!rounded-lg"}),t.jsx("div",{children:t.jsx(M.TextArea,{field:"base_url",label:"AZURE_OPENAI_ENDPOINT",placeholder:g("channel_placeholder_004"),onChange:e=>ot("base_url",e),autosize:{minRows:2,maxRows:6},showClear:!0})}),t.jsx("div",{children:t.jsx(M.Input,{field:"other",label:g("é»è®¤ API çæ¬"),placeholder:g("请è¾å
¥é»è®¤ API çæ¬ï¼ä¾å¦ï¼2025-04-01-preview"),onChange:e=>ot("other",e),showClear:!0})})]}),8===te.type&&t.jsxs(t.Fragment,{children:[t.jsx($,{type:"warning",description:g("å¦æä½ å¯¹æ¥çæ¯ä¸æ¸¸One APIæè
New APIç转å项ç®ï¼è¯·ä½¿ç¨OpenAIç±»åï¼ä¸è¦ä½¿ç¨æ¤ç±»åï¼é¤éä½ ç¥éä½ å¨åä»ä¹ã"),className:"!rounded-lg"}),t.jsx("div",{children:t.jsx(M.Input,{field:"base_url",label:g("宿´ç Base URLï¼æ¯æåé{model}"),placeholder:g("请è¾å
¥å®æ´çURLï¼ä¾å¦ï¼https://api.openai.com/v1/c
1hat/completions"),onChange:e=>ot("base_url",e),showClear:!0})})]}),37===te.type&&t.jsx($,{type:"warning",description:g("Difyæ¸ éåªéé
chatflowåagentï¼å¹¶ä¸agent䏿¯æå¾çï¼"),className:"!rounded-lg"}),3!==te.type&&8!==te.type&&22!==te.type&&36!==te.type&&t.jsx("div",{children:t.jsx(M.TextArea,{field:"base_url",label:g("APIå°å"),placeholder:g("channel_placeholder_003"),onChange:e=>ot("base_url",e),autosize:{minRows:2,maxRows:6},showClear:!0,extraText:g("对äºå®æ¹æ¸ éï¼new-apiå·²ç»å
ç½®å°åï¼é¤éæ¯ç¬¬ä¸æ¹ä»£çç«ç¹æè
Azureçç¹æ®æ¥å
¥å°åï¼å¦åä¸éè¦å¡«åãå¤ä¸ªå°å请æ¯è¡ä¸ä¸ªï¼ç³»ç»ä¼èªå¨è´è½½åè¡¡ã")})}),22===te.type&&t.jsx("div",{children:t.jsx(M.TextArea,{field:"base_url",label:g("ç§æé¨ç½²å°å"),placeholder:g("请è¾å
¥ç§æé¨ç½²å°åï¼æ ¼å¼ä¸ºï¼https://fastgpt.run/api/openapi\næ¯æå¤ä¸ªå°åè´è½½åè¡¡ï¼æ¯è¡ä¸ä¸ª"),onChange:e=>ot("base_url",e),autosize:{minRows:2,maxRows:6},showClear:!0})}),36===te.type&&t.jsx("div",{children:t.jsx(M.TextArea,{field:"base_url",label:g("注æéChat APIï¼è¯·å¡å¿
å¡«åæ£ç¡®çAPIå°åï¼å¦åå¯è½å¯¼è´æ æ³ä½¿ç¨"),placeholder:g("请è¾å
¥å° /suno åçè·¯å¾ï¼é常就æ¯ååï¼ä¾å¦ï¼https://api.example.com\næ¯æå¤ä¸ªå°åè´è½½åè¡¡ï¼æ¯è¡ä¸ä¸ª"),onChange:e=>ot("base_url",e),autosize:{minRows:2,maxRows:6},showClear:!0})})]}),t.jsxs(L,{className:"!rounded-2xl shadow-sm border-0 mb-6",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx(J,{size:14,color:"purple",className:"mr-2 shadow-md",children:t.jsx(de,{size:16})}),t.jsxs("div",{children:[t.jsx(Be,{className:"text-lg font-medium",children:g("模åé
ç½®")}),t.jsx("div",{className:"text-xs text-gray-600",children:g("模åéæ©åæ å°è®¾ç½®")})]})]}),t.jsx(M.Select,{field:"models",label:g("模å"),placeholder:g("è¯·éæ©è¯¥æ¸ éææ¯æç模å"),rules:[{required:!0,message:g("è¯·éæ©æ¨¡å")}],dropdownClassName:qe,dropdownMatchSelectWidth:!0,dropdownStyle:R,autoAdjustOverflow:!0,onDropdownVisibleChange:V,multiple:!0,filter:!0,searchPosition:"dropdown",optionList:re,style:{width:"100%"},onChange:e=>ot("models",e),extraText:t.jsxs(z,{wrap:!0,children:[t.jsx(T,{size:"small",type:"primary",onClick:()=>ot("models",ye),children:g("å¡«å
¥ç¸å
³æ¨¡å")}),t.jsx(T,{size:"small",type:"secondary",onClick:()=>ot("models",fe),children:g("å¡«å
¥æææ¨¡å")}),t.jsx(T,{size:"small",type:"tertiary",onClick:()=>(async()=>{j(!0);const e=te.models||[];let t=!1;if(_){const s=await i.get("/api/channel/fetch_models/"+y,{skipErrorHandler:!0});s&&s.data&&s.data.success?e.push(...s.data.data):t=!0}else if(te?.key)try{const s=await i.post("/api/channel/fetch_models",{base_url:te.base_url,type:te.type,key:te.key},{skipErrorHandler:!0});s&&s.data&&s.data.success?e.push(...s.data.data):t=!0}catch(s){console.error("Error fetching models:",s),t=!0}else r(g("请填åå¯é¥")),t=!0;t?r(g("è·å模åå表失败")):(ot("models",Array.from(new Set(e))),o(g("è·å模åå表æå"))),j(!1)})(),children:g("è·å模åå表")}),t.jsx(T,{size:"small",type:"warning",onClick:()=>ot("models",[]),children:g("æ¸
é¤æææ¨¡å")}),t.jsx(T,{size:"small",type:"tertiary",onClick:()=>{if(0!==te.models.length)try{d(te.models.join(",")),o(g("模åå表已å¤å¶å°åªè´´æ¿"))}catch(e){r(g("å¤å¶å¤±è´¥"))}else n(g("æ²¡ææ¨¡åå¯ä»¥å¤å¶"))},children:g("å¤å¶æææ¨¡å")})]})}),t.jsx(M.Input,{field:"custom_model",label:g("èªå®ä¹æ¨¡ååç§°"),placeholder:g("è¾å
¥èªå®ä¹æ¨¡ååç§°"),onChange:e=>be(e.trim()),value:ve,suffix:t.jsx(T,{size:"small",type:"primary",onClick:dt,children:g("å¡«å
¥")})}),t.jsx(M.Input,{field:"test_model",label:g("é»è®¤æµè¯æ¨¡å"),placeholder:g("ä¸å¡«å为模åå表第ä¸ä¸ª"),onChange:e=>ot("test_model",e),showClear:!0}),_&&t.jsx(T,{icon:t.jsx(he,{size:16}),type:"warning",theme:"solid",size:"large",onClick:()=>w(!0),style:{marginBottom:12,fontWeight:600},children:g("é
ç½®æ¨¡åææ¬ï¼å¿
å¡«ï¼")}),t.jsx(Re,{channelId:y,models:te.models||[],isEdit:_,visible:b,onClose:()=>w(!1)}),t.jsx(M.TextArea,{field:"model_mapping",label:g("模åéå®å"),placeholder:g("æ¤é¡¹å¯éï¼ç¨äºä¿®æ¹è¯·æ±ä½ä¸ç模ååç§°ï¼ä¸ºä¸ä¸ª JSON å符串ï¼é®ä¸ºè¯·æ±ä¸æ¨¡ååç§°ï¼å¼ä¸ºè¦æ¿æ¢ç模ååç§°ï¼ä¾å¦ï¼")+`\n${JSON.stringify(Me,null,2)}`,autosize:!0,onChange:e=>ot("model_mapping",e),extraText:t.jsx(Be,{className:"!text-primary curs
1or-pointer",onClick:()=>ot("model_mapping",JSON.stringify(Me,null,2)),children:g("å¡«å
¥æ¨¡æ¿")}),showClear:!0}),t.jsx(M.TextArea,{field:"return_model_mapping",label:g("è¿å模åéå®å"),placeholder:g("æ¤é¡¹å¯éï¼ç¨äºä¿®æ¹è¿åä½ä¸ç模ååç§°ï¼ä¸ºä¸ä¸ª JSON å符串ï¼é®ä¸ºè¿å䏿¨¡ååç§°ï¼å¼ä¸ºè¦æ¿æ¢ç模ååç§°ï¼ä¾å¦ï¼")+`\n${JSON.stringify(Le,null,2)}`,autosize:!0,onChange:e=>ot("return_model_mapping",e),extraText:t.jsx(Be,{className:"!text-primary cursor-pointer",onClick:()=>ot("return_model_mapping",JSON.stringify(Le,null,2)),children:g("å¡«å
¥æ¨¡æ¿")}),showClear:!0}),t.jsx(M.TextArea,{field:"model_timeout_mapping",label:g("模åè¶
æ¶éå¶"),placeholder:g("æ¤é¡¹å¯éï¼ç¨äºè®¾ç½®æ¨¡åè¶
æ¶éå¶ï¼ä¸ºä¸ä¸ª JSON å符串ï¼é®ä¸ºæ¨¡ååç§°ï¼å¼ä¸ºè¶
æ¶æ¶é´ï¼ç§ï¼ï¼ä¾å¦ï¼")+`\n${JSON.stringify(We,null,2)}`,autosize:!0,onChange:e=>ot("model_timeout_mapping",e),extraText:t.jsx(Be,{className:"!text-primary cursor-pointer",onClick:()=>ot("model_timeout_mapping",JSON.stringify(We,null,2)),children:g("å¡«å
¥æ¨¡æ¿")}),showClear:!0}),t.jsx(M.Switch,{field:"trust_upstream_token",label:g("ä¿¡ä»»ä¸æ¸¸Token计费"),checkedText:g("æ¯"),uncheckedText:g("å¦"),onChange:e=>it("trust_upstream_token",e),extraText:g("æ¯å¦ä¿¡ä»»ä½¿ç¨ä¸æ¸¸è¿åç token è¿è¡è®¡è´¹ï¼å
³éåå°ä½¿ç¨æ¬å°è®¡ç®")})]}),t.jsxs(L,{className:"!rounded-2xl shadow-sm border-0 mb-6",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx(J,{size:14,color:"orange",className:"mr-2 shadow-md",children:t.jsx(me,{size:16})}),t.jsxs("div",{children:[t.jsx(Be,{className:"text-lg font-medium",children:g("é«çº§è®¾ç½®")}),t.jsx("div",{className:"text-xs text-gray-600",children:g("æ¸ éçé«çº§é
ç½®é项")})]})]}),t.jsx(M.Select,{field:"groups",label:g("åç»"),placeholder:g("è¯·éæ©å¯ä»¥ä½¿ç¨è¯¥æ¸ éçåç»"),multiple:!0,dropdownClassName:qe,dropdownMatchSelectWidth:!0,dropdownStyle:R,autoAdjustOverflow:!0,onDropdownVisibleChange:V,allowAdditions:!0,additionLabel:g("请å¨ç³»ç»è®¾ç½®é¡µé¢ç¼è¾åç»åçä»¥æ·»å æ°çåç»ï¼"),optionList:xe,style:{width:"100%"},onChange:e=>ot("groups",e),renderOptionItem:({disabled:e,selected:s,label:l,value:a,focused:i,className:r,style:n,onMouseEnter:o,onClick:c,empty:d,...h})=>{const m=xe.find(e=>e.value===a),p=m?.ratio||1,u=m?.description||"",x=p<=1?"green":p<=3?"blue":p<=7?"orange":"red";return t.jsxs("div",{style:{...n,display:"grid",gridTemplateColumns:"minmax(0, 1fr) auto",alignItems:"center",columnGap:12,width:"calc(100% - 8px)",maxWidth:"calc(100% - 8px)",boxSizing:"border-box",backgroundColor:i?"hsl(var(--foreground) / 0.02)":"transparent",color:"hsl(var(--foreground))",cursor:e?"not-allowed":"pointer",opacity:e?.5:1,borderRadius:4,margin:"2px 4px",padding:"8px 12px",transition:"background-color 0.1s ease",...Ke},onClick:()=>!e&&c(),onPointerEnter:e=>{"touch"!==e.pointerType&&o()},children:[t.jsxs("div",{className:"flex items-center min-w-0",children:[t.jsx("div",{className:"flex-shrink-0",style:{width:22,height:16,marginRight:8},children:s&&t.jsx("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",focusable:"false","aria-hidden":"true",children:t.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M21.35 4.27c.68.47.86 1.4.38 2.08l-10 14.5a1.5 1.5 0 0 1-2.33.17l-6.5-7a1.5 1.5 0 0 1 2.2-2.04l5.23 5.63 8.94-12.96a1.5 1.5 0 0 1 2.08-.38Z",fill:"currentColor"})})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-medium truncate",children:a}),u&&t.jsx("div",{className:"text-xs mt-0.5 truncate",style:{color:"hsl(var(--muted-foreground))"},children:u})]})]}),t.jsxs(k,{color:x,size:"small",className:"flex-shrink-0 !m-0",children:[p,"å"]})]})},renderSelectedItem:(e,{onClose:s})=>{const l=e?.value||e?.props?.value||e,a=xe.find(e=>e.value===l),i=a?.ratio||1,r=i<=1?"green":i<=3?"blue":i<=7?"orange":"red";return{isRenderInTag:!1,content:t.jsxs(k,{closable:!0,onClose:s,color:r,size:"small",className:"!px-2 !py-0.5 !mr-1 !mb-1",children:[t.jsx("span",{className:"font-medium",children:l}),t.jsx("span",{className:"opacity-75 mx-1",children:"·"}),t.jsxs("span",{className:"text-xs font-mono",children:[i,"å"]})]})}}}),t.jsx(M.Input,{field:"tag",label:g("æ¸ éæ ç¾"),placeholder:g("æ¸ éæ ç¾"),showClear:!0,onChange:e=>ot("tag",e)}),t.jsxs(P,{gutter:12,children:[t.jsx(W,{span:12,children:t.jsx(M.InputNumber,{field:"priority",label:g("æ¸ éä¼å
级"),placeholder:g("æ¸ éä¼å
级"),min:0,onNumberChange:e=>ot("priority",e),style:{width:"100%"}})}),t.jsx(W,{span:12,children:t.jsx(M.InputNumber,{field:"weight",label:g("æ¸ éæé"),placeholder:g("æ¸ éæé"),min:0,onNumberChange:e=>ot("weight",e),style:{width:"100%"}})})]}),t.jsxs(P,{gutter:12,children:[t.jsx(W,{span:8,children:t.jsx(M.InputNumber,{field:"price",label:g("æ¸ éä»·æ ¼"),placeholder:g("è®¾ç½®æ¸ éçåºç¡ä»·æ ¼"),min:0,step:.
101,onNumberChange:e=>ot("price",e),style:{width:"100%"},extraText:g("å¯éï¼ç¨äºèªå®ä¹æ¸ éçä»·æ ¼è®¡ç®")})}),t.jsx(W,{span:8,children:t.jsx(M.InputNumber,{field:"recharge_price",label:g("å
弿±ç"),placeholder:g("ä¾å¦ï¼1 表示 1å
=1é¢åº¦"),min:0,step:1e-4,precision:4,onNumberChange:e=>ot("recharge_price",void 0===e?null:e),style:{width:"100%"},extraText:g("䏿¸¸å¹³å°å
弿±çï¼ä¿®æ¹åæ§æ¸ éå°èªå¨å½æ¡£çåº")})}),t.jsx(W,{span:8,children:t.jsx(M.InputNumber,{field:"group_ratio",label:g("åç»åç"),placeholder:g("ä¾å¦ï¼3 表示å®é
ææ¬=å
弿±çÃ3"),min:0,step:.01,precision:4,onNumberChange:e=>ot("group_ratio",void 0===e?null:e),style:{width:"100%"},extraText:g("䏿¸¸åç»ä»·æ ¼åçï¼å®é
ææ¬ = å
弿±ç à åç»åçï¼ä¿®æ¹åæ§æ¸ éå°èªå¨å½æ¡£çåº")})})]}),t.jsx(M.Switch,{field:"auto_ban",label:g("æ¯å¦èªå¨ç¦ç¨"),checkedText:g("å¼"),uncheckedText:g("å
³"),onChange:e=>{ee(e),ot("auto_ban",e)},extraText:g("ä»
å½èªå¨ç¦ç¨å¼å¯æ¶ææï¼å
³éåä¸ä¼èªå¨ç¦ç¨è¯¥æ¸ é"),initValue:Q}),t.jsx(M.TextArea,{field:"param_override",label:g("åæ°è¦ç"),placeholder:g("æ¤é¡¹å¯éï¼ç¨äºè¦ç请æ±åæ°ã䏿¯æè¦ç stream åæ°")+"\n"+g("æ§æ ¼å¼ï¼ç´æ¥è¦çï¼ï¼")+'\n{\n "temperature": 0,\n "max_tokens": 1000\n}\n\n'+g("æ°æ ¼å¼ï¼æ¯ææ¡ä»¶å¤æä¸jsonèªå®ä¹ï¼ï¼")+'\n{\n "operations": [\n {\n "path": "temperature",\n "mode": "set",\n "value": 0.7,\n "conditions": [\n {\n "path": "model",\n "mode": "prefix",\n "value": "gpt"\n }\n ]\n }\n ]\n}',autosize:!0,onChange:e=>ot("param_override",e),extraText:t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[t.jsx(Be,{className:"!text-primary cursor-pointer",onClick:()=>ot("param_override",JSON.stringify({temperature:0},null,2)),children:g("æ§æ ¼å¼æ¨¡æ¿")}),t.jsx(Be,{className:"!text-primary cursor-pointer",onClick:()=>ot("param_override",JSON.stringify({operations:[{path:"temperature",mode:"set",value:.7,conditions:[{path:"model",mode:"prefix",value:"gpt"}],logic:"AND"}]},null,2)),children:g("æ°æ ¼å¼æ¨¡æ¿")})]}),showClear:!0}),t.jsx(M.TextArea,{field:"header_override",label:g("请æ±å¤´è¦ç"),placeholder:g("æ¤é¡¹å¯éï¼ç¨äºè¦çåå¾ä¸æ¸¸ç请æ±å¤´")+"\n"+g("æ ¼å¼ç¤ºä¾ï¼")+'\n{\n "User-Agent": "Mozilla/5.0 ...",\n "Authorization": "Bearer {api_key}"\n}',autosize:!0,onChange:e=>ot("header_override",e),extraText:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[t.jsx(Be,{className:"!text-primary cursor-pointer",onClick:()=>ot("header_override",JSON.stringify({"*":!0,"re:^X-Trace-.*$":!0,"X-Foo":"{client_header:X-Foo}",Authorization:"Bearer {api_key}","User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"},null,2)),children:g("å¡«å
¥æ¨¡æ¿")}),t.jsx(Be,{className:"!text-primary cursor-pointer",onClick:()=>ot("header_override",JSON.stringify({"*":!0},null,2)),children:g("å¡«å
¥éä¼ æ¨¡æ¿")}),t.jsx(Be,{className:"!text-primary cursor-pointer",onClick:()=>{const e="string"==typeof te.header_override?te.header_override.trim():"";if(e)try{ot("header_override",JSON.stringify(JSON.parse(e),null,2))}catch(t){n(g("请æ±å¤´è¦ç䏿¯åæ³ç JSON æ ¼å¼"))}},children:g("æ ¼å¼å")})]}),t.jsxs("div",{className:"text-xs",children:[t.jsx("span",{children:g("æ¯æåéï¼")}),t.jsxs("span",{className:"ml-2 text-gray-500",children:[g("æ¸ éå¯é¥"),": ","{api_key}"]}),t.jsxs("span",{className:"ml-2 text-gray-500",children:[g("客æ·ç«¯è¯·æ±å¤´"),": ","{client_header:<åç§°>}"]})]})]}),showClear:!0}),t.jsx(M.TextArea,{field:"status_code_mapping",label:g("ç¶æç å¤å"),placeholder:g("æ¤é¡¹å¯éï¼ç¨äºå¤åè¿åçç¶æç ï¼ä»
影忬å°å¤æï¼ä¸ä¿®æ¹è¿åå°ä¸æ¸¸çç¶æç ï¼æ¯å¦å°claudeæ¸ éç400é误å¤å为500ï¼ç¨äºéè¯ï¼ï¼è¯·å¿æ»¥ç¨è¯¥åè½ï¼ä¾å¦ï¼")+"\n"+JSON.stringify(Je,null,2),autosize:!0,onChange:e=>ot("status_code_mapping",e),extraText:t.jsx(Be,{className:"!text-primary curs
1or-pointer",onClick:()=>ot("status_code_mapping",JSON.stringify(Je,null,2)),children:g("å¡«å
¥æ¨¡æ¿")}),showClear:!0})]}),t.jsxs(L,{className:"!rounded-2xl shadow-sm border-0 mb-6",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx(J,{size:14,color:"violet",className:"mr-2 shadow-md",children:t.jsx(oe,{size:16})}),t.jsxs("div",{children:[t.jsx(Be,{className:"text-lg font-medium",children:g("æ¸ éé¢å¤è®¾ç½®")}),t.jsx("div",{className:"text-xs text-gray-600",children:g("æ¸ éçç¹æ®åè½é
ç½®")})]})]}),1===te.type&&t.jsx(M.Switch,{field:"force_format",label:g("å¼ºå¶æ ¼å¼å"),checkedText:g("å¼"),uncheckedText:g("å
³"),onChange:e=>it("force_format",e),extraText:g("强å¶å°ååºæ ¼å¼å为 OpenAI æ åæ ¼å¼ï¼åªéç¨äºOpenAIæ¸ éç±»åï¼")}),t.jsx(M.Switch,{field:"thinking_to_content",label:g("æèå
容转æ¢"),checkedText:g("å¼"),uncheckedText:g("å
³"),onChange:e=>it("thinking_to_content",e),extraText:g("å° reasoning_content 转æ¢ä¸º <think> æ ç¾æ¼æ¥å°å
容ä¸")}),t.jsx(M.Switch,{field:"pass_through_body_enabled",label:g("éä¼ è¯·æ±ä½"),checkedText:g("å¼"),uncheckedText:g("å
³"),onChange:e=>it("pass_through_body_enabled",e),extraText:g("å¯ç¨è¯·æ±ä½éä¼ åè½")}),t.jsx("div",{className:"text-sm font-medium mt-4 mb-1",children:g("åæ®µéä¼ æ§å¶")}),t.jsx(M.Switch,{field:"allow_service_tier",label:g("å
许 service_tier éä¼ "),checkedText:g("å¼"),uncheckedText:g("å
³"),onChange:e=>rt("allow_service_tier",e),extraText:g("service_tier åæ®µç¨äºæå®æå¡å±çº§ï¼å
许éä¼ å¯è½å¯¼è´å®é
计费é«äºé¢æãé»è®¤å
³é以é¿å
é¢å¤è´¹ç¨")}),t.jsx(M.Switch,{field:"disable_store",label:g("store åæ®µéä¼ "),checkedText:g("ç¦ç¨"),uncheckedText:g("å
许"),onChange:e=>rt("disable_store",e),extraText:g("store åæ®µé»è®¤å
许éä¼ ï¼ç¦ç¨åå¯è½å¯¼è´ Codex æ æ³æ£å¸¸ä½¿ç¨")}),t.jsx(M.Input,{field:"proxy",label:g("代çå°å"),placeholder:g("ä¾å¦: socks5://user:pass@host:port"),onChange:e=>it("proxy",e),showClear:!0,extraText:g("ç¨äºé
ç½®ç½ç»ä»£çï¼æ¯æ socks5 åè®®")}),t.jsx(M.TextArea,{field:"system_prompt",label:g("ç³»ç»æç¤ºè¯"),placeholder:g("è¾å
¥ç³»ç»æç¤ºè¯ï¼ç¨æ·çç³»ç»æç¤ºè¯å°ä¼å
äºæ¤è®¾ç½®"),onChange:e=>it("system_prompt",e),autosize:!0,showClear:!0,extraText:g("ç¨æ·ä¼å
ï¼å¦æç¨æ·å¨è¯·æ±ä¸æå®äºç³»ç»æç¤ºè¯ï¼å°ä¼å
使ç¨ç¨æ·ç设置")}),t.jsx(M.Switch,{field:"system_prompt_override",label:g("ç³»ç»æç¤ºè¯æ¼æ¥"),checkedText:g("å¼"),uncheckedText:g("å
³"),onChange:e=>it("system_prompt_override",e),extraText:g("å¦æç¨æ·è¯·æ±ä¸å
å«ç³»ç»æç¤ºè¯ï¼åä½¿ç¨æ¤è®¾ç½®æ¼æ¥å°ç¨æ·çç³»ç»æç¤ºè¯åé¢")}),t.jsx(M.TextArea,{field:"filter_fields",label:g("è¿æ»¤è¿ååæ®µ"),placeholder:g("channel_placeholder_009"),onChange:e=>it("filter_fields",e),autosize:!0,showClear:!0,extraText:t.jsxs(z,{children:[t.jsx(Be,{type:"tertiary",size:"small",children:g("è¿æ»¤APIè¿åçåæ®µï¼å¼ä¸ºtrueè¡¨ç¤ºè¿æ»¤è¯¥åæ®µï¼æ¯æsjsonè·¯å¾è¯æ³")}),t.jsx(Be,{className:"!text-primary cursor-pointer",onClick:()=>it("filter_fields",JSON.stringify(De,null,2)),children:g("å¡«å
¥æ¨¡æ¿")})]})}),t.jsx(M.TextArea,{field:"claude_beta_filters",label:g("Claude Beta Flags è¿æ»¤"),placeholder:g("channel_placeholder_008"),onChange:e=>it("claude_beta_filters",e),autosize:!0,showClear:!0,extraText:g("è¿æ»¤ Anthropic-Beta 请æ±å¤´ä¸çç¹å® flagsï¼å¤ä¸ª flag ç¨è±æéå·åé")}),t.jsx(M.Switch,{field:"bedrock_compat",label:g("AWS Bedrock å
¼å®¹æ¨¡å¼"),checkedText:g("å¼"),uncheckedText:g("å
³"),onChange:e=>it("bedrock_compat",e),extraText:g("channel_placeholder_001")}),t.jsx(M.Switch,{field:"retry_on_content_filter",label:g("å
å®¹è¿æ»¤éè¯"),checkedText:g("å¼"),uncheckedText:g("å
³"),onChange:e=>it("retry_on_content_filter",e),extraText:g("å½å
å®¹è¢«å®¡æ ¸è¿æ»¤æ¶(finish_reason=content_filter)触å429é误éè¯")}
1),t.jsx(M.TextArea,{field:"channel_rate_limit",label:g("æ¸ ééæµè®¾ç½®"),placeholder:g("channel_placeholder_007"),onChange:e=>it("channel_rate_limit",e),autosize:!0,showClear:!0,extraText:t.jsxs(z,{vertical:!0,align:"start",children:[t.jsxs(z,{children:[t.jsx(Be,{type:"tertiary",size:"small",children:g("æ¸ ééæµè®¾ç½®ï¼å½å¼å¯æ¸ ééæµæ¶ï¼èªå¨å¡«å
¥é»è®¤å¼")}),t.jsx(Be,{className:"!text-primary cursor-pointer",onClick:()=>it("channel_rate_limit",JSON.stringify(Fe,null,2)),children:g("å¡«å
¥æ¨¡æ¿")})]}),t.jsx(Be,{type:"tertiary",size:"small",children:g("channel_placeholder_002")})]})})]}),t.jsxs(L,{className:"!rounded-2xl shadow-sm border-0 mb-6",children:[t.jsxs("div",{className:"flex items-center mb-4 p-6 rounded-xl",style:{background:"linear-gradient(135deg, #7c2d12 0%, #dc2626 50%, #ef4444 100%)",position:"relative"},children:[t.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[t.jsx("div",{className:"absolute -top-10 -right-10 w-40 h-40 bg-white opacity-5 rounded-full"}),t.jsx("div",{className:"absolute -bottom-8 -left-8 w-24 h-24 bg-white opacity-10 rounded-full"})]}),t.jsx("div",{className:"w-10 h-10 rounded-full bg-white/20 flex items-center justify-center mr-4 relative",children:t.jsx(me,{size:20,style:{color:"#ffffff"}})}),t.jsxs("div",{className:"relative",children:[t.jsx(Be,{style:{color:"#ffffff"},className:"text-lg font-medium",children:g("æ©å±åè½")}),t.jsx("div",{style:{color:"#ffffff"},className:"text-sm opacity-80",children:g("äºå¼çæ¬çä¸å±åè½é
ç½®")})]})]}),t.jsx(M.InputNumber,{field:"failure_timeout_ban_limit",label:g("失败è¶
æ¶ç¦ç¨éå¶æ¶é´ï¼ç§ï¼"),placeholder:g("设置
1失败è¶
æ¶ç¦ç¨éå¶æ¶é´"),min:0,onNumberChange:e=>ot("failure_timeout_ban_limit",e),style:{width:"100%"},extraText:g("彿¸ éè¿ç»å¤±è´¥è¾¾å°æ¤æ¶é´éå¶æ¶èªå¨ç¦ç¨")})]})]})})}),t.jsx(D,{src:we,visible:Se,onVisibleChange:e=>Ce(e)})]})})},{Text:Ge,Title:Ye}=w,Ze={"gpt-3.5-turbo":"gpt-3.5-turbo-0125"},Xe={"gpt-4o":"gpt-4o-2024-08-06","gpt-3.5-turbo":"gpt-3.5-turbo-0125","gpt-4o-mini":"gpt-4o-mini-2024-07-18","o1-mini":"o1-mini-2024-09-12","o1-preview":"o1-preview-2024-09-12","gpt-4-turbo":"gpt-4-turbo-2024-04-09"},Qe=s=>{const{t:a}=l(),{visible:c,tag:d,handleClose:u,refresh:x}=s,[g,y]=e.useState(!1),[_,f]=e.useState([]),[j,v]=e.useState([]),[b,w]=e.useState([]),[S,C]=e.useState(""),N={tag:"",new_tag:null,model_mapping:null,return_model_mapping:null,header_override:null,groups:[],models:[]},[I,O]=e.useState(N),E=e.useRef(null),R=()=>({...N}),P=(e,t)=>{if(O(s=>({...s,[e]:t})),E.current&&E.current.setValue(e,t),"type"===e){let e=[];switch(t){case 2:e=["mj_imagine","mj_variation","mj_reroll","mj_blend","mj_upscale","mj_describe","mj_uploads"];break;case 5:e=["swap_face","mj_imagine","mj_video","mj_edits","mj_variation","mj_reroll","mj_blend","mj_upscale","mj_describe","mj_zoom","mj_shorten","mj_modal","mj_inpaint","mj_custom_zoom","mj_high_variation","mj_low_variation","mj_pan","mj_uploads"];break;case 36:e=["suno_music","suno_music_open","suno_lyrics"];break;default:e=h(t)}0===I.models.length&&O(t=>({...t,models:e}))}};e.useEffect(()=>{let e=[..._];I.models.forEach(t=>{e.find(e=>e.label===t)||e.push({label:t,value:t})}),v(e)},[_,I.models]),e.useEffect(()=>{(async()=>{try{let e=(await i.get("/api/channel/models")).data.data.map(e=>({label:e.id,value:e.id}));f(e)}catch(e){r(e.message)}})().then(),(async()=>{try{let e=await i.get("/api/group/");if(void 0===e)return;const t=e.data.data;t&&t.groups?w(t.groups.map(e=>({label:e,value:e}))):Array.isArray(t)&&w(t.map(e=>({label:e,value:e})))}catch(e){r(e.message)}})().then(),(async()=>{if(d){y(!0);try{const e=await i.get(`/api/channel/tag/models?tag=${d}`);if(e?.data?.success){const t=e.data.data?e.data.data.split(","):[];P("models",t)}else r(e.data.message)}catch(e){r(e.message)}finally{y(!1)}}})().then(),E.current&&E.current.setValues({...R(),tag:d,new_tag:d}),O({...N,tag:d,new_tag:d})},[c,d]),e.useEffect(()=>{E.current&&E.current.setValues(I)},[I]);const W=()=>{if(""===S.trim())return;const e=S.split(",").map(e=>e.trim());let t=[...I.models],s=[...j];const l=[];e.forEach(e=>{e&&!t.includes(e)&&(t.push(e),s.push({key:e,text:e,value:e}),l.push(e))}),v(s),C(""),P("models",t),l.length>0?o(a("å·²æ°å¢ {{num}} 个模åï¼{{list}}",{num:l.length,list:l.join(", ")})):n(a("æªåç°æ°å¢æ¨¡å"))};return t.jsx(B,{placement:"right",title:t.jsxs(z,{children:[t.jsx(k,{color:"blue",shape:"circle",children:a("ç¼è¾")}),t.jsx(Ye,{heading:4,className:"m-0",children:a("ç¼è¾æ ç¾")})]}),bodyStyle:{padding:"0"},visible:c,width:600,onCancel:u,footer:t.jsx("div",{className:"flex justify-end bg-white",children:t.jsxs(z,{children:[t.jsx(T,{theme:"solid",onClick:()=>E.current?.submitForm(),loading:g,icon:t.jsx(le,{size:16}),children:a("ä¿å")}),t.jsx(T,{theme:"light",type:"primary",onClick:u,icon:t.jsx(pe,{size:16}),children:a("åæ¶")})]})}),closeIcon:null,children:t.jsx(M,{initValues:R(),getFormApi:e=>E.current=e,onSubmit:async e=>{y(!0);const t=e||E.current?.getValues()||{};let s={tag:d};if(t.model_mapping){if(!p(t.model_mapping))return n(a("æ¨¡åæ å°å¿
é¡»æ¯åæ³ç JSON æ ¼å¼ï¼")),void y(!1);s.model_mapping=t.model_mapping}if(null!==I.return_model_mapping&&""!==I.return_model_mapping){if(""!==I.return_model_mapping&&!p(I.return_model_mapping))return n(a("è¿å模åéå®åå¿
é¡»æ¯åæ³ç JSON æ ¼å¼ï¼")),void y(!1);s.return_model_mapping=I.return_model_mapping}if(t.groups&&t.groups.length>0&&(s.groups=t.groups.join(",")),t.models&&t.models.length>0&&(s.models=t.models.join(",")),void 0!==t.header_override&&null!==t.header_override){if("string"!=typeof t.header_override)return n(a("请æ±å¤´è¦çå¿
é¡»æ¯åæ³ç JSON æ ¼å¼ï¼")),void y(!1);const e=t.header_override.trim();if(""!==e&&!p(e))return n(a("请æ±å¤´è¦çå¿
é¡»æ¯åæ³ç JSON æ ¼å¼ï¼")),void y(!1);s.header_override=e}if(s.new_tag=t.new_tag,void 0===s.model_mapping&&void 0===s.return_model_mapping&&void 0===s.groups&&void 0===s.models&&void 0===s.header_override&&void 0===s.new_tag)return m(a("没æä»»ä½ä¿®æ¹ï¼")),void y(!1);await(async e=>{try{const t=await i.put("/api/channel/tag",e);t?.data?.success&&(o(a("æ ç¾æ´æ°æåï¼")),x(),u())}catch(t){r(t)}})(s),y(!1)},children:()=>t.jsx(A,{spinning:g,children:t.jsxs("div",{className:"p-2",children:[t.jsxs(L,{className:"!rounded-2xl shadow-sm border-0 mb-6",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx(J,{size:14,color:"blue",className:"mr-2 shadow-md",children:t.jsx(ue,{size:16})}),t.jsxs("div",{children:[t.jsx(Ge,{className:"text-lg font-medium",children:a("æ ç¾ä¿¡æ¯")}),t.jsx("div",{className:"text-xs text-gray-600",children:a("æ ç¾çåºæ¬é
ç½®")})]})]}),t.jsx($,{type:"warning",description:a("ææç¼è¾å为è¦çæä½ï¼ç空å䏿´æ¹"),className:"!rounded-lg mb-4"}),t.jsx("div",{className:"space-y-4",children:t.jsx(M.Input,{field:"new_tag",label:a("æ ç¾åç§°"),placeholder:a("请è¾å
¥æ°æ ç¾ï¼ç空åè§£æ£æ ç¾"),onChange:e=>P("new_tag",e)})})]}),t.jsxs(L,{className:"!rounded-2xl shadow-sm border-0 mb-6",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx(J,{size:14,color:"purple",className:"mr-2 shadow-md",children:t.jsx(de,{size:16})}),t.jsxs("div",{children:[t.jsx(Ge,{className:"text-lg font-medium",children:a("模åé
ç½®")}),t.jsx("div",{className:"text-xs text-gray-600",children:a("模åéæ©åæ å°è®¾ç½®")})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx($,{type:"info",description:a("å½å模åå表为该æ ç¾ä¸æææ¸ 鿍¡åå表æé¿çä¸ä¸ªï¼å¹¶éæææ¸ éçå¹¶éï¼è¯·æ³¨æå¯è½å¯¼è´æäºæ¸ 鿍¡å丢失ã"),className:"!rounded-lg mb-4"}),t.jsx(M.Select,{field:"models",label:a("模å"),placeholder:a("è¯·éæ©è¯¥æ¸ éææ¯æç模åï¼ç空å䏿´æ¹"),multiple:!0,filter:!0,searchPosition:"dropdown",optionList:j,style:{width:"100%"},onChange:e=>P("models",e)}),t.jsx(M.Input,{field:"custom_model",label:a("èªå®ä¹æ¨¡ååç§°"),placeholder:a("è¾å
¥èªå®ä¹æ¨¡ååç§°"),onChange:e=>C(e.trim()),suffix:t.jsx(T,{size:"small",type:"primary",onClick:W,children:a("å¡«å
¥")})}),t.jsx(M.TextArea,{field:"model_mapping",label:a("模åéå®å"),placeholder:a("æ¤é¡¹å¯éï¼ç¨äºä¿®æ¹è¯·æ±ä½ä¸ç模ååç§°ï¼ä¸ºä¸ä¸ª JSON å符串ï¼é®ä¸ºè¯·æ±ä¸æ¨¡ååç§°ï¼å¼ä¸ºè¦æ¿æ¢ç模ååç§°ï¼ç空å䏿´æ¹"),autosize:!0,value:
1I.model_mapping,onChange:e=>P("model_mapping",e),extraText:t.jsxs(z,{children:[t.jsx(Ge,{className:"!text-primary cursor-pointer",onClick:()=>P("model_mapping",JSON.stringify(Ze,null,2)),children:a("å¡«å
¥æ¨¡æ¿")}),t.jsx(Ge,{className:"!text-primary cursor-pointer",onClick:()=>P("model_mapping",JSON.stringify({},null,2)),children:a("æ¸
空éå®å")}),t.jsx(Ge,{className:"!text-primary cursor-pointer",onClick:()=>P("model_mapping",""),children:a("䏿´æ¹")})]})}),t.jsx(M.TextArea,{field:"return_model_mapping",label:a("è¿å模åéå®å"),placeholder:a("æ¤é¡¹å¯éï¼ç¨äºä¿®æ¹è¿åä½ä¸ç模ååç§°ï¼ä¸ºä¸ä¸ª JSON å符串ï¼é®ä¸ºè¿å䏿¨¡ååç§°ï¼å¼ä¸ºè¦æ¿æ¢ç模ååç§°ï¼ç空å䏿´æ¹"),autosize:!0,value:I.return_model_mapping,onChange:e=>P("return_model_mapping",e),extraText:t.jsxs(z,{children:[t.jsx(Ge,{className:"!text-primary cursor-pointer",onClick:()=>P("return_model_mapping",JSON.stringify(Xe,null,2)),children:a("å¡«å
¥æ¨¡æ¿")}),t.jsx(Ge,{className:"!text-primary cursor-pointer",onClick:()=>P("return_model_mapping",JSON.stringify({},null,2)),children:a("æ¸
空éå®å")}),t.jsx(Ge,{className:"!text-primary cursor-pointer",onClick:()=>P("return_model_mapping",""),children:a("䏿´æ¹")})]})})]})]}),t.jsxs(L,{className:"!rounded-2xl shadow-sm border-0",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx(J,{size:14,color:"green",className:"mr-2 shadow-md",children:t.jsx(xe,{size:16})}),t.jsxs("div",{children:[t.jsx(Ge,{className:"text-lg font-medium",children:a("åç»è®¾ç½®")}),t.jsx("div",{className:"text-xs text-gray-600",children:a("ç¨æ·åç»é
ç½®")})]})]}),t.jsx("div",{className:"space-y-4",children:t.jsx(M.Select,{field:"groups",label:a("åç»"),placeholder:a("è¯·éæ©å¯ä»¥ä½¿ç¨è¯¥æ¸ éçåç»ï¼ç空å䏿´æ¹"),multiple:!0,allowAdditions:!0,additionLabel:a("请å¨ç³»ç»è®¾ç½®é¡µé¢ç¼è¾åç»åçä»¥æ·»å æ°çåç»ï¼"),optionList:b,style:{width:"100%"},onChange:e=>P("groups",e)})})]}),t.jsxs(L,{className:"!rounded-2xl shadow-sm border-0 mt-6",children:[t.jsxs("div",{className:"flex items-center mb-2",children:[t.jsx(J,{size:14,color:"orange",className:"mr-2 shadow-md",children:t.jsx(de,{size:16})}),t.jsxs("div",{children:[t.jsx(Ge,{className:"text-lg font-medium",children:a("请æ±å¤´è¦ç")}),t.jsx("div",{className:"text-xs text-gray-600",children:a("æ¹é设置æ ç¾ä¸æ¸ éç请æ±å¤´è¦ç")})]})]}),t.jsx(M.TextArea,{field:"header_override",label:a("请æ±å¤´è¦ç"),placeholder:a("æ¤é¡¹å¯éï¼ç¨äºè¦ç请æ±å¤´åæ°")+"\n"+a("æ ¼å¼ç¤ºä¾ï¼")+'\n{\n "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36",\n "Authorization": "Bearer {api_key}"\n}',autosize:!0,showClear:!0,onChange:e=>P("header_override",e),extraText:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs(z,{children:[t.jsx(Ge,{className:"!text-primary cursor-pointer",onClick:()=>P("header_override",JSON.stringify({"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36",Authorization:"Bearer {api_key}"},null,2)),children:a("å¡«å
¥æ¨¡æ¿")}),t.jsx(Ge,{className:"!text-primary cursor-pointer",onClick:()=>P("header_override",null),children:a("䏿´æ¹")})]}),t.jsxs("div",{className:"text-xs text-tertiary",children:[t.jsx("div",{children:a("æ¯æåéï¼")}),t.jsxs("div",{className:"ml-2",children:[a("æ¸ éå¯é¥"),": ","{api_key}"]}),t.jsxs("div",{className:"ml-2",children:[a("客æ·ç«¯è¯·æ±å¤´"),": ","{client_header:<åç§°>}"]})]})]})})]})]})})},d||"edit")})};function et(e){return be({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M504.971 359.029c9.373 9.373 9.373 24.569 0 33.941l-80 79.984c-15.01 15.01-40.971 4.49-40.971-16.971V416h-58.785a12.004 12.004 0 0 1-8.773-3.812l-70.556-75.596 53.333-57.143L352 336h32v-39.981c0-21.438 25.943-31.998 40.971-16.971l80 79.981zM12 176h84l52.781 56.551 53.333-57.143-70.556-75.596A11.999 11.999 0 0 0 122.785 96H12c-6.627 0-12 5.373-12 12v56c0 6.627 5.373 12 12 12zm372 0v39.984c0 21.46 25.961 31.98 40.971 16.971l80-79.984c9.373-9.373 9.373-24.569 0-33.941l-80-79.981C409.943 24.021 384 34.582 384 56.019V96h-58.785a12.004 12.004 0 0 0-8.773 3.812L96 336H12c-6.627 0-12 5.373-12 12v56c0 6.627 5.373 12 12 12h110.785c3.326 0 6.503-1.381 8.773-3.812L352 176h32z"},child:[]}]})(e)}const tt=({visible:s,onCancel:a,channelId:n,channelName:o})=>{const{t:c}=l(),[d,h]=e.useState(!1),[m,p]=e.useState([]),[u,x]=e.useState(""),[g,y]=e.useState("24h"),[_,f]=e.useState(null),[j,v]=e.useState(null);e.useEffect(()=>{s&&n&&b()},[s,n]);const b=async()=>{try{const e=await i.get(`/api/channel/${n}`);if(e.data.success&&e.data.data){const t=e.data.data;if(t.models&&t.models.length>0){const e=t.models.split(",").map(e=>e.trim()).filter(e=>e);p(e),e.length>0&&!u&&x(e[0])}}}catch(e){console.error("è·åæ¸ éæ¨¡åå表失败:",e)}};e.useEffect(()=>{u&&n&&w()},[u,g,n]);const w=async()=>{h(!0);try{const e=await i.get(`/api/channel/success_rate_trend?channel_id=${n}&model=${u}&period=${g}`);if(e.data.success){const t=e.data.data;f(t),S(t)}else r(e.data.message||c("è·åæ°æ®å¤±è´¥"))}catch(e){r(c("è·åæåçè¶å¿æ°æ®å¤±è´¥")),console.error("fetchTrendData error:",e)}finally{h(!1)}},S=e=>{if(!e||!e.data_points||0===e.data_points.length)return void v(null);const t={type:"line",data:[{id:"data",values:e.data_points.map(e=>({time:e.time_label,success_rate:parseFloat((100*e.success_rate).toFixed(2)),total_requests:e.total_requests}))}],xField:"time",yField:"success_rate",line:{style:{lineWidth:3,lineCap:"round",stroke:"#4CC9F0"}},point:{style:{size:6,fill:"white",stroke:"#4CC9F0",lineWidth:2}},axes:[{orient:"left",type:"linear",title:{visible:!0,text:c("æåç")+" (%)",style:{fontSize:12}},min:0,max:100,grid:{visible:!0}},{orient:"bottom",type:"band",label:{autoRotate:!0,autoRotateAngle:[0,45,90]}}],title:{visible:!0,text:c("æåçè¶å¿"),textStyle:{fontSize:16,fontWeight:"bold"}},tooltip:{mark:{content:[{key:e=>c("æ¶é´"),value:e=>e.time},{key:e=>c("æåç"),value:e=>`${e.success_rate}%`},{key:e=>c("æ»è¯·æ±æ°"),value:e=>e.total_requests}]}},legends:{visible:!1}};v(t)};return t.jsxs(N,{title:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx(ge,{size:16}),t.jsxs("span",{children:[c("æåçè¶å¿åæ")," - ",o]})]}),visible:s,onCancel:a,footer:null,width:900,bodyStyle:{padding:"24px"}
1,children:[t.jsxs("div",{style:{marginBottom:"16px",display:"flex",gap:"12px",alignItems:"center"},children:[t.jsxs("div",{style:{flex:1},children:[t.jsxs("span",{style:{marginRight:"8px"},children:[c("éæ©æ¨¡å"),":"]}),t.jsx(C,{value:u,onChange:x,style:{width:"300px"},filter:!0,placeholder:c("è¯·éæ©æ¨¡å"),children:m.map(e=>t.jsx(C.Option,{value:e,children:e},e))})]}),t.jsxs("div",{children:[t.jsxs("span",{style:{marginRight:"8px"},children:[c("æ¶é´èå´"),":"]}),t.jsxs(C,{value:g,onChange:y,style:{width:"120px"},children:[t.jsx(C.Option,{value:"24h",children:c("æè¿24å°æ¶")}),t.jsx(C.Option,{value:"7d",children:c("æè¿7天")})]})]}),t.jsx(T,{icon:t.jsx(se,{size:16}),onClick:()=>{u&&w()},disabled:!u,children:c("å·æ°")})]}),d?t.jsxs("div",{style:{textAlign:"center",padding:"60px 0"},children:[t.jsx(A,{size:20}),t.jsxs("div",{style:{marginTop:"16px",color:"#999"},children:[c("å è½½ä¸..."),"..."]})]}):u?_&&j?t.jsxs(t.Fragment,{children:[t.jsx(L,{style:{marginBottom:"16px"},bodyStyle:{padding:"16px"},children:t.jsxs(V,{row:!0,children:[t.jsx(V.Item,{itemKey:c("å¹³åæåç"),children:t.jsx(k,{color:_.summary.avg_success_rate>=.9?"green":_.summary.avg_success_rate>=.7?"orange":"red",size:"large",children:(z=_.summary.avg_success_rate,`${(100*z).toFixed(2)}%`)})}),t.jsx(V.Item,{itemKey:c("æ»è¯·æ±æ°"),children:_.summary.total_requests}),t.jsx(V.Item,{itemKey:c("æå请æ±"),children:t.jsx("span",{style:{color:"#52c41a"},children:_.summary.success_requests})}),t.jsx(V.Item,{itemKey:c("失败请æ±"),children:t.jsx("span",{style:{color:"#ff4d4f"},children:_.summary.failure_requests})})]})}),t.jsx("div",{style:{height:"400px",marginTop:"16px"},children:t.jsx(ke,{spec:j})})]}):t.jsx(E,{description:c("ææ æ°æ®"),style:{padding:"60px 0"}}):t.jsx(E,{description:c("请å
éæ©è¦åæç模å"),style:{padding:"60px 0"}})]});var z},st=()=>{const{t:s}=l(),c=a(),h=e.useRef(!1);let m;const p=(e,l=void 0)=>{if(!m){m=new Map;for(let e=0;e<v.length;e++)m[v[e].value]=v[e];m[0]={value:0,label:s("æªç¥ç±»å"),color:"grey"}}let a=u(e);return l?.is_multi_key&&(a="random"===l?.multi_key_mode?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(et,{className:"text-blue-500"}),a]}):t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(je,{size:16,className:"text-blue-500"}),a]})),t.jsx(k,{color:m[e]?.color,shape:"circle",prefixIcon:a,children:m[e]?.label})},$=(e,l=void 0)=>{if(l&&l.is_multi_key){let t=l.multi_key_size,s=t;return l.multi_key_status_list&&(s=t-Object.keys(l.multi_key_status_list).length),J(e,t,s)}switch(e){case 1:return t.jsx(k,{color:"green",shape:"circle",children:s("å·²å¯ç¨")});case 2:return t.jsx(k,{color:"red",shape:"circle",children:s("å·²ç¦ç¨")});case 3:return t.jsx(k,{color:"yellow",shape:"circle",children:s("èªå¨ç¦ç¨")});case 4:return t.jsx(k,{color:"teal",shape:"circle",children:s("å¯¹è´¦å®æ¯")});case 5:return t.jsx(k,{color:"grey",shape:"circle",children:s("ä»·æ ¼å½æ¡£")});case 6:return t.jsx(k,{color:"red",shape:"circle",children:s("æ¸ éåå°ç¦")});default:return t.jsx(k,{color:"grey",shape:"circle",children:s("æªç¥ç¶æ")})}},J=(e,l,a)=>{switch(e){case 1:return t.jsxs(k,{color:"green",shape:"circle",children:[s("å·²å¯ç¨")," ",a,"/",l]});case 2:return t.jsxs(k,{color:"red",shape:"circle",children:[s("å·²ç¦ç¨")," ",a,"/",l]});case 3:return t.jsxs(k,{color:"yellow",shape:"circle",children:[s("èªå¨ç¦ç¨")," ",a,"/",l]});default:return t.jsxs(k,{color:"grey",shape:"circle",children:[s("æªç¥ç¶æ")," ",a,"/",l]})}},P=e=>{if(2!==e.status&&3!==e.status)return null;try{const t=JSON.parse(e.other_info||"{}"),s=t.status_reason;if(!s)return null;const l=t.status_operator||"",a=t.status_time;let i="";if(a){const e=new Date(1e3*a);i=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`}return{reason:s,operator:l,timeStr:i}}catch(t){return null}},W=e=>{if(c||!ms)return null;const s=P(e);return s?t.jsx("div",{style:{marginTop:"4px",fontSize:"12px",color:"hsl(var(--muted-foreground))",lineHeight:"1.4",wordBreak:"break-word",whiteSpace:"normal",maxWidth:"200px"},children:s.reason}):null},D=(e,l)=>{N.info({title:s("ç¦ç¨åå "),hasCancel:!1,okText:s("ç¥éäº"),centered:!0,width:"calc(100vw - 48px)",style:{maxWidth:480},content:t.jsxs("div",{style:{fontSize:"13px",lineHeight:1.6,wordBreak:"break-word"},children:[(e.operator||e.timeStr)&&t.jsxs("div",{style:{display:"flex",gap:12,marginBottom:10,fontSize:"12px",color:"hsl(var(--muted-foreground))",borderBottom:"1px solid hsl(var(--border))",paddingBottom:8},children:[e.operator&&t.jsx("span",{children:e.operator}
1),e.timeStr&&t.jsx("span",{children:e.timeStr})]}),t.jsx("div",{style:{color:l,maxHeight:"40vh",overflowY:"auto",whiteSpace:"pre-wrap",fontSize:"13px",lineHeight:1.6},children:e.reason})]})})},F=e=>{let l=e/1e3;return l=s("{{seconds}} ç§",{seconds:l.toFixed(2)}),0===e?t.jsx(k,{color:"grey",shape:"circle",children:s("æªæµè¯")}):e<=1e3?t.jsx(k,{color:"green",shape:"circle",children:l}):e<=3e3?t.jsx(k,{color:"lime",shape:"circle",children:l}):e<=5e3?t.jsx(k,{color:"yellow",shape:"circle",children:l}):t.jsx(k,{color:"red",shape:"circle",children:l})},V={ID:"id",NAME:"name",GROUP:"group",TYPE:"type",STATUS:"status",DISABLE_REASON:"disable_reason",DISABLED_BY:"disabled_by",DISABLED_AT:"disabled_at",RESPONSE_TIME:"response_time",BALANCE:"balance",PRIORITY:"priority",WEIGHT:"weight",PRICE:"price",OPERATE:"operate"},[se,le]=e.useState({}),[ae,ie]=e.useState(!1),[re,ne]=e.useState(x()?localStorage.getItem("channel-status-filter")||"price_archived":localStorage.getItem("channel-status-filter")||"all");e.useEffect(()=>{const e=localStorage.getItem("channels-table-columns");if(e)try{const t=JSON.parse(e),s={...oe(),...t};le(s)}catch(t){console.error("Failed to parse saved column preferences",t),ce()}else ce()},[]),e.useEffect(()=>{Object.keys(se).length>0&&localStorage.setItem("channels-table-columns",JSON.stringify(se))},[se]);const oe=()=>({[V.ID]:!0,[V.NAME]:!0,[V.GROUP]:!0,[V.TYPE]:!0,[V.STATUS]:!0,[V.DISABLE_REASON]:!0,[V.DISABLED_BY]:!0,[V.DISABLED_AT]:!0,[V.RESPONSE_TIME]:!0,[V.BALANCE]:!0,[V.PRIORITY]:!0,[V.WEIGHT]:!0,[V.PRICE]:!0,[V.OPERATE]:!0}),ce=()=>{const e=oe();le(e)},de=[{key:V.ID,title:s("ID"),dataIndex:"id"},{key:V.NAME,title:s("åç§°"),dataIndex:"name",width:200,render:(e,l)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx(S,{content:s("ç¹å»å¤å¶æ¸ éåç§°"),children:t.jsx("span",{style:{wordBreak:"break-all",cursor:"pointer"},onClick:()=>d(e).then(e=>e?o(s("å·²å¤å¶æ¸ éåç§°")):r(s("å¤å¶å¤±è´¥"))),children:e})}),1===l.is_synced&&t.jsx(S,{content:s("æ¤æ¸ éä»å
¶ä»ç³»ç»åæ¥èæ¥"),children:t.jsx(k,{color:"blue",size:"small",style:{marginLeft:"4px"},children:s("忥")})})]})},{key:V.GROUP,title:s("åç»"),dataIndex:"group",width:220,render:(e,s,l)=>t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"2px"},children:e?.split(",").sort((e,t)=>"default"===e?-1:"default"===t?1:e.localeCompare(t)).map((e,t)=>g(e))})},{key:V.TYPE,title:s("ç±»å"),dataIndex:"type",render:(e,l,a)=>void 0===l.children?l.channel_info&&l.channel_info.is_multi_key?t.jsx(t.Fragment,{children:p(e,l.channel_info)}):t.jsx(t.Fragment,{children:p(e)}):t.jsx(t.Fragment,{children:t.jsx(k,{color:"light-blue",shape:"circle",type:"light",children:s("æ ç¾èå")})})},{key:V.STATUS,title:s("ç¶æ"),dataIndex:"status",width:140,render:(e,s,l)=>t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[$(e,s.channel_info),!c&&W(s)]})},{key:V.DISABLE_REASON,title:s("ç¦ç¨åå "),dataIndex:"other_info",render:(e,l)=>{if(2!==l.status&&3!==l.status)return c?null:"-";const a=P(l);return a?c?(e=>{if(2!==e.status&&3!==e.status)return null;const l=P(e);if(!l)return null;const a=3===e.status?"hsl(var(--warning))":"hsl(var(--destructive))",i=l.reason.length>16?l.reason.slice(0,16)+"â¦":l.reason;return t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"4px",fontSize:"12px",lineHeight:"1.4",width:"100%"},children:[t.jsx("span",{style:{color:a,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i}),t.jsx("span",{style:{color:"hsl(var(--primary))",cursor:"pointer",whiteSpace:"nowrap",marginLeft:8,flexShrink:0},onClick:e=>{e.stopPropagation(),D(l,a)},children:s("ç¹å»æ¥ç")})]})})(l):t.jsx("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",lineHeight:"1.4",wordBreak:"break-word",maxWidth:"200px"},children:a.reason}):c?null:"-"}},{key:V.DISABLED_BY,title:s("ç¦ç¨äºº"),dataIndex:"other_info",render:(e,s)=>{const l=P(s);return l?.operator?t.jsx("span",{style:{fontSize:"13px"},children:l.operator}):c?null:"-"}},{key:V.DISABLED_AT,title:s("ç¦ç¨æ¶é´"),dataIndex:"other_info",render:(e,s)=>{const l=P(s);return l?.timeStr?t.jsx("span",{style:{fontSize:"13px",whiteSpace:"nowrap"},children:l.timeStr}):c?null:"-"}},{key:V.RESPONSE_TIME,title:s("ååºæ¶é´"),dataIndex:"response_time",render:(e,s,l)=>t.jsx("div",{children:F(e)})},{key:V.BALANCE,title:s("å·²ç¨/å©ä½"),dataIndex:"expired_time",render:(e,l,a)=>void 0===l.children?t.jsx("div",{children:t.jsxs(z,{spacing:1,children:[t.jsx(S,{content:s("ç¹å»å¤å¶å·²ç¨é¢åº¦"),children:t.jsx(k,{color:"white",type:"ghost",shape:"circle",style:{cursor:"pointer"},onClick:()=>{const e=y(l.used_quota);d(e).then(e=>e?o(s("å·²å¤å¶å·²ç¨é¢åº¦")):r(s("å¤å¶å¤±è´¥")))},children:y(l.used_quota)})}),t.jsx(S,{content:s("å©ä½é¢åº¦{{balance}}ï¼ç¹å»æ´æ°",{balance:l.balance}),children:t.jsx(k,{color:"white",type:"ghost",shape:"circle",onClick:()=>fl(l),children:_(l.balance)})})]})}):t.jsx(S,{content:s("ç¹å»å¤å¶å·²ç¨é¢åº¦"),children:t.jsx(k,{color:"white",type:"ghost",shape:"circle",style:{cursor:"pointer"},onClick:()=>{const e=y(l.used_quota);d(e).then(e=>e?o(s("å·²å¤å¶å·²ç¨é¢åº¦")):r(s("å¤å¶å¤±è´¥")))},children:y(l.used_quota)})})},{key:V.PRIORITY,title:s("ä¼å
级"),dataIndex:"priority",render:(e,l,a)=>void 0===l.children?t.jsx("div",{children:t.jsx(I,{style:{width:70},name:"priority",onBlur:e=>{sl(l.id,"priority",l,e.target.value)},keepFocus:!0,innerButtons:!0,defaultValue:l.priority,min:-999,size:"small"})}):t.jsx(I,{style:{width:70},name:"priority",keepFocus:!0,onBlur:e=>{N.warning({title:s("ä¿®æ¹åæ¸ éä¼å
级"),content:s("ç¡®å®è¦ä¿®æ¹ææåæ¸ éä¼å
级为 {{value}} åï¼",{value:e.target.value}),onOk:()=>{""!==e.target.value&&pl("priority",{tag:l.key,priority:e.target.value})}})},innerButtons:!0,defaultValue:l.priority,min:-999,size:"small"})},{key:V.WEIGHT,title:s("æé"),dataIndex:"weight",render:(e,l,a)=>void 0===l.children?t.jsx("div",{children:t.jsx(I,{style:{width:70},name:"weight",onBlur:e=>{sl(l.id,"weight",l,e.target.value)},keepFocus:!0,innerButtons:!0,defaultValue:l.weight,min:0,size:"small"})}):t.jsx(I,{style:{width:70},name:"weight",keepFocus:!0,onBlur:e=>{N.warning({title:s("ä¿®æ¹åæ¸ éæé"),content:s("ç¡®å®è¦ä¿®æ¹ææåæ¸ éæé为 {{value}} åï¼",{value:e.target.value}),onOk:()=>{""!==e.target.value&&pl("weight",{tag:l.key,weight:e.target.value})}})},innerButtons:!0,defaultValue:l.weight,min:-999,size:"small"})},{key:V.PRICE,title:s("ææ¬æ ¸ç®"),dataIndex:"recharge_price",render:(e,l,a)=>{if(void 0!==l.children)return null;const i=null!=l.recharge_price?l.recharge_price:"-",r=null!=l.group_ratio?l.group_ratio:"-",n=null!=l.price?l.price:"-";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsxs("div",{style:{fontSize:12,lineHeight:"1.5"},children:[t.jsx("div",{style:{marginBottom:2},children:(()=>{const e=l.model_cost_count||0,a=l.model_total_count||0;if(a>0&&e>=a)return t.jsx("span",{style:{fontSize:11,color:"#16a34a",background:"rgba(22,163,74,0.12)",borderRadius:4,padding:"1px 6px"},children:s("å
¨é¨å·²é
ç½®")});if(e>0){const l=Math.max(a-e,0);return t.jsxs("span",{style:{fontSize:11,color:"#d97706",background:"rgba(217,119,6,0.12)",borderRadius:4,padding:"1px 6px"},children:[s("å·²é
")," ",e,"/",a," · ",s("è¿å·®")," ",l]})}return t.jsxs("span",{style:{fontSize:11,color:"hsl(var(--muted-foreground))",background:"hsl(var(--muted))",borderRadius:4,padding:"1px 6px"},children:[s("æªé
ææ¬"),a>0?` · ${s("è¿å·®")}
1 ${a}`:""]})})()}),t.jsxs("div",{children:[t.jsxs("span",{style:{color:"hsl(var(--muted-foreground))"},children:[s("å
弿±ç"),":"]}),t.jsx("span",{style:{marginLeft:4,fontWeight:500},children:i})]}),t.jsxs("div",{children:[t.jsxs("span",{style:{color:"hsl(var(--muted-foreground))"},children:[s("åç»åç"),":"]}),t.jsx("span",{style:{marginLeft:4,fontWeight:500},children:r})]}),t.jsxs("div",{children:[t.jsxs("span",{style:{color:"hsl(var(--muted-foreground))"},children:[s("æåºä»·æ ¼"),":"]}),t.jsx("span",{style:{marginLeft:4,fontWeight:500},children:n})]})]}),t.jsx(T,{size:"small",theme:"borderless",onClick:()=>{cs(l),hs({recharge_price:null!=l.recharge_price?l.recharge_price:1,group_ratio:null!=l.group_ratio?l.group_ratio:1}),ns(!0)},children:s("ä¿®æ¹")})]})}},{key:V.OPERATE,title:"",dataIndex:"operate",fixed:"right",render:(e,l,a)=>{if(void 0===l.children){const e=[{node:"item",name:s("æåç"),onClick:()=>{It(l),zt(!0)}},{node:"item",name:s("å é¤"),type:"danger",onClick:()=>{N.confirm({title:s("ç¡®å®æ¯å¦è¦å 餿¤æ¸ éï¼"),content:s("æ¤ä¿®æ¹å°ä¸å¯é"),onOk:()=>{(async()=>{await sl(l.id,"delete",l),await tl(),setTimeout(()=>{0===me.length&&ge>1&&tl(ge-1)},100)})()}})}},{node:"item",name:s("å¤å¶"),type:"tertiary",onClick:()=>{N.confirm({title:s("ç¡®å®æ¯å¦è¦å¤å¶æ¤æ¸ éï¼"),content:s("å¤å¶æ¸ éçææä¿¡æ¯"),onOk:()=>el(l)})}}];if(c){const a={width:"100%",borderRadius:"8px",flex:1};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px",width:"100%",flex:1},children:[!x()&&t.jsxs(K,{style:{...a,display:"flex",alignItems:"stretch",width:"100%"},"aria-label":s("æµè¯åä¸ªæ¸ éæä½é¡¹ç®ç»"),children:[t.jsx(T,{type:"primary",theme:"light",style:{flex:1,height:"100%"},onClick:()=>nl(l,""),children:s("æµè¯")}),t.jsx(T,{type:"primary",theme:"light",icon:t.jsx(ye,{size:16}),style:{padding:"0 12px",height:"100%"},onClick:()=>{jt(l),_t(!0)}})]}),!x()&&(1===l.status?t.jsx(T,{size:"small",type:"danger",theme:"light",style:a,onClick:()=>sl(l.id,"disable",l),children:s("ç¦ç¨")}):t.jsx(T,{size:"small",type:"primary",theme:"light",style:a,onClick:()=>sl(l.id,"enable",l),children:s("å¯ç¨")})),!x()&&l.channel_info?.is_multi_key&&t.jsx(T,{size:"small",type:"tertiary",style:a,onClick:()=>sl(l.id,"enable_all",l),children:s("å¯ç¨å
¨é¨å¯é¥")}),x()&&5===l.status&&t.jsx(T,{size:"small",type:"primary",theme:"light",style:a,onClick:()=>{N.confirm({title:s("确认æ è®°å¯¹è´¦å®æ¯ï¼"),content:s("å°æ¸ éã{{name}}ãæ è®°ä¸ºå¯¹è´¦å®æ¯åä¸å¯æ¤é",{name:l.name}),onOk:async()=>{const e=await i.put(`/api/channel/reconcile/${l.id}`),{success:t,message:a}=e.data;t?(o(s("å·²æ è®°ä¸ºå¯¹è´¦å®æ¯")),await tl()):r(a)}})},children:s("æ 记对账")}),!x()&&t.jsx(T,{size:"small",type:"tertiary",style:a,onClick:()=>{Pe(l),$e(!0)},children:s("ç¼è¾")}),!x()&&t.jsx(T,{size:"small",type:"warning",theme:"light",style:a,icon:t.jsx(he,{size:14}),onClick:()=>{Ve(l),De(!0)},children:s("ææ¬")}),!x()&&e.map((e,s)=>t.jsx(T,{size:"small",style:a,type:"danger"===e.type?"danger":"tertiary",theme:"danger"===e.type?"light":void 0,onClick:e.onClick,children:e.name},s))]})}return t.jsxs(z,{wrap:!0,children:[!x()&&t.jsxs(K,{className:"overflow-hidden","aria-label":s("æµè¯åä¸ªæ¸ éæä½é¡¹ç®ç»"),children:[t.jsx(T,{size:"small",type:"tertiary",onClick:()=>nl(l,""),children:s("æµè¯")}),t.jsx(T,{size:"small",type:"tertiary",icon:t.jsx(ye,{size:16}),onClick:()=>{jt(l),_t(!0)}})]}),x()&&5===l.status&&t.jsx(T,{size:"small",type:"primary",theme:"light",onClick:()=>{N.confirm({title:s("确认æ è®°å¯¹è´¦å®æ¯ï¼"),content:s("å°æ¸ éã{{name}}ãæ è®°ä¸ºå¯¹è´¦å®æ¯åä¸å¯æ¤é",{name:l.name}),onOk:async()=>{const e=await i.put(`/api/channel/reconcile/${l.id}`),{success:t,message:a}=e.data;t?(o(s("å·²æ è®°ä¸ºå¯¹è´¦å®æ¯")),await tl()):r(a)}})},children:s("æ 记对账")}),!x()&&(l.channel_info?.is_multi_key?t.jsxs(K,{"aria-label":s("å¤å¯é¥æ¸ éæä½é¡¹ç®ç»"),children:[1===l.status?t.jsx(T,{type:"danger",size:"small",onClick:()=>sl(l.id,"disable",l),children:s("ç¦ç¨")}):t.jsx(T,{size:"small",onClick:()=>sl(l.id,"enable",l),children:s("å¯ç¨")}),t.jsx(q,{trigger:"click",position:"bottomRight",menu:[{node:"item",name:s("å¯ç¨å
¨é¨å¯é¥"),onClick:()=>sl(l.id,"enable_all",l)}],children:t.jsx(T,{type:"tertiary",size:"small",icon:t.jsx(ye,{size:16})})})]}):1===l.status?t.jsx(T,{type:"danger",size:"small",onClick:()=>sl(l.id,"disable",l),children:s("ç¦ç¨")}):t.jsx(T,{size:"small",onClick:()=>sl(l.id,"enable",l),children:s("å¯ç¨")})),!x()&&t.jsx(T,{type:"tertiary",size:"small",onClick:()=>{Pe(l),$e(!0)},children:s("ç¼è¾")}),!x()&&t.jsx(S,{content:s("é
ç½®æ¨¡åææ¬"),children:t.jsx(T,{icon:t.jsx(he,{size:14}),type:"warning",theme:"light",size:"small",onClick:()=>{Ve(l),De(!0)}})}),!x()&&t.jsx(q,{trigger:"click",position:"bottomRight",menu:e,children:t.jsx(T,{icon:t.jsx(_e,{size:16}),type:"tertiary",size:"small"})})]})}return t.jsxs(z,{wrap:!0,children:[t.jsx(T,{type:"tertiary",size:"small",onClick:()=>ll(l.key,"enable"),children:s("å¯ç¨å
¨é¨")}
1),t.jsx(T,{type:"tertiary",size:"small",onClick:()=>ll(l.key,"disable"),children:s("ç¦ç¨å
¨é¨")}),t.jsx(T,{type:"tertiary",size:"small",onClick:()=>{qe(!0),Ge(l.key)},children:s("ç¼è¾")})]})}}],[me,pe]=e.useState([]),[ue,xe]=e.useState(!0),[ge,be]=e.useState(1),[ke,Se]=e.useState(!1),[Ce,Ne]=e.useState(!1),[ze,Te]=e.useState(f),[Ie,Oe]=e.useState(ze),[Ae,Ee]=e.useState([]),[Be,$e]=e.useState(!1),[Me,Le]=e.useState(!1),[Je,Pe]=e.useState({id:void 0}),[We,De]=e.useState(!1),[Fe,Ve]=e.useState(null),[Ke,qe]=e.useState(!1),[Ue,Ge]=e.useState(""),[Ye,Ze]=e.useState([]),[Xe,st]=e.useState(!1),[lt,at]=e.useState(!1),[it,rt]=e.useState(""),[nt,ot]=e.useState(!1),[ct,dt]=e.useState(""),[ht,mt]=e.useState(""),[pt,ut]=e.useState(!1),[xt,gt]=e.useState(""),[yt,_t]=e.useState(!1),[ft,jt]=e.useState(null),[vt,bt]=e.useState(""),[wt,kt]=e.useState(""),[St,Ct]=e.useState(!1),[Nt,zt]=e.useState(!1),[Tt,It]=e.useState(null),[Ot,At]=e.useState({}),[Et,Rt]=e.useState(new Set),[Bt,$t]=e.useState([]),[Mt,Lt]=e.useState(!1),[Jt,Pt]=e.useState([]),[Wt,Dt]=e.useState(!1),[Ft,Vt]=e.useState(1),[Kt,qt]=e.useState("all"),[Ut,Ht]=e.useState({}),Gt=e.useRef(0),[Yt,Zt]=e.useState(null),[Xt,Qt]=ve("channels"),[es,ts]=e.useState(!1),[ss,ls]=e.useState(""),[as,is]=e.useState(null),[rs,ns]=e.useState(!1),[os,cs]=e.useState(null),[ds,hs]=e.useState({recharge_price:null,group_ratio:null}),[ms,ps]=e.useState(!1),[us,xs]=e.useState([]),[gs,ys]=e.useState(!1),_s=e.useCallback(async()=>{try{const e=await i.get("/api/smart_sorting/banned_models");e.data.success&&xs(e.data.data||[])}catch(e){}},[]),fs=e.useCallback(async(e,t)=>{try{const l=await i.post("/api/smart_sorting/unban_model",{channel_id:e,model_name:t});l.data.success?(o(s("已解é¤ç¦ç¨")),_s()):r(l.data.message)}catch(l){r(s("æä½å¤±è´¥"))}},[s,_s]),js=e.useCallback(async()=>{try{const e=await i.post("/api/smart_sorting/unban_all_models");e.data.success?(o(s("å·²å
¨é¨è§£é¤ï¼å
±")+" "+(e.data.data||0)+" "+s("个")),_s()):r(e.data.message)}catch(e){r(s("æä½å¤±è´¥"))}},[s,_s]);e.useEffect(()=>{const e="true"===localStorage.getItem("show-disable-reason");ps(e),_s()},[_s]);const vs=e.useRef(!1),[bs,ws]=e.useState(!1),[ks,Ss]=e.useState(null),[Cs,Ns]=e.useState(null),zs=e.useRef(null),[Ts,Is]=e.useState(!1),[Os,As]=e.useState(""),[Es,Rs]=e.useState(""),[Bs,$s]=e.useState(!1),[Ms,Ls]=e.useState(!1),[Js,Ps]=e.useState(null),[Ws,Ds]=e.useState([]),[Fs,Vs]=e.useState(!1),[Ks,qs]=e.useState(null),[Us,Hs]=e.useState(null),[Gs,Ys]=e.useState(!1),Zs=()=>de.filter(e=>!(!se[e.key]||!c&&e.key===V.DISABLE_REASON&&!ms)),Xs=(e,t)=>{let s=[],l={};for(let a=0;a<e.length;a++)if(e[a].key=""+e[a].id,t){let t,i=e[a].tag?e[a].tag:"";void 0===l[i]?(l[i]=1,t={key:i,id:i,tag:i,name:"æ ç¾ï¼"+i,group:"",used_quota:0,response_time:0,priority:-1,weight:-1},t.children=[],s.push(t)):t=s.find(e=>e.key===i),-1===t.priority?t.priority=e[a].priority:t.priority!==e[a].priority&&(t.priority=""),-1===t.weight?t.weight=e[a].weight:t.weight!==e[a].weight&&(t.weight=""),""===t.group?t.group=e[a].group:e[a].group.split(",").forEach((e,s)=>{-1===t.group.indexOf(e)&&(t.group+=","+e)}),t.children.push(e[a]),1===e[a].status&&(t.status=1),t.used_quota+=e[a].used_quota,t.response_time+=e[a].response_time,t.response_time=t.response_time/2}else s.push(e[a]);pe(s)},Qs=async(e,t,s,l,a=Kt,n)=>{void 0===n&&(n=re);const{searchKeyword:o,searchGroup:c,searchModel:d}=al();if(""!==o||""!==c||""!==d)return xe(!0),await il(l,a,n,e,t,s),void xe(!1);const h=++Gt.current;xe(!0);const m="all"!==a?`&type=${a}`:"",p="all"!==n?`&status=${n}`:"",u=await i.get(`/api/channel/?p=${e}&page_size=${t}&id_sort=${s}&tag_mode=${l}${m}${p}`);if(void 0===u||h!==Gt.current)return;const{success:x,message:g,data:y}=u.data;if(x){const{items:e,total:t,type_counts:s}=y;if(s){const e=Object.values(s).reduce((e,t)=>e+t,0);Ht({...s,all:e})}Xs(e,l),Oe(t)}else r(g);xe(!1)},el=async e=>{try{const t=await i.post(`/api/channel/copy/${e.id}`);t?.data?.success?(o(s("æ¸ éå¤å¶æå")),await tl()):r(t?.data?.message||s("æ¸ éå¤å¶å¤±è´¥"))}catch(t){r(s("æ¸ éå¤å¶å¤±è´¥ï¼{{message}}",{message:t?.response?.data?.message||t?.message||t}))}},tl=async(e=ge)=>{const{searchKeyword:t,searchGroup:s,searchModel:l}=al();""===t&&""===s&&""===l?await Qs(e,ze,ke,Xe):await il(Xe,Kt,re,e,ze,ke),_s()};e.useEffect(()=>{const e="true"===localStorage.getItem("id-sort"),t=parseInt(localStorage.getItem("page-size"))||f,s="true"===localStorage.getItem("enable-tag-mode"),l="true"===localStorage.getItem("enable-batch-delete");Se(e),Te(t),st(s),Le(l),Qs(1,t,e,s).then().catch(e=>{r(e)}),ml().then(),j().then()},[]);const sl=async(e,t,l,a)=>{let n,c={id:e};switch(t){case"delete":n=await i.delete(`/api/channel/${e}/`);break;case"enable":c.status=1,n=await i.put("/api/channel/",c);break;case"disable":return is({id:e,record:l}),ls(""),void ts(!0);case"priority":if(""===a)return;c.priority=parseInt(a),n=await i.put("/api/channel/",c);break;case"weight":if(""===a)return;c.weight=parseInt(a),c.weight<0&&(c.weight=0),n=await i.put("/api/channel/",c);break;case"price":if(""===a)return;c.price=parseFloat(a),c.price<0&&(c.price=0),n=await i.put("/api/channel/",c);break;case"enable_all":c.channel_info=l.channel_info,c.channel_info.multi_key_status_list={},n=await i.put("/api/channel/",c)}const{success:d,message:h}=n.data;if(d){o(s("æä½æå宿ï¼"));let e=n.data.data,a=[...me];"delete"===t||(l.status=e.status),pe(a)}else r(h)},ll=async(e,t)=>{let l;switch(t){case"enable":l=await i.post("/api/channel/tag/enabled",{tag:e});break;case"disable":l=await i.post("/api/channel/tag/disabled",{tag:e})}const{success:a,message:n}=l.data;if(a){o(s("æä½æå宿ï¼"));let l=[...me];for(let s=0;s<l.length;s++)if(l[s].tag===e){let e="enable"===t?1:2;l[s]?.children?.forEach(t=>{t.status=e}),l[s].status=e}pe(l)}else r(n)},al=()=>{const e=Yt?Yt.getValues():{};return{searchKeyword:e.searchKeyword||"",searchGroup:e.searchGroup||"",searchModel:e.searchModel||""}},il=async(e,t=Kt,s=re,l=1,a=ze,n=ke)=>{const{searchKeyword:o,searchGroup:c,searchModel:d}=al();Ne(!0);try{if(""===o&&""===c&&""===d)return void(await Qs(l,a,n,e,t,s));const h="all"!==t?`&type=${t}`:"",m="all"!==s?`&status=${s}`:"",p=await i.get(`/api/channel/search?keyword=${o}&group=${c}&model=${d}&id_sort=${n}&tag_mode=${e}&p=${l}&page_size=${a}${h}${m}`),{success:u,message:x,data:g}=p.data;if(u){const{items:t=[],total:s=0,type_counts:a={}}=g,i=Object.values(a).reduce((e,t)=>
1e+t,0);Ht({...a,all:i}),Xs(t,e),Oe(s),be(l)}else r(x)}finally{Ne(!1)}},rl=(e,t)=>{const s=[...me];let l=!1;s.forEach(s=>{void 0!==s.children?s.children.forEach(s=>{s.id===e&&(t(s),l=!0)}):s.id===e&&(t(s),l=!0)}),l&&pe(s)};e.useEffect(()=>{Jt.length>0&&Wt?(async()=>{if(!Wt||0===Jt.length)return;const{channel:e,model:t,indexInFiltered:l,endpointType:a,stream:o}=Jt[0];if(ft&&ft.id===e.id){let e;if(void 0!==l)e=Math.floor(l/b)+1;else{const s=ft.models.split(",").filter(e=>e.toLowerCase().includes(vt.toLowerCase())).indexOf(t);e=-1!==s?Math.floor(s/b)+1:1}Vt(e)}try{Rt(e=>new Set([...e,t]));let l=`/api/channel/test/${e.id}?model=${t}`;a&&(l+=`&endpoint_type=${encodeURIComponent(a)}`),o&&(l+="&stream=true");const c=await i.get(l),{success:d,message:h,time:m}=c.data;At(s=>({...s,[`${e.id}-${t}`]:{success:d,time:m}})),d?(rl(e.id,e=>{e.response_time=1e3*m,e.test_time=Date.now()/1e3}),t||n(s("éé {{name}} æµè¯æåï¼èæ¶ {{time}} ç§ã",{name:e.name,time:m.toFixed(2)}))):r(h)}catch(c){r(c.message)}finally{Rt(e=>{const s=new Set(e);return s.delete(t),s})}Pt(e=>e.slice(1))})():0===Jt.length&&Wt&&(Dt(!1),Lt(!1))},[Jt,Wt]);const nl=async(e,t,s="",l=!1)=>{Pt(a=>[...a,{channel:e,model:t,endpointType:s,stream:l}]),Wt||Dt(!0)},ol=()=>{Mt?(Pt([]),Dt(!1),Lt(!1),o(s("已忢æµè¯"))):(_t(!1),bt(""),$t([]),Vt(1),kt(""),Ct(!1))},cl=e.useMemo(()=>{if(Object.keys(Ut).length>0)return Ut;const e={all:me.length};return me.forEach(t=>{const s=t=>{const s=t.type;e[s]=(e[s]||0)+1};void 0!==t.children?t.children.forEach(s):s(t)}),e},[Ut,me]),dl=e.useMemo(()=>{const e=["all"];return Object.entries(cl).forEach(([t,s])=>{"all"!==t&&s>0&&e.push(String(t))}),e},[cl]);let hl=me;const ml=async()=>{try{let e=await i.get("/api/group/");if(void 0===e)return;const t=e.data.data;t&&t.groups?Ee(t.groups.map(e=>({label:e,value:e}))):Array.isArray(t)&&Ee(t.map(e=>({label:e,value:e})))}catch(e){r(e.message)}},pl=async(e,t)=>{switch(e){case"priority":if(void 0===t.priority||""===t.priority)return void n(s("ä¼å
级å¿
é¡»æ¯æ´æ°ï¼"));t.priority=parseInt(t.priority);break;case"weight":if(void 0===t.weight||t.weight<0||""===t.weight)return void n(s("æéå¿
é¡»æ¯éè´æ´æ°ï¼"));t.weight=parseInt(t.weight)}try{const e=await i.put("/api/channel/tag",t);e?.data?.success&&(o(s("æ´æ°æå")+"ï¼"),await tl())}catch(l){r(l)}},ul=async e=>{ws(!0),Is(!1);const{searchKeyword:t,searchGroup:l,searchModel:a}=al();let n=[];try{const e="all"!==Kt?`&type=${Kt}`:"",s="all"!==re?`&status=${re}`:"";let o;o=""!==t||""!==l||""!==a?await i.get(`/api/channel/search?keyword=${t}&group=${l}&model=${a}&id_sort=${ke}&tag_mode=false&p=1&page_size=9999${e}${s}`):await i.get(`/api/channel/?p=1&page_size=9999&id_sort=${ke}&tag_mode=false${e}${s}`);const{success:c,message:d,data:h}=o.data;if(!c)return r(d),void ws(!1);n=(h.items||[]).filter(e=>void 0===e.children)}catch(c){return r(c.message),void ws(!1)}if(0===n.length)return r(s("æ²¡ææ¾å°ç¬¦åæ¡ä»¶çæ¸ é")),void ws(!1);const o=n.map(t=>({channel_id:t.id,model:e||""}));try{const e=await i.post("/api/channel/batch_test",{items:o}),{success:t,message:s,data:l}=e.data;if(!t)return r(s),void ws(!1);Ss(l.task_id),Ns(l),$s(!0),qs(l.task_id),Hs(l),xl(l.task_id)}catch(c){r(c.message),ws(!1)}},xl=e=>{zs.current&&clearInterval(zs.current),zs.current=setInterval(async()=>{try{const t=await i.get(`/api/channel/batch_test/${e}`),{success:l,data:a}=t.data;if(!l)return clearInterval(zs.current),void ws(!1);Hs(a),Ns(a),"done"===a.status&&(clearInterval(zs.current),ws(!1),o(s("æ¹éæµè¯å®æï¼æå {{s}} 个ï¼å¤±è´¥ {{f}} 个",{s:a.succeeded,f:a.failed})),gl())}catch(t){clearInterval(zs.current),ws(!1)}},1500)},gl=async()=>{Vs(!0);try{const e=await i.get("/api/channel/batch_test_list"),{success:t,data:s}=e.data;t&&Ds(s||[])}catch(e){}finally{Vs(!1)}},yl=()=>{$s(!0),gl()},_l=(e,l,a=!0)=>t.jsx("div",{className:"py-1"+(e.success?"":" cursor-pointer"),style:{borderBottom:"1px solid hsl(var(--border))",fontSize:12},onClick:e.success?void 0:()=>Ps(e),children:c?t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(k,{color:e.success?"green":"red",size:"small",children:e.success?s("æå"):s("失败")}),t.jsx(w.Text,{size:"small",strong:!0,ellipsis:!0,style:{maxWidth:160},children:e.channel_name}),a&&t.jsxs(w.Text,{size:"small",type:"secondary",children:["#",e.channel_id]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pl-1",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(k,{size:"small",color:"blue",children:e.model}),e.success?t.jsxs(w.Text,{size:"small",type:"tertiary",children:[e.time.toFixed(2),"s"]}):t.jsx(w.Text,{size:"small",type:"danger",ellipsis:!0,style:{maxWidth:160},children:e.message})]}),!e.success&&t.jsxs(w.Text,{size:"small",type:"danger",style:{flexShrink:0},children:[s("æ¥ç")," âº"]}
1)]})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(k,{color:e.success?"green":"red",size:"small",children:e.success?s("æå"):s("失败")}),t.jsx(w.Text,{size:"small",strong:!0,children:e.channel_name}),a&&t.jsxs(w.Text,{size:"small",type:"secondary",children:["#",e.channel_id]}),t.jsx(k,{size:"small",color:"blue",children:e.model}),e.success?t.jsxs(w.Text,{size:"small",type:"tertiary",children:[e.time.toFixed(2),"s"]}):t.jsx(S,{content:e.message,children:t.jsx(w.Text,{size:"small",type:"danger",ellipsis:!0,style:{maxWidth:200,cursor:"pointer"},children:e.message})})]})},l);e.useEffect(()=>{if(c&&Bs){const e=window.scrollY;return document.body.style.position="fixed",document.body.style.top=`-${e}px`,document.body.style.width="100%",document.body.style.overflowY="scroll",()=>{document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflowY="",window.scrollTo(0,e)}}},[Bs,c]);const fl=async e=>{const t=await i.get(`/api/channel/update_balance/${e.id}/`),{success:l,message:a,balance:o}=t.data;l?(rl(e.id,e=>{e.balance=o,e.balance_updated_time=Date.now()/1e3}),n(s("éé {{name}} ä½é¢æ´æ°æåï¼",{name:e.name}))):r(a)};return t.jsxs(t.Fragment,{children:[t.jsxs(N,{title:s("å设置"),visible:ae,onCancel:()=>ie(!1),footer:t.jsxs("div",{className:"flex justify-end",children:[t.jsx(T,{onClick:()=>ce(),children:s("éç½®")}),t.jsx(T,{onClick:()=>ie(!1),children:s("åæ¶")}),t.jsx(T,{onClick:()=>ie(!1),children:s("ç¡®å®")})]}),children:[t.jsx("div",{style:{marginBottom:20},children:t.jsx(O,{checked:Object.values(se).every(e=>!0===e),indeterminate:Object.values(se).some(e=>!0===e)&&!Object.values(se).every(e=>!0===e),onChange:e=>(e=>{const t=Object.keys(V).map(e=>V[e]),s={};t.forEach(t=>{s[t]=e}),le(s)})(e.target.checked),children:s("å
¨é")})}),t.jsx("div",{className:"flex flex-wrap max-h-96 overflow-y-auto rounded-lg p-4",style:{border:"1px solid hsl(var(--border))"},children:de.map(e=>e.title?t.jsx("div",{className:"w-1/2 mb-4 pr-2",children:t.jsx(O,{checked:!!se[e.key],onChange:t=>((e,t)=>{const s={...se,[e]:t};le(s)})(e.key,t.target.checked),children:e.title})},e.key):null)})]}),t.jsx(Qe,{visible:Ke,tag:Ue,handleClose:()=>qe(!1),refresh:tl}),t.jsx(He,{refresh:tl,visible:Be,handleClose:()=>{$e(!1)},editingChannel:Je}),Fe&&t.jsx(Re,{channelId:Fe.id,models:Fe.models?Fe.models.split(","):[],isEdit:!0,visible:We,onClose:()=>{De(!1),Ve(null),tl()}}),us.length>0&&t.jsxs("div",{className:"mb-3",style:{borderRadius:12,borderLeft:"4px solid hsl(var(--destructive))",background:"hsl(var(--card))",boxShadow:"var(--app-shadow-md)",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",cursor:"pointer",userSelect:"none",flexWrap:"wrap",gap:8},onClick:()=>ys(e=>!e),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[t.jsx("span",{style:{color:"hsl(var(--destructive))",fontWeight:600,fontSize:14,transition:"transform 0.2s",display:"inline-block",transform:gs?"rotate(90deg)":"rotate(0deg)",flexShrink:0},children:"â¶"}),t.jsx("span",{style:{color:"hsl(var(--destructive))",fontWeight:600,whiteSpace:"nowrap"},children:s("临æ¶ç¦ç¨ç模å")}),t.jsx(k,{color:"red",size:"small",shape:"circle",children:us.length})]}),t.jsxs("div",{style:{display:"flex",gap:8},onClick:e=>e.stopPropagation(),children:[t.jsx(T,{size:"small",type:"tertiary",onClick:_s,children:s("å·æ°")}),t.jsx(T,{size:"small",type:"danger",onClick:()=>{N.confirm({title:s("确认å
¨é¨è§£é¤"),content:s("å°è§£é¤ææä¸´æ¶ç¦ç¨å¹¶éç½®å级计æ°ï¼ç¡®å®ç»§ç»ï¼"),onOk:js,centered:!0})},children:s("å
¨é¨è§£é¤")})]})]}),gs&&t.jsxs("div",{style:{padding:"0 16px 12px"},children:[t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:6},children:us.map((e,l)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",background:"hsl(var(--destructive) / 0.12)",borderRadius:6,padding:"6px 10px",gap:8,fontSize:13,lineHeight:1.4,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0,flexWrap:"wrap"},children:[t.jsx(S,{content:s("ç¹å»å¤å¶æ¸ éID"),children:t.jsxs("span",{style:{cursor:"pointer",fontWeight:600,color:"hsl(var(--destructive))",whiteSpace:"nowrap"},onClick:()=>d(String(e.channel_id)).then(t=>t&&o(s("å·²å¤å¶")+": "+e.channel_id)),children:["#",e.channel_id]})}),e.channel_name&&t.jsx(S,{content:s("ç¹å»å¤å¶æ¸ éå"),children:t.jsx("span",{style:{cursor:"pointer",color:"hsl(var(--muted-foreground))",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:120},onClick:()=>d(e.channel_name).then(t=>t&&o(s("å·²å¤å¶")+": "+e.channel_name)),children:e.channel_name})}),t.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.60)"},children:"/"}),t.jsx(S,{content:s("ç¹å»å¤å¶æ¨¡åå"),children:t.jsx("span",{style:{cursor:"pointer",fontWeight:500,color:"hsl(var(--destructive))",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onClick:()=>d(e.model_name).then(t=>t&&o(s("å·²å¤å¶")+": "+e.model_name)),children:e.model_name})}),e.ttl>0&&t.jsxs("span",{style:{opacity:.6,fontSize:11,whiteSpace:"nowrap",flexShrink:0},children:[Math.ceil(e.ttl/60),s("åé")]})]}),t.jsx(T,{size:"small",type:"danger",theme:"borderless",style:{flexShrink:0,padding:"0 4px"},onClick:()=>fs(e.channel_id,e.model_name),children:s("è§£é¤")})]},`${e.channel_id}-${e.model_name}-${l}`))}),t.jsx(w.Text,{type:"tertiary",size:"small",style:{display:"block",marginTop:8},children:s("è¿ç»è¶
æ¶å被临æ¶ç¦ç¨ï¼å°æèªå¨æ¢å¤ãåå¤è¶
æ¶å°èªå¨å»¶é¿ç¦ç¨æ¶é´ãç¹å»å¯å¤å¶ï¼å³ä¾§æé®è§£é¤ç¦ç¨å¹¶éç½®å级ã")})]})]}),t.jsx(L,{className:"!rounded-2xl channel-table-card-toolbar-host",title:t.jsxs("div",{className:"flex flex-col w-full",children:[Xe?null:t.jsxs(ee,{activeKey:Kt,type:"card",collapsible:!0,onChange:e=>{qt(e),be(1),Qs(1,ze,ke,Xe,e)},className:"mb-4",children:[t.jsx(te,{itemKey:"all",tab:t.jsxs("span",{className:"flex items-center gap-2",children:[s("å
¨é¨"),t.jsx(k,{color:"all"===Kt?"red":"grey",shape:"circle",children:cl.all||0})]})}),v.filter(e=>dl.includes(String(e.value))).map(e=>
1{const s=String(e.value),l=cl[e.value]||0;return t.jsx(te,{itemKey:s,tab:t.jsxs("span",{className:"flex items-center gap-2",children:[u(e.value),e.label,t.jsx(k,{color:Kt===s?"red":"grey",shape:"circle",children:l})]})},s)})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 w-full min-w-0",children:[!x()&&t.jsx(T,{size:"small",disabled:!Me,type:"danger",className:"order-2 md:order-1 "+(c?"w-full basis-full shrink-0":"shrink-0 w-auto max-w-full"),onClick:()=>{N.confirm({title:s("ç¡®å®æ¯å¦è¦å 餿éééï¼"),content:s("æ¤ä¿®æ¹å°ä¸å¯é"),onOk:()=>(async()=>{if(0===Ye.length)return void r(s("请å
éæ©è¦å é¤çééï¼"));xe(!0);let e=[];Ye.forEach(t=>{e.push(t.id)});const t=await i.post("/api/channel/batch",{ids:e}),{success:l,message:a,data:n}=t.data;l?(o(s("å·²å é¤ ${data} 个ééï¼").replace("${data}",n)),await tl(),setTimeout(()=>{0===me.length&&ge>1&&tl(ge-1)},100)):r(a),xe(!1)})()})},children:s("å 餿ééé")}),!x()&&t.jsx(T,{size:"small",disabled:!Me,type:"tertiary",onClick:()=>at(!0),className:"order-2 md:order-1 "+(c?"w-full basis-full shrink-0":"shrink-0 w-auto max-w-full"),children:s("æ¹é设置æ ç¾")}),!x()&&t.jsx(T,{size:"small",type:"tertiary",onClick:()=>ot(!0),className:"order-2 md:order-1 "+(c?"w-full basis-full shrink-0":"shrink-0 w-auto max-w-full"),children:s("æ¹éè¿½å æ¨¡å")}),!x()&&t.jsx(T,{size:"small",type:"tertiary",onClick:()=>ut(!0),className:"order-2 md:order-1 "+(c?"w-full basis-full shrink-0":"shrink-0 w-auto max-w-full"),children:s("æ¹éç§»é¤æ¨¡å")}),!x()&&t.jsx(q,{className:"order-2 md:order-1",size:"small",trigger:"click",render:t.jsxs(q.Menu,{children:[t.jsx(q.Item,{children:t.jsx(T,{size:"small",type:"tertiary",className:"w-full",onClick:()=>{N.confirm({title:s("ç¡®å®")+"ï¼",content:s("ç¡®å®è¦æµè¯ææééåï¼"),onOk:()=>(async()=>{const e=await i.get("/api/channel/test"),{success:t,message:l}=e.data;t?n(s("å·²æåå¼å§æµè¯ææå·²å¯ç¨ééï¼è¯·å·æ°é¡µé¢æ¥çç»æã")):r(l)})(),size:"small",centered:!0})},children:s("æµè¯ææéé")})}),t.jsx(q.Item,{children:t.jsx(T,{size:"small",className:"w-full",onClick:()=>{N.confirm({title:s("ç¡®å®æ¯å¦è¦ä¿®å¤æ°æ®åºä¸è´æ§ï¼"),content:s("è¿è¡è¯¥æä½æ¶ï¼å¯è½å¯¼è´æ¸ é访é®é误ï¼è¯·ä»
卿°æ®åºåºç°é®é¢æ¶ä½¿ç¨"),onOk:()=>(async()=>{const e=await i.post("/api/channel/fix"),{success:t,message:l,data:a}=e.data;t?(o(s("å·²ä¿®å¤ ${success} 个ééï¼å¤±è´¥ ${fails} 个ééã").replace("${success}",a.success).replace("${fails}",a.fails)),await tl()):r(l)})(),size:"sm",centered:!0})},children:s("ä¿®å¤æ°æ®åºä¸è´æ§")})}),t.jsx(q.Item,{children:t.jsx(T,{size:"small",type:"secondary",className:"w-full",onClick:()=>{N.confirm({title:s("ç¡®å®")+"ï¼",content:s("ç¡®å®è¦æ´æ°ææå·²å¯ç¨ééä½é¢åï¼"),onOk:()=>(async()=>{const e=await i.get("/api/channel/update_balance"),{success:t,message:l}=e.data;t?n(s("å·²æ´æ°å®æ¯ææå·²å¯ç¨ééä½é¢ï¼")):r(l)})(),size:"sm",centered:!0})},children:s("æ´æ°ææå·²å¯ç¨ééä½é¢")})}),t.jsx(q.Item,{children:t.jsx(T,{size:"small",type:"danger",className:"w-full",onClick:()=>{N.confirm({title:s("ç¡®å®æ¯å¦è¦å é¤ç¦ç¨ééï¼"),content:s("æ¤ä¿®æ¹å°ä¸å¯é"),onOk:()=>(async()=>{const e=await i.delete("/api/channel/disabled"),{success:t,message:l,data:a}=e.data;t?(o(s("å·²å 餿æç¦ç¨æ¸ éï¼å
±è®¡ {{num}} 个",{num:a})),await tl()):r(l)})(),size:"sm",centered:!0})},children:s("å é¤ç¦ç¨éé")})})]}),children:t.jsx(T,{size:"small",theme:"light",type:"tertiary",className:c?"w-full basis-full shrink-0":"shrink-0 w-auto max-w-full",children:s("æ¹éæä½")})}),t.jsx(T,{size:"small",type:"tertiary",className:"order-2 md:order-1 "+(c?"w-full basis-full shrink-0":"shrink-0 w-auto max-w-full"),onClick:()=>Qt(!Xt),children:s(Xt?"èªéåºå表":"ç´§åå表")}),!c&&t.jsxs("div",{className:"flex items-center gap-2 shrink-0 w-full sm:w-auto order-1 md:order-2",children:[t.jsx(w.Text,{strong:!0,children:s("æ¾ç¤ºç¦ç¨åå ")}),t.jsx(Y,{size:"small",checked:ms,onChange:e=>{ps(e),localStorage.setItem("show-disable-reason",e+"")}})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0 w-full sm:w-auto order-1 md:order-2",children:[t.jsx(w.Text,{strong:!0,children:s("使ç¨IDæåº")}),t.jsx(Y,{size:"small",checked:ke,onChange:e=>{localStorage.setItem("id-sort",e+""),Se(e);const{searchKeyword:t,searchGroup:s,searchModel:l}=al();""===t&&""===s&&""===l?Qs(ge,ze,e,Xe):il(Xe,Kt,re,ge,ze,e)}})]}),!x()&&t.jsxs("div",{className:"flex items-center gap-2 shrink-0 w-full sm:w-auto order-1 md:order-2",children:[t.jsx(w.Text,{strong:!0,children:s("å¼å¯æ¹éæä½")}
1),t.jsx(Y,{size:"small",checked:Me,onChange:e=>{localStorage.setItem("enable-batch-delete",e+""),Le(e)}})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0 w-full sm:w-auto order-1 md:order-2",children:[t.jsx(w.Text,{strong:!0,children:s("æ ç¾è忍¡å¼")}),t.jsx(Y,{size:"small",checked:Xe,onChange:e=>{localStorage.setItem("enable-tag-mode",e+""),st(e),be(1),Qs(1,ze,ke,e)}})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 shrink-0 w-full sm:w-auto min-w-0 order-1 md:order-2",children:[t.jsx(w.Text,{strong:!0,className:"shrink-0",children:s("ç¶æçé")}),t.jsxs(C,{size:"small",className:"shrink-0 w-full min-w-0 sm:w-auto sm:min-w-[168px] max-w-full",value:re,onChange:e=>{localStorage.setItem("channel-status-filter",e),ne(e),be(1),Qs(1,ze,ke,Xe,Kt,e)},children:[t.jsx(C.Option,{value:"all",children:s("å
¨é¨")}),t.jsx(C.Option,{value:"enabled",children:s("å·²å¯ç¨")}),t.jsx(C.Option,{value:"disabled",children:s("å·²ç¦ç¨")}),t.jsx(C.Option,{value:"auto_disabled",children:s("èªå¨ç¦ç¨")}),t.jsx(C.Option,{value:"reconciled",children:s("å¯¹è´¦å®æ¯")}),t.jsx(C.Option,{value:"price_archived",children:s("ä»·æ ¼å½æ¡£")})]})]})]}),t.jsx(Q,{margin:"12px"}),t.jsxs("div",{className:"flex flex-col lg:flex-row lg:justify-between lg:items-center gap-4 w-full",children:[t.jsxs("div",{className:"flex flex-wrap gap-2 w-full lg:w-auto order-2 lg:order-1",children:[!x()&&t.jsx(T,{size:"small",theme:"light",type:"primary",onClick:()=>{Pe({id:void 0}),$e(!0)},children:s("æ·»å æ¸ é")}),t.jsx(T,{size:"small",type:"tertiary",onClick:tl,children:s("å·æ°")}),c?t.jsx(q,{trigger:"custom",visible:Ms,onVisibleChange:Ls,position:"bottomLeft",render:t.jsxs(q.Menu,{children:[t.jsx(q.Item,{onClick:()=>{Ls(!1),ie(!0)},children:s("å设置")}),!x()&&t.jsx(q.Item,{disabled:bs,onClick:()=>{bs||(Ls(!1),As(al().searchModel||""),Rs(""),Is(!0))},children:s(bs?"æµè¯ä¸...":"æ¹éæµè¯")}),t.jsx(q.Item,{onClick:()=>{Ls(!1),yl()},children:s("æµè¯è®°å½")})]}),children:t.jsx(T,{size:"small",type:"tertiary",icon:t.jsx(_e,{size:16}),onClick:()=>Ls(e=>!e),children:s("æ´å¤")})}):t.jsxs(t.Fragment,{children:[t.jsx(T,{size:"small",type:"tertiary",onClick:()=>ie(!0),children:s("å设置")}),!x()&&t.jsx(T,{size:"small",type:"tertiary",loading:bs,disabled:bs,onClick:()=>{bs||(As(al().searchModel||""),Rs(""),Is(!0))},children:s("æ¹éæµè¯")}),t.jsx(T,{size:"small",type:"tertiary",onClick:yl,children:s("æµè¯è®°å½")})]})]}),t.jsx("div",{className:"flex flex-col lg:flex-row lg:items-center gap-4 w-full lg:w-auto order-1 lg:order-2",children:t.jsxs(M,{initValues:{searchKeyword:"",searchGroup:"",searchModel:""},getFormApi:e=>Zt(e),onSubmit:()=>il(Xe),allowEmpty:!0,autoComplete:"on",layout:"horizontal",trigger:"change",stopValidateWithError:!1,className:"flex flex-col lg:flex-row lg:items-center gap-4 w-full",children:[t.jsx("div",{className:"relative w-full lg:w-64",children:t.jsx(M.Input,{size:"small",field:"searchKeyword",name:"channels_search_keyword",prefix:t.jsx(fe,{size:16}),placeholder:s("æ¸ éIDï¼åç§°ï¼å¯é¥ï¼APIå°å"),showClear:!0,pure:!0})}),t.jsx("div",{className:"w-full lg:w-48",children:t.jsx(M.Input,{size:"small",field:"searchModel",name:"channels_search_model",prefix:t.jsx(fe,{size:16}),placeholder:s("模åå
³é®å"),showClear:!0,pure:!0})}),t.jsx("div",{className:"w-full lg:w-48",children:t.jsx(M.Select,{size:"small",filter:!0,field:"searchGroup",placeholder:s("éæ©åç»"),optionList:[{label:s("éæ©åç»"),value:null},...Ae],className:"w-full",showClear:!0,pure:!0,onChange:()=>{setTimeout(()=>{il(Xe)},0)}})}),t.jsxs("div",{className:"flex gap-2 w-full lg:w-auto",children:[t.jsx(T,{size:"small",type:"tertiary",htmlType:"submit",loading:ue||Ce,className:"flex-1 lg:flex-none",children:s("æ¥è¯¢")}),t.jsx(T,{size:"small",type:"tertiary",onClick:()=>{Yt&&(Yt.reset(),setTimeout(()=>{tl()},100))},className:"flex-1 lg:flex-none",children:s("éç½®")})]})]})})]})]}),shadows:"always",bordered:!1,children:t.jsx(we,{swipeRevealRender:c?e=>{const l=P(e);if(!l)return null;const a=3===e.status?"hsl(var(--warning))":"hsl(var(--destructive))";return t.jsxs("div",{style:{width:"100%",padding:"0 6px",textAlign:"center",cursor:"pointer"},onClick:e=>{e.stopPropagation(),D(l,a)},children:[t.jsx("div",{style:{fontSize:"10px",color:"hsl(var(--muted-foreground))",marginBottom:2},children:s("ç¦ç¨åå ")}),t.jsx("div",{style:{fontSize:"11px",color:a,lineHeight:1.3,wordBreak:"break-word"},children:l.reason}),(l.operator||l.timeStr)&&t.jsxs("div",{style:{fontSize:"10px",color:"hsl(var(--muted-foreground))",marginTop:4,lineHeight:1.3}
1,children:[l.operator&&t.jsx("div",{children:l.operator}),l.timeStr&&t.jsx("div",{children:l.timeStr})]}),t.jsx("div",{style:{fontSize:"10px",color:"hsl(var(--primary))",marginTop:4},children:s("ç¹å»æ¥ç")})]})}:void 0,swipeColumnKeys:c?[V.OPERATE]:void 0,swipeRevealWidth:140,swipeColumnWidth:180,columns:Xt?Zs().map(({fixed:e,...t})=>t):Zs(),dataSource:hl,scroll:Xt?void 0:{x:"max-content"},pagination:{currentPage:ge,pageSize:ze,total:Ie,pageSizeOpts:[10,20,50,100],showSizeChanger:!0,formatPageText:e=>s("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:Ie}),onPageSizeChange:e=>{(async e=>{localStorage.setItem("page-size",e+""),Te(e),be(1),h.current=!0;const{searchKeyword:t,searchGroup:s,searchModel:l}=al();try{""===t&&""===s&&""===l?await Qs(1,e,ke,Xe):await il(Xe,Kt,re,1,e,ke)}catch(a){r(a)}finally{h.current=!1}})(e)},onPageChange:e=>{if(h.current)return;const{searchKeyword:t,searchGroup:s,searchModel:l}=al();be(e),""===t&&""===s&&""===l?Qs(e,ze,ke,Xe).then(()=>{}):il(Xe,Kt,re,e,ze,ke)}},expandAllRows:!1,onRow:(e,t)=>{let s={};return 1!==e.status&&(s={background:"hsl(var(--border))"}),{style:s}},rowSelection:Me?{onChange:(e,t)=>
1{Ze(t)}}:null,empty:t.jsx(E,{image:t.jsx(H,{style:{width:150,height:150}}),darkModeImage:t.jsx(U,{style:{width:150,height:150}}),description:s("æç´¢æ ç»æ"),style:{padding:30}}),className:"rounded-xl overflow-hidden",size:"middle",loading:ue||Ce})}),t.jsxs(N,{title:s("æ¹éæµè¯æ¸ é"),visible:Ts,onOk:()=>{const e=Os.trim();e?(Rs(""),ul(e)):Rs(s("请è¾å
¥è¦æµè¯ç模ååç§°"))},onCancel:()=>{Is(!1),Rs("")},okText:s("å¼å§æµè¯"),cancelText:s("åæ¶"),maskClosable:!1,centered:!0,size:c?"full-width":"small",children:[t.jsx("div",{className:"mb-2",children:t.jsxs(w.Text,{children:[s("请è¾å
¥è¦æµè¯ç模ååç§°"),t.jsx(w.Text,{type:"danger",children:" *"})]})}),t.jsx(G,{placeholder:s(c?"ä¾å¦ï¼gpt-4oãgemini-2.0-flash":"ä¾å¦ï¼gpt-4oãgemini-2.0-flashãgemini-3.1-flash-image-preview"),value:Os,onChange:e=>{As(e),e.trim()&&Rs("")},validateStatus:Es?"error":void 0,showClear:!0,autoFocus:!0,onEnterPress:()=>{const e=Os.trim();e?(Rs(""),ul(e)):Rs(s("请è¾å
¥è¦æµè¯ç模ååç§°"))}}),Es&&t.jsx(w.Text,{type:"danger",size:"small",style:{marginTop:4,display:"block"},children:Es}),t.jsx("div",{className:"mt-3",children:t.jsx(w.Text,{type:"secondary",size:"small",children:s("channels_table_hint_001")})})]}),t.jsxs(N,{title:s("æ¹é设置æ ç¾"),visible:lt,onOk:async()=>{if(0===Ye.length)return void r(s("请å
éæ©è¦è®¾ç½®æ ç¾çæ¸ éï¼"));if(""===it)return void r(s("æ ç¾ä¸è½ä¸ºç©ºï¼"));let e=Ye.map(e=>e.id);const t=await i.post("/api/channel/batch/tag",{ids:e,tag:""===it?null:it});t.data.success?(o(s("已为 {{num}} ä¸ªæ¸ é设置æ ç¾ï¼",{num:t.data.data})),await tl(),at(!1)):r(t.data.message)},onCancel:()=>at(!1),maskClosable:!1,centered:!0,size:"small",className:"!rounded-lg",children:[t.jsx("div",{className:"mb-5",children:t.jsx(w.Text,{children:s("请è¾å
¥è¦è®¾ç½®çæ ç¾åç§°")})}),t.jsx(G,{placeholder:s("请è¾å
¥æ ç¾åç§°"),value:it,onChange:e=>rt(e)}),t.jsx("div",{className:"mt-4",children:t.jsx(w.Text,{type:"secondary",children:s("已鿩 {{num}} ä¸ªæ¸ é",{num:Ye.length})})})]}),t.jsxs(N,{title:s("æ¹éè¿½å æ¨¡å"),visible:nt,onOk:async()=>{if(""===ct.trim()||""===ht.trim())return void r(s("åèæ¨¡ååç®æ 模åä¸è½ä¸ºç©ºï¼"));const e=await i.post("/api/channel/batch/add_model",{source_model:ct.trim(),target_model:ht.trim()});e.data.success?(o(s("已为 {{num}} ä¸ªæ¸ éè¿½å æ¨¡åï¼",{num:e.data.data})),await tl(),ot(!1),dt(""),mt("")):r(e.data.message)},onCancel:()=>{ot(!1),dt(""),mt("")},maskClosable:!1,centered:!0,size:"small",className:"!rounded-lg",children:[t.jsx("div",{className:"mb-3",children:t.jsx(w.Text,{children:s("åèæ¨¡åï¼å«æ¤æ¨¡åçæ¸ éå°è¢«æ´æ°ï¼")})}),t.jsx(G,{placeholder:s("ä¾å¦ï¼claude-opus-4-6"),value:ct,onChange:e=>dt(e),className:"mb-4"}),t.jsx("div",{className:"mb-3",children:t.jsx(w.Text,{children:s("ç®æ 模åï¼è¿½å å°è¿äºæ¸ éä¸ï¼")})}),t.jsx(G,{placeholder:s("ä¾å¦ï¼claude-sonnet-4-6"),value:ht,onChange:e=>mt(e)}),t.jsx("div",{className:"mt-4",children:t.jsx(w.Text,{type:"secondary",children:s("ç³»ç»å°èªå¨æ¥æ¾ææå
å«åèæ¨¡åçæ¸ éï¼å¹¶å°ç®æ 模å追å å°å
¶æ¨¡åå表ä¸ãå·²å
å«ç®æ 模åçæ¸ éå°è¢«è·³è¿ã")})})]}),t.jsxs(N,{title:s("æ¹éç§»é¤æ¨¡å"),visible:pt,onOk:async()=>{if(""===xt.trim())return void r(s("ç®æ 模åä¸è½ä¸ºç©ºï¼"));const e=await i.post("/api/channel/batch/remove_model",{target_model:xt.trim()});e.data.success?(o(s("å·²ä» {{num}} ä¸ªæ¸ éç§»é¤æ¨¡åï¼",{num:e.data.data})),await tl(),ut(!1),gt("")):r(e.data.message)},onCancel:()=>{ut(!1),gt("")},maskClosable:!1,centered:!0,size:"small",className:"!rounded-lg",children:[t.jsx("div",{className:"mb-3",children:t.jsx(w.Text,{children:s("ç®æ 模åï¼å°ä»ææå
嫿¤æ¨¡åçæ¸ éä¸ç§»é¤ï¼")})}),t.jsx(G,{placeholder:s("ä¾å¦ï¼claude-opus-4-6"),value:xt,onChange:e=>gt(e)}),t.jsx("div",{className:"mt-4",children:t.jsx(w.Text,{type:"secondary",children:s("ç³»ç»å°èªå¨æ¥æ¾ææå
å«è¯¥æ¨¡åçæ¸ éï¼å¹¶å°å
¶ä»æ¨¡åå表ä¸ç§»é¤ã")})})]}),t.jsx(N,{title:ft&&t.jsxs("div",{className:"flex flex-col gap-2 w-full",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(w.Text,{strong:!0,className:"!text-[hsl(var(--foreground))] !text-base",children:[ft.name," ",s("æ¸ éçæ¨¡åæµè¯")]}),t.jsx(w.Text,{type:"tertiary",className:"!text-xs flex items-center",children:s("å
± {{num}} 个模å",{num:ft.models.split(",").length})})]}),t.jsxs("div",{className:"flex items-center justify-end gap-2 w-full",children:[t.jsx(G,{placeholder:s("æç´¢æ¨¡å..."),value:vt,onChange:e=>{bt(e),Vt(1)},className:"!w-full",prefix:t.jsx(fe,{size:16}),showClear:!0}),t.jsx(T,{theme:"light",onClick:()=>{0!==Bt.length?d(Bt.join(",")).then(e=>{e?o(s("å·²å¤å¶ {{num}} 个模å",{num:Bt.length})):r(s("å¤å¶å¤±è´¥ï¼è¯·æå¨å¤å¶"))}
1):r(s("请å
éæ©æ¨¡å")+"ï¼")},children:s("å¤å¶å·²é")}),t.jsx(T,{theme:"light",type:"primary",onClick:()=>{if(!ft)return;const e=ft.models.split(",").filter(e=>e.toLowerCase().includes(vt.toLowerCase())).filter(e=>{const t=Ot[`${ft.id}-${e}`];return t&&t.success});0===e.length&&n(s("ææ æå模å")),$t(e)},children:s("éæ©æå")})]}),t.jsxs("div",{className:"flex items-center gap-3 w-full flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(w.Text,{type:"tertiary",className:"!text-xs whitespace-nowrap",children:s("æµè¯ç«¯ç¹ç±»å")}),t.jsx(C,{value:wt,onChange:e=>{kt(e),["embedding","image-generation","jina-rerank"].includes(e)&&Ct(!1)},style:{width:180},size:"small",optionList:[{value:"",label:s("èªå¨æ£æµ")},{value:"openai",label:s("å¯¹è¯ (Chat)")},{value:"openai-response",label:s("Responses")},{value:"embedding",label:s("Embedding")},{value:"image-generation",label:s("å¾ççæ")},{value:"jina-rerank",label:s("Rerank")}]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(w.Text,{type:"tertiary",className:"!text-xs whitespace-nowrap",children:s("æµå¼")}),t.jsx(Y,{checked:St,onChange:e=>Ct(e),size:"small",disabled:["embedding","image-generation","jina-rerank"].includes(wt)})]})]})]}),visible:yt&&null!==ft,onCancel:ol,footer:t.jsxs("div",{className:"flex justify-end",children:[Mt?t.jsx(T,{type:"danger",onClick:ol,children:s("忢æµè¯")}):t.jsx(T,{type:"tertiary",onClick:ol,children:s("åæ¶")}),t.jsx(T,{onClick:async()=>{if(!ft)return;Lt(!0),Vt(1);const e=ft.models.split(",").filter(e=>e.toLowerCase().includes(vt.toLowerCase()));Pt(e.map((e,t)=>({channel:ft,model:e,indexInFiltered:t,endpointType:wt,stream:St}))),Dt(!0)},loading:Mt,disabled:Mt,children:Mt?s("æµè¯ä¸..."):s("æ¹éæµè¯{{num}}个模å",{num:ft?ft.models.split(",").filter(e=>e.toLowerCase().includes(vt.toLowerCase())).length:0})})]}),maskClosable:!Mt,className:"!rounded-lg",size:c?"full-width":"large",children:t.jsx("div",{className:"model-test-scroll",children:ft&&t.jsx("div",{children:t.jsx(R,{columns:[{title:s("模ååç§°"),dataIndex:"model",render:e=>t.jsx("div",{className:"flex items-center",children:t.jsx(w.Text,{strong:!0,children:e})})},{title:s("ç¶æ"),dataIndex:"status",render:(e,l)=>{const a=Ot[`${ft.id}-${l.model}`];return Et.has(l.model)?t.jsx(k,{color:"blue",shape:"circle",children:s("æµè¯ä¸...")}):a?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(k,{color:a.success?"green":"red",shape:"circle",children:a.success?s("æå"):s("失败")}),a.success&&t.jsx(w.Text,{type:"tertiary",children:s("è¯·æ±æ¶é¿: {{time}}s",{time:a.time.toFixed(2)})})]}):t.jsx(k,{color:"grey",shape:"circle",children:s("æªå¼å§")})}},{title:"",dataIndex:"operate",render:(e,l)=>{const a=Et.has(l.model);return t.jsx(T,{type:"tertiary",onClick:()=>nl(ft,l.model,wt,St),loading:a,size:"small",children:s("æµè¯")})}}],dataSource:(()=>{const e=ft.models.split(",").filter(e=>e.toLowerCase().includes(vt.toLowerCase())),t=(Ft-1)*b,s=t+b;return e.slice(t,s).map(e=>({model:e,key:e}))})(),rowSelection:{selectedRowKeys:Bt,onChange:e=>{vs.current?vs.current=!1:$t(e)},onSelectAll:e=>{const t=ft.models.split(",").filter(e=>e.toLowerCase().includes(vt.toLowerCase()));vs.current=!0,$t(e?t:[])}},pagination:{currentPage:Ft,pageSize:b,total:ft.models.split(",").filter(e=>e.toLowerCase().includes(vt.toLowerCase())).length,showSizeChanger:!1,onPageChange:e=>Vt(e)}})})})}),t.jsx(tt,{visible:Nt,onCancel:()=>{zt(!1),It(null)},channelId:Tt?.id,channelName:Tt?.name}),t.jsx(N,{title:s("ä¿®æ¹ææ¬æ ¸ç®"),visible:rs,onOk:async()=>{if(!os)return;const e=await i.put("/api/channel/",{id:os.id,recharge_price:ds.recharge_price,group_ratio:ds.group_ratio}),{success:t,message:l}=e.data;t?(o(s("æä½æå宿ï¼")),ns(!1),cs(null),await tl()):r(l)},onCancel:()=>{ns(!1),cs(null)},okText:s("ä¿å"),cancelText:s("åæ¶"),centered:!0,children:t.jsxs("div",{style:{padding:"8px 0"},children:[t.jsxs("div",{style:{marginBottom:16},children:[t.jsx("div",{style:{marginBottom:6,fontWeight:500},children:s("å
弿±ç")}
1),t.jsx("div",{style:{marginBottom:4,color:"hsl(var(--muted-foreground))",fontSize:12},children:s("1 表示 1人æ°å¸=1é¢åº¦ï¼é»è®¤ä¸º1")}),t.jsx(I,{style:{width:"100%"},value:ds.recharge_price,onChange:e=>hs(t=>({...t,recharge_price:e})),placeholder:s("é»è®¤ä¸º1"),min:0,step:.01,precision:4})]}),t.jsxs("div",{children:[t.jsx("div",{style:{marginBottom:6,fontWeight:500},children:s("åç»åç")}),t.jsx("div",{style:{marginBottom:4,color:"hsl(var(--muted-foreground))",fontSize:12},children:s("å®é
ææ¬ = å
弿±ç à åç»åçï¼é»è®¤ä¸º1")}),t.jsx(I,{style:{width:"100%"},value:ds.group_ratio,onChange:e=>hs(t=>({...t,group_ratio:e})),placeholder:s("é»è®¤ä¸º1"),min:0,step:.01,precision:4})]})]})}),t.jsxs(N,{title:s("ç¦ç¨æ¸ é"),visible:es,onOk:async()=>{if(!as)return;if(!ss.trim())return void r(s("请填åç¦ç¨åå "));const{id:e,record:t}=as,l=await i.put("/api/channel/",{id:e,status:2,disable_reason:ss.trim()}),{success:a,message:n}=l.data;if(a){o(s("æä½æå宿ï¼"));let e=[...me];t.status=2,pe(e)}else r(n);ts(!1),ls(""),is(null)},onCancel:()=>{ts(!1),ls(""),is(null)},okText:s("确认ç¦ç¨"),cancelText:s("åæ¶"),okButtonProps:{type:"danger"},centered:!0,children:[t.jsxs("div",{style:{marginBottom:8},children:[t.jsx("span",{style:{color:"hsl(var(--destructive))",marginRight:4},children:"*"}),s("请填åç¦ç¨åå ï¼å¿
å¡«ï¼")]}),t.jsx(Z,{value:ss,onChange:e=>ls(e),placeholder:s("ä¾å¦ï¼ä»·æ ¼å¼å¸¸ãè´¦å·æ¬ è´¹ã䏿¸¸æ
é..."),rows:4,maxCount:200,showClear:!0})]}),t.jsxs(B,{title:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(w.Title,{heading:5,style:{margin:0},children:s("æ¸ éæµè¯è®°å½")}),bs&&Cs&&t.jsx(k,{color:"orange",size:"small",children:s("æµè¯ä¸ {{done}}/{{total}}",{done:Cs.finished,total:Cs.total})})]}),visible:Bs,onCancel:()=>$s(!1),placement:c?"bottom":"right",width:c?"100%":680,height:c?"85vh":void 0,style:c?{}:{maxWidth:"95vw"},bodyStyle:{padding:0,overflowY:"auto",overscrollBehavior:"contain",WebkitOverflowScrolling:"touch"},headerStyle:{borderBottom:"1px solid hsl(var(--border))"},children:[bs&&Cs&&t.jsxs("div",{style:{position:"sticky",top:0,zIndex:10,background:"hsl(var(--background))",borderBottom:"1px solid hsl(var(--border))",padding:"12px 16px"},children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx(w.Text,{strong:!0,children:s("æ¹éæµè¯è¿è¡ä¸...")}),t.jsx(w.Text,{type:"tertiary",size:"small",children:s("æå {{s}} | 失败 {{f}} | å
± {{t}} 个",{s:Cs.succeeded,f:Cs.failed,t:Cs.total})})]}),t.jsx(X,{percent:Math.round(Cs.finished/Cs.total*100),showInfo:!0,size:"default",stroke:Cs.failed>0?"hsl(var(--warning))":"hsl(var(--success))"}),Cs.results&&Cs.results.length>0&&t.jsx("div",{className:"mt-3",style:{maxHeight:c?"28vh":"200px",overflowY:"auto",overscrollBehavior:"contain"},children:[...Cs.results].reverse().slice(0,10).map((e,t)=>_l(e,t,!0))})]}),t.jsxs("div",{style:{padding:"16px"},children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx(w.Text,{strong:!0,children:s("åå²è®°å½")}),t.jsx(T,{size:"small",type:"tertiary",loading:Fs,onClick:gl,children:s("å·æ°")})]}),Fs&&0===Ws.length?t.jsx("div",{className:"flex justify-center py-8",children:t.jsx(A,{})}):0===Ws.length?t.jsx(E,{image:t.jsx(H,{style:{width:80,height:80}}),darkModeImage:t.jsx(U,{style:{width:80,height:80}}),description:s("ææ æµè¯è®°å½"),style:{padding:24}}):t.jsx("div",{className:"flex flex-col gap-2",children:Ws.map(e=>{const l=Ks===e.task_id,a=bs&&ks===e.task_id,r=new Date(1e3*e.created_at).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"});return t.jsxs(L,{shadows:"hover",bordered:!0,style:{borderRadius:8},bodyStyle:{padding:"12px 16px"},children:[t.jsxs("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>a?null:(async e=>{if(Ks===e)return qs(null),void Hs(null);qs(e),Ys(!0);try{const t=await i.get(`/api/channel/batch_test/${e}`),{success:s,data:l}=t.data;s&&Hs(l)}catch(t){}finally{Ys(!1)}})(e.task_id),children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(k,{color:"done"===e.status?e.failed>0?"orange":"green":"blue",size:"small",children:"done"===e.status?s("宿"):s("è¿è¡ä¸")}),t.jsx(w.Text,{size:"small",type:"secondary",children:r}),t.jsx(w.Text,{size:"small",children:s("å
±{{total}}项",{total:e.total})})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(w.Text,{size:"small",style:{color:"hsl(var(--success))"},children:["â ",e.succeeded]}),t.jsxs(w.Text,{size:"small",style:{color:"hsl(var(--destructive))"},children:["â ",e.failed]}),!a&&t.jsx(w.Text,{size:"small",type:"tertiary",children:l?"â²":"â¼"})]})]}),"done"!==e.status&&t.jsx("div",{className:"mt-2",children:t.jsx(X,{percent:Math.round(e.finished/e.total*100),showInfo:!0,size:"small"})}),l&&!a&&t.jsx("div",{className:"mt-3",children:Gs?t.jsx("div",{className:"flex justify-center py-4",children:t.jsx(A,{})}):Us&&Us.results?t.jsx("div",{children:Us.results.map((e,t)=>_l(e,t,!0))}):null}),a&&Cs&&Cs.results&&t.jsxs("div",{className:"mt-3",children:[t.jsx(X,{percent:Math.round(Cs.finished/Cs.total*100),showInfo:!0,size:"small",className:"mb-2"}),[...Cs.results].reverse().slice(0,5).map((e,t)=>_l(e,t,!1))]})]},e.task_id)})})]})]}),t.jsx(N,{title:s("失败åå "),visible:!!Js,onCancel:()=>Ps(null),footer:t.jsx(T,{type:"primary",onClick:()=>Ps(null),children:s("å
³é")}),centered:!0,size:c?"full-width":"small",children:Js&&t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(w.Text,{strong:!0,children:Js.channel_name}),t.jsxs(w.Text,{type:"secondary",children:["#",Js.channel_id]}),t.jsx(k,{size:"small",color:"blue",children:Js.model})]}),t.jsx("div",{style:{background:"hsl(var(--foreground) / 0.02)",borderRadius:6,padding:"10px 12px",wordBreak:"break-all",fontSize:13,lineHeight:1.6,color:"hsl(var(--destructive))",maxHeight:"50vh",overflowY:"auto"},children:Js.message||s("æ é误信æ¯")})]})})]})},lt=()=>t.jsx("div",{className:"px-2",children:t.jsx(st,{})});
1export{lt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.