1import{g as e,r as t,j as n,R as i,u as s,h as l}from"./vendor-react-DejgYtBM.js";import{o as a,m as r,R as o,C as c,B as d,f as u,ba as p,p as h,M as x,l as m,j as g,Y as y,i as j,z as f,T as b,a as _,a1 as S,F as k,y as v,E as C,J as w,K as T,D as I,r as E,A as R,ap as P,bb as z,k as N,X as A,u as M,G as O,v as D,s as L,t as B,_ as F,aQ as W,O as J,aK as U,aX as V,aP as K,bc as G,ar as q,as as $,ay as H,az as Q,aA as X,at as Y,au as Z,av as ee,aw as te,ax as ne,aB as ie,aC as se,L as le,bd as ae,P as re,an as oe}from"./vendor-semi-D8d7bTtM.js";import{bl as ce,bm as de,bn as ue,bo as pe,bp as he,bq as xe,br as me,u as ge,A as ye,s as je,bs as fe,w as be,bt as _e,bu as Se,bv as ke,aT as ve,g as Ce,bw as we,S as Te,Y as Ie,a0 as Ee,aU as Re,$ as Pe,a as ze,V as Ne,bx as Ae,ax as Me,v as Oe,J as De}from"./index-BeIIFw6E.js";import{T as Le,a as Be,D as Fe,b as We,g as Je,S as Ue,c as Ve,d as Ke}from"./i18nFieldCore-CS3IirKt.js";import{o as Ge,bT as qe,br as $e,T as He,bU as Qe,B as Xe,x as Ye,bB as Ze,R as et,q as tt,ah as nt,S as it,X as st,ba as lt,am as at,bV as rt,bW as ot,a7 as ct,aj as dt,b6 as ut,k as pt,aS as ht,ae as xt,I as mt,bm as gt,C as yt,bC as jt,u as ft,n as bt,c as _t,G as St,bX as kt,O as vt,f as Ct,a as wt,bY as Tt,bt as It,bZ as Et,b_ as Rt,b9 as Pt}from"./vendor-icons-EJvJ5X-w.js";import{m as zt}from"./marked.esm-B28mcIGu.js";import{p as Nt}from"./noticeI18n-CXa-dBKj.js";import"./index-BOZr6JVI.js";import"./index-KF7PEnkU.js";import"./captchaCrypto-qWW2iG_E.js";import{d as At}from"./dayjs.min-CASHsil8.js";import{g as Mt}from"./index-3LiQSZK3.js";import{f as Ot,g as Dt,b as Lt,c as Bt,B as Ft,a as Wt,m as Jt,d as Ut,D as Vt}from"./customerSupportContactOrder-BvYdiOIa.js";import"./vendor-motion-Chfy_MiU.js";const Kt=e({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});var Gt=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function qt(e){var t={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(Kt[n[1]]||"/"===e.charAt(e.length-2))&&(t.voidElement=!0),t.name.startsWith("!--"))){var i=e.indexOf("--\x3e");return{type:"comment",comment:-1!==i?e.slice(4,i):""}}for(var s=new RegExp(Gt),l=null;null!==(l=s.exec(e));)if(l[0].trim())if(l[1]){var a=l[1].trim(),r=[a,""];a.indexOf("=")>-1&&(r=a.split("=")),t.attrs[r[0]]=r[1],s.lastIndex--}else l[2]&&(t.attrs[l[2]]=l[3].trim().substring(1,l[3].length-1));return t}var $t=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Ht=/^\s*$/,Qt=Object.create(null);const Xt=(e,t)=>{if(!e)return!1;const n=e.props?.children??e.children;return t?n.length>0:!!n},Yt=e=>{if(!e)return[];const t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?Zt(t):t},Zt=e=>Array.isArray(e)?e:[e],en=(e,n,i,s)=>{if(!e)return"";let l="";const a=Zt(e),r=n?.transSupportBasicHtmlNodes?n.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(pe(e))l+=`${e}`;else{if(t.isValidElement(e)){const{props:t,type:o}=e,c=Object.keys(t).length,d=r.indexOf(o)>-1,u=t.children;if(!u&&d&&!c)return void(l+=`<${o}/>`);if(!u&&(!d||c)||t.i18nIsDynamicList)return void(l+=`<${a}></${a}>`);if(d&&1===c&&pe(u))return void(l+=`<${o}>${u}</${o}>`);const p=en(u,n,i,s);return void(l+=`<${a}>${p}</${a}>`)}if(null!==e){if(xe(e)){const{format:t,...n}=e,a=Object.keys(n);if(1===a.length){const e=t?`${a[0]}, ${t}`:a[0];return void(l+=`{{${e}}}`)}return void he(i,"TRANS_INVALID_OBJ","Invalid child - Object should only have keys {{ value, format }} (format is optional).",{i18nKey:s,child:e})}he(i,"TRANS_INVALID_VAR","Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.",{i18nKey:s,child:e})}else he(i,"TRANS_NULL_VALUE","Passed in a null value as child",{i18nKey:s})}}),l},tn=(e,n,i,s,l,a,r)=>{if(""===i)return[];const o=l.transKeepBasicHtmlNodesFor||[],c=i&&new RegExp(o.map(e=>`<${e}`).join("|")).test(i);if(!(e||n||c||r))return[i];const d=n??{},u=e=>{Zt(e).forEach(e=>{pe(e)||(Xt(e)?u(Yt(e)):xe(e)&&!t.isValidElement(e)&&Object.assign(d,e))})};u(e);const p=function(e,t){t||(t={}),t.components||(t.components=Qt);var n,i=[],s=[],l=-1,a=!1;if(0!==e.indexOf("<")){var r=e.indexOf("<");i.push({type:"text",content:-1===r?e:e.substring(0,r)})}return e.replace($t,function(r,o){if(a){if(r!=="</"+n.name+">")return;a=!1}var c,d="/"!==r.charAt(1),u=r.startsWith("\x3c!--"),p=o+r.length,h=e.charAt(p);if(u){var x=qt(r);return l<0?(i.push(x),i):((c=s[l]).children.push(x),i)}
vendor: 3,722 bytes, line 1
1if(d&&(l++,"tag"===(n=qt(r)).type&&t.components[n.name]&&(n.type="component",a=!0),n.voidElement||a||!h||"<"===h||n.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),0===l&&i.push(n),(c=s[l-1])&&c.children.push(n),s[l]=n),(!d||n.voidElement)&&(l>-1&&(n.voidElement||n.name===r.slice(2,-1))&&(l--,n=-1===l?i:s[l]),!a&&"<"!==h&&h)){c=-1===l?i:s[l].children;var m=e.indexOf("<",p),g=e.slice(p,-1===m?void 0:m);Ht.test(g)&&(g=" "),(m>-1&&l+c.length>=0||" "!==g)&&c.push({type:"text",content:g})}}),i}(`<0>${i}</0>`),h={...d,...a},x=(e,n,i)=>{const s=Yt(e),l=g(s,n.children,i);return(e=>Array.isArray(e)&&e.every(t.isValidElement))(s)&&0===l.length||e.props?.i18nIsDynamicList?s:l},m=(e,n,i,s,l)=>{e.dummy?(e.children=n,i.push(t.cloneElement(e,{key:s},l?void 0:n))):i.push(...t.Children.map([e],e=>{const i={...e.props};return delete i.i18nIsDynamicList,t.createElement(e.type,{...i,key:s,ref:e.props.ref??e.ref},l?null:n)}))},g=(e,i,a)=>{const d=Zt(e);return Zt(i).reduce((e,i,u)=>{const p=i.children?.[0]?.content&&s.services.interpolator.interpolate(i.children[0].content,h,s.language);if("tag"===i.type){let r=d[parseInt(i.name,10)];!r&&n&&(r=n[i.name]),1!==a.length||r||(r=a[0][i.name]),r||(r={});const y=0!==Object.keys(i.attrs).length?((e,t)=>{const n={...t};return n.props=Object.assign(e.props,t.props),n})({props:i.attrs},r):r,j=t.isValidElement(y),f=j&&Xt(i,!0)&&!i.voidElement,b=c&&xe(y)&&y.dummy&&!j,_=xe(n)&&Object.hasOwnProperty.call(n,i.name);if(pe(y)){const t=s.services.interpolator.interpolate(y,h,s.language);e.push(t)}else if(Xt(y)||f){const t=x(y,i,a);m(y,t,e,u)}else if(b){const t=g(d,i.children,a);m(y,t,e,u)}else if(Number.isNaN(parseFloat(i.name)))if(_){const t=x(y,i,a);m(y,t,e,u,i.voidElement)}else if(l.transSupportBasicHtmlNodes&&o.indexOf(i.name)>-1)if(i.voidElement)e.push(t.createElement(i.name,{key:`${i.name}-${u}`}));else{const n=g(d,i.children,a);e.push(t.createElement(i.name,{key:`${i.name}-${u}`},n))}else if(i.voidElement)e.push(`<${i.name} />`);else{const t=g(d,i.children,a);e.push(`<${i.name}>${t}</${i.name}>`)}else if(xe(y)&&!j){const t=i.children[0]?p:null;t&&e.push(t)}else m(y,p,e,u,1!==i.children.length||!p)}else if("text"===i.type){const n=l.transWrapTextNodes,a=r?l.unescape(s.services.interpolator.interpolate(i.content,h,s.language)):s.services.interpolator.interpolate(i.content,h,s.language);n?e.push(t.createElement(n,{key:`${i.name}-${u}`},a)):e.push(a)}return e},[])},y=g([{dummy:!0,children:e||[]}],p,Zt(e||[]));return Yt(y[0])},nn=(e,n,i)=>{const s=e.key||n,l=t.cloneElement(e,{key:s});return!l.props||!l.props.children||i.indexOf(`${n}/>`)<0&&i.indexOf(`${n} />`)<0?l:t.createElement(function(){return t.createElement(t.Fragment,null,l)},{key:s})};function sn({children:e,count:n,parent:i,i18nKey:s,context:l,tOptions:a={},values:r,defaults:o,components:c,ns:d,i18n:u,t:p,shouldUnescape:h,...x}){const m=u||ue();if(!m)return ce(m,"NO_I18NEXT_INSTANCE","Trans: You need to pass in an i18next instance using i18nextReactModule",{i18nKey:s}),e;const g=p||m.t.bind(m)||(e=>e),y={...de(),...m.options?.react};let j=d||g.ns||m.options?.defaultNS;j=pe(j)?[j]:j||["translation"];const f=en(e,y,m,s),b=o||f||y.transEmptyNodeValue||s,{hashTransKey:_}=y,S=s||(_?_(f||b):f||b);m.options?.interpolation?.defaultVariables&&(r=r&&Object.keys(r).length>0?{...r,...m.options.interpolation.defaultVariables}:{...m.options.interpolation.defaultVariables});const k=r||void 0!==n&&!m.options?.interpolation?.alwaysFormat||!e?a.interpolation:{interpolation:{...a.interpolation,prefix:"#$?",suffix:"?$#"}},v={...a,context:l||a.context,count:n,...r,...k,defaultValue:b,ns:j},C=S?g(S,v):b,w=((e,t,n,i)=>e?Array.isArray(e)?((e,t)=>e.map((e,n)=>nn(e,n,t)))(e,t):xe(e)?((e,t)=>
1{const n={};return Object.keys(e).forEach(i=>{Object.assign(n,{[i]:nn(e[i],i,t)})}),n})(e,t):(ce(n,"TRANS_INVALID_COMPONENTS",'<Trans /> "components" prop expects an object or array',{i18nKey:i}),null):null)(c,C,m,s);let T=w||e,I=null;var E;xe(E=w)&&!Array.isArray(E)&&Object.keys(E).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0)&&(I=w,T=e);const R=tn(T,I,C,m,y,v,h),P=i??y.defaultTransParent;return P?t.createElement(P,x,R):R}function ln({children:e,count:n,parent:i,i18nKey:s,context:l,tOptions:a={},values:r,defaults:o,components:c,ns:d,i18n:u,t:p,shouldUnescape:h,...x}){const{i18n:m,defaultNS:g}=t.useContext(me)||{},y=u||m||ue(),j=p||y?.t.bind(y);return sn({children:e,count:n,parent:i,i18nKey:s,context:l,tOptions:a,values:r,defaults:o,components:c,ns:d||j?.ns||g||y?.options?.defaultNS,i18n:y,t:p,shouldUnescape:h,...x})}const an=e=>{if("boolean"==typeof e)return e;if("number"==typeof e)return 1===e;if("string"==typeof e){const t=e.toLowerCase();return"true"===t||"1"===t}return!1},{Text:rn}=u,on=()=>{const{t:e}=ge();let[i,s]=t.useState({PasswordLoginEnabled:"",PasswordRegisterEnabled:"",EmailVerificationEnabled:"",GitHubOAuthEnabled:"",GitHubClientId:"",GitHubClientSecret:"",GoogleOAuthEnabled:"",GoogleClientId:"",GoogleClientSecret:"","oidc.enabled":"","oidc.client_id":"","oidc.client_secret":"","oidc.well_known":"","oidc.authorization_endpoint":"","oidc.token_endpoint":"","oidc.user_info_endpoint":"",Notice:"",SMTPServer:"",SMTPPort:"",SMTPAccount:"",SMTPFrom:"",SMTPToken:"",WorkerUrl:"",WorkerValidKey:"",WorkerAllowHttpImageRequestEnabled:"",Footer:"",WeChatAuthEnabled:"",WeChatServerAddress:"",WeChatServerToken:"",WeChatAccountQRCodeImageURL:"",TurnstileCheckEnabled:"",TurnstileSiteKey:"",TurnstileSecretKey:"",RegisterEnabled:"",EmailDomainRestrictionEnabled:"",EmailAliasRestrictionEnabled:"",SMTPSSLEnabled:"",EmailDomainWhitelist:[],TelegramOAuthEnabled:"",TelegramBotToken:"",TelegramBotName:"",LinuxDOOAuthEnabled:"",LinuxDOClientId:"",LinuxDOClientSecret:"",ServerAddress:""});const[l,u]=t.useState({}),[g,y]=t.useState(!1),[j,f]=t.useState(!1),b=t.useRef(null),[_,S]=t.useState([]),[k,v]=t.useState(!1),[C,w]=t.useState(!1),[T,I]=t.useState("");t.useEffect(()=>{(async()=>{y(!0);const e=await ye.get("/api/option/"),{success:t,message:n,data:i}=e.data;if(t){let e={};i.forEach(t=>{switch(t.key){case"TopupGroupRatio":t.value=JSON.stringify(JSON.parse(t.value),null,2);break;case"EmailDomainWhitelist":S(t.value?t.value.split(","):[]);break;case"PasswordLoginEnabled":case"PasswordRegisterEnabled":case"EmailVerificationEnabled":case"GitHubOAuthEnabled":case"GoogleOAuthEnabled":case"WeChatAuthEnabled":case"TelegramOAuthEnabled":case"RegisterEnabled":case"TurnstileCheckEnabled":case"EmailDomainRestrictionEnabled":case"EmailAliasRestrictionEnabled":case"SMTPSSLEnabled":case"LinuxDOOAuthEnabled":case"oidc.enabled":case"WorkerAllowHttpImageRequestEnabled":t.value=an(t.value);break;case"Price":case"MinTopUp":t.value=parseFloat(t.value)}e[t.key]=t.value}),s(e),u(e),b.current&&b.current.setValues(e),f(!0)}else je(n);y(!1)})()},[]);const E=async t=>{y(!0);try{const n=t.filter(e=>e.key.toLowerCase().endsWith("enabled")),l=t.filter(e=>!e.key.toLowerCase().endsWith("enabled"));for(const e of n){const t=await ye.put("/api/option/",{key:e.key,value:e.value.toString()});if(!t.data.success)return void je(t.data.message)}if(l.length>0){const e=l.map(e=>ye.put("/api/option/",{key:e.key,value:"boolean"==typeof e.value?e.value.toString():e.value}));(await Promise.all(e)).filter(e=>!e.data.success).forEach(e=>{je(e.data.message)})}be(e("æ´æ°æå"));const a={...i};t.forEach(e=>{a[e.key]=e.value}),s(a)}catch(n){je(e("æ´æ°å¤±è´¥"))}y(!1)},R=async()=>{let e=fe(i.WorkerUrl);const t=[{key:"WorkerUrl",value:e},{key:"WorkerAllowHttpImageRequestEnabled",value:i.WorkerAllowHttpImageRequestEnabled?"true":"false"}];""===i.WorkerValidKey&&""!==e||t.push({key:"WorkerValidKey",value:i.WorkerValidKey}),await E(t)},P=async()=>{let e=fe(i.ServerAddress);await E([{key:"ServerAddress",value:e}])},z=async()=>{const e=[];l.SMTPServer!==i.SMTPServer&&e.push({key:"SMTPServer",value:i.SMTPServer}),l.SMTPAccount!==i.SMTPAccount&&e.push({key:"SMTPAccount",value:i.SMTPAccount}),l.SMTPFrom!==i.SMTPFrom&&e.push({key:"SMTPFrom",value:i.SMTPFrom}),l.SMTPPort!==i.SMTPPort&&""!==i.SMTPPort&&e.push({key:"SMTPPort",value:i.SMTPPort}),l.SMTPToken!==i.SMTPToken&&""!==i.SMTPToken&&e.push({key:"SMTPToken",value:i.SMTPToken}),e.length>0&&await E(e)},N=async()=>{Array.isArray(_)?await E([{key:"EmailDomainWhitelist",value:_.join(",")}]):je(e("é®ç®±ååç½ååæ ¼å¼ä¸æ£ç¡®"))},A=()=>{if(T&&""!==T.trim()){const t=T.trim();if(!/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/.test(t))return void je(e("é®ç®±ååæ ¼å¼ä¸æ£ç¡®ï¼è¯·è¾å
¥ææçååï¼å¦ gmail.com"));if(_.includes(t))return void je(e("该ååå·²åå¨äºç½ååä¸"));S([..._,t]),I(""),be(e("已添å å°ç½åå"))}},M=async()=>{const e=[];l.WeChatServerAddress!==i.WeChatServerAddress&&e.push({key:"WeChatServerAddress",value:fe(i.WeChatServerAddress)}),l.WeChatAccountQRCodeImageURL!==i.WeChatAccountQRCodeImageURL&&e.push({key:"WeChatAccountQRCodeImageURL",value:i.WeChatAccountQRCodeImageURL}),l.WeChatServerToken!==i.WeChatServerToken&&""!==i.WeChatServerToken&&e.push({key:"WeChatServerToken",value:i.WeChatServerToken}),e.length>0&&await E(e)},O=async()=>{const e=[];l.GitHubClientId!==i.GitHubClientId&&e.push({key:"GitHubClientId",value:i.GitHubClientId}),l.GitHubClientSecret!==i.GitHubClientSecret&&""!==i.GitHubClientSecret&&e.push({key:"GitHubClientSecret",value:i.GitHubClientSecret}),e.length>0&&await E(e)},D=async()=>{const e=[];l.GoogleClientId!==i.GoogleClientId&&e.push({key:"GoogleClientId",value:i.GoogleClientId}),l.GoogleClientSecret!==i.GoogleClientSecret&&""!==i.GoogleClientSecret&&e.push({key:"GoogleClientSecret",value:i.GoogleClientSecret}),e.length>0&&await E(e)},L=async()=>
1{if(i["oidc.well_known"]&&""!==i["oidc.well_known"]){if(!i["oidc.well_known"].startsWith("http://")&&!i["oidc.well_known"].startsWith("https://"))return void je(e("Well-Known URL å¿
须以 http:// æ https:// å¼å¤´"));try{const t=await _e.create().get(i["oidc.well_known"]);i["oidc.authorization_endpoint"]=t.data.authorization_endpoint,i["oidc.token_endpoint"]=t.data.token_endpoint,i["oidc.user_info_endpoint"]=t.data.userinfo_endpoint,be(e("è·å OIDC é
ç½®æåï¼"))}catch(n){return console.error(n),void je(e("è·å OIDC é
置失败ï¼è¯·æ£æ¥ç½ç»ç¶åµå Well-Known URL æ¯å¦æ£ç¡®"))}}const t=[];l["oidc.well_known"]!==i["oidc.well_known"]&&t.push({key:"oidc.well_known",value:i["oidc.well_known"]}),l["oidc.client_id"]!==i["oidc.client_id"]&&t.push({key:"oidc.client_id",value:i["oidc.client_id"]}),l["oidc.client_secret"]!==i["oidc.client_secret"]&&""!==i["oidc.client_secret"]&&t.push({key:"oidc.client_secret",value:i["oidc.client_secret"]}),l["oidc.authorization_endpoint"]!==i["oidc.authorization_endpoint"]&&t.push({key:"oidc.authorization_endpoint",value:i["oidc.authorization_endpoint"]}),l["oidc.token_endpoint"]!==i["oidc.token_endpoint"]&&t.push({key:"oidc.token_endpoint",value:i["oidc.token_endpoint"]}),l["oidc.user_info_endpoint"]!==i["oidc.user_info_endpoint"]&&t.push({key:"oidc.user_info_endpoint",value:i["oidc.user_info_endpoint"]}),t.length>0&&await E(t)},B=async()=>{const e=[{key:"TelegramBotToken",value:i.TelegramBotToken},{key:"TelegramBotName",value:i.TelegramBotName}];await E(e)},F=async()=>{const e=[];l.TurnstileSiteKey!==i.TurnstileSiteKey&&e.push({key:"TurnstileSiteKey",value:i.TurnstileSiteKey}),l.TurnstileSecretKey!==i.TurnstileSecretKey&&""!==i.TurnstileSecretKey&&e.push({key:"TurnstileSecretKey",value:i.TurnstileSecretKey}),e.length>0&&await E(e)},W=async()=>{const e=[];l.LinuxDOClientId!==i.LinuxDOClientId&&e.push({key:"LinuxDOClientId",value:i.LinuxDOClientId}),l.LinuxDOClientSecret!==i.LinuxDOClientSecret&&""!==i.LinuxDOClientSecret&&e.push({key:"LinuxDOClientSecret",value:i.LinuxDOClientSecret}),e.length>0&&await E(e)},J=async(t,n)=>{const s=n.target.checked;"GitHubOAuthEnabled"!==t||!s||i.GitHubClientId&&i.GitHubClientSecret?"GoogleOAuthEnabled"!==t||!s||i.GoogleClientId&&i.GoogleClientSecret?"LinuxDOOAuthEnabled"!==t||!s||i.LinuxDOClientId&&i.LinuxDOClientSecret?("PasswordLoginEnabled"!==t||s?await E([{key:t,value:s}]):v(!0),"LinuxDOOAuthEnabled"===t&&w(s)):je(e("请å
å¨ä¸æ¹é
ç½® LinuxDO Client ID å Client Secret")):je(e("请å
å¨ä¸æ¹é
ç½® Google Client ID å Client Secret")):je(e("请å
å¨ä¸æ¹é
ç½® GitHub Client ID å Client Secret"))},U=async()=>{await E([{key:"PasswordLoginEnabled",value:!1}]),v(!1)};return n.jsx("div",{children:j?n.jsx(a,{initValues:i,onValueChange:e=>{s(e)},getFormApi:e=>b.current=e,children:({formState:t,values:s,formApi:l})=>n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px",marginTop:"10px"},children:[n.jsx(r,{children:n.jsxs(a.Section,{text:e("éç¨è®¾ç½®"),children:[n.jsx(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:n.jsx(c,{xs:24,sm:24,md:24,lg:24,xl:24,children:n.jsx(a.Input,{field:"ServerAddress",label:e("æå¡å¨å°å"),placeholder:"https://yourdomain.com",extraText:e("该æå¡å¨å°åå°å½±åæ¯ä»åè°å°å以åé»è®¤é¦é¡µå±ç¤ºçå°åï¼è¯·ç¡®ä¿æ£ç¡®é
ç½®")})})}),n.jsx(d,{onClick:P,children:e("æ´æ°æå¡å¨å°å")})]})}),n.jsx(r,{children:n.jsxs(a.Section,{text:e("代ç设置"),children:[n.jsx(rn,{children:n.jsx(ln,{i18nKey:"worker_proxy_support",components:{workerLink:n.jsx("a",{href:"https://github.com/Calcium-Ion/new-api-worker",target:"_blank",rel:"noreferrer"})}})}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"WorkerUrl",label:e("Workerå°å"),placeholder:e("ä¾å¦ï¼https://workername.yourdomain.workers.dev")})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"WorkerValidKey",label:e("Workerå¯é¥"),placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º"),type:"password"})})]}),n.jsx(a.Checkbox,{field:"WorkerAllowHttpImageRequestEnabled",noLabel:!0,children:e("å
许 HTTP åè®®
1å¾ç请æ±ï¼éç¨äºèªé¨ç½²ä»£çï¼")}),n.jsx(d,{onClick:R,children:e("æ´æ°Worker设置")})]})}),n.jsx(r,{children:n.jsx(a.Section,{text:e("é
ç½®ç»å½æ³¨å"),children:n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsxs(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:[n.jsx(a.Checkbox,{field:"PasswordLoginEnabled",noLabel:!0,onChange:e=>J("PasswordLoginEnabled",e),children:e("å
许éè¿å¯ç è¿è¡ç»å½")}),n.jsx(a.Checkbox,{field:"PasswordRegisterEnabled",noLabel:!0,onChange:e=>J("PasswordRegisterEnabled",e),children:e("å
许éè¿å¯ç è¿è¡æ³¨å")}),n.jsx(a.Checkbox,{field:"EmailVerificationEnabled",noLabel:!0,onChange:e=>J("EmailVerificationEnabled",e),children:e("éè¿å¯ç æ³¨åæ¶éè¦è¿è¡é®ç®±éªè¯")}),n.jsx(a.Checkbox,{field:"RegisterEnabled",noLabel:!0,onChange:e=>J("RegisterEnabled",e),children:e("å
许æ°ç¨æ·æ³¨å")}),n.jsx(a.Checkbox,{field:"TurnstileCheckEnabled",noLabel:!0,onChange:e=>J("TurnstileCheckEnabled",e),children:e("å
许 Turnstile ç¨æ·æ ¡éª")})]}),n.jsxs(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:[n.jsx(a.Checkbox,{field:"GitHubOAuthEnabled",noLabel:!0,onChange:e=>J("GitHubOAuthEnabled",e),children:e("å
许éè¿ GitHub è´¦æ·ç»å½ & 注å")}),n.jsx(a.Checkbox,{field:"GoogleOAuthEnabled",noLabel:!0,onChange:e=>J("GoogleOAuthEnabled",e),children:e("å
许éè¿ Google è´¦æ·ç»å½ & 注å")}),n.jsx(a.Checkbox,{field:"LinuxDOOAuthEnabled",noLabel:!0,onChange:e=>J("LinuxDOOAuthEnabled",e),children:e("å
许éè¿ Linux DO è´¦æ·ç»å½ & 注å")}),n.jsx(a.Checkbox,{field:"WeChatAuthEnabled",noLabel:!0,onChange:e=>J("WeChatAuthEnabled",e),children:e("å
许éè¿å¾®ä¿¡ç»å½ & 注å")}),n.jsx(a.Checkbox,{field:"TelegramOAuthEnabled",noLabel:!0,onChange:e=>J("TelegramOAuthEnabled",e),children:e("å
许éè¿ Telegram è¿è¡ç»å½")}),n.jsx(a.Checkbox,{field:"['oidc.enabled']",noLabel:!0,onChange:e=>J("oidc.enabled",e),children:e("å
许éè¿ OIDC è¿è¡ç»å½")})]})]})})}),n.jsx(r,{children:n.jsxs(a.Section,{text:e("é
ç½®é®ç®±ååç½åå"),children:[n.jsx(rn,{children:e("ç¨ä»¥é²æ¢æ¶æç¨æ·å©ç¨ä¸´æ¶é®ç®±æ¹é注å")}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Checkbox,{field:"EmailDomainRestrictionEnabled",noLabel:!0,onChange:e=>J("EmailDomainRestrictionEnabled",e),children:e("å¯ç¨é®ç®±ååç½åå")})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Checkbox,{field:"EmailAliasRestrictionEnabled",noLabel:!0,onChange:e=>J("EmailAliasRestrictionEnabled",e),children:e("å¯ç¨é®ç®±å«åéå¶")})})]}),n.jsx(p,{value:_,onChange:S,placeholder:e("è¾å
¥åååå车"),style:{width:"100%",marginTop:16}}),n.jsx(a.Input,{placeholder:e("è¾å
¥è¦æ·»å çé®ç®±åå"),value:T,onChange:e=>I(e),style:{marginTop:16},suffix:n.jsx(d,{theme:"solid",type:"primary",onClick:A,children:e("æ·»å ")}),onEnterPress:A}),n.jsx(d,{onClick:N,style:{marginTop:10},children:e("ä¿åé®ç®±ååç½åå设置")})]})}),n.jsx(r,{children:n.jsxs(a.Section,{text:e("é
ç½® SMTP"),children:[n.jsx(rn,{children:e("ç¨ä»¥æ¯æç³»ç»çé®ä»¶åé")}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"SMTPServer",label:e("SMTP æå¡å¨å°å")})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"SMTPPort",label:e("SMTP 端å£")})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"SMTPAccount",label:e("SMTP è´¦æ·")})})]}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},style:{marginTop:16},children:[n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"SMTPFrom",label:e("SMTP åéè
é®ç®±")})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"SMTPToken",label:e("SMTP 访é®åè¯"),type:"password",placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º")})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Checkbox,{field:"SMTPSSLEnabled",noLabel:!0,onChange:e=>J("SMTPSSLEnabled",e),children:e("å¯ç¨SMTP SSL")})})]}),n.jsx(d,{onClick:z,children:e("ä¿å SMTP 设置")})]})}),n.jsx(r,{children:n.jsxs(a.Section,{text:e("é
ç½® OIDC"),children:[n.jsx(rn,{children:e("ç¨ä»¥æ¯æéè¿ OIDC ç»å½ï¼ä¾å¦ OktaãAuth0 çå
¼å®¹ OIDC åè®®ç IdP")}),n.jsx(h,{type:"info",description:`${e("䏻页龿¥å¡«")} ${i.ServerAddress?i.ServerAddress:e("ç½ç«å°å")}ï¼${e("éå®å URL å¡«")} ${i.ServerAddress?i.ServerAddress:e("ç½ç«å°å")}/oauth/oidc`,style:{marginBottom:20,marginTop:16}}),n.jsx(rn,{children:e("system_hint_001")}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"['oidc.well_known']",label:e("Well-Known URL"),placeholder:e("请è¾å
¥ OIDC ç Well-Known URL")})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"['oidc.client_id']",label:e("Client ID"),placeholder:e("è¾å
¥ OIDC ç Client ID")})})]}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"['oidc.client_secret']",label:e("Client Secret"),type:"password",placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º")})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"['oidc.authorization_endpoint']",label:e("Authorization Endpoint"),placeholder:e("è¾å
¥ OIDC ç Authorization Endpoint")})})]}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"['oidc.token_endpoint']",label:e("Token Endpoint"),placeholder:e("è¾å
¥ OIDC ç Token Endpoint")})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"['oidc.user_info_endpoint']",label:e("User Info Endpoint"),placeholder:e("è¾å
¥ OIDC ç Userinfo Endpoint")})})]}),n.jsx(d,{onClick:L,children:e("ä¿å OIDC 设置")})]})}),n.jsx(r,{children:n.jsxs(a.Section,{text:e("é
ç½® GitHub OAuth App"),children:[n.jsx(rn,{children:e("ç¨ä»¥æ¯æéè¿ GitHub è¿è¡ç»å½æ³¨å")}),n.jsx(h,{type:"info",description:`${e("Homepage URL å¡«")} ${i.ServerAddress?i.ServerAddress:e("ç½ç«å°å")}ï¼${e("Authorization callback URL å¡«")} ${i.ServerAddress?i.ServerAddress:e("ç½ç«å°å")}/oauth/github`,style:{marginBottom:20,marginTop:16}}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"GitHubClientId",label:e("GitHub Client ID")})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"GitHubClientSecret",label:e("GitHub Client Secret"),type:"password",placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º")})})]}),n.jsx(d,{onClick:O,children:e("ä¿å GitHub OAuth 设置")})]})}),n.jsx(r,{children:n.jsxs(a.Section,{text:e("é
ç½® Google OAuth 2.0"),children:[n.jsx(rn,{children:e("ç¨ä»¥æ¯æéè¿ Google è¿è¡ç»å½æ³¨å")}),n.jsx(h,{type:"info",description:`${e('è¯·å¨ Google Cloud Console å建 OAuth 2.0 客æ·ç«¯ IDï¼åºç¨ç±»åéæ©"Webåºç¨"ãææçéå®å URI å¡«')} ${i.ServerAddress?i.ServerAddress:e("ç½ç«å°å")}/oauth/google`,style:{marginBottom:20,marginTop:16}}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"GoogleClientId",label:e("Google Client ID")})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"GoogleClientSecret",label:e("Google Client Secret"),type:"password",placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º")})})]}),n.jsx(d,{onClick:D,children:e("ä¿å Google OAuth 设置")})]})}),n.jsx(r,{children:n.jsxs(a.Section,{text:e("é
ç½® Linux DO OAuth"),children:[n.jsxs(rn,{children:[e("ç¨ä»¥æ¯æéè¿ Linux DO è¿è¡ç»å½æ³¨å"),n.jsx("a",{href:"https://connect.linux.do/",target:"_blank",rel:"noreferrer",style:{display:"inline-block",marginLeft:4,marginRight:4},children:e("ç¹å»æ¤å¤")}),e("管çä½ ç LinuxDO OAuth App")]}),n.jsx(h,{type:"info",description:`${e("åè° URL å¡«")} ${i.ServerAddress?i.ServerAddress:e("ç½ç«å°å")}/oauth/linuxdo`,style:{marginBottom:20,marginTop:16}}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"LinuxDOClientId",label:e("Linux DO Client ID"),placeholder:e("è¾å
¥ä½ 注åç
1LinuxDO OAuth APP ç ID")})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"LinuxDOClientSecret",label:e("Linux DO Client Secret"),type:"password",placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º")})})]}),n.jsx(d,{onClick:W,children:e("ä¿å Linux DO OAuth 设置")})]})}),n.jsx(r,{children:n.jsxs(a.Section,{text:e("é
ç½® WeChat Server"),children:[n.jsx(rn,{children:e("ç¨ä»¥æ¯æéè¿å¾®ä¿¡è¿è¡ç»å½æ³¨å")}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"WeChatServerAddress",label:e("WeChat Server æå¡å¨å°å")})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"WeChatServerToken",label:e("WeChat Server 访é®åè¯"),type:"password",placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º")})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"WeChatAccountQRCodeImageURL",label:e("微信å
¬ä¼å·äºç»´ç å¾ç龿¥")})})]}),n.jsx(d,{onClick:M,children:e("ä¿å WeChat Server 设置")})]})}),n.jsx(r,{children:n.jsxs(a.Section,{text:e("é
ç½® Telegram ç»å½"),children:[n.jsx(rn,{children:e("ç¨ä»¥æ¯æéè¿ Telegram è¿è¡ç»å½æ³¨å")}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"TelegramBotToken",label:e("Telegram Bot Token"),placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º"),type:"password"})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"TelegramBotName",label:e("Telegram Bot åç§°")})})]}),n.jsx(d,{onClick:B,children:e("ä¿å Telegram ç»å½è®¾ç½®")})]})}),n.jsx(r,{children:n.jsxs(a.Section,{text:e("é
ç½® Turnstile"),children:[n.jsx(rn,{children:e("ç¨ä»¥æ¯æç¨æ·æ ¡éª")}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"TurnstileSiteKey",label:e("Turnstile Site Key")})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"TurnstileSecretKey",label:e("Turnstile Secret Key"),type:"password",placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º")})})]}),n.jsx(d,{onClick:F,children:e("ä¿å Turnstile 设置")})]})}),n.jsx(x,{title:e("ç¡®è®¤åæ¶å¯ç ç»å½"),visible:k,onOk:U,onCancel:()=>{v(!1),b.current.setValue("PasswordLoginEnabled",!0)},okText:e("确认"),cancelText:e("åæ¶"),children:n.jsx("p",{children:e("æ¨ç¡®å®è¦åæ¶å¯ç ç»å½åè½åï¼è¿å¯è½ä¼å½±åç¨æ·çç»å½æ¹å¼ã")})})]})}):n.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:n.jsx(m,{size:"large"})})})};const cn=({options:e,refresh:i})=>{const{t:s}=ge(),l=t.useRef(null),[r,u]=t.useState(!1),[p,x]=t.useState(!1),[j,f]=t.useState({enabled:!1,base_url:"",api_key:"",model:""}),[b,_]=t.useState(j);t.useEffect(()=>{if(!e)return;const t={enabled:an(e["translation_setting.enabled"]),base_url:e["translation_setting.base_url"]||"",api_key:"",model:e["translation_setting.model"]||""};f(t),_(structuredClone(t)),l.current&&l.current.setValues(t)},[e?.["translation_setting.enabled"],e?.["translation_setting.base_url"],e?.["translation_setting.model"]]);const S=e=>t=>{f(n=>({...n,[e]:t}))};return n.jsx(m,{spinning:r,children:n.jsx(a,{getFormApi:e=>l.current=e,values:j,layout:"vertical",style:{marginBottom:15},children:n.jsxs(a.Section,{text:n.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[n.jsx(Ge,{size:16}),s("å¤è¯è¨èªå¨ç¿»è¯")]}),children:[n.jsx(h,{type:"info",description:s("å¼å¯åï¼å¨ä¿åç³»ç»å
¬å / 常è§é®ç / API ä¿¡æ¯æ¶ï¼å¯¹æªç¿»è¯æåæå·²ä¿®æ¹çæ¡ç®èªå¨è°ç¨ AI 模åç¿»è¯ä¸º 6 ç§è¯è¨ï¼en / ja / ko / ru / es / deï¼ï¼å¹¶éåæä¸åä¿åãåå°ç¨æ·è®¿é®æ¶ä¼æå½åè¯è¨è¯»åè¯æï¼ä¸åæ¶è tokenã"),fullMode:!1,closeIcon:null}),n.jsxs(o,{gutter:16,style:{marginTop:12},children:[n.jsx(c,{xs:24,md:6,children:n.jsx(a.Switch,{field:"enabled",label:s("å¯ç¨èªå¨ç¿»è¯"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:S("enabled")})}),n.jsx(c,{xs:24,md:9,children:n.jsx(a.Input,{field:"base_url",label:s("ç¿»è¯æ¨¡å Base URL"),placeholder:"https://yunwu.ai/v1",onChange:S("base_url"),showClear:!0})}),n.jsx(c,{xs:24,md:9,children:n.jsx(a.Input,{field:"model",label:s("ç¿»è¯æ¨¡å"),placeholder:"gpt-4o-mini",onChange:S("model"),showClear:!0})})]}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,md:18,children:n.jsx(a.Input,{field:"api_key",label:s("ç¿»è¯æ¨¡å API Key"),placeholder:s("çç©ºä¿æåå¼ä¸å"),mode:"password",onChange:S("api_key"),showClear:!0})})}),n.jsx(o,{style:{marginTop:8},children:n.jsxs(g,{children:[n.jsx(d,{onClick:async()=>{const e=(()=>{const e=[];return String(j.enabled)!==String(b.enabled)&&e.push({key:"translation_setting.enabled",value:String(!!j.enabled)}),j.base_url!==b.base_url&&e.push({key:"translation_setting.base_url",value:j.base_url||""}),j.model!==b.model&&e.push({key:"translation_setting.model",value:j.model||""}),j.api_key&&""!==j.api_key.trim()&&e.push({key:"translation_setting.api_key",value:j.api_key}),e})();if(0!==e.length){u(!0);try{await Promise.all(e.map(e=>ye.put(Se(),e))),be(s("ä¿åæå")),f(e=>({...e,api_key:""})),_(e=>({enabled:j.enabled,base_url:j.base_url,api_key:"",model:j.model})),i&&i()}catch(t){je(s("ä¿å失败ï¼è¯·éè¯"))}finally{u(!1)}}else y.info(s("æªæ£æµå°åæ´"))},type:"primary",theme:"solid",loading:r,children:s("ä¿åç¿»è¯è®¾ç½®")}),n.jsx(d,{onClick:async()=>{x(!0);try{const e={};j.api_key&&""!==j.api_key.trim()&&(e.baseURL=j.base_url,e.apiKey=j.api_key,e.model=j.model);const t=await async function({baseURL:e,apiKey:t,model:n}={}){const i=new URLSearchParams;e&&i.set("base_url",e),t&&i.set("api_key",t),n&&i.set("model",n);const s=await ye.post("/api/option/translate-test"+(i.toString()?`?${i.toString()}`:"")),{success:l,message:a,data:r}=s.data||{};if(!l)throw new Error(a||"è¿æ¥æµè¯å¤±è´¥");return r}(e);y.success(`${s("è¿æ¥æå")}: ${t?.sample||""}`)}catch(e){je(e&&e.message||s("è¿æ¥å¤±è´¥"))}finally{x(!1)}},loading:p,children:s("æµè¯è¿éæ§")})]})})]})})})},{Text:dn}=u,un=()=>{const{t:e}=ge();let[i,s]=t.useState({EmailDomainRestrictionEnabled:"",EmailAliasRestrictionEnabled:"",EmailDomainWhitelist:[],"translation_setting.enabled":!1,"translation_setting.base_url":"","translation_setting.model":""});const[l,u]=t.useState({}),[h,x]=t.useState(!1),[g,y]=t.useState(!1),j=t.useRef(null),[f,b]=t.useState([]),[_,S]=t.useState(""),k=async()=>{x(!0);try{const e=await ye.get("/api/option/admin"),{success:t,message:n,data:i}=e.data;if(t){let e={};
1i.forEach(t=>{switch(t.key){case"EmailDomainWhitelist":b(t.value?t.value.split(","):[]);break;case"EmailDomainRestrictionEnabled":case"EmailAliasRestrictionEnabled":case"translation_setting.enabled":t.value=an(t.value)}e[t.key]=t.value}),s(e),u(e),j.current&&j.current.setValues(e)}else je(n);y(!0)}catch(t){console.error("è·åé项失败:",t),je(e("è·åé项失败ï¼è¯·å·æ°éè¯")),y(!0)}finally{x(!1)}};t.useEffect(()=>{k()},[]);const v=async t=>{x(!0);try{const n=t.filter(e=>e.key.toLowerCase().endsWith("enabled")),l=t.filter(e=>!e.key.toLowerCase().endsWith("enabled")),a="/api/option/admin";for(const e of n){const t=await ye.put(a,{key:e.key,value:e.value.toString()});if(!t.data.success)return void je(t.data.message)}if(l.length>0){const e=l.map(e=>ye.put(a,{key:e.key,value:"boolean"==typeof e.value?e.value.toString():e.value}));(await Promise.all(e)).filter(e=>!e.data.success).forEach(e=>{je(e.data.message)})}be(e("æ´æ°æå"));const r={...i};t.forEach(e=>{r[e.key]=e.value}),s(r)}catch(n){je(e("æ´æ°å¤±è´¥"))}x(!1)},C=async()=>{Array.isArray(f)?await v([{key:"EmailDomainWhitelist",value:f.join(",")}]):je(e("é®ç®±ååç½ååæ ¼å¼ä¸æ£ç¡®"))},w=()=>{if(_&&""!==_.trim()){const t=_.trim();if(!/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/.test(t))return void je(e("é®ç®±ååæ ¼å¼ä¸æ£ç¡®ï¼è¯·è¾å
¥ææçååï¼å¦ gmail.com"));if(f.includes(t))return void je(e("该ååå·²åå¨äºç½ååä¸"));b([...f,t]),S(""),be(e("已添å å°ç½åå"))}},T=async(e,t)=>{const n=t.target.checked;await v([{key:e,value:n}])};return n.jsx("div",{children:g?n.jsx(a,{initValues:i,onValueChange:e=>{s(e)},getFormApi:e=>j.current=e,children:({formState:t,values:s,formApi:l})=>n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px",marginTop:"10px"},children:[n.jsx(r,{children:n.jsxs(a.Section,{text:e("é
ç½®é®ç®±ååç½åå"),children:[n.jsx(dn,{children:e("ç¨ä»¥é²æ¢æ¶æç¨æ·å©ç¨ä¸´æ¶é®ç®±æ¹é注å")}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Checkbox,{field:"EmailDomainRestrictionEnabled",noLabel:!0,onChange:e=>T("EmailDomainRestrictionEnabled",e),children:e("å¯ç¨é®ç®±ååç½åå")})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Checkbox,{field:"EmailAliasRestrictionEnabled",noLabel:!0,onChange:e=>T("EmailAliasRestrictionEnabled",e),children:e("å¯ç¨é®ç®±å«åéå¶")})})]}),n.jsx(p,{value:f,onChange:b,placeholder:e("è¾å
¥åååå车"),style:{width:"100%",marginTop:16}}),n.jsx(a.Input,{placeholder:e("è¾å
¥è¦æ·»å çé®ç®±åå"),value:_,onChange:e=>S(e),style:{marginTop:16},suffix:n.jsx(d,{theme:"solid",type:"primary",onClick:w,children:e("æ·»å ")}),onEnterPress:w}),n.jsx(d,{onClick:C,style:{marginTop:10},children:e("ä¿åé®ç®±ååç½åå设置")})]})}),n.jsx(r,{children:n.jsx(cn,{options:i,refresh:k})})]})}):n.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:n.jsx(m,{size:"large"})})})};function pn(e){const{t:i}=ge(),s=[{key:"hour",label:i("å°æ¶"),value:"hour"},{key:"day",label:i("天"),value:"day"},{key:"week",label:i("å¨"),value:"week"},{key:"month",label:i("æ"),value:"month"}],[l,r]=t.useState(!1),[u,p]=t.useState({DataExportEnabled:!1,DataExportInterval:"",DataExportDefaultTime:""}),h=t.useRef(),[x,g]=t.useState(u);return t.useEffect(()=>{const t={};for(let n in e.options)Object.keys(u).includes(n)&&(t[n]=e.options[n]);p(t),g(structuredClone(t)),h.current.setValues(t),localStorage.setItem("data_export_default_time",String(u.DataExportDefaultTime))},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:l,children:n.jsx(a,{values:u,getFormApi:e=>h.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("æ°æ®çæ¿è®¾ç½®"),children:[n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"DataExportEnabled",label:i("å¯ç¨æ°æ®çæ¿ï¼å®éªæ§ï¼"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{p({...u,DataExportEnabled:e})}})})}),n.jsxs(o,{children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("æ°æ®çæ¿æ´æ°é´é"),step:1,min:1,suffix:i("åé"),extraText:i("设置è¿çä¼å½±åæ°æ®åºæ§è½"),placeholder:i("æ°æ®çæ¿æ´æ°é´é"),field:"DataExportInterval",onChange:e=>p({...u,DataExportInterval:String(e)})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Select,{label:i("æ°æ®çæ¿é»è®¤æ¶é´ç²åº¦"),optionList:s,field:"DataExportDefaultTime",extraText:i("ä»
ä¿®æ¹å±ç¤ºç²åº¦ï¼ç»è®¡ç²¾ç¡®å°å°æ¶"),placeholder:i("æ°æ®çæ¿é»è®¤æ¶é´ç²åº¦"),style:{width:180},onChange:e=>p({...u,DataExportDefaultTime:String(e)})})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(u,x);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t="";return t="boolean"==typeof u[e.key]?String(u[e.key]):u[e.key],ye.put("/api/option/admin",{key:e.key,value:t})});r(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{r(!1)})},children:i("ä¿åæ°æ®çæ¿è®¾ç½®")})})]})})})})}const hn=({item:e,fields:t,targetLangs:i,onClick:s})=>{const{t:l}=ge(),a=Je(e,t,i),r=Ue[a]||Ue.none,o=n.jsx(j,{color:r.color,shape:"circle",style:{cursor:s?"pointer":"default"},onClick:s,children:l(r.textKey)});return"failed"===a&&e?.translation_error?n.jsx(f,{content:e.translation_error,position:"top",children:o}):"stale"===a?n.jsx(f,{content:l("åæå·²ä¿®æ¹ï¼è¯æå¯è½è¿æï¼è¯·éæ°ç¿»è¯"),position:"top",children:o}):o},xn=({visible:e,onClose:i,item:s,fields:l,sourceLang:a=Fe,targetLangs:r=Le,onApply:o,translationEnabled:c=!1})=>{const{t:p}=ge(),[m,j]=t.useState({}),[f,v]=t.useState(!1),[C,w]=t.useState(a),T=t.useMemo(()=>l.map(e=>e.key),[l]),I=t.useMemo(()=>Je(s,T,r),[s,T,r]);t.useEffect(()=>{if(!e)return;const t={};t[a]={}
1,l.forEach(e=>{t[a][e.key]=s?.[e.key]??""}),r.forEach(e=>{const n=s?.translations?.[e]||{};t[e]={},l.forEach(i=>{t[e][i.key]=n[i.key]??""})}),j(t),w(a)},[e,s,a,r,l]);const E=(e,t,n)=>{j(i=>({...i,[e]:{...i[e]||{},[t]:n}}))};return n.jsxs(x,{title:p("æ¥ç / ç¼è¾å¤è¯è¨è¯æ"),visible:e,onOk:()=>{const e={...s};l.forEach(t=>{e[t.key]=m[a]?.[t.key]??""});const t={...s?.translations||{}};let n=!1;r.forEach(e=>{const i=m[e]||{},s={...t[e]||{}};let a=!1;l.forEach(e=>{const t=i[e.key]??"";s[e.key]=t,""!==String(t).trim()&&(a=!0)}),a?(t[e]=s,n=!0):delete t[e]}),n?(e.translations=t,e.translation_hash=Ke(Be(e,T)),e.translation_updated_at=(new Date).toISOString(),delete e.translation_error):(delete e.translations,delete e.translation_hash,delete e.translation_updated_at),o&&o(e),i&&i()},onCancel:i,okText:p("ç¡®å®"),cancelText:p("åæ¶"),width:800,children:[n.jsx(h,{type:"stale"===I?"warning":"failed"===I?"danger":"info",description:n.jsxs(g,{children:[n.jsxs("span",{children:[p("å½åç¶æ"),":"," ","done"===I&&p("已翻è¯"),"partial"===I&&p("é¨åç¿»è¯"),"stale"===I&&p("åæå·²æ¹"),"failed"===I&&(s?.translation_error||p("ç¿»è¯å¤±è´¥")),"none"===I&&p("æªç¿»è¯")]}),n.jsx(d,{icon:"none"===I?n.jsx(Ge,{size:14}):n.jsx(qe,{size:14}),size:"small",theme:"solid",type:"primary",loading:f,disabled:!c||f,onClick:async()=>{try{v(!0);const e={...s,...m[a]||{}},t=await async function(e,t,n=Le){const i=Be(e,t),{results:s,errors:l}=await async function(e,t=Le,n=Fe){const i=await ye.post("/api/option/translate-batch",{fields:e,source_lang:n,target_langs:t}),{success:s,message:l,data:a}=i.data||{};if(!s)throw new Error(l||"ç¿»è¯å¤±è´¥");return{results:a?.results||{},errors:a?.errors||{}}}(i,n);return We(e,t,s,l)}(e,T,r),n={...m};r.forEach(e=>{const i=t?.translations?.[e]||{};n[e]={},l.forEach(t=>{n[e][t.key]=i[t.key]??""})}),j(n),y.success(p("AI ç¿»è¯å®æ"))}catch(e){y.error(e&&e.message||p("AI ç¿»è¯å¤±è´¥"))}finally{v(!1)}},children:p("none"===I?"AI ç¿»è¯":"éæ°ç¿»è¯")})]}),fullMode:!1,closeIcon:null}),n.jsx(b,{activeKey:C,onChange:w,type:"line",style:{marginTop:12},children:[a,...r].map(e=>n.jsx(_,{tab:`${Ve(e)}${e===a?` (${p("åæ")})`:""}`,itemKey:e,children:n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16,paddingTop:8},children:l.map(t=>{const i=m[e]?.[t.key]??"";return n.jsxs("div",{children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:4},children:t.label}),"textarea"===t.type?n.jsx(S,{value:i,rows:t.rows||4,maxCount:t.maxCount,showClear:!0,onChange:n=>E(e,t.key,n),placeholder:e===a?"":p("ç空å°åéå°åæ")}):n.jsx(k,{value:i,maxLength:t.maxLength,showClear:!0,onChange:n=>E(e,t.key,n),placeholder:e===a?"":p("ç空å°åéå°åæ")})]},t.key)})})},e))})]})},mn=["content","extra"],gn=[{key:"content",label:"å
容",type:"textarea",rows:4,maxCount:500},{key:"extra",label:"说æ",type:"input",maxLength:200}],{Text:yn}=u,jn=({options:e,refresh:i})=>{const{t:s}=ge(),[l,r]=t.useState([]),[o,c]=t.useState(!1),[u,p]=t.useState(!1),[h,m]=t.useState(!1),[y,b]=t.useState(null),[_,k]=t.useState(null),[R,P]=t.useState(!1),[z,N]=t.useState(!1),[A,M]=t.useState(!1),[O,D]=t.useState({content:"",publishDate:new Date,type:"default",extra:""}),[L,B]=t.useState(1),[F,W]=t.useState(10),[J,U]=t.useState([]),[V,K]=t.useState(!0),[G,q]=t.useState(null),$=an(e?.["translation_setting.enabled"]),H=t.useRef(null),Q=[{value:"default",label:s("é»è®¤")},{value:"ongoing",label:s("è¿è¡ä¸")},{value:"success",label:s("æå")},{value:"warning",label:s("è¦å")},{value:"error",label:s("é误")}],X=e=>({default:"grey",ongoing:"blue",success:"green",warning:"orange",error:"red"}[e]||"grey"),Y=[{title:s("å
容"),dataIndex:"content",key:"content",render:e=>n.jsx(f,{content:e,position:"topLeft",showArrow:!0,children:n.jsx("div",{style:{maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})})},{title:s("å叿¶é´"),dataIndex:"publishDate",key:"publishDate",width:180,render:e=>n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:"bold"},children:Ce(e)}),n.jsx("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",marginTop:"2px"},children:e?we(new Date(e)):"-"})]})},{title:s("ç±»å"),dataIndex:"type",key:"type",width:100,render:e=>n.jsx(j,{color:X(e),shape:"circle",children:Q.find(t=>t.value===e)?.label||e})},{title:s("说æ"),dataIndex:"extra",key:"extra",render:e=>n.jsx(f,{content:e||"-",showArrow:!0,children:n.jsx("div",{style:{maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"hsl(var(--muted-foreground))"},children:e||"-"})})},{title:s("ç¿»è¯"),key:"translation_status",width:110,render:(e,t)=>n.jsx(hn,{item:t,fields:mn,onClick:()=>q(t)})},{title:s("æä½"),key:"action",fixed:"right",width:220,render:(e,t)=>n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx(Ge,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>q(t),children:s("è¯æ")}),n.jsx(d,{icon:n.jsx($e,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>ee(t),children:s("ç¼è¾")}),n.jsx(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",size:"small",onClick:()=>te(t),children:s("å é¤")})]})}],Z=async()=>{try{N(!0);let e=l;const t=JSON.stringify(e);await(async(e,t)=>
1{const n=await ye.put("/api/option/admin",{key:"console_setting.announcements",value:t}),{success:l,message:a}=n.data;l?(be(s("ç³»ç»å
¬åå·²æ´æ°")),i&&i()):je(a)})(0,t),M(!1)}catch(e){console.error("ç³»ç»å
¬åæ´æ°å¤±è´¥",e),je(s("ç³»ç»å
¬åæ´æ°å¤±è´¥"))}finally{N(!1)}},ee=e=>{k(e),D({content:e.content,publishDate:e.publishDate?new Date(e.publishDate):new Date,type:e.type||"default",extra:e.extra||""}),c(!0)},te=e=>{b(e),p(!0)};t.useEffect(()=>{const t=e["console_setting.announcements"]??e.Announcements;void 0!==t&&(e=>{if(e)try{const t=JSON.parse(e),n=(Array.isArray(t)?t:[]).map((e,t)=>({...e,id:e.id||t+1}));r(n)}catch(t){console.error("è§£æç³»ç»å
¬å失败:",t),r([])}else r([])})(t)},[e["console_setting.announcements"],e.Announcements]),t.useEffect(()=>{const t=e["console_setting.announcements_enabled"];K(void 0===t||"true"===t||!0===t)},[e["console_setting.announcements_enabled"]]);const ne={selectedRowKeys:J,onChange:(e,t)=>{U(e)},onSelect:(e,t,n)=>{},onSelectAll:(e,t)=>{},getCheckboxProps:e=>({disabled:!1,name:e.id})};return n.jsxs(n.Fragment,{children:[n.jsx(a.Section,{text:n.jsxs("div",{className:"flex flex-col w-full",children:[n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-center text-blue-500",children:[n.jsx(Xe,{size:16,className:"mr-2"}),n.jsx(yn,{children:s("ç³»ç»å
¬å管çï¼å¯ä»¥åå¸ç³»ç»éç¥åéè¦æ¶æ¯ï¼æå¤100个ï¼å端æ¾ç¤ºææ°20æ¡ï¼")})]}),$&&n.jsxs("div",{className:"flex items-center text-amber-500 mt-1",children:[n.jsx(Ge,{size:14,className:"mr-2"}),n.jsx(yn,{type:"warning",size:"small",children:s('å·²å¼å¯èªå¨ç¿»è¯ï¼ç¹å»"触åç¿»è¯"æ"ä¿å设置"ï¼å°å¯¹æªç¿»è¯/åæå·²æ¹çæ¡ç®èªå¨ç¿»è¯ä¸º 6 ç§è¯è¨ï¼ç¿»è¯å¨ä¿åæ¶åæ¥æ§è¡ï¼éç¨çï¼')})]})]}),n.jsx(I,{margin:"12px"}),n.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 w-full",children:[n.jsxs("div",{className:"flex gap-2 w-full md:w-auto order-2 md:order-1",children:[n.jsx(d,{theme:"light",type:"primary",icon:n.jsx(Ye,{size:14}),className:"w-full md:w-auto",onClick:()=>{k(null),D({content:"",publishDate:new Date,type:"default",extra:""}),c(!0)},children:s("æ·»å å
¬å")}),n.jsxs(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",onClick:()=>{if(0===J.length)return void je(s("请å
éæ©è¦å é¤çç³»ç»å
¬å"));const e=l.filter(e=>!J.includes(e.id));r(e),U([]),M(!0),be(s('å·²å é¤ {{count}} 个系ç»å
¬åï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å',{count:J.length}))},disabled:0===J.length,className:"w-full md:w-auto",children:[s("æ¹éå é¤")," ",J.length>0&&`(${J.length})`]}),n.jsx(d,{icon:n.jsx(Ze,{size:14}),onClick:Z,loading:z,disabled:!A,type:"secondary",className:"w-full md:w-auto",children:s("ä¿å设置")}),$&&n.jsx(f,{content:s("å¯¹æææªç¿»è¯/åæå·²æ¹çæ¡ç®è§¦åç¿»è¯ï¼æ éä¿®æ¹å
¬åå
容"),children:n.jsx(d,{icon:n.jsx(et,{size:14}),onClick:Z,loading:z,type:"tertiary",className:"w-full md:w-auto",children:s("触åç¿»è¯")})})]}),n.jsxs("div",{className:"order-1 md:order-2 flex items-center gap-2",children:[n.jsx(E,{checked:V,onChange:async e=>{const t=e?"true":"false";try{const n=await ye.put("/api/option/admin",{key:"console_setting.announcements_enabled",value:t});n.data.success?(K(e),be(s("设置已ä¿å")),i?.()):je(n.data.message)}catch(n){je(n.message)}}}),n.jsx(yn,{children:s(V?"å·²å¯ç¨":"å·²ç¦ç¨")})]})]})]}),children:n.jsx(v,{columns:Y,dataSource:(()=>{const e=[...l].sort((e,t)=>{const n=new Date(e.publishDate).getTime();return new Date(t.publishDate).getTime()-n}),t=(L-1)*F,n=t+F;return e.slice(t,n)})(),rowSelection:ne,rowKey:"id",scroll:{x:"max-content"},pagination:{currentPage:L,pageSize:F,total:l.length,showSizeChanger:!0,showQuickJumper:!0,formatPageText:e=>s("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:l.length}),pageSizeOptions:["5","10","20","50"],onChange:(e,t)=>
1{B(e),W(t)},onShowSizeChange:(e,t)=>{B(1),W(t)}},size:"middle",loading:z,empty:n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:s("ææ ç³»ç»å
¬å"),style:{padding:30}}),className:"overflow-hidden"})}),n.jsx(x,{title:s(_?"ç¼è¾å
¬å":"æ·»å å
¬å"),visible:o,onOk:async()=>{if(O.content&&O.publishDate)try{P(!0);const e={...O,publishDate:O.publishDate.toISOString()};let t;if(_)t=l.map(t=>t.id===_.id?{...t,...e}:t);else{const n={id:Math.max(...l.map(e=>e.id),0)+1,...e};t=[...l,n]}r(t),M(!0),c(!1),be(s(_?'å
¬åå·²æ´æ°ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å':'å
¬å已添å ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å'))}catch(e){je(s("æä½å¤±è´¥")+": "+e.message)}finally{P(!1)}else je(s("请填å宿´çå
¬åä¿¡æ¯"))},onCancel:()=>c(!1),okText:s("ä¿å"),cancelText:s("åæ¶"),confirmLoading:R,children:n.jsxs(a,{layout:"vertical",initValues:O,getFormApi:e=>H.current=e,children:[n.jsx(a.TextArea,{field:"content",label:s("å
¬åå
容"),placeholder:s("请è¾å
¥å
¬åå
å®¹ï¼æ¯æ Markdown/HTMLï¼"),maxCount:500,rows:3,rules:[{required:!0,message:s("请è¾å
¥å
¬åå
容")}],onChange:e=>D({...O,content:e})}),n.jsx(d,{theme:"light",type:"tertiary",size:"small",icon:n.jsx(Qe,{size:14}),style:{marginBottom:16},onClick:()=>m(!0),children:s("æ¾å¤§ç¼è¾")}),n.jsx(a.DatePicker,{field:"publishDate",label:s("å叿¥æ"),type:"dateTime",rules:[{required:!0,message:s("è¯·éæ©å叿¥æ")}],onChange:e=>D({...O,publishDate:e})}),n.jsx(a.Select,{field:"type",label:s("å
¬åç±»å"),optionList:Q,onChange:e=>D({...O,type:e})}),n.jsx(a.Input,{field:"extra",label:s("说æä¿¡æ¯"),placeholder:s("å¯éï¼å
¬åçè¡¥å
说æ"),onChange:e=>D({...O,extra:e})})]},_?_.id:"new")}),n.jsx(x,{title:s("确认å é¤"),visible:u,onOk:()=>{if(y){const e=l.filter(e=>e.id!==y.id);r(e),M(!0),be(s('å
¬åå·²å é¤ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å'))}p(!1),b(null)},onCancel:()=>{p(!1),b(null)},okText:s("确认å é¤"),cancelText:s("åæ¶"),type:"warning",okButtonProps:{type:"danger",theme:"solid"},children:n.jsx(yn,{children:s("ç¡®å®è¦å 餿¤å
¬ååï¼")})}),n.jsx(xn,{visible:!!G,onClose:()=>q(null),item:G||{},fields:gn.map(e=>({...e,label:s(e.label)})),translationEnabled:$,onApply:e=>{if(!G)return;const t=l.map(t=>t.id===G.id?{...t,...e}:t);r(t),M(!0)}}),n.jsx(x,{title:s("ç¼è¾å
¬åå
容"),visible:h,onOk:()=>{H.current&&H.current.setValue("content",O.content),m(!1)},onCancel:()=>m(!1),okText:s("ç¡®å®"),cancelText:s("åæ¶"),width:800,children:n.jsx(S,{value:O.content,placeholder:s("请è¾å
¥å
¬åå
å®¹ï¼æ¯æ Markdown/HTMLï¼"),maxCount:500,rows:15,style:{width:"100%"},onChange:e=>D({...O,content:e})})})]})},{Text:fn}=u,bn=["question","answer"],_n=[{key:"question",label:"é®é¢æ é¢",type:"input",maxLength:200},{key:"answer",label:"åçå
容",type:"textarea",rows:6,maxCount:1e3}],Sn=({options:e,refresh:i})=>{const{t:s}=ge(),[l,r]=t.useState([]),[o,c]=t.useState(!1),[u,p]=t.useState(!1),[h,m]=t.useState(null),[y,j]=t.useState(null),[b,_]=t.useState(!1),[S,k]=t.useState(!1),[R,P]=t.useState(!1),[z,N]=t.useState({question:"",answer:""}),[A,M]=t.useState(1),[O,D]=t.useState(10),[L,B]=t.useState([]),[F,W]=t.useState(!0),[J,U]=t.useState(null),V=an(e?.["translation_setting.enabled"]),K=[{title:s("é®é¢æ é¢"),dataIndex:"question",key:"question",render:e=>n.jsx(f,{content:e,showArrow:!0,children:n.jsx("div",{style:{maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:"bold"},children:e})})},{title:s("åçå
容"),dataIndex:"answer",key:"answer",render:e=>n.jsx(f,{content:e,showArrow:!0,children:n.jsx("div",{style:{maxWidth:"400px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"hsl(var(--foreground) / 0.80)"},children:e})})},{title:s("ç¿»è¯"),key:"translation_status",width:110,render:(e,t)=>n.jsx(hn,{item:t,fields:bn,onClick:()=>U(t)})},{title:s("æä½"),key:"action",fixed:"right",width:220,render:(e,t)=>n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx(Ge,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>U(t),children:s("è¯æ")}),n.jsx(d,{icon:n.jsx($e,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>G(t),children:s("ç¼è¾")}),n.jsx(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",size:"small",onClick:()=>q(t),children:s("å é¤")})]})}],G=e=>{j(e),N({question:e.question,answer:e.answer}),c(!0)},q=e=>{m(e),p(!0)};t.useEffect(()=>{void 0!==e["console_setting.faq"]&&(e=>{if(e)try{const t=JSON.parse(e),n=(Array.isArray(t)?t:[]).map((e,t)=>({...e,id:e.id||t+1}));r(n)}catch(t){console.error("è§£æå¸¸è§é®ç失败:",t),r([])}else r([])})(e["console_setting.faq"])},[e["console_setting.faq"]]),t.useEffect(()=>{const t=e["console_setting.faq_enabled"];W(void 0===t||"true"===t||!0===t)},[e["console_setting.faq_enabled"]]);const $={selectedRowKeys:L,onChange:(e,t)=>
1{B(e)},onSelect:(e,t,n)=>{},onSelectAll:(e,t)=>{},getCheckboxProps:e=>({disabled:!1,name:e.id})};return n.jsxs(n.Fragment,{children:[n.jsx(a.Section,{text:n.jsxs("div",{className:"flex flex-col w-full",children:[n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-center text-blue-500",children:[n.jsx(tt,{size:16,className:"mr-2"}),n.jsx(fn,{children:s("常è§é®ç管çï¼ä¸ºç¨æ·æä¾å¸¸è§é®é¢ççæ¡ï¼æå¤50个ï¼å端æ¾ç¤ºææ°20æ¡ï¼")})]}),V&&n.jsxs("div",{className:"flex items-center text-amber-500 mt-1",children:[n.jsx(Ge,{size:14,className:"mr-2"}),n.jsx(fn,{type:"warning",size:"small",children:"t('å·²å¼å¯èªå¨ç¿»è¯ï¼ä¿å设置æ¶ä¼å¯¹æªç¿»è¯/åæå·²ä¿®æ¹çæ¡ç®èªå¨ç¿»è¯ä¸º 6 ç§è¯è¨')"})]})]}),n.jsx(I,{margin:"12px"}),n.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 w-full",children:[n.jsxs("div",{className:"flex gap-2 w-full md:w-auto order-2 md:order-1",children:[n.jsx(d,{theme:"light",type:"primary",icon:n.jsx(Ye,{size:14}),className:"w-full md:w-auto",onClick:()=>{j(null),N({question:"",answer:""}),c(!0)},children:s("æ·»å é®ç")}),n.jsxs(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",onClick:()=>{if(0===L.length)return void je(s("请å
éæ©è¦å é¤ç常è§é®ç"));const e=l.filter(e=>!L.includes(e.id));r(e),B([]),P(!0),be(s('å·²å é¤ {{count}} 个常è§é®çï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å',{count:L.length}))},disabled:0===L.length,className:"w-full md:w-auto",children:[s("æ¹éå é¤")," ",L.length>0&&`(${L.length})`]}),n.jsx(d,{icon:n.jsx(Ze,{size:14}),onClick:async()=>{try{k(!0);let e=l;const t=JSON.stringify(e);await(async(e,t)=>{const n=await ye.put("/api/option/admin",{key:"console_setting.faq",value:t}),{success:l,message:a}=n.data;l?(be(s("常è§é®çå·²æ´æ°")),i&&i()):je(a)})(0,t),P(!1)}catch(e){console.error("常è§é®çæ´æ°å¤±è´¥",e),je(s("常è§é®çæ´æ°å¤±è´¥"))}finally{k(!1)}},loading:S,disabled:!R,type:"secondary",className:"w-full md:w-auto",children:s("ä¿å设置")})]}),n.jsxs("div",{className:"order-1 md:order-2 flex items-center gap-2",children:[n.jsx(E,{checked:F,onChange:async e=>{const t=e?"true":"false";try{const n=await ye.put("/api/option/admin",{key:"console_setting.faq_enabled",value:t});n.data.success?(W(e),be(s("设置已ä¿å")),i?.()):je(n.data.message)}catch(n){je(n.message)}}}),n.jsx(fn,{children:s(F?"å·²å¯ç¨":"å·²ç¦ç¨")})]})]})]}),children:n.jsx(v,{columns:K,dataSource:(()=>{const e=(A-1)*O,t=e+O;return l.slice(e,t)})(),rowSelection:$,rowKey:"id",scroll:{x:"max-content"},pagination:{currentPage:A,pageSize:O,total:l.length,showSizeChanger:!0,showQuickJumper:!0,formatPageText:e=>s("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:l.length}),pageSizeOptions:["5","10","20","50"],onChange:(e,t)=>
1{M(e),D(t)},onShowSizeChange:(e,t)=>{M(1),D(t)}},size:"middle",loading:S,empty:n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:s("ææ å¸¸è§é®ç"),style:{padding:30}}),className:"overflow-hidden"})}),n.jsx(x,{title:s(y?"ç¼è¾é®ç":"æ·»å é®ç"),visible:o,onOk:async()=>{if(z.question&&z.answer)try{let e;if(_(!0),y)e=l.map(e=>e.id===y.id?{...e,...z}:e);else{const t={id:Math.max(...l.map(e=>e.id),0)+1,...z};e=[...l,t]}r(e),P(!0),c(!1),be(s(y?'é®çå·²æ´æ°ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å':'é®ç已添å ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å'))}catch(e){je(s("æä½å¤±è´¥")+": "+e.message)}finally{_(!1)}else je(s("请填å宿´çé®çä¿¡æ¯"))},onCancel:()=>c(!1),okText:s("ä¿å"),cancelText:s("åæ¶"),confirmLoading:b,width:800,children:n.jsxs(a,{layout:"vertical",initValues:z,children:[n.jsx(a.Input,{field:"question",label:s("é®é¢æ é¢"),placeholder:s("请è¾å
¥é®é¢æ é¢"),maxLength:200,rules:[{required:!0,message:s("请è¾å
¥é®é¢æ é¢")}],onChange:e=>N({...z,question:e})}),n.jsx(a.TextArea,{field:"answer",label:s("åçå
容"),placeholder:s("请è¾å
¥åçå
å®¹ï¼æ¯æ Markdown/HTMLï¼"),maxCount:1e3,rows:6,rules:[{required:!0,message:s("请è¾å
¥åçå
容")}],onChange:e=>N({...z,answer:e})})]},y?y.id:"new")}),n.jsx(x,{title:s("确认å é¤"),visible:u,onOk:()=>{if(h){const e=l.filter(e=>e.id!==h.id);r(e),P(!0),be(s('é®çå·²å é¤ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å'))}p(!1),m(null)},onCancel:()=>{p(!1),m(null)},okText:s("确认å é¤"),cancelText:s("åæ¶"),type:"warning",okButtonProps:{type:"danger",theme:"solid"},children:n.jsx(fn,{children:s("ç¡®å®è¦å 餿¤é®çåï¼")})}),n.jsx(xn,{visible:!!J,onClose:()=>U(null),item:J||{},fields:_n.map(e=>({...e,label:s(e.label)})),translationEnabled:V,onApply:e=>{if(!J)return;const t=l.map(t=>t.id===J.id?{...t,...e}:t);r(t),P(!0)}})]})},{Text:kn}=u,vn=({options:e,refresh:i})=>{const{t:s}=ge(),[l,r]=t.useState([]),[o,c]=t.useState(!1),[u,p]=t.useState(!1),[h,m]=t.useState(null),[y,j]=t.useState(null),[f,b]=t.useState(!1),[_,S]=t.useState(!1),[k,R]=t.useState(!1),[P,z]=t.useState({categoryName:"",url:"",slug:""}),[N,A]=t.useState(1),[M,O]=t.useState(10),[D,L]=t.useState([]),[B,F]=t.useState(!0),W=[{title:s("åç±»åç§°"),dataIndex:"categoryName",key:"categoryName",render:e=>n.jsx("div",{style:{fontWeight:"bold",color:"hsl(var(--foreground))"},children:e})},{title:s("Uptime Kumaå°å"),dataIndex:"url",key:"url",render:e=>n.jsx("div",{style:{maxWidth:"300px",wordBreak:"break-all",fontFamily:"monospace",color:"hsl(var(--primary))"},children:e})},{title:s("ç¶æé¡µé¢Slug"),dataIndex:"slug",key:"slug",render:e=>n.jsx("div",{style:{fontFamily:"monospace",color:"hsl(var(--foreground) / 0.80)"},children:e})},{title:s("æä½"),key:"action",fixed:"right",width:150,render:(e,t)=>n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx($e,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>J(t),children:s("ç¼è¾")}),n.jsx(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",size:"small",onClick:()=>U(t),children:s("å é¤")})]})}],J=e=>{j(e),z({categoryName:e.categoryName,url:e.url,slug:e.slug}),c(!0)},U=e=>{m(e),p(!0)};t.useEffect(()=>{const t=e["console_setting.uptime_kuma_groups"];void 0!==t&&(e=>{if(e)try{const t=JSON.parse(e),n=(Array.isArray(t)?t:[]).map((e,t)=>({...e,id:e.id||t+1}));r(n)}catch(t){console.error("è§£æUptime Kumaé
置失败:",t),r([])}else r([])})(t)},[e["console_setting.uptime_kuma_groups"]]),t.useEffect(()=>{const t=e["console_setting.uptime_kuma_enabled"];F(void 0===t||"true"===t||!0===t)},[e["console_setting.uptime_kuma_enabled"]]);const V={selectedRowKeys:D,onChange:(e,t)=>
1{L(e)},onSelect:(e,t,n)=>{},onSelectAll:(e,t)=>{},getCheckboxProps:e=>({disabled:!1,name:e.id})};return n.jsxs(n.Fragment,{children:[n.jsx(a.Section,{text:n.jsxs("div",{className:"flex flex-col w-full",children:[n.jsx("div",{className:"mb-2",children:n.jsxs("div",{className:"flex items-center text-blue-500",children:[n.jsx(nt,{size:16,className:"mr-2"}),n.jsx(kn,{children:s("Uptime Kumaçæ§å类管çï¼å¯ä»¥é
ç½®å¤ä¸ªçæ§åç±»ç¨äºæå¡ç¶æå±ç¤ºï¼æå¤20个ï¼")})]})}),n.jsx(I,{margin:"12px"}),n.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 w-full",children:[n.jsxs("div",{className:"flex gap-2 w-full md:w-auto order-2 md:order-1",children:[n.jsx(d,{theme:"light",type:"primary",icon:n.jsx(Ye,{size:14}),className:"w-full md:w-auto",onClick:()=>{j(null),z({categoryName:"",url:"",slug:""}),c(!0)},children:s("æ·»å åç±»")}),n.jsxs(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",onClick:()=>{if(0===D.length)return void je(s("请å
éæ©è¦å é¤çåç±»"));const e=l.filter(e=>!D.includes(e.id));r(e),L([]),R(!0),be(s('å·²å é¤ {{count}} 个åç±»ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å',{count:D.length}))},disabled:0===D.length,className:"w-full md:w-auto",children:[s("æ¹éå é¤")," ",D.length>0&&`(${D.length})`]}),n.jsx(d,{icon:n.jsx(Ze,{size:14}),onClick:async()=>{try{S(!0);const e=JSON.stringify(l);await(async(e,t)=>{const n=await ye.put("/api/option/admin",{key:"console_setting.uptime_kuma_groups",value:t}),{success:l,message:a}=n.data;l?(be(s("Uptime Kumaé
ç½®å·²æ´æ°")),i&&i()):je(a)})(0,e),R(!1)}catch(e){console.error("Uptime Kumaé
ç½®æ´æ°å¤±è´¥",e),je(s("Uptime Kumaé
ç½®æ´æ°å¤±è´¥"))}finally{S(!1)}},loading:_,disabled:!k,type:"secondary",className:"w-full md:w-auto",children:s("ä¿å设置")})]}),n.jsxs("div",{className:"order-1 md:order-2 flex items-center gap-2",children:[n.jsx(E,{checked:B,onChange:async e=>{const t=e?"true":"false";try{const n=await ye.put("/api/option/admin",{key:"console_setting.uptime_kuma_enabled",value:t});n.data.success?(F(e),be(s("设置已ä¿å")),i?.()):je(n.data.message)}catch(n){je(n.message)}}}),n.jsx(kn,{children:s(B?"å·²å¯ç¨":"å·²ç¦ç¨")})]})]})]}),children:n.jsx(v,{columns:W,dataSource:(()=>{const e=(N-1)*M,t=e+M;return l.slice(e,t)})(),rowSelection:V,rowKey:"id",scroll:{x:"max-content"},pagination:{currentPage:N,pageSize:M,total:l.length,showSizeChanger:!0,showQuickJumper:!0,formatPageText:e=>s("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:l.length}),pageSizeOptions:["5","10","20","50"],onChange:(e,t)=>
1{A(e),O(t)},onShowSizeChange:(e,t)=>{A(1),O(t)}},size:"middle",loading:_,empty:n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:s("ææ çæ§æ°æ®"),style:{padding:30}}),className:"overflow-hidden"})}),n.jsx(x,{title:s(y?"ç¼è¾åç±»":"æ·»å åç±»"),visible:o,onOk:async()=>{if(P.categoryName&&P.url&&P.slug){try{new URL(P.url)}catch(e){return void je(s("请è¾å
¥ææçURLå°å"))}if(/^[a-zA-Z0-9_-]+$/.test(P.slug))try{let e;if(b(!0),y)e=l.map(e=>e.id===y.id?{...e,...P}:e);else{const t={id:Math.max(...l.map(e=>e.id),0)+1,...P};e=[...l,t]}r(e),R(!0),c(!1),be(s(y?'åç±»å·²æ´æ°ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å':'å类已添å ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å'))}catch(e){je(s("æä½å¤±è´¥")+": "+e.message)}finally{b(!1)}else je(s("Slugåªè½å
å«åæ¯ãæ°åãä¸å线åè¿å符"))}else je(s("请填å宿´çå类信æ¯"))},onCancel:()=>c(!1),okText:s("ä¿å"),cancelText:s("åæ¶"),confirmLoading:f,width:600,children:n.jsxs(a,{layout:"vertical",initValues:P,children:[n.jsx(a.Input,{field:"categoryName",label:s("åç±»åç§°"),placeholder:s("请è¾å
¥åç±»åç§°ï¼å¦ï¼OpenAIãClaudeç"),maxLength:50,rules:[{required:!0,message:s("请è¾å
¥åç±»åç§°")}],onChange:e=>z({...P,categoryName:e})}),n.jsx(a.Input,{field:"url",label:s("Uptime Kumaå°å"),placeholder:s("请è¾å
¥Uptime Kumaæå¡å°åï¼å¦ï¼https://status.example.com"),maxLength:500,rules:[{required:!0,message:s("请è¾å
¥Uptime Kumaå°å")}],onChange:e=>z({...P,url:e})}),n.jsx(a.Input,{field:"slug",label:s("ç¶æé¡µé¢Slug"),placeholder:s("请è¾å
¥ç¶æé¡µé¢çSlugï¼å¦ï¼my-status"),maxLength:100,rules:[{required:!0,message:s("请è¾å
¥ç¶æé¡µé¢Slug")}],onChange:e=>z({...P,slug:e})})]},y?y.id:"new")}),n.jsx(x,{title:s("确认å é¤"),visible:u,onOk:()=>{if(h){const e=l.filter(e=>e.id!==h.id);r(e),R(!0),be(s('å类已å é¤ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å'))}p(!1),m(null)},onCancel:()=>{p(!1),m(null)},okText:s("确认å é¤"),cancelText:s("åæ¶"),type:"warning",okButtonProps:{type:"danger",theme:"solid"},children:n.jsx(kn,{children:s("ç¡®å®è¦å 餿¤åç±»åï¼")})})]})},{Text:Cn}=u,wn=["description","route"],Tn=[{key:"route",label:"线路æè¿°",type:"input",maxLength:50},{key:"description",label:"说æ",type:"input",maxLength:200}],In=({options:e,refresh:i})=>{const{t:s}=ge(),[l,r]=t.useState([]),[o,c]=t.useState(!1),[u,p]=t.useState(!1),[h,m]=t.useState(null),[y,f]=t.useState(null),[b,_]=t.useState(!1),[S,k]=t.useState(!1),[P,z]=t.useState(!1),[N,A]=t.useState({url:"",description:"",route:"",color:"blue"}),[M,O]=t.useState(1),[D,L]=t.useState(10),[B,F]=t.useState([]),[W,J]=t.useState(!0),[U,V]=t.useState(null),K=an(e?.["translation_setting.enabled"]);t.useEffect(()=>{const t=e["console_setting.api_info"]??e.ApiInfo;void 0!==t&&(e=>{if(e)try{const t=JSON.parse(e);r(Array.isArray(t)?t:[])}catch(t){console.error("è§£æAPIä¿¡æ¯å¤±è´¥:",t),r([])}else r([])})(t)},[e["console_setting.api_info"],e.ApiInfo]),t.useEffect(()=>{const t=e["console_setting.api_info_enabled"];J(void 0===t||"true"===t||!0===t)},[e["console_setting.api_info_enabled"]]);const G=[{title:"ID",dataIndex:"id"},{title:s("APIå°å"),dataIndex:"url",render:(e,t)=>n.jsx(j,{color:t.color,shape:"circle",style:{maxWidth:"280px"},children:e})},{title:s("线路æè¿°"),dataIndex:"route",render:(e,t)=>n.jsx(j,{shape:"circle",children:e})},{title:s("说æ"),dataIndex:"description",ellipsis:!0,render:(e,t)=>n.jsx(j,{shape:"circle",children:e||"-"})},{title:s("é¢è²"),dataIndex:"color",render:e=>n.jsx(R,{size:"extra-extra-small",color:e})},{title:s("ç¿»è¯"),key:"translation_status",width:110,render:(e,t)=>n.jsx(hn,{item:t,fields:wn,onClick:()=>V(t)})},{title:s("æä½"),fixed:"right",width:220,render:(e,t)=>n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx(Ge,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>V(t),children:s("è¯æ")}),n.jsx(d,{icon:n.jsx($e,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>{return f(e=t),A({url:e.url,description:e.description,route:e.route,color:e.color}),void c(!0);var e},children:s("ç¼è¾")}),n.jsx(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",size:"small",onClick:()=>(m(t),void p(!0)),children:s("å é¤")})]})}],q={selectedRowKeys:B,onChange:(e,t)=>
1{F(e)},onSelect:(e,t,n)=>{},onSelectAll:(e,t)=>{},getCheckboxProps:e=>({disabled:!1,name:e.id})};return n.jsxs(n.Fragment,{children:[n.jsx(a.Section,{text:n.jsxs("div",{className:"flex flex-col w-full",children:[n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-center text-blue-500",children:[n.jsx(it,{size:16,className:"mr-2"}),n.jsx(Cn,{children:s("APIä¿¡æ¯ç®¡çï¼å¯ä»¥é
ç½®å¤ä¸ªAPIå°åç¨äºç¶æå±ç¤ºåè´è½½åè¡¡ï¼æå¤50个ï¼")})]}),K&&n.jsxs("div",{className:"flex items-center text-amber-500 mt-1",children:[n.jsx(Ge,{size:14,className:"mr-2"}),n.jsx(Cn,{type:"warning",size:"small",children:"t('å·²å¼å¯èªå¨ç¿»è¯ï¼ä¿å设置æ¶ä¼å¯¹æªç¿»è¯/åæå·²ä¿®æ¹çæ¡ç®èªå¨ç¿»è¯ä¸º 6 ç§è¯è¨')"})]})]}),n.jsx(I,{margin:"12px"}),n.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 w-full",children:[n.jsxs("div",{className:"flex gap-2 w-full md:w-auto order-2 md:order-1",children:[n.jsx(d,{theme:"light",type:"primary",icon:n.jsx(Ye,{size:14}),className:"w-full md:w-auto",onClick:()=>{f(null),A({url:"",description:"",route:"",color:"blue"}),c(!0)},children:s("æ·»å API")}),n.jsxs(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",onClick:()=>{if(0===B.length)return void je(s("请å
éæ©è¦å é¤çAPIä¿¡æ¯"));const e=l.filter(e=>!B.includes(e.id));r(e),F([]),z(!0),be(s('å·²å é¤ {{count}} 个APIä¿¡æ¯ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å',{count:B.length}))},disabled:0===B.length,className:"w-full md:w-auto",children:[s("æ¹éå é¤")," ",B.length>0&&`(${B.length})`]}),n.jsx(d,{icon:n.jsx(Ze,{size:14}),onClick:async()=>{try{k(!0);let e=l;const t=JSON.stringify(e);await(async(e,t)=>{const n=await ye.put("/api/option/admin",{key:"console_setting.api_info",value:t}),{success:l,message:a}=n.data;l?(be(s("APIä¿¡æ¯å·²æ´æ°")),i&&i()):je(a)})(0,t),z(!1)}catch(e){console.error("APIä¿¡æ¯æ´æ°å¤±è´¥",e),je(s("APIä¿¡æ¯æ´æ°å¤±è´¥"))}finally{k(!1)}},loading:S,disabled:!P,type:"secondary",className:"w-full md:w-auto",children:s("ä¿å设置")})]}),n.jsxs("div",{className:"order-1 md:order-2 flex items-center gap-2",children:[n.jsx(E,{checked:W,onChange:async e=>{const t=e?"true":"false";try{const n=await ye.put("/api/option/admin",{key:"console_setting.api_info_enabled",value:t});n.data.success?(J(e),be(s("设置已ä¿å")),i?.()):je(n.data.message)}catch(n){je(n.message)}}}),n.jsx(Cn,{children:s(W?"å·²å¯ç¨":"å·²ç¦ç¨")})]})]})]}),children:n.jsx(v,{columns:G,dataSource:(()=>{const e=(M-1)*D,t=e+D;return l.slice(e,t)})(),rowSelection:q,rowKey:"id",scroll:{x:"max-content"},pagination:{currentPage:M,pageSize:D,total:l.length,showSizeChanger:!0,showQuickJumper:!0,formatPageText:e=>s("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:l.length}),pageSizeOptions:["5","10","20","50"],onChange:(e,t)=>
1{O(e),L(t)},onShowSizeChange:(e,t)=>{O(1),L(t)}},size:"middle",loading:S,empty:n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:s("ææ APIä¿¡æ¯"),style:{padding:30}}),className:"overflow-hidden"})}),n.jsx(x,{title:s(y?"ç¼è¾API":"æ·»å API"),visible:o,onOk:async()=>{if(N.url&&N.route&&N.description)try{let e;if(_(!0),y)e=l.map(e=>e.id===y.id?{...e,...N}:e);else{const t={id:Math.max(...l.map(e=>e.id),0)+1,...N};e=[...l,t]}r(e),z(!0),c(!1),be(s(y?'APIä¿¡æ¯å·²æ´æ°ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å':'APIä¿¡æ¯å·²æ·»å ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å'))}catch(e){je(s("æä½å¤±è´¥")+": "+e.message)}finally{_(!1)}else je(s("请填å宿´çAPIä¿¡æ¯"))},onCancel:()=>c(!1),okText:s("ä¿å"),cancelText:s("åæ¶"),confirmLoading:b,children:n.jsxs(a,{layout:"vertical",initValues:N,children:[n.jsx(a.Input,{field:"url",label:s("APIå°å"),placeholder:"https://api.example.com",rules:[{required:!0,message:s("请è¾å
¥APIå°å")}],onChange:e=>A({...N,url:e})}),n.jsx(a.Input,{field:"route",label:s("线路æè¿°"),placeholder:s("å¦ï¼é¦æ¸¯çº¿è·¯"),rules:[{required:!0,message:s("请è¾å
¥çº¿è·¯æè¿°")}],onChange:e=>A({...N,route:e})}),n.jsx(a.Input,{field:"description",label:s("说æ"),placeholder:s("å¦ï¼å¤§å¸¦å®½æ¹éåæå¾çæ¨è"),rules:[{required:!0,message:s("请è¾å
¥è¯´æ")}],onChange:e=>A({...N,description:e})}),n.jsx(a.Select,{field:"color",label:s("æ è¯é¢è²"),optionList:[{value:"blue",label:"blue"},{value:"green",label:"green"},{value:"cyan",label:"cyan"},{value:"purple",label:"purple"},{value:"pink",label:"pink"},{value:"red",label:"red"},{value:"orange",label:"orange"},{value:"amber",label:"amber"},{value:"yellow",label:"yellow"},{value:"lime",label:"lime"},{value:"light-green",label:"light-green"},{value:"teal",label:"teal"},{value:"light-blue",label:"light-blue"},{value:"indigo",label:"indigo"},{value:"violet",label:"violet"},{value:"grey",label:"grey"}],onChange:e=>A({...N,color:e}),render:e=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx(R,{size:"extra-extra-small",color:e.value}),e.label]})})]},y?y.id:"new")}),n.jsx(x,{title:s("确认å é¤"),visible:u,onOk:()=>{if(h){const e=l.filter(e=>e.id!==h.id);r(e),z(!0),be(s('APIä¿¡æ¯å·²å é¤ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å'))}p(!1),m(null)},onCancel:()=>{p(!1),m(null)},okText:s("确认å é¤"),cancelText:s("åæ¶"),type:"warning",okButtonProps:{type:"danger",theme:"solid"},children:n.jsx(Cn,{children:s("ç¡®å®è¦å 餿¤APIä¿¡æ¯åï¼")})}),n.jsx(xn,{visible:!!U,onClose:()=>V(null),item:U||{},fields:Tn.map(e=>({...e,label:s(e.label)})),translationEnabled:K,onApply:e=>{if(!U)return;const t=l.map(t=>t.id===U.id?{...t,...e}:t);r(t),z(!0)}})]})},En=()=>{const{t:e}=ge();let[i,s]=t.useState({"console_setting.api_info":"","console_setting.announcements":"","console_setting.faq":"","console_setting.uptime_kuma_groups":"","console_setting.api_info_enabled":"","console_setting.announcements_enabled":"","console_setting.faq_enabled":"","console_setting.uptime_kuma_enabled":"","translation_setting.enabled":!1,DataExportEnabled:!1,DataExportDefaultTime:"hour",DataExportInterval:5}),[l,a]=t.useState(!1);async function o(){try{a(!0),await(async()=>{const e=await ye.get("/api/option/admin"),{success:t,message:n,data:l}=e.data;if(t){let e={};l.forEach(t=>{t.key in i&&(e[t.key]=t.value),t.key.endsWith("Enabled")&&"DataExportEnabled"===t.key&&(e[t.key]=an(t.value)),"translation_setting.enabled"===t.key&&(e[t.key]=an(t.value))}),s(e)}else je(n)})()}catch(t){je(e("å·æ°å¤±è´¥")),console.error(t)}finally{a(!1)}}return t.useEffect(()=>{o()},[]),n.jsx(n.Fragment,{children:n.jsxs(m,{spinning:l,size:"large",children:[n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(pn,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(jn,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(In,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Sn,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(vn,{options:i,refresh:o})})]})})},Rn=()=>{const{t:e}=ge();let[i,s]=t.useState({Notice:"",NoticeI18n:"",SystemName:"",SystemNameEn:"",Logo:"",Footer:"",About:"",HomePageContent:""}),[l,u]=t.useState(!1);const[p,m]=t.useState(!1),[y,b]=t.useContext(Te),[_,S]=t.useState({tag_name:"",content:""}),k=async(e,t)=>{u(!0);const n=await ye.put("/api/option/",{key:e,value:t}),{success:i,message:l}=n.data;i?s(n=>({...n,[e]:t})):je(l),u(!1)},[v,C]=t.useState([]),[w,T]=t.useState(!1),[I,E]=t.useState({Notice:!1,SystemName:!1,SystemNameEn:!1,Logo:!1,HomePageContent:!1,About:!1,Footer:!1,CheckUpdate:!1}),R=async(e,t)=>{const n=t.target.id;s(t=>({...t,[n]:e}))},z=t.useRef(),N=t.useRef();return t.useEffect(()=>{(async()=>{const e=await ye.get("/api/option/"),{success:t,message:n,data:l}=e.data;if(t){let e={};if(l.forEach(t=>{t.key in i&&(e[t.key]=t.value)}),e.NoticeI18n){const t=Nt(e.NoticeI18n);"structured"===t.type?C(Object.keys(t.texts||{}).filter(e=>"zh"!==e)):C([])}s(e),z.current.setValues(e),N.current.setValues(e)}else je(n)})()},[]),n.jsxs(o,{children:[n.jsxs(c,{span:24,style:{marginTop:"10px",display:"flex",flexDirection:"column",gap:"10px"},children:[n.jsx(a,{children:n.jsx(r,{children:n.jsxs(a.Section,{text:e("ç³»ç»ä¿¡æ¯"),children:[n.jsx(o,{children:n.jsx(c,{span:16,children:n.jsxs(g,{children:[n.jsxs(P,{children:[e("å½åçæ¬"),"ï¼",y?.status?.version||e("æªç¥")]}),n.jsx(d,{type:"primary",onClick:async()=>{try{E(e=>({...e,CheckUpdate:!0}));const t=await fetch("https://api.github.com/repos/Calcium-Ion/new-api/releases/latest",{headers:{Accept:"application/json","Content-Type":"application/json","User-Agent":"new-api-update-checker"}}).then(e=>e.json()),{tag_name:n,body:i}=t;n===y?.status?.version?be(e("å·²æ¯ææ°çæ¬ï¼{{version}}",{version:n})):(S({tag_name:n,content:zt.parse(i)}),m(!0))}catch(t){console.error("Failed to check for updates:",t),je(e("æ£æ¥æ´æ°å¤±è´¥ï¼è¯·ç¨ååè¯"))}finally{E(e=>({...e,CheckUpdate:!1}))}},loading:I.CheckUpdate,children:e("æ£æ¥æ´æ°")})]})})}),n.jsx(o,{children:n.jsx(c,{span:16,children:n.jsxs(P,{children:[e("å¯å¨æ¶é´"),"ï¼",(()=>{const e=y?.status?.start_time;return y.status?Ie(e):""})()]})})})]})})}),n.jsx(a,{values:i,getFormApi:e=>z.current=e,children:n.jsx(r,{children:n.jsxs(a.Section,{text:e("éç¨è®¾ç½®"),children:[n.jsx(a.TextArea,{label:e("å
¬å"),placeholder:e("卿¤è¾å
¥æ°çå
¬åå
å®¹ï¼æ¯æ Markdown & HTML 代ç "),field:"Notice",onChange:R,style:{fontFamily:"JetBrains Mono, Consolas"},autosize:{minRows:6,maxRows:12}}
1),n.jsxs(g,{align:"center",style:{flexWrap:"wrap",gap:8},children:[n.jsx(d,{onClick:async()=>{try{E(e=>({...e,Notice:!0})),await k("Notice",i.Notice),await k("NoticeI18n",""),C([]),be(e("å
¬åå·²æ´æ°"))}catch(t){console.error(e("å
¬åæ´æ°å¤±è´¥"),t),je(e("å
¬åæ´æ°å¤±è´¥"))}finally{E(e=>({...e,Notice:!1}))}},loading:I.Notice,children:e("设置å
¬å")}),n.jsx(f,{content:e("èªå¨æåæ®µè½ææ¬å ä½ç¬¦ï¼åéè¿ AI ç¿»è¯ä¸º 6 ç§è¯è¨ï¼ä¿åä¸ºç»æåå
¬å"),children:n.jsx(d,{icon:n.jsx(Ge,{size:14}),type:"secondary",onClick:async()=>{const t=i.Notice||"";if(t.trim()){T(!0);try{const n=zt.parse(t),i=await ye.post("/api/notice/extract-and-translate",{content:n}),{success:s,message:l,data:a}=i.data;if(!s)return void je(l);const r={original:n,template:a.template,texts:a.texts};await k("NoticeI18n",JSON.stringify(r));const o=Object.keys(a.texts||{}).filter(e=>"zh"!==e);if(C(o),be(e("å
¬å已翻è¯ä¸º {{count}} ç§è¯è¨",{count:o.length})),a.errors&&Object.keys(a.errors).length>0){const t=Object.keys(a.errors).join(", ");je(e("é¨åè¯è¨ç¿»è¯å¤±è´¥")+": "+t)}}catch(n){je(e("ç¿»è¯å¤±è´¥")+": "+n.message)}finally{T(!1)}}else je(e("请å
å¡«åå
¬åå
容"))},loading:w,children:e("æåå¹¶ç¿»è¯")})}),v.length>0&&n.jsxs(j,{color:"green",size:"small",children:[e("å·²ç¿»è¯ {{count}} è¯è¨",{count:v.length}),"ï¼",v.join(" / ")]})]})]})})}),n.jsx(a,{values:i,getFormApi:e=>N.current=e,children:n.jsx(r,{children:n.jsxs(a.Section,{text:e("个æ§å设置"),children:[n.jsx(a.Input,{label:e("ç³»ç»åç§°"),placeholder:e("卿¤è¾å
¥ç³»ç»åç§°"),field:"SystemName",onChange:R}),n.jsx(d,{onClick:async()=>{try{E(e=>({...e,SystemName:!0})),await k("SystemName",i.SystemName),be(e("ç³»ç»åç§°å·²æ´æ°"))}catch(t){console.error(e("ç³»ç»åç§°æ´æ°å¤±è´¥"),t),je(e("ç³»ç»åç§°æ´æ°å¤±è´¥"))}finally{E(e=>({...e,SystemName:!1}))}},loading:I.SystemName,children:e("设置系ç»åç§°")}),n.jsx(a.Input,{label:e("ç³»ç»åç§°ï¼è±æï¼"),placeholder:e("卿¤è¾å
¥è±æç³»ç»åç§°"),field:"SystemNameEn",onChange:R}),n.jsx(d,{onClick:async()=>{try{E(e=>({...e,SystemNameEn:!0})),await k("SystemNameEn",i.SystemNameEn),be(e("è±æç³»ç»åç§°å·²æ´æ°"))}catch(t){console.error(e("è±æç³»ç»åç§°æ´æ°å¤±è´¥"),t),je(e("è±æç³»ç»åç§°æ´æ°å¤±è´¥"))}finally{E(e=>({...e,SystemNameEn:!1}))}},loading:I.SystemNameEn,children:e("è®¾ç½®è±æç³»ç»åç§°")}),n.jsx(a.Input,{label:e("Logo å¾çå°å"),placeholder:e("卿¤è¾å
¥ Logo å¾çå°å"),field:"Logo",onChange:R}),n.jsx(d,{onClick:async()=>{try{E(e=>({...e,Logo:!0})),await k("Logo",i.Logo),be(e("Logo å·²æ´æ°"))}catch(t){console.error("Logo æ´æ°å¤±è´¥",t),je(e("Logo æ´æ°å¤±è´¥"))}finally{E(e=>({...e,Logo:!1}))}},loading:I.Logo,children:e("设置 Logo")}),n.jsx(a.TextArea,{label:e("é¦é¡µå
容"),placeholder:e("other_hint_002"),field:"HomePageContent",onChange:R,style:{fontFamily:"JetBrains Mono, Consolas"},autosize:{minRows:6,maxRows:12}}),n.jsx(d,{onClick:()=>(async t=>{try{E(e=>({...e,HomePageContent:!0})),await k(t,i[t]),be(e("é¦é¡µå
å®¹å·²æ´æ°"))}catch(n){console.error("é¦é¡µå
å®¹æ´æ°å¤±è´¥",n),je(e("é¦é¡µå
å®¹æ´æ°å¤±è´¥"))}finally{E(e=>({...e,HomePageContent:!1}))}})("HomePageContent"),loading:I.HomePageContent,children:e("设置é¦é¡µå
容")}),n.jsx(a.TextArea,{label:e("å
³äº"),placeholder:e("other_hint_001"),field:"About",onChange:R,style:{fontFamily:"JetBrains Mono, Consolas"},autosize:{minRows:6,maxRows:12}}),n.jsx(d,{onClick:async()=>{try{E(e=>({...e,About:!0})),await k("About",i.About),be(e("å
³äºå
å®¹å·²æ´æ°"))}catch(t){console.error("å
³äºå
å®¹æ´æ°å¤±è´¥",t),je(e("å
³äºå
å®¹æ´æ°å¤±è´¥"))}finally{E(e=>({...e,About:!1}))}},loading:I.About,children:e("设置å
³äº")}),n.jsx(h,{fullMode:!1,type:"info",description:e("ç§»é¤ One API ççææ è¯å¿
é¡»é¦å
è·å¾ææï¼é¡¹ç®ç»´æ¤éè¦è±è´¹å¤§éç²¾åï¼å¦ææ¬é¡¹ç®å¯¹ä½ ææä¹ï¼è¯·ä¸»å¨æ¯ææ¬é¡¹ç®"),closeIcon:null,style:{marginTop:15}}),n.jsx(a.Input,{label:e("页è"),placeholder:e("卿¤è¾å
¥æ°ç页èï¼ç空å使ç¨é»è®¤é¡µèï¼æ¯æ HTML 代ç "),field:"Footer",onChange:R}),n.jsx(d,{onClick:async()=>{try{E(e=>({...e,Footer:!0})),await k("Footer",i.Footer),be(e("页èå
å®¹å·²æ´æ°"))}catch(t){console.error("页èå
å®¹æ´æ°å¤±è´¥",t),je(e("页èå
å®¹æ´æ°å¤±è´¥"))}finally{E(e=>({...e,Footer:!1}))}},loading:I.Footer,children:e("设置页è")})]})})})]}),n.jsx(x,{title:e("æ°çæ¬")+"ï¼"+_.tag_name,visible:p,onCancel:()=>m(!1),footer:[n.jsx(d,{type:"primary",onClick:()=>{m(!1),window.open(`https://github.com/Calcium-Ion/new-api/releases/tag/${_.tag_name}`,"_blank")},children:e("详æ
")},"details")],children:n.jsx("div",{dangerouslySetInnerHTML:{__html:_.content}})})]})},{Text:Pn}=u;function zn(e){const{t:i}=ge(),[s,l]=t.useState(!1),[u,p]=t.useState(!1),[g,y]=t.useState({TopUpLink:"","general_setting.docs_link":"",CurrencyType:"USD",CustomCurrencySymbol:"$",CustomCurrencyExchangeRate:"",QuotaPerUnit:"",RetryTimes:"",USDExchangeRate:"",DisplayTokenStatEnabled:!1,DefaultCollapseSidebar:!1,DemoSiteEnabled:!1,SelfUseModeEnabled:!1,CustomMenuLinks:""}),j=t.useRef(),[f,b]=t.useState(g),[_,S]=t.useState([]),v=(e,t,n
1)=>{const i=[..._];i[e]={...i[e],[t]:n},S(i)};function C(e){return t=>{y(n=>({...n,[e]:t}))}}const w=t.useMemo(()=>{const e=g.CurrencyType;return"USD"===e?"1":"CNY"===e?String(g.USDExchangeRate||""):"TOKENS"===e?String(g.QuotaPerUnit||""):"CUSTOM"===e?String(g.CustomCurrencyExchangeRate||""):""},[g]);function T(){const t=JSON.stringify(_.filter(e=>e.name&&e.url)),n={...g,CustomMenuLinks:t};g.CustomCurrencyExchangeRate,f.CustomCurrencyExchangeRate;const s=ke(n,f);if(!s.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const a=s.map(e=>{let t="";return t="boolean"==typeof n[e.key]?String(n[e.key]):n[e.key],ye.put(Se(),{key:e.key,value:t})});l(!0),Promise.all(a).then(t=>{if(1===a.length){if(t.includes(void 0))return}else if(a.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})}return t.useEffect(()=>{const t={...g};for(let i in e.options)Object.keys(g).includes(i)&&(t[i]=e.options[i]);if(void 0===t.CurrencyType&&void 0!==e.options?.DisplayInCurrencyEnabled&&(t.CurrencyType=e.options.DisplayInCurrencyEnabled?"USD":"TOKENS"),t.CurrencyType||(t.CurrencyType="USD"),t.CustomCurrencySymbol||(t.CustomCurrencySymbol="$"),void 0!==t.CustomCurrencyExchangeRate&&""!==t.CustomCurrencyExchangeRate||(t.CustomCurrencyExchangeRate="1"),void 0!==t.USDExchangeRate&&""!==t.USDExchangeRate||(t.USDExchangeRate="7.3"),void 0!==t.QuotaPerUnit&&""!==t.QuotaPerUnit||(t.QuotaPerUnit="500000"),y(t),b(structuredClone(t)),j.current&&j.current.setValues(t),e.options.CustomMenuLinks)try{const t=JSON.parse(e.options.CustomMenuLinks);Array.isArray(t)&&S(t)}catch(n){console.error("è§£æèªå®ä¹èå龿¥å¤±è´¥",n)}},[e.options]),n.jsxs(n.Fragment,{children:[n.jsx(m,{spinning:s,children:n.jsxs(a,{values:g,getFormApi:e=>j.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:i("éç¨è®¾ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"TopUpLink",label:i("å
å¼é¾æ¥"),initValue:"",placeholder:i("ä¾å¦åå¡ç½ç«çè´ä¹°é¾æ¥"),onChange:C("TopUpLink"),showClear:!0})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"general_setting.docs_link",label:i("ææ¡£å°å"),initValue:"",placeholder:i("ä¾å¦ https://docs.newapi.pro"),onChange:C("general_setting.docs_link"),showClear:!0})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"RetryTimes",label:i("失败éè¯æ¬¡æ°"),initValue:"",placeholder:i("失败éè¯æ¬¡æ°"),onChange:C("RetryTimes"),showClear:!0})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Slot,{label:i("ç«ç¹é¢åº¦å±ç¤ºç±»ååæ±ç"),children:n.jsxs(z,{style:{width:"100%"},children:[n.jsx(k,{prefix:"1 USD = ",style:{width:"50%"},value:w,onChange:e=>{const t=g.CurrencyType;"CNY"===t?C("USDExchangeRate")(e):"TOKENS"===t?C("QuotaPerUnit")(e):"CUSTOM"===t&&C("CustomCurrencyExchangeRate")(e)},disabled:"USD"===g.CurrencyType}),n.jsxs(N,{style:{width:"50%"}
1,value:g.CurrencyType,onChange:C("CurrencyType"),children:[n.jsx(N.Option,{value:"USD",children:"USD ($)"}),n.jsx(N.Option,{value:"CNY",children:"CNY (Â¥)"}),n.jsx(N.Option,{value:"TOKENS",children:"Tokens"}),n.jsx(N.Option,{value:"CUSTOM",children:i("èªå®ä¹è´§å¸")})]})]})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"CustomCurrencySymbol",label:i("èªå®ä¹è´§å¸ç¬¦å·"),initValue:"$",placeholder:i("ä¾å¦ â¬, £, Rp, â©, â¹..."),onChange:C("CustomCurrencySymbol"),showClear:!0,disabled:"CUSTOM"!==g.CurrencyType})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"DisplayTokenStatEnabled",label:i("é¢åº¦æ¥è¯¢æ¥å£è¿å令çé¢åº¦èéç¨æ·é¢åº¦"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:C("DisplayTokenStatEnabled")})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"DefaultCollapseSidebar",label:i("é»è®¤æå ä¾§è¾¹æ "),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:C("DefaultCollapseSidebar")})})]}),n.jsxs(o,{children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"DemoSiteEnabled",label:i("æ¼ç¤ºç«ç¹æ¨¡å¼"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:C("DemoSiteEnabled")})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"SelfUseModeEnabled",label:i("èªç¨æ¨¡å¼"),extraText:i("å¼å¯åä¸éå¶ï¼å¿
须设置模ååç"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:C("SelfUseModeEnabled")})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:T,children:i("ä¿åéç¨è®¾ç½®")})})]}),n.jsxs(a.Section,{text:i("èªå®ä¹èå龿¥"),children:[n.jsx(Pn,{type:"tertiary",style:{display:"block",marginBottom:16},children:i("æ·»å èªå®ä¹èå龿¥ï¼å°å¨é¡¶é¨å¯¼èªæ åä¾§è¾¹æ 䏿¾ç¤ºï¼ç¹å»åè·³è½¬å°æå®å°å")}),_.map((e,t)=>n.jsx(r,{style:{marginBottom:16},title:`${i("龿¥")} ${t+1}`,headerExtraContent:n.jsx(d,{type:"danger",theme:"borderless",icon:n.jsx(He,{size:16}),onClick:()=>(e=>{const t=[..._];t.splice(e,1),S(t)})(t),children:i("å é¤")}),children:n.jsxs(o,{gutter:16,children:[n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx(Pn,{strong:!0,children:i("åç§°")}),n.jsx(Pn,{type:"tertiary",style:{marginLeft:8},children:i("æ¾ç¤ºå¨èåä¸çåç§°")})]}),n.jsx(k,{value:e.name,onChange:e=>v(t,"name",e),placeholder:i("ä¾å¦ï¼å¸®å©ä¸å¿"),style:{width:"100%"}})]}),n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx(Pn,{strong:!0,children:i("龿¥å°å")}),n.jsx(Pn,{type:"tertiary",style:{marginLeft:8},children:i("ç¹å»å跳转çURL")})]}),n.jsx(k,{value:e.url,onChange:e=>v(t,"url",e),placeholder:i("ä¾å¦ï¼https://help.example.com"),style:{width:"100%"}})]})]})},t)),n.jsx(d,{icon:n.jsx(Ye,{size:16}),onClick:()=>{S([..._,{name:"",url:""}])},style:{marginBottom:16},children:i("æ·»å 龿¥")}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:T,children:i("ä¿åèªå®ä¹èå龿¥")})})]})]})}),n.jsx(x,{title:i("è¦å"),visible:u,onOk:()=>p(!1),onCancel:()=>p(!1),closeOnEsc:!0,width:500,children:n.jsx(h,{type:"warning",description:i("æ¤è®¾ç½®ç¨äºç³»ç»å
é¨è®¡ç®ï¼é»è®¤å¼500000æ¯ä¸ºäºç²¾ç¡®å°6ä½å°æ°ç¹è®¾è®¡ï¼ä¸æ¨èä¿®æ¹ã"),bordered:!0,fullMode:!1,closeIcon:null})})]})}function Nn(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({CheckSensitiveEnabled:!1,CheckSensitiveOnPromptEnabled:!1,SensitiveWords:"",SensitiveCheckWhitelistUserIds:"",ChannelSpecifyWhitelistEnabled:!1,ChannelSpecifyWhitelistUserIds:""}),p=t.useRef(),[h,x]=t.useState(r);return t.useEffect(()=>{const t={};for(let n in r)t[n]=void 0!==e.options[n]?e.options[n]:r[n];u(t),x(structuredClone(t)),p.current.setValues(t)},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("å±è½è¯è¿æ»¤è®¾ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"CheckSensitiveEnabled",label:i("å¯ç¨å±è½è¯è¿æ»¤åè½"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{u({...r,CheckSensitiveEnabled:e})}})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"CheckSensitiveOnPromptEnabled",label:i("å¯ç¨ Prompt æ£æ¥"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>u({...r,CheckSensitiveOnPromptEnabled:e})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"ChannelSpecifyWhitelistEnabled",label:i("å¯ç¨æå®æ¸ éIDç½åå"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>u({...r,ChannelSpecifyWhitelistEnabled:e})})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.TextArea,{label:i("å±è½è¯å表"),extraText:i("ä¸è¡ä¸ä¸ªå±è½è¯ï¼ä¸éè¦ç¬¦å·åå²"),placeholder:i("ä¸è¡ä¸ä¸ªå±è½è¯ï¼ä¸éè¦ç¬¦å·åå²"),field:"SensitiveWords",onChange:e=>u({...r,SensitiveWords:e}),style:{fontFamily:"JetBrains Mono, Consolas"},autosize:{minRows:6,maxRows:12}}
1)}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.TextArea,{label:i("ç½ååç¨æ·IDå表"),extraText:i("ä¸è¡ä¸ä¸ªç¨æ·IDï¼è¿äºç¨æ·å°è·³è¿ææè¯æ£æµ"),placeholder:i("ä¸è¡ä¸ä¸ªç¨æ·ID"),field:"SensitiveCheckWhitelistUserIds",onChange:e=>u({...r,SensitiveCheckWhitelistUserIds:e}),style:{fontFamily:"JetBrains Mono, Consolas"},autosize:{minRows:6,maxRows:12}})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.TextArea,{label:i("æå®æ¸ éIDç½ååç¨æ·å表"),extraText:i("ä¸è¡ä¸ä¸ªç¨æ·IDï¼è¿äºç¨æ·å¯ä½¿ç¨æå®æ¸ éIDåè½"),placeholder:i("ä¸è¡ä¸ä¸ªç¨æ·ID"),field:"ChannelSpecifyWhitelistUserIds",onChange:e=>u({...r,ChannelSpecifyWhitelistUserIds:e}),style:{fontFamily:"JetBrains Mono, Consolas"},autosize:{minRows:6,maxRows:12}})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(r,h);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t="";return t="boolean"==typeof r[e.key]?String(r[e.key]):r[e.key],ye.put(Se(),{key:e.key,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿åå±è½è¯è¿æ»¤è®¾ç½®")})})]})})})})}function An(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState(!1),[p,h]=t.useState({LogConsumeEnabled:!1,LogFailureEnabled:!1,historyTimestamp:At().subtract(1,"month").toDate()}),x=t.useRef(),[g,y]=t.useState(p);return t.useEffect(()=>{const t={};for(let n in e.options)Object.keys(p).includes(n)&&(t[n]=e.options[n]);t.historyTimestamp=p.historyTimestamp,h(Object.assign(p,t)),y(structuredClone(t)),x.current.setValues(t)},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:s,children:n.jsx(a,{values:p,getFormApi:e=>x.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("æ¥å¿è®¾ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"LogConsumeEnabled",label:i("å¯ç¨é¢åº¦æ¶è´¹æ¥å¿è®°å½"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{h({...p,LogConsumeEnabled:e})}})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"LogFailureEnabled",label:i("å¯ç¨å¤±è´¥æ¥å¿è®°å½"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{h({...p,LogFailureEnabled:e})}})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsxs(m,{spinning:r,children:[n.jsx(a.DatePicker,{label:i("æ¥å¿è®°å½æ¶é´"),field:"historyTimestamp",type:"dateTime",inputReadOnly:!0,onChange:e=>{h({...p,historyTimestamp:e})}}),n.jsx(d,{size:"default",onClick:async function(){try{if(u(!0),!p.historyTimestamp)throw new Error(i("è¯·éæ©æ¥å¿è®°å½æ¶é´"));const e=await ye.delete("/api/log/?target_timestamp="+Date.parse(p.historyTimestamp)/1e3),{success:t,message:n,data:s}=e.data;if(t)return void be(i("{{count}} æ¡æ¥å¿å·²æ¸
çï¼",{count:s}));throw new Error(i("æ¥å¿æ¸
ç失败ï¼{{message}}",{message:n}))}catch(e){je(e.message)}finally{u(!1)}},children:i("æ¸
é¤å岿¥å¿")})]})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(p,g).filter(e=>"historyTimestamp"!==e.key);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t="";return t="boolean"==typeof p[e.key]?String(p[e.key]):p[e.key],ye.put(Se(),{key:e.key,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿åæ¥å¿è®¾ç½®")})})]})})})})}function Mn(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({ChannelDisableThreshold:"",QuotaRemindThreshold:"",AutomaticDisableChannelEnabled:!1,AutomaticEnableChannelEnabled:!1}),p=t.useRef(),[h,x]=t.useState(r);return t.useEffect(()=>{if(!e.options||0===Object.keys(e.options).length)return;const t={},n=Object.keys(r);for(let i in e.options)n.includes(i)&&(t[i]=e.options[i]);
1n.forEach(e=>{e in t||(t[e]=r[e])}),u(t),x(structuredClone(t)),p.current&&p.current.setValues(t)},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("çæ§è®¾ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("æµè¯æææ¸ éçæé¿ååºæ¶é´"),step:1,min:0,suffix:i("ç§"),extraText:i("å½è¿è¡ééå
¨é¨æµè¯æ¶ï¼è¶
è¿æ¤æ¶é´å°èªå¨ç¦ç¨éé"),placeholder:"",field:"ChannelDisableThreshold",onChange:e=>u({...r,ChannelDisableThreshold:String(e)})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("é¢åº¦æééå¼"),step:1,min:0,suffix:"Token",extraText:i("ä½äºæ¤é¢åº¦æ¶å°åéé®ä»¶æéç¨æ·"),placeholder:"",field:"QuotaRemindThreshold",onChange:e=>u({...r,QuotaRemindThreshold:String(e)})})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"AutomaticDisableChannelEnabled",label:i("失败æ¶èªå¨ç¦ç¨éé"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{u({...r,AutomaticDisableChannelEnabled:e})}})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"AutomaticEnableChannelEnabled",label:i("æåæ¶èªå¨å¯ç¨éé"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>u({...r,AutomaticEnableChannelEnabled:e})})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(r,h);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t="";return t="boolean"==typeof r[e.key]?String(r[e.key]):r[e.key],ye.put(Se(),{key:e.key,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿åçæ§è®¾ç½®")})})]})})})})}function On(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({QuotaForNewUser:"",PreConsumedQuota:"",QuotaForInviter:"",QuotaForInvitee:""}),p=t.useRef(),[h,x]=t.useState(r);return t.useEffect(()=>{const t={};for(let n in e.options)Object.keys(r).includes(n)&&(t[n]=e.options[n]);u(t),x(structuredClone(t)),p.current.setValues(t)},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("é¢åº¦è®¾ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("æ°ç¨æ·åå§é¢åº¦"),field:"QuotaForNewUser",step:1,min:0,suffix:"Token",placeholder:"",onChange:e=>u({...r,QuotaForNewUser:String(e)})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("请æ±é¢æ£è´¹é¢åº¦"),field:"PreConsumedQuota",step:1,min:0,suffix:"Token",extraText:i("请æ±ç»æåå¤éå°è¡¥"),placeholder:"",onChange:e=>u({...r,PreConsumedQuota:String(e)})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("é请æ°ç¨æ·å¥å±é¢åº¦"),field:"QuotaForInviter",step:1,min:0,suffix:"Token",extraText:"",placeholder:i("ä¾å¦ï¼2000"),onChange:e=>u({...r,QuotaForInviter:String(e)})})})]}),n.jsx(o,{children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:6,children:n.jsx(a.InputNumber,{label:i("æ°ç¨æ·ä½¿ç¨é请ç å¥å±é¢åº¦"),field:"QuotaForInvitee",step:1,min:0,suffix:"Token",extraText:"",placeholder:i("ä¾å¦ï¼1000"),onChange:e=>u({...r,QuotaForInvitee:String(e)})})})}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(r,h);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t="";return t="boolean"==typeof r[e.key]?String(r[e.key]):r[e.key],ye.put(Se(),{key:e.key,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿åé¢åº¦è®¾ç½®")})})]})})})})}function Dn(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,p]=t.useState({"checkin_setting.enabled":!1,"checkin_setting.min_quota":1e3,"checkin_setting.max_quota":1e4}),h=t.useRef(),[x,g]=t.useState({"checkin_setting.enabled":!1,"checkin_setting.min_quota":1e3,"checkin_setting.max_quota":1e4}),[y,j]=t.useState(!1);function f(e){return t=>{p(n=>({...n,[e]:t}))}}return t.useEffect(()=>{if(!e.options)return;const t={"checkin_setting.enabled":!1,"checkin_setting.min_quota":1e3,"checkin_setting.max_quota":1e4},n="checkin_setting.enabled"in e.options||"checkin_setting.min_quota"in e.options||"checkin_setting.max_quota"in e.options;if(j(n),"checkin_setting.enabled"in e.options&&(t["checkin_setting.enabled"]=e.options["checkin_setting.enabled"]),"checkin_setting.min_quota"in e.options){const n=e.options["checkin_setting.min_quota"];t["checkin_setting.min_quota"]="number"==typeof n?n:parseInt(n)||1e3}if("checkin_setting.max_quota"in e.options){const n=e.options["checkin_setting.max_quota"];t["checkin_setting.max_quota"]="number"==typeof n?n:parseInt(n)||1e4}p(t),g(structuredClone(t)),h.current&&h.current.setValues(t)},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>h.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("ç¾å°è®¾ç½®"),children:[n.jsx(u.Text,{type:"tertiary",style:{marginBottom:16,display:"block"},children:i("ç¾å°åè½å
è®¸ç¨æ·æ¯æ¥ç¾å°è·åéæºé¢åº¦å¥å±")}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"checkin_setting.enabled",label:i("å¯ç¨ç¾å°åè½"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:f("checkin_setting.enabled")})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"checkin_setting.min_quota",label:i("ç¾å°æå°é¢åº¦"),placeholder:i("ç¾å°å¥å±çæå°é¢åº¦"),onChange:f("checkin_setting.min_quota"),min:0,disabled:!r["checkin_setting.enabled"]})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"checkin_setting.max_quota",label:i("ç¾å°æå¤§é¢åº¦"),placeholder:i("ç¾å°å¥å±çæå¤§é¢åº¦"),onChange:f("checkin_setting.max_quota"),min:0,disabled:!r["checkin_setting.enabled"]})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(r,x);if(!t.length&&y)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=(y?t.map(e=>e.key):Object.keys(r)).map(e=>{let t="";return r[e],t=String(r[e]),ye.put(Se(),{key:e,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿åç¾å°è®¾ç½®")})})]})})})})}const Ln={"withdraw_setting.min_quota":"","withdraw_setting.max_quota":"","withdraw_setting.bound_invoice_max_per_tx_rmb":"5000","withdraw_setting.personal_daily_cap_rmb":"500","withdraw_setting.strict_payee_match":!0,"withdraw_setting.our_company_name":"","withdraw_setting.our_company_tax_no":"","aliyun_setting.invoice_ocr_app_code":"","aliyun_setting.invoice_verify_app_code":"","aliyun_setting.invoice_ocr_endpoint":"","aliyun_setting.invoice_verify_endpoint":""},Bn=new Set(["withdraw_setting.strict_payee_match"]);function Fn(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState(Ln),p=t.useRef(),[x,g]=t.useState(r);function y(){const t=ke(r,x);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t="";return t="boolean"==typeof r[e.key]?String(r[e.key]):r[e.key],ye.put(Se(),{key:e.key,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})}return t.useEffect(()=>{const t={...Ln};for(let n in e.options)if(Object.keys(Ln).includes(n)){const i=e.options[n];Bn.has(n)?t[n]=!0===i||"true"===i||"1"===i||1===i:t[n]=i??""}u(t),g(structuredClone(t)),p.current&&p.current.setValues(t)},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:s,children:n.jsxs(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:i("æç°é¢åº¦éå¶"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("æä½æç°é¢åº¦"),field:"withdraw_setting.min_quota",step:1,min:0,suffix:"å
",extraText:i("ç¨æ·å次æç°çæä½éé¢ï¼è®¾ç½®ä¸º0åä¸éå¶"),onChange:e=>u({...r,"withdraw_setting.min_quota":String(e??0)})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("æé«æç°é¢åº¦"),field:"withdraw_setting.max_quota",step:1,min:0,suffix:"å
",extraText:i("ç¨æ·å次æç°çæé«éé¢ï¼è®¾ç½®ä¸º0åä¸éå¶"),onChange:e=>u({...r,"withdraw_setting.max_quota":String(e??0)})})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:y,children:i("ä¿åæç°é¢åº¦éå¶")})})]}),n.jsxs(a.Section,{text:i("æç°ç»å®å¼ç¥¨"),children:[n.jsx(h,{type:"info",fullMode:!1,closeIcon:null,description:i("ææç¨æ·æç°åèµ°ãæç°ç»å®å¼ç¥¨ãæµç¨ï¼å¯¹ç§èµ°æ¯ä»å®ï¼ä»
1
æ¯æ¥ç´¯è®¡ä¸éï¼å
å票ï¼ï¼å¯¹å
¬éå¨æç°æ¶ä¸ä¼ çé¢å票并éè¿å®¡æ ¸åæ¾æ¬¾ãä¸ååæ®µä¸ºå
¨å±çç¥ã"),style:{marginBottom:12}}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.InputNumber,{label:i("åç¬æ»ä¸é"),field:"withdraw_setting.bound_invoice_max_per_tx_rmb",step:1,min:0,suffix:"å
",extraText:i("对ç§+对å
Œ
±ç¨çåç¬ä¸éï¼é»è®¤ 5000ï¼å«çäºï¼"),onChange:e=>u({...r,"withdraw_setting.bound_invoice_max_per_tx_rmb":String(e??0)})})}),n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.InputNumber,{label:i("å¯¹ç§æ¯æ¥ç´¯è®¡ä¸é"),field:"withdraw_setting.personal_daily_cap_rmb",step:100,min:0,suffix:"å
",extraText:i("é»è®¤ 500ãåä¸ç¨æ·å½æ¥å¯¹ç§æç°ç´¯è®¡ä¸å¾è¶
è¿è¯¥å¼ï¼è¶
åºé走对å
¬çº¿"),onChange:e=>u({...r,"withdraw_setting.personal_daily_cap_rmb":String(e??0)})})}),n.jsx(c,{xs:24,sm:12,md:8,children:n.jsxs(a.Slot,{label:i("ä¸¥æ ¼æ¯å¯¹ç¨å·"),children:[n.jsx(E,{checked:!!r["withdraw_setting.strict_payee_match"],onChange:e=>u({...r,"withdraw_setting.strict_payee_match":!!e})}),n.jsx("span",{style:{marginLeft:8,color:"var(--semi-color-text-2)",fontSize:12},children:i("é»è®¤å¼å¯ï¼åç¥¨éæ¹å
¬å¸å + ç»ä¸ä¿¡ç¨ä»£ç å¿
é¡»ä¸å¯¹å
¬è´¦æ·å®å
¨ä¸è´")})]})})]}),n.jsx(h,{type:"warning",fullMode:!1,closeIcon:null,description:i('è´æ¹æ ¡éªï¼å¡«å
¥ææ¹å
¬å¸å
¨åä¸ç»ä¸ä¿¡ç¨ä»£ç åï¼å票å票æ¹å¿
é¡»å®å
¨ä¸è´æè½èªå¨éè¿ã强ç建议ç产ç¯å¢å¿
å¡«ï¼å¦å代çç论ä¸å¯æ¿ä»»ä½"å·²çå®å¼å
·çå票"æ ¸éãç空æ¶è·³è¿è¯¥æ ¡éªã'),style:{marginBottom:12,marginTop:8}}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,md:12,children:n.jsx(a.Input,{label:i("ææ¹å
¬å¸å
¨åï¼è´æ¹æ ¡éªï¼"),field:"withdraw_setting.our_company_name",placeholder:"示ä¾ï¼éåºäºä¹é¾ç½ç»ç§ææéå
¬å¸",extraText:i("éä¸è¥ä¸æ§ç
§å®å
¨ä¸è´ï¼ç空æ¶è·³è¿æ¤ç¡¬è§å"),onChange:e=>u({...r,"withdraw_setting.our_company_name":e})})}),n.jsx(c,{xs:24,md:12,children:n.jsx(a.Input,{label:i("ææ¹ç»ä¸ä¿¡ç¨ä»£ç ï¼è´æ¹æ ¡éªï¼strict 模å¼çæï¼"),field:"withdraw_setting.our_company_tax_no",placeholder:"18 ä½ç»ä¸ç¤¾ä¼ä¿¡ç¨ä»£ç ï¼ä¾å¦ 91500105MACDM4LEXT",extraText:i('ä»
å½ä¸æ¹"ä¸¥æ ¼æ¯å¯¹ç¨å·"å¼å¯æ¶çæï¼ç空æ¶è·³è¿ç¨å·æ ¡éª'),onChange:e=>u({...r,"withdraw_setting.our_company_tax_no":e})})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",theme:"solid",type:"primary",onClick:y,children:i("ä¿åæç°ç»å®å¼ç¥¨è®¾ç½®")})})]}),n.jsxs(a.Section,{text:i("é¿éäºåç¥¨æ ¸éª"),children:[n.jsx(h,{type:"info",fullMode:!1,closeIcon:null,description:i("ä»é¿éäºå¸åºè´ä¹°ãå票 OCRãåãåç¥¨æ ¸éªã两个 API ååï¼å嫿¿å° AppCode å¡«å
¥å¯¹åºæ ï¼å¹¶å¡«å
¥ååçæ¥å£å°åãå·¥åæ ¸éªå·²å¨å®åæ¶å®æï¼æ ééå¤è´ä¹°ã"),style:{marginBottom:12}}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,md:12,children:n.jsx(a.Input,{label:i("å票 OCR AppCode"),field:"aliyun_setting.invoice_ocr_app_code",placeholder:"é¿éäºå¸åºãæçæå¡ãä¸ OCR ååç AppCode",onChange:e=>u({...r,"aliyun_setting.invoice_ocr_app_code":e})})}),n.jsx(c,{xs:24,md:12,children:n.jsx(a.Input,{label:i("åç¥¨æ ¸éª AppCode"),field:"aliyun_setting.invoice_verify_app_code",placeholder:"é¿éäºå¸åºãæçæå¡ãä¸åç¥¨æ ¸éªååç AppCode",onChange:e=>u({...r,"aliyun_setting.invoice_verify_app_code":e})})}),n.jsx(c,{span:24,children:n.jsx(a.Input,{label:i("å票 OCR æ¥å£å°å"),field:"aliyun_setting.invoice_ocr_endpoint",placeholder:"https://dgfp.market.alicloudapi.com/ocrservice/invoice",extraText:i("æ¨èï¼é¿é宿¹ OCRï¼https://dgfp.market.alicloudapi.com/ocrservice/invoiceï¼ç空æ¶ä½¿ç¨æ¤é»è®¤å¼ï¼"),onChange:e=>u({...r,"aliyun_setting.invoice_ocr_endpoint":e})})}),n.jsx(c,{span:24,children:n.jsx(a.Input,{label:i("åç¥¨æ ¸éªæ¥å£å°å"),field:"aliyun_setting.invoice_verify_endpoint",placeholder:"https://invoicech1.market.alicloudapi.com/s/api/ocr/invoiceCheck",extraText:i("æ¨èï¼å¿«ç³ äºè¦ç´ æ ¸éªï¼
1宿´å°å https://invoicech1.market.alicloudapi.com/s/api/ocr/invoiceCheck ï¼æ³¨æ host æ¯ invoicech1 è䏿¯ invocheck1ï¼è·¯å¾åç¼å« /s/api 䏿¯ /apiï¼ã代ç å·²èªå¨ç¨ form-urlencoded æäº¤ï¼å¹¶å
¼å®¹å¤å®¶å段åï¼invoicingDate/invoiceDateãtotalAmount/invoiceAmount/pretaxAmountãelectronicMark/electronMarkã"),onChange:e=>u({...r,"aliyun_setting.invoice_verify_endpoint":e})})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:y,children:i("ä¿åé¿éäºé
ç½®")})})]})]})})})}function Wn(e){const{t:i}=ge(),[s,l]=t.useState(!1),r={CostDailyAggEnabled:!1,CostDailyAggScheduleMode:"interval",CostDailyAggIntervalHours:6,CostDailyAggFixedHour:2,CostDailyAggBatchSize:1e3,CostDailyAggBacklogDays:3,CostDailyAggMinDateKey:0},[u,p]=t.useState({...r}),x=["CostDailyAggIntervalHours","CostDailyAggFixedHour","CostDailyAggBatchSize","CostDailyAggBacklogDays","CostDailyAggMinDateKey"],g=t.useRef(),[y,f]=t.useState(u),[b,_]=t.useState([]),[S,k]=t.useState(!1);function C(){k(!0),ye.get("/api/admin/cost-statistics/daily-agg-states?limit=30").then(e=>{e?.data?.success&&_(e.data.data||[])}).catch(()=>{}).finally(()=>{k(!1)})}t.useEffect(()=>{C()},[]);const w={finished:"green",running:"blue",failed:"red",skipped:"orange"},T=[{title:i("æ¥æ"),dataIndex:"date_key",width:100},{title:i("ç¶æ"),dataIndex:"status",width:100,render:e=>n.jsx(j,{color:w[e]||"grey",children:e||"-"})},{title:i("æ«æè¡æ°"),dataIndex:"scanned_rows",width:110},{title:i("ç¨æ·è¡æ°"),dataIndex:"user_rows",width:100},{title:i("æ±æ»è¡æ°"),dataIndex:"summary_rows",width:100},{title:i("æªé
ç¬æ°"),dataIndex:"unconf_count",width:100},{title:i("éè¯æ¬¡æ°"),dataIndex:"retry_count",width:90},{title:i("宿æ¶é´"),dataIndex:"finished_at",width:170,render:e=>e>0?Ie(e):"-"},{title:i("ä¿¡æ¯"),dataIndex:"message",ellipsis:!0}];return t.useEffect(()=>{if(!e.options)return;const t={...r};for(let n in r)if(n in e.options){let i=e.options[n];x.includes(n)?(i=parseInt(i),Number.isNaN(i)&&(i=r[n])):"CostDailyAggEnabled"===n&&(i="boolean"==typeof i?i:"true"===i),t[n]=i}p(t),f(structuredClone(t)),g.current&&g.current.setValues(t)},[e.options]),n.jsx(m,{spinning:s,children:n.jsxs(a,{values:u,getFormApi:e=>g.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:i("æ¯æ¥ææ¬èå"),children:[n.jsx(h,{type:"info",description:i("åå°çº¿ç¨æ¯å¤©è忍天çä½¿ç¨æ¥å¿ãåæ¨ææ¬ï¼åå
¥ææ¬ç»è®¡ï¼æ¸ é/模å/æ¶é´ + ç¨æ·ç»´åº¦ï¼ãé»è®¤å
³éï¼å¤èç¹é¨ç½²æ¶èªå¨åªå¨ä¸ä¸ªèç¹æ§è¡ã"),style:{marginBottom:10}}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"CostDailyAggEnabled",label:i("å¯ç¨æ¯æ¥ææ¬èå"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>p({...u,CostDailyAggEnabled:e})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Select,{field:"CostDailyAggScheduleMode",label:i("è°åº¦æ¨¡å¼"),style:{width:"100%"},optionList:[{label:i("æé´éæ£æ¥ï¼æ¯ N å°æ¶ï¼"),value:"interval"},{label:i("æ¯å¤©å®ç¹æ£æ¥"),value:"fixed_time"}],onChange:e=>p({...u,CostDailyAggScheduleMode:e})})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"CostDailyAggIntervalHours",label:i("æ£æ¥é´éï¼å°æ¶ï¼é´é模å¼ï¼"),min:1,max:24,step:1,style:{width:"100%"},onChange:e=>p({...u,CostDailyAggIntervalHours:e})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"CostDailyAggFixedHour",label:i("å®ç¹å°æ¶ 0-23ï¼å®ç¹æ¨¡å¼ï¼"),min:0,max:23,step:1,style:{width:"100%"},onChange:e=>p({...u,CostDailyAggFixedHour:e})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"CostDailyAggBatchSize",label:i("åæ¹è¡æ°ï¼æ«æ/ååºï¼"),min:100,max:1e4,step:100,style:{width:"100%"},onChange:e=>p({...u,CostDailyAggBatchSize:e})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"CostDailyAggBacklogDays",label:i("åç天æ°ï¼é¡» ⤠ClickHouse 导å
¥åå²ä¸çï¼"),min:1,max:30,step:1,style:{width:"100%"},onChange:e=>p({...u,CostDailyAggBacklogDays:e})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"CostDailyAggMinDateKey",label:i("ææ©å¯è忥æ YYYYMMDDï¼0=ä¸éï¼è®¾ä¸º ClickHouse 已导å
¥æå¤§æ¥æ+1ï¼"),min:0,max:99991231,step:1,style:{width:"100%"},onChange:e=>p({...u,CostDailyAggMinDateKey:e})})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(u,
1y);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>ye.put("/api/option/",{key:e.key,value:String(u[e.key])}));l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿åææ¬èå设置")})})]}),n.jsxs(a.Section,{text:i("èåè¿è¡ç¶æ"),children:[n.jsx(h,{type:"info",description:i("æ¯æ¥ææ¬èååå°çº¿ç¨æè¿çè¿è¡è®°å½ï¼åªè¯»ï¼ãç¶æï¼finished æå / running è¿è¡ä¸ / failed 失败éè¯ä¸ / skipped è¿ç»å¤±è´¥å·²æ¾å¼ï¼é线ä¸è¡¥èåï¼ã"),style:{marginBottom:10}}),n.jsx(o,{style:{marginBottom:10},children:n.jsx(d,{size:"default",onClick:C,loading:S,children:i("å·æ°ç¶æ")})}),n.jsx(v,{columns:T,dataSource:b,loading:S,rowKey:"date_key",pagination:!1,size:"small"})]})]})})}const Jn=()=>{const{t:e}=ge();let[i,s]=t.useState({QuotaForNewUser:0,PreConsumedQuota:0,QuotaForInviter:0,QuotaForInvitee:0,TopUpLink:"","general_setting.docs_link":"",QuotaPerUnit:0,USDExchangeRate:0,RetryTimes:0,DisplayInCurrencyEnabled:!1,DisplayTokenStatEnabled:!1,DefaultCollapseSidebar:!1,DemoSiteEnabled:!1,SelfUseModeEnabled:!1,CustomMenuLinks:"",CheckSensitiveEnabled:!1,CheckSensitiveOnPromptEnabled:!1,SensitiveWords:"",LogConsumeEnabled:!1,ErrorLogWhitelist:"",ChannelDisableThreshold:0,QuotaRemindThreshold:0,AutomaticDisableChannelEnabled:!1,AutomaticEnableChannelEnabled:!1,AutomaticDisableKeywords:"","checkin_setting.enabled":!1,"checkin_setting.min_quota":1e3,"checkin_setting.max_quota":1e4,"withdraw_setting.min_quota":0,"withdraw_setting.max_quota":0,"withdraw_setting.bound_invoice_buffer_rmb":5e3,"withdraw_setting.bound_invoice_max_per_tx_rmb":5e3,"withdraw_setting.personal_daily_cap_rmb":500,"withdraw_setting.hard_lock_enabled":!1,"withdraw_setting.hard_lock_threshold_rmb":5e3,"withdraw_setting.strict_payee_match":!0,"withdraw_setting.our_company_name":"","withdraw_setting.our_company_tax_no":"","aliyun_setting.invoice_ocr_app_code":"","aliyun_setting.invoice_verify_app_code":"","aliyun_setting.invoice_ocr_endpoint":"","aliyun_setting.invoice_verify_endpoint":"","translation_setting.enabled":!1,"translation_setting.base_url":"","translation_setting.model":""}),[l,a]=t.useState(!1);async function o(){try{a(!0),await(async()=>{const e=await ye.get(Se()),{success:t,message:n,data:i}=e.data;if(t){let e={};i.forEach(t=>{t.key.endsWith("Enabled")||["DefaultCollapseSidebar"].includes(t.key)||"checkin_setting.enabled"===t.key||"translation_setting.enabled"===t.key?e[t.key]=an(t.value):"checkin_setting.min_quota"===t.key||"checkin_setting.max_quota"===t.key?e[t.key]=parseInt(t.value)||0:"withdraw_setting.min_quota"===t.key||"withdraw_setting.max_quota"===t.key?e[t.key]=parseFloat(t.value)||0:"withdraw_setting.hard_lock_enabled"===t.key||"withdraw_setting.strict_payee_match"===t.key?e[t.key]=an(t.value):"withdraw_setting.bound_invoice_buffer_rmb"===t.key||"withdraw_setting.bound_invoice_max_per_tx_rmb"===t.key||"withdraw_setting.personal_daily_cap_rmb"===t.key||"withdraw_setting.hard_lock_threshold_rmb"===t.key?e[t.key]=parseFloat(t.value)||0:e[t.key]=t.value}),s(e)}else je(n)})()}catch(t){je(e("å·æ°å¤±è´¥"))}finally{a(!1)}}return t.useEffect(()=>{o()},[]),n.jsx(n.Fragment,{children:n.jsxs(m,{spinning:l,size:"large",children:[n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(zn,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Nn,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(An,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Mn,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(On,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Dn,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Fn,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(cn,{options:i,refresh:o})}),Ee()&&n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Wn,{options:i,refresh:o})})]})})};function Un(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({ModelRequestRateLimitEnabled:!1,ModelRequestRateLimitCount:-1,ModelRequestRateLimitSuccessCount:1e3,ModelRequestRateLimitDurationMinutes:1,ModelRequestRateLimitGroup:""}),p=t.useRef(),[h,x]=t.useState(r);return t.useEffect(()=>{const t={};for(let n in e.options)Object.keys(r).includes(n)&&(t[n]=e.options[n]);u(t),x(structuredClone(t)),p.current.setValues(t)},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("模å请æ±éçéå¶"),children:[n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"ModelRequestRateLimitEnabled",label:i("å¯ç¨ç¨æ·æ¨¡å请æ±éçéå¶ï¼å¯è½ä¼å½±åé«å¹¶åæ§è½ï¼"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{u({...r,ModelRequestRateLimitEnabled:e})}})})}),n.jsx(o,{children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("éå¶å¨æ"),step:1,min:0,suffix:i("åé"),extraText:i("é¢çéå¶ç卿ï¼åéï¼"),field:"ModelRequestRateLimitDurationMinutes",onChange:e=>u({...r,ModelRequestRateLimitDurationMinutes:String(e)})})})}),n.jsxs(o,{children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("ç¨æ·æ¯å¨ææå¤è¯·æ±æ¬¡æ°"),step:1,min:0,suffix:i("次"),extraText:i("å
æ¬å¤±è´¥è¯·æ±ç次æ°ï¼0代表ä¸éå¶"),field:"ModelRequestRateLimitCount",onChange:e=>u({...r,ModelRequestRateLimitCount:String(e)})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("ç¨æ·æ¯å¨ææå¤è¯·æ±å®ææ¬¡æ°"),step:1,min:1,suffix:i("次"),extraText:i("åªå
æ¬è¯·æ±æåçæ¬¡æ°"),field:"ModelRequestRateLimitSuccessCount",onChange:e=>u({...r,ModelRequestRateLimitSuccessCount:String(e)})})})]}
1),n.jsx(o,{children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:i("åç»éçéå¶"),placeholder:i('{\n "default": [200, 100],\n "vip": [0, 1000]\n}'),field:"ModelRequestRateLimitGroup",autosize:{minRows:5,maxRows:15},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:i("䏿¯åæ³ç JSON å符串")}],extraText:n.jsxs("div",{children:[n.jsx("p",{children:i("说æ")+"ï¼"}),n.jsxs("ul",{children:[n.jsx("li",{children:i('ä½¿ç¨ JSON å¯¹è±¡æ ¼å¼ï¼æ ¼å¼ä¸ºï¼{"ç»å": [æå¤è¯·æ±æ¬¡æ°, æå¤è¯·æ±å®ææ¬¡æ°]}')}),n.jsx("li",{children:i('示ä¾ï¼{"default": [200, 100], "vip": [0, 1000]}ã')}),n.jsx("li",{children:i("[æå¤è¯·æ±æ¬¡æ°]å¿
须大äºçäº0ï¼[æå¤è¯·æ±å®ææ¬¡æ°]å¿
须大äºçäº1ã")}),n.jsx("li",{children:i("åç»éçé
ç½®ä¼å
级é«äºå
¨å±éçéå¶ã")}),n.jsx("li",{children:i("éå¶å¨æç»ä¸ä½¿ç¨ä¸æ¹é
ç½®çâéå¶å¨æâå¼ã")})]})]}),onChange:e=>{u({...r,ModelRequestRateLimitGroup:e})}})})}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(r,h);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t="";return t="boolean"==typeof r[e.key]?String(r[e.key]):r[e.key],ye.put("/api/option/",{key:e.key,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));for(let e=0;e<t.length;e++)if(!t[e].data.success)return je(t[e].data.message);be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿å模åéçéå¶")})})]})})})})}const Vn=()=>{const{t:e}=ge();let[i,s]=t.useState({ModelRequestRateLimitEnabled:!1,ModelRequestRateLimitCount:0,ModelRequestRateLimitSuccessCount:1e3,ModelRequestRateLimitDurationMinutes:1,ModelErrorRequestRateLimitEnabled:!1,ModelErrorRequestRateLimitDurationMinutes:0,ModelErrorRequestRateLimitCount:0,ResponseReorderEnabled:!1,ModelRequestRateLimitGroup:""}),[l,a]=t.useState(!1);async function o(){try{a(!0),await(async()=>{const e=await ye.get("/api/option/"),{success:t,message:n,data:i}=e.data;if(t){let e={};i.forEach(t=>{"ModelRequestRateLimitGroup"===t.key&&(t.value=JSON.stringify(JSON.parse(t.value),null,2)),t.key.endsWith("Enabled")?e[t.ke
1y]=an(t.value):e[t.key]=t.value}),s(e)}else je(n)})()}catch(t){je(e("å·æ°å¤±è´¥"))}finally{a(!1)}}return t.useEffect(()=>{o()},[]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:l,size:"large",children:n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Un,{options:i,refresh:o})})})})},Kn={default:"OFF",HARM_CATEGORY_CIVIC_INTEGRITY:"BLOCK_NONE"},Gn={default:"v1beta"};function qn(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({"gemini.safety_settings":"","gemini.version_settings":"","gemini.supported_imagine_models":"","gemini.thinking_adapter_enabled":!1,"gemini.thinking_adapter_budget_tokens_percentage":.6}),p=t.useRef(),[h,x]=t.useState(r);return t.useEffect(()=>{const t={};for(let n in e.options)Object.keys(r).includes(n)&&(t[n]=e.options[n]);u(t),x(structuredClone(t)),p.current.setValues(t)},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:s,children:n.jsxs(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:i("Gemini设置"),children:[n.jsx(o,{children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.TextArea,{label:i("Geminiå®å
¨è®¾ç½®"),placeholder:i("为ä¸ä¸ª JSON ææ¬ï¼ä¾å¦ï¼")+"\n"+JSON.stringify(Kn,null,2),field:"gemini.safety_settings",extraText:i("default为é»è®¤è®¾ç½®ï¼å¯åç¬è®¾ç½®æ¯ä¸ªåç±»çå®å
¨ç级"),autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:i("䏿¯åæ³ç JSON å符串")}],onChange:e=>u({...r,"gemini.safety_settings":e})})})}),n.jsx(o,{children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.TextArea,{label:i("Geminiçæ¬è®¾ç½®"),placeholder:i("为ä¸ä¸ª JSON ææ¬ï¼ä¾å¦ï¼")+"\n"+JSON.stringify(Gn,null,2),field:"gemini.version_settings",extraText:i("default为é»è®¤è®¾ç½®ï¼å¯åç¬è®¾ç½®æ¯ä¸ªæ¨¡åççæ¬"),autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:i("䏿¯åæ³ç JSON å符串")}],onChange:e=>u({...r,"gemini.version_settings":e})})})}),n.jsx(o,{children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.TextArea,{field:"gemini.supported_imagine_models",label:i("æ¯æçå¾å模å"),placeholder:i("ä¾å¦ï¼")+"\n"+JSON.stringify(["gemini-2.0-flash-exp-image-generation"],null,2),onChange:e=>u({...r,"gemini.supported_imagine_models":e}),trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:i("䏿¯åæ³ç JSON å符串")}]})})})]}),n.jsxs(a.Section,{text:i("Geminiæèéé
设置"),children:[n.jsx(o,{children:n.jsx(c,{span:16,children:n.jsx(P,{children:i("gemini_thinking_description")})})}),n.jsx(o,{children:n.jsx(c,{span:16,children:n.jsx(a.Switch,{label:i("å¯ç¨Geminiæèåç¼éé
"),field:"gemini.thinking_adapter_enabled",extraText:i("éé
-thinkingã-thinking-é¢ç®æ°å å -nothinking åç¼"),onChange:e=>u({...r,"gemini.thinking_adapter_enabled":e})})})}),n.jsx(o,{children:n.jsx(c,{span:16,children:n.jsx(P,{children:i("Geminiæèéé
BudgetTokens = MaxTokens * BudgetTokens ç¾åæ¯")})})}),n.jsx(o,{children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("æèé¢ç®å æ¯"),field:"gemini.thinking_adapter_budget_tokens_percentage",initValue:"",extraText:i("0.002-1ä¹é´çå°æ°"),min:.002,max:1,onChange:e=>u({...r,"gemini.thinking_adapter_budget_tokens_percentage":e})})})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:async function(){await p.current.validate().then(()=>{const t=ke(r,h);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t=String(r[e.key]);return ye.put("/api/option/",{key:e.key,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})}).catch(e=>{console.error("Validation failed:",e),je(i("è¯·æ£æ¥è¾å
¥"))})},children:i("ä¿å")})})]})})})}const $n={"claude-3-7-sonnet-20250219-thinking":{"anthropic-beta":["output-128k-2025-02-19","token-efficient-tools-2025-02-19"]}},Hn={default:8192,"claude-3-haiku-20240307":4096,"claude-3-opus-20240229":4096,"claude-3-7-sonnet-20250219-thinking":8192};function Qn(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({"claude.model_headers_settings":"","claude.thinking_adapter_enabled":!0,"claude.default_max_tokens":"","claude.thinking_adapter_budget_tokens_percentage":.8}),p=t.useRef(),[h,x]=t.useState(r);return t.useEffect(()=>{const t={};for(let n in e.options)Object.keys(r).includes(n)&&(t[n]=e.options[n]);u(t),x(structuredClone(t)),p.current.setValues(t)},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("Claude设置"),children:[n.jsx(o,{children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.TextArea,{label:i("Claude请æ±å¤´è¦ç"),field:"claude.model_headers_settings",placeholder:i("为ä¸ä¸ª JSON ææ¬ï¼ä¾å¦ï¼")+"\n"+JSON.stringify($n,null,2),extraText:i("示ä¾")+"\n"+JSON.stringify($n,null,2),autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>
1Re(t),message:i("䏿¯åæ³ç JSON å符串")}],onChange:e=>u({...r,"claude.model_headers_settings":e})})})}),n.jsx(o,{children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.TextArea,{label:i("缺ç MaxTokens"),field:"claude.default_max_tokens",placeholder:i("为ä¸ä¸ª JSON ææ¬ï¼ä¾å¦ï¼")+"\n"+JSON.stringify(Hn,null,2),extraText:i("示ä¾")+"\n"+JSON.stringify(Hn,null,2),autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:i("䏿¯åæ³ç JSON å符串")}],onChange:e=>u({...r,"claude.default_max_tokens":e})})})}),n.jsx(o,{children:n.jsx(c,{span:16,children:n.jsx(a.Switch,{label:i("å¯ç¨Claudeæèéé
ï¼-thinkingåç¼ï¼"),field:"claude.thinking_adapter_enabled",onChange:e=>u({...r,"claude.thinking_adapter_enabled":e})})})}),n.jsx(o,{children:n.jsx(c,{span:16,children:n.jsx(P,{children:i("Claudeæèéé
BudgetTokens = MaxTokens * BudgetTokens ç¾åæ¯")})})}),n.jsx(o,{children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("æèéé
BudgetTokens ç¾åæ¯"),field:"claude.thinking_adapter_budget_tokens_percentage",initValue:"",extraText:i("0.1-1ä¹é´çå°æ°"),min:.1,max:1,onChange:e=>u({...r,"claude.thinking_adapter_budget_tokens_percentage":e})})})}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(r,h);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t=String(r[e.key]);return ye.put("/api/option/",{key:e.key,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿å")})})]})})})})}function Xn(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({"grok.violation_deduction_enabled":!1,"grok.violation_deduction_amount":.05}),p=t.useRef(),[h,x]=t.useState(r);return t.useEffect(()=>{const t={};for(let n in e.options)Object.keys(r).includes(n)&&(t[n]=e.options[n]);u(t),x(structuredClone(t)),p.current.setValues(t)},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("Grok 设置"),children:[n.jsx(o,{children:n.jsx(c,{span:16,children:n.jsx(a.Switch,{label:i("å¯ç¨è¿è§æ£è´¹"),field:"grok.violation_deduction_enabled",extraText:i("å¼å¯åï¼å½ä¸æ¸¸ Grok è¿åå
容å®å
¨è¿è§ï¼å¦ CSAM æ£æ¥ï¼æ¶ï¼å¨æ£å¸¸éè´¹ä¹åé¢å¤æ£ä¸ç¬è¿è§è´¹ãé»è®¤å
³éï¼ç¡®è®¤å½ä¸åç¡®ååå¼å¯ã"),onChange:e=>u({...r,"grok.violation_deduction_enabled":e})})})}),n.jsx(o,{children:n.jsx(c,{span:16,children:n.jsx(P,{children:i("å®é
æ£è´¹é¢åº¦ = è¿è§æ£è´¹éé¢ Ã åç»åçï¼åä½ï¼ç¾å
ï¼")})})}),n.jsx(o,{children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("è¿è§æ£è´¹éé¢ï¼ç¾å
ï¼"),field:"grok.violation_deduction_amount",extraText:i("å¤§äº 0 çå°æ°ï¼ä¾å¦ 0.05"),min:0,step:.01,onChange:e=>u({...r,"grok.violation_deduction_amount":e})})})}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(r,h);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t=String(r[e.key]);return ye.put("/api/option/",{key:e.key,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿å")})})]})})})})}function Yn(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({"global.pass_through_request_enabled":!1,"general_setting.ping_interval_enabled":!1,"general_setting.ping_interval_seconds":60}),p=t.useRef(),[x,g]=t.useState(r);return t.useEffect(()=>{const t={};for(let n in e.options)Object.keys(r).includes(n)&&(t[n]=e.options[n]);u(t),g(structuredClone(t)),p.current.setValues(t)},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("å
¨å±è®¾ç½®"),children:[n.jsx(o,{children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{label:i("å¯ç¨è¯·æ±éä¼ "),field:"global.pass_through_request_enabled",onChange:e=>u({...r,"global.pass_through_request_enabled":e}),extraText:i("pass_through_request_extra")})})}),n.jsxs(a.Section,{text:i("è¿æ¥ä¿æ´»è®¾ç½®"),children:[n.jsx(o,{style:{marginTop:10},children:n.jsx(c,{span:24,children:n.jsx(h,{type:"warning",description:i("ping_interval_warning")})})}),n.jsxs(o,{children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{label:i("å¯ç¨Pingé´é"),field:"general_setting.ping_interval_enabled",onChange:e=>u({...r,"general_setting.ping_interval_enabled":e}),extraText:i("ping_interval_extra")})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("Pingé´éï¼ç§ï¼"),field:"general_setting.ping_interval_seconds",onChange:e=>u({...r,"general_setting.ping_interval_seconds":e}),min:1,disabled:!r["general_setting.ping_interval_enabled"]})})]})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(r,x);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t=String(r[e.key]);return ye.put("/api/option/",{key:e.key,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿å")})})]})})})})}const Zn=e=>({operations:[{mode:"pass_headers",value:[...e],keep_origin:!0}]}),ei={codexCli:{name:"codex cli trace",model_regex:["^gpt-.*$"],path_regex:["/v1/responses"],key_sources:[{t
1ype:"gjson",path:"prompt_cache_key"}],param_override_template:Zn(["Originator","Session_id","User-Agent","X-Codex-Beta-Features","X-Codex-Turn-Metadata"]),value_regex:"",ttl_seconds:0,skip_retry_on_failure:!1,include_using_group:!0,include_rule_name:!0},claudeCli:{name:"claude cli trace",model_regex:["^claude-.*$"],path_regex:["/v1/messages"],key_sources:[{type:"gjson",path:"metadata.user_id"}],param_override_template:Zn(["X-Stainless-Arch","X-Stainless-Lang","X-Stainless-Os","X-Stainless-Package-Version","X-Stainless-Retry-Count","X-Stainless-Runtime","X-Stainless-Runtime-Version","X-Stainless-Timeout","User-Agent","X-App","Anthropic-Beta","Anthropic-Dangerous-Direct-Browser-Access","Anthropic-Version"]),value_regex:"",ttl_seconds:0,skip_retry_on_failure:!1,include_using_group:!0,include_rule_name:!0}},ti="channel_affinity_setting.enabled",ni="channel_affinity_setting.switch_on_success",ii="channel_affinity_setting.max_entries",si="channel_affinity_setting.default_ttl_seconds",li="channel_affinity_setting.rules",ai=[{label:"context_int",value:"context_int"},{label:"context_string",value:"context_string"},{label:"gjson",value:"gjson"}],ri=[{key:"id",label:"idï¼ç¨æ· IDï¼"},{key:"token_id",label:"token_id"},{key:"token_key",label:"token_key"},{key:"token_group",label:"token_group"},{key:"group",label:"groupï¼using_groupï¼"},{key:"username",label:"username"},{key:"user_group",label:"user_group"},{key:"user_email",label:"user_email"},{key:"specific_channel_id",label:"specific_channel_id"}],oi=e=>e?e.split("\n").map(e=>e.trim()).filter(e=>e.length>0):[],ci=e=>JSON.stringify(e,null,2),di=e=>{try{const t=JSON.parse(e||"[]");return Array.isArray(t)?t.map((e,t)=>({id:t,...e||{}})):[]}catch(t){return[]}},ui=e=>{const t=(e||[]).map(e=>{const{id:t,...n}=e||{};return n});return ci(t)},pi=e=>{const t=(e?.type||"").trim(),n=(e?.key||"").trim(),i=(e?.path||"").trim();return"gjson"===t?{type:t,key:"",path:i}:{type:t,key:n,path:""}};function hi(e){const{t:i}=ge(),{Text:s}=u,[l,r]=t.useState(!1),[p,y]=t.useState(!1),[f,b]=t.useState({enabled:!1,total:0,unknown:0,by_rule_name:{},cache_capacity:0,cache_algo:""}),[_,S]=t.useState({[ti]:!1,[ni]:!0,[ii]:1e5,[si]:3600,[li]:"[]"}),C=t.useRef(),[w,T]=t.useState(_),[E,R]=t.useState("visual"),P=t.useRef(E),[z,M]=t.useState([]),[O,D]=t.useState(!1),[L,B]=t.useState(null),[F,W]=t.useState(!1),J=t.useRef(),[U,V]=t.useState(null),[K,G]=t.useState(0),[q,$]=t.useState([]),[H,Q]=t.useState(""),X=Number(_?.[si]||0)>0?Number(_?.[si]||0):3600,Y=e=>{const t=e||{};return{name:t.name||"",model_regex_text:(t.model_regex||[]).join("\n"),path_regex_text:(t.path_regex||[]).join("\n"),user_agent_include_text:(t.user_agent_include||[]).join("\n"),value_regex:t.value_regex||"",ttl_seconds:Number(t.ttl_seconds||0),skip_retry_on_failure:!!t.skip_retry_on_failure,include_using_group:t.include_using_group??!0,include_model_name:!!t.include_model_name,include_rule_name:t.include_rule_name??!0,param_override_template_json:t.param_override_template?ci(t.param_override_template):""}},Z=t.useMemo(()=>{const e=(H||"").trim();if(!e)return{tagLabel:i("æªè®¾ç½®"),tagColor:"grey",preview:i("å½åè§åæªè®¾ç½®åæ°è¦ç模æ¿")};if(!Re(e))return{tagLabel:i("JSON æ æ"),tagColor:"red",preview:e};try{return{tagLabel:i("已设置"),tagColor:"orange",preview:JSON.stringify(JSON.parse(e),null,2)}}catch(t){return{tagLabel:i("JSON æ æ"),tagColor:"red",preview:e}}},[H,i]),ee=e=>{const t="string"==typeof e?e:"";Q(t),J.current&&J.current.setValue("param_override_template_json",t)},te=async()=>{try{y(!0);const e=await ye.get("/api/option/channel_affinity_cache",{disableDuplicate:!0}),{success:t,message:n,data:s}=e.data;if(!t)return je(i(n));b(s||{})}catch(e){je(i("å·æ°ç¼åç»è®¡å¤±è´¥"))}finally{y(!1)}},ne=e=>{M(e);const t=ui(e);S(e=>({...e,[li]:t})),C.current&&"json"===E&&C.current.setValue(li,t)},ie=[{title:i("åç§°"),dataIndex:"name",render:e=>n.jsx(s,{children:e||"-"})},{title:i("æ¨¡åæ£å"),dataIndex:"model_regex",render:e=>(e||[]).length>0?(e||[]).slice(0,3).map((e,t)=>n.jsx(j,{style:{marginRight:4},children:e},`${e}-${t}`)):"-"},{title:i("è·¯å¾æ£å"),dataIndex:"path_regex",render:e=>(e||[]).length>0?(e||[]).slice(0,2).map((e,t)=>n.jsx(j,{style:{marginRight:4},children:e},`${e}-${t}`)):"-"},{title:i("Key æ¥æº"),dataIndex:"key_sources",render:e=>{const t=e||[];return 0===t.length?"-":t.slice(0,3).map((e,t)=>
1{const i=pi(e),s="gjson"===i.type?i.path:i.key;return n.jsxs(j,{style:{marginRight:4},children:[i.type,":",s]},`${i.type}-${t}`)})}},{title:i("TTLï¼ç§ï¼"),dataIndex:"ttl_seconds",render:e=>n.jsx(s,{children:Number(e||0)||"-"})},{title:i("å¤±è´¥åæ¯å¦éè¯"),dataIndex:"skip_retry_on_failure",render:e=>n.jsx(j,{color:e?"orange":"green",style:{marginRight:4},children:i(e?"ä¸éè¯":"éè¯")})},{title:i("è¦ç模æ¿"),render:(e,t)=>t?.param_override_template?n.jsx(d,{size:"small",icon:n.jsx(st,{size:16}),type:"tertiary",onClick:()=>(e=>{const t=e?.param_override_template;t&&"object"==typeof t?x.info({title:i("åæ°è¦ç模æ¿é¢è§"),content:n.jsx("div",{style:{marginTop:6,paddingBottom:10},children:n.jsx("pre",{style:{margin:0,maxHeight:420,overflow:"auto",fontSize:12,lineHeight:1.6,padding:10,borderRadius:8,background:"hsl(var(--foreground) / 0.02)",border:"1px solid hsl(var(--border))",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:ci(t)})}),footer:null,width:760}):ve(i("该è§åæªè®¾ç½®åæ°è¦ç模æ¿"))})(t),children:i("é¢è§æ¨¡æ¿")}):n.jsx(s,{type:"tertiary",children:"-"})},{title:i("ç¼åæ¡ç®æ°"),render:(e,t)=>{const i=(t?.name||"").trim();if(!i||!t?.include_rule_name)return n.jsx(s,{type:"tertiary",children:"N/A"});const l=Number(f?.by_rule_name?.[i]||0);return n.jsx(s,{children:l})}},{title:i("ä½ç¨å"),render:(e,t)=>{const s=[];return t?.include_using_group&&s.push(i("åç»")),t?.include_model_name&&s.push(i("模å")),t?.include_rule_name&&s.push(i("è§å")),0===s.length?"-":s.map(e=>n.jsx(j,{style:{marginRight:4},children:e},e))}},{title:i("æä½"),render:(e,t)=>n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx(lt,{size:16}),theme:"borderless",type:"warning",disabled:!t?.include_rule_name,title:i("æ¸
空该è§åç¼å"),"aria-label":i("æ¸
空该è§åç¼å"),onClick:()=>(e=>{const t=(e?.name||"").trim();t&&(e?.include_rule_name?x.confirm({title:i("确认æ¸
空该è§åç¼å"),content:n.jsxs("div",{style:{lineHeight:"1.6"},children:[n.jsxs(s,{children:[i("è§å"),"ï¼"]})," ",n.jsx(s,{strong:!0,children:t})]}),onOk:async()=>{const e=await ye.delete("/api/option/channel_affinity_cache",{params:{rule_name:t}}),{success:n,message:s}=e.data;n?(be(i("å·²æ¸
空")),await te()):je(i(s))}}):ve(i('该è§åæªå¯ç¨"ä½ç¨åï¼å
å«è§ååç§°"ï¼æ æ³æè§åæ¸
空ç¼åã')))})(t)}),n.jsx(d,{icon:n.jsx(at,{size:16}),theme:"borderless",title:i("ç¼è¾è§å"),"aria-label":i("ç¼è¾è§å"),onClick:()=>se(t)}),n.jsx(d,{icon:n.jsx(He,{size:16}),theme:"borderless",type:"danger",title:i("å é¤è§å"),"aria-label":i("å é¤è§å"),onClick:()=>le(t.id)})]})}],se=e=>{const t=e||{},n={...t,user_agent_include:Array.isArray(t.user_agent_include)?t.user_agent_include:[],key_sources:(t.key_sources||[]).map(pi)};B(n),W(!0),J.current=null;const i=Y(n);V(i),Q(i.param_override_template_json||""),$([]),G(e=>e+1),D(!0)},le=e=>{const t=(z||[]).filter(t=>t.id!==e);ne(t.map((e,t)=>({...e,id:t}))),be(i("å 餿å"))},ae=(e,t)=>{const n=[...L?.key_sources||[]];n[e]=pi({...n[e]||{},...t||{}}),B(e=>({...e||{},key_sources:n}))};t.useEffect(()=>{const t={..._};for(let i in e.options)if([ti,ni,ii,si,li].includes(i))if(i===ti)t[i]=an(e.options[i]);else if(i===ni)t[i]=an(e.options[i]);else if(i===ii)t[i]=Number(e.options[i]||0)||0;else if(i===si)t[i]=Number(e.options[i]||0)||0;else if(i===li)try{const n=JSON.parse(e.options[i]||"[]");t[i]=ci(n)}catch(n){t[i]=e.options[i]||"[]"}S(t),T(structuredClone(t)),C.current&&C.current.setValues(t),M(di(t[li])),te()},[e.options]),t.useEffect(()=>{const e=P.current;P.current=E,e!==E&&"json"===E&&C.current&&C.current.setValue(li,_[li]||"[]")},[E,_]),t.useEffect(()=>{"visual"===E&&M(di(_[li]))},[_[li],E]);const re=n.jsx(h,{fullMode:!1,type:"info",description:i("æ¸ éäº²åæ§ä¼åºäºä»è¯·æ±ä¸ä¸ææ JSON Body æåç Keyï¼ä¼å
å¤ç¨ä¸ä¸æ¬¡æåçæ¸ éã")});return n.jsxs(n.Fragment,{children:[n.jsx(m,{spinning:l,children:n.jsx(a,{values:_,getFormApi:e=>C.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("æ¸ éäº²åæ§"),children:[re,n.jsx(I,{style:{marginTop:12,marginBottom:12}}),n.jsxs(o,{gutter:16,children:[n.jsxs(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:[n.jsx(a.Switch,{field:ti,label:i("å¯ç¨"),checkedText:"|",uncheckedText:"O",onChange:e=>S({..._,[ti]:e})}),n.jsx(s,{type:"tertiary",size:14,children:i("å¯ç¨åå°ä¼å
å¤ç¨ä¸ä¸æ¬¡æåçæ¸ éï¼ç²æ»éè·¯ï¼ã")})]}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:ii,label:i("æå¤§æ¡ç®æ°"),min:0,placeholder:"ä¾
1å¦ 100000â¦",extraText:n.jsx(s,{type:"tertiary",size:14,children:i("å
åç¼åæå¤§æ¡ç®æ°ã0 表示使ç¨å端é»è®¤å®¹éï¼100000ã")}),onChange:e=>S({..._,[ii]:Number(e||0)})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:si,label:i("é»è®¤ TTLï¼ç§ï¼"),min:0,placeholder:"ä¾å¦ 3600â¦",extraText:n.jsx(s,{type:"tertiary",size:14,children:i("è§å ttl_seconds 为 0 æ¶ä½¿ç¨ã0 表示使ç¨å端é»è®¤ TTLï¼3600 ç§ã")}),onChange:e=>S({..._,[si]:Number(e||0)})})})]}),n.jsx(o,{gutter:16,style:{marginTop:12},children:n.jsxs(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:[n.jsx(a.Switch,{field:ni,label:i("æåååæ¢äº²å"),checkedText:"|",uncheckedText:"O",onChange:e=>S({..._,[ni]:e})}),n.jsx(s,{type:"tertiary",size:14,children:i("å¦æäº²åå°çæ¸ é失败ï¼éè¯å°å
¶ä»æ¸ éæååï¼å°äº²åæ´æ°å°æåçæ¸ éã")})]})}),n.jsx(I,{style:{marginTop:12,marginBottom:12}}),n.jsxs(g,{style:{marginBottom:10},children:[n.jsx(d,{type:"visual"===E?"primary":"tertiary",onClick:()=>{const e=(e=>{const t=e;
1if(!Re(t))return{ok:!1,message:"Rules JSON is invalid"};try{const e=JSON.parse(t);return Array.isArray(e)?{ok:!0,value:e}:{ok:!1,message:"Rules JSON must be an array"}}catch(n){return{ok:!1,message:"Rules JSON is invalid"}}})(_[li]||"[]");e.ok?R("visual"):je(i(e.message))},children:i("å¯è§å")}),n.jsx(d,{type:"json"===E?"primary":"tertiary",onClick:()=>{const e=ui(z);S(t=>({...t||{},[li]:e})),R("json")},children:i("JSON 模å¼")}),n.jsx(d,{onClick:()=>{const e=()=>{const e=new Set((z||[]).map(e=>(e?.name||"").trim()).filter(e=>e.length>0)),t=[ei.codexCli,ei.claudeCli].map(t=>{const n=(i=t,JSON.parse(JSON.stringify(i||{})));var i;const s=((e,t)=>{const n=(t||"").trim()||"rule";if(!e.has(n))return n;for(let i=2;i<1e3;i++){const t=`${n}-${i}`;if(!e.has(t))return t}return`${n}-${Date.now()}`})(e,t.name);return e.add(s),{...n,name:s}}),n=[...z||[],...t].map((e,t)=>({...e||{},id:t}));ne(n),be(i("已填å
模ç"))};0!==(z||[]).length?x.confirm({title:i("å¡«å
Codex CLI / Claude CLI 模ç"),content:n.jsx("div",{style:{lineHeight:"1.6"},children:n.jsx(s,{type:"tertiary",children:i("å°è¿½å 2 æ¡è§åå°ç°æè§åå表ã")})}),onOk:e}):e()},children:i("å¡«å
Codex CLI / Claude CLI 模ç")}),n.jsx(d,{icon:n.jsx(Ye,{size:16}),onClick:()=>{const e={name:"",model_regex:[],path_regex:[],user_agent_include:[],key_sources:[{type:"gjson",path:""}],value_regex:"",ttl_seconds:0,skip_retry_on_failure:!1,include_using_group:!0,include_model_name:!1,include_rule_name:!0};B(e),W(!1),J.current=null;const t=Y(e);V(t),Q(t.param_override_template_json||""),$([]),G(e=>e+1),D(!0)},children:i("æ°å¢è§å")}),n.jsx(d,{theme:"solid",onClick:async function(){const t=ke(_,w);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));if(!Re(_[li]||"[]"))return je(i("è§å JSON æ ¼å¼ä¸æ£ç¡®"));let n;try{s=JSON.parse(_[li]||"[]"),n=JSON.stringify(s)}catch(a){return je(i("è§å JSON æ ¼å¼ä¸æ£ç¡®"))}var s;const l=t.map(e=>{let t="";return t=e.key===li?n:"boolean"==typeof _[e.key]?String(_[e.key]):String(_[e.key]??""),ye.put("/api/option/",{key:e.key,value:t})});r(!0),Promise.all(l).then(t=>{if(1===l.length){if(t.includes(void 0))return}else if(l.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>je(i("ä¿å失败ï¼è¯·éè¯"))).finally(()=>r(!1))},children:i("ä¿å")}),n.jsx(d,{icon:n.jsx(et,{size:16}),loading:p,onClick:te,children:i("å·æ°ç¼åç»è®¡")}),n.jsx(d,{type:"danger",onClick:()=>{x.confirm({title:i("确认æ¸
空å
¨é¨æ¸ éäº²åæ§ç¼å"),content:n.jsx("div",{style:{lineHeight:"1.6"},children:n.jsx(s,{children:i("å°å 餿æä»å¨å
åä¸çæ¸ éäº²åæ§ç¼åæ¡ç®ã")})}),onOk:async()=>{const e=await ye.delete("/api/option/channel_affinity_cache",{params:{all:!0}}),{success:t,message:n}=e.data;t?(be(i("å·²æ¸
空")),await te()):je(i(n))}})},children:i("æ¸
空å
¨é¨ç¼å")})]}),"visual"===E?n.jsx(v,{columns:ie,dataSource:z,rowKey:"id",pagination:!1,size:"small"}):n.jsx(a.TextArea,{field:li,label:i("è§å JSON"),extraText:i("è§å为 JSON æ°ç»ï¼å¯è§åä¸ JSON 模å¼å
±ç¨åä¸ä»½æ°æ®ã"),placeholder:'[\n {\n "name": "prefer-by-conversation-id",\n "model_regex": ["^gpt-.*$"],\n "path_regex": ["/v1/chat/completions"],\n "user_agent_include": ["curl", "PostmanRuntime"],\n "key_sources": [\n { "type": "gjson", "path": "metadata.conversation_id" },\n { "type": "context_string", "key": "conversation_id" }\n ],\n "value_regex": "^[-0-9A-Za-z._:]{1,128}$",\n "ttl_seconds": 600,\n "param_override_template": {\n "operations": [\n { "path": "temperature", "mode": "set", "value": 0.2 }\n ]\n },\n "skip_retry_on_failure": false,\n "include_using_group": true,\n "include_model_name": false,\n "include_rule_name": true\n }\n]',style:{width:"100%"},autosize:{minRows:10,maxRows:28},rules:[{validator:(e,t)=>Re(t||"[]")}],onChange:e=>S({..._,[li]:e})})]})})}),n.jsx(x,{title:i(F?"ç¼è¾è§å":"æ°å¢è§å"),visible:O,onCancel:()=>{D(!1),B(null),V(null),$([]),Q("")},onOk:async()=>{try{const e=await J.current.validate(),t=oi(e.model_regex_text);if(0===t.length)return je(i("æ¨¡åæ£åä¸è½ä¸ºç©º"));const n=(e=>{const t=(e||[]).map(pi).filter(e=>e.type);if(0===t.length)return{ok:!1,message:"Key æ¥æºä¸è½ä¸ºç©º"};
1for(const n of t)if("context_int"===n.type||"context_string"===n.type){if(!n.key)return{ok:!1,message:"Key ä¸è½ä¸ºç©º"}}else{if("gjson"!==n.type)return{ok:!1,message:"Key æ¥æºç±»åä¸åæ³"};if(!n.path)return{ok:!1,message:"Path ä¸è½ä¸ºç©º"}}return{ok:!0,value:t}})(L?.key_sources);if(!n.ok)return je(i(n.message));const s=oi(e.user_agent_include_text),l=((e,t)=>{const n=(e||"").trim();if(!n)return{ok:!0,value:null};if(!Re(n))return{ok:!1,message:`${t} JSON æ ¼å¼ä¸æ£ç¡®`};try{const e=JSON.parse(n);return!e||"object"!=typeof e||Array.isArray(e)?{ok:!1,message:`${t} å¿
é¡»æ¯ JSON 对象`}:{ok:!0,value:e}}catch(i){return{ok:!1,message:`${t} JSON æ ¼å¼ä¸æ£ç¡®`}}})(H,"åæ°è¦ç模æ¿");if(!l.ok)return je(i(l.message));const a={id:F?L.id:z.length,name:(e.name||"").trim(),model_regex:t,path_regex:oi(e.path_regex_text),key_sources:n.value,value_regex:(e.value_regex||"").trim(),ttl_seconds:Number(e.ttl_seconds||0),include_using_group:!!e.include_using_group,include_model_name:!!e.include_model_name,include_rule_name:!!e.include_rule_name,skip_retry_on_failure:!!e.skip_retry_on_failure,...s.length>0?{user_agent_include:s}:{},...l.value?{param_override_template:l.value}:{}};if(!a.name)return je(i("åç§°ä¸è½ä¸ºç©º"));const r=[...z||[]];if(F){let e=r.findIndex(e=>e.id===L?.id);if(e<0&&L?.name&&(e=r.findIndex(e=>(e?.name||"").trim()===(L?.name||"").trim())),e<0)return je(i("è§åæªæ¾å°ï¼è¯·å·æ°åéè¯"));r[e]=a}else r.push(a);ne(r.map((e,t)=>({...e,id:t}))),D(!1),B(null),V(null),Q(""),be(i("ä¿åæå"))}catch(e){je(i("è¯·æ£æ¥è¾å
¥"))}},okText:i("ä¿å"),cancelText:i("åæ¶"),width:720,children:n.jsxs(a,{initValues:U||{},getFormApi:e=>{J.current=e},children:[n.jsx(a.Input,{field:"name",label:i("åç§°"),extraText:i("è§ååç§°ï¼å¯è¯»æ§æ´å¥½ï¼ä¹ä¼åºç°å¨ç®¡çä¾§æ¥å¿ä¸ï¼ã"),placeholder:"ä¾å¦ prefer-by-conversation-idâ¦",rules:[{required:!0}],onChange:e=>B(t=>({...t||{},name:e}))}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,children:n.jsx(a.TextArea,{field:"model_regex_text",label:i("æ¨¡åæ£åï¼æ¯è¡ä¸ä¸ªï¼"),extraText:i("å¿
å¡«ã对请æ±ç model åç§°è¿è¡å¹é
ï¼ä»»æä¸æ¡å¹é
å³å½ä¸è¯¥è§åã"),placeholder:"^gpt-4o.*$\n^claude-3.*$â¦",autosize:{minRows:4,maxRows:10},rules:[{required:!0}]})}),n.jsx(c,{xs:24,sm:12,children:n.jsx(a.TextArea,{field:"path_regex_text",label:i("è·¯å¾æ£åï¼æ¯è¡ä¸ä¸ªï¼"),extraText:i("å¯éã对请æ±è·¯å¾è¿è¡å¹é
ï¼ä¸å¡«è¡¨ç¤ºå¹é
ææè·¯å¾ã"),placeholder:"/v1/chat/completions\n/v1/responsesâ¦",autosize:{minRows:4,maxRows:10}})})]}),n.jsx(o,{gutter:16,style:{marginTop:12},children:n.jsxs(c,{xs:24,sm:12,children:[n.jsx(a.Switch,{field:"skip_retry_on_failure",label:i("失败åä¸éè¯")}),n.jsx(s,{type:"tertiary",size:14,children:i("å¼å¯åï¼è¥è¯¥è§åå½ä¸ä¸è¯·æ±å¤±è´¥ï¼å°ä¸ä¼åæ¢æ¸ ééè¯ã")})]})}),n.jsx(A,{keepDOM:!0,activeKey:q,onChange:e=>{const t=Array.isArray(e)?e:[e];$(t.filter(Boolean))},children:n.jsxs(A.Panel,{header:i("é«çº§è®¾ç½®"),itemKey:"advanced",children:[n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,children:n.jsx(a.TextArea,{field:"user_agent_include_text",label:i("User-Agent includeï¼æ¯è¡ä¸ä¸ªï¼å¯ä¸åï¼"),extraText:n.jsx(s,{type:"tertiary",size:14,children:i("å¯éãå¹é
å
¥å£è¯·æ±ç User-Agentï¼ä»»æä¸è¡ä½ä¸ºå串å¹é
ï¼å¿½ç¥å¤§å°åï¼å³å½ä¸ã")}),placeholder:"curl\nPostmanRuntime\nMyApp/â¦",autosize:{minRows:3,maxRows:8}})})}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,children:n.jsx(a.Input,{field:"value_regex",label:i("Value æ£å"),placeholder:"^[-0-9A-Za-z._:]{1,128}$",extraText:i("å¯éã对æåå°ç亲å Key åæ£åæ ¡éªï¼ä¸å¡«è¡¨ç¤ºä¸æ ¡éªã")})}),n.jsx(c,{xs:24,sm:12,children:n.jsx(a.InputNumber,{field:"ttl_seconds",label:i("TTLï¼ç§ï¼0 表示é»è®¤ï¼"),placeholder:"ä¾å¦ 600â¦",min:0,extraText:n.jsxs(s,{type:"tertiary",size:14,children:[i("该è§åçç¼åä¿çæ¶é¿ï¼0 表示使ç¨é»è®¤ TTLï¼"),X,i("ç§")]})})})]}),n.jsx(o,{gutter:16,children:n.jsxs(c,{xs:24,children:[n.jsx("div",{style:{marginBottom:8},children:n.jsx(s,{strong:!0,children:i("åæ°è¦ç模æ¿")})}),n.jsx(s,{type:"tertiary",size:14,children:i("å½ä¸è¯¥äº²åè§ååï¼ä¼ææ¤æ¨¡æ¿åå¹¶å°æ¸ éåæ°è¦çä¸ï¼ååé®ç±æ¨¡æ¿è¦çï¼ã")}),n.jsxs("div",{style:{marginTop:8,borderRadius:10,padding:10,background:"hsl(var(--foreground) / 0.02)",border:"1px solid hsl(var(--border))"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8,gap:8,flexWrap:"wrap"},children:[n.jsx(j,{color:Z.tagColor,children:Z.tagLabel}),n.jsxs(g,{children:[n.jsx(d,{size:"small",onClick:()=>{const e=(H||"").trim();if(e)if(Re(e))try{ee(JSON.stringify(JSON.parse(e),null,2))}catch(t){je(i("åæ°è¦çæ¨¡æ¿ JSON æ ¼å¼ä¸æ£ç¡®"))}else je(i("åæ°è¦çæ¨¡æ¿ JSON æ ¼å¼ä¸æ£ç¡®"))},children:i("æ ¼å¼å")}),n.jsx(d,{size:"small",type:"tertiary",onClick:()=>ee(""),children:i("æ¸
空")})]})]}),n.jsx(a.TextArea,{field:"param_override_template_json",noLabel:!0,placeholder:'{"operations": [...]}',autosize:{minRows:3,maxRows:12},onChange:e=>Q(e||"")})]})]})}),n.jsxs(o,{gutter:16,children:[n.jsxs(c,{xs:24,sm:8,children:[n.jsx(a.Switch,{field:"include_using_group",label:i("ä½ç¨åï¼å
å«åç»")}
1),n.jsx(s,{type:"tertiary",size:14,children:i("å¼å¯åï¼using_group ä¼åä¸ cache keyï¼ä¸ååç»é离ï¼ã")})]}),n.jsxs(c,{xs:24,sm:8,children:[n.jsx(a.Switch,{field:"include_model_name",label:i("ä½ç¨åï¼å
嫿¨¡ååç§°")}),n.jsx(s,{type:"tertiary",size:14,children:i("å¼å¯åï¼æ¨¡ååç§°ä¼åä¸ cache keyï¼ä¸å模åé离ï¼ã")})]}),n.jsxs(c,{xs:24,sm:8,children:[n.jsx(a.Switch,{field:"include_rule_name",label:i("ä½ç¨åï¼å
å«è§ååç§°")}),n.jsx(s,{type:"tertiary",size:14,children:i("å¼å¯åï¼è§ååç§°ä¼åä¸ cache keyï¼ä¸åè§åé离ï¼ã")})]})]})]})}),n.jsx(I,{style:{marginTop:12,marginBottom:12}}),n.jsxs(g,{style:{marginBottom:10},children:[n.jsx(s,{children:i("Key æ¥æº")}),n.jsx(d,{icon:n.jsx(Ye,{size:16}),onClick:()=>{const e=[...L?.key_sources||[]];e.push({type:"gjson",path:""}),B(t=>({...t||{},key_sources:e}))},children:i("æ°å¢ Key æ¥æº")})]}),n.jsx(s,{type:"tertiary",size:14,children:i("context_int/context_string ä»è¯·æ±ä¸ä¸æè¯»åï¼gjson ä»å
¥å£è¯·æ±ç JSON body æ gjson path 读åã")}),n.jsxs("div",{style:{marginTop:8,marginBottom:8},children:[n.jsxs(s,{type:"tertiary",size:14,children:[i("常ç¨ä¸ä¸æ Keyï¼ç¨äº context_*ï¼"),"ï¼"]}),n.jsx("div",{style:{marginTop:6},children:(ri||[]).map(e=>n.jsx(j,{style:{marginRight:6,marginBottom:6},children:e.label},e.key))})]}),n.jsx(v,{columns:[{title:i("ç±»å"),render:(e,t,s)=>n.jsx(N,{style:{width:160},optionList:ai,value:(L?.key_sources?.[s]?.type||"gjson").trim(),"aria-label":i("Key æ¥æºç±»å"),onChange:e=>ae(s,{type:e})})},{title:i("Key æ Path"),render:(e,t,s)=>{const l=pi(L?.key_sources?.[s]),a="gjson"===l.type;return n.jsx(k,{placeholder:a?"metadata.conversation_id":"user_id","aria-label":i("Key æ Path"),value:a?l.path:l.key,onChange:e=>ae(s,a?{path:e}:{key:e})})}},{title:i("æä½"),width:90,render:(e,t,s)=>n.jsx(d,{icon:n.jsx(He,{size:16}),theme:"borderless",type:"danger",title:i("å é¤ Key æ¥æº"),"aria-label":i("å é¤ Key æ¥æº"),onClick:()=>(e=>{const t=[...L?.key_sources||[]].filter((t,n)=>n!==e);B(e=>({...e||{},key_sources:t}))})(s)})}],dataSource:(L?.key_sources||[]).map((e,t)=>({id:t,...e})),rowKey:"id",pagination:!1,size:"small"})]},`channel-affinity-rule-form-${K}`)})]})}const xi=()=>{const{t:e}=ge();let[i,s]=t.useState({"gemini.safety_settings":"","gemini.version_settings":"","gemini.supported_imagine_models":"","claude.model_headers_settings":"","claude.thinking_adapter_enabled":!0,"claude.default_max_tokens":"","claude.thinking_adapter_budget_tokens_percentage":.8,"global.pass_through_request_enabled":!1,"general_setting.ping_interval_enabled":!1,"general_setting.ping_interval_seconds":60,"gemini.thinking_adapter_enabled":!1,"gemini.thinking_adapter_budget_tokens_percentage":.6,"grok.violation_deduction_enabled":!1,"grok.violation_deduction_amount":.05}),[l,a]=t.useState(!1);async function o(){try{a(!0),await(async()=>{const e=await ye.get("/api/option/"),{success:t,message:n,data:i}=e.data;if(t){let e={};i.forEach(t=>{"gemini.safety_settings"!==t.key&&"gemini.version_settings"!==t.key&&"claude.model_headers_settings"!==t.key&&"claude.default_max_tokens"!==t.key&&"gemini.supported_imagine_models"!==t.key||""!==t.value&&(t.value=JSON.stringify(JSON.parse(t.value),null,2)),t.key.endsWith("Enabled")||t.key.endsWith("enabled")?e[t.ke
1y]=an(t.value):e[t.key]=t.value}),s(e)}else je(n)})()}catch(t){je(e("å·æ°å¤±è´¥")),console.error(t)}finally{a(!1)}}return t.useEffect(()=>{o()},[]),n.jsx(n.Fragment,{children:n.jsxs(m,{spinning:l,size:"large",children:[n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Yn,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(qn,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Qn,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Xn,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(hi,{options:i,refresh:o})})]})})},{Text:mi}=u,gi=["description","route"],yi=[{key:"route",label:"线路æè¿°",type:"input",maxLength:50},{key:"description",label:"说æ",type:"input",maxLength:200}],ji=({options:e,refresh:i})=>{const{t:s}=ge(),[l,r]=t.useState([]),[o,c]=t.useState(!1),[u,p]=t.useState(!1),[h,m]=t.useState(null),[y,f]=t.useState(null),[b,_]=t.useState(!1),[S,k]=t.useState(!1),[P,z]=t.useState(!1),[N,A]=t.useState({url:"",description:"",route:"",color:"blue"}),[M,O]=t.useState(1),[D,L]=t.useState(10),[B,F]=t.useState([]),[W,J]=t.useState(!0),[U,V]=t.useState(null),K=an(e?.["translation_setting.enabled"]);t.useEffect(()=>{const t=e["console_setting.api_info"]??e.ApiInfo;void 0!==t&&(e=>{if(e)try{const t=JSON.parse(e);r(Array.isArray(t)?t:[])}catch(t){console.error("è§£æAPIä¿¡æ¯å¤±è´¥:",t),r([])}else r([])})(t)},[e["console_setting.api_info"],e.ApiInfo]),t.useEffect(()=>{const t=e["console_setting.api_info_enabled"];J(void 0===t||"true"===t||!0===t)},[e["console_setting.api_info_enabled"]]);const G=[{title:"ID",dataIndex:"id"},{title:s("APIå°å"),dataIndex:"url",render:(e,t)=>n.jsx(j,{color:t.color,shape:"circle",style:{maxWidth:"280px"},children:e})},{title:s("线路æè¿°"),dataIndex:"route",render:(e,t)=>n.jsx(j,{shape:"circle",children:e})},{title:s("说æ"),dataIndex:"description",ellipsis:!0,render:(e,t)=>n.jsx(j,{shape:"circle",children:e||"-"})},{title:s("é¢è²"),dataIndex:"color",render:e=>n.jsx(R,{size:"extra-extra-small",color:e})},{title:s("ç¿»è¯"),key:"translation_status",width:110,render:(e,t)=>n.jsx(hn,{item:t,fields:gi,onClick:()=>V(t)})},{title:s("æä½"),fixed:"right",width:220,render:(e,t)=>n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx(Ge,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>V(t),children:s("è¯æ")}),n.jsx(d,{icon:n.jsx($e,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>{return f(e=t),A({url:e.url,description:e.description,route:e.route,color:e.color}),void c(!0);var e},children:s("ç¼è¾")}),n.jsx(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",size:"small",onClick:()=>(m(t),void p(!0)),children:s("å é¤")})]})}],q={selectedRowKeys:B,onChange:(e,t)=>
1{F(e)},onSelect:(e,t,n)=>{},onSelectAll:(e,t)=>{},getCheckboxProps:e=>({disabled:!1,name:e.id})};return n.jsxs(n.Fragment,{children:[n.jsx(a.Section,{text:n.jsxs("div",{className:"flex flex-col w-full",children:[n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-center text-blue-500",children:[n.jsx(it,{size:16,className:"mr-2"}),n.jsx(mi,{children:s("APIä¿¡æ¯ç®¡çï¼å¯ä»¥é
ç½®å¤ä¸ªAPIå°åç¨äºç¶æå±ç¤ºåè´è½½åè¡¡ï¼æå¤50个ï¼")})]}),K&&n.jsxs("div",{className:"flex items-center text-amber-500 mt-1",children:[n.jsx(Ge,{size:14,className:"mr-2"}),n.jsx(mi,{type:"warning",size:"small",children:"t('å·²å¼å¯èªå¨ç¿»è¯ï¼ä¿å设置æ¶ä¼å¯¹æªç¿»è¯/åæå·²ä¿®æ¹çæ¡ç®èªå¨ç¿»è¯ä¸º 6 ç§è¯è¨')"})]})]}),n.jsx(I,{margin:"12px"}),n.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 w-full",children:[n.jsxs("div",{className:"flex gap-2 w-full md:w-auto order-2 md:order-1",children:[n.jsx(d,{theme:"light",type:"primary",icon:n.jsx(Ye,{size:14}),className:"w-full md:w-auto",onClick:()=>{f(null),A({url:"",description:"",route:"",color:"blue"}),c(!0)},children:s("æ·»å API")}),n.jsxs(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",onClick:()=>{if(0===B.length)return void je(s("请å
éæ©è¦å é¤çAPIä¿¡æ¯"));const e=l.filter(e=>!B.includes(e.id));r(e),F([]),z(!0),be(s('å·²å é¤ {{count}} 个APIä¿¡æ¯ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å',{count:B.length}))},disabled:0===B.length,className:"w-full md:w-auto",children:[s("æ¹éå é¤")," ",B.length>0&&`(${B.length})`]}),n.jsx(d,{icon:n.jsx(Ze,{size:14}),onClick:async()=>{try{k(!0);let e=l;const t=JSON.stringify(e);await(async(e,t)=>{const n=await ye.put("/api/option/",{key:"console_setting.api_info",value:t}),{success:l,message:a}=n.data;l?(be(s("APIä¿¡æ¯å·²æ´æ°")),i&&i()):je(a)})(0,t),z(!1)}catch(e){console.error("APIä¿¡æ¯æ´æ°å¤±è´¥",e),je(s("APIä¿¡æ¯æ´æ°å¤±è´¥"))}finally{k(!1)}},loading:S,disabled:!P,type:"secondary",className:"w-full md:w-auto",children:s("ä¿å设置")})]}),n.jsxs("div",{className:"order-1 md:order-2 flex items-center gap-2",children:[n.jsx(E,{checked:W,onChange:async e=>{const t=e?"true":"false";try{const n=await ye.put("/api/option/",{key:"console_setting.api_info_enabled",value:t});n.data.success?(J(e),be(s("设置已ä¿å")),i?.()):je(n.data.message)}catch(n){je(n.message)}}}),n.jsx(mi,{children:s(W?"å·²å¯ç¨":"å·²ç¦ç¨")})]})]})]}),children:n.jsx(v,{columns:G,dataSource:(()=>{const e=(M-1)*D,t=e+D;return l.slice(e,t)})(),rowSelection:q,rowKey:"id",scroll:{x:"max-content"},pagination:{currentPage:M,pageSize:D,total:l.length,showSizeChanger:!0,showQuickJumper:!0,formatPageText:e=>s("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:l.length}),pageSizeOptions:["5","10","20","50"],onChange:(e,t)=>
1{O(e),L(t)},onShowSizeChange:(e,t)=>{O(1),L(t)}},size:"middle",loading:S,empty:n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:s("ææ APIä¿¡æ¯"),style:{padding:30}}),className:"overflow-hidden"})}),n.jsx(x,{title:s(y?"ç¼è¾API":"æ·»å API"),visible:o,onOk:async()=>{if(N.url&&N.route&&N.description)try{let e;if(_(!0),y)e=l.map(e=>e.id===y.id?{...e,...N}:e);else{const t={id:Math.max(...l.map(e=>e.id),0)+1,...N};e=[...l,t]}r(e),z(!0),c(!1),be(s(y?'APIä¿¡æ¯å·²æ´æ°ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å':'APIä¿¡æ¯å·²æ·»å ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å'))}catch(e){je(s("æä½å¤±è´¥")+": "+e.message)}finally{_(!1)}else je(s("请填å宿´çAPIä¿¡æ¯"))},onCancel:()=>c(!1),okText:s("ä¿å"),cancelText:s("åæ¶"),confirmLoading:b,children:n.jsxs(a,{layout:"vertical",initValues:N,children:[n.jsx(a.Input,{field:"url",label:s("APIå°å"),placeholder:"https://api.example.com",rules:[{required:!0,message:s("请è¾å
¥APIå°å")}],onChange:e=>A({...N,url:e})}),n.jsx(a.Input,{field:"route",label:s("线路æè¿°"),placeholder:s("å¦ï¼é¦æ¸¯çº¿è·¯"),rules:[{required:!0,message:s("请è¾å
¥çº¿è·¯æè¿°")}],onChange:e=>A({...N,route:e})}),n.jsx(a.Input,{field:"description",label:s("说æ"),placeholder:s("å¦ï¼å¤§å¸¦å®½æ¹éåæå¾çæ¨è"),rules:[{required:!0,message:s("请è¾å
¥è¯´æ")}],onChange:e=>A({...N,description:e})}),n.jsx(a.Select,{field:"color",label:s("æ è¯é¢è²"),optionList:[{value:"blue",label:"blue"},{value:"green",label:"green"},{value:"cyan",label:"cyan"},{value:"purple",label:"purple"},{value:"pink",label:"pink"},{value:"red",label:"red"},{value:"orange",label:"orange"},{value:"amber",label:"amber"},{value:"yellow",label:"yellow"},{value:"lime",label:"lime"},{value:"light-green",label:"light-green"},{value:"teal",label:"teal"},{value:"light-blue",label:"light-blue"},{value:"indigo",label:"indigo"},{value:"violet",label:"violet"},{value:"grey",label:"grey"}],onChange:e=>A({...N,color:e}),render:e=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx(R,{size:"extra-extra-small",color:e.value}),e.label]})})]},y?y.id:"new")}),n.jsx(x,{title:s("确认å é¤"),visible:u,onOk:()=>{if(h){const e=l.filter(e=>e.id!==h.id);r(e),z(!0),be(s("APIä¿¡æ¯å·²å é¤ï¼è¯·åæ¶ç¹å»âä¿å设置âè¿è¡ä¿å"))}p(!1),m(null)},onCancel:()=>{p(!1),m(null)},okText:s("确认å é¤"),cancelText:s("åæ¶"),type:"warning",okButtonProps:{type:"danger",theme:"solid"},children:n.jsx(mi,{children:s("ç¡®å®è¦å 餿¤APIä¿¡æ¯åï¼")})}),n.jsx(xn,{visible:!!U,onClose:()=>V(null),item:U||{},fields:yi.map(e=>({...e,label:s(e.label)})),translationEnabled:K,onApply:e=>{if(!U)return;const t=l.map(t=>t.id===U.id?{...t,...e}:t);r(t),z(!0)}})]})},fi=["content","extra"],bi=[{key:"content",label:"å
容",type:"textarea",rows:4,maxCount:500},{key:"extra",label:"说æ",type:"input",maxLength:200}],{Text:_i}=u,Si=({options:e,refresh:i})=>{const{t:s}=ge(),[l,r]=t.useState([]),[o,c]=t.useState(!1),[u,p]=t.useState(!1),[h,m]=t.useState(!1),[y,b]=t.useState(null),[_,k]=t.useState(null),[R,P]=t.useState(!1),[z,N]=t.useState(!1),[A,M]=t.useState(!1),[O,D]=t.useState({content:"",publishDate:new Date,type:"default",extra:""}),[L,B]=t.useState(1),[F,W]=t.useState(10),[J,U]=t.useState([]),[V,K]=t.useState(!0),[G,q]=t.useState(null),$=an(e?.["translation_setting.enabled"]),H=t.useRef(null),Q=[{value:"default",label:s("é»è®¤")},{value:"ongoing",label:s("è¿è¡ä¸")},{value:"success",label:s("æå")},{value:"warning",label:s("è¦å")},{value:"error",label:s("é误")}],X=e=>({default:"grey",ongoing:"blue",success:"green",warning:"orange",error:"red"}[e]||"grey"),Y=[{title:s("å
容"),dataIndex:"content",key:"content",render:e=>n.jsx(f,{content:e,position:"topLeft",showArrow:!0,children:n.jsx("div",{style:{maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})})},{title:s("å叿¶é´"),dataIndex:"publishDate",key:"publishDate",width:180,render:e=>n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:"bold"},children:Ce(e)}),n.jsx("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",marginTop:"2px"},children:e?we(new Date(e)):"-"})]})},{title:s("ç±»å"),dataIndex:"type",key:"type",width:100,render:e=>n.jsx(j,{color:X(e),shape:"circle",children:Q.find(t=>t.value===e)?.label||e})},{title:s("说æ"),dataIndex:"extra",key:"extra",render:e=>n.jsx(f,{content:e||"-",showArrow:!0,children:n.jsx("div",{style:{maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"hsl(var(--muted-foreground))"},children:e||"-"})})},{title:s("ç¿»è¯"),key:"translation_status",width:110,render:(e,t)=>n.jsx(hn,{item:t,fields:fi,onClick:()=>q(t)})},{title:s("æä½"),key:"action",fixed:"right",width:220,render:(e,t)=>n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx(Ge,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>q(t),children:s("è¯æ")}),n.jsx(d,{icon:n.jsx($e,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>Z(t),children:s("ç¼è¾")}),n.jsx(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",size:"small",onClick:()=>ee(t),children:s("å é¤")})]})}],Z=e=>{k(e),D({content:e.content,publishDate:e.publishDate?new Date(e.publishDate):new Date,type:e.type||"default",extra:e.extra||""}),c(!0)},ee=e=>{b(e),p(!0)};t.useEffect(()=>{const t=e["console_setting.announcements"]??e.Announcements;void 0!==t&&(e=>{if(e)try{const t=JSON.parse(e),n=(Array.isArray(t)?t:[]).map((e,t)=>({...e,id:e.id||t+1}));r(n)}catch(t){console.error("è§£æç³»ç»å
¬å失败:",t),r([])}else r([])})(t)},[e["console_setting.announcements"],e.Announcements]),t.useEffect(()=>{const t=e["console_setting.announcements_enabled"];K(void 0===t||"true"===t||!0===t)},[e["console_setting.announcements_enabled"]]);const te={selectedRowKeys:J,onChange:(e,t)=>
1{U(e)},onSelect:(e,t,n)=>{},onSelectAll:(e,t)=>{},getCheckboxProps:e=>({disabled:!1,name:e.id})};return n.jsxs(n.Fragment,{children:[n.jsx(a.Section,{text:n.jsxs("div",{className:"flex flex-col w-full",children:[n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-center text-blue-500",children:[n.jsx(Xe,{size:16,className:"mr-2"}),n.jsx(_i,{children:s("ç³»ç»å
¬å管çï¼å¯ä»¥åå¸ç³»ç»éç¥åéè¦æ¶æ¯ï¼æå¤100个ï¼å端æ¾ç¤ºææ°20æ¡ï¼")})]}),$&&n.jsxs("div",{className:"flex items-center text-amber-500 mt-1",children:[n.jsx(Ge,{size:14,className:"mr-2"}),n.jsx(_i,{type:"warning",size:"small",children:s("å·²å¼å¯èªå¨ç¿»è¯ï¼ä¿å设置æ¶ç±å端并åç¿»è¯ä¸º 6 ç§è¯è¨ï¼èæ¶åå³äºæ¡ç®æ°ä¸æ¨¡åï¼é常 30 ç§~2 åéï¼")})]})]}),n.jsx(I,{margin:"12px"}),n.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 w-full",children:[n.jsxs("div",{className:"flex gap-2 w-full md:w-auto order-2 md:order-1",children:[n.jsx(d,{theme:"light",type:"primary",icon:n.jsx(Ye,{size:14}),className:"w-full md:w-auto",onClick:()=>{k(null),D({content:"",publishDate:new Date,type:"default",extra:""}),c(!0)},children:s("æ·»å å
¬å")}),n.jsxs(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",onClick:()=>{if(0===J.length)return void je(s("请å
éæ©è¦å é¤çç³»ç»å
¬å"));const e=l.filter(e=>!J.includes(e.id));r(e),U([]),M(!0),be(s('å·²å é¤ {{count}} 个系ç»å
¬åï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å',{count:J.length}))},disabled:0===J.length,className:"w-full md:w-auto",children:[s("æ¹éå é¤")," ",J.length>0&&`(${J.length})`]}),n.jsx(d,{icon:n.jsx(Ze,{size:14}),onClick:async()=>{try{N(!0);const e=JSON.stringify(l);await(async(e,t)=>{const n=await ye.put("/api/option/",{key:"console_setting.announcements",value:t}),{success:l,message:a}=n.data;l?(be(s("ç³»ç»å
¬åå·²æ´æ°")),i&&i()):je(a)})(0,e),M(!1)}catch(e){console.error("ç³»ç»å
¬åæ´æ°å¤±è´¥",e),je(s("ç³»ç»å
¬åæ´æ°å¤±è´¥"))}finally{N(!1)}},loading:z,disabled:!A,type:"secondary",className:"w-full md:w-auto",children:s("ä¿å设置")})]}),n.jsxs("div",{className:"order-1 md:order-2 flex items-center gap-2",children:[n.jsx(E,{checked:V,onChange:async e=>{const t=e?"true":"false";try{const n=await ye.put("/api/option/",{key:"console_setting.announcements_enabled",value:t});n.data.success?(K(e),be(s("设置已ä¿å")),i?.()):je(n.data.message)}catch(n){je(n.message)}}}),n.jsx(_i,{children:s(V?"å·²å¯ç¨":"å·²ç¦ç¨")})]})]})]}),children:n.jsx(v,{columns:Y,dataSource:(()=>{const e=[...l].sort((e,t)=>{const n=new Date(e.publishDate).getTime();return new Date(t.publishDate).getTime()-n}),t=(L-1)*F,n=t+F;return e.slice(t,n)})(),rowSelection:te,rowKey:"id",scroll:{x:"max-content"},pagination:{currentPage:L,pageSize:F,total:l.length,showSizeChanger:!0,showQuickJumper:!0,formatPageText:e=>s("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:l.length}),pageSizeOptions:["5","10","20","50"],onChange:(e,t)=>
1{B(e),W(t)},onShowSizeChange:(e,t)=>{B(1),W(t)}},size:"middle",loading:z,empty:n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:s("ææ ç³»ç»å
¬å"),style:{padding:30}}),className:"overflow-hidden"})}),n.jsx(x,{title:s(_?"ç¼è¾å
¬å":"æ·»å å
¬å"),visible:o,onOk:async()=>{if(O.content&&O.publishDate)try{P(!0);const e={...O,publishDate:O.publishDate.toISOString()};let t;if(_)t=l.map(t=>t.id===_.id?{...t,...e}:t);else{const n={id:Math.max(...l.map(e=>e.id),0)+1,...e};t=[...l,n]}r(t),M(!0),c(!1),be(s(_?"å
¬åå·²æ´æ°ï¼è¯·åæ¶ç¹å»âä¿å设置âè¿è¡ä¿å":"å
¬å已添å ï¼è¯·åæ¶ç¹å»âä¿å设置âè¿è¡ä¿å"))}catch(e){je(s("æä½å¤±è´¥")+": "+e.message)}finally{P(!1)}else je(s("请填å宿´çå
¬åä¿¡æ¯"))},onCancel:()=>c(!1),okText:s("ä¿å"),cancelText:s("åæ¶"),confirmLoading:R,children:n.jsxs(a,{layout:"vertical",initValues:O,getFormApi:e=>H.current=e,children:[n.jsx(a.TextArea,{field:"content",label:s("å
¬åå
容"),placeholder:s("请è¾å
¥å
¬åå
å®¹ï¼æ¯æ Markdown/HTMLï¼"),maxCount:500,rows:3,rules:[{required:!0,message:s("请è¾å
¥å
¬åå
容")}],onChange:e=>D({...O,content:e})}),n.jsx(d,{theme:"light",type:"tertiary",size:"small",icon:n.jsx(Qe,{size:14}),style:{marginBottom:16},onClick:()=>m(!0),children:s("æ¾å¤§ç¼è¾")}),n.jsx(a.DatePicker,{field:"publishDate",label:s("å叿¥æ"),type:"dateTime",rules:[{required:!0,message:s("è¯·éæ©å叿¥æ")}],onChange:e=>D({...O,publishDate:e})}),n.jsx(a.Select,{field:"type",label:s("å
¬åç±»å"),optionList:Q,onChange:e=>D({...O,type:e})}),n.jsx(a.Input,{field:"extra",label:s("说æä¿¡æ¯"),placeholder:s("å¯éï¼å
¬åçè¡¥å
说æ"),onChange:e=>D({...O,extra:e})})]},_?_.id:"new")}),n.jsx(x,{title:s("确认å é¤"),visible:u,onOk:()=>{if(y){const e=l.filter(e=>e.id!==y.id);r(e),M(!0),be(s("å
¬åå·²å é¤ï¼è¯·åæ¶ç¹å»âä¿å设置âè¿è¡ä¿å"))}p(!1),b(null)},onCancel:()=>{p(!1),b(null)},okText:s("确认å é¤"),cancelText:s("åæ¶"),type:"warning",okButtonProps:{type:"danger",theme:"solid"},children:n.jsx(_i,{children:s("ç¡®å®è¦å 餿¤å
¬ååï¼")})}),n.jsx(xn,{visible:!!G,onClose:()=>q(null),item:G||{},fields:bi.map(e=>({...e,label:s(e.label)})),translationEnabled:$,onApply:e=>{if(!G)return;const t=l.map(t=>t.id===G.id?{...t,...e}:t);r(t),M(!0)}}),n.jsx(x,{title:s("ç¼è¾å
¬åå
容"),visible:h,onOk:()=>{H.current&&H.current.setValue("content",O.content),m(!1)},onCancel:()=>m(!1),okText:s("ç¡®å®"),cancelText:s("åæ¶"),width:800,children:n.jsx(S,{value:O.content,placeholder:s("请è¾å
¥å
¬åå
å®¹ï¼æ¯æ Markdown/HTMLï¼"),maxCount:500,rows:15,style:{width:"100%"},onChange:e=>D({...O,content:e})})})]})},{Text:ki}=u,vi=["question","answer"],Ci=[{key:"question",label:"é®é¢æ é¢",type:"input",maxLength:200},{key:"answer",label:"åçå
容",type:"textarea",rows:6,maxCount:1e3}],wi=({options:e,refresh:i})=>{const{t:s}=ge(),[l,r]=t.useState([]),[o,c]=t.useState(!1),[u,p]=t.useState(!1),[h,m]=t.useState(null),[y,j]=t.useState(null),[b,_]=t.useState(!1),[S,k]=t.useState(!1),[R,P]=t.useState(!1),[z,N]=t.useState({question:"",answer:""}),[A,M]=t.useState(1),[O,D]=t.useState(10),[L,B]=t.useState([]),[F,W]=t.useState(!0),[J,U]=t.useState(null),V=an(e?.["translation_setting.enabled"]),K=[{title:s("é®é¢æ é¢"),dataIndex:"question",key:"question",render:e=>n.jsx(f,{content:e,showArrow:!0,children:n.jsx("div",{style:{maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:"bold"},children:e})})},{title:s("åçå
容"),dataIndex:"answer",key:"answer",render:e=>n.jsx(f,{content:e,showArrow:!0,children:n.jsx("div",{style:{maxWidth:"400px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"hsl(var(--foreground) / 0.80)"},children:e})})},{title:s("ç¿»è¯"),key:"translation_status",width:110,render:(e,t)=>n.jsx(hn,{item:t,fields:vi,onClick:()=>U(t)})},{title:s("æä½"),key:"action",fixed:"right",width:220,render:(e,t)=>n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx(Ge,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>U(t),children:s("è¯æ")}),n.jsx(d,{icon:n.jsx($e,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>G(t),children:s("ç¼è¾")}),n.jsx(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",size:"small",onClick:()=>q(t),children:s("å é¤")})]})}],G=e=>{j(e),N({question:e.question,answer:e.answer}),c(!0)},q=e=>{m(e),p(!0)};t.useEffect(()=>{void 0!==e["console_setting.faq"]&&(e=>{if(e)try{const t=JSON.parse(e),n=(Array.isArray(t)?t:[]).map((e,t)=>({...e,id:e.id||t+1}));r(n)}catch(t){console.error("è§£æå¸¸è§é®ç失败:",t),r([])}else r([])})(e["console_setting.faq"])},[e["console_setting.faq"]]),t.useEffect(()=>{const t=e["console_setting.faq_enabled"];W(void 0===t||"true"===t||!0===t)},[e["console_setting.faq_enabled"]]);const $={selectedRowKeys:L,onChange:(e,t)=>
1{B(e)},onSelect:(e,t,n)=>{},onSelectAll:(e,t)=>{},getCheckboxProps:e=>({disabled:!1,name:e.id})};return n.jsxs(n.Fragment,{children:[n.jsx(a.Section,{text:n.jsxs("div",{className:"flex flex-col w-full",children:[n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-center text-blue-500",children:[n.jsx(tt,{size:16,className:"mr-2"}),n.jsx(ki,{children:s("常è§é®ç管çï¼ä¸ºç¨æ·æä¾å¸¸è§é®é¢ççæ¡ï¼æå¤50个ï¼å端æ¾ç¤ºææ°20æ¡ï¼")})]}),V&&n.jsxs("div",{className:"flex items-center text-amber-500 mt-1",children:[n.jsx(Ge,{size:14,className:"mr-2"}),n.jsx(ki,{type:"warning",size:"small",children:"t('å·²å¼å¯èªå¨ç¿»è¯ï¼ä¿å设置æ¶ä¼å¯¹æªç¿»è¯/åæå·²ä¿®æ¹çæ¡ç®èªå¨ç¿»è¯ä¸º 6 ç§è¯è¨')"})]})]}),n.jsx(I,{margin:"12px"}),n.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 w-full",children:[n.jsxs("div",{className:"flex gap-2 w-full md:w-auto order-2 md:order-1",children:[n.jsx(d,{theme:"light",type:"primary",icon:n.jsx(Ye,{size:14}),className:"w-full md:w-auto",onClick:()=>{j(null),N({question:"",answer:""}),c(!0)},children:s("æ·»å é®ç")}),n.jsxs(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",onClick:()=>{if(0===L.length)return void je(s("请å
éæ©è¦å é¤ç常è§é®ç"));const e=l.filter(e=>!L.includes(e.id));r(e),B([]),P(!0),be(s('å·²å é¤ {{count}} 个常è§é®çï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å',{count:L.length}))},disabled:0===L.length,className:"w-full md:w-auto",children:[s("æ¹éå é¤")," ",L.length>0&&`(${L.length})`]}),n.jsx(d,{icon:n.jsx(Ze,{size:14}),onClick:async()=>{try{k(!0);let e=l;const t=JSON.stringify(e);await(async(e,t)=>{const n=await ye.put("/api/option/",{key:"console_setting.faq",value:t}),{success:l,message:a}=n.data;l?(be(s("常è§é®çå·²æ´æ°")),i&&i()):je(a)})(0,t),P(!1)}catch(e){console.error("常è§é®çæ´æ°å¤±è´¥",e),je(s("常è§é®çæ´æ°å¤±è´¥"))}finally{k(!1)}},loading:S,disabled:!R,type:"secondary",className:"w-full md:w-auto",children:s("ä¿å设置")})]}),n.jsxs("div",{className:"order-1 md:order-2 flex items-center gap-2",children:[n.jsx(E,{checked:F,onChange:async e=>{const t=e?"true":"false";try{const n=await ye.put("/api/option/",{key:"console_setting.faq_enabled",value:t});n.data.success?(W(e),be(s("设置已ä¿å")),i?.()):je(n.data.message)}catch(n){je(n.message)}}}),n.jsx(ki,{children:s(F?"å·²å¯ç¨":"å·²ç¦ç¨")})]})]})]}),children:n.jsx(v,{columns:K,dataSource:(()=>{const e=(A-1)*O,t=e+O;return l.slice(e,t)})(),rowSelection:$,rowKey:"id",scroll:{x:"max-content"},pagination:{currentPage:A,pageSize:O,total:l.length,showSizeChanger:!0,showQuickJumper:!0,formatPageText:e=>s("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:l.length}),pageSizeOptions:["5","10","20","50"],onChange:(e,t)=>
1{M(e),D(t)},onShowSizeChange:(e,t)=>{M(1),D(t)}},size:"middle",loading:S,empty:n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:s("ææ å¸¸è§é®ç"),style:{padding:30}}),className:"overflow-hidden"})}),n.jsx(x,{title:s(y?"ç¼è¾é®ç":"æ·»å é®ç"),visible:o,onOk:async()=>{if(z.question&&z.answer)try{let e;if(_(!0),y)e=l.map(e=>e.id===y.id?{...e,...z}:e);else{const t={id:Math.max(...l.map(e=>e.id),0)+1,...z};e=[...l,t]}r(e),P(!0),c(!1),be(s(y?"é®çå·²æ´æ°ï¼è¯·åæ¶ç¹å»âä¿å设置âè¿è¡ä¿å":"é®ç已添å ï¼è¯·åæ¶ç¹å»âä¿å设置âè¿è¡ä¿å"))}catch(e){je(s("æä½å¤±è´¥")+": "+e.message)}finally{_(!1)}else je(s("请填å宿´çé®çä¿¡æ¯"))},onCancel:()=>c(!1),okText:s("ä¿å"),cancelText:s("åæ¶"),confirmLoading:b,width:800,children:n.jsxs(a,{layout:"vertical",initValues:z,children:[n.jsx(a.Input,{field:"question",label:s("é®é¢æ é¢"),placeholder:s("请è¾å
¥é®é¢æ é¢"),maxLength:200,rules:[{required:!0,message:s("请è¾å
¥é®é¢æ é¢")}],onChange:e=>N({...z,question:e})}),n.jsx(a.TextArea,{field:"answer",label:s("åçå
容"),placeholder:s("请è¾å
¥åçå
å®¹ï¼æ¯æ Markdown/HTMLï¼"),maxCount:1e3,rows:6,rules:[{required:!0,message:s("请è¾å
¥åçå
容")}],onChange:e=>N({...z,answer:e})})]},y?y.id:"new")}),n.jsx(x,{title:s("确认å é¤"),visible:u,onOk:()=>{if(h){const e=l.filter(e=>e.id!==h.id);r(e),P(!0),be(s("é®çå·²å é¤ï¼è¯·åæ¶ç¹å»âä¿å设置âè¿è¡ä¿å"))}p(!1),m(null)},onCancel:()=>{p(!1),m(null)},okText:s("确认å é¤"),cancelText:s("åæ¶"),type:"warning",okButtonProps:{type:"danger",theme:"solid"},children:n.jsx(ki,{children:s("ç¡®å®è¦å 餿¤é®çåï¼")})}),n.jsx(xn,{visible:!!J,onClose:()=>U(null),item:J||{},fields:Ci.map(e=>({...e,label:s(e.label)})),translationEnabled:V,onApply:e=>{if(!J)return;const t=l.map(t=>t.id===J.id?{...t,...e}:t);r(t),P(!0)}})]})},{Text:Ti}=u,Ii=({options:e,refresh:i})=>{const{t:s}=ge(),[l,r]=t.useState([]),[o,c]=t.useState(!1),[u,p]=t.useState(!1),[h,m]=t.useState(null),[y,j]=t.useState(null),[f,b]=t.useState(!1),[_,S]=t.useState(!1),[k,R]=t.useState(!1),[P,z]=t.useState({categoryName:"",url:"",slug:""}),[N,A]=t.useState(1),[M,O]=t.useState(10),[D,L]=t.useState([]),[B,F]=t.useState(!0),W=[{title:s("åç±»åç§°"),dataIndex:"categoryName",key:"categoryName",render:e=>n.jsx("div",{style:{fontWeight:"bold",color:"hsl(var(--foreground))"},children:e})},{title:s("Uptime Kumaå°å"),dataIndex:"url",key:"url",render:e=>n.jsx("div",{style:{maxWidth:"300px",wordBreak:"break-all",fontFamily:"monospace",color:"hsl(var(--primary))"},children:e})},{title:s("ç¶æé¡µé¢Slug"),dataIndex:"slug",key:"slug",render:e=>n.jsx("div",{style:{fontFamily:"monospace",color:"hsl(var(--foreground) / 0.80)"},children:e})},{title:s("æä½"),key:"action",fixed:"right",width:150,render:(e,t)=>n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx($e,{size:14}),theme:"light",type:"tertiary",size:"small",onClick:()=>J(t),children:s("ç¼è¾")}),n.jsx(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",size:"small",onClick:()=>U(t),children:s("å é¤")})]})}],J=e=>{j(e),z({categoryName:e.categoryName,url:e.url,slug:e.slug}),c(!0)},U=e=>{m(e),p(!0)};t.useEffect(()=>{const t=e["console_setting.uptime_kuma_groups"];void 0!==t&&(e=>{if(e)try{const t=JSON.parse(e),n=(Array.isArray(t)?t:[]).map((e,t)=>({...e,id:e.id||t+1}));r(n)}catch(t){console.error("è§£æUptime Kumaé
置失败:",t),r([])}else r([])})(t)},[e["console_setting.uptime_kuma_groups"]]),t.useEffect(()=>{const t=e["console_setting.uptime_kuma_enabled"];F(void 0===t||"true"===t||!0===t)},[e["console_setting.uptime_kuma_enabled"]]);const V={selectedRowKeys:D,onChange:(e,t)=>
1{L(e)},onSelect:(e,t,n)=>{},onSelectAll:(e,t)=>{},getCheckboxProps:e=>({disabled:!1,name:e.id})};return n.jsxs(n.Fragment,{children:[n.jsx(a.Section,{text:n.jsxs("div",{className:"flex flex-col w-full",children:[n.jsx("div",{className:"mb-2",children:n.jsxs("div",{className:"flex items-center text-blue-500",children:[n.jsx(nt,{size:16,className:"mr-2"}),n.jsx(Ti,{children:s("Uptime Kumaçæ§å类管çï¼å¯ä»¥é
ç½®å¤ä¸ªçæ§åç±»ç¨äºæå¡ç¶æå±ç¤ºï¼æå¤20个ï¼")})]})}),n.jsx(I,{margin:"12px"}),n.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 w-full",children:[n.jsxs("div",{className:"flex gap-2 w-full md:w-auto order-2 md:order-1",children:[n.jsx(d,{theme:"light",type:"primary",icon:n.jsx(Ye,{size:14}),className:"w-full md:w-auto",onClick:()=>{j(null),z({categoryName:"",url:"",slug:""}),c(!0)},children:s("æ·»å åç±»")}),n.jsxs(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",onClick:()=>{if(0===D.length)return void je(s("请å
éæ©è¦å é¤çåç±»"));const e=l.filter(e=>!D.includes(e.id));r(e),L([]),R(!0),be(s('å·²å é¤ {{count}} 个åç±»ï¼è¯·åæ¶ç¹å»"ä¿å设置"è¿è¡ä¿å',{count:D.length}))},disabled:0===D.length,className:"w-full md:w-auto",children:[s("æ¹éå é¤")," ",D.length>0&&`(${D.length})`]}),n.jsx(d,{icon:n.jsx(Ze,{size:14}),onClick:async()=>{try{S(!0);const e=JSON.stringify(l);await(async(e,t)=>{const n=await ye.put("/api/option/",{key:"console_setting.uptime_kuma_groups",value:t}),{success:l,message:a}=n.data;l?(be(s("Uptime Kumaé
ç½®å·²æ´æ°")),i&&i()):je(a)})(0,e),R(!1)}catch(e){console.error("Uptime Kumaé
ç½®æ´æ°å¤±è´¥",e),je(s("Uptime Kumaé
ç½®æ´æ°å¤±è´¥"))}finally{S(!1)}},loading:_,disabled:!k,type:"secondary",className:"w-full md:w-auto",children:s("ä¿å设置")})]}),n.jsxs("div",{className:"order-1 md:order-2 flex items-center gap-2",children:[n.jsx(E,{checked:B,onChange:async e=>{const t=e?"true":"false";try{const n=await ye.put("/api/option/",{key:"console_setting.uptime_kuma_enabled",value:t});n.data.success?(F(e),be(s("设置已ä¿å")),i?.()):je(n.data.message)}catch(n){je(n.message)}}}),n.jsx(Ti,{children:s(B?"å·²å¯ç¨":"å·²ç¦ç¨")})]})]})]}),children:n.jsx(v,{columns:W,dataSource:(()=>{const e=(N-1)*M,t=e+M;return l.slice(e,t)})(),rowSelection:V,rowKey:"id",scroll:{x:"max-content"},pagination:{currentPage:N,pageSize:M,total:l.length,showSizeChanger:!0,showQuickJumper:!0,formatPageText:e=>s("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:l.length}),pageSizeOptions:["5","10","20","50"],onChange:(e,t)=>
1{A(e),O(t)},onShowSizeChange:(e,t)=>{A(1),O(t)}},size:"middle",loading:_,empty:n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:s("ææ çæ§æ°æ®"),style:{padding:30}}),className:"overflow-hidden"})}),n.jsx(x,{title:s(y?"ç¼è¾åç±»":"æ·»å åç±»"),visible:o,onOk:async()=>{if(P.categoryName&&P.url&&P.slug){try{new URL(P.url)}catch(e){return void je(s("请è¾å
¥ææçURLå°å"))}if(/^[a-zA-Z0-9_-]+$/.test(P.slug))try{let e;if(b(!0),y)e=l.map(e=>e.id===y.id?{...e,...P}:e);else{const t={id:Math.max(...l.map(e=>e.id),0)+1,...P};e=[...l,t]}r(e),R(!0),c(!1),be(s(y?"åç±»å·²æ´æ°ï¼è¯·åæ¶ç¹å»âä¿å设置âè¿è¡ä¿å":"å类已添å ï¼è¯·åæ¶ç¹å»âä¿å设置âè¿è¡ä¿å"))}catch(e){je(s("æä½å¤±è´¥")+": "+e.message)}finally{b(!1)}else je(s("Slugåªè½å
å«åæ¯ãæ°åãä¸å线åè¿å符"))}else je(s("请填å宿´çå类信æ¯"))},onCancel:()=>c(!1),okText:s("ä¿å"),cancelText:s("åæ¶"),confirmLoading:f,width:600,children:n.jsxs(a,{layout:"vertical",initValues:P,children:[n.jsx(a.Input,{field:"categoryName",label:s("åç±»åç§°"),placeholder:s("请è¾å
¥åç±»åç§°ï¼å¦ï¼OpenAIãClaudeç"),maxLength:50,rules:[{required:!0,message:s("请è¾å
¥åç±»åç§°")}],onChange:e=>z({...P,categoryName:e})}),n.jsx(a.Input,{field:"url",label:s("Uptime Kumaå°å"),placeholder:s("请è¾å
¥Uptime Kumaæå¡å°åï¼å¦ï¼https://status.example.com"),maxLength:500,rules:[{required:!0,message:s("请è¾å
¥Uptime Kumaå°å")}],onChange:e=>z({...P,url:e})}),n.jsx(a.Input,{field:"slug",label:s("ç¶æé¡µé¢Slug"),placeholder:s("请è¾å
¥ç¶æé¡µé¢çSlugï¼å¦ï¼my-status"),maxLength:100,rules:[{required:!0,message:s("请è¾å
¥ç¶æé¡µé¢Slug")}],onChange:e=>z({...P,slug:e})})]},y?y.id:"new")}),n.jsx(x,{title:s("确认å é¤"),visible:u,onOk:()=>{if(h){const e=l.filter(e=>e.id!==h.id);r(e),R(!0),be(s("å类已å é¤ï¼è¯·åæ¶ç¹å»âä¿å设置âè¿è¡ä¿å"))}p(!1),m(null)},onCancel:()=>{p(!1),m(null)},okText:s("确认å é¤"),cancelText:s("åæ¶"),type:"warning",okButtonProps:{type:"danger",theme:"solid"},children:n.jsx(Ti,{children:s("ç¡®å®è¦å 餿¤åç±»åï¼")})})]})};function Ei(e){const{t:i}=ge(),s=[{key:"hour",label:i("å°æ¶"),value:"hour"},{key:"day",label:i("天"),value:"day"},{key:"week",label:i("å¨"),value:"week"},{key:"month",label:i("æ"),value:"month"}],[l,r]=t.useState(!1),[u,p]=t.useState({DataExportEnabled:!1,DataExportInterval:"",DataExportDefaultTime:""}),h=t.useRef(),[x,g]=t.useState(u);return t.useEffect(()=>{const t={};for(let n in e.options)Object.keys(u).includes(n)&&(t[n]=e.options[n]);p(t),g(structuredClone(t)),h.current.setValues(t),localStorage.setItem("data_export_default_time",String(u.DataExportDefaultTime))},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:l,children:n.jsx(a,{values:u,getFormApi:e=>h.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("æ°æ®çæ¿è®¾ç½®"),children:[n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"DataExportEnabled",label:i("å¯ç¨æ°æ®çæ¿ï¼å®éªæ§ï¼"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{p({...u,DataExportEnabled:e})}})})}),n.jsxs(o,{children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{label:i("æ°æ®çæ¿æ´æ°é´é"),step:1,min:1,suffix:i("åé"),extraText:i("设置è¿çä¼å½±åæ°æ®åºæ§è½"),placeholder:i("æ°æ®çæ¿æ´æ°é´é"),field:"DataExportInterval",onChange:e=>p({...u,DataExportInterval:String(e)})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Select,{label:i("æ°æ®çæ¿é»è®¤æ¶é´ç²åº¦"),optionList:s,field:"DataExportDefaultTime",extraText:i("ä»
ä¿®æ¹å±ç¤ºç²åº¦ï¼ç»è®¡ç²¾ç¡®å°å°æ¶"),placeholder:i("æ°æ®çæ¿é»è®¤æ¶é´ç²åº¦"),style:{width:180},onChange:e=>p({...u,DataExportDefaultTime:String(e)})})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(u,x);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t="";return t="boolean"==typeof u[e.key]?String(u[e.key]):u[e.key],ye.put("/api/option/",{key:e.key,value:t})});r(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{r(!1)})},children:i("ä¿åæ°æ®çæ¿è®¾ç½®")})})]})})})})}const Ri=()=>{const{t:e}=ge();let[i,s]=t.useState({"console_setting.api_info":"","console_setting.announcements":"","console_setting.faq":"","console_setting.uptime_kuma_groups":"","console_setting.api_info_enabled":"","console_setting.announcements_enabled":"","console_setting.faq_enabled":"","console_setting.uptime_kuma_enabled":"","translation_setting.enabled":!1,ApiInfo:"",Announcements:"",FAQ:"",UptimeKumaUrl:"",UptimeKumaSlug:"",DataExportEnabled:!1,DataExportDefaultTime:"hour",DataExportInterval:5}),[l,a]=t.useState(!1);const[o,c]=t.useState(!1);async function d(){try{a(!0),await(async()=>{const e=await ye.get("/api/option/"),{success:t,message:n,data:l}=e.data;if(t){let e={};l.forEach(t=>{t.key in i&&(e[t.key]=t.value),t.key.endsWith("Enabled")&&"DataExportEnabled"===t.key&&(e[t.key]=an(t.value)),"translation_setting.enabled"===t.key&&(e[t.key]=an(t.value))}),s(e)}else je(n)})()}catch(t){je(e("å·æ°å¤±è´¥")),console.error(t)}finally{a(!1)}}t.useEffect(()=>{d()},[]);const u=t.useMemo(()=>["ApiInfo","Announcements","FAQ","UptimeKumaUrl","UptimeKumaSlug"].some(e=>i[e]),[i]);return t.useEffect(()=>{u&&c(!0)},[u]),n.jsx(n.Fragment,{children:n.jsxs(m,{spinning:l,size:"large",children:[n.jsxs(x,{title:e("é
ç½®è¿ç§»ç¡®è®¤"),visible:o,onOk:async()=>{try{a(!0),await ye.post("/api/option/migrate_console_setting"),be(e("æ§é
ç½®è¿ç§»å®æ")),await d(),c(!1)}catch(t){console.error(t),je(e("è¿ç§»å¤±è´¥: ")+(t.message||e("æªç¥é误")))}finally{a(!1)}},onCancel:()=>c(!1),confirmLoading:l,okText:e("确认è¿ç§»"),cancelText:e("åæ¶"),children:[n.jsx("p",{children:e("æ£æµå°æ§çæ¬çé
ç½®æ°æ®ï¼æ¯å
1¦è¦è¿ç§»å°æ°çé
ç½®æ ¼å¼ï¼")}),n.jsxs("p",{style:{color:"hsl(var(--warning))",marginTop:"10px"},children:[n.jsx("strong",{children:e("注æï¼")}),e("è¿ç§»è¿ç¨ä¸ä¼èªå¨å¤çæ°æ®æ ¼å¼è½¬æ¢ï¼è¿ç§»å®æåæ§é
ç½®å°è¢«æ¸
é¤ï¼è¯·å¨è¿ç§»å卿°æ®åºä¸å¤ä»½å¥½æ§é
ç½®ã")]})]}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Ei,{options:i,refresh:d})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Si,{options:i,refresh:d})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(ji,{options:i,refresh:d})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(wi,{options:i,refresh:d})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Ii,{options:i,refresh:d})})]})})};function Pi(e){const{t:i}=ge(),[s,l]=t.useState([]),[r,o]=t.useState(!1),[c,u]=t.useState(null),[p,h]=t.useState(""),[m,y]=t.useState(1),[j,f]=t.useState(!1);t.useEffect(()=>{try{const t=JSON.parse(e.options.GroupRatio||"{}"),n=JSON.parse(e.options.UserUsableGroups||"{}"),i=new Set([...Object.keys(t),...Object.keys(n)]),s=Array.from(i).map(e=>({name:e,ratio:void 0===t[e]?"":t[e],description:void 0===n[e]||null===n[e]?"":String(n[e])}));l(s)}catch(t){console.error("JSONè§£æé误:",t)}},[e.options]);const b=s.filter(e=>!p||e.name.toLowerCase().includes(p.toLowerCase())),_=((e,t)=>{const n=10*(t-1),i=n+10;return e.slice(n,i)})(b,m),S=[{title:i("åç»åç§°"),dataIndex:"name",key:"name"},{title:i("åç»åç"),dataIndex:"ratio",key:"ratio",render:(e,t)=>n.jsx(k,{value:e,placeholder:i("è¾å
¥åç"),onChange:e=>C(t.name,"ratio",e)})},{title:i("åç»æè¿°"),dataIndex:"description",key:"description",render:(e,t)=>n.jsx(k,{value:e,placeholder:i("è¾å
¥æè¿°"),onChange:e=>C(t.name,"description",e)})},{title:i("æä½"),key:"action",render:(e,t)=>n.jsx(d,{icon:n.jsx(He,{size:16}),type:"danger",onClick:()=>w(t.name)})}],C=(e,t,n)=>{"ratio"===t&&isNaN(n)?je(i("请è¾å
¥æ°å")):l(i=>i.map(i=>i.name===e?{...i,[t]:n}:i))},w=e=>{l(t=>t.filter(t=>t.name!==e))};return n.jsxs(n.Fragment,{children:[n.jsxs(g,{vertical:!0,align:"start",style:{width:"100%"},children:[n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx(Ye,{size:16}),onClick:()=>o(!0),children:i("æ·»å åç»")}),n.jsx(d,{type:"primary",icon:n.jsx(Ze,{size:16}),onClick:async()=>{f(!0);const t={GroupRatio:{},UserUsableGroups:{}};try{s.forEach(e=>{""===e.ratio||isNaN(parseFloat(e.ratio))||(t.GroupRatio[e.name]=parseFloat(e.ratio)),""!==e.description&&null!==e.description&&void 0!==e.description&&(t.UserUsableGroups[e.name]=String(e.description))});const n={GroupRatio:JSON.stringify(t.GroupRatio,null,2),UserUsableGroups:JSON.stringify(t.UserUsableGroups,null,2)},l=Ee()?"/api/option/":"/api/option/admin",a=Object.entries(n).map(([e,t])=>ye.put(l,{key:e,value:t})),r=await Promise.all(a);if(r.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));for(const e of r)if(!e.data.success)return je(e.data.message);be(i("ä¿åæå")),e.refresh()}catch(n){console.error("ä¿å失败:",n),je(i("ä¿å失败ï¼è¯·éè¯"))}finally{f(!1)}},children:i("åºç¨æ´æ¹")}),n.jsx(k,{prefix:n.jsx(st,{size:16}),placeholder:i("æç´¢åç»åç§°"),value:p,onChange:e=>{h(e),y(1)},style:{width:200}})]}),n.jsx(v,{columns:S,dataSource:_,pagination:{currentPage:m,pageSize:10,total:b.length,onPageChange:e=>y(e),showTotal:!0,showSizeChanger:!1}})]}),n.jsx(x,{title:i("æ·»å åç»"),visible:r,onCancel:()=>o(!1),onOk:()=>{var e;c&&(e=c,s.some(t=>t.name===e.name)?je(i("åç»åç§°å·²åå¨")):(l(t=>[{name:e.name,ratio:e.ratio||"",description:e.description||""},...t]),o(!1),be(i("æ·»å æå"))))},children:n.jsxs(a,{children:[n.jsx(a.Input,{field:"name",label:i("åç»åç§°"),required:!0,onChange:e=>u(t=>({...t,name:e}))}),n.jsx(a.Input,{field:"ratio",label:i("åç»åç"),onChange:e=>u(t=>({...t,ratio:e}))}),n.jsx(a.Input,{field:"description",label:i("åç»æè¿°"),onChange:e=>u(t=>({...t,description:e}))})]})})]})}function zi(e){const{t:i}=ge(),[s,l]=t.useState([]),[r,o]=t.useState(!1),[c,u]=t.useState(null),[p,h]=t.useState([]),[m,y]=t.useState(!1),[j,f]=t.useState(1),[b,_]=t.useState(10);t.useEffect(()=>{try{const t=JSON.parse(e.options.GroupPermissions||"{}"),n=JSON.parse(e.options.UserUsableGroups||"{}");h(Object.keys(n));const i=Object.entries(t).map(([e,t])=>({group:e,allowedGroups:t,description:n[e]||""}));l(i)}catch(t){console.error("JSONè§£æé误:",t)}},[e.options]);const S=((e,t,n)=>{const i=(t-1)*n,s=i+n;return e.slice(i,s)})(s,j,b),k=[{title:i("ç¨æ·ç»"),dataIndex:"group",key:"group"},{title:i("å¯ç¨ä»¤çç»"),dataIndex:"allowedGroups",key:"allowedGroups",render:(e,t)=>n.jsx(N,{multiple:!0,value:t.allowedGroups,onChange:e=>C(t.group,e),style:{width:"100%"},children:p.map(e=>n.jsx(N.Option,{value:e,children:e},e))})},{title:i("æä½"),key:"action",render:(e,t)=>n.jsx(d,{icon:n.jsx(He,{size:16}),type:"danger",onClick:()=>w(t.group)})}],C=(e,t)=>{l(n=>n.map(n=>n.group===e?{...n,allowedGroups:t}:n))},w=e=>{l(t=>t.filter(t=>t.group!==e))};return n.jsxs(n.Fragment,{children:[n.jsxs(g,{vertical:!0,align:"start",style:{width:"100%"},children:[n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx(Ye,{size:16}),onClick:()=>o(!0),children:i("æ·»å æ°çç¨æ·ç»")}),n.jsx(d,{type:"primary",icon:n.jsx(Ze,{size:16}),onClick:async()=>{y(!0);try{const t={};
1s.forEach(e=>{t[e.group]=e.allowedGroups});const n=Ee()?"/api/option/":"/api/option/admin",l=await ye.put(n,{key:"GroupPermissions",value:JSON.stringify(t,null,2)});if(!l.data.success)return je(l.data.message);be(i("ä¿åæå")),e.refresh()}catch(t){console.error("ä¿å失败:",t),je(i("ä¿å失败ï¼è¯·éè¯"))}finally{y(!1)}},children:i("åºç¨æ´æ¹")})]}),n.jsx(v,{columns:k,dataSource:S,pagination:{currentPage:j,pageSize:b,total:s.length,onPageChange:e=>f(e)}})]}),n.jsx(x,{title:i("æ·»å æ°çç¨æ·ç»"),visible:r,onCancel:()=>o(!1),onOk:()=>{var e;c&&(e=c,s.some(t=>t.group===e.group)?je(i("åç»å·²åå¨")):(l(t=>[{group:e.group,allowedGroups:e.allowedGroups||[],description:e.description||""},...t]),o(!1),be(i("æ·»å æå"))))},children:n.jsxs(a,{children:[n.jsx(a.Input,{field:"group",label:i("ç¨æ·ç»åç§°"),required:!0,onChange:e=>u(t=>({...t,group:e}))}),n.jsx(a.Select,{field:"allowedGroups",label:i("å¯ç¨åç»"),multiple:!0,onChange:e=>u(t=>({...t,allowedGroups:e})),children:p.map(e=>n.jsx(a.Select.Option,{value:e,children:e},e))})]})})]})}const Ni=({options:e,refresh:i})=>{const{t:s}=ge(),[l,a]=t.useState([]),[r,o]=t.useState(!1);t.useEffect(()=>{if(e.BulkTopUpDiscounts)try{const t=JSON.parse(e.BulkTopUpDiscounts),n=Object.entries(t).map(([e,t])=>({amount:Number(e),ratio:Number(t)}));a(n)}catch(t){console.error("è§£æææ£æ°æ®å¤±è´¥:",t),a([])}},[e.BulkTopUpDiscounts]);const c=(e,t,n)=>{const i=[...l];i[e][t]=n,a(i)},u=[{title:s("å
å¼éé¢(åä½: å)"),dataIndex:"amount",render:(e,t,i)=>n.jsx(M,{value:e,onChange:e=>c(i,"amount",e),min:0,style:{width:"100%"}})},{title:s("ææ£æ¯ä¾(0-1 0.5 表示50%ææ£)"),dataIndex:"ratio",render:(e,t,i)=>n.jsx(M,{value:e,onChange:e=>c(i,"ratio",e),min:0,max:1,step:.1,style:{width:"100%"}})},{title:s("æä½"),dataIndex:"operation",render:(e,t,i)=>n.jsx(O,{title:s("ç¡®å®è¦å é¤åï¼"),onConfirm:()=>(e=>{const t=l.filter((t,n)=>n!==e);a(t)})(i),children:n.jsx(d,{icon:n.jsx(rt,{size:16}),type:"danger",theme:"borderless"})})}];return n.jsxs("div",{children:[n.jsx(v,{columns:u,dataSource:l,pagination:!1,loading:r}),n.jsxs("div",{style:{marginTop:16,display:"flex",gap:8},children:[n.jsx(d,{icon:n.jsx(ot,{size:16}),onClick:()=>{a([...l,{amount:0,ratio:1}])},children:s("æ·»å ææ£")}),n.jsx(d,{type:"primary",onClick:async()=>{try{o(!0);const e={};l.forEach(({amount:t,ratio:n})=>{e[t]=n});const t=Ee()?"/api/option/":"/api/option/admin",n=await ye.put(t,{key:"BulkTopUpDiscounts",value:JSON.stringify(e)});n.data.success?(be(s("ä¿åæå")),i()):je(s("ä¿å失败")+"ï¼"+n.data.message)}catch(e){je(s("ä¿å失败")+"ï¼"+e.message)}finally{o(!1)}},children:s("ä¿å")})]})]})},Ai=({options:e,refresh:i})=>{const{t:s}=ge(),[l,a]=t.useState([]),[r,o]=t.useState(!1),c=Pe();t.useEffect(()=>{if(e.TopupStarLevels)try{const t=JSON.parse(e.TopupStarLevels),n=Object.entries(t).map(([e,t])=>({name:String(e),price:Number(t)}));a(n)}catch(t){console.error("è§£ææçº§æ°æ®å¤±è´¥:",t),a([])}else a([])},[e.TopupStarLevels]);const u=(e,t,n)=>{const i=[...l];i[e][t]=n,a(i)},p=[{title:s("æçº§åç§°"),dataIndex:"name",render:(e,t,i)=>n.jsx(k,{value:e,onChange:e=>u(i,"name",e),placeholder:s("å¦ï¼1æ / è客æ·"),style:{width:"100%"}})},{title:s("å
å¼åä»·(å
/é¢åº¦)"),dataIndex:"price",render:(e,t,i)=>n.jsx(M,{value:e,onChange:e=>u(i,"price",e),min:0,step:.001,precision:4,style:{width:"100%"}})},{title:s("æä½"),dataIndex:"operation",render:(e,t,i)=>n.jsx(O,{title:s("ç¡®å®è¦å é¤åï¼"),onConfirm:()=>(e=>{a(l.filter((t,n)=>n!==e))})(i),children:n.jsx(d,{icon:n.jsx(rt,{size:16}),type:"danger",theme:"borderless"})})}];return c?n.jsxs("div",{children:[n.jsx(v,{columns:p,dataSource:l,pagination:!1,loading:r}),n.jsxs("div",{style:{marginTop:16,display:"flex",gap:8},children:[n.jsx(d,{icon:n.jsx(ot,{size:16}),onClick:()=>{a([...l,{name:"",price:0}])},children:s("æ·»å æçº§")}),n.jsx(d,{type:"primary",onClick:async()=>{if(c)try{const e={};for(const{name:n,price:i}of l){const t=(n||"").trim();if(!t)return void je(s("æçº§åç§°ä¸è½ä¸ºç©º"));if(Object.prototype.hasOwnProperty.call(e,t))return void je(s("æçº§åç§°ä¸è½éå¤")+"ï¼"+t);if(!(Number(i)>0))return void je(s("å
å¼åä»·å¿
é¡»å¤§äº 0")+"ï¼"+t);e[t]=Number(i)}o(!0);const t=await ye.put("/api/option/admin",{key:"TopupStarLevels",value:JSON.stringify(e)});t.data.success?(be(s("ä¿åæå")),i()):je(s("ä¿å失败")+"ï¼"+t.data.message)}catch(e){je(s("ä¿å失败")+"ï¼"+e.message)}finally{o(!1)}},children:s("ä¿å")})]})]}):null};function Mi(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({GroupRatio:"",UserUsableGroups:"",GroupPermissions:"",BulkTopUpDiscounts:"",TopupStarLevels:"",GroupGroupRatio:"",GroupModelRatio:"",AutoGroups:"",DefaultUseAutoGroup:!1}),p=t.useRef(),[h,x]=t.useState(r);return t.useEffect(()=>{const t={GroupRatio:"",UserUsableGroups:"",GroupPermissions:"",BulkTopUpDiscounts:"",TopupStarLevels:"",GroupGroupRatio:"",GroupModelRatio:"",AutoGroups:"",DefaultUseAutoGroup:!1};for(let n in e.options)n in t&&(t[n]=e.options[n]);u(t),x(structuredClone(t)),p.current.setValues(t)},[e.options]),n.jsx(m,{spinning:s,children:n.jsxs(b,{type:"line",children:[n.jsx(b.TabPane,{tab:i("å¯è§åç¼è¾ä»¤çç»"),itemKey:"visual",children:n.jsx(Pi,{options:r,refresh:e.refresh})}),n.jsx(b.TabPane,{tab:i("ç¨æ·åç»æé设置"),itemKey:"permissions",children:n.jsx(zi,{options:r,refresh:e.refresh})}),n.jsx(b.TabPane,{tab:i("å
弿æ£è®¾ç½®"),itemKey:"discount",children:n.jsx(Ni,{options:r,refresh:e.refresh})}),Pe()&&n.jsx(b.TabPane,{tab:i("ç¨æ·æçº§å价设置"),itemKey:"starLevel",children:n.jsx(Ai,{options:r,refresh:e.refresh})}),n.jsxs(b.TabPane,{tab:i("ææ¬ç¼è¾æ¨¡å¼"),itemKey:"text",children:[n.jsx(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("åç»è®¾ç½®"),children:[n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,
1children:n.jsx(a.TextArea,{label:i("åç»åç"),placeholder:i("为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºåç»åç§°ï¼å¼ä¸ºåç"),extraText:i("group_ratio_hint_002"),field:"GroupRatio",autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:i("䏿¯åæ³ç JSON å符串")}],onChange:e=>u({...r,GroupRatio:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:i("ç¨æ·å¯éåç»"),placeholder:i("为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºåç»åç§°ï¼å¼ä¸ºåç»æè¿°"),extraText:i("group_ratio_hint_003"),field:"UserUsableGroups",autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:i("䏿¯åæ³ç JSON å符串")}],onChange:e=>u({...r,UserUsableGroups:e})})})}),n.jsx(o,{gutter:16,children:n.jsxs(c,{xs:24,sm:16,children:[n.jsx(a.TextArea,{label:i("åç»æéé
ç½®"),placeholder:i("为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºç¨æ·åç»ï¼å¼ä¸ºè¯¥åç»å¯ä»¥ä½¿ç¨çåç»å表"),field:"GroupPermissions",autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:i("䏿¯åæ³ç JSON å符串")}],onChange:e=>u({...r,GroupPermissions:e})}),n.jsx("div",{style:{marginTop:8,color:"hsl(var(--foreground))"},children:i("group_ratio_hint_004")})]})}),n.jsx(o,{gutter:16,children:n.jsxs(c,{xs:24,sm:16,children:[n.jsx(a.TextArea,{label:i("å
弿æ£ä»·"),placeholder:i("为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºå
å¼éé¢ï¼å¼ä¸ºææ£æ¯ä¾"),field:"BulkTopUpDiscounts",autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:i("䏿¯åæ³ç JSON å符串")}],onChange:e=>u({...r,BulkTopUpDiscounts:e})}),n.jsx("div",{style:{marginTop:8,color:"hsl(var(--foreground))"},children:i('示ä¾: {"100": 0.9, "200": 0.8, "500": 0.7}')})]})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:i("åç»ç¹æ®åç"),placeholder:i("为ä¸ä¸ª JSON ææ¬"),extraText:i("group_ratio_hint_005"),field:"GroupGroupRatio",autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:i("䏿¯åæ³ç JSON å符串")}],onChange:e=>u({...r,GroupGroupRatio:e})})})}),n.jsx(o,{gutter:16,children:n.jsxs(c,{xs:24,sm:16,children:[n.jsx(a.TextArea,{label:i("åç»æ¨¡ååç"),placeholder:i("为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºåç»åç§°ï¼å¼ä¸ºæ¨¡ååçæ å°"),extraText:i("group_ratio_hint_001"),field:"GroupModelRatio",autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>!t||""===t.trim()||Re(t),message:i("䏿¯åæ³ç JSON å符串")}],onChange:e=>u({...r,GroupModelRatio:e})}),n.jsx("div",{style:{marginTop:8,color:"hsl(var(--foreground))"},children:i('示ä¾: {"default": {"kling-*": 0.65, "vidu*": 0.55, "aigc-image-qwen": 0.85}}')})]})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:i("èªå¨åç»autoï¼ä»ç¬¬ä¸ä¸ªå¼å§éæ©"),placeholder:i("为ä¸ä¸ª JSON ææ¬"),field:"AutoGroups",autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>{if(!t||""===t.trim())return!0;try{const e=JSON.parse(t);return!!Array.isArray(e)&&e.every(e=>"string"==typeof e)}catch(n){return!1}},message:i('å¿
é¡»æ¯ææç JSON å符串æ°ç»ï¼ä¾å¦ï¼["g1","g2"]')}],onChange:e=>u({...r,AutoGroups:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{span:16,children:n.jsx(a.Switch,{label:i("å建令çé»è®¤éæ©autoåç»ï¼åå§ä»¤çä¹å°è®¾ä¸ºautoï¼å¦åç空ï¼ä¸ºç¨æ·é»è®¤åç»ï¼"),field:"DefaultUseAutoGroup",onChange:e=>u({...r,DefaultUseAutoGroup:e})})})})]})}),n.jsx(d,{onClick:async function(){try{await p.current.validate().then(()=>{const t=ke(r,h);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=Ee()?"/api/option/":"/api/option/admin",s=t.map(e=>{const t="boolean"==typeof r[e.key]?String(r[e.key]):r[e.key];return ye.put(n,{key:e.key,value:t})});l(!0),Promise.all(s).then(t=>{if(t.includes(void 0))return je(s.length>1?i("é¨åä¿å失败ï¼è¯·éè¯"):i("ä¿å失败"));for(let e=0;e<t.length;e++)if(!t[e].data.success)return je(t[e].data.message);be(i("ä¿åæå")),e.refresh()}).catch(e=>{console.error("Unexpected error:",e),je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})}).catch(()=>{je(i("è¯·æ£æ¥è¾å
¥"))})}catch(t){je(i("è¯·æ£æ¥è¾å
¥")),console.error(t)}},children:i("ä¿ååç»è®¾ç½®")})]})]})})}function Oi(e){const[i,s]=t.useState(!1),[l,r]=t.useState({ModelPrice:"",ModelRatio:"",CacheRatio:"",ServiceTierRatio:"",CacheCreation5mRatio:"",CacheCreation1hRatio:"",CompletionRatio:"",ModelStepRatio:"",ModelPixelPrice:"",ModelVideoTokenPrice:"",ModelVideoDurationPrice:"",ModelVideoDurationAudioPrice:"",AudioRatio:"",AudioCompletionRatio:"",ExposeRatioEnabled:!1}),u=t.useRef(),[p,h]=t.useState(l),{t:y}=ge(),[j,f]=t.useState(!1);return t.useEffect(()=>{const t={};for(let n in l)t[n]="ExposeRatioEnabled"===n?void 0!==e.options[n]&&e.options[n]:void 0!==e.options[n]?e.options[n]:"";r(t),h(structuredClone(t)),u.current.setValues(t)},[e.options]),n.jsxs(m,{spinning:i,children:[n.jsxs(a,{values:l,getFormApi:e=>u.current=e,style:{marginBottom:15}
1,children:[n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("模ååºå®ä»·æ ¼"),extraText:y("䏿¬¡è°ç¨æ¶èå¤å°åï¼ä¼å
çº§å¤§äºæ¨¡ååç"),placeholder:y('为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºæ¨¡ååç§°ï¼å¼ä¸ºä¸æ¬¡è°ç¨æ¶èå¤å°åï¼æ¯å¦ "gpt-4-gizmo-*": 0.1ï¼ä¸æ¬¡æ¶è0.1å'),field:"ModelPrice",autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,ModelPrice:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("模ååç"),placeholder:y("为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºæ¨¡ååç§°ï¼å¼ä¸ºåç"),field:"ModelRatio",autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,ModelRatio:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("æç¤ºç¼ååç"),placeholder:y("为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºæ¨¡ååç§°ï¼å¼ä¸ºåç"),field:"CacheRatio",autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,CacheRatio:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("æå¡å±çº§åçï¼service_tierï¼"),extraText:y('é®ä¸º service_tier å±çº§åï¼å¦ priorityãflexï¼ï¼å¼ä¸ºè®¡è´¹åçãä»
彿¸ éå¼å¯ãå
许 service_tier éä¼ ãä¸è¯·æ±å¸¦è¯¥å段æ¶çæï¼æªé
ç½®çå±çº§æ 1.0 计费ãä¾å¦ {"priority": 2, "flex": 0.5}'),placeholder:y('为ä¸ä¸ª JSON ææ¬ï¼é®ä¸º service_tier å±çº§åï¼å¼ä¸ºåçï¼å¦ {"priority": 2, "flex": 0.5}'),field:"ServiceTierRatio",autosize:{minRows:4,maxRows:10},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>!t||""===t.trim()||Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,ServiceTierRatio:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("ç¼ååå
¥åçï¼5åéï¼"),extraText:y("Claude 5åéç¼ååå
¥åçï¼ç空å使ç¨é»è®¤å¼ï¼é常为 1.25ï¼"),placeholder:y('为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºæ¨¡ååç§°ï¼å¼ä¸ºåçï¼å¦ {"claude-sonnet-4-20250514": 1.25}'),field:"CacheCreation5mRatio",autosize:{minRows:4,maxRows:10},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>!t||""===t.trim()||Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,CacheCreation5mRatio:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("ç¼ååå
¥åçï¼1å°æ¶ï¼"),extraText:y("Claude 1å°æ¶ç¼ååå
¥åçï¼ç空å使ç¨é»è®¤å¼ï¼é常为 2.0ï¼å³ 5m åç à 1.6ï¼"),placeholder:y('为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºæ¨¡ååç§°ï¼å¼ä¸ºåçï¼å¦ {"claude-sonnet-4-20250514": 2.0}'),field:"CacheCreation1hRatio",autosize:{minRows:4,maxRows:10},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>!t||""===t.trim()||Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,CacheCreation1hRatio:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("模åè¡¥å
¨åçï¼ä»
对èªå®ä¹æ¨¡åææï¼"),extraText:y("ä»
对èªå®ä¹æ¨¡åææ"),placeholder:y("为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºæ¨¡ååç§°ï¼å¼ä¸ºåç"),field:"CompletionRatio",autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,CompletionRatio:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:n.jsxs("span",{children:[y("模åé¶æ¢¯è®¡è´¹åç"),n.jsx(d,{size:"small",type:"tertiary",onClick:()=>{try{const e={"doubao-seed-1.6-vision":[{step_size:32e3,completion_step_size:-1,prompt_step_ratio:1,completion_step_ratio:1,prompt_thinking_step_ratio:4,completion_thinking_step_ratio:4},{step_size:128e3,completion_step_size:-1,prompt_step_ratio:1.5,completion_step_ratio:2,prompt_thinking_step_ratio:6,completion_thinking_step_ratio:8},{step_size:256e3,completion_step_size:-1,prompt_step_ratio:3,completion_step_ratio:3,prompt_thinking_step_ratio:12,completion_thinking_step_ratio:12}],"doubao-seed-1.6":[{step_size:32e3,completion_step_size:200,prompt_step_ratio:1,completion_step_ratio:1,prompt_thinking_step_ratio:4,completion_thinking_step_ratio:4},{step_size:32e3,completion_step_size:-1,prompt_step_ratio:1,completion_step_ratio:4,prompt_thinking_step_ratio:4,completion_thinking_step_ratio:16},{step_size:128e3,completion_step_size:-1,prompt_step_ratio:1.5,completion_step_ratio:2,prompt_thinking_step_ratio:6,completion_thinking_step_ratio:8},{step_size:256e3,completion_step_size:-1,prompt_step_ratio:3,completion_step_ratio:3,prompt_thinking_step_ratio:12,completion_thinking_step_ratio:12}],"qwen-plus-2025-12-01":[{step_size:12e3,completion_step_size:-1,prompt_step_ratio:.4,completion_step_ratio:2.5,prompt_thinking_step_ratio:.8,completion_thinking_step_ratio:5},{step_size:25e3,completion_step_size:-1,prompt_step_ratio:1.2,completion_step_ratio:8.33,prompt_thinking_step_ratio:2.4,completion_thinking_step_ratio:16.66},{step_size:1e5,completion_step_size:-1,prompt_step_ratio:2.4,completion_step_ratio:11,prompt_thinking_step_ratio:4.8,completion_thinking_step_ratio:22}],"doubao-seed-1.6-lite":[{step_size:32e3,completion_step_size:200,prompt_step_ratio:1,completion_step_ratio:1},{step_size:32e3,completion_step_size:-1,prompt_step_ratio:1,completion_step_ratio:4},{step_size:128e3,completion_step_size:-1,prompt_step_ratio:2,completion_step_ratio:6.667},{step_size:256e3,completion_step_size:-1,prompt_step_ratio:4,completion_step_ratio:20}],"doubao-seed-1.6-flash":[{step_size:32e3,completion_step_size:-1,prompt_step_ratio:1,completion_step_ratio:1},{step_size:128e3,completion_step_size:-1,prompt_step_ratio:2,completion_step_ratio:2},{step_size:256e3,completion_step_size:-1,prompt_step_ratio:4,completion_step_ratio:4}]},t=JSON.stringify(e,null,2),n={...l,ModelStepRatio:t};r(n),u.current&&u.current.setValues(n),be(y("已填å
¥æ¨¡æ¿ï¼å¯æ ¹æ®éè¦ä¿®æ¹"))}catch(e){console.error("å¡«å
¥æ¨¡æ¿å¤±è´¥:",e),je(y("å¡«å
¥æ¨¡æ¿å¤±è´¥ï¼è¯·ç¨åéè¯"))}},style:{marginLeft:"10px"},children:y("å¡«å
¥æ¨¡æ¿")})]}),extraText:y("æ ¹æ®token使ç¨éåæ®µè®¾ç½®æº¢ä»·åçï¼ä½ä¸ºç¬ç«ç乿°å ååºç¨äºé
é¢è®¡ç®"),placeholder:y("ratio_hint_001"),field:"ModelStepRatio",autosize:{minRows:10,maxRows:20},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>
1{if(!t||""===t.trim())return!0;if(!Re(t))return!1;try{const e=JSON.parse(t);for(const t in e){const n=e[t];if(!Array.isArray(n))throw new Error(`模å ${t} çé
ç½®å¿
é¡»æ¯æ°ç»`);for(let e=0;e<n.length;e++){const i=n[e];if("number"!=typeof i.step_size)throw new Error(`模å ${t} 第 ${e+1} ä¸ªåæ®µç step_size å¿
é¡»æ¯æ°å`);if(void 0!==i.completion_step_size&&"number"!=typeof i.completion_step_size)throw new Error(`模å ${t} 第 ${e+1} ä¸ªåæ®µç completion_step_size å¿
é¡»æ¯æ°å`);if(void 0!==i.prompt_step_ratio&&("number"!=typeof i.prompt_step_ratio||i.prompt_step_ratio<=0))throw new Error(`模å ${t} 第 ${e+1} ä¸ªåæ®µç prompt_step_ratio å¿
é¡»æ¯æ£æ°`);if(void 0!==i.completion_step_ratio&&("number"!=typeof i.completion_step_ratio||i.completion_step_ratio<=0))throw new Error(`模å ${t} 第 ${e+1} ä¸ªåæ®µç completion_step_ratio å¿
é¡»æ¯æ£æ°`);if(void 0!==i.prompt_thinking_step_ratio&&("number"!=typeof i.prompt_thinking_step_ratio||i.prompt_thinking_step_ratio<0))throw new Error(`模å ${t} 第 ${e+1} ä¸ªåæ®µç prompt_thinking_step_ratio å¿
é¡»æ¯éè´æ°`);if(void 0!==i.completion_thinking_step_ratio&&("number"!=typeof i.completion_thinking_step_ratio||i.completion_thinking_step_ratio<0))throw new Error(`模å ${t} 第 ${e+1} ä¸ªåæ®µç completion_thinking_step_ratio å¿
é¡»æ¯éè´æ°`)}}return!0}catch(n){return console.error("JSON validation error:",n),!1}},message:y("JSONæ ¼å¼éè¯¯ææ°æ®ç»æä¸æ£ç¡®")}],onChange:e=>r({...l,ModelStepRatio:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(d,{onClick:()=>f(!0),type:"tertiary",style:{marginTop:"10px",marginBottom:"10px"},children:y("æ¥çé
置说æ")})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("åç´ ä»·æ ¼"),extraText:y("æç¾ä¸åç´ è®¡è´¹ï¼éç¨äºå¾ççææ¨¡å"),placeholder:y('为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºæ¨¡ååç§°ï¼å¼ä¸ºæ¯ç¾ä¸åç´ çä»·æ ¼ï¼ç¾å
ï¼ï¼å¦ {"fal-ai/flux-krea-lora/stream": 0.035}'),field:"ModelPixelPrice",autosize:{minRows:4,maxRows:10},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>!t||""===t.trim()||Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,ModelPixelPrice:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("è§é¢Tokenä»·æ ¼"),extraText:y("æç¾ä¸Token计费ï¼éç¨äºè§é¢çææ¨¡å"),placeholder:y("为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºæ¨¡ååç§°ï¼å¼ä¸ºæ¯ç¾ä¸Tokençä»·æ ¼ï¼ç¾å
ï¼"),field:"ModelVideoTokenPrice",autosize:{minRows:4,maxRows:10},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>!t||""===t.trim()||Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,ModelVideoTokenPrice:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("è§é¢æ¶é¿ä»·æ ¼(æ é³é¢)"),extraText:y("æç§è®¡è´¹ï¼éç¨äºè§é¢çææ¨¡åï¼ä¸å
å«é³é¢çä»·æ ¼"),placeholder:y("ratio_hint_003"),field:"ModelVideoDurationPrice",autosize:{minRows:4,maxRows:10},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>!t||""===t.trim()||Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,ModelVideoDurationPrice:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("è§é¢æ¶é¿ä»·æ ¼(å«é³é¢)"),extraText:y("æç§è®¡è´¹ï¼éç¨äºå¸¦é³é¢çè§é¢çææ¨¡å"),placeholder:y("ratio_hint_004"),field:"ModelVideoDurationAudioPrice",autosize:{minRows:4,maxRows:10},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>!t||""===t.trim()||Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,ModelVideoDurationAudioPrice:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("é³é¢åç"),extraText:y("é³é¢è¾å
¥çåçï¼éç¨äºå®æ¶é³é¢æ¨¡å"),placeholder:y("ratio_hint_002"),field:"AudioRatio",autosize:{minRows:4,maxRows:10},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>!t||""===t.trim()||Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,AudioRatio:e})})})}
1),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:16,children:n.jsx(a.TextArea,{label:y("é³é¢è¡¥å
¨åç"),extraText:y("é³é¢è¾åºçè¡¥å
¨åçï¼éç¨äºå®æ¶é³é¢æ¨¡å"),placeholder:y('为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºæ¨¡ååç§°ï¼å¼ä¸ºåçï¼å¦ {"gpt-4o-realtime": 2, "gpt-4o-mini-realtime": 2}'),field:"AudioCompletionRatio",autosize:{minRows:4,maxRows:10},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>!t||""===t.trim()||Re(t),message:"䏿¯åæ³ç JSON å符串"}],onChange:e=>r({...l,AudioCompletionRatio:e})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{span:16,children:n.jsx(a.Switch,{label:y("æ´é²åçæ¥å£"),field:"ExposeRatioEnabled",onChange:e=>r({...l,ExposeRatioEnabled:e})})})})]}),n.jsxs(g,{children:[n.jsx(d,{onClick:async function(){try{await u.current.validate().then(()=>{const t=ke(l,p);if(!t.length)return ve(y("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=Ee()?"/api/option/":"/api/option/admin",i=t.map(e=>{const t="boolean"==typeof l[e.key]?String(l[e.key]):l[e.key];return ye.put(n,{key:e.key,value:t})});s(!0),Promise.all(i).then(t=>{if(t.includes(void 0))return je(i.length>1?y("é¨åä¿å失败ï¼è¯·éè¯"):y("ä¿å失败"));for(let e=0;e<t.length;e++)if(!t[e].data.success)return je(t[e].data.message);be(y("ä¿åæå")),e.refresh()}).catch(e=>{console.error("Unexpected error:",e),je(y("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{s(!1)})}).catch(()=>{je(y("è¯·æ£æ¥è¾å
¥"))})}catch(t){je(y("è¯·æ£æ¥è¾å
¥")),console.error(t)}},children:y("ä¿å模ååç设置")}),n.jsx(O,{title:y("ç¡®å®é置模ååçåï¼"),content:y("æ¤ä¿®æ¹å°ä¸å¯é"),okType:"danger",position:"top",onConfirm:async function(){try{const t=Ee()?"/api/option/rest_model_ratio":"/api/option/admin/rest_model_ratio";let n=await ye.post(t);n.data.success?(be(n.data.message),e.refresh()):je(n.data.message)}catch(t){je(t)}},children:n.jsx(d,{type:"danger",children:y("é置模ååç")})})]}),n.jsx(x,{title:y("é¶æ¢¯è®¡è´¹é
置说æ"),visible:j,onCancel:()=>f(!1),footer:n.jsx(d,{onClick:()=>f(!1),children:y("å
³é")}),width:800,bodyStyle:{maxHeight:"70vh",overflow:"auto"},children:n.jsxs("div",{style:{padding:"10px"},children:[n.jsx("h3",{children:y("åæ®µè¯´æ")}),n.jsxs("ul",{style:{paddingLeft:"20px",lineHeight:"1.8"},children:[n.jsxs("li",{children:[n.jsx("strong",{children:"step_size"}),": ",y("è¾å
¥tokenä¸éï¼å½å请æ±è¾å
¥tokenâ¤æ¤å¼æ¶ä½¿ç¨æ¤å段ï¼")]}),n.jsxs("li",{children:[n.jsx("strong",{children:"completion_step_size"}),": ",y("è¾åºtokenä¸éï¼å¯éï¼å½è®¾ç½®åéåæ¶æ»¡è¶³è¾å
¥åè¾åºæ¡ä»¶ï¼")]}),n.jsxs("li",{children:[n.jsx("strong",{children:"prompt_step_ratio"}),": ",y("è¾å
¥æº¢ä»·åçï¼éæè模å¼ï¼ï¼ä½ä¸ºç¬ç«ç乿°å ååºç¨")]}),n.jsxs("li",{children:[n.jsx("strong",{children:"completion_step_ratio"}),": ",y("è¾åºæº¢ä»·åçï¼éæè模å¼ï¼ï¼ä½ä¸ºç¬ç«ç乿°å ååºç¨")]}),n.jsxs("li",{children:[n.jsx("strong",{children:"prompt_thinking_step_ratio"}),": ",y("è¾å
¥æº¢ä»·åçï¼æèæ¨¡å¼ï¼å¯éï¼0æä¸å¡«è¡¨ç¤ºä¸å¯ç¨ï¼")]}),n.jsxs("li",{children:[n.jsx("strong",{children:"completion_thinking_step_ratio"}),": ",y("è¾åºæº¢ä»·åçï¼æèæ¨¡å¼ï¼å¯éï¼0æä¸å¡«è¡¨ç¤ºä¸å¯ç¨ï¼")]})]}),n.jsx("h3",{children:y("计费è§å")}),n.jsxs("ul",{style:{paddingLeft:"20px",lineHeight:"1.8"},children:[n.jsx("li",{children:y("åæ®µæstep_sizeä»å°å°å¤§æåºï¼ç³»ç»æ ¹æ®å®é
token使ç¨éèªå¨éæ©å段")}),n.jsx("li",{children:y("妿è¶
è¿æå¤§åæ®µï¼åä½¿ç¨æåä¸ä¸ªåæ®µçæº¢ä»·åç")})]}),n.jsx("h3",{children:y("é
ç½®æ¡ä¾")}),n.jsxs("div",{style:{padding:"15px",background:"#f8f9fa",borderRadius:"4px",marginBottom:"15px"},children:[n.jsx("h4",{style:{marginTop:0},children:y("æ¡ä¾1ï¼ä»
夿è¾å
¥ï¼")}),n.jsx("p",{style:{marginBottom:"8px"},children:n.jsx("strong",{children:"doubao-seed-1.6-vision"})}),n.jsxs("p",{style:{marginBottom:"5px"},children:[y("åºç¡ä»·æ ¼ï¼â¤32kï¼"),": è¾å
¥ 0.8å
/M tokensï¼è¾åº 8å
/M tokens"]}),n.jsx("p",{style:{marginBottom:"5px"},children:"32k-128k: è¾å
¥ 1.2å
ï¼è¾åº 16å
â prompt_step_ratio=1.5, completion_step_ratio=2"}),n.jsx("p",{style:{marginBottom:"5px"},children:"128k-256k: è¾å
¥ 2.4å
ï¼è¾åº 24å
â prompt_step_ratio=3, completion_step_ratio=3"})]}),n.jsxs("div",{style:{padding:"15px",background:"#fff3cd",borderRadius:"4px",marginBottom:"15px"},children:[n.jsx("h4",{style:{marginTop:0},children:y("æ¡ä¾2ï¼è¾å
¥è¾åºåé夿ï¼")}),n.jsx("p",{style:{marginBottom:"8px"},children:n.jsx("strong",{children:"doubao-seed-1.6-lite"})}),n.jsxs("p",{style:{marginBottom:"5px"},children:[y("åºç¡ä»·æ ¼ï¼è¾å
¥â¤32k ä¸ è¾åºâ¤0.2kï¼"),": è¾å
¥ 0.3å
/M tokensï¼è¾åº 0.6å
/M tokens"]}),n.jsxs("p",{style:{marginBottom:"5px"},children:[y("è¾å
¥â¤32k ä½ è¾åº>0.2k"),": è¾å
¥ 0.3å
ï¼è¾åº 2.4å
â completion_step_ratio=4"]}),n.jsxs("p",{style:{marginBottom:"5px",fontSize:"12px",color:"#666"},children:["ð¡ ",y("注æï¼è¿ééè¦è®¾ç½® completion_step_size=200ï¼0.2k tokensï¼æ¥åºåä¸¤ç§æ
åµ")]})]}),n.jsxs("div",{style:{padding:"15px",background:"#e7f3ff",borderRadius:"4px",border:"1px solid #b3d8ff"},children:[n.jsxs("h4",{style:{marginTop:0},children:["ð ",y("åèææ¡£")]}),n.jsx("p",{style:{marginBottom:0},children:n.jsxs("a",{href:"https://www.volcengine.com/docs/82379/1544106",target:"_blank",rel:"noopener noreferrer",style:{color:"#0066cc"},children:[y("ç«å±±å¼æè±å
模å宿¹å®ä»·")," â"]})})]})]})})]})}function Di(e){const{t:i}=ge(),s=ze(),[l,p]=t.useState([]),[m,y]=t.useState(!1),[f,b]=t.useState(null),[_,S]=t.useState(""),[C,w]=t.useState(1),[T,I]=t.useState(!1),[R,P]=t.useState("per-token"),[z,N]=t.useState("ratio"),[A,M]=t.useState(!1),[O,F]=t.useState(!1),[W,J]=t.useState(!1),U=t.useRef(null),V=s?5:10;Ne(),t.useEffect(()=>{try{const t=JSON.parse(e.options.ModelPrice||"{}"),n=JSON.parse(e.options.ModelRatio||"{}"),i=JSON.parse(e.options.CompletionRatio||"{}"),s=JSON.parse(e.options.ModelPixelPrice||"{}"),l=JSON.parse(e.options.ModelVideoTokenPrice||"{}"),a=JSON.parse(e.options.ModelVideoDurationPrice||"{}"),r=JSON.parse(e.options.CompletionRatioMeta||"{}"),o=JSON.parse(e.options.AudioRatio||"{}"),c=JSON.parse(e.options.AudioCompletionRatio||"{}"),d=JSON.parse(e.options.ImageRatio||"{}"),u=new Set([...Object.keys(t),...Object.keys(n),...Object.keys(i),...Object.keys(s),...Object.keys(l),...Object.keys(a),...Object.keys(o),...Object.keys(c),...Object.keys(d)]),h=Array.from(u).map(e=>
1{const u=void 0===t[e]?"":t[e],p=void 0===n[e]?"":n[e],h=void 0===i[e]?"":i[e],x=void 0===s[e]?"":s[e],m=void 0===l[e]?"":l[e],g=void 0===a[e]?"":a[e],y=r[e]||{},j=void 0===o[e]?"":o[e],f=void 0===c[e]?"":c[e];let b=""!==j?String(j):"",_=""!==f?String(f):"";const S=void 0===d[e]?"":d[e];return{name:e,price:u,ratio:p,completionRatio:h,pixelPrice:x,videoPrice:m,videoDurationPrice:g,audioRatio:b,audioCompletionRatio:_,imageRatio:""!==S?String(S):"",completionRatioLocked:!0===y.locked,lockedCompletionRatio:void 0!==y.ratio?y.ratio:"",hasConflict:(""!==u?1:0)+(""!==p||""!==h?1:0)+(""!==x?1:0)+(""!==m?1:0)+(""!==g?1:0)>1}});p(h)}catch(t){console.error("JSONè§£æé误:",t)}},[e.options]);const K=l.filter(e=>{const t=!_||e.name.toLowerCase().includes(_.toLowerCase()),n=!A||e.hasConflict;return t&&n}),G=((e,t,n)=>{const i=(t-1)*n,s=i+n;return e.slice(i,s)})(K,C,V),q=[{title:i("模ååç§°"),dataIndex:"name",key:"name",width:s?120:200,render:(e,t)=>{let s="",l="blue";return"doubao-seedance-2-0-260128"===t.name||"doubao-seedance-2-0-fast-260128"===t.name?(s=i("æé计费"),l="blue"):""!==t.pixelPrice?(s=i("æåç´ è®¡è´¹"),l="orange"):""!==t.videoPrice?(s=i("æè§é¢å°ºå¯¸è®¡è´¹"),l="green"):""!==t.videoDurationPrice?(s=i("æè§é¢æ¶é¿è®¡è´¹"),l="purple"):""!==t.price?(s=i("ææ¬¡è®¡è´¹"),l="purple"):""===t.ratio&&""===t.completionRatio||(s=i("æé计费"),l="blue"),n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-sm font-medium",children:e}),n.jsxs("div",{className:"flex flex-wrap gap-1",children:[s&&n.jsx(j,{color:l,size:"small",children:s}),t.hasConflict&&n.jsx(j,{color:"red",shape:"circle",size:"small",children:i("çç¾")})]})]})}},{title:i("模ååºå®ä»·æ ¼"),dataIndex:"price",key:"price",width:s?100:150,render:(e,t)=>n.jsx(k,{value:e,placeholder:i("ææ¬¡è®¡è´¹"),size:s?"small":"default",onChange:e=>$(t.name,"price",e)})},{title:i("åç´ ä»·æ ¼"),dataIndex:"pixelPrice",key:"pixelPrice",width:s?100:150,render:(e,t)=>n.jsx(k,{value:e,placeholder:i(s?"$/1M":"æåç´ è®¡è´¹($/1M pixels)"),size:s?"small":"default",onChange:e=>$(t.name,"pixelPrice",e)})},{title:i("è§é¢å°ºå¯¸ä»·æ ¼"),dataIndex:"videoPrice",key:"videoPrice",width:s?100:150,render:(e,t)=>n.jsx(k,{value:e,placeholder:i(s?"$/1M":"æè§é¢å°ºå¯¸è®¡è´¹($/1M tokens)"),size:s?"small":"default",onChange:e=>$(t.name,"videoPrice",e)})},{title:i("è§é¢æ¶é¿ä»·æ ¼"),dataIndex:"videoDurationPrice",key:"videoDurationPrice",width:s?100:150,render:(e,t)=>n.jsx(k,{value:e,placeholder:i(s?"æç§":"æè§é¢æ¶é¿è®¡è´¹(æç§)"),size:s?"small":"default",onChange:e=>$(t.name,"videoDurationPrice",e)})},{title:i("模ååç"),dataIndex:"ratio",key:"ratio",width:s?100:150,render:(e,t)=>n.jsx(k,{value:e,placeholder:""!==t.price||""!==t.pixelPrice||""!==t.videoPrice||""!==t.videoDurationPrice?i("模ååç"):i("é»è®¤è¡¥å
¨åç"),disabled:""!==t.price||""!==t.pixelPrice||""!==t.videoPrice||""!==t.videoDurationPrice,size:s?"small":"default",onChange:e=>$(t.name,"ratio",e)})},{title:i("è¡¥å
¨åç"),dataIndex:"completionRatio",key:"completionRatio",width:s?100:150,render:(e,t)=>n.jsx("div",{children:n.jsx(k,{value:t.completionRatioLocked?String(t.lockedCompletionRatio):e,placeholder:""!==t.price||""!==t.pixelPrice||""!==t.videoPrice||""!==t.videoDurationPrice?i("è¡¥å
¨åç"):i("é»è®¤è¡¥å
¨åç"),disabled:t.completionRatioLocked||""!==t.price||""!==t.pixelPrice||""!==t.videoPrice||""!==t.videoDurationPrice,size:s?"small":"default",addonAfter:t.completionRatioLocked?n.jsx(j,{size:"small",color:"orange",children:i("éå®")}):null,onChange:e=>$(t.name,"completionRatio",e)})})},{title:i("é³é¢è¾å
¥ä»·æ ¼"),dataIndex:"audioRatio",key:"audioRatio",width:s?100:150,render:(e,t)=>n.jsx(k,{value:e,placeholder:i("é³é¢è¾å
¥ä»·æ ¼"),size:s?"small":"default",onChange:e=>$(t.name,"audioRatio",e)})},{title:i("é³é¢è¡¥å
¨ä»·æ ¼"),dataIndex:"audioCompletionRatio",key:"audioCompletionRatio",width:s?100:150,render:(e,t)=>n.jsx(k,{value:e,placeholder:i("é³é¢è¡¥å
¨ä»·æ ¼"),size:s?"small":"default",onChange:e=>$(t.name,"audioCompletionRatio",e)})},{title:i("æä½"),key:"action",width:s?80:120,render:(e,t)=>n.jsxs(g,{size:14,children:[n.jsx(d,{type:"primary",icon:n.jsx(at,{size:16}),size:s?"small":"default",onClick:()=>Y(t)}),n.jsx(d,{icon:n.jsx(He,{size:16}),type:"danger",size:s?"small":"default",onClick:()=>H(t.name)})]})}],$=(e,t,n)=>{isNaN(n)?je(i("请è¾å
¥æ°å")):p(i=>i.map(i=>{if(i.name!==e)return i;const s={...i,[t]:n};return s.hasConflict=(""!==s.price?1:0)+(""!==s.ratio||""!==s.completionRatio?1:0)+(""!==s.pixelPrice?1:0)+(""!==s.videoPrice?1:0)+(""!==s.videoDurationPrice?1:0)>1,s}))},H=e=>{p(t=>t.filter(t=>t.name!==e))},Q=e=>2*e,X=()=>
1{b(null),P("per-token"),N("ratio"),F(!1),J(!1),U.current&&U.current.reset()},Y=e=>{let t="per-token";t=""!==e.price?"per-request":""!==e.pixelPrice?"per-pixel":""!==e.videoPrice?"per-video":""!==e.videoDurationPrice?"per-video-duration":"per-token",P(t),N("ratio");const n={...e};e.ratio&&(n.tokenPrice=Q(parseFloat(e.ratio)).toString(),e.completionRatio&&(n.completionTokenPrice=(parseFloat(n.tokenPrice)*parseFloat(e.completionRatio)).toString()),e.imageRatio&&(n.imageInputPrice=(parseFloat(n.tokenPrice)*parseFloat(e.imageRatio)).toString())),b(n),F(""!==e.audioRatio&&void 0!==e.audioRatio),J(""!==e.audioCompletionRatio&&void 0!==e.audioCompletionRatio),y(!0),setTimeout(()=>{if(U.current){const e={name:n.name};"per-request"===t?e.priceInput=n.price:"per-pixel"===t?e.pixelPriceInput=n.pixelPrice:"per-video"===t?e.videoPriceInput=n.videoPrice:"per-video-duration"===t?e.videoDurationPriceInput=n.videoDurationPrice:"per-token"===t&&(e.ratioInput=n.ratio,e.completionRatioInput=n.completionRatio,e.modelTokenPrice=n.tokenPrice,e.completionTokenPrice=n.completionTokenPrice,e.imageRatioInput=n.imageRatio||"",e.imageInputPrice=n.imageInputPrice||""),e.audioRatioInput=n.audioRatio||"",e.audioCompletionRatioInput=n.audioCompletionRatio||"",U.current.setValues(e)}},0)};return n.jsxs(n.Fragment,{children:[n.jsxs(g,{vertical:!0,align:"start",style:{width:"100%"},children:[n.jsxs("div",{className:(s?"space-y-2":"flex items-center gap-3")+" w-full",children:[n.jsxs("div",{className:s?"flex flex-wrap gap-2":"flex gap-3",children:[n.jsx(d,{icon:n.jsx(Ye,{size:16}),size:s?"small":"default",onClick:()=>{X(),y(!0)},children:i("æ·»å æ¨¡å")}),n.jsx(d,{type:"primary",icon:n.jsx(Ze,{size:16}),size:s?"small":"default",loading:T,onClick:async()=>{I(!0);const t={ModelPrice:{},ModelRatio:{},CompletionRatio:{},ModelPixelPrice:{},ModelVideoTokenPrice:{},ModelVideoDurationPrice:{},AudioRatio:{},AudioCompletionRatio:{},ImageRatio:{}};let n="";try{l.forEach(e=>{if(n=e.name,""!==e.price)t.ModelPrice[e.name]=parseFloat(e.price);else if(""!==e.pixelPrice)t.ModelPixelPrice[e.name]=parseFloat(e.pixelPrice);else if(""!==e.videoPrice)t.ModelVideoTokenPrice[e.name]=parseFloat(e.videoPrice);else if(""!==e.videoDurationPrice)t.ModelVideoDurationPrice[e.name]=parseFloat(e.videoDurationPrice);else if(""!==e.ratio&&(t.ModelRatio[e.name]=parseFloat(e.ratio)),""!==e.completionRatio&&(t.CompletionRatio[e.name]=parseFloat(e.completionRatio)),""!==e.imageRatio&&void 0!==e.imageRatio){const n=parseFloat(e.imageRatio);!isNaN(n)&&n>0&&(t.ImageRatio[e.name]=n)}if(""!==e.audioRatio){const n=parseFloat(e.audioRatio);!isNaN(n)&&n>0&&(t.AudioRatio[e.name]=n)}if(""!==e.audioCompletionRatio){const n=parseFloat(e.audioCompletionRatio);!isNaN(n)&&n>0&&(t.AudioCompletionRatio[e.name]=n)}});const s={ModelPrice:JSON.stringify(t.ModelPrice,null,2),ModelRatio:JSON.stringify(t.ModelRatio,null,2),CompletionRatio:JSON.stringify(t.CompletionRatio,null,2),ModelPixelPrice:JSON.stringify(t.ModelPixelPrice,null,2),ModelVideoTokenPrice:JSON.stringify(t.ModelVideoTokenPrice,null,2),ModelVideoDurationPrice:JSON.stringify(t.ModelVideoDurationPrice,null,2),AudioRatio:JSON.stringify(t.AudioRatio,null,2),AudioCompletionRatio:JSON.stringify(t.AudioCompletionRatio,null,2),ImageRatio:JSON.stringify(t.ImageRatio,null,2)},a=Ee()?"/api/option/":"/api/option/admin",r=Object.entries(s).map(([e,t])=>ye.put(a,{key:e,value:t})),o=await Promise.all(r);if(1===r.length){if(o.includes(void 0))return}else if(r.length>1&&o.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));for(const e of o)if(!e.data.success)return je(e.data.message);be(i("ä¿åæå")),e.refresh()}catch(s){console.error("ä¿å失败:",s),je(i("ä¿å失败ï¼è¯·éè¯"))}finally{I(!1)}},children:i("åºç¨æ´æ¹")})]}),n.jsxs("div",{className:s?"flex flex-col gap-2":"flex items-center gap-3",children:[n.jsx(k,{prefix:n.jsx(st,{size:16}),placeholder:i("æç´¢æ¨¡ååç§°"),value:_,onChange:e=>{S(e),w(1)},style:{width:s?"100%":200},size:s?"small":"default",showClear:!0}),n.jsx(D,{checked:A,onChange:e=>{M(e.target.checked),w(1)},className:s?"text-sm":"",children:i("ä»
æ¾ç¤ºçç¾åç")})]})]}),s?n.jsxs("div",{className:"w-full",children:[G.length>0?n.jsx("div",{className:"space-y-3",children:G.map(e=>{let t="",s="blue";return""!==e.pixelPrice?(t=i("æåç´ è®¡è´¹"),s="orange"):""!==e.videoPrice?(t=i("æè
1§é¢å°ºå¯¸è®¡è´¹"),s="green"):""!==e.videoDurationPrice?(t=i("æè§é¢æ¶é¿è®¡è´¹"),s="purple"):""!==e.price?(t=i("ææ¬¡è®¡è´¹"),s="purple"):""===e.ratio&&""===e.completionRatio||(t=i("æé计费"),s="blue"),n.jsx(r,{className:"mb-3",bodyStyle:{padding:"12px"},children:n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center flex-wrap gap-2",children:[n.jsx(u.Text,{strong:!0,className:"text-sm",children:e.name}),t&&n.jsx(j,{color:s,size:"small",children:t}),e.hasConflict&&n.jsx(j,{color:"red",shape:"circle",children:i("çç¾")})]}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(d,{type:"primary",icon:n.jsx(at,{size:16}),size:"small",onClick:()=>Y(e)}),n.jsx(d,{icon:n.jsx(He,{size:16}),type:"danger",size:"small",onClick:()=>H(e.name)})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs(o,{gutter:[8,8],children:[n.jsx(c,{span:12,children:n.jsxs("div",{children:[n.jsx(u.Text,{className:"text-xs text-muted-foreground block mb-1",children:i("åºå®ä»·æ ¼")}),n.jsx(k,{value:e.price,placeholder:i("ææ¬¡è®¡è´¹"),size:"small",onChange:t=>$(e.name,"price",t)})]})}),n.jsx(c,{span:12,children:n.jsxs("div",{children:[n.jsx(u.Text,{className:"text-xs text-muted-foreground block mb-1",children:i("åç´ ä»·æ ¼")}),n.jsx(k,{value:e.pixelPrice,placeholder:i("$/1M pixels"),size:"small",onChange:t=>$(e.name,"pixelPrice",t)})]})})]}),n.jsxs(o,{gutter:[8,8],children:[n.jsx(c,{span:12,children:n.jsxs("div",{children:[n.jsx(u.Text,{className:"text-xs text-muted-foreground block mb-1",children:i("è§é¢å°ºå¯¸ä»·æ ¼")}),n.jsx(k,{value:e.videoPrice,placeholder:i("$/1M tokens"),size:"small",onChange:t=>$(e.name,"videoPrice",t)})]})}),n.jsx(c,{span:12,children:n.jsxs("div",{children:[n.jsx(u.Text,{className:"text-xs text-muted-foreground block mb-1",children:i("è§é¢æ¶é¿ä»·æ ¼")}),n.jsx(k,{value:e.videoDurationPrice,placeholder:i("æç§"),size:"small",onChange:t=>$(e.name,"videoDurationPrice",t)})]})})]}),n.jsxs(o,{gutter:[8,8],children:[n.jsx(c,{span:12,children:n.jsxs("div",{children:[n.jsx(u.Text,{className:"text-xs text-muted-foreground block mb-1",children:i("模ååç")}),n.jsx(k,{value:e.ratio,placeholder:""!==e.price||""!==e.pixelPrice||""!==e.videoPrice||""!==e.videoDurationPrice?i("模ååç"):i("é»è®¤è¡¥å
¨åç"),size:"small",disabled:""!==e.price||""!==e.pixelPrice||""!==e.videoPrice||""!==e.videoDurationPrice,onChange:t=>$(e.name,"ratio",t)})]})}),n.jsx(c,{span:12,children:n.jsxs("div",{children:[n.jsxs(u.Text,{className:"text-xs text-muted-foreground block mb-1",children:[i("è¡¥å
¨åç"),e.completionRatioLocked&&n.jsx(j,{size:"small",color:"orange",style:{marginLeft:4},children:i("å·²éå®")})]}),e.completionRatioLocked&&n.jsx(h,{type:"warning",bordered:!0,fullMode:!1,closeIcon:null,style:{marginBottom:6,padding:"4px 8px"},description:i("该模åè¡¥å
¨åçç±å端åºå®ä¸º {{ratio}}ï¼æ æ³ä¿®æ¹",{ratio:e.lockedCompletionRatio})}),n.jsx(k,{value:e.completionRatio,placeholder:""!==e.price||""!==e.pixelPrice||""!==e.videoPrice||""!==e.videoDurationPrice?i("è¡¥å
¨åç"):i("é»è®¤è¡¥å
¨åç"),size:"small",disabled:e.completionRatioLocked||""!==e.price||""!==e.pixelPrice||""!==e.videoPrice||""!==e.videoDurationPrice,onChange:t=>$(e.name,"completionRatio",t)})]})})]}),n.jsxs(o,{gutter:[8,8],children:[n.jsx(c,{span:12,children:n.jsxs("div",{children:[n.jsx(u.Text,{className:"text-xs text-muted-foreground block mb-1",children:i("é³é¢è¾å
¥ä»·æ ¼")}),n.jsx(k,{value:e.audioRatio,placeholder:i("é³é¢è¾å
¥ä»·æ ¼"),size:"small",onChange:t=>$(e.name,"audioRatio",t)})]})}),n.jsx(c,{span:12,children:n.jsxs("div",{children:[n.jsx(u.Text,{className:"text-xs text-muted-foreground block mb-1",children:i("é³é¢è¡¥å
¨ä»·æ ¼")}),n.jsx(k,{value:e.audioCompletionRatio,placeholder:i("é³é¢è¡¥å
¨ä»·æ ¼"),size:"small",onChange:t=>$(e.name,"audioCompletionRatio",t)})]})})]})]})]})},e.name)})}):n.jsx(r,{className:"text-center py-8",children:n.jsx(u.Text,{type:"tertiary",children:i("æ²¡ææ¾å°å¹é
çæ¨¡å")})}),K.length>V&&n.jsx("div",{className:"flex justify-center mt-4",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(d,{size:"small",disabled:1===C,onClick:()=>w(C-1),children:i("ä¸ä¸é¡µ")}),n.jsxs(u.Text,{className:"text-sm",children:[C," / ",Math.ceil(K.length/V)]}),n.jsx(d,{size:"small",disabled:C>=Math.ceil(K.length/V),onClick:()=>w(C+1),children:i("ä¸ä¸é¡µ")})]})})]}):n.jsx(v,{columns:q,dataSource:G,pagination:{currentPage:C,pageSize:V,total:K.length,onPageChange:e=>w(e),formatPageText:e=>i("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:K.length}),showTotal:!0,showSizeChanger:!1}})]}
1),n.jsx(x,{title:f&&f.name&&l.some(e=>e.name===f.name)?i("ç¼è¾æ¨¡å"):i("æ·»å æ¨¡å"),visible:m,onCancel:()=>{X(),y(!1)},onOk:()=>{if(f){const t={...f};if("per-token"===R&&"token-price"===z&&f.tokenPrice){const e=parseFloat(f.tokenPrice);if(t.ratio=(e/2).toString(),f.completionTokenPrice&&f.tokenPrice){const e=parseFloat(f.completionTokenPrice),n=parseFloat(f.tokenPrice);n>0&&(t.completionRatio=(e/n).toString())}if(f.imageInputPrice&&f.tokenPrice){const e=parseFloat(f.imageInputPrice),n=parseFloat(f.tokenPrice);n>0&&(t.imageRatio=String(parseFloat((e/n).toFixed(6))))}}"per-token"===R?(t.price="",t.pixelPrice="",t.videoPrice="",t.videoDurationPrice=""):"per-request"===R?(t.ratio="",t.completionRatio="",t.imageRatio="",t.pixelPrice="",t.videoPrice="",t.videoDurationPrice=""):"per-pixel"===R?(t.price="",t.ratio="",t.completionRatio="",t.imageRatio="",t.videoPrice="",t.videoDurationPrice=""):"per-video"===R?(t.price="",t.ratio="",t.completionRatio="",t.imageRatio="",t.pixelPrice="",t.videoDurationPrice=""):"per-video-duration"===R&&(t.price="",t.ratio="",t.completionRatio="",t.imageRatio="",t.pixelPrice="",t.videoPrice=""),e=t,p(t=>{const n=t.findIndex(t=>t.name===e.name);if(n>=0){const i=[...t];return i[n]={...e},i}return[...t,{...e}]}),y(!1),X()}var e},width:s?"95%":600,style:s?{top:20}:{},children:n.jsxs(a,{getFormApi:e=>U.current=e,children:[n.jsx(a.Input,{field:"name",label:i("模ååç§°"),placeholder:"strawberry",required:!0,disabled:f&&f.name&&l.some(e=>e.name===f.name),onChange:e=>b(t=>({...t,name:e}))}),n.jsx(a.Section,{text:i("å®ä»·æ¨¡å¼"),children:n.jsx("div",{style:{marginBottom:"16px"},children:n.jsxs(L,{type:"button",value:R,direction:s?"vertical":"horizontal",onChange:e=>{const t=e.target.value;if(P(t),f){const e={...f};if(U.current){const n={name:e.name};"per-request"===t?n.priceInput=e.price||"":"per-pixel"===t?n.pixelPriceInput=e.pixelPrice||"":"per-video"===t?n.videoPriceInput=e.videoPrice||"":"per-video-duration"===t?n.videoDurationPriceInput=e.videoDurationPrice||"":"per-token"===t&&(n.ratioInput=e.ratio||"",n.completionRatioInput=e.completionRatio||"",n.modelTokenPrice=e.tokenPrice||"",n.completionTokenPrice=e.completionTokenPrice||""),n.audioRatioInput=e.audioRatio||"",n.audioCompletionRatioInput=e.audioCompletionRatio||"",U.current.setValues(n)}b(e)}},children:[n.jsx(B,{value:"per-token",children:i("æé计费")}),n.jsx(B,{value:"per-request",children:i("ææ¬¡è®¡è´¹")}),n.jsx(B,{value:"per-pixel",children:i("æåç´ è®¡è´¹")}),n.jsx(B,{value:"per-video",children:i("æè§é¢å°ºå¯¸è®¡è´¹")}),n.jsx(B,{value:"per-video-duration",children:i("æè§é¢æ¶é¿è®¡è´¹")})]})})}),"per-token"===R&&n.jsxs(n.Fragment,{children:[n.jsx(a.Section,{text:i("ä»·æ ¼è®¾ç½®æ¹å¼"),children:n.jsx("div",{style:{marginBottom:"16px"},children:n.jsxs(L,{type:"button",value:z,direction:s?"vertical":"horizontal",onChange:e=>{const t=e.target.value,n=z;if(N(t),f){const e={...f};if("ratio"===n&&"token-price"===t&&e.ratio&&(e.tokenPrice=Q(parseFloat(e.ratio)).toString(),e.completionRatio&&(e.completionTokenPrice=(parseFloat(e.tokenPrice)*parseFloat(e.completionRatio)).toString()),e.imageRatio&&(e.imageInputPrice=(parseFloat(e.tokenPrice)*parseFloat(e.imageRatio)).toString())),U.current){const n={};"ratio"===t?(n.ratioInput=e.ratio||"",n.completionRatioInput=e.completionRatio||"",n.imageRatioInput=e.imageRatio||""):"token-price"===t&&(n.modelTokenPrice=e.tokenPrice||"",n.completionTokenPrice=e.completionTokenPrice||"",n.imageInputPrice=e.imageInputPrice||""),n.audioRatioInput=e.audioRatio||"",n.audioCompletionRatioInput=e.audioCompletionRatio||"",U.current.setValues(n)}b(e)}},children:[n.jsx(B,{value:"ratio",children:i("æåç设置")}),n.jsx(B,{value:"token-price",children:i("æä»·æ ¼è®¾ç½®")})]})})}),"ratio"===z&&n.jsxs(n.Fragment,{children:[n.jsx(a.Input,{field:"ratioInput",label:i("模ååç"),placeholder:i("è¾å
¥æ¨¡ååç"),onChange:e=>b(t=>({...t||{},ratio:e})),initValue:f?.ratio||""}),n.jsx(a.Input,{field:"completionRatioInput",label:i("è¡¥å
¨åç"),placeholder:i("è¾å
¥è¡¥å
¨åç"),onChange:e=>b(t=>({...t||{},completionRatio:e})),initValue:f?.completionRatio||""}),n.jsx(a.Input,{field:"imageRatioInput",label:i("å¾çè¾å
¥åç"),placeholder:i("å¾çè¾å
¥ token ç¸å¯¹ææ¬è¾å
¥ä»·çåçï¼å¦ 1.6"),onChange:e=>b(t=>({...t||{},imageRatio:e})),initValue:f?.imageRatio||""})]}),"token-price"===z&&n.jsxs(n.Fragment,{children:[n.jsx(a.Input,{field:"modelTokenPrice",label:i("è¾å
¥ä»·æ ¼"),onChange:e=>{(e=>{let t={...f||{},tokenPrice:e,ratio:0};if(!isNaN(e)&&""!==e){const n=parseFloat(e)/2;t.ratio=n}b(t)})(e)},initValue:f?.tokenPrice||"",suffix:i("$/1M tokens")}),n.jsx(a.Input,{field:"completionTokenPrice",label:i("è¾åºä»·æ ¼"),onChange:e=>{(e=>{let t={...f||{},completionTokenPrice:e,completionRatio:0};if(!isNaN(e)&&""!==e&&f?.tokenPrice){const n=parseFloat(e),s=parseFloat(f.tokenPrice);if(s>0){const e=((e,t)=>e&&"0"!==e?t/e:(je(i("模åä»·æ ¼ä¸è½ä¸º0")),""))(s,n);t.completionRatio=e}}b(t)})(e)},initValue:f?.completionTokenPrice||"",suffix:i("$/1M tokens")}),n.jsx(a.Input,{field:"imageInputPrice",label:i("å¾çè¾å
¥ä»·æ ¼"),onChange:e=>{(e=>{let t={...f||{},imageInputPrice:e,imageRatio:""};if(!isNaN(e)&&""!==e&&f?.tokenPrice){const n=parseFloat(e),i=parseFloat(f.tokenPrice);i>0&&(t.imageRatio=String(parseFloat((n/i).toFixed(6))))}b(t)})(e)},initValue:f?.imageInputPrice||"",suffix:i("$/1M tokens")})]})]}),"per-request"===R&&n.jsx(a.Input,{field:"priceInput",label:i("åºå®ä»·æ ¼(æ¯æ¬¡)"),placeholder:i("è¾å
¥æ¯æ¬¡ä»·æ ¼"),onChange:e=>b(t=>({...t||{},price:e})),initValue:f?.price||""}),"per-pixel"===R&&n.jsx(a.Input,{field:"pixelPriceInput",label:i("æ¯ç¾ä¸åç´ ä»·æ ¼"),placeholder:i("è¾å
¥æ¯ç¾ä¸åç´ ä»·æ ¼"),onChange:e=>b(t=>({...t||{},pixelPrice:e})),initValue:f?.pixelPrice||"",suffix:i("$/1M pixels")}),"per-video"===R&&n.jsx(a.Input,{field:"videoPriceInput",label:i("è§é¢å°ºå¯¸ä»·æ ¼"),placeholder:i("è¾å
¥è§é¢å°ºå¯¸ä»·æ ¼"),onChange:e=>b(t=>({...t||{},videoPrice:e})),initValue:f?.videoPrice||"",suffix:i("$/1M tokens")}),"per-video-duration"===R&&n.jsx(a.Input,{field:"videoDurationPriceInput",label:i("è§é¢æ¶é¿ä»·æ ¼"),placeholder:i("è¾å
¥è§é¢æ¶é¿ä»·æ ¼(æç§)"),onChange:e=>b(t=>({...t||{},videoDurationPrice:e})),initValue:f?.videoDurationPrice||"",suffix:i("$/ç§")}),n.jsxs(a.Section,{text:i("æ©å±ä»·æ ¼"),children:[n.jsx("div",{style:{marginBottom:"8px",color:"hsl(var(--muted-foreground))",fontSize:"13px"},children:i("è¿äºä»·æ ¼é½æ¯å¯é项ï¼ä¸å¡«ä¹å¯ä»¥ã")}),n.jsxs("div",{style:{marginBottom:"12px"},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"6px"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:i("é³é¢è¾å
¥ä»·æ ¼")}),!O&&n.jsx("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))"},children:i("å½åæªå¯ç¨ï¼éè¦æ¶åæå¼å³å¯ã")})]}),n.jsx(E,{checked:O,onChange:e=>{F(e),e||(b(e=>({...e||{},audioRatio:""})),U.current&&U.current.setValue("audioRatioInput",""))}})]}),O&&n.jsx(a.Input,{field:"audioRatioInput",noLabel:!0,placeholder:i("è¾å
¥é³é¢è¾å
¥ä»·æ ¼"),onChange:e=>b(t=>({...t||{},audioRatio:e})),initValue:f?.audioRatio||"",suffix:i("$/1M tokens")})]}),n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"6px"},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:i("é³é¢è¡¥å
¨ä»·æ ¼")}),!W&&n.jsx("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))"},children:i("å½åæªå¯ç¨ï¼éè¦æ¶åæå¼å³å¯ã")})]}),n.jsx(E,{checked:W,onChange:e=>{J(e),e||(b(e=>({...e||{},audioCompletionRatio:""})),U.current&&U.current.setValue("audioCompletionRatioInput",""))}})]}),W&&n.jsx(a.Input,{field:"audioCompletionRatioInput",noLabel:!0,placeholder:i("è¾å
¥é³é¢è¡¥å
¨ä»·æ ¼"),onChange:e=>b(t=>({...t||{},audioCompletionRatio:e})),initValue:f?.audioCompletionRatio||"",suffix:i("$/1M tokens")})]})]})]})})]})}function Li(e){const{t:i}=ge(),[s,l]=t.useState([]),[r,o]=t.useState(!1),[c,p]=t.useState(!1),[h,m]=t.useState(null),[y,j]=t.useState(""),[f,b]=t.useState(1),[_,S]=t.useState(10),[C,w]=t.useState(!1),[T,I]=t.useState([]),[E,R]=t.useState([]),[P,z]=t.useState("ratio"),[N,A]=t.useState(""),[M,O]=t.useState(""),[D,L]=t.useState(""),[W,J]=t.useState(""),[U,V]=t.useState(""),[K,G]=t.useState(""),[q,$]=t.useState(""),[H,Q]=t.useState(""),[X,Y]=t.useState(""),{Text:Z}=u,ee=async()=>{try{const e=await ye.get("/api/channel/models_enabled"),{success:t,message:n,data:i}=e.data;t?I(i):je(n)}catch(e){console.error(i("è·åå¯ç¨æ¨¡å失败")+":",e),je(i("è·åå¯ç¨æ¨¡å失败"))}};t.useEffect(()=>{ee()},[]),t.useEffect(()=>{try{const t=JSON.parse(e.options.ModelPrice||"{}"),n=JSON.parse(e.options.ModelRatio||"{}"),i=JSON.parse(e.options.CompletionRatio||"{}"),s=JSON.parse(e.options.ModelPixelPrice||"{}"),a=JSON.parse(e.options.ModelVideoTokenPrice||"{}"),r=JSON.parse(e.options.ModelVideoDurationPrice||"{}"),o=JSON.parse(e.options.ModelVideoDurationAudioPrice||"{}"),c=JSON.parse(e.options.AudioRatio||"{}"),d=JSON.parse(e.options.AudioCompletionRatio||"{}"),u=T.filter(e=>{const i=void 0!==t[e],l=void 0!==n[e],d=void 0!==s[e],u=void 0!==a[e],p=void 0!==r[e],h=void 0!==o[e],x=void 0!==c[e];return!(i||l||d||u||p||h||x)}).map(e=>({name:e,price:t[e]||"",ratio:n[e]||"",completionRatio:i[e]||"",pixelPrice:s[e]||"",videoTokenPrice:a[e]||"",videoDurationPrice:r[e]||"",videoDurationAudioPrice:o[e]||"",audioRatio:c[e]||"",audioCompletionRatio:d[e]||""}));l(u),R([])}catch(t){console.error(i("JSONè§£æé误:"),t)}},[e.options,T]);const te=s.filter(e=>!y||e.name.toLowerCase().includes(y.toLowerCase())),ne=((e,t,n)=>{const i=(t-1)*n,s=i+n;return e.slice(i,s)})(te,f,_),ie=[{title:i("模ååç§°"),dataIndex:"name",key:"name",fixed:"left",width:200},{title:i("åºå®ä»·æ ¼"),dataIndex:"price",key:"price",width:120,render:(e,t)=>n.jsx(k,{value:e,placeholder:i("ææ¬¡"),onChange:e=>se(t.name,"price",e)})},{title:i("模ååç"),dataIndex:"ratio",key:"ratio",width:120,render:(e,t)=>n.jsx(k,{value:e,placeholder:i("æé"),disabled:""!==t.price,onChange:e=>se(t.name,"ratio",e)})},{title:i("è¡¥å
¨åç"),dataIndex:"completionRatio",key:"completionRatio",width:120,render:(e,t)=>n.jsx(k,{value:e,placeholder:i("è¡¥å
¨"),disabled:""!==t.price,onChange:e=>se(t.name,"completionRatio",e)})},{title:i("åç´ ä»·æ ¼"),dataIndex:"pixelPrice",key:"pixelPrice",width:120,render:(e,t)=>n.jsx(k,{value:e,placeholder:i("æåç´ "),disabled:""!==t.price,onChange:e=>se(t.name,"pixelPrice",e)})},{title:i("è§é¢Tokenä»·æ ¼"),dataIndex:"videoTokenPrice",key:"videoTokenPrice",width:140,render:(e,t)=>n.jsx(k,{value:e,placeholder:i("æToken"),disabled:""!==t.price,onChange:e=>se(t.name,"videoTokenPrice",e)})},{title:i("ææ¶é¿(ç§)"),dataIndex:"videoDurationPrice",key:"videoDurationPrice",width:120,render:(e,t)=>n.jsx(k,{value:e,placeholder:i("æç§"),disabled:""!==t.price,onChange:e=>se(t.name,"videoDurationPrice",e)})},{title:i("ææ¶é¿+é³é¢"),dataIndex:"videoDurationAudioPrice",key:"videoDurationAudioPrice",width:140,render:(e,t)=>n.jsx(k,{value:e,placeholder:i("æç§+é³é¢"),disabled:""!==t.price,onChange:e=>se(t.name,"videoDurationAudioPrice",e)})},{title:i("é³é¢åç"),dataIndex:"audioRatio",key:"audioRatio",width:120,render:(e,t)=>n.jsx(k,{value:e,placeholder:i("é³é¢"),disabled:""!==t.price,onChange:e=>se(t.name,"audioRatio",e)})},{title:i("é³é¢è¡¥å
¨åç"),dataIndex:"audioCompletionRatio",key:"audioCompletionRatio",width:140,render:(e,t)=>n.jsx(k,{value:e,placeholder:i("é³é¢è¡¥å
¨"),disabled:""!==t.price,onChange:e=>se(t.name,"audioCompletionRatio",e)})}],se=(e,t,n)=>{""!==n&&isNaN(n)?je(i("请è¾å
¥æ°å")):l(i=>i.map(i=>i.name===e?{...i,[t]:n}:i))},le=e=>{i("Changing batch type to:"),z(e),"bothRatio"!==e?A(""):(O(""),L(""))},ae={selectedRowKeys:E,onChange:e=>{R(e)}};return n.jsxs(n.Fragment,{children:[n.jsxs(g,{vertical:!0,align:"start",style:{width:"100%"},children:[n.jsxs(g,{className:"mt-2",children:[n.jsx(d,{icon:n.jsx(Ye,{size:16}),onClick:()=>o(!0),children:i("æ·»å æ¨¡å")}),n.jsxs(d,{icon:n.jsx(ct,{size:16}),type:"secondary",onClick:()=>p(!0),disabled:0===E.length,children:[i("æ¹é设置")," (",E.length,")"]}),n.jsx(d,{type:"primary",icon:n.jsx(Ze,{size:16}),onClick:async()=>{w(!0);const t={ModelPrice:JSON.parse(e.options.ModelPrice||"{}"),ModelRatio:JSON.parse(e.options.ModelRatio||"{}"),CompletionRatio:JSON.parse(e.options.CompletionRatio||"{}"),ModelPixelPrice:JSON.parse(e.options.ModelPixelPrice||"{}"),ModelVideoTokenPrice:JSON.parse(e.options.ModelVideoTokenPrice||"{}"),ModelVideoDurationPrice:JSON.parse(e.options.ModelVideoDurationPrice||"{}"),ModelVideoDurationAudioPrice:JSON.parse(e.options.ModelVideoDurationAudioPrice||"{}"),AudioRatio:JSON.parse(e.options.AudioRatio||"{}"),AudioCompletionRatio:JSON.parse(e.options.AudioCompletionRatio||"{}")};
1try{s.forEach(e=>{""!==e.price?t.ModelPrice[e.name]=parseFloat(e.price):(""!==e.ratio&&(t.ModelRatio[e.name]=parseFloat(e.ratio)),""!==e.completionRatio&&(t.CompletionRatio[e.name]=parseFloat(e.completionRatio)),""!==e.pixelPrice&&(t.ModelPixelPrice[e.name]=parseFloat(e.pixelPrice)),""!==e.videoTokenPrice&&(t.ModelVideoTokenPrice[e.name]=parseFloat(e.videoTokenPrice)),""!==e.videoDurationPrice&&(t.ModelVideoDurationPrice[e.name]=parseFloat(e.videoDurationPrice)),""!==e.videoDurationAudioPrice&&(t.ModelVideoDurationAudioPrice[e.name]=parseFloat(e.videoDurationAudioPrice)),""!==e.audioRatio&&(t.AudioRatio[e.name]=parseFloat(e.audioRatio)),""!==e.audioCompletionRatio&&(t.AudioCompletionRatio[e.name]=parseFloat(e.audioCompletionRatio)))});const n={ModelPrice:JSON.stringify(t.ModelPrice,null,2),ModelRatio:JSON.stringify(t.ModelRatio,null,2),CompletionRatio:JSON.stringify(t.CompletionRatio,null,2),ModelPixelPrice:JSON.stringify(t.ModelPixelPrice,null,2),ModelVideoTokenPrice:JSON.stringify(t.ModelVideoTokenPrice,null,2),ModelVideoDurationPrice:JSON.stringify(t.ModelVideoDurationPrice,null,2),ModelVideoDurationAudioPrice:JSON.stringify(t.ModelVideoDurationAudioPrice,null,2),AudioRatio:JSON.stringify(t.AudioRatio,null,2),AudioCompletionRatio:JSON.stringify(t.AudioCompletionRatio,null,2)},l=Ee()?"/api/option/":"/api/option/admin",a=Object.entries(n).map(([e,t])=>ye.put(l,{key:e,value:t})),r=await Promise.all(a);if(1===a.length){if(r.includes(void 0))return}else if(a.length>1&&r.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));for(const e of r)if(!e.data.success)return je(e.data.message);be(i("ä¿åæå")),e.refresh(),ee()}catch(n){console.error(i("ä¿å失败")+":",n),je(i("ä¿å失败ï¼è¯·éè¯"))}finally{w(!1)}},loading:C,children:i("åºç¨æ´æ¹")}),n.jsx(k,{prefix:n.jsx(st,{size:16}),placeholder:i("æç´¢æ¨¡ååç§°"),value:y,onChange:e=>{j(e),b(1)},style:{width:200}})]}),n.jsx(Z,{children:i("æ¤é¡µé¢ä»
æ¾ç¤ºæªè®¾ç½®ä»·æ ¼æåççæ¨¡åï¼è®¾ç½®åå°èªå¨ä»å表ä¸ç§»é¤")}),n.jsx(v,{columns:ie,dataSource:ne,rowSelection:ae,rowKey:"name",scroll:{x:1600},pagination:{currentPage:f,pageSize:_,total:te.length,onPageChange:e=>b(e),onPageSizeChange:e=>{S(e);const t=Math.ceil(te.length/e);f>t&&b(t||1)},pageSizeOptions:[10,20,50,100],formatPageText:e=>i("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:te.length}),showTotal:!0,showSizeChanger:!0},empty:n.jsx("div",{style:{textAlign:"center",padding:"20px"},children:i("æ²¡ææªè®¾ç½®çæ¨¡å")})})]}),n.jsx(x,{title:i("æ·»å æ¨¡å"),visible:r,onCancel:()=>o(!1),onOk:()=>{var e;h&&(e=h,s.some(t=>t.name===e.name)?je(i("模ååç§°å·²åå¨")):(l(t=>[{name:e.name,price:e.price||"",ratio:e.ratio||"",completionRatio:e.completionRatio||"",pixelPrice:e.pixelPrice||"",videoTokenPrice:e.videoTokenPrice||"",videoDurationPrice:e.videoDurationPrice||"",videoDurationAudioPrice:e.videoDurationAudioPrice||"",audioRatio:e.audioRatio||"",audioCompletionRatio:e.audioCompletionRatio||""},...t]),o(!1),be(i("æ·»å æå"))))},children:n.jsxs(a,{children:[n.jsx(a.Input,{field:"name",label:i("模ååç§°"),placeholder:"strawberry",required:!0,onChange:e=>m(t=>({...t,name:e}))}),n.jsx(a.Switch,{field:"priceMode",label:n.jsxs(n.Fragment,{children:[i("å®ä»·æ¨¡å¼"),"ï¼",i(h?.priceMode?"åºå®ä»·æ ¼":"åçæ¨¡å¼")]}),onChange:e=>{m(t=>({...t,price:"",ratio:"",completionRatio:"",priceMode:e}))}}),h?.priceMode?n.jsx(a.Input,{field:"price",label:i("åºå®ä»·æ ¼(æ¯æ¬¡)"),placeholder:i("è¾å
¥æ¯æ¬¡ä»·æ ¼"),onChange:e=>m(t=>({...t,price:e}))}):n.jsxs(n.Fragment,{children:[n.jsx(a.Input,{field:"ratio",label:i("模ååç"),placeholder:i("è¾å
¥æ¨¡ååç"),onChange:e=>m(t=>({...t,ratio:e}))}),n.jsx(a.Input,{field:"completionRatio",label:i("è¡¥å
¨åç"),placeholder:i("è¾å
¥è¡¥å
¨ä»·æ ¼"),onChange:e=>m(t=>({...t,completionRatio:e}))})]})]})}),n.jsx(x,{title:i("æ¹é设置模ååæ°"),visible:c,onCancel:()=>p(!1),onOk:()=>{if(0===E.length)return void je(i("请å
éæ©éè¦æ¹éè®¾ç½®çæ¨¡å"));if("bothRatio"===P){if(""===M||""===D)return void je(i("请è¾å
¥æ¨¡ååçåè¡¥å
¨åç"));if(isNaN(M)||isNaN(D))return void je(i("请è¾å
¥ææçæ°å"))}else{if(""===N)return void je(i("请è¾å
¥å¡«å
å¼"));if(isNaN(N))return void je(i("请è¾å
¥ææçæ°å"))}l(e=>e.map(e=>{if(E.includes(e.name)){const t={...e,price:""};if("price"===P)return{...e,price:N,ratio:"",completionRatio:"",pixelPrice:"",videoTokenPrice:"",videoDurationPrice:"",videoDurationAudioPrice:"",audioRatio:"",audioCompletionRatio:""};if("ratio"===P)return{...t,ratio:N};if("completionRatio"===P)return{...t,completionRatio:N};if("bothRatio"===P)return{...t,ratio:M,completionRatio:D};if("pixelPrice"===P)return{...t,pixelPrice:N};if("videoTokenPrice"===P)return{...t,videoTokenPrice:N};if("videoDurationPrice"===P)return{...t,videoDurationPrice:N};if("videoDurationAudioPrice"===P)return{...t,videoDurationAudioPrice:N};if("audioRatio"===P)return{...t,audioRatio:N};if("audioCompletionRatio"===P)return{...t,audioCompletionRatio:N}}return e})),p(!1);const e={price:i("åºå®ä»·æ ¼"),ratio:i("模ååç"),completionRatio:i("è¡¥å
¨åç"),bothRatio:i("模ååçåè¡¥å
¨åç"),pixelPrice:i("åç´ ä»·æ ¼"),videoTokenPrice:i("è§é¢Tokenä»·æ ¼"),videoDurationPrice:i("ææ¶é¿(ç§)"),videoDurationAudioPrice:i("ææ¶é¿+é³é¢"),audioRatio:i("é³é¢åç"),audioCompletionRatio:i("é³é¢è¡¥å
¨åç")};F.success({title:i("æ¹é设置æå"),content:i("已为 {{num}} 个模å设置{{type}}",{num:E.length,type:e[P]||P}),duration:3})},width:600,children:n.jsxs(a,{children:[n.jsx(a.Section,{text:i("设置类å"),children:n.jsx("div",{style:{marginBottom:"16
1px"},children:n.jsxs(g,{vertical:!0,align:"start",children:[n.jsxs(g,{wrap:!0,children:[n.jsx(B,{checked:"price"===P,onChange:()=>le("price"),children:i("åºå®ä»·æ ¼")}),n.jsx(B,{checked:"ratio"===P,onChange:()=>le("ratio"),children:i("模ååç")}),n.jsx(B,{checked:"completionRatio"===P,onChange:()=>le("completionRatio"),children:i("è¡¥å
¨åç")}),n.jsx(B,{checked:"bothRatio"===P,onChange:()=>le("bothRatio"),children:i("模å+è¡¥å
¨åç")})]}),n.jsxs(g,{wrap:!0,children:[n.jsx(B,{checked:"pixelPrice"===P,onChange:()=>le("pixelPrice"),children:i("æåç´ è®¡è´¹")}),n.jsx(B,{checked:"videoTokenPrice"===P,onChange:()=>le("videoTokenPrice"),children:i("æè§é¢Token")}),n.jsx(B,{checked:"videoDurationPrice"===P,onChange:()=>le("videoDurationPrice"),children:i("ææ¶é¿(ç§)")}),n.jsx(B,{checked:"videoDurationAudioPrice"===P,onChange:()=>le("videoDurationAudioPrice"),children:i("ææ¶é¿+é³é¢")})]}),n.jsxs(g,{wrap:!0,children:[n.jsx(B,{checked:"audioRatio"===P,onChange:()=>le("audioRatio"),children:i("é³é¢åç")}),n.jsx(B,{checked:"audioCompletionRatio"===P,onChange:()=>le("audioCompletionRatio"),children:i("é³é¢è¡¥å
¨åç")})]})]})})}),"bothRatio"===P?n.jsxs(n.Fragment,{children:[n.jsx(a.Input,{field:"batchRatioValue",label:i("模ååçå¼"),placeholder:i("请è¾å
¥æ¨¡ååç"),value:M,onChange:e=>O(e)}),n.jsx(a.Input,{field:"batchCompletionRatioValue",label:i("è¡¥å
¨åçå¼"),placeholder:i("请è¾å
¥è¡¥å
¨åç"),value:D,onChange:e=>L(e)})]}):n.jsx(a.Input,{field:"batchFillValue",label:i("price"===P?"åºå®ä»·æ ¼å¼":"ratio"===P?"模ååçå¼":"completionRatio"===P?"è¡¥å
¨åçå¼":"pixelPrice"===P?"åç´ ä»·æ ¼å¼":"videoTokenPrice"===P?"è§é¢Tokenä»·æ ¼å¼":"videoDurationPrice"===P?"æ¶é¿ä»·æ ¼å¼(æ¯ç§)":"videoDurationAudioPrice"===P?"æ¶é¿+é³é¢ä»·æ ¼å¼(æ¯ç§)":"audioRatio"===P?"é³é¢åçå¼":"audioCompletionRatio"===P?"é³é¢è¡¥å
¨åçå¼":"æ°å¼"),placeholder:i("请è¾å
¥æ°å¼"),value:N,onChange:e=>A(e)}),n.jsxs(Z,{type:"tertiary",children:[i("å°ä¸ºéä¸ç ")," ",n.jsx(Z,{strong:!0,children:E.length})," ",i(" 个模å设置ç¸åçå¼")]}),n.jsx("div",{style:{marginTop:"8px"},children:n.jsxs(Z,{type:"tertiary",children:[i("å½å设置类å: ")," ",n.jsx(Z,{strong:!0,children:"price"===P?i("åºå®ä»·æ ¼"):"ratio"===P?i("模ååç"):"completionRatio"===P?i("è¡¥å
¨åç"):"bothRatio"===P?i("模ååçåè¡¥å
¨åç"):"pixelPrice"===P?i("æåç´ è®¡è´¹"):"videoTokenPrice"===P?i("æè§é¢Token"):"videoDurationPrice"===P?i("ææ¶é¿(ç§)"):"videoDurationAudioPrice"===P?i("ææ¶é¿+é³é¢"):"audioRatio"===P?i("é³é¢åç"):"audioCompletionRatio"===P?i("é³é¢è¡¥å
¨åç"):P})]})})]})})]})}const Bi=t.forwardRef(({visible:e,onCancel:i,onOk:s,allChannels:l,selectedChannelIds:a,setSelectedChannelIds:o,channelEndpoints:c,updateChannelEndpoint:d,t:u},p)=>{const[h,m]=t.useState(""),[y,f]=t.useState(1),[b,_]=t.useState(10),S=ze(),[C,w]=t.useState([]);t.useImperativeHandle(p,()=>({resetPagination:()=>{f(1),m("")}})),t.useEffect(()=>{if(!l)return;const e=h.trim().toLowerCase(),t=e?l.filter(t=>{const n=(t.label||"").toLowerCase(),i=(t._originalData?.base_url||"").toLowerCase();return n.includes(e)||i.includes(e)}):l;w(t)},[l,h]);const T=C.length,I=C.slice((y-1)*b,y*b),E=(e,t)=>{"function"==typeof d&&d(e,t)},R=e=>"/api/ratio_config"===e?"ratio_config":"/api/pricing"===e?"pricing":"custom",P=e=>{switch(e){case 1:return n.jsx(j,{color:"green",shape:"circle",size:"small",prefixIcon:n.jsx(pt,{size:14}),children:u("å·²å¯ç¨")});case 2:return n.jsx(j,{color:"red",shape:"circle",size:"small",prefixIcon:n.jsx(ut,{size:14}),children:u("å·²ç¦ç¨")});case 3:return n.jsx(j,{color:"yellow",shape:"circle",size:"small",prefixIcon:n.jsx(dt,{size:14}),children:u("èªå¨ç¦ç¨")});default:return n.jsx(j,{color:"grey",shape:"circle",size:"small",prefixIcon:n.jsx(tt,{size:14}),children:u("æªç¥ç¶æ")})}},z=[{title:u("åç§°"),dataIndex:"label",render:e=>n.jsx(W,{sourceString:e,searchWords:[h]})},{title:u("æºå°å"),dataIndex:"_originalData.base_url",render:(e,t)=>{return i=t._originalData?.base_url||"",n.jsx(W,{sourceString:i,searchWords:[h]});var i}},{title:u("ç¶æ"),dataIndex:"_originalData.status",render:(e,t)=>P(t._originalData?.status||0)},{title:u("忥æ¥å£"),dataIndex:"endpoint",fixed:"right",render:(e,t)=>{const i=t.key||t.value,s=c[i]||"",l=R(s);return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8}
1,children:[n.jsx(N,{size:"small",value:l,onChange:e=>{"ratio_config"===e?E(i,"/api/ratio_config"):"pricing"===e?E(i,"/api/pricing"):"custom"!==l&&E(i,"")},style:{width:120},optionList:[{label:"ratio_config",value:"ratio_config"},{label:"pricing",value:"pricing"},{label:"custom",value:"custom"}]}),"custom"===l&&n.jsx(k,{size:"small",value:s,onChange:e=>E(i,e),placeholder:"/your/endpoint",style:{width:160,fontSize:12}})]})}}],A={selectedRowKeys:a,onChange:e=>o(e)},M=()=>n.jsxs("div",{className:"px-2 pt-2",children:[n.jsx("div",{className:"grid grid-cols-1 gap-2",children:I.map((e,t)=>{const i=e.key||e.value,s=c[i]||"",l=R(s),d=a.includes(i);return n.jsxs(r,{className:"!rounded-2xl border shadow-sm w-full",bodyStyle:{padding:12},children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsx("div",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:u("åç§°")}),n.jsx("div",{className:"flex-1 ml-3 text-sm font-semibold truncate text-right",children:n.jsx(W,{sourceString:e.label,searchWords:[h]})}),n.jsx("div",{className:"ml-3 flex items-center",children:n.jsx(D,{checked:d,onChange:e=>((e,t)=>{const n=new Set(a);t?n.add(e):n.delete(e),o(Array.from(n))})(i,e.target.checked)})})]}),n.jsxs("div",{className:"flex items-center justify-between mt-1",children:[n.jsx("div",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:u("æºå°å")}),n.jsx("div",{className:"flex-1 ml-3 text-xs line-clamp-1 text-right",style:{color:"hsl(var(--muted-foreground))",wordBreak:"break-all"},children:n.jsx(W,{sourceString:e._originalData?.base_url||"",searchWords:[h]})})]}),n.jsxs("div",{className:"flex items-center justify-between mt-1",children:[n.jsx("div",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:u("ç¶æ")}),n.jsx("div",{className:"ml-3",children:P(e._originalData?.status||0)})]}),n.jsxs("div",{className:"flex items-center justify-between mt-2",children:[n.jsx("div",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:u("忥æ¥å£")}),n.jsx("div",{className:"ml-3 flex-1 flex justify-end",children:n.jsx(N,{size:"small",value:l,onChange:e=>{"ratio_config"===e?E(i,"/api/ratio_config"):"pricing"===e?E(i,"/api/pricing"):"custom"!==l&&E(i,"")},style:{width:140,minWidth:0},optionList:[{label:"ratio_config",value:"ratio_config"},{label:"pricing",value:"pricing"},{label:"custom",value:"custom"}]})})]}),"custom"===l&&n.jsxs("div",{className:"flex items-center justify-between mt-2",children:[n.jsx("div",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:u("èªå®ä¹")}),n.jsx("div",{className:"ml-3 flex-1 flex justify-end",children:n.jsx(k,{size:"small",value:s,onChange:e=>E(i,e),placeholder:"/your/endpoint",style:{width:"100%",maxWidth:220,fontSize:12,minWidth:0}})})]})]},i||t)})}),T>0&&n.jsx("div",{className:"flex justify-center mt-4",children:n.jsx(J,{currentPage:y,pageSize:b,total:T,showSizeChanger:!0,showQuickJumper:!0,size:"small",pageSizeOptions:[10,20,50,100],onPageChange:e=>f(e),onPageSizeChange:e=>{_(e),f(1)}})})]});return n.jsx(x,{visible:e,onCancel:i,onOk:s,title:n.jsx("span",{className:"text-lg font-semibold",children:u("éæ©åæ¥æ¸ é")}),size:S?"full-width":"large",keepDOM:!0,lazyRender:!1,children:n.jsxs(g,{vertical:!0,style:{width:"100%"},children:[n.jsx(k,{prefix:n.jsx(st,{size:14}),placeholder:u("æç´¢æ¸ éåç§°æå°å"),value:h,onChange:m,showClear:!0}),S?n.jsx(M,{}):n.jsx(v,{columns:z,dataSource:I,rowKey:"key",rowSelection:A,pagination:{currentPage:y,pageSize:b,total:T,showSizeChanger:!0,showQuickJumper:!0,pageSizeOptions:["10","20","50","100"],formatPageText:e=>u("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:T}),onChange:(e,t)=>
1{f(e),_(t)},onShowSizeChange:(e,t)=>{f(1),_(t)}},size:"small"})]})})});function Fi({t:e,visible:t,items:i,onOk:s,onCancel:l}){const a=ze(),r=[{title:e("æ¸ é"),dataIndex:"channel"},{title:e("模å"),dataIndex:"model"},{title:e("å½å计费"),dataIndex:"current",render:e=>n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:e})},{title:e("ä¿®æ¹ä¸º"),dataIndex:"newVal",render:e=>n.jsx("div",{style:{whiteSpace:"pre-wrap"},children:e})}];return n.jsx(x,{title:e("确认å²çªé¡¹ä¿®æ¹"),visible:t,onCancel:l,onOk:s,size:a?"full-width":"large",children:n.jsx(v,{columns:r,dataSource:i,pagination:!1,size:14})})}function Wi(e){const{t:s}=ge(),[l,r]=t.useState(!1),[o,c]=t.useState(!1),[u,p]=t.useState(!1);ze();const[h,x]=t.useState([]),[m,g]=t.useState([]),[y,b]=t.useState({}),[_,S]=t.useState({}),[I,E]=t.useState({}),[R,P]=t.useState(!1),[z,A]=t.useState(1),[M,O]=t.useState(10),[L,B]=t.useState(""),[F,W]=t.useState(""),[J,U]=t.useState(!1),[V,K]=t.useState([]),G=i.useRef(null);t.useEffect(()=>{A(1)},[F,L]);function q(e){return"model_price"===e?"price":"ratio"}const $=t.useCallback((e,t,n)=>{const i=q(t);E(s=>{const l={...s[e]||{}};return Object.keys(l).forEach(e=>{q(e)!==i&&delete l[e]}),l[t]=n,{...s,[e]:l}})},[E]),H=async()=>{const t={ModelRatio:JSON.parse(e.options.ModelRatio||"{}"),CompletionRatio:JSON.parse(e.options.CompletionRatio||"{}"),CacheRatio:JSON.parse(e.options.CacheRatio||"{}"),ModelPrice:JSON.parse(e.options.ModelPrice||"{}")},n=[];if(Object.entries(I).forEach(([e,i])=>{const l=(e=>void 0!==t.ModelPrice[e]?"price":void 0!==t.ModelRatio[e]||void 0!==t.CompletionRatio[e]||void 0!==t.CacheRatio[e]?"ratio":null)(e),a="model_price"in i?"price":"ratio";if(l&&l!==a){const r="price"===l?`${s("åºå®ä»·æ ¼")} : ${t.ModelPrice[e]}`:`${s("模ååç")} : ${t.ModelRatio[e]??"-"}\n${s("è¡¥å
¨åç")} : ${t.CompletionRatio[e]??"-"}`;let o="";if("price"===a)o=`${s("åºå®ä»·æ ¼")} : ${i.model_price}`;else{const e=i.model_ratio??"-",t=i.completion_ratio??"-";o=`${s("模ååç")} : ${e}\n${s("è¡¥å
¨åç")} : ${t}`}const c=Object.entries(i).map(([t,n])=>((e,t,n)=>{if(_[e]&&_[e][t]){const i=_[e][t].upstreams||{},s=Object.entries(i).find(([e,t])=>t===n);if(s)return s[0]}return s("æªç¥")})(e,t,n)).filter((e,t,n)=>n.indexOf(e)===t).join(", ");n.push({channel:c,model:e,current:r,newVal:o})}}),n.length>0)return K(n),void U(!0);await Q(t)},Q=t.useCallback(async t=>{const n={ModelRatio:{...t.ModelRatio},CompletionRatio:{...t.CompletionRatio},CacheRatio:{...t.CacheRatio},ModelPrice:{...t.ModelPrice}};Object.entries(I).forEach(([e,t])=>{const i=Object.keys(t),s=i.includes("model_price"),l=i.some(e=>"model_price"!==e);s&&(delete n.ModelRatio[e],delete n.CompletionRatio[e],delete n.CacheRatio[e]),l&&delete n.ModelPrice[e],Object.entries(t).forEach(([t,i])=>{const s=t.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("");n[s][e]=parseFloat(i)})}),c(!0);try{const t=Ee()?"/api/option/":"/api/option/admin",i=Object.entries(n).map(([e,n])=>ye.put(t,{key:e,value:JSON.stringify(n,null,2)}));(await Promise.all(i)).every(e=>e.data.success)?(be(s("忥æå")),e.refresh(),S(e=>{const t={...e};return Object.entries(I).forEach(([e,n])=>{Object.keys(n).forEach(n=>{t[e]&&t[e][n]&&(delete t[e][n],0===Object.keys(t[e]).length&&delete t[e])})}),t}),E({})):je(s("é¨åä¿å失败"))}catch(i){je(s("ä¿å失败"))}finally{c(!1)}},[I,e.options,e.refresh]),X=e=>{const t=(z-1)*M,n=t+M;return e.slice(t,n)},Y=t.useCallback((e,t)=>{b(n=>({...n,[e]:t}))},[]);return n.jsxs(n.Fragment,{children:[n.jsx(a.Section,{text:n.jsx("div",{className:"flex flex-col w-full",children:n.jsx("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 w-full",children:n.jsxs("div",{className:"flex flex-col md:flex-row gap-2 w-full md:w-auto order-2 md:order-1",children:[n.jsx(d,{icon:n.jsx(qe,{size:14}),className:"w-full md:w-auto mt-2",onClick:()=>{r(!0),0===h.length&&(async()=>{c(!0);try{const e=await ye.get("/api/ratio_sync/channels");if(e.data.success){const t=(e.data.data||[]).map(e=>({key:e.id,label:e.name,value:e.id,disabled:!1,_originalData:e}));x(t),b(e=>{const n={...e};
1return t.forEach(e=>{n[e.key]||(n[e.key]=Ae)}),n})}else je(e.data.message)}catch(e){je(s("è·åæ¸ é失败ï¼")+e.message)}finally{c(!1)}})()},children:s("éæ©åæ¥æ¸ é")}),(()=>{const e=Object.keys(I).length>0;return n.jsx(d,{icon:n.jsx(ht,{size:14}),type:"secondary",onClick:H,disabled:!e,className:"w-full md:w-auto mt-2",children:s("åºç¨åæ¥")})})(),n.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full md:w-auto mt-2",children:[n.jsx(k,{prefix:n.jsx(st,{size:14}),placeholder:s("æç´¢æ¨¡ååç§°"),value:L,onChange:B,className:"w-full sm:w-64",showClear:!0}),n.jsxs(N,{placeholder:s("æåçç±»åçé"),value:F,onChange:W,className:"w-full sm:w-48",showClear:!0,onClear:()=>W(""),children:[n.jsx(N.Option,{value:"model_ratio",children:s("模ååç")}),n.jsx(N.Option,{value:"completion_ratio",children:s("è¡¥å
¨åç")}),n.jsx(N.Option,{value:"cache_ratio",children:s("ç¼ååç")}),n.jsx(N.Option,{value:"model_price",children:s("åºå®ä»·æ ¼")})]})]})]})})}),children:(()=>{const e=t.useMemo(()=>{const e=[];return Object.entries(_).forEach(([t,n])=>{const i="model_price"in n,s=["model_ratio","completion_ratio","cache_ratio"].some(e=>e in n),l=i&&s;Object.entries(n).forEach(([n,i])=>{e.push({key:`${t}_${n}`,model:t,ratioType:n,current:i.current,upstreams:i.upstreams,confidence:i.confidence||{},billingConflict:l})})}),e},[_]),i=t.useMemo(()=>L.trim()||F?e.filter(e=>{const t=!L.trim()||e.model.toLowerCase().includes(L.toLowerCase().trim()),n=!F||e.ratioType===F;return t&&n}):e,[e,L,F]),l=t.useMemo(()=>{const e=new Set;return i.forEach(t=>{Object.keys(t.upstreams||{}).forEach(t=>e.add(t))}),Array.from(e)},[i]);if(0===i.length)return n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:L.trim()?s("æªæ¾å°å¹é
çæ¨¡å"):0===Object.keys(_).length?s(R?"ææ å·®å¼ååçæ¾ç¤º":"请å
éæ©åæ¥æ¸ é"):s("请å
éæ©åæ¥æ¸ é"),style:{padding:30}});const a=[{title:s("模å"),dataIndex:"model",fixed:"left"},{title:s("åçç±»å"),dataIndex:"ratioType",render:(e,t)=>{const i={model_ratio:s("模ååç"),completion_ratio:s("è¡¥å
¨åç"),cache_ratio:s("ç¼ååç"),model_price:s("åºå®ä»·æ ¼")},l=n.jsx(j,{color:Me(e),shape:"circle",children:i[e]||e});return t?.billingConflict?n.jsxs("div",{className:"flex items-center gap-1",children:[l,n.jsx(f,{position:"top",content:s("该模ååå¨åºå®ä»·æ ¼ä¸åç计费æ¹å¼å²çªï¼è¯·ç¡®è®¤éæ©"),children:n.jsx(xt,{size:14,className:"text-yellow-500"})})]}):l}},{title:s("置信度"),dataIndex:"confidence",render:(e,t)=>{if(Object.values(t.confidence||{}).every(e=>!1!==e))return n.jsx(f,{content:s("ææä¸æ¸¸æ°æ®åå¯ä¿¡"),children:n.jsx(j,{color:"green",shape:"circle",type:"light",prefixIcon:n.jsx(pt,{size:14}),children:s("å¯ä¿¡")})});
1{const e=Object.entries(t.confidence||{}).filter(([e,t])=>!1===t).map(([e])=>e).join(", ");return n.jsx(f,{content:s("以ä¸ä¸æ¸¸æ°æ®å¯è½ä¸å¯ä¿¡ï¼")+e,children:n.jsx(j,{color:"yellow",shape:"circle",type:"light",prefixIcon:n.jsx(xt,{size:14}),children:s("è°¨æ
")})})}}},{title:s("å½åå¼"),dataIndex:"current",render:e=>n.jsx(j,{color:null!=e?"blue":"default",shape:"circle",children:null!=e?e:s("æªè®¾ç½®")})},...l.map(e=>{const t=(()=>{let t=0,n=0;return i.forEach(i=>{const s=i.upstreams?.[e];null!=s&&"same"!==s&&(t++,I[i.model]?.[i.ratioType]===s&&n++)}),{selectableCount:t,selectedCount:n,allSelected:t>0&&n===t,partiallySelected:n>0&&n<t,hasSelectableItems:t>0}})();return{title:t.hasSelectableItems?n.jsx(D,{checked:t.allSelected,indeterminate:t.partiallySelected,onChange:t=>{t.target.checked?i.forEach(t=>{const n=t.upstreams?.[e];null!=n&&"same"!==n&&$(t.model,t.ratioType,n)}):E(e=>{const t={...e};return i.forEach(e=>{t[e.model]&&(delete t[e.model][e.ratioType],0===Object.keys(t[e.model]).length&&delete t[e.model])}),t})},children:e}):n.jsx("span",{children:e}),dataIndex:e,render:(t,i)=>{const l=i.upstreams?.[e],a=!1!==i.confidence?.[e];if(null==l)return n.jsx(j,{color:"default",shape:"circle",children:s("æªè®¾ç½®")});if("same"===l)return n.jsx(j,{color:"blue",shape:"circle",children:s("䏿¬å°ç¸å")});const r=I[i.model]?.[i.ratioType]===l;return n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(D,{checked:r,onChange:e=>{e.target.checked?$(i.model,i.ratioType,l):E(e=>{const t={...e};return t[i.model]&&(delete t[i.model][i.ratioType],0===Object.keys(t[i.model]).length&&delete t[i.model]),t})},children:l}),!a&&n.jsx(f,{position:"left",content:s("è¯¥æ°æ®å¯è½ä¸å¯ä¿¡ï¼è¯·è°¨æ
使ç¨"),children:n.jsx(xt,{size:16,className:"text-yellow-500"})})]})}}})];return n.jsx(v,{columns:a,dataSource:X(i),pagination:{currentPage:z,pageSize:M,total:i.length,showSizeChanger:!0,showQuickJumper:!0,formatPageText:e=>s("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:e.currentStart,end:e.currentEnd,total:i.length}),pageSizeOptions:["5","10","20","50"],onChange:(e,t)=>
1{A(e),O(t)},onShowSizeChange:(e,t)=>{A(1),O(t)}},scroll:{x:"max-content"},size:"middle",loading:o||u})})()}),n.jsx(Bi,{ref:G,t:s,visible:l,onCancel:()=>{r(!1),G.current&&G.current.resetPagination()},onOk:()=>{const e=h.filter(e=>m.includes(e.value)).map(e=>e._originalData);0!==e.length?(r(!1),(async e=>{p(!0);const t={upstreams:e.map(e=>({id:e.id,name:e.name,base_url:e.base_url,endpoint:y[e.id]||Ae})),timeout:10};try{const e=await ye.post("/api/ratio_sync/fetch",t);if(!e.data.success)return je(e.data.message||s("å端请æ±å¤±è´¥")),void p(!1);const{differences:n={},test_results:i=[]}=e.data.data,l=i.filter(e=>"error"===e.status);l.length>0&&ve(s("é¨åæ¸ éæµè¯å¤±è´¥ï¼")+l.map(e=>`${e.name}: ${e.error}`).join(", ")),S(n),E({}),P(!0),0===Object.keys(n).length&&be(s("æªæ¾å°å·®å¼ååçï¼æ é忥"))}catch(n){je(s("请æ±å端æ¥å£å¤±è´¥ï¼")+n.message)}finally{p(!1)}})(e)):ve(s("请è³å°éæ©ä¸ä¸ªæ¸ é"))},allChannels:h,selectedChannelIds:m,setSelectedChannelIds:g,channelEndpoints:y,updateChannelEndpoint:Y}),n.jsx(Fi,{t:s,visible:J,items:V,onOk:async()=>{U(!1);const t={ModelRatio:JSON.parse(e.options.ModelRatio||"{}"),CompletionRatio:JSON.parse(e.options.CompletionRatio||"{}"),CacheRatio:JSON.parse(e.options.CacheRatio||"{}"),ModelPrice:JSON.parse(e.options.ModelPrice||"{}")};await Q(t)},onCancel:()=>U(!1)})]})}const{Text:Ji}=u,Ui="tool_price_setting.prices",Vi={web_search:10,web_search_preview:10,"web_search_preview:gpt-4o*":25,"web_search_preview:gpt-4.1*":25,"web_search_preview:gpt-4o-mini*":25,"web_search_preview:gpt-4.1-mini*":25,file_search:2.5,google_search:14};function Ki(e){const t={};for(const n of e){const e=n.key.trim();e&&(t[e]=Number(n.price)||0)}return t}function Gi(e){return Object.entries(e).map(([e,t],n)=>({id:n,key:e,price:t}))}function qi({options:e,refresh:i}){const{t:s}=ge(),[l,a]=t.useState([]),[r,o]=t.useState("visual"),[c,u]=t.useState(""),[p,x]=t.useState(""),[m,g]=t.useState(!1);t.useEffect(()=>{let t={};try{const n=e?.[Ui];n&&(t="string"==typeof n?JSON.parse(n):n)}catch{t={}}t&&0!==Object.keys(t).length||(t={...Vi}),a(Gi(t)),u(JSON.stringify(t,null,2))},[e]);const y=e=>{a(e),u(JSON.stringify(Ki(e),null,2)),x("")},j=(e,t,n)=>{y(l.map(i=>i.id===e?{...i,[t]:n}:i))},f=()=>{y(Gi(Vi))},b=t.useMemo(()=>Ki(l),[l]),_=[{title:s("å·¥å
·æ è¯"),dataIndex:"key",render:(e,t)=>n.jsx(k,{value:e,placeholder:"web_search_preview:gpt-4o*",onChange:e=>j(t.id,"key",e),style:{width:"100%"}})},{title:s("ä»·æ ¼")+" ($/1K"+s("次")+")",dataIndex:"price",width:160,render:(e,t)=>n.jsx(M,{value:e,min:0,step:.5,onChange:e=>j(t.id,"price",e??0),style:{width:"100%"}})},{title:s("æä½"),width:60,render:(e,t)=>n.jsx(d,{icon:n.jsx(U,{}),type:"danger",theme:"borderless",size:"small",onClick:()=>{return e=t.id,void y(l.filter(t=>t.id!==e));var e}})}];return n.jsxs("div",{style:{maxWidth:700},children:[n.jsx(h,{type:"info",description:n.jsxs(n.Fragment,{children:[n.jsx("div",{children:s("é
ç½®åå·¥å
·çè°ç¨ä»·æ ¼ï¼$/1K次è°ç¨ï¼ãææ¬¡è®¡è´¹æ¨¡åä¸é¢å¤æ¶åå·¥å
·è´¹ç¨ã")}),n.jsxs("div",{style:{marginTop:4},children:[n.jsxs(Ji,{strong:!0,children:[s("æ ¼å¼"),"ï¼"]}),n.jsx("code",{children:"web_search_preview"})," ",s("为é»è®¤ä»·æ ¼"),"ï¼",n.jsx("code",{children:"web_search_preview:gpt-4o*"})," ",s("为模ååç¼è¦ç")]})]}),style:{marginBottom:16}}),n.jsxs(L,{type:"button",size:"small",value:r,onChange:e=>o(e.target.value),style:{marginBottom:12},children:[n.jsx(B,{value:"visual",children:s("å¯è§å")}),n.jsx(B,{value:"json",children:"JSON"})]}),"visual"===r?n.jsxs(n.Fragment,{children:[n.jsx(v,{dataSource:l,columns:_,pagination:!1,size:"small",rowKey:"id"}),n.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[n.jsx(d,{icon:n.jsx(V,{}),onClick:()=>{y([...l,{id:Date.now(),key:"",price:0}])},children:s("æ·»å ")}),n.jsx(d,{theme:"borderless",onClick:f,children:s("æ¢å¤é»è®¤")})]})]}):n.jsxs(n.Fragment,{children:[n.jsx(S,{value:c,onChange:e=>{u(e);try{const t=JSON.parse(e);if("object"!=typeof t||Array.isArray(t)||null===t)return void x(s("JSON å¿
é¡»æ¯å¯¹è±¡"));a(Gi(t)),x("")}catch(t){x(t.message)}},autosize:{minRows:8,maxRows:20},style:{fontFamily:"monospace",fontSize:13}}),p&&n.jsx(Ji,{type:"danger",size:"small",style:{display:"block",marginTop:4},children:p}),n.jsxs("div",{style:{display:"flex",gap:8,marginTop:8},children:[n.jsx(d,{icon:n.jsx(K,{}),size:"small",theme:"borderless",onClick:()=>{Oe(c)},children:s("å¤å¶")}),n.jsx(d,{size:"small",theme:"borderless",onClick:f,children:s("æ¢å¤é»è®¤")})]})]}),n.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:16},children:n.jsx(d,{theme:"solid",type:"primary",loading:m,disabled:"json"===r&&!!p,onClick:async()=>{g(!0);try{const e=Ee()?"/api/option/":"/api/option/admin",t=await ye.put(e,{key:Ui,value:JSON.stringify(b)});t.data.success?(be(s("ä¿åæå")),i&&i()):je(t.data.message||s("ä¿å失败"))}catch(e){je(e.message)}finally{g(!1)}},children:s("ä¿å")})})]})}const $i=()=>{const{t:e}=ge();let[i,s]=t.useState({ModelPrice:"",ModelRatio:"",CacheRatio:"",CompletionRatio:"",ModelStepRatio:"",GroupRatio:"",GroupGroupRatio:"",AutoGroups:"",DefaultUseAutoGroup:!1,ExposeRatioEnabled:!1,UserUsableGroups:"",GroupPermissions:"",BulkTopUpDiscounts:""});const[l,a]=t.useState(!1),o=async()=>{try{a(!0),await(async()=>{try{const e=Ee()?"/api/option/":"/api/option/admin",t=await ye.get(e),{success:n,message:i,data:l}=t.data;if(n){let e={};l.forEach(t=>{if("ModelRatio"===t.key||"GroupRatio"===t.key||"GroupGroupRatio"===t.key||"AutoGroups"===t.key||"UserUsableGroups"===t.key||"CompletionRatio"===t.key||"ModelPrice"===t.key||"CacheRatio"===t.key||"ModelStepRatio"===t.key||"GroupPermissions"===t.key||"BulkTopUpDiscounts"===t.key)try{t.value=JSON.stringify(JSON.parse(t.value),null,2)}catch(n){}["DefaultUseAutoGroup","ExposeRatioEnabled"].includes(t.key)?e[t.key]=an(t.value):e[t.key]=t.value}),s(e)}else je(i)}catch(t){console.error("è·åé项失败:",t),je(e("è·åé项失败ï¼è¯·å·æ°éè¯")),s({ModelPrice:"",ModelRatio:"",CacheRatio:"",CompletionRatio:"",ModelStepRatio:"",GroupRatio:"",GroupGroupRatio:"",AutoGroups:"",DefaultUseAutoGroup:!1,ExposeRatioEnabled:!1,UserUsableGroups:"",GroupPermissions:"",BulkTopUpDiscounts:""})}})()}catch(t){je(e("å·æ°å¤±è´¥"))}finally{a(!1)}};return t.useEffect(()=>{o()},[]),n.jsx(m,{spinning:l,size:"large",children:n.jsx(r,{style:{marginTop:"10px"},children:n.jsxs(b,{type:"card",children:[n.jsx(b.TabPane,{tab:e("å¯è§å模ååç设置"),itemKey:"visual",children:n.jsx(Di,{options:i,refresh:o})}),n.jsx(b.TabPane,{tab:e("模ååç设置"),itemKey:"model",children:n.jsx(Oi,{options:i,refresh:o})}),n.jsx(b.TabPane,{tab:e("æªè®¾ç½®åçæ¨¡å"),itemKey:"unset_models",children:n.jsx(Li,{options:i,refresh:o})}),n.jsx(b.TabPane,{tab:e("䏿¸¸åç忥"),itemKey:"upstream_sync",children:n.jsx(Wi,{options:i,refresh:o})}),n.jsx(b.TabPane,{tab:e("åç»ç¸å
³è®¾ç½®"),itemKey:"group",children:n.jsx(Mi,{options:i,refresh:o})}),n.jsx(b.TabPane,{tab:e("å·¥å
·è°ç¨å®ä»·"),itemKey:"tool_price",children:n.jsx(qi,{options:i,refresh:o})})]})})})};function Hi(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,o]=t.useState({Chats:"[]"}),c=t.useRef(),[u,p]=t.useState(r);return t.useEffect(()=>{const t={};for(let n in e.options)if(Object.keys(r).includes(n))if("Chats"===n){const i=JSON.parse(e.options[n]);t[n]=JSON.stringify(i,null,2)}else t[n]=e.options[n];o(t),p(structuredClone(t)),c.current.setValues(t)},[e.options]),n.jsxs(m,{spinning:s,children:[n.jsx(a,{values:r,getFormApi:e=>c.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("è天设置"),children:[n.jsx(h,{type:"info",description:n.jsxs("div",{children:[n.jsx("div",{children:i("龿¥ä¸æ¯æä»¥ä¸å ä½ç¬¦èªå¨æ¿æ¢ï¼")}),n.jsxs("div",{style:{marginTop:"8px",fontSize:"13px",lineHeight:"1.6"},children:[n.jsxs("div",{children:["⢠",n.jsx("code",{children:"{key}"})," - ",i("æ¿æ¢ä¸º sk-xxxx æ ¼å¼ç令ç")]}),n.jsxs("div",{children:["⢠",n.jsx("code",{children:"{address}"})," - ",i("æ¿æ¢ä¸ºç³»ç»è®¾ç½®çæå¡å¨å°åï¼æ«å°¾ä¸å¸¦/å/v1ï¼")]}),n.jsx("div",{style:{marginTop:"6px",fontWeight:"bold"},children:i("Cherry Studio ä¸ç¨å ä½ç¬¦ï¼")}),n.jsxs("div",{children:["⢠",n.jsx("code",{children:"{openai_base64}"})," - ",i("OpenAI é
ç½®ç base64 ç¼ç ")]}),n.jsxs("div",{children:["⢠",n.jsx("code",{children:"{openai_response_base64}"})," - ",i("OpenAI Response é
ç½®ç base64 ç¼ç ")]}),n.jsxs("div",{children:["⢠",n.jsx("code",{children:"{anthropic_base64}"})," - ",i("Anthropic é
ç½®ç base64 ç¼ç ")]}),n.jsxs("div",{children:["⢠",n.jsx("code",{children:"{gemini_base64}"})," - ",i("Gemini é
ç½®ç base64 ç¼ç ")]})]})]})}),n.jsx(a.TextArea,{label:i("è天é
ç½®"),extraText:"",placeholder:i("为ä¸ä¸ª JSON ææ¬"),field:"Chats",autosize:{minRows:6,maxRows:12},trigger:"blur",stopValidateWithError:!0,rules:[{validator:(e,t)=>
1Re(t),message:i("䏿¯åæ³ç JSON å符串")}],onChange:e=>o({...r,Chats:e})})]})}),n.jsx(g,{children:n.jsx(d,{onClick:async function(){try{await c.current.validate().then(()=>{const t=ke(r,u);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t="";return t="boolean"==typeof r[e.key]?String(r[e.key]):r[e.key],ye.put("/api/option/",{key:e.key,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})}).catch(e=>{console.error("Validation failed:",e),je(i("è¯·æ£æ¥è¾å
¥"))})}catch(t){je(i("è¯·æ£æ¥è¾å
¥")),console.error(t)}},children:i("ä¿åè天设置")})})]})}const Qi=()=>{const{t:e}=ge();let[i,s]=t.useState({Chats:"[]"}),[l,a]=t.useState(!1);async function o(){try{a(!0),await(async()=>{const e=await ye.get("/api/option/"),{success:t,message:n,data:i}=e.data;if(t){let e={};i.forEach(t=>{t.key.endsWith("Enabled")||["DefaultCollapseSidebar"].includes(t.key)?e[t.key]=an(t.value):e[t.key]=t.value}),s(e)}else je(n)})()}catch(t){je(e("å·æ°å¤±è´¥"))}finally{a(!1)}}return t.useEffect(()=>{o()},[]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:l,size:"large",children:n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Hi,{options:i,refresh:o})})})})};function Xi(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({DrawingEnabled:!1,MjNotifyEnabled:!1,MjAccountFilterEnabled:!1,MjForwardUrlEnabled:!1,MjModeClearEnabled:!1,MjActionCheckSuccessEnabled:!1}),p=t.useRef(),[h,x]=t.useState(r);return t.useEffect(()=>{const t={};for(let n in e.options)Object.keys(r).includes(n)&&(t[n]=e.options[n]);u(t),x(structuredClone(t)),p.current.setValues(t),localStorage.setItem("mj_notify_enabled",String(r.MjNotifyEnabled))},[e.options]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("ç»å¾è®¾ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"DrawingEnabled",label:i("å¯ç¨ç»å¾åè½"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{u({...r,DrawingEnabled:e})}})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"MjNotifyEnabled",label:i("å
许åè°ï¼ä¼æ³é²æå¡å¨ IP å°åï¼"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>u({...r,MjNotifyEnabled:e})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"MjAccountFilterEnabled",label:i("å
许 AccountFilter åæ°"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>u({...r,MjAccountFilterEnabled:e})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"MjForwardUrlEnabled",label:i("å¼å¯ä¹åå°ä¸æ¸¸å°åæ¿æ¢ä¸ºæå¡å¨å°å"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>u({...r,MjForwardUrlEnabled:e})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"MjModeClearEnabled",label:i("å¼å¯ä¹å伿¸
é¤ç¨æ·æç¤ºè¯ä¸ç --fastã--relax 以å --turbo åæ°"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>u({...r,MjModeClearEnabled:e})})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"MjActionCheckSuccessEnabled",label:i("æ£æµå¿
é¡»çå¾
ç»å¾æåæè½è¿è¡æ¾å¤§çæä½"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>u({...r,MjActionCheckSuccessEnabled:e})})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(r,h);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=t.map(e=>{let t="";return t="boolean"==typeof r[e.key]?String(r[e.key]):r[e.key],ye.put("/api/option/",{key:e.key,value:t})});l(!0),Promise.all(n).then(t=>{if(1===n.length){if(t.includes(void 0))return}else if(n.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿åç»å¾è®¾ç½®")})})]})})})})}const Yi=()=>{const{t:e}=ge();let[i,s]=t.useState({DrawingEnabled:!1,MjNotifyEnabled:!1,MjAccountFilterEnabled:!1,MjForwardUrlEnabled:!1,MjModeClearEnabled:!1,MjActionCheckSuccessEnabled:!1}),[l,a]=t.useState(!1);async function o(){try{a(!0),await(async()=>{const e=await ye.get("/api/option/"),{success:t,message:n,data:i}=e.data;if(t){let e={};
1i.forEach(t=>{t.key.endsWith("Enabled")?e[t.key]=an(t.value):e[t.key]=t.value}),s(e)}else je(n)})()}catch(t){je(e("å·æ°å¤±è´¥"))}finally{a(!1)}}return t.useEffect(()=>{o()},[]),n.jsx(n.Fragment,{children:n.jsx(m,{spinning:l,size:"large",children:n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Xi,{options:i,refresh:o})})})})};function Zi(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,o]=t.useState({ServerAddress:""}),c=t.useRef(null);return t.useEffect(()=>{if(e.options&&c.current){const t={ServerAddress:e.options.ServerAddress||""};o(t),c.current.setValues(t)}},[e.options]),n.jsx(m,{spinning:s,children:n.jsx(a,{initValues:r,onValueChange:e=>{o(e)},getFormApi:e=>c.current=e,children:n.jsxs(a.Section,{text:i("éç¨è®¾ç½®"),children:[n.jsx(a.Input,{field:"ServerAddress",label:i("æå¡å¨å°å"),placeholder:"https://yourdomain.com",style:{width:"100%"},extraText:i("该æå¡å¨å°åå°å½±åæ¯ä»åè°å°å以åé»è®¤é¦é¡µå±ç¤ºçå°åï¼è¯·ç¡®ä¿æ£ç¡®é
ç½®")}),n.jsx(d,{onClick:async()=>{l(!0);try{let t=fe(r.ServerAddress);const n=await ye.put("/api/option/",{key:"ServerAddress",value:t});n.data.success?(be(i("æ´æ°æå")),e.refresh&&e.refresh()):je(n.data.message)}catch(t){je(i("æ´æ°å¤±è´¥"))}l(!1)},children:i("æ´æ°æå¡å¨å°å")})]})})})}const{Text:es}=u;function ts(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState(!1),[p,x]=t.useState({PayAddress:"",EpayId:"",EpayKey:"",Price:7.3,MinTopUp:1,TopupGroupRatio:"",CustomCallbackAddress:"",PayMethods:"",PayChannelNames:"",SubSiteFollowMainPayment:"true",SubSitePayAddress:"",SubSiteEpayId:"",SubSiteEpayKey:"",ForceHideBepusdt:!1}),[g,y]=t.useState({}),f=t.useRef(null),b={WebkitTextSecurity:"disc"},[_,S]=t.useState([]),[v,w]=t.useState([]),[T,E]=t.useState(!1),[R,P]=t.useState(""),[z,N]=t.useState(!1),A=e=>({value:e.id,label:`${e.username||e.display_name||i("ç¨æ·")+e.id} (ID: ${e.id})`}),M=async e=>{const t=(e||"").trim();if(t){E(!0);try{const e=await ye.get(`/api/user/search?keyword=${encodeURIComponent(t)}&page_size=20&p=0`);if(e.data.success){const t=e.data.data?.items||[];w(t.map(A))}else w([])}catch{w([])}E(!1)}else w([])};return t.useEffect(()=>{if(e.options&&f.current){const t={PayAddress:e.options.PayAddress||"",EpayId:e.options.EpayId||"",EpayKey:e.options.EpayKey||"",Price:void 0!==e.options.Price?parseFloat(e.options.Price):7.3,MinTopUp:void 0!==e.options.MinTopUp?parseFloat(e.options.MinTopUp):1,TopupGroupRatio:e.options.TopupGroupRatio||"",CustomCallbackAddress:e.options.CustomCallbackAddress||"",PayMethods:e.options.PayMethods||"",PayChannelNames:e.options.PayChannelNames||"",SubSiteFollowMainPayment:"false"!==e.options.SubSiteFollowMainPayment?"true":"false",SubSitePayAddress:e.options.SubSitePayAddress||"",SubSiteEpayId:e.options.SubSiteEpayId||"",SubSiteEpayKey:e.options.SubSiteEpayKey||"",ForceHideBepusdt:!0===e.options.ForceHideBepusdt||"true"===e.options.ForceHideBepusdt};x(t),y({...t}),f.current.setValues(t),(async e=>{const t=e.split(",").map(e=>e.trim()).filter(Boolean);if(0===t.length)return void S([]);const n=await Promise.all(t.map(async e=>{try{const t=await ye.get(`/api/user/search?user_id=${e}&page_size=1&p=0`);if(t.data.success&&t.data.data?.items?.length>0){const e=t.data.data.items[0];return{value:e.id,label:`${e.username||e.display_name||i("ç¨æ·")+e.id} (ID: ${e.id})`}}}catch{}return{value:parseInt(e),label:`${i("ç¨æ·")}${e}`}}));S(n)})(e.options.BepusdtHideUserIds||"")}},[e.options]),n.jsx(m,{spinning:s,children:n.jsxs(a,{initValues:p,onValueChange:e=>{x(t=>({...t,...e}))},getFormApi:e=>f.current=e,autoComplete:"off",children:[n.jsxs(a.Section,{text:i("æ¯ä»è®¾ç½®"),children:[n.jsx(es,{children:i("ï¼å½åä»
æ¯æææ¯ä»æ¥å£ï¼é»è®¤ä½¿ç¨ä¸æ¹æå¡å¨å°åä½ä¸ºåè°å°åï¼ï¼")}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"PayAddress",label:i("æ¯ä»å°å"),placeholder:i("ä¾å¦ï¼https://yourdomain.com")})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"EpayId",label:i("ææ¯ä»åæ·ID"),placeholder:i("ä¾å¦ï¼0001"),autoComplete:"off"})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"EpayKey",label:i("ææ¯ä»åæ·å¯é¥"),placeholder:i("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º"),autoComplete:"off",style:b,inputStyle:b})})]}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},style:{marginTop:16},children:[n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"CustomCallbackAddress",label:i("åè°å°å"),placeholder:i("ä¾å¦ï¼https://yourdomain.com")})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"Price",precision:2,label:i("å
å¼ä»·æ ¼ï¼xå
/ç¾éï¼"),placeholder:i("ä¾å¦ï¼7ï¼å°±æ¯7å
/ç¾é")})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"MinTopUp",label:i("æä½å
å¼ç¾å
æ°é"),placeholder:i("ä¾å¦ï¼2ï¼å°±æ¯æä½å
å¼2$")})})]}),n.jsx(a.TextArea,{field:"TopupGroupRatio",label:i("å
å¼åç»åç"),placeholder:i("为ä¸ä¸ª JSON ææ¬ï¼é®ä¸ºç»åç§°ï¼å¼ä¸ºåç"),autosize:!0}),n.jsx(a.TextArea,{field:"PayMethods",label:i("å
弿¹å¼è®¾ç½®"),placeholder:i("为ä¸ä¸ª JSON ææ¬"),autosize:!0}),n.jsx(a.TextArea,{field:"PayChannelNames",label:i("æ¯ä»æ¸ éåç§°æ å°"),placeholder:i('为ä¸ä¸ª JSON 对象ï¼é®ä¸ºæ¸ éIDï¼å¼ä¸ºæ¸ éåç§°ãä¾å¦ï¼{"1": "æ¯ä»å®", "2": "微信æ¯ä»"}'),extraText:i("ç¨äºå¼ç¥¨è®°å½ä¸æ¾ç¤ºæ¯ä»æ¸ éåç§°ï¼ä»
è´¢å¡å¯è§ï¼"),autosize:!0}),n.jsx(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},style:{marginTop:16},children:n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Switch,{field:"ForceHideBepusdt",label:i("强å¶éèèæè´§å¸æ¯ä»"),extraText:i("å¼å¯åï¼ææç¨æ·ï¼å«æµ·å¤IPï¼åä¸ä¼çå°èæè´§å¸æ¯ä»é项")})})}),n.jsx(I,{style:{margin:"16px 0"}}),n.jsxs("div",{style:{padding:16,borderRadius:8,border:"1px solid var(--semi-color-border)",background:"var(--semi-color-fill-0)"},children:[n.jsxs("div",{style:{marginBottom:12},children:[n.jsx(es,{strong:!0,style:{fontSize:14},children:i("USDT éèç¨æ·")}),n.jsx(es,{type:"tertiary",size:"small",style:{display:"block",marginTop:4},children:i("ååå
çç¨æ·å
å¼é¡µä¸æ¾ç¤º USDT / èæè´§å¸æ¯ä»")})]}),n.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[n.jsx(k,{value:R,onChange:P,placeholder:i("è¾å
¥ç¨æ·åæ ID æç´¢"),onEnterPress:()=>M(R),style:{flex:1},showClear:!0}),n.jsx(d,{loading:T,onClick:()=>M(R),children:i("æç´¢")})]}),v.length>0&&n.jsx("div",{style:{border:"1px solid var(--semi-color-border)",borderRadius:6,background:"var(--semi-color-bg-0)",maxHeight:180,overflowY:"auto",marginBottom:12},children:v.map(e=>{const t=_.some(t=>t.value===e.value);return n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderBottom:"1px solid var(--semi-color-border)"},children:[n.jsx(es,{type:t?"tertiary":void 0,children:e.label}),n.jsx(d,{size:"small",theme:t?"borderless":"light",type:t?"tertiary":"primary",disabled:t,onClick:()=>{return t=e,void(t?.value&&(S(e=>e.some(e=>e.value===t.value)?e:[...e,t]),P(""),w([])));var t},children:i(t?"已添å ":"æ·»å ")})]},e.value)})}),n.jsx("div",{style:{marginBottom:8},children:n.jsxs(es,{type:"secondary",size:"small",children:[i("已添å ")," (",_.length,")"]})}),n.jsx("div",{style:{minHeight:56,padding:_.length>0?"10px 12px":0,borderRadius:6,border:"1px dashed var(--semi-color-border)",background:"var(--semi-color-bg-0)",marginBottom:12},children:_.length>0?n.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:_.map(e=>n.jsx(j,{closable:!0,onClose:()=>{return t=e.value,void S(e=>e.filter(e=>e.value!==t));var t},color:"blue",size:"large",children:e.label},e.value))}):n.jsx(C,{image:C.PRESENTED_IMAGE_SIMPLE,description:i("ææ ç¨æ·ï¼è¯·æç´¢åæ·»å "),style:{padding:"12px 0"}})}),n.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:n.jsx(d,{loading:z,onClick:async()=>{N(!0);try{const t=_.map(e=>e.value).join(","),n=await ye.put("/api/option/",{key:"BepusdtHideUserIds",value:t});n.data.success?(be(i("é»ååä¿åæå")),e.refresh&&e.refresh()):je(n.data.message)}catch{je(i("é»ååä¿å失败"))}N(!1)},type:"primary",children:i("ä¿ååå")})})]})]}),n.jsxs(a.Section,{text:i("åç«æ¯ä»é
ç½®"),children:[n.jsx(h,{type:"info",description:i('为ææåç«ç»ä¸é
ç½®æ¯ä»ç½å
³ã
1éæ©"è·é主ç«"ååç«ä½¿ç¨ä¸æ¹çä¸»ç«æ¯ä»é
ç½®ï¼éæ©"ç¬ç«é
ç½®"ååç«ä½¿ç¨ä¸æ¹çä¸ç¨æ¯ä»é
ç½®ã'),style:{marginBottom:16}}),n.jsx(h,{type:"warning",description:i("忢æ¯ä»é
ç½®åï¼è¯·ä¿çæ§çåæ·IDåå¯é¥é
ç½®ï¼ç´å°æææ§è®¢åå¤ç宿¯ãç³»ç»ä¼æ ¹æ®è®¢åçåæ·IDèªå¨å¹é
对åºå¯é¥éªç¾ï¼æ¸
空æ§é
ç½®ä¼å¯¼è´æªåè°çæ§è®¢åéªç¾å¤±è´¥ã"),style:{marginBottom:16}}),n.jsxs(a.RadioGroup,{field:"SubSiteFollowMainPayment",label:i("åç«æ¯ä»æ¨¡å¼"),onChange:e=>x(t=>({...t,SubSiteFollowMainPayment:e.target.value})),children:[n.jsx(a.Radio,{value:"true",children:i("è·é主ç«é
ç½®")}),n.jsx(a.Radio,{value:"false",children:i("使ç¨ç¬ç«é
ç½®")})]}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},style:{marginTop:8,display:"false"===p.SubSiteFollowMainPayment?"flex":"none"},children:[n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"SubSitePayAddress",label:i("åç«æ¯ä»å°å"),placeholder:i("ä¾å¦ï¼https://yourdomain.com")})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"SubSiteEpayId",label:i("åç«ææ¯ä»åæ·ID"),placeholder:i("ä¾å¦ï¼0001"),autoComplete:"off"})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"SubSiteEpayKey",label:i("åç«ææ¯ä»åæ·å¯é¥"),placeholder:i("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º"),autoComplete:"off",style:b,inputStyle:b})})]})]}),n.jsxs("div",{style:{display:"flex",gap:12,marginTop:16,flexWrap:"wrap"},children:[n.jsx(d,{onClick:async()=>{if(""!==e.options.ServerAddress)if(g.TopupGroupRatio===p.TopupGroupRatio||Re(p.TopupGroupRatio))if(g.PayMethods===p.PayMethods||Re(p.PayMethods))if(g.PayChannelNames===p.PayChannelNames||!p.PayChannelNames||Re(p.PayChannelNames)){l(!0);try{const t=[{key:"PayAddress",value:fe(p.PayAddress)}];""!==p.EpayId&&t.push({key:"EpayId",value:p.EpayId}),void 0!==p.EpayKey&&""!==p.EpayKey&&t.push({key:"EpayKey",value:p.EpayKey}),""!==p.Price&&t.push({key:"Price",value:p.Price.toString()}),""!==p.MinTopUp&&t.push({key:"MinTopUp",value:p.MinTopUp.toString()}),""!==p.CustomCallbackAddress&&t.push({key:"CustomCallbackAddress",value:p.CustomCallbackAddress}),g.TopupGroupRatio!==p.TopupGroupRatio&&t.push({key:"TopupGroupRatio",value:p.TopupGroupRatio}),g.PayMethods!==p.PayMethods&&t.push({key:"PayMethods",value:p.PayMethods}),g.PayChannelNames!==p.PayChannelNames&&t.push({key:"PayChannelNames",value:p.PayChannelNames||"{}"}),t.push({key:"ForceHideBepusdt",value:p.ForceHideBepusdt?"true":"false"}),t.push({key:"SubSiteFollowMainPayment",value:p.SubSiteFollowMainPayment}),"false"===p.SubSiteFollowMainPayment&&(t.push({key:"SubSitePayAddress",value:fe(p.SubSitePayAddress)}),""!==p.SubSiteEpayId&&t.push({key:"SubSiteEpayId",value:p.SubSiteEpayId}),void 0!==p.SubSiteEpayKey&&""!==p.SubSiteEpayKey&&t.push({key:"SubSiteEpayKey",value:p.SubSiteEpayKey}));const n=t.map(e=>ye.put("/api/option/",{key:e.key,value:e.value})),s=(await Promise.all(n)).filter(e=>!e.data.success);s.length>0?s.forEach(e=>{je(e.data.message)}):(be(i("æ´æ°æå")),y({...p}),e.refresh&&e.refresh())}catch(t){je(i("æ´æ°å¤±è´¥"))}l(!1)}else je(i("æ¯ä»æ¸ éåç§°æ å°ä¸æ¯åæ³ç JSON å符串"));else je(i("å
弿¹å¼è®¾ç½®ä¸æ¯åæ³ç JSON å符串"));else je(i("å
å¼åç»åç䏿¯åæ³ç JSON å符串"));else je(i("请å
å¡«åæå¡å¨å°å"))},children:i("æ´æ°æ¯ä»è®¾ç½®")}),n.jsx(d,{onClick:async()=>{u(!0);try{const e=await ye.post("/api/option/admin/reload-geoip");e.data.success?be(e.data.data?.message||i("GeoIP æ°æ®åºæ´æ°æå")):je(e.data.message||i("GeoIP æ°æ®åºæ´æ°å¤±è´¥"))}catch{je(i("GeoIP æ°æ®åºæ´æ°å¤±è´¥"))}u(!1)},loading:r,theme:"light",type:"secondary",children:i("æ´æ° GeoIP æ°æ®åº")})]})]})})}const{Text:ns}=u;function is(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({StripeApiSecret:"",StripeWebhookSecret:"",StripePriceId:"",StripeProductPrice:.01,StripeExchangeRate:1.1,StripeMinTopUp:1}),[p,x]=t.useState({}),g=t.useRef(null);return t.useEffect(()=>{if(e.options&&g.current){const t={StripeApiSecret:e.options.StripeApiSecret||"",StripeWebhookSecret:e.options.StripeWebhookSecret||"",StripePriceId:e.options.StripePriceId||"",StripeProductPrice:void 0!==e.options.StripeProductPrice?parseFloat(e.options.StripeProductPrice):.01,StripeExchangeRate:void 0!==e.options.StripeExchangeRate?parseFloat(e.options.StripeExchangeRate):1.1,StripeMinTopUp:void 0!==e.options.StripeMinTopUp?parseFloat(e.options.StripeMinTopUp):1};u(t),x({...t}),g.current.setValues(t)}},[e.options]),n.jsx(m,{spinning:s,children:n.jsx(a,{initValues:r,onValueChange:e=>{u(e)},getFormApi:e=>g.current=e,children:n.jsxs(a.Section,{text:i("Stripe 设置"),children:[n.jsxs(ns,{children:[n.jsx(ln,{i18nKey:"stripe_setup_description",components:{dashboardLink:n.jsx("a",{href:"https://dashboard.stripe.com/developers",target:"_blank",rel:"noreferrer"}),testLink:n.jsx("a",{href:"https://dashboard.stripe.com/test/developers",target:"_blank",rel:"noreferrer"})}}),n.jsx("br",{})]}),n.jsx(h,{type:"info",description:i("stripe_webhook_url_hint",{url:e.options.ServerAddress?fe(e.options.ServerAddress):i("ç½ç«å°å")})}),n.jsx(h,{type:"warning",description:i("stripe_webhook_events_hint")}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"StripeApiSecret",label:i("API å¯é¥"),placeholder:i("sk_xxx æ rk_xxx ç Stripe å¯é¥ï¼ææä¿¡æ¯ä¸æ¾ç¤º"),type:"password"})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"StripeWebhookSecret",label:i("Webhook ç¾åå¯é¥"),placeholder:i("whsec_xxx ç Webhook ç¾åå¯é¥ï¼ææä¿¡æ¯ä¸æ¾ç¤º"),type:"password"})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"StripePriceId",label:i("ååä»·æ ¼ ID"),placeholder:i("price_xxx çååä»·æ ¼ IDï¼æ°å»ºäº§ååå¯è·å¾")})})]}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},style:{marginTop:16},children:[n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"StripeProductPrice",precision:3,label:i("Stripeåååä»·ï¼æ¸¯å
ï¼"),placeholder:i("ä¾å¦ï¼0.01ï¼å³HK$0.01")})}),n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"StripeExchangeRate",precision:3,label:i("人æ°å¸è½¬æ¸¯å
æ±ç"),placeholder:i("ä¾å¦ï¼1.10ï¼å³1å
=1.10港å
")})})]}),n.jsx(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},style:{marginTop:16},children:n.jsx(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"StripeMinTopUp",label:i("æä½å
å¼é¢åº¦æ°é"),placeholder:i("ä¾å¦ï¼1ï¼æä½å
å¼1个é¢åº¦")})})}),n.jsx(d,{onClick:async()=>
1{if(""!==e.options.ServerAddress){l(!0);try{const t=[];r.StripeApiSecret&&""!==r.StripeApiSecret&&t.push({key:"StripeApiSecret",value:r.StripeApiSecret}),r.StripeWebhookSecret&&""!==r.StripeWebhookSecret&&t.push({key:"StripeWebhookSecret",value:r.StripeWebhookSecret}),""!==r.StripePriceId&&t.push({key:"StripePriceId",value:r.StripePriceId}),void 0!==r.StripeProductPrice&&null!==r.StripeProductPrice&&t.push({key:"StripeProductPrice",value:r.StripeProductPrice.toString()}),void 0!==r.StripeExchangeRate&&null!==r.StripeExchangeRate&&t.push({key:"StripeExchangeRate",value:r.StripeExchangeRate.toString()}),void 0!==r.StripeMinTopUp&&null!==r.StripeMinTopUp&&t.push({key:"StripeMinTopUp",value:r.StripeMinTopUp.toString()});const n=t.map(e=>ye.put("/api/option/",{key:e.key,value:e.value})),s=(await Promise.all(n)).filter(e=>!e.data.success);s.length>0?s.forEach(e=>{je(e.data.message)}):(be(i("æ´æ°æå")),x({...r}),e.refresh?.())}catch(t){je(i("æ´æ°å¤±è´¥"))}l(!1)}else je(i("请å
å¡«åæå¡å¨å°å"))},children:i("æ´æ° Stripe 设置")})]})})})}const ss=()=>{const{t:e}=ge();let[i,s]=t.useState({ServerAddress:"",PayAddress:"",EpayId:"",EpayKey:"",Price:7.3,MinTopUp:1,TopupGroupRatio:"",CustomCallbackAddress:"",PayMethods:"",StripeApiSecret:"",StripeWebhookSecret:"",StripePriceId:"",StripeProductPrice:.01,StripeExchangeRate:1.1,StripeMinTopUp:1}),[l,a]=t.useState(!1);async function o(){try{a(!0),await(async()=>{const t=await ye.get("/api/option/"),{success:n,message:i,data:l}=t.data;if(n){let e={};l.forEach(t=>{switch(t.key){case"TopupGroupRatio":try{e[t.key]=JSON.stringify(JSON.parse(t.value),null,2)}catch(n){console.error("è§£æTopupGroupRatioåºé:",n),e[t.key]=t.value}break;case"Price":case"MinTopUp":case"StripeProductPrice":case"StripeExchangeRate":case"StripeMinTopUp":e[t.key]=parseFloat(t.value);break;case"ForceHideBepusdt":e[t.key]=an(t.value);break;
1default:t.key.endsWith("Enabled")?e[t.key]=an(t.value):e[t.key]=t.value}}),s(e)}else je(e(i))})()}catch(t){je(e("å·æ°å¤±è´¥"))}finally{a(!1)}}return t.useEffect(()=>{o()},[]),n.jsx(n.Fragment,{children:n.jsxs(m,{spinning:l,size:"large",children:[n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(Zi,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(ts,{options:i,refresh:o})}),n.jsx(r,{style:{marginTop:"10px"},children:n.jsx(is,{options:i,refresh:o})})]})})},{Text:ls}=u,as=()=>{const e=G(),t=e?.values?.agent_domain||"",s=i.useMemo(()=>{if(!t)return[];if("string"==typeof t&&t.trim()){return t.split(",").map(e=>e.trim()).filter(e=>""!==e)}return[]},[t]);return n.jsx("div",{style:{marginBottom:16},children:s.length>0?n.jsxs("div",{style:{marginBottom:12},children:[n.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:8,padding:12,backgroundColor:"#f8f9fa",borderRadius:6,border:"1px solid #e9ecef"},children:s.map((e,t)=>n.jsxs(j,{color:"blue",style:{cursor:"pointer",transition:"all 0.2s ease",padding:"4px 8px",margin:0},onClick:()=>(async e=>{const t=`https://${e}`;try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(t),y.success({content:`å·²å¤å¶: ${t}`,duration:2});else{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy")?y.success({content:`å·²å¤å¶: ${t}`,duration:2}):y.error({content:"å¤å¶å¤±è´¥ï¼è¯·æå¨å¤å¶",duration:3}),document.body.removeChild(e)}}catch(n){console.error("å¤å¶å¤±è´¥:",n),y.error({content:"å¤å¶å¤±è´¥ï¼è¯·æå¨å¤å¶",duration:3})}})(e),title:`ç¹å»å¤å¶: https://${e}`,children:[n.jsx(gt,{style:{marginRight:4},size:12}),e,n.jsx(yt,{style:{marginLeft:4,opacity:.6},size:12})]},t))}),n.jsxs(ls,{style:{fontSize:12,color:"#6c757d"},children:["ð¡ å
±é
ç½® ",s.length," 个æå¡å¨ååï¼ç¹å»ååå¯å¤å¶å®æ´URL"]})]}):n.jsx("div",{style:{padding:16,backgroundColor:"#f8f9fa",borderRadius:6,textAlign:"center",border:"1px solid #e9ecef"},children:n.jsx(ls,{type:"tertiary",style:{fontSize:14},children:e?.values?"ææ é
ç½®åå":"æ£å¨å è½½é
ç½®..."})})})},rs={headerGradientFrom:"#53ACFF",headerGradientTo:"#0084FF"},os=({label:e,color:t,onChange:i})=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[n.jsx("input",{type:"color",value:t||"#FFFFFF",onChange:e=>i(e.target.value),style:{width:36,height:36,border:"2px solid #e9ecef",borderRadius:8,padding:2,cursor:"pointer",background:"transparent"}}),n.jsx("div",{style:{flex:1},children:n.jsx(ls,{style:{fontSize:13,fontWeight:500},children:e})}),n.jsx(k,{value:t||"",onChange:e=>i(e),placeholder:"#FFFFFF",style:{width:100,fontFamily:"monospace",fontSize:12},size:"small"})]}),cs=()=>{const{t:e}=ge(),[i,s]=t.useContext(Te),[l,u]=t.useState(!1),[p,x]=t.useState({system_name:"",system_name_en:"",logo:"",url:"",home_url:"",notice:"",agent_domain:"",domain_restricted:!1,rate:"",agent_price:"",sale_price:"",invite_reward_enabled:!1,invite_reward_rate:10,checkin_enabled:!1,enable_topup_sections:!0,enable_invite_reward_section:!0,enable_topup_records_section:!0,enable_withdrawal_records_section:!0,custom_menu_links:"",header_color_config:""}),[g,y]=t.useState({...rs}),[j,f]=t.useState(p),b=t.useRef(),[_,S]=t.useState([]),[v,C]=t.useState("template"),[w,T]=t.useState(!1);function I(e){return t=>{x(n=>({...n,[e]:t}))}}const E=(e,t,n)=>{const i=[..._];i[e]={...i[e],[t]:n},S(i)};return t.useEffect(()=>{(async()=>{try{const t=await ye.get("/api/option/getagentoptions"),{success:n,message:i,data:s}=t.data;if(n){const t={};for(let e in s)Object.keys(p).includes(e)&&(t[e]=s[e]);if(x(t),f(structuredClone(t)),t.custom_menu_links)try{const e=JSON.parse(t.custom_menu_links);S(Array.isArray(e)?e:[])}catch(e){console.error("è§£æèªå®ä¹èå龿¥å¤±è´¥:",e),S([])}else S([]);if(t.header_color_config)try{const e=JSON.parse(t.header_color_config);y({...rs,...e})}catch(e){console.error("è§£æåºåè²åé
置失败:",e),y({...rs})}else y({...rs});b.current&&b.current.setValues(t)}else je(i)}catch(t){je(t.message)}})()},[]),t.useEffect(()=>{if(!w&&p&&void 0!==p.home_url){const t=(e=p.home_url)&&""!==e?/^\d+$/.test(e)?"template":(/<[^>]+>/.test(e)||e.startsWith("https://"),"custom"):"template";C(e=>t!==e?t:e)}var e},[p?.home_url,w]),n.jsx(m,{spinning:l,children:n.jsxs(a,{values:p,getFormApi:e=>b.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:e("åºç¡è®¾ç½®"),children:[n.jsxs(o,{gutter:{xs:8,sm:12,md:16,lg:24,xl:24},children:[n.jsx(c,{xs:24,sm:12,md:12,lg:6,xl:6,children:n.jsx(a.Input,{field:"system_name",label:e("ç³»ç»åç§°"),placeholder:e("请è¾å
¥ç³»ç»åç§°ï¼å¦ï¼æçAPIæå¡"),extraText:e("å°æ¾ç¤ºå¨ç½ç«æ é¢åå¯¼èªæ ä¸"),onChange:I("system_name"),showClear:!0,rules:[{required:!0,message:e("ç³»ç»åç§°ä¸è½ä¸ºç©º")},{type:"string",min:2,max:50,message:e("ç³»ç»åç§°é¿åº¦åºå¨2-50个å符ä¹é´")}]})}),n.jsx(c,{xs:24,sm:12,md:12,lg:6,xl:6,children:n.jsx(a.Input,{field:"system_name_en",label:e("ç³»ç»åç§°ï¼è±æï¼"),placeholder:e("请è¾å
¥è±æç³»ç»åç§°ï¼å¦ï¼My API Service"),extraText:e("è±æç¯å¢ä¸æ¾ç¤ºå¨ç½ç«æ é¢åå¯¼èªæ ä¸"),onChange:I("system_name_en"),showClear:!0,rules:[{type:"string",min:2,max:50,message:e("ç³»ç»åç§°é¿åº¦åºå¨2-50个å符ä¹é´")}]})}),n.jsx(c,{xs:24,sm:12,md:12,lg:6,xl:6,children:n.jsx(a.Input,{field:"logo",label:e("LOGO"),placeholder:e("请è¾å
¥logoç½åï¼å¦ï¼https://example.com/logo.png"),onChange:I("logo"),showClear:!0})}),n.jsx(c,{xs:24,sm:12,md:12,lg:6,xl:6,children:n.jsx(a.Input,{field:"url",label:e("æç¨ææ¡£ç½å"),placeholder:e("请è¾å
¥æç¨ææ¡£ç½åï¼å¦ï¼https://docs.example.com"),extraText:e("ç¨æ·ç¹å»å¸®å©æé®æ¶å°è·³è½¬å°æ¤å°å"),onChange:I("url"),showClear:!0,validate:t=>t&&t.trim()&&!/^https?:\/\/.+/.test(t.trim())?e("请è¾å
¥ææçç½åï¼é以 http:// æ https:// å¼å¤´"):""})})]}),n.jsxs("div",{style:{marginTop:24},children:[n.jsx(ls,{strong:!0,style:{fontSize:14,display:"block",marginBottom:12},children:e("å³ä¸è§åºåè²åèªå®ä¹")}),n.jsx(ls,{type:"tertiary",style:{display:"block",marginBottom:16,fontSize:13},children:e("èªå®ä¹æ§å¶å°æ 颿 çæ¸åè²æ¹æ¡")}),n.jsxs(r,{title:e("æ 颿 æ¸åè²"),style:{marginBottom:16},headerStyle:{padding:"12px 16px"},bodyStyle:{padding:16},children:[n.jsx(os,{label:e("æ§å¶å°æ 颿 - æ¸åèµ·å§è²"),color:g.headerGradientFrom,onChange:e=>y(t=>({...t,headerGradientFrom:e}))}),n.jsx(os,{label:e("æ§å¶å°æ 颿 - æ¸åç»æè²"),color:g.headerGradientTo,onChange:e=>y(t=>({...t,headerGradientTo:e}))}),n.jsxs("div",{style:{marginTop:16},children:[n.jsx(ls,{style:{fontSize:13,fontWeight:500,marginBottom:8,display:"block"},children:e("æ¸åé¢è§")}),n.jsx("div",{style:{height:48,borderRadius:8,background:`linear-gradient(to right, ${g.headerGradientFrom||"#53ACFF"}, ${g.headerGradientTo||"#0084FF"})`,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontWeight:600,fontSize:14,letterSpacing:1},children:e("æ 颿 æ¸åææé¢è§")})]})]}),n.jsx(d,{type:"tertiary",size:"small",onClick:()=>y({...rs}),style:{marginBottom:8},children:e("æ¢å¤é»è®¤é¢è²")})]})]}),n.jsxs(a.Section,{text:e("é¦é¡µè®¾ç½®"),children:[n.jsx(o,{gutter:16,children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{marginBottom:16},children:[n.jsx("label",{style:{display:"block",marginBottom:8,fontWeight:600,fontSize:14,color:"hsl(var(--foreground))"},children:e("é¦é¡µæ¾ç¤ºæ¨¡å¼")}
1),n.jsxs(L,{value:v,onChange:e=>{const t=e.target.value;C(t),T(!0),I("home_url")("")},direction:"vertical",style:{width:"100%"},children:[n.jsx(B,{value:"template",children:n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:500},children:e("宿¹æ¨¡æ¿æ¨¡å¼")}),n.jsx("div",{style:{fontSize:12,color:"hsl(var(--muted-foreground))",marginTop:4},children:e("使ç¨ç³»ç»å
ç½®çç²¾ç¾æ¨¡æ¿ï¼å¿«éé
ç½®ï¼å¼ç®±å³ç¨")})]})}),n.jsx(B,{value:"custom",children:n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:500},children:e("èªå®ä¹æ¨¡å¼")}),n.jsx("div",{style:{fontSize:12,color:"hsl(var(--muted-foreground))",marginTop:4},children:e("å®å
¨èªå®ä¹é¦é¡µå
å®¹ï¼æ¯æHTML/CSSï¼å®å
¨å¯é ")})]})})]})]})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{span:24,children:"template"===v?n.jsxs(n.Fragment,{children:[n.jsx(a.Select,{field:"home_url",label:e("éæ©é¦é¡µæ¨¡æ¿"),style:{width:"100%"},placeholder:e("è¯·éæ©é¦é¡µæ¨¡æ¿"),onChange:I("home_url"),optionList:[{value:"",label:e("é»è®¤æ¨¡æ¿ - 模æ¿1")},...Mt()]}),n.jsx(h,{type:"info",icon:n.jsx(mt,{size:16}),description:e('宿¹æ¨¡æ¿æ¨¡å¼ï¼éæ©æ¨¡æ¿åï¼home_urlåæ®µå°å卿¨¡æ¿IDï¼å¦"1","2","3"çï¼'),style:{marginBottom:16}})]}):n.jsxs(n.Fragment,{children:[n.jsx(a.TextArea,{field:"home_url",label:e("èªå®ä¹é¦é¡µå
容"),placeholder:e("请è¾å
¥èªå®ä¹é¦é¡µå
å®¹ï¼æ¯æHTMLãCSSï¼..."),autosize:{minRows:10,maxRows:25},style:{fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace'},onChange:I("home_url")}),n.jsx(h,{type:"info",icon:n.jsx(mt,{size:16}),description:n.jsxs("div",{children:[n.jsx("div",{style:{marginBottom:12},children:e("åºç¡ç¤ºä¾ä»£ç ï¼å¯å¤å¶ï¼ï¼")}),n.jsx("div",{style:{background:"#f8f9fa",padding:"12px",borderRadius:"6px",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',fontSize:"12px",lineHeight:"1.4",border:"1px solid #e9ecef",whiteSpace:"pre-wrap",userSelect:"text",cursor:"text"},children:'<style>\n .welcome {\n text-align: center;\n padding: 50px;\n margin-top: 80px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n border-radius: 12px;\n box-shadow: 0 10px 30px rgba(0,0,0,0.2);\n }\n</style>\n<div class="welcome">\n <h1>欢è¿ä½¿ç¨æçAPIæå¡</h1>\n <p>è¿éæ¯èªå®ä¹å
容...</p>\n</div>'}),n.jsx("div",{style:{marginTop:16,marginBottom:12},children:n.jsx("strong",{children:e("å¤è¯è¨éé
示ä¾ï¼çº¯CSSå®ç°ï¼ï¼")})}),n.jsx("div",{style:{background:"#f8f9fa",padding:"12px",borderRadius:"6px",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',fontSize:"12px",lineHeight:"1.4",border:"1px solid #e9ecef",whiteSpace:"pre-wrap",userSelect:"text",cursor:"text"},children:'<style>\n /* é»è®¤éèææè¯è¨ */\n .lang { display: none; }\n \n /* æ ¹æ® data-lang-main 屿§æ¾ç¤ºå¯¹åºè¯è¨ */\n [data-lang-main="zh"] .lang-zh,\n [data-lang-main="en"] .lang-en,\n [data-lang-main="ru"] .lang-ru,\n [data-lang-main="ko"] .lang-ko,\n [data-lang-main="ja"] .lang-ja,\n [data-lang-main="es"] .lang-es,\n [data-lang-main="de"] .lang-de {\n display: block;\n }\n \n .welcome {\n text-align: center;\n padding: 50px;\n margin-top: 80px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n border-radius: 12px;\n }\n</style>\n\n<div class="welcome">\n \x3c!-- 䏿å
容 --\x3e\n <div class="lang lang-zh">\n <h1>欢è¿ä½¿ç¨æçAPIæå¡</h1>\n <p>è¿æ¯èªå®ä¹çå¤è¯è¨å
容</p>\n </div>\n \n \x3c!-- è±æå
容 --\x3e\n <div class="lang lang-en">\n <h1>Welcome to My API Service</h1>\n <p>This is custom multilingual content</p>\n </div>\n \n \x3c!-- æ¥æå
容 --\x3e\n <div class="lang lang-ja">\n <h1>APIãµã¼ãã¹ã¸ãããã</h1>\n <p>ããã¯ã«ã¹ã¿ã å¤è¨èªã³ã³ãã³ãã§ã</p>\n </div>\n \n \x3c!-- 驿å
容 --\x3e\n <div class="lang lang-ko">\n <h1>API ìë¹ì¤ì ì¤ì ê²ì íìí©ëë¤</h1>\n <p>ì¬ì©ì ì ì ë¤êµì´ ì½í
ì¸ ì
ëë¤</p>\n </div>\n</div>'}),n.jsxs("div",{style:{marginTop:12,fontSize:"12px",color:"#6c757d"},children:[n.jsx("div",{children:n.jsx("strong",{children:e("æ¯æçè¯è¨ä»£ç ï¼")})}),n.jsx("div",{children:"zh (䏿) | en (English) | ru (Ð ÑÑÑкий) | ko (íêµì´) | ja (æ¥æ¬èª) | es (Español) | de (Deutsch)"})]})]}),style:{marginBottom:12}}),n.jsx(h,{type:"warning",icon:n.jsx(mt,{size:16}),description:n.jsxs("div",{children:[n.jsx("div",{children:e("èªå®ä¹æ¨¡å¼æ³¨æäºé¡¹ï¼")}),n.jsxs("ul",{style:{margin:"8px 0",paddingLeft:"20px"},children:[n.jsx("li",{children:e("home_urlåæ®µå°åå¨å®æ´çHTML/CSS代ç ")}),n.jsx("li",{children:e("æ¯æå®æ´çHTMLãCSS代ç ")}),n.jsx("li",{children:e("䏿¯æJavaScript代ç ï¼ææscriptæ ç¾åäºä»¶å±æ§å°è¢«èªå¨ç§»é¤")}),n.jsx("li",{children:e("å¯ä»¥ä½¿ç¨å
èCSSï¼<style>æ ç¾ï¼åå¤é¨CSS龿¥ï¼<link>æ ç¾ï¼")}),n.jsxs("li",{children:[n.jsx("strong",{children:e("æ¯æå¤è¯è¨éé
")}),e("ï¼ç³»ç»ä¼èªå¨æ·»å data-lang å data-lang-main 屿§ï¼å¯éè¿çº¯CSSå®ç°å¤è¯è¨åæ¢")]}),n.jsx("li",{children:e("建议æµè¯ä»£ç å
¼å®¹æ§ï¼ç¡®ä¿å¨ä¸å设å¤ä¸æ£å¸¸æ¾ç¤º")})]})]}),style:{marginBottom:16}})]})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{span:24,children:n.jsx(a.TextArea,{field:"notice",label:e("ç³»ç»å
¬å"),placeholder:e("请è¾å
¥ç³»ç»å
¬åï¼æ¯æHTMLæ ¼å¼..."),extraText:e("æ¯æHTMLæ ç¾ï¼
1å°æ¾ç¤ºå¨é¦é¡µé¡¶é¨å
¬åæ "),autosize:{minRows:3,maxRows:6},onChange:I("notice"),validate:t=>t&&t.length>1e5?e("ç³»ç»å
¬åå
容ä¸è½è¶
è¿1000个å符"):""})})})]}),n.jsxs(a.Section,{text:e("æå¡å¨è®¾ç½®"),children:[n.jsx(a.Input,{field:"agent_domain",allowEmptyString:!0,style:{display:"none"}}),n.jsx(o,{gutter:16,children:n.jsx(c,{span:24,children:n.jsxs(a.Slot,{label:{text:e("æå¡å¨å°å")},children:[n.jsx(as,{}),n.jsx(ls,{style:{fontSize:12,color:"#6c757d",marginTop:4},children:e("ç¨æ·å¯éè¿è¿äºåå访é®APIæå¡ï¼åªè¯»æ¾ç¤ºï¼")})]})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"domain_restricted",label:e("éå¶åå访é®"),extraText:e("å¯ç¨åï¼åªæä»£çæä¸çç¨æ·æè½éè¿æ¤åå访é®APIæå¡"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:I("domain_restricted")})})})]}),n.jsx(a.Section,{text:e("å
å¼é¡µé¢æ¾ç¤ºè®¾ç½®"),children:n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"enable_topup_sections",label:e("æ¾ç¤ºå
å¼ååº"),extraText:e('æ§å¶å
å¼é¡µé¢ç"å
å¼ç±»å"ã"éæ©å
å¼éé¢"ã"å
弿°é"ã"éæ©æ¯ä»æ¹å¼"çå
å¼ç¸å
³ååºçæ¾ç¤º'),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:I("enable_topup_sections")})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"enable_invite_reward_section",label:e("æ¾ç¤ºé请å¥å±æ¨¡å"),extraText:e('æ§å¶å
å¼é¡µé¢ç"é请å¥å±"æ¨¡åæ¾ç¤ºï¼å
æ¬éè¯·é¾æ¥ãé请ç ãé请å¥å±ä½é¢çä¿¡æ¯'),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:I("enable_invite_reward_section")})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"enable_topup_records_section",label:e("æ¾ç¤ºå
å¼è®°å½"),extraText:e('æ§å¶å
å¼é¡µé¢ç"å
å¼è®°å½"æ ç¾é¡µæ¾ç¤ºï¼ç¨æ·å¯æ¥çåå²å
å¼è®¢å'),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:I("enable_topup_records_section")})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"enable_withdrawal_records_section",label:e("æ¾ç¤ºæç°è®°å½"),extraText:e('æ§å¶å
å¼é¡µé¢ç"æç°è®°å½"æ ç¾é¡µæ¾ç¤ºï¼ç¨æ·å¯æ¥çæç°ç³è¯·åå¤çç¶æ'),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:I("enable_withdrawal_records_section")})})]})}),n.jsx(a.Section,{text:e("ç¾å°åè½è®¾ç½®"),children:n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"checkin_enabled",label:e("å¯ç¨æä¸ç¨æ·ç¾å°"),extraText:e("å¯ç¨åï¼æä¸ç¨æ·æ¯æ¥å¯ç¾å°é¢åä½é¢ï¼ç¾å°éé¢èå´ç±ä¸»ç«ç»ä¸é
ç½®"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:I("checkin_enabled")})})})}),n.jsx(a.Section,{text:e("é请å¥å±åè½è®¾ç½®"),children:n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"invite_reward_enabled",label:e("å¯ç¨é请å¥å±åè½"),extraText:e("å¯ç¨åï¼ç¨æ·éè¿éè¯·é¾æ¥æ³¨åçæ°ç¨æ·äº§çæ¶è´¹æ¶ï¼é请人å¯è·å¾ç¸åºæ¯ä¾çå¥å±éé¢"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:I("invite_reward_enabled")})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"invite_reward_rate",label:e("é请å¥å±æ¯ä¾"),initValue:10,placeholder:e("请è¾å
¥é请å¥å±æ¯ä¾"),extraText:e("设置é请人å¯è·å¾è¢«é请人æ¶è´¹éé¢çå¥å±ç¾åæ¯ï¼èå´1%-10%"),suffix:"%",min:1,max:10,precision:1,step:.5,style:{width:"100%"},onChange:I("invite_reward_rate"),validate:t=>{if(t<1||t>10)return e("å¥å±æ¯ä¾å¿
é¡»å¨1-10ä¹é´")}})})]})}),n.jsxs(a.Section,{text:e("èªå®ä¹èå龿¥"),children:[n.jsx(ls,{type:"tertiary",style:{display:"block",marginBottom:16},children:e("æ·»å èªå®ä¹èå龿¥ï¼å°å¨é¡¶é¨å¯¼èªæ åä¾§è¾¹æ 䏿¾ç¤ºï¼ç¹å»åè·³è½¬å°æå®å°å")}),_.map((t,i)=>n.jsx(r,{style:{marginBottom:16},title:`${e("龿¥")} ${i+1}`,headerExtraContent:n.jsx(d,{type:"danger",theme:"borderless",icon:n.jsx(He,{size:16}),onClick:()=>(e=>{const t=[..._];t.splice(e,1),S(t)})(i),children:e("å é¤")}),children:n.jsxs(o,{gutter:16,children:[n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx(ls,{strong:!0,children:e("åç§°")}),n.jsx(ls,{type:"tertiary",style:{marginLeft:8},children:e("æ¾ç¤ºå¨èåä¸çåç§°")})]}),n.jsx(k,{value:t.name,onChange:e=>E(i,"name",e),placeholder:e("ä¾å¦ï¼å¸®å©ä¸å¿"),style:{width:"100%"}})]}),n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx(ls,{strong:!0,children:e("龿¥å°å")}),n.jsx(ls,{type:"tertiary",style:{marginLeft:8},children:e("ç¹å»å跳转çURL")})]}),n.jsx(k,{value:t.url,onChange:e=>E(i,"url",e),placeholder:e("ä¾å¦ï¼https://help.example.com"),style:{width:"100%"}})]})]})},i)),n.jsx(d,{icon:n.jsx(Ye,{size:16}),onClick:()=>{S([..._,{name:"",url:""}])},style:{marginBottom:16},children:e("æ·»å 龿¥")})]}),n.jsx(o,{children:n.jsx(c,{children:n.jsx(d,{type:"primary",size:"default",onClick:function(){for(let n=0;n<_.length;n++){const t=_[n];if(!t.name||""===t.name.trim())return void je(e("èªå®ä¹èå龿¥")+` ${n+1}: `+e("åç§°ä¸è½ä¸ºç©º"));if(!t.url||""===t.url.trim())return void je(e("èªå®ä¹èå龿¥")+` ${n+1}: `+e("龿¥å°åä¸è½ä¸ºç©º"))}u(!0);try{const t={...p};""!==p.sale_price&&void 0!==p.sale_price&&null!==p.sale_price?t.sale_price=parseFloat(p.sale_price):delete t.sale_price,""!==p.invite_reward_rate&&void 0!==p.invite_reward_rate&&null!==p.invite_reward_rate?t.invite_reward_rate=parseFloat(p.invite_reward_rate):delete t.invite_reward_rate,t.custom_menu_links=JSON.stringify(_),t.header_color_config=JSON.stringify(g),ye.post("/api/option/updateagentoption",t).then(async n=>{const{success:i,message:l}=n.data;if(i){be(e("ä¿åæå")),f(structuredClone(t)),x(t);try{const e=await ye.get("/api/status");e?.data?.success&&s({type:"set",payload:e.data.data})}catch(a){}}else je(l||e("ä¿å失败"))}).catch(t=>{je(t.message||e("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{u(!1)})}catch(t){je(t.message||e("æäº¤æ¶åçé误")),u(!1)}},children:e("ä¿ååºç¡è®¾ç½®")})})})]})})},{Text:ds}=u,us=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,r]=t.useState({seo_title:"",keywords:"",description:"",statistics_code:"",baidu_ocpc_token:"",footer:"",seo_page_configs:""}),[u,p]=t.useState(l),g=t.useRef(),[y,f]=t.useState([]),[b,_]=t.useState(!1),[S,k]=t.useState({path:"",title:"",description:"",keywords:""}),[C,w]=t.useState(-1);function T(e){return t=>{r(n=>({...n,[e]:t}))}}const I=(e,t)=>{k({...S,[e]:t})};t.useEffect(()=>{(async()=>{try{const t=await ye.get("/api/option/getagentoptions"),{success:n,message:i,data:s}=t.data;if(n){const t={};for(let e in s)Object.keys(l).includes(e)&&(t[e]=s[e]);r(t),p(structuredClone(t));try{if(s.seo_page_configs){const e=JSON.parse(s.seo_page_configs||"[]");f(e)}}catch(e){f([])}g.current&&g.current.setValues(t)}else je(i)}catch(t){je(t.message)}})()},[]);const E=[{title:e("页é¢è·¯å¾"),dataIndex:"path",render:t=>t.endsWith("*")?n.jsxs(n.Fragment,{children:[t," ",n.jsx(j,{color:"blue",children:e("åç¼å¹é
")})]}):t},{title:e("æ é¢"),dataIndex:"title",width:200},{title:e("æè¿°"),dataIndex:"description",width:300,ellipsis:!0},{title:e("å
³é®è¯"),dataIndex:"keywords",width:200,ellipsis:!0},{title:e("æä½"),width:120,render:(t,i,s)=>n.jsxs(n.Fragment,{children:[n.jsx(d,{theme:"light",type:"primary",style:{marginRight:8},onClick:()=>((e,t)=>{k(e),w(t),_(!0)})(i,s),children:e("ç¼è¾")}),n.jsx(d,{theme:"light",type:"danger",onClick:()=>(e=>{const t=[...y];t.splice(e,1),f(t)})(s),children:e("å é¤")})]})}];return n.jsxs(n.Fragment,{children:[n.jsx(m,{spinning:i,children:n.jsxs(a,{values:l,getFormApi:e=>g.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:e("SEO设置"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"seo_title",label:e("SEOæ é¢"),placeholder:e("请è¾å
¥ç½ç«SEOæ é¢"),onChange:T("seo_title"),showClear:!0})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"footer",label:e("页è设置"),placeholder:e("请è¾å
¥é¡µè设置"),onChange:T("footer"),showClear:!0})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:12,lg:12,xl:12,children:n.jsx(a.TextArea,{field:"
1keywords",label:e("ç½ç«å
³é®è¯"),placeholder:e("请è¾å
¥ç½ç«å
³é®è¯ï¼å¤ä¸ªå
³é®è¯ç¨éå·åé"),autosize:{minRows:3,maxRows:6},onChange:T("keywords")})}),n.jsx(c,{xs:24,sm:12,md:12,lg:12,xl:12,children:n.jsx(a.TextArea,{field:"description",label:e("ç½ç«æè¿°"),placeholder:e("请è¾å
¥ç½ç«æè¿°"),autosize:{minRows:3,maxRows:6},onChange:T("description")})})]}),n.jsx(o,{gutter:16,children:n.jsx(c,{span:24,children:n.jsx(a.Input,{field:"baidu_ocpc_token",label:e("ç¾åº¦ OCPC Token"),placeholder:e("请è¾å
¥ç¾åº¦ OCPC Tokenï¼ä¾å¦ï¼_f7L2XwGXjyszb4d1e2oxPybgDï¼"),onChange:T("baidu_ocpc_token"),showClear:!0})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{span:24,children:n.jsx(a.TextArea,{field:"statistics_code",label:e("ç»è®¡ä»£ç "),placeholder:e("请è¾å
¥ç½ç«ç»è®¡ä»£ç ï¼å¦Google Analyticsãç¾åº¦ç»è®¡ç"),autosize:{minRows:3,maxRows:6},onChange:T("statistics_code")})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{marginTop:16},children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[n.jsx(ds,{strong:!0,children:e("页é¢SEO设置")}),n.jsx(d,{icon:n.jsx(Ye,{size:16}),type:"primary",onClick:()=>{k({path:"",title:"",description:"",keywords:""}),w(-1),_(!0)},children:e("æ·»å 页é¢")})]}),n.jsx(v,{columns:E,dataSource:y,pagination:!1,size:"small",empty:e("ææ é¡µé¢SEOé
ç½®")})]})})}),n.jsx(h,{type:"info",icon:n.jsx(mt,{size:16}),description:n.jsxs("div",{children:[n.jsx("div",{style:{marginBottom:8},children:e("SEOä¼å建议ï¼")}),n.jsxs("ul",{style:{margin:0,paddingLeft:"20px"},children:[n.jsx("li",{children:e("SEOæ é¢åºç®æ´æäºï¼å
嫿 ¸å¿å
³é®è¯")}),n.jsx("li",{children:e("ç½ç«æè¿°åºæ§å¶å¨150å符以å
")}),n.jsx("li",{children:e("å
³é®è¯ä¸å®è¿å¤ï¼3-5个为佳")}),n.jsx("li",{children:e("å¯ä¸ºä¸å页é¢è®¾ç½®ä¸é¨çSEOä¿¡æ¯")})]})]}),style:{marginTop:16,marginBottom:16}})]}),n.jsx(o,{children:n.jsx(c,{children:n.jsx(d,{type:"primary",size:"default",onClick:function(){s(!0);try{const t={...l,seo_page_configs:JSON.stringify(y)};t.baidu_ocpc_token||delete t.baidu_ocpc_token,ye.post("/api/option/updateagentoption",t).then(n=>{const{success:i,message:s}=n.data;i?(be(e("ä¿åæå")),p(structuredClone(t))):je(s||e("ä¿å失败"))}).catch(t=>{je(t.message||e("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{s(!1)})}catch(t){je(t.message||e("æäº¤æ¶åçé误")),s(!1)}},children:e("ä¿åSEO设置")})})})]})}),n.jsx(x,{title:e(C>=0?"ç¼è¾é¡µé¢SEO":"æ·»å 页é¢SEO"),visible:b,onOk:()=>{if(S.path){if(C>=0){const e=[...y];e[C]=S,f(e)}else{if(y.some(e=>e.path===S.path))return void je(e("该页é¢è·¯å¾å·²åå¨"));f([...y,S])}_(!1)}else je(e("页é¢è·¯å¾ä¸è½ä¸ºç©º"))},onCancel:()=>_(!1),closeOnEsc:!0,width:600,children:b&&n.jsxs(a,{initValues:S,children:[n.jsx(a.Input,{field:"path",label:e("页é¢è·¯å¾"),placeholder:e("ä¾å¦: /chat æ /chat/* (éé
符å¹é
ææchatå页é¢)"),onChange:e=>I("path",e),help:e("以/å¼å¤´çè·¯å¾ã使ç¨*ä½ä¸ºéé
符å¯ä»¥å¹é
以ç¸ååç¼å¼å¤´çææé¡µé¢"),required:!0}),n.jsx(a.Input,{field:"title",label:e("页颿 é¢"),placeholder:e("页颿 é¢"),onChange:e=>I("title",e),help:e("ä¸éè¦å
å«ç³»ç»åç§°ï¼ç³»ç»ä¼èªå¨æ·»å ")}),n.jsx(a.TextArea,{field:"description",label:e("é¡µé¢æè¿°"),placeholder:e("é¡µé¢æè¿°"),onChange:e=>I("description",e),rows:3}
1),n.jsx(a.TextArea,{field:"keywords",label:e("页é¢å
³é®è¯"),placeholder:e("页é¢å
³é®è¯ï¼å¤ä¸ªå
³é®è¯ç¨è±æéå·åé"),onChange:e=>I("keywords",e),rows:3})]})})]})},ps=["email","phone","qrcode","link"];function hs(e){if(!e||"string"!=typeof e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function xs(e){const t=hs(e).map(e=>{if(!e||"object"!=typeof e)return e;const t=e.category,n={...e.payload&&"object"==typeof e.payload?e.payload:{}};return"email"===t&&null!=n.address&&(n.address=String(n.address).trim()),"phone"===t&&null!=n.number&&(n.number=String(n.number).trim()),"qrcode"===t&&(null!=n.image_url&&(n.image_url=String(n.image_url).trim()),null!=n.subtitle&&(n.subtitle=String(n.subtitle).trim())),"link"===t&&null!=n.url&&(n.url=String(n.url).trim()),{...e,payload:n}});return JSON.stringify(t)}function ms(e){const t=e.payload||{};switch(e.category){case"email":return t.address||"";case"phone":return t.number||"";case"qrcode":return t.image_url||"";case"link":return t.url||"";default:return JSON.stringify(t||{})}}function gs(e,t){const n=null==t?"":String(t),i={...e.payload||{}};switch(e.category){case"email":i.address=n;break;case"phone":i.number=n;break;case"qrcode":i.image_url=n;break;case"link":i.url=n}return{...e,payload:i}}function ys(e){const t=String(e??"").trim();return""===t?"":/^https?:\/\//i.test(t)?t:`https://${t}`}function js(e){const t=e.payload||{};switch(e.category){case"email":return t.address||"";case"phone":return t.number||"";case"qrcode":return t.image_url||"";case"link":return t.url||"";default:return""}}t.forwardRef(function({value:e,onChange:i,colProps:s,translationEnabled:l=!1},a){const{t:r}=ge(),[o,p]=t.useState([]),[h,m]=t.useState(-1);t.useEffect(()=>{p(hs(e))},[e]);const y=t.useCallback(e=>{p(e),i(JSON.stringify(e))},[i]),[j,f]=t.useState(!1),[b,_]=t.useState("email"),[S,v]=t.useState(""),[C,w]=t.useState(""),[T,I]=t.useState(""),[E,R]=t.useState(""),[P,z]=t.useState(""),[A,M]=t.useState(""),O=t.useCallback(()=>{_("email"),v(""),w(""),I(""),R(""),z(""),M(""),f(!0)},[]);t.useImperativeHandle(a,()=>({openAdd:O}),[O]);const D=t.useCallback(e=>({email:r("èªå®ä¹èç³»åç±»_email"),phone:r("èªå®ä¹èç³»åç±»_phone"),qrcode:r("èªå®ä¹èç³»åç±»_qrcode"),link:r("èªå®ä¹èç³»åç±»_link")}[e]||e),[r]),L=t.useMemo(()=>ps.map(e=>({value:e,label:D(e)})),[D]),B=s||{span:12};return n.jsxs(n.Fragment,{children:[o.map((e,t)=>{const i=Ot(e),s=Dt(e);return n.jsx(c,{...B,children:n.jsxs("div",{className:"semi-form-field semi-form-field-vertical",children:[n.jsxs("div",{className:"semi-form-field-label",style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,width:"100%"},children:[n.jsxs("span",{children:[n.jsx("span",{children:e.title}),n.jsxs(u.Text,{type:"tertiary",size:"small",style:{marginLeft:4},children:["(",D(e.category),")"]})]}),n.jsxs(g,{spacing:4,children:[l&&n.jsxs(n.Fragment,{children:[n.jsx(hn,{item:i,fields:s,onClick:()=>m(t)}),n.jsx(d,{theme:"borderless",type:"tertiary",size:"small",icon:n.jsx(Ge,{size:14}),"aria-label":r("æ¥ç / ç¼è¾è¯æ"),onMouseDown:e=>e.preventDefault(),onClick:e=>{e?.stopPropagation?.(),m(t)}})]}),n.jsx(d,{theme:"borderless",type:"tertiary",size:"small",icon:n.jsx(lt,{size:16}),"aria-label":r("å é¤è¯¥èç³»æ¡ç®"),onMouseDown:e=>e.preventDefault(),onClick:e=>{e?.stopPropagation?.(),function(e){const t=o.filter((t,n)=>n!==e);y(t)}(t)}})]})]}),n.jsx(k,{value:ms(e),onChange:e=>function(e,t){const n=[...o];n[e]=gs(n[e],t),y(n)}(t,e),onBlur:e=>function(e,t){const n=o[e];if(!n||"qrcode"!==n.category)return;const i=ys(t);if(i===String(t??"").trim())return;const s=[...o];s[e]=gs(s[e],i),y(s)}(t,e?.target?.value),showClear:!0})]})},e.id||t)}),n.jsx(x,{title:r("æ·»å èªå®ä¹èç³»æ¡ç®"),visible:j,onOk:function(){const e=S.trim();if(!e)return void x.error({title:r("æç¤º"),content:r("请è¾å
¥å±ç¤ºæ é¢")});const t=b,n=function(e){switch(e){case"email":return{address:C.trim()};case"phone":return{number:T.trim()};case"qrcode":{const e={image_url:ys(E)};return P.trim()&&(e.subtitle=P.trim()),e}case"link":return{url:ys(A)};default:return{}}}(t),i={id:"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():`ce-${Date.now()}-${Math.random().toString(36).slice(2,11)}`,category:t,title:e,payload:n};y([...o,i]),f(!1)},onCancel:()=>f(!1),width:520,children:n.jsxs(g,{vertical:!0,align:"start",style:{width:"100%"},spacing:"loose",children:[n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:r("èç³»æ¡ç®åç±»")}),n.jsx(N,{style:{width:"100%"},optionList:L,value:b,onChange:e=>_(e)})]}),n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:r("å±ç¤ºæ é¢")}),n.jsx(k,{value:S,onChange:v,placeholder:r("请è¾å
¥å±ç¤ºæ é¢")})]}),"email"===b&&n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:r("é®ç®±å°å")}),n.jsx(k,{value:C,onChange:w,placeholder:r("请è¾å
¥é®ç®±å°å")})]}),"phone"===b&&n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:r("çµè¯å·ç ")}),n.jsx(k,{value:T,onChange:I,placeholder:r("请è¾å
¥çµè¯å·ç ")})]}),"qrcode"===b&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:r("å¾çURL")}),n.jsx(k,{value:E,onChange:R,placeholder:r("请è¾å
¥äºç»´ç å¾çURL")})]}),n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:r("坿æ¡")}),n.jsx(k,{value:P,onChange:z,placeholder:r("å¯é坿æ¡")})]})]}),"link"===b&&n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:r("龿¥å°å")}),n.jsx(k,{value:A,onChange:M,placeholder:r("请è¾å
¥é¾æ¥å°åï¼å¦ https://example.com")})]})]})}),(()=>{const e=h,t=e>=0?o[e]:null;if(!t)return null;const i=Ot(t),s=Lt(t).map(e=>({...e,label:r(e.label)}));return n.jsx(xn,{visible:e>=0,onClose:()=>m(-1),item:i,fields:s,translationEnabled:l,onApply:t=>{const n=o.slice();n[e]=Bt(o[e],t),y(n)}})})()]})});const fs=({id:e,label:t,placeholder:i,value:s,onValueChange:l,onRemove:a,translationTag:r,translationButton:o})=>
1{const{attributes:c,listeners:u,setNodeRef:p,transform:h,transition:x,isDragging:m}=ie({id:e}),y={transform:se.Transform.toString(h),transition:x,opacity:m?.5:1,zIndex:m?1e3:"auto"};return n.jsx("div",{ref:p,style:y,children:n.jsxs("div",{className:"semi-form-field semi-form-field-vertical",style:{marginBottom:12},children:[n.jsxs("div",{className:"semi-form-field-label",style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,width:"100%"},children:[n.jsx("div",{...c,...u,style:{cursor:"grab",touchAction:"none",flexShrink:0},children:n.jsx(jt,{size:14,style:{color:"var(--semi-color-text-2)"}})}),n.jsx("span",{style:{flex:1,fontWeight:500,fontSize:14,color:"var(--semi-color-text-0)"},children:t}),n.jsxs(g,{spacing:4,children:[r,o,n.jsx(d,{theme:"borderless",type:"tertiary",size:"small",icon:n.jsx(lt,{size:16}),onMouseDown:e=>e.preventDefault(),onClick:e=>{e?.stopPropagation?.(),a()}})]})]}),n.jsx(k,{value:s,onChange:e=>l(e),placeholder:i,showClear:!0})]})})},bs=({order:e,builtinValues:i,customEntries:s,onOrderChange:l,onBuiltinChange:a,onCustomEntriesChange:r,translationEnabled:o})=>{const{t:c}=ge(),p=function(){const{t:e}=ge();return t=>({[Ft.EMAIL]:e("客æé®ç®±"),[Ft.PHONE]:e("客æçµè¯"),[Ft.ONLINE_TIME]:e("客æå¨çº¿æ¶é´"),[Ft.WEIXIN]:e("ä¼ä¸å¾®ä¿¡å®¢æé¾æ¥"),[Ft.WHATSAPP]:e("WhatsApp äºç»´ç å¾çå°å"),[Ft.QRCODE]:e("äºç»´ç URL")}[t]||t)}(),h=function(){const{t:e}=ge();return t=>({[Ft.EMAIL]:e("请è¾å
¥å®¢æé®ç®±"),[Ft.PHONE]:e("请è¾å
¥å®¢æçµè¯"),[Ft.ONLINE_TIME]:e("请è¾å
¥å®¢æå¨çº¿æ¶é´"),[Ft.WEIXIN]:e("请è¾å
¥ä¼ä¸å¾®ä¿¡å®¢æé¾æ¥"),[Ft.WHATSAPP]:e("请è¾å
¥äºç»´ç å¾ç龿¥"),[Ft.QRCODE]:e("请è¾å
¥äºç»´ç URL")}[t]||"")}(),x=function(){const{t:e}=ge();return t=>({email:e("èªå®ä¹èç³»åç±»_email"),phone:e("èªå®ä¹èç³»åç±»_phone"),qrcode:e("èªå®ä¹èç³»åç±»_qrcode"),link:e("èªå®ä¹èç³»åç±»_link")}[t]||t)}(),[m,g]=t.useState(null),y=q($(X),$(Q,{coordinateGetter:H}));function j(t){const n=e.filter(e=>e!==t);if(l(n),t.startsWith("builtin:"))a(t,"");else{const e=s.filter(e=>e.id!==t);r(e)}}const f=t.useMemo(()=>m?s.find(e=>e.id===m):null,[m,s]);return n.jsxs(n.Fragment,{children:[n.jsx(Y,{sensors:y,collisionDetection:Z,onDragEnd:function(t){const{active:n,over:i}=t;if(!i||n.id===i.id)return;const s=e.indexOf(n.id),a=e.indexOf(i.id);l(ne(e,s,a))},children:n.jsx(ee,{items:e,strategy:te,children:e.map(e=>{if(e.startsWith("builtin:"))return n.jsx(fs,{id:e,label:p(e),placeholder:h(e),value:i[e]||"",onValueChange:t=>function(e,t){a(e,t)}(e,t),onRemove:()=>j(e)},e);const t=s.find(t=>t.id===e);if(!t)return null;const l=Ot(t),m=Dt(t);return n.jsx(fs,{id:e,label:n.jsxs("span",{children:[t.title,n.jsxs(u.Text,{type:"tertiary",size:"small",style:{marginLeft:4},children:["(",x(t.category),")"]})]}),placeholder:"",value:js(t),onValueChange:t=>function(e,t){const n=s.map(n=>n.id===e?function(e,t){const n=null==t?"":String(t),i={...e.payload||{}};switch(e.category){case"email":i.address=n;break;case"phone":i.number=n;break;case"qrcode":i.image_url=n;break;case"link":i.url=n}return{...e,payload:i}}(n,t):n);r(n)}(e,t),onRemove:()=>j(e),translationTag:o?n.jsx(hn,{item:l,fields:m,onClick:()=>g(e)}):null,translationButton:o?n.jsx(d,{theme:"borderless",type:"tertiary",size:"small",icon:n.jsx(Ge,{size:14}),"aria-label":c("æ¥ç / ç¼è¾è¯æ"),onMouseDown:e=>e.preventDefault(),onClick:t=>
1{t?.stopPropagation?.(),g(e)}}):null},e)})})}),f&&(()=>{const e=Ot(f),t=Lt(f).map(e=>({...e,label:c(e.label)}));return n.jsx(xn,{visible:!!m,onClose:()=>g(null),item:e,fields:t,translationEnabled:o,onApply:e=>{const t=s.map(t=>t.id===m?Bt(t,e):t);r(t)}})})()]})},_s={[Ft.EMAIL]:"agent_email",[Ft.PHONE]:"phone",[Ft.ONLINE_TIME]:"work_time",[Ft.WEIXIN]:"customer_support_weixin_link",[Ft.QRCODE]:"qrcode_url"},Ss=[Ft.EMAIL,Ft.PHONE,Ft.ONLINE_TIME,Ft.WEIXIN,Ft.QRCODE],ks=["agent_email","phone","work_time","qrcode_url","customer_support_weixin_link","customer_support_custom_entries","customer_support_contact_order"],vs={agent_email:"",phone:"",work_time:"",qrcode_url:"",customer_support_weixin_link:"",customer_support_custom_entries:"[]",customer_support_contact_order:""};function Cs(e){const t={};for(const[n,i]of Object.entries(_s))t[n]=e[i]||"";return t}function ws(e,t){const n=Wt(e.customer_support_contact_order),i=Object.keys(_s),s=t.map(e=>e.id);return Jt(n||Ss,i,s)}function Ts(e){if(!e)return!0;try{const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}}const Is=["email","phone","qrcode","link"],Es=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,a]=t.useState(vs),[r,o]=t.useState(vs),[c,p]=t.useState(!1),[h,y]=t.useState(!1),[j,f]=t.useState("email"),[b,_]=t.useState(""),[S,k]=t.useState(""),[v,C]=t.useState(""),[w,T]=t.useState(""),[I,E]=t.useState(""),[R,P]=t.useState(""),z=hs(l.customer_support_custom_entries),N=ws(l,z);function A(e){a(t=>({...t,customer_support_contact_order:JSON.stringify(e)}))}function M(e){a(t=>({...t,customer_support_custom_entries:JSON.stringify(e)}))}t.useEffect(()=>{(async()=>{try{const e=await ye.get("/api/option/getagentoptions"),{success:t,message:n,data:i}=e.data;if(t){const e={...vs};for(const t of ks)void 0!==i[t]&&null!==i[t]&&(e[t]="string"==typeof i[t]?i[t]:JSON.stringify(i[t]));e.customer_support_custom_entries||(e.customer_support_custom_entries="[]"),a(e),o(structuredClone(e)),p(an(i.translation_enabled))}else je(n)}catch(e){je(e.message)}})()},[]);const O=t=>({email:e("èªå®ä¹èç³»åç±»_email"),phone:e("èªå®ä¹èç³»åç±»_phone"),qrcode:e("èªå®ä¹èç³»åç±»_qrcode"),link:e("èªå®ä¹èç³»åç±»_link")}[t]||t);return n.jsxs(m,{spinning:i,children:[n.jsxs(g,{align:"center",style:{marginBottom:12},children:[n.jsx(u.Title,{heading:6,style:{margin:0},children:e("èç³»æ¹å¼è®¾ç½®")}),n.jsx(d,{icon:n.jsx(Ye,{size:16}),type:"tertiary",size:"small",onClick:()=>{f("email"),_(""),k(""),C(""),T(""),E(""),P(""),y(!0)},children:e("æ·»å èªå®ä¹èç³»æ¡ç®")})]}),n.jsx(bs,{order:N,builtinValues:Cs(l),customEntries:z,onOrderChange:function(e){A(e)},onBuiltinChange:function(e,t){const n=_s[e];n&&a(e=>({...e,[n]:t}))},onCustomEntriesChange:function(e){M(e);const t=new Set(e.map(e=>e.id));A(ws(l,z).filter(e=>e.startsWith("builtin:")||t.has(e)))},translationEnabled:c}),c&&n.jsx("div",{style:{marginTop:8},children:n.jsx(u.Text,{type:"warning",size:"small",children:e("å·²å¼å¯èªå¨ç¿»è¯ï¼ä¿å设置æ¶ç±å端并åç¿»è¯ä¸º 6 ç§è¯è¨ï¼èæ¶åå³äºæ¡ç®æ°ä¸æ¨¡åï¼é常 30 ç§~2 åéï¼")})}),n.jsx("div",{style:{marginTop:16},children:n.jsx(d,{type:"primary",size:"default",onClick:async function(){const t=z.find(e=>"link"===e.category&&!Ts(e.payload?.url||""));if(t)x.error({title:e("æç¤º"),content:e("请è¾å
¥ææçURLå°å")+`ï¼${t.title}ï¼`});else{s(!0);try{const t={...l,customer_support_custom_entries:xs(l.customer_support_custom_entries),customer_support_contact_order:l.customer_support_contact_order||JSON.stringify(N)},n=await ye.post("/api/option/updateagentoption",t),{success:i,message:s}=n.data;i?(be(e("ä¿åæå")),a(structuredClone(t)),o(structuredClone(t))):je(s||e("ä¿å失败"))}catch(n){je(n?.message||e("ä¿å失败ï¼è¯·éè¯"))}finally{s(!1)}}},children:e("ä¿åèç³»æ¹å¼è®¾ç½®")})}),n.jsx(x,{title:e("æ·»å èªå®ä¹èç³»æ¡ç®"),visible:h,onOk:function(){const t=b.trim();if(!t)return void x.error({title:e("æç¤º"),content:e("请è¾å
¥å±ç¤ºæ é¢")});let n={};if("email"===j)n={address:S.trim()};else if("phone"===j)n={number:v.trim()};else if("qrcode"===j)n={image_url:w.trim()},I.trim()&&(n.subtitle=I.trim());else if("link"===j){const t=R.trim();if(!Ts(t))return void x.error({title:e("æç¤º"),content:e("请è¾å
¥ææçURLå°å")});n={url:t}}const i={id:"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():`ce-${Date.now()}-${Math.random().toString(36).slice(2,11)}`,category:j,title:t,payload:n};M([...z,i]);const s=ws(l,z);A(Ut(s,i.id)),y(!1),_(""),k(""),C(""),T(""),E(""),P("")},onCancel:()=>y(!1),width:520,children:n.jsxs(g,{vertical:!0,align:"start",style:{width:"100%"},spacing:"loose",children:[n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:e("èç³»æ¡ç®åç±»")}),n.jsx("select",{value:j,onChange:e=>f(e.target.value),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)"},children:Is.map(e=>n.jsx("option",{value:e,children:O(e)},e))})]}),n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:e("å±ç¤ºæ é¢")}),n.jsx("input",{value:b,onChange:e=>_(e.target.value),placeholder:e("请è¾å
¥å±ç¤ºæ é¢"),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)",boxSizing:"border-box"}})]}),"email"===j&&n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:e("é®ç®±å°å")}),n.jsx("input",{value:S,onChange:e=>k(e.target.value),placeholder:e("请è¾å
¥é®ç®±å°å"),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)",boxSizing:"border-box"}})]}),"phone"===j&&n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:e("çµè¯å·ç ")}
1),n.jsx("input",{value:v,onChange:e=>C(e.target.value),placeholder:e("请è¾å
¥çµè¯å·ç "),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)",boxSizing:"border-box"}})]}),"qrcode"===j&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:e("å¾çURL")}),n.jsx("input",{value:w,onChange:e=>T(e.target.value),placeholder:e("请è¾å
¥äºç»´ç å¾çURL"),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)",boxSizing:"border-box"}})]}),n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:e("坿æ¡")}),n.jsx("input",{value:I,onChange:e=>E(e.target.value),placeholder:e("å¯é坿æ¡"),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)",boxSizing:"border-box"}})]})]}),"link"===j&&n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:e("龿¥å°å")}),n.jsx("input",{value:R,onChange:e=>P(e.target.value),placeholder:e("请è¾å
¥é¾æ¥å°åï¼å¦ https://example.com"),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)",boxSizing:"border-box"}})]})]})})]})},Rs=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,r]=t.useState({smtp_server:"",smtp_port:"",smtp_account:"",smtp_from:"",smtp_token:""}),[u,p]=t.useState(l),h=t.useRef();function x(e){return t=>{r(n=>({...n,[e]:t}))}}return t.useEffect(()=>{(async()=>{try{const e=await ye.get("/api/option/getagentoptions"),{success:t,message:n,data:i}=e.data;if(t){const e={};for(let t in i)Object.keys(l).includes(t)&&(e[t]=i[t]);r(e),p(structuredClone(e)),h.current&&h.current.setValues(e)}else je(n)}catch(e){je(e.message)}})()},[]),n.jsx(m,{spinning:i,children:n.jsxs(a,{values:l,getFormApi:e=>h.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:e("SMTPé®ä»¶è®¾ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"smtp_server",label:e("SMTP æå¡å¨å°å"),placeholder:e("请è¾å
¥SMTP æå¡å¨å°åï¼å¦ï¼smtp.gmail.com"),onChange:x("smtp_server"),showClear:!0,rules:[{required:!0,message:e("SMTP æå¡å¨å°åä¸è½ä¸ºç©º")}]})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"smtp_port",label:e("SMTP 端å£"),placeholder:e("请è¾å
¥SMTP 端å£ï¼å¦ï¼587"),onChange:x("smtp_port"),min:1,max:65535,style:{width:"100%"},rules:[{required:!0,message:e("SMTP 端å£ä¸è½ä¸ºç©º")},{type:"number",min:1,max:65535,message:e("端å£èå´ä¸º1-65535")}]})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"smtp_account",label:e("SMTP è´¦æ·"),autoComplete:"off",placeholder:e("请è¾å
¥SMTP è´¦æ·ï¼é常æ¯é®ç®±å°å"),onChange:x("smtp_account"),showClear:!0,rules:[{required:!0,message:e("SMTP è´¦æ·ä¸è½ä¸ºç©º")}]})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"smtp_from",label:e("SMTP åéè
é®ç®±"),placeholder:e("请è¾å
¥åéè
é®ç®±å°å"),onChange:x("smtp_from"),showClear:!0,validate:t=>t&&t.trim()&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim())?e("请è¾å
¥ææçé®ç®±å°å"):"",rules:[{required:!0,message:e("åéè
é®ç®±ä¸è½ä¸ºç©º")}]})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"smtp_token",label:e("SMTP 访é®åè¯"),autoComplete:"new-password",type:"password",placeholder:e("请è¾å
¥SMTP 访é®åè¯æå¯ç "),onChange:x("smtp_token"),showClear:!0,rules:[{required:!0,message:e("SMTP 访é®åè¯ä¸è½ä¸ºç©º")}]})})]})]}),n.jsx(o,{children:n.jsx(c,{children:n.jsx(d,{type:"primary",size:"default",onClick:function(){s(!0);try{const t={...l,smtp_port:""!==l.smtp_port?parseInt(l.smtp_port):""};ye.post("/api/option/updateagentoption",t).then(t=>{const{success:n,message:i}=t.data;n?(be(e("ä¿åæå")),p(structuredClone(l))):je(i||e("ä¿å失败"))}).catch(t=>{je(t.message||e("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{s(!1)})}catch(t){je(t.message||e("æäº¤æ¶åçé误")),s(!1)}},children:e("ä¿å SMTP 设置")})})})]})})},Ps=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,r]=t.useState({agent_domain:"",github_oauth_enabled:!1,github_client_id:"",github_client_secret:"",google_oauth_enabled:!1,google_client_id:"",google_client_secret:"",linuxdo_oauth_enabled:!1,linuxdo_client_id:"",linuxdo_client_secret:"",telegram_oauth_enabled:!1,wechat_auth_enabled:!1,wechat_server_address:"",wechat_server_token:"",wechat_account_qrcode_image_url:"",captcha_login_mode:0,captcha_register_mode:0}),[p,x]=t.useState(l),g=t.useRef();function y(e){return t=>{r(n=>({...n,[e]:t}))}}t.useEffect(()=>{j()},[]);const j=async()=>{try{const e=await ye.get("/api/option/getagentoptions"),{success:t,message:n,data:i}=e.data;if(t){const e={};for(let t in i)Object.keys(l).includes(t)&&(e[t]=i[t]);r(e),x(structuredClone(e)),g.current&&g.current.setValues(e)}else je(n)}catch(e){je(e.message)}};return n.jsx(m,{spinning:i,children:n.jsxs(a,{values:l,getFormApi:e=>g.current=e,labelPosition:"left",labelWidth:"120px",onValueChange:e=>{r(t=>({...t,...e}))},children:[n.jsxs(a.Section,{children:[n.jsx(u.Title,{heading:4,children:e("é
ç½® GitHub OAuth App")}),n.jsx(u.Text,{children:n.jsx(ln,{i18nKey:"github_oauth_intro",components:{link:n.jsx("a",{href:"https://github.com/settings/developers",target:"_blank",rel:"noreferrer"})}})}),n.jsx(h,{type:"info",icon:n.jsx(mt,{size:16}),description:n.jsx(u.Text,{children:n.jsx(ln,{i18nKey:"github_oauth_banner_desc",values:{homepageUrl:l.agent_domain?`https://${l.agent_domain}`:e("æ¨çåå"),callbackUrl:l.agent_domain?`https://${l.agent_domain}/oauth/github`:`${e("æ¨çåå")}/oauth/github`},components:{code:n.jsx("code",{})}})}),style:{marginBottom:12}}),n.jsx(a.Switch,{field:"github_oauth_enabled",label:e("å¯ç¨ GitHub ç»å½"),extraText:"å
è®¸ç¨æ·éè¿ GitHub è´¦å·ç»å½å注å",size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:y("github_oauth_enabled")}),n.jsx(a.Input,{field:"github_client_id",label:"GitHub Client ID",placeholder:e("请è¾å
¥ GitHub Client ID"),autoComplete:"off",onChange:y("github_client_id")}),n.jsx(a.Input,{field:"github_client_secret",label:"GitHub Client Secret",type:"password",placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º"),autoComplete:"new-password",onChange:y("github_client_secret")})]}),n.jsxs(a.Section,{children:[n.jsx(u.Title,{heading:4,children:e("é
ç½® Google OAuth 2.0")}),n.jsx(u.Text,{children:n.jsx(ln,{i18nKey:"google_oauth_intro_with_link",components:{gconsole:n.jsx("a",{href:"https://console.cloud.google.com/",target:"_blank",rel:"noreferrer"})}})}),n.jsx(h,{type:"info",icon:n.jsx(mt,{size:16}),description:n.jsx(u.Text,{children:n.jsx(ln,{i18nKey:"google_oauth_banner_desc",values:{callbackUrl:l.agent_domain?`https://${l.agent_domain}/oauth/google`:`${e("æ¨çåå")}/oauth/google`},components:{code:n.jsx("code",{})}})}),style:{marginBottom:12}}),n.jsx(a.Switch,{field:"google_oauth_enabled",label:e("å¯ç¨ Google ç»å½"),extraText:"å
è®¸ç¨æ·éè¿ Google è´¦å·ç»å½å注å",size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:y("google_oauth_enabled")}),n.jsx(a.Input,{field:"google_client_id",label:"Google Client ID",placeholder:e("请è¾å
¥ Google Client ID"),autoComplete:"off",onChange:y("google_client_id")}),n.jsx(a.Input,{field:"google_client_secret",label:"Google Client Secret",type:"password",placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º"),autoComplete:"new-password",onChange:y("google_client_secret")})]}),n.jsxs(a.Section,{children:[n.jsx(u.Title,{heading:4,children:e("é
ç½® LinuxDO OAuth App")}),n.jsx(u.Text,{children:n.jsx(ln,{i18nKey:"linuxdo_oauth_intro",components:{link:n.jsx("a",{href:"https://connect.linux.do/",target:"_blank",rel:"noreferrer"})}})}),n.jsx(h,{type:"info",icon:n.jsx(mt,{size:16}),description:n.jsx(u.Text,{children:n.jsx(ln,{i18nKey:"linuxdo_oauth_banner_desc",values:{homepageUrl:l.agent_domain?`https://${l.agent_domain}`:e("æ¨çåå"),callbackUrl:l.agent_domain?`https://${l.agent_domain}/oauth/linuxdo`:`${e("æ¨çåå")}/oauth/linuxdo`},components:{code:n.jsx("code",{})}})}),style:{marginBottom:12}}),n.jsx(a.Switch,{field:"linuxdo_oauth_enabled",label:e("å¯ç¨ LinuxDO ç»å½"),extraText:"å
è®¸ç¨æ·éè¿ LinuxDO è´¦å·ç»å½å注å",size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:y("linuxdo_oauth_enabled")}),n.jsx(a.Input,{field:"linuxdo_client_id",label:"LinuxDO Client ID",placeholder:e("请è¾å
¥ LinuxDO Client ID"),autoComplete:"off",onChange:y("linuxdo_client_id")}),n.jsx(a.Input,{field:"linuxdo_client_secret",label:"LinuxDO Client Secret",type:"password",placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º"),autoComplete:"new-password",onChange:y("linuxdo_client_secret")})]}),n.jsxs(a.Section,{children:[n.jsx(u.Title,{heading:4,children:e("é
置微信ç»å½")}),n.jsx(u.Text,{children:n.jsx(ln,{i18nKey:"wechat_oauth_intro",components:{link:n.jsx("a",{href:"https://github.com/songquanpeng/wechat-server",target:"_blank",rel:"noreferrer"})}})}),n.jsx(a.Switch,{field:"wechat_auth_enabled",label:e("å¯ç¨å¾®ä¿¡ç»å½"),extraText:e("å
è®¸ç¨æ·éè¿å¾®ä¿¡è´¦å·ç»å½å注å"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:y("wechat_auth_enabled")}),n.jsx(a.Input,{field:"wechat_server_address",label:e("WeChat Server å°å"),placeholder:e("ä¾å¦ï¼https://yourdomain.com"),autoComplete:"off",onChange:y("wechat_server_address")}),n.jsx(a.Input,{field:"wechat_server_token",label:e("WeChat Server 访é®åè¯"),type:"password",placeholder:e("ææä¿¡æ¯ä¸ä¼åéå°å端æ¾ç¤º"),autoComplete:"new-password",onChange:y("wechat_server_token")}),n.jsx(a.Input,{field:"wechat_account_qrcode_image_url",label:e("微信å
¬ä¼å·äºç»´ç å¾ç龿¥"),placeholder:e("请è¾å
¥å¾ç龿¥"),autoComplete:"off",onChange:y("wechat_account_qrcode_image_url")})]}),n.jsxs(a.Section,{children:[n.jsx(u.Title,{heading:4,children:e("æ»åéªè¯ç ")}),n.jsx(u.Text,{children:e('æ§å¶ä»£çç«ç»å½åæ³¨åæ¯å¦éè¦æ»åéªè¯ç ï¼"è·é主ç«"表示使ç¨ä¸»ç«çå
¨å±è®¾ç½®ã')}
1),n.jsxs(a.Select,{field:"captcha_login_mode",label:e("ç»å½æ»åéªè¯"),style:{width:"100%"},onChange:y("captcha_login_mode"),children:[n.jsx(a.Select.Option,{value:0,children:e("è·é主ç«")}),n.jsx(a.Select.Option,{value:1,children:e("强å¶å¼å¯")}),n.jsx(a.Select.Option,{value:2,children:e("强å¶å
³é")})]}),n.jsxs(a.Select,{field:"captcha_register_mode",label:e("æ³¨åæ»åéªè¯"),style:{width:"100%"},onChange:y("captcha_register_mode"),children:[n.jsx(a.Select.Option,{value:0,children:e("è·é主ç«")}),n.jsx(a.Select.Option,{value:1,children:e("强å¶å¼å¯")}),n.jsx(a.Select.Option,{value:2,children:e("强å¶å
³é")})]})]}),n.jsx(o,{children:n.jsx(c,{span:24,style:{textAlign:"center",marginTop:24},children:n.jsx(d,{type:"primary",onClick:()=>{!l.github_oauth_enabled||l.github_client_id&&l.github_client_secret?!l.google_oauth_enabled||l.google_client_id&&l.google_client_secret?!l.linuxdo_oauth_enabled||l.linuxdo_client_id&&l.linuxdo_client_secret?ke(p,l).length>0?(s(!0),ye.post("/api/option/updateagentoption",l).then(t=>{const{success:n,message:i}=t.data;n?(be(e("ä¿åæå")),x(structuredClone(l))):je(i||e("ä¿å失败"))}).catch(t=>{je(t.message||e("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{s(!1)})):je(e("æ åæ´ï¼æ éä¿å")):je("å¯ç¨ LinuxDO ç»å½éè¦é
ç½® LinuxDO Client ID å Client Secret"):je(e("å¯ç¨ Google ç»å½éè¦é
ç½® Google Client ID å Client Secret")):je(e("å¯ç¨ GitHub ç»å½éè¦é
ç½® GitHub Client ID å Client Secret"))},loading:i,children:e("ä¿å设置")})})})]})})},{Text:zs}=u,Ns=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,r]=t.useState({disclaimer:""}),[u,p]=t.useState(l),x=t.useRef();return t.useEffect(()=>{(async()=>{try{const e=await ye.get("/api/option/getagentoptions"),{success:t,message:n,data:i}=e.data;if(t){const e={};for(let t in i)Object.keys(l).includes(t)&&(e[t]=i[t]);r(e),p(structuredClone(e)),x.current&&x.current.setValues(e)}else je(n)}catch(e){je(e.message)}})()},[]),n.jsx(m,{spinning:i,children:n.jsxs(a,{values:l,getFormApi:e=>x.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:e("ç¨æ·å议设置"),children:[n.jsx(o,{gutter:16,children:n.jsxs(c,{span:24,children:[n.jsx(a.TextArea,{field:"disclaimer",label:e("ç¨æ·åè®®å
容"),placeholder:e("卿¤è¾å
¥ç¨æ·åè®®å
å®¹ï¼æ¯æ Markdown & HTML 代ç "),autosize:{minRows:10,maxRows:20},style:{fontFamily:"JetBrains Mono, Consolas, Monaco, monospace"},onChange:(g="disclaimer",e=>{r(t=>({...t,[g]:e}))}),validate:t=>t&&t.length>1e5?e("ç¨æ·åè®®å
容ä¸è½è¶
è¿100000个å符"):""}),n.jsx(zs,{type:"tertiary",style:{marginTop:8,display:"block"},children:e("ç¨æ·åè®®å°å¨ç¨æ·æ³¨å/ç»å½æ¶æ¾ç¤ºï¼ç¨æ·å¿
é¡»åæåè®®æè½æ³¨å/ç»å½")})]})}),n.jsx(h,{type:"info",icon:n.jsx(mt,{size:16}),description:n.jsxs("div",{children:[n.jsx("div",{style:{marginBottom:8},children:e("ç¨æ·åè®®ç¼å建议ï¼")}),n.jsxs("ul",{style:{margin:0,paddingLeft:"20px"},children:[n.jsx("li",{children:e("æ¯æ Markdown è¯æ³ï¼å¦ **ç²ä½**ã*æä½*")}),n.jsx("li",{children:e("æ¯æ HTML æ ç¾ï¼å¦ <h1>ã<p>ã<a> ç")}),n.jsx("li",{children:e("建议å
嫿塿¡æ¬¾ãéç§æ¿çãå
责声æç")}),n.jsx("li",{children:e("åºæç¡®ç¨æ·æå©åä¹å¡ï¼ä¿æ¤æå¡æä¾è
åæ³æç")})]})]}),style:{marginTop:16,marginBottom:16}})]}),n.jsx(o,{children:n.jsx(c,{children:n.jsx(d,{type:"primary",size:"default",onClick:function(){s(!0);try{ye.post("/api/option/updateagentoption",l).then(t=>{const{success:n,message:i}=t.data;n?(be(e("ä¿åæå")),p(structuredClone(l))):je(i||e("ä¿å失败"))}).catch(t=>{je(t.message||e("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{s(!1)})}catch(t){je(t.message||e("æäº¤æ¶åçé误")),s(!1)}},children:e("ä¿åç¨æ·åè®®")})})})]})});var g},{Text:As}=u,Ms=()=>{const{t:e}=ge(),[i,s]=t.useContext(Te),[l,r]=t.useState(!1),[u,p]=t.useState({enabled_menus:"",enabled_side_menus:"",enabled_personal_features:"",enable_invite_reward_section:!0}),[x,y]=t.useState(u),j=t.useRef(),f=[{label:e("é¦é¡µ"),value:"home"},{label:e("OpenClaw ä¸é®é¨ç½²"),value:"openclaw"},{label:e("API ææ¡£"),value:"docs"},{label:e("æè½ä¸å¿"),value:"skills"},{label:e("å
¬å"),value:"announcement"},{label:e("代çå ç"),value:"affiliate"},{label:e("èç³»æä»¬"),value:"customersupport"},{label:e("æç« èµè®¯"),value:"news"}],b=[{label:e("æç« 管ç"),value:"article"},{label:e("æ¨å¹¿æ¸ é管ç"),value:"invite_channel"},{label:e("OpenClaw é¨ç½²"),value:"openclaw"}],_=[{label:e("å¯ç 管ç"),value:"change_password"},{label:e("å é¤è´¦æ·"),value:"delete_account"}];function S(e){return t=>{const n=Array.isArray(t)?t.join(","):t;p(t=>({...t,[e]:n}))}}return t.useEffect(()=>{(async()=>{try{const e=await ye.get("/api/option/getagentoptions"),{success:t,message:n,data:i}=e.data;if(t){const e={...u};for(let t in i)Object.keys(e).includes(t)&&(e[t]=i[t]);p(e),y(structuredClone(e)),j.current&&j.current.setValues({...e,enabled_menus:e.enabled_menus?e.enabled_menus.split(","):[],enabled_side_menus:e.enabled_side_menus?e.enabled_side_menus.split(","):[],enabled_personal_features:e.enabled_personal_features?e.enabled_personal_features.split(","):[]})}else je(n)}catch(e){je(e.message)}})()},[]),n.jsx(m,{spinning:l,children:n.jsxs(a,{values:u,getFormApi:e=>j.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:e("é¡¶é¨èå设置"),children:[n.jsx(o,{gutter:16,children:n.jsxs(c,{span:24,children:[n.jsx(a.CheckboxGroup,{field:"enabled_menus",label:e("å¯ç¨çé¡¶é¨èå"),direction:"vertical",initValue:[],onChange:S("enabled_menus"),children:n.jsx(g,{spacing:"loose",wrap:!0,children:f.map(e=>n.jsx(D,{value:e.value,children:e.label},e.value))})}),n.jsx(As,{type:"tertiary",style:{marginTop:8,display:"block"},children:e("éæ©è¦å¨ç½ç«é¡¶é¨æ¾ç¤ºçèå项")})]})}),n.jsx(h,{type:"info",icon:n.jsx(mt,{size:16}),description:n.jsxs("div",{children:[n.jsx("div",{style:{marginBottom:8},children:e("èå说æï¼")}),n.jsxs("ul",{style:{margin:0,paddingLeft:"20px"},children:[n.jsx("li",{children:e("é¦é¡µï¼è¥åæ¶å¾éï¼æªç»å½ç¨æ·å°è·³è½¬è³ç»å½é¡µï¼å·²ç»å½ç¨æ·å°è·³è½¬è³æ§å¶å°")}),n.jsx("li",{children:e("OpenClaw ä¸é®é¨ç½²ï¼æ¾ç¤º OpenClaw ä¸é®é¨ç½²ä»ç»é¡µå
¥å£")}),n.jsx("li",{children:e("API ææ¡£ï¼æ¾ç¤º API ææ¡£å¤é¾å
¥å£")}),n.jsx("li",{children:e("å
¬åï¼æ¾ç¤ºé¡¶é¨å
¬åééæé®")}),n.jsx("li",{children:e("代çå çï¼æ¾ç¤ºä»£çå çç¸å
³ä¿¡æ¯å龿¥")}),n.jsx("li",{children:e("èç³»æä»¬ï¼æ¾ç¤ºå®¢æèç³»æ¹å¼åæ¯æä¿¡æ¯")}),n.jsx("li",{children:e("æç« èµè®¯ï¼æ¾ç¤ºå·²åå¸çæç« å表页é¢")}),n.jsx("li",{children:e("æªéæ©çèå项å°ä¸ä¼å¨ç½ç«é¡¶é¨æ¾ç¤º")}),n.jsx("li",{children:n.jsx("strong",{children:e('èªå®ä¹èå龿¥è¯·å¨"åºç¡è
1®¾ç½®"ä¸é
ç½®')})})]})]}),style:{marginTop:16,marginBottom:16}})]}),n.jsx(a.Section,{text:e("ä¾§è¾¹èå设置"),children:n.jsx(o,{gutter:16,children:n.jsxs(c,{span:24,children:[n.jsx(a.CheckboxGroup,{field:"enabled_side_menus",label:e("å¯ç¨çä¾§è¾¹èå"),direction:"vertical",initValue:[],onChange:S("enabled_side_menus"),children:n.jsx(g,{spacing:"loose",wrap:!0,children:b.map(e=>n.jsx(D,{value:e.value,children:e.label},e.value))})}),n.jsx(As,{type:"tertiary",style:{marginTop:8,display:"block"},children:e("åæ¶å¾éçèå项å°å¯¹ææç¨æ·éèï¼å
å«ä»£ç管çåï¼")})]})})}),n.jsx(a.Section,{text:e("个人设置åè½"),children:n.jsx(o,{gutter:16,children:n.jsxs(c,{span:24,children:[n.jsx(a.CheckboxGroup,{field:"enabled_personal_features",label:e("å¯ç¨ç个人设置åè½"),direction:"vertical",initValue:[],onChange:S("enabled_personal_features"),children:n.jsx(g,{spacing:"loose",wrap:!0,children:_.map(e=>n.jsx(D,{value:e.value,children:e.label},e.value))})}),n.jsx(As,{type:"tertiary",style:{marginTop:8,display:"block"},children:e("åæ¶å¾éçåè½å°å¨ç¨æ·ä¸ªäººè®¾ç½®é¡µé¢ä¸éè")})]})})}),n.jsx(a.Section,{text:e("é±å
页é¢è®¾ç½®"),children:n.jsx(o,{gutter:16,children:n.jsxs(c,{span:24,children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:4},children:[n.jsx(E,{checked:!!u.enable_invite_reward_section,onChange:e=>p(t=>({...t,enable_invite_reward_section:e}))}),n.jsx(As,{children:e("æ¾ç¤ºé请å¥å±æ¨¡å")})]}),n.jsx(As,{type:"tertiary",style:{display:"block"},children:e("å
³éåé±å
页é¢å³ä¾§çé请å¥å±å¡çå°ä¸åæ¾ç¤º")})]})})}),n.jsx(o,{children:n.jsx(c,{children:n.jsx(d,{type:"primary",size:"default",onClick:function(){r(!0),ye.post("/api/option/updateagentoption",u).then(t=>{const{success:n,message:l,data:a}=t.data;if(n){if(be(e("ä¿åæå")),y(structuredClone(u)),i?.status?.is_global_agent){const e={};void 0!==a?.enabled_menus&&(e.enabled_menus=a.enabled_menus),void 0!==a?.enabled_side_menus&&(e.enabled_side_menus=a.enabled_side_menus),void 0!==a?.enabled_personal_features&&(e.enabled_personal_features=a.enabled_personal_features),void 0!==a?.enable_invite_reward_section&&(e.invite_reward_section_enabled=a.enable_invite_reward_section),Object.keys(e).length>0&&s({type:"set",payload:{...i?.status,...e}})}}else je(l||e("ä¿å失败"))}).catch(t=>{je(t.message||e("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{r(!1)})},children:e("ä¿åèå设置")})})})]})})},{Text:Os}=u,Ds=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,r]=t.useState({currency_type:"CUSTOM",custom_currency_symbol:"ð°",rate:"",agent_price:"",sale_price:"",show_official_discount:!0}),[u,p]=t.useState(l),x=t.useRef();function g(e){return t=>{r(n=>({...n,[e]:t}))}}t.useEffect(()=>{y()},[]);const y=async()=>{try{const e=await ye.get("/api/option/getagentoptions"),{success:t,message:n,data:i}=e.data;if(t){const e={};for(let t in i)Object.keys(l).includes(t)&&(e[t]=i[t]);void 0!==e.show_official_discount&&null!==e.show_official_discount||(e.show_official_discount=!0),r(e),p(structuredClone(e)),x.current&&x.current.setValues(e)}else je(n)}catch(e){je(e.message)}};return n.jsx(n.Fragment,{children:n.jsxs(m,{spinning:i,children:[n.jsx(h,{type:"info",description:e("é
置代çç«ç¹çè´§å¸æ¾ç¤ºæ¹å¼åå
å¼ä»·æ ¼ãè´§å¸æ±çç±ä¸»ç«ç»ä¸ç®¡çã"),icon:n.jsx(mt,{size:16}),style:{marginBottom:16}}),n.jsxs(a,{getFormApi:e=>x.current=e,onValueChange:e=>r(e),labelPosition:"left",labelAlign:"left",labelWidth:140,children:[n.jsx(a.Section,{text:e("è´§å¸é
ç½®"),children:n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsxs(a.Select,{field:"currency_type",label:e("è´§å¸ç±»å"),placeholder:e("è¯·éæ©è´§å¸ç±»å"),initValue:"CUSTOM",extraText:e("éæ©ç«ç¹æ¾ç¤ºçè´§å¸ç±»å"),style:{width:"100%"},onChange:g("currency_type"),children:[n.jsx(N.Option,{value:"USD",children:e("ç¾å
($)")}),n.jsx(N.Option,{value:"TOKENS",children:e("ä»£å¸ (TOKEN)")}),n.jsx(N.Option,{value:"CUSTOM",children:e("èªå®ä¹è´§å¸")})]})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"custom_currency_symbol",label:e("èªå®ä¹è´§å¸ç¬¦å·"),placeholder:e("请è¾å
¥è´§å¸ç¬¦å·"),initValue:"ð°",extraText:e("éæ©CUSTOMæ¶ä½¿ç¨çè´§å¸ç¬¦å·"),style:{width:"100%"},onChange:g("custom_currency_symbol"),disabled:"CUSTOM"!==l.currency_type})})]})}),n.jsx(a.Section,{text:e("å
å¼ä»·æ ¼è®¾ç½®"),children:n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"rate",label:e("ç³»ç»è´¹ç"),placeholder:e("请è¾å
¥ç³»ç»è´¹ç"),disabled:!0,extraText:e("ç³»ç»è®¡è´¹è´¹çï¼ç³»ç»èªå¨è®¾ç½®ï¼ä¸å¯ä¿®æ¹ï¼"),suffix:"%",min:0,precision:4,style:{width:"100%"}})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"agent_price",label:e("ææ¬ä»·æ ¼"),placeholder:e("请è¾å
¥ææ¬ä»·æ ¼"),disabled:!0,extraText:e("æ¨çææ¬ä»·æ ¼ï¼ç³»ç»èªå¨è®¾ç½®ï¼ä¸å¯ä¿®æ¹ï¼"),suffix:e("å
/1$ é¢åº¦"),min:0,precision:6,style:{width:"100%"}})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"sale_price",label:e("å¨çº¿å
å¼ä»·æ ¼"),placeholder:e("请è¾å
¥å¨çº¿å
å¼ä»·æ ¼"),extraText:e("ç¨æ·å¨çº¿å
弿¶çåä»·ï¼å»ºè®®è®¾ç½®åçç婿¶¦ç©ºé´"),suffix:e("å
/1$ é¢åº¦"),min:0,precision:6,style:{width:"100%"},onChange:g("sale_price"),rules:[{required:!0,message:e("å¨çº¿å
å¼ä»·æ ¼ä¸è½ä¸ºç©º")},{type:"number",min:1e-6,message:e("ä»·æ ¼å¿
须大äº0")}]})})]})}),n.jsx(a.Section,{text:e("模å广åºå±ç¤ºè®¾ç½®"),children:n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"show_official_discount",label:e("æ¾ç¤ºãæ¯å®æ¹ä¾¿å®ãæ ç¾"),extraText:e("å
³éåï¼æ¨¡å广åºåç»ä»·æ ¼å°ä¸åå±ç¤ºãæ¯å®æ¹ä¾¿å® N%ãçº¢è²æ ç¾ï¼é»è®¤å¼å¯"),onChange:g("show_official_discount")}
1)})})}),n.jsx("div",{style:{marginTop:24,display:"flex",justifyContent:"flex-end"},children:n.jsx(d,{type:"primary",onClick:function(){s(!0),ye.post("/api/option/updateagentoption",l).then(t=>{const{success:n,message:i}=t.data;n?(be(e("ä¿åæå")),p(structuredClone(l))):je(i||e("ä¿å失败"))}).catch(t=>{je(t.message||e("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{s(!1)})},loading:i,children:e("ä¿åé
ç½®")})})]})]})})},Ls=["content","extra"],Bs=[{key:"content",label:"å
容",type:"textarea",rows:4,maxCount:500},{key:"extra",label:"说æ",type:"input",maxLength:200}],{Text:Fs}=u,Ws=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,r]=t.useState({agent_announcements:"",follow_main_announce:!0,announcements_enabled:!0}),[u,p]=t.useState(l),[h,y]=t.useState([]),[f,b]=t.useState(!1),[_,S]=t.useState(!1),[k,R]=t.useState(null),[P,z]=t.useState(null),[N,A]=t.useState(!1),[M,O]=t.useState(!1),[D,L]=t.useState({content:"",publishDate:new Date,type:"default",extra:""}),[B,F]=t.useState(1),[W,J]=t.useState(10),[U,V]=t.useState([]),[K,G]=t.useState(!0),[q,$]=t.useState(!0),[H,Q]=t.useState(!1),[X,Y]=t.useState(null);t.useEffect(()=>{Z()},[]);const Z=async()=>{try{s(!0);const t=await ye.get("/api/option/getagentoptions"),{success:n,message:i,data:a}=t.data;if(n){const t={};for(let e in a)Object.keys(l).includes(e)&&(t[e]=a[e]);r(t),p(structuredClone(t));try{if(a.agent_announcements){const e=JSON.parse(a.agent_announcements);y(Array.isArray(e)?e:[])}}catch(e){console.error("è§£æå
¬åæ°æ®å¤±è´¥:",e),y([])}G(!1!==a.follow_main_announce),$(!1!==a.announcements_enabled),Q(an(a.translation_enabled))}else je(i)}catch(t){je(t.message)}finally{s(!1)}},ee=[{value:"default",label:e("é»è®¤")},{value:"ongoing",label:e("è¿è¡ä¸")},{value:"success",label:e("æå")},{value:"warning",label:e("è¦å")},{value:"error",label:e("é误")}],te=e=>({default:"grey",ongoing:"blue",success:"green",warning:"orange",error:"red"}[e]||"grey"),ne=[{title:e("å
容"),dataIndex:"content",key:"content",render:e=>n.jsx("div",{style:{maxWidth:"300px",wordBreak:"break-word",whiteSpace:"pre-wrap"},children:e})},{title:e("å叿¶é´"),dataIndex:"publishDate",key:"publishDate",width:180,render:e=>n.jsxs("div",{children:[n.jsx("div",{style:{fontWeight:"bold"},children:Ce(e)}),n.jsx("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",marginTop:"2px"},children:e?we(new Date(e)):"-"})]})},{title:e("ç±»å"),dataIndex:"type",key:"type",width:100,render:e=>n.jsx(j,{color:te(e),shape:"circle",children:ee.find(t=>t.value===e)?.label||e})},{title:e("说æ"),dataIndex:"extra",key:"extra",render:e=>n.jsx("div",{style:{maxWidth:"200px",wordBreak:"break-word",color:"hsl(var(--muted-foreground))"},children:e||"-"})},...H?[{title:e("ç¿»è¯"),key:"translation_status",width:110,render:(e,t)=>n.jsx(hn,{item:t,fields:Ls,onClick:()=>Y(t)})}]:[],{title:e("æä½"),key:"action",fixed:"right",width:H?230:150,render:(t,i)=>n.jsxs(g,{children:[H&&n.jsx(d,{icon:n.jsx(Ge,{size:14}),theme:"light",type:"tertiary",size:"small",className:"!rounded-full",onClick:()=>Y(i),children:e("è¯æ")}),n.jsx(d,{icon:n.jsx($e,{size:14}),theme:"light",type:"tertiary",size:"small",className:"!rounded-full",onClick:()=>ie(i),children:e("ç¼è¾")}),n.jsx(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",size:"small",className:"!rounded-full",onClick:()=>se(i),children:e("å é¤")})]})}],ie=e=>{z(e),L({content:e.content,publishDate:e.publishDate?new Date(e.publishDate):new Date,type:e.type||"default",extra:e.extra||""}),b(!0)},se=e=>{R(e),S(!0)},le={selectedRowKeys:U,onChange:(e,t)=>
1{V(e)},onSelect:(e,t,n)=>{},onSelectAll:(e,t)=>{},getCheckboxProps:e=>({disabled:!1,name:e.id})};return n.jsxs(m,{spinning:i,children:[n.jsx(a.Section,{text:n.jsxs("div",{className:"flex flex-col w-full",children:[n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-center text-blue-500",children:[n.jsx(Xe,{size:16,className:"mr-2"}),n.jsx(Fs,{children:e("代çç«ç³»ç»å
¬å管çï¼å¯ä»¥åå¸ç«ç¹éç¥åéè¦æ¶æ¯ï¼æå¤50个ï¼å端æ¾ç¤ºææ°10æ¡ï¼")})]}),H&&n.jsxs("div",{className:"flex items-center text-amber-500 mt-1",children:[n.jsx(Ge,{size:14,className:"mr-2"}),n.jsx(Fs,{type:"warning",size:"small",children:"t('å·²å¼å¯èªå¨ç¿»è¯ï¼ä¿å设置æ¶ä¼å¯¹æªç¿»è¯/åæå·²ä¿®æ¹çæ¡ç®èªå¨ç¿»è¯ä¸º 6 ç§è¯è¨')"})]})]}),n.jsx("div",{className:"mb-4 p-3 bg-gray-50 rounded-lg",children:n.jsxs("div",{className:"flex flex-col md:flex-row gap-4 items-start md:items-center",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(E,{checked:q,onChange:e=>{$(e),O(!0)}}),n.jsx(Fs,{strong:!0,children:e("å¯ç¨å
¬å模å")})]}),q&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(E,{checked:K,onChange:e=>{G(e),O(!0)}}),n.jsx(Fs,{children:e("è·é主ç«å
¬å")}),n.jsx(Fs,{type:"tertiary",size:"small",children:e(K?"ï¼å°æ¾ç¤ºä¸»ç«å
¬åï¼å¿½ç¥èªå®ä¹å
¬åï¼":"ï¼ä½¿ç¨ä¸æ¹èªå®ä¹å
¬åï¼")})]})]})}),n.jsx(I,{margin:"12px"}),n.jsx("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 w-full",children:n.jsxs("div",{className:"flex gap-2 w-full md:w-auto",children:[n.jsx(d,{theme:"light",type:"primary",icon:n.jsx(Ye,{size:14}),className:"!rounded-full w-full md:w-auto",onClick:()=>{z(null),L({content:"",publishDate:new Date,type:"default",extra:""}),b(!0)},disabled:!q||K,children:e("æ·»å å
¬å")}),n.jsxs(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",onClick:()=>{if(0===U.length)return void je(e("请å
éæ©è¦å é¤çç³»ç»å
¬å"));const t=h.filter(e=>!U.includes(e.id));y(t),V([]),O(!0),be(e("å·²å é¤ {{count}} 个系ç»å
¬åï¼è®°å¾ä¿å设置",{count:U.length}))},disabled:0===U.length||!q||K,className:"!rounded-full w-full md:w-auto",children:[e("æ¹éå é¤")," ",U.length>0&&`(${U.length})`]})]})})]}),children:q?K?n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:e("å½åè·é主ç«å
¬åï¼å°æ¾ç¤ºä¸»ç«çç³»ç»å
¬å"),style:{padding:30}}):n.jsx(v,{columns:ne,dataSource:(()=>{const e=[...h].sort((e,t)=>{const n=new Date(e.publishDate).getTime();return new Date(t.publishDate).getTime()-n}),t=(B-1)*W,n=t+W;return e.slice(t,n)})(),rowSelection:le,rowKey:"id",scroll:{x:"max-content"},pagination:{currentPage:B,pageSize:W,total:h.length,showSizeChanger:!0,showQuickJumper:!0,formatPageText:t=>e("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:t.currentStart,end:t.currentEnd,total:h.length}),pageSizeOptions:["5","10","20","30"],onChange:(e,t)=>
1{F(e),J(t)},onShowSizeChange:(e,t)=>{F(1),J(t)}},size:"middle",empty:n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:e("ææ ç³»ç»å
¬å"),style:{padding:30}}),className:"rounded-xl overflow-hidden"}):n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:e("å
¬å模åå·²ç¦ç¨"),style:{padding:30}})}),n.jsx(o,{children:n.jsx(c,{span:24,style:{textAlign:"center",marginTop:24},children:n.jsx(d,{type:"primary",size:"large",onClick:async()=>{if(ke(u,l).length>0||M){s(!0);try{let t=h;const n={...l,agent_announcements:JSON.stringify(t),follow_main_announce:K,announcements_enabled:q},i=await ye.post("/api/option/updateagentoption",n),{success:s,message:a}=i.data;s?(be(e("ä¿åæå")),p(structuredClone(l)),O(!1)):je(a||e("ä¿å失败"))}catch(t){je(t?.message||e("ä¿å失败ï¼è¯·éè¯"))}finally{s(!1)}}else je(e("æ åæ´ï¼æ éä¿å"))},loading:i,disabled:!M&&ke(l,u),children:e("ä¿å设置")})})}),n.jsx(x,{title:e(P?"ç¼è¾å
¬å":"æ·»å å
¬å"),visible:f,onOk:async()=>{if(D.content&&D.publishDate)try{A(!0);const t={...D,publishDate:D.publishDate.toISOString()};let n;if(P)n=h.map(e=>e.id===P.id?{...e,...t}:e);else{const e={id:Math.max(...h.map(e=>e.id),0)+1,...t};n=[...h,e]}y(n),O(!0),b(!1),be(e(P?"å
¬åå·²æ´æ°ï¼è®°å¾ä¿å设置":"å
¬å已添å ï¼è®°å¾ä¿å设置"))}catch(t){je(e("æä½å¤±è´¥")+": "+t.message)}finally{A(!1)}else je(e("请填å宿´çå
¬åä¿¡æ¯"))},onCancel:()=>b(!1),okText:e("ä¿å"),cancelText:e("åæ¶"),className:"rounded-xl",confirmLoading:N,children:n.jsxs(a,{layout:"vertical",initValues:D,children:[n.jsx(a.TextArea,{field:"content",label:e("å
¬åå
容"),placeholder:e("请è¾å
¥å
¬åå
容"),maxCount:500,rows:3,rules:[{required:!0,message:e("请è¾å
¥å
¬åå
容")}],onChange:e=>L({...D,content:e})}),n.jsx(a.DatePicker,{field:"publishDate",label:e("å叿¥æ"),type:"dateTime",rules:[{required:!0,message:e("è¯·éæ©å叿¥æ")}],onChange:e=>L({...D,publishDate:e})}),n.jsx(a.Select,{field:"type",label:e("å
¬åç±»å"),optionList:ee,onChange:e=>L({...D,type:e})}),n.jsx(a.Input,{field:"extra",label:e("说æä¿¡æ¯"),placeholder:e("å¯éç说æä¿¡æ¯"),maxLength:100,onChange:e=>L({...D,extra:e})})]},P?P.id:"new")}),n.jsx(x,{title:e("确认å é¤"),visible:_,onOk:()=>{if(k){const t=h.filter(e=>e.id!==k.id);y(t),O(!0),be(e("å
¬åå·²å é¤ï¼è®°å¾ä¿å设置"))}S(!1),R(null)},onCancel:()=>{S(!1),R(null)},okText:e("确认å é¤"),cancelText:e("åæ¶"),type:"warning",className:"rounded-xl",okButtonProps:{type:"danger",theme:"solid"},children:n.jsx(Fs,{children:e("ç¡®å®è¦å 餿¤å
¬ååï¼")})}),n.jsx(xn,{visible:!!X,onClose:()=>Y(null),item:X||{},fields:Bs.map(t=>({...t,label:e(t.label)})),translationEnabled:H,onApply:e=>{if(!X)return;const t=h.map(t=>t.id===X.id?{...t,...e}:t);y(t),O(!0)}})]})},Js=["description","route"],Us=[{key:"description",label:"说æ",type:"input",maxLength:200},{key:"route",label:"线路æè¿°",type:"input",maxLength:100}],{Text:Vs}=u,Ks=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,r]=t.useState({agent_api_info:"",api_info_enabled:!0}),[u,p]=t.useState(l),[h,y]=t.useState([]),[f,b]=t.useState(!1),[_,S]=t.useState(!1),[k,P]=t.useState(null),[z,N]=t.useState(null),[A,M]=t.useState(!1),[O,D]=t.useState(!1),[L,B]=t.useState({url:"",description:"",route:"",color:"blue"}),[F,W]=t.useState(1),[J,U]=t.useState(10),[V,K]=t.useState([]),[G,q]=t.useState(!0),[$,H]=t.useState(!1),[Q,X]=t.useState(null);t.useEffect(()=>{Y()},[]);const Y=async()=>{try{s(!0);const t=await ye.get("/api/option/getagentoptions"),{success:n,message:i,data:a}=t.data;if(n){const t={};for(let e in a)Object.keys(l).includes(e)&&(t[e]=a[e]);r(t),p(structuredClone(t));try{if(a.agent_api_info){const e=JSON.parse(a.agent_api_info);y(Array.isArray(e)?e:[])}}catch(e){console.error("è§£æAPIä¿¡æ¯æ°æ®å¤±è´¥:",e),y([])}q(!1!==a.api_info_enabled),H(an(a.translation_enabled))}else je(i)}catch(t){je(t.message)}finally{s(!1)}},Z=[{title:"ID",dataIndex:"id"},{title:e("APIå°å"),dataIndex:"url",render:(e,t)=>n.jsx(j,{color:t.color,className:"!rounded-full",style:{maxWidth:"280px"},children:e})},{title:e("线路æè¿°"),dataIndex:"route",render:(e,t)=>n.jsx(j,{shape:"circle",children:e})},{title:e("说æ"),dataIndex:"description",ellipsis:!0,render:(e,t)=>n.jsx(j,{shape:"circle",children:e||"-"})},{title:e("é¢è²"),dataIndex:"color",render:e=>n.jsx(R,{size:"extra-extra-small",color:e})},...$?[{title:e("ç¿»è¯"),key:"translation_status",width:110,render:(e,t)=>n.jsx(hn,{item:t,fields:Js,onClick:()=>X(t)})}]:[],{title:e("æä½"),fixed:"right",width:$?230:150,render:(t,i)=>n.jsxs(g,{children:[$&&n.jsx(d,{icon:n.jsx(Ge,{size:14}),theme:"light",type:"tertiary",size:"small",className:"!rounded-full",onClick:()=>X(i),children:e("è¯æ")}),n.jsx(d,{icon:n.jsx($e,{size:14}),theme:"light",type:"tertiary",size:"small",className:"!rounded-full",onClick:()=>ee(i),children:e("ç¼è¾")}),n.jsx(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",size:"small",className:"!rounded-full",onClick:()=>te(i),children:e("å é¤")})]})}],ee=e=>{N(e),B({url:e.url,description:e.description,route:e.route,color:e.color||"blue"}),b(!0)},te=e=>{P(e),S(!0)},ne={selectedRowKeys:V,onChange:(e,t)=>
1{K(e)},onSelect:(e,t,n)=>{},onSelectAll:(e,t)=>{},getCheckboxProps:e=>({disabled:!1,name:e.id})};return n.jsxs(m,{spinning:i,children:[n.jsx(a.Section,{text:n.jsxs("div",{className:"flex flex-col w-full",children:[n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-center text-blue-500",children:[n.jsx(it,{size:16,className:"mr-2"}),n.jsx(Vs,{children:e("APIä¿¡æ¯ç®¡çï¼å¯ä»¥é
ç½®å¤ä¸ªAPIå°åç¨äºç¶æå±ç¤ºåè´è½½åè¡¡ï¼æå¤30个ï¼")})]}),$&&n.jsxs("div",{className:"flex items-center text-amber-500 mt-1",children:[n.jsx(Ge,{size:14,className:"mr-2"}),n.jsx(Vs,{type:"warning",size:"small",children:"t('å·²å¼å¯èªå¨ç¿»è¯ï¼ä¿å设置æ¶ä¼å¯¹æªç¿»è¯/åæå·²ä¿®æ¹çæ¡ç®èªå¨ç¿»è¯ä¸º 6 ç§è¯è¨')"})]})]}),n.jsx("div",{className:"mb-4 p-3 bg-gray-50 rounded-lg",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(E,{checked:G,onChange:e=>{q(e),D(!0)}}),n.jsx(Vs,{strong:!0,children:e("å¯ç¨APIä¿¡æ¯æ¨¡å")}),n.jsx(Vs,{type:"tertiary",size:"small",children:e("ï¼å
³éåå°ä¸ä¼å¨å端æ¾ç¤ºAPIç¶æä¿¡æ¯ï¼")})]})}),n.jsx(I,{margin:"12px"}),n.jsx("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 w-full",children:n.jsxs("div",{className:"flex gap-2 w-full md:w-auto",children:[n.jsx(d,{theme:"light",type:"primary",icon:n.jsx(Ye,{size:14}),className:"!rounded-full w-full md:w-auto",onClick:()=>{N(null),B({url:"",description:"",route:"",color:"blue"}),b(!0)},disabled:!G,children:e("æ·»å API")}),n.jsxs(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",onClick:()=>{if(0===V.length)return void je(e("请å
éæ©è¦å é¤çAPIä¿¡æ¯"));const t=h.filter(e=>!V.includes(e.id));y(t),K([]),D(!0),be(e("å·²å é¤ {{count}} 个APIä¿¡æ¯ï¼è®°å¾ä¿å设置",{count:V.length}))},disabled:0===V.length||!G,className:"!rounded-full w-full md:w-auto",children:[e("æ¹éå é¤")," ",V.length>0&&`(${V.length})`]})]})})]}),children:G?n.jsx(v,{columns:Z,dataSource:(()=>{const e=(F-1)*J,t=e+J;return h.slice(e,t)})(),rowSelection:ne,rowKey:"id",scroll:{x:"max-content"},pagination:{currentPage:F,pageSize:J,total:h.length,showSizeChanger:!0,showQuickJumper:!0,formatPageText:t=>e("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:t.currentStart,end:t.currentEnd,total:h.length}),pageSizeOptions:["5","10","20","30"],onChange:(e,t)=>
1{W(e),U(t)},onShowSizeChange:(e,t)=>{W(1),U(t)}},size:"middle",empty:n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:e("ææ APIä¿¡æ¯"),style:{padding:30}}),className:"rounded-xl overflow-hidden"}):n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:e("APIä¿¡æ¯æ¨¡åå·²ç¦ç¨"),style:{padding:30}})}),n.jsx(o,{children:n.jsx(c,{span:24,style:{textAlign:"center",marginTop:24},children:n.jsx(d,{type:"primary",size:"large",onClick:async()=>{if(!ke(l,u)||O){s(!0);try{let t=h;const n={...l,agent_api_info:JSON.stringify(t),api_info_enabled:G},i=await ye.post("/api/option/updateagentoption",n),{success:s,message:a}=i.data;s?(be(e("ä¿åæå")),p(structuredClone(l)),D(!1)):je(a||e("ä¿å失败"))}catch(t){je(t?.message||e("ä¿å失败ï¼è¯·éè¯"))}finally{s(!1)}}else je(e("æ åæ´ï¼æ éä¿å"))},loading:i,disabled:!O&&ke(l,u),children:e("ä¿å设置")})})}),n.jsx(x,{title:e(z?"ç¼è¾API":"æ·»å API"),visible:f,onOk:async()=>{if(L.url&&L.route&&L.description){try{new URL(L.url)}catch(t){return void je(e("请è¾å
¥ææçURLå°å"))}try{let t;if(M(!0),z)t=h.map(e=>e.id===z.id?{...e,...L}:e);else{const e={id:Math.max(...h.map(e=>e.id),0)+1,...L};t=[...h,e]}y(t),D(!0),b(!1),be(e(z?"APIä¿¡æ¯å·²æ´æ°ï¼è®°å¾ä¿å设置":"APIä¿¡æ¯å·²æ·»å ï¼è®°å¾ä¿å设置"))}catch(t){je(e("æä½å¤±è´¥")+": "+t.message)}finally{M(!1)}}else je(e("请填å宿´çAPIä¿¡æ¯"))},onCancel:()=>b(!1),okText:e("ä¿å"),cancelText:e("åæ¶"),className:"rounded-xl",confirmLoading:A,children:n.jsxs(a,{layout:"vertical",initValues:L,children:[n.jsx(a.Input,{field:"url",label:e("APIå°å"),placeholder:"https://api.example.com",rules:[{required:!0,message:e("请è¾å
¥APIå°å")}],onChange:e=>B({...L,url:e})}),n.jsx(a.Input,{field:"route",label:e("线路æè¿°"),placeholder:e("å¦ï¼é¦æ¸¯çº¿è·¯"),rules:[{required:!0,message:e("请è¾å
¥çº¿è·¯æè¿°")}],onChange:e=>B({...L,route:e})}),n.jsx(a.Input,{field:"description",label:e("说æ"),placeholder:e("å¦ï¼å¤§å¸¦å®½æ¹éåæå¾çæ¨è"),rules:[{required:!0,message:e("请è¾å
¥è¯´æ")}],onChange:e=>B({...L,description:e})}),n.jsx(a.Select,{field:"color",label:e("æ è¯é¢è²"),optionList:[{value:"blue",label:"blue"},{value:"green",label:"green"},{value:"cyan",label:"cyan"},{value:"purple",label:"purple"},{value:"pink",label:"pink"},{value:"red",label:"red"},{value:"orange",label:"orange"},{value:"amber",label:"amber"},{value:"yellow",label:"yellow"},{value:"lime",label:"lime"},{value:"light-green",label:"light-green"},{value:"teal",label:"teal"},{value:"light-blue",label:"light-blue"},{value:"indigo",label:"indigo"},{value:"violet",label:"violet"},{value:"grey",label:"grey"}],onChange:e=>B({...L,color:e}),render:e=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx(R,{size:"extra-extra-small",color:e.value}),e.label]})})]},z?z.id:"new")}),n.jsx(x,{title:e("确认å é¤"),visible:_,onOk:()=>{if(k){const t=h.filter(e=>e.id!==k.id);y(t),D(!0),be(e("APIä¿¡æ¯å·²å é¤ï¼è®°å¾ä¿å设置"))}S(!1),P(null)},onCancel:()=>{S(!1),P(null)},okText:e("确认å é¤"),cancelText:e("åæ¶"),type:"warning",className:"rounded-xl",okButtonProps:{type:"danger",theme:"solid"},children:n.jsx(Vs,{children:e("ç¡®å®è¦å 餿¤APIä¿¡æ¯åï¼")})}),n.jsx(xn,{visible:!!Q,onClose:()=>X(null),item:Q||{},fields:Us.map(t=>({...t,label:e(t.label)})),translationEnabled:$,onApply:e=>{if(!Q)return;const t=h.map(t=>t.id===Q.id?{...t,...e}:t);y(t),D(!0)}})]})},Gs=["question","answer"],qs=[{key:"question",label:"é®é¢æ é¢",type:"input",maxLength:200},{key:"answer",label:"åçå
容",type:"textarea",rows:5,maxCount:1e3}],{Text:$s}=u,Hs=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,r]=t.useState({agent_faq:"",follow_main_faq:!0,faq_enabled:!0}),[u,p]=t.useState(l),[h,y]=t.useState([]),[j,f]=t.useState(!1),[b,_]=t.useState(!1),[S,k]=t.useState(null),[R,P]=t.useState(null),[z,N]=t.useState(!1),[A,M]=t.useState(!1),[O,D]=t.useState({question:"",answer:""}),[L,B]=t.useState(1),[F,W]=t.useState(10),[J,U]=t.useState([]),[V,K]=t.useState(!0),[G,q]=t.useState(!0),[$,H]=t.useState(!1),[Q,X]=t.useState(null);t.useEffect(()=>{Y()},[]);const Y=async()=>{try{s(!0);const t=await ye.get("/api/option/getagentoptions"),{success:n,message:i,data:a}=t.data;if(n){const t={};for(let e in a)Object.keys(l).includes(e)&&(t[e]=a[e]);r(t),p(structuredClone(t));try{if(a.agent_faq){const e=JSON.parse(a.agent_faq);y(Array.isArray(e)?e:[])}}catch(e){console.error("è§£æFAQæ°æ®å¤±è´¥:",e),y([])}K(!1!==a.follow_main_faq),q(!1!==a.faq_enabled),H(an(a.translation_enabled))}else je(i)}catch(t){je(t.message)}finally{s(!1)}},Z=[{title:e("é®é¢æ é¢"),dataIndex:"question",key:"question",render:e=>n.jsx("div",{style:{maxWidth:"300px",wordBreak:"break-word",fontWeight:"bold"},children:e})}
1,{title:e("åçå
容"),dataIndex:"answer",key:"answer",render:e=>n.jsx("div",{style:{maxWidth:"400px",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"hsl(var(--foreground) / 0.80)"},children:e})},...$?[{title:e("ç¿»è¯"),key:"translation_status",width:110,render:(e,t)=>n.jsx(hn,{item:t,fields:Gs,onClick:()=>X(t)})}]:[],{title:e("æä½"),key:"action",fixed:"right",width:$?230:150,render:(t,i)=>n.jsxs(g,{children:[$&&n.jsx(d,{icon:n.jsx(Ge,{size:14}),theme:"light",type:"tertiary",size:"small",className:"!rounded-full",onClick:()=>X(i),children:e("è¯æ")}),n.jsx(d,{icon:n.jsx($e,{size:14}),theme:"light",type:"tertiary",size:"small",className:"!rounded-full",onClick:()=>ee(i),children:e("ç¼è¾")}),n.jsx(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",size:"small",className:"!rounded-full",onClick:()=>te(i),children:e("å é¤")})]})}],ee=e=>{P(e),D({question:e.question,answer:e.answer}),f(!0)},te=e=>{k(e),_(!0)},ne={selectedRowKeys:J,onChange:(e,t)=>{U(e)},onSelect:(e,t,n)=>{},onSelectAll:(e,t)=>{},getCheckboxProps:e=>({disabled:!1,name:e.id})};return n.jsxs(m,{spinning:i,children:[n.jsx(a.Section,{text:n.jsxs("div",{className:"flex flex-col w-full",children:[n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-center text-blue-500",children:[n.jsx(tt,{size:16,className:"mr-2"}),n.jsx($s,{children:e("代çç«å¸¸è§é®ç管çï¼ä¸ºç¨æ·æä¾å¸¸è§é®é¢ççæ¡ï¼æå¤30个ï¼å端æ¾ç¤ºææ°15æ¡ï¼")})]}),$&&n.jsxs("div",{className:"flex items-center text-amber-500 mt-1",children:[n.jsx(Ge,{size:14,className:"mr-2"}),n.jsx($s,{type:"warning",size:"small",children:"t('å·²å¼å¯èªå¨ç¿»è¯ï¼ä¿å设置æ¶ä¼å¯¹æªç¿»è¯/åæå·²ä¿®æ¹çæ¡ç®èªå¨ç¿»è¯ä¸º 6 ç§è¯è¨')"})]})]}),n.jsx("div",{className:"mb-4 p-3 bg-gray-50 rounded-lg",children:n.jsxs("div",{className:"flex flex-col md:flex-row gap-4 items-start md:items-center",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(E,{checked:G,onChange:e=>{q(e),M(!0)}}),n.jsx($s,{strong:!0,children:e("å¯ç¨é®ç模å")})]}),G&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(E,{checked:V,onChange:e=>{K(e),M(!0)}}),n.jsx($s,{children:e("è·é主ç«é®ç")}),n.jsx($s,{type:"tertiary",size:"small",children:e(V?"ï¼å°æ¾ç¤ºä¸»ç«é®çï¼å¿½ç¥èªå®ä¹é®çï¼":"ï¼ä½¿ç¨ä¸æ¹èªå®ä¹é®çï¼")})]})]})}),n.jsx(I,{margin:"12px"}),n.jsx("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 w-full",children:n.jsxs("div",{className:"flex gap-2 w-full md:w-auto",children:[n.jsx(d,{theme:"light",type:"primary",icon:n.jsx(Ye,{size:14}),className:"!rounded-full w-full md:w-auto",onClick:()=>{P(null),D({question:"",answer:""}),f(!0)},disabled:!G||V,children:e("æ·»å é®ç")}),n.jsxs(d,{icon:n.jsx(He,{size:14}),type:"danger",theme:"light",onClick:()=>{if(0===J.length)return void je(e("请å
éæ©è¦å é¤ç常è§é®ç"));const t=h.filter(e=>!J.includes(e.id));y(t),U([]),M(!0),be(e("å·²å é¤ {{count}} 个常è§é®çï¼è®°å¾ä¿å设置",{count:J.length}))},disabled:0===J.length||!G||V,className:"!rounded-full w-full md:w-auto",children:[e("æ¹éå é¤")," ",J.length>0&&`(${J.length})`]})]})})]}),children:G?V?n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:e("å½åè·é主ç«é®çï¼å°æ¾ç¤ºä¸»ç«ç常è§é®ç"),style:{padding:30}}):n.jsx(v,{columns:Z,dataSource:(()=>{const e=(L-1)*F,t=e+F;return h.slice(e,t)})(),rowSelection:ne,rowKey:"id",scroll:{x:"max-content"},pagination:{currentPage:L,pageSize:F,total:h.length,showSizeChanger:!0,showQuickJumper:!0,formatPageText:t=>e("第 {{start}} - {{end}} æ¡ï¼å
± {{total}} æ¡",{start:t.currentStart,end:t.currentEnd,total:h.length}),pageSizeOptions:["5","10","20","30"],onChange:(e,t)=>
1{B(e),W(t)},onShowSizeChange:(e,t)=>{B(1),W(t)}},size:"middle",empty:n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:e("ææ å¸¸è§é®ç"),style:{padding:30}}),className:"rounded-xl overflow-hidden"}):n.jsx(C,{image:n.jsx(T,{style:{width:150,height:150}}),darkModeImage:n.jsx(w,{style:{width:150,height:150}}),description:e("é®ç模åå·²ç¦ç¨"),style:{padding:30}})}),n.jsx(o,{children:n.jsx(c,{span:24,style:{textAlign:"center",marginTop:24},children:n.jsx(d,{type:"primary",size:"large",onClick:async()=>{if(!ke(l,u)||A){s(!0);try{let t=h;const n={...l,agent_faq:JSON.stringify(t),follow_main_faq:V,faq_enabled:G},i=await ye.post("/api/option/updateagentoption",n),{success:s,message:a}=i.data;s?(be(e("ä¿åæå")),p(structuredClone(l)),M(!1)):je(a||e("ä¿å失败"))}catch(t){je(t?.message||e("ä¿å失败ï¼è¯·éè¯"))}finally{s(!1)}}else je(e("æ åæ´ï¼æ éä¿å"))},loading:i,disabled:!A&&ke(l,u),children:e("ä¿å设置")})})}),n.jsx(x,{title:e(R?"ç¼è¾é®ç":"æ·»å é®ç"),visible:j,onOk:async()=>{if(O.question&&O.answer)try{let t;if(N(!0),R)t=h.map(e=>e.id===R.id?{...e,...O}:e);else{const e={id:Math.max(...h.map(e=>e.id),0)+1,...O};t=[...h,e]}y(t),M(!0),f(!1),be(e(R?"é®çå·²æ´æ°ï¼è®°å¾ä¿å设置":"é®ç已添å ï¼è®°å¾ä¿å设置"))}catch(t){je(e("æä½å¤±è´¥")+": "+t.message)}finally{N(!1)}else je(e("请填å宿´çé®çä¿¡æ¯"))},onCancel:()=>f(!1),okText:e("ä¿å"),cancelText:e("åæ¶"),className:"rounded-xl",confirmLoading:z,width:800,children:n.jsxs(a,{layout:"vertical",initValues:O,children:[n.jsx(a.Input,{field:"question",label:e("é®é¢æ é¢"),placeholder:e("请è¾å
¥é®é¢æ é¢"),maxLength:200,rules:[{required:!0,message:e("请è¾å
¥é®é¢æ é¢")}],onChange:e=>D({...O,question:e})}),n.jsx(a.TextArea,{field:"answer",label:e("åçå
容"),placeholder:e("请è¾å
¥åçå
容"),maxCount:1e3,rows:6,rules:[{required:!0,message:e("请è¾å
¥åçå
容")}],onChange:e=>D({...O,answer:e})})]},R?R.id:"new")}),n.jsx(x,{title:e("确认å é¤"),visible:b,onOk:()=>{if(S){const t=h.filter(e=>e.id!==S.id);y(t),M(!0),be(e("é®çå·²å é¤ï¼è®°å¾ä¿å设置"))}_(!1),k(null)},onCancel:()=>{_(!1),k(null)},okText:e("确认å é¤"),cancelText:e("åæ¶"),type:"warning",className:"rounded-xl",okButtonProps:{type:"danger",theme:"solid"},children:n.jsx($s,{children:e("ç¡®å®è¦å 餿¤é®çåï¼")})}),n.jsx(xn,{visible:!!Q,onClose:()=>X(null),item:Q||{},fields:qs.map(t=>({...t,label:e(t.label)})),translationEnabled:$,onApply:e=>{if(!Q)return;const t=h.map(t=>t.id===Q.id?{...t,...e}:t);y(t),M(!0)}})]})},{Text:Qs}=u,Xs=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,r]=t.useState({sms_login_enabled:!1,sms_provider:"",sms_secret_id:"",sms_secret_key:"",sms_region:"",sms_sdk_app_id:"",sms_sign_name:"",sms_template_id:"",sms_code_expire_minutes:5,sms_rate_limit_minutes:1,sms_rate_limit_count:1,sms_mos_username:"",sms_mos_password:"",sms_mos_signature:"",sms_mos_content_template:"æ¨çéªè¯ç 为{code}ï¼{expire}åéå
ææï¼è¯·å¿æ³é²ã",sms_mos_biz_type:"",sms_mos_endpoint:"https://ns.mosapi.cn:9100"}),[u,p]=t.useState(l),h=t.useRef();function x(e){return t=>{r(n=>({...n,[e]:t}))}}return t.useEffect(()=>{(async()=>{try{const e=await ye.get("/api/option/getagentoptions"),{success:t,message:n,data:i}=e.data;if(t){const e={};for(let t in i)Object.keys(l).includes(t)&&(e[t]=i[t]);e.sms_login_enabled=!0===i.sms_login_enabled,e.sms_code_expire_minutes=Number(i.sms_code_expire_minutes)||5,e.sms_rate_limit_minutes=Number(i.sms_rate_limit_minutes)||1,e.sms_rate_limit_count=Number(i.sms_rate_limit_count)||1,r(e),p(structuredClone(e)),h.current&&h.current.setValues(e)}else je(n)}catch(e){je(e.message)}})()},[]),n.jsx(m,{spinning:i,children:n.jsxs(a,{values:l,getFormApi:e=>h.current=e,style:{marginBottom:15},children:[n.jsx(a.Section,{text:e("çä¿¡éªè¯ç ç»å½"),children:n.jsx(o,{gutter:16,children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"sms_login_enabled",label:e("å¯ç¨çä¿¡éªè¯ç ç»å½"),checkedText:e("å¼"),uncheckedText:e("å
³"),onChange:x("sms_login_enabled")}),n.jsx(Qs,{type:"tertiary",style:{fontSize:12,display:"block",marginTop:6},children:e("å¼å¯åï¼ç¨æ·å¯ä½¿ç¨ææºå·+éªè¯ç ç»å½ï¼éé
ç½®ä¸æ¹çä¿¡æå¡ä¿¡æ¯")})]})})}),n.jsxs(a.Section,{text:e("çä¿¡æå¡é
ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,children:n.jsxs(a.Select,{field:"sms_provider",label:e("çä¿¡æå¡æä¾å"),placeholder:e("è¯·éæ©æå¡æä¾å"),style:{width:"100%"}
1,initValue:l.sms_provider,onChange:e=>{r(t=>({...t,sms_provider:e}))},children:[n.jsx(a.Select.Option,{value:"tencent",children:e("è
¾è®¯äºçä¿¡")}),n.jsx(a.Select.Option,{value:"aliyun",children:e("é¿éäºçä¿¡")}),n.jsx(a.Select.Option,{value:"xuanwu",children:e("çæ¦äºMOSçä¿¡")})]})}),"xuanwu"!==l.sms_provider&&n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.Input,{field:"sms_region",label:e("æå¡åºå"),placeholder:"ap-guangzhou",extraText:e("è
¾è®¯äºé»è®¤ ap-guangzhouï¼é¿éäºé»è®¤ cn-hangzhou"),onChange:x("sms_region"),showClear:!0})}),"xuanwu"===l.sms_provider&&n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.Input,{field:"sms_mos_endpoint",label:e("æ¥å
¥å°å"),placeholder:"https://ns.mosapi.cn:9100",extraText:e("é»è®¤ https://ns.mosapi.cn:9100ï¼ä¸è¬æ éä¿®æ¹"),initValue:l.sms_mos_endpoint,onChange:x("sms_mos_endpoint"),showClear:!0})})]}),"xuanwu"!==l.sms_provider&&n.jsxs(n.Fragment,{children:[n.jsxs(o,{gutter:16,style:{marginTop:8},children:[n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.Input,{field:"sms_secret_id",label:e("Secret ID"),autoComplete:"off",placeholder:u.sms_secret_id?e("å·²é
ç½®ï¼è¾å
¥æ°å¼ä»¥æ´æ°ï¼"):e("请è¾å
¥ Secret ID / AccessKey ID"),onChange:x("sms_secret_id"),showClear:!0})}),n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.Input,{field:"sms_secret_key",label:e("Secret Key"),autoComplete:"new-password",type:"password",placeholder:u.sms_secret_key?e("å·²é
ç½®ï¼è¾å
¥æ°å¼ä»¥æ´æ°ï¼"):e("请è¾å
¥ Secret Key / AccessKey Secret"),onChange:x("sms_secret_key"),showClear:!0})})]}),n.jsxs(o,{gutter:16,style:{marginTop:8},children:[n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.Input,{field:"sms_sdk_app_id",label:e("SDK App ID"),placeholder:"1400xxxxxx",extraText:e("è
¾è®¯äºä¸ç¨ï¼å¨çä¿¡æ§å¶å°åºç¨å表è·å"),onChange:x("sms_sdk_app_id"),showClear:!0})}),n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.Input,{field:"sms_sign_name",label:e("çä¿¡ç¾å"),placeholder:e("请è¾å
¥çä¿¡ç¾å"),onChange:x("sms_sign_name"),showClear:!0})}),n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.Input,{field:"sms_template_id",label:e("æ¨¡æ¿ ID"),placeholder:"123456",extraText:e("模æ¿ç¤ºä¾ï¼æ¨çéªè¯ç æ¯{1}ï¼{2}åéå
ææ"),onChange:x("sms_template_id"),showClear:!0})})]})]}),"xuanwu"===l.sms_provider&&n.jsxs(n.Fragment,{children:[n.jsxs(o,{gutter:16,style:{marginTop:8},children:[n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.Input,{field:"sms_mos_username",label:e("MOS è´¦å·"),autoComplete:"off",placeholder:e("请è¾å
¥çæ¦äº MOS è´¦å·"),initValue:l.sms_mos_username,onChange:x("sms_mos_username"),showClear:!0})}),n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.Input,{field:"sms_mos_password",label:e("MOS å¯ç "),autoComplete:"new-password",type:"password",placeholder:u.sms_mos_password?e("å·²é
ç½®ï¼è¾å
¥æ°å¼ä»¥æ´æ°ï¼"):e("请è¾å
¥çæ¦äº MOS å¯ç "),onChange:x("sms_mos_password"),showClear:!0})}),n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.Input,{field:"sms_mos_signature",label:e("çä¿¡ç¾å"),placeholder:e("å¦ï¼çæ¦ç§æ"),extraText:e("ä¼èªå¨æ¼æ¥å°å
容å¼å¤´ï¼æ éåè¿å
容模æ¿"),initValue:l.sms_mos_signature,onChange:x("sms_mos_signature"),showClear:!0})})]}),n.jsxs(o,{gutter:16,style:{marginTop:8},children:[n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.Input,{field:"sms_mos_biz_type",label:e("ä¸å¡ç±»å IDï¼bizTypeï¼å¯éï¼"),placeholder:"100",initValue:l.sms_mos_biz_type,onChange:x("sms_mos_biz_type"),showClear:!0})}),n.jsx(c,{xs:24,sm:24,md:16,children:n.jsx(a.Input,{field:"sms_mos_content_template",label:e("éªè¯ç å
容模æ¿"),placeholder:"æ¨çéªè¯ç 为{code}ï¼{expire}åéå
ææï¼è¯·å¿æ³é²ã",extraText:e("å ä½ç¬¦ {code} 为éªè¯ç ï¼{expire} ä¸ºæææåéæ°ï¼å¿
é¡»å
å« {code}"),initValue:l.sms_mos_content_template,onChange:x("sms_mos_content_template"),showClear:!0})})]})]})]}),n.jsx(a.Section,{text:e("é¢çæ§å¶"),children:n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.InputNumber,{field:"sms_code_expire_minutes",label:e("éªè¯ç æææï¼åéï¼"),placeholder:"5",min:1,max:30,initValue:l.sms_code_expire_minutes,onChange:e=>{r(t=>({...t,sms_code_expire_minutes:e}))},style:{width:"100%"}})}),n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.InputNumber,{field:"sms_rate_limit_minutes",label:e("é¢çéå¶å¨æï¼åéï¼"),placeholder:"1",min:1,max:60,initValue:l.sms_rate_limit_minutes,onChange:e=>{r(t=>({...t,sms_rate_limit_minutes:e}))},style:{width:"100%"}})}),n.jsx(c,{xs:24,sm:12,md:8,children:n.jsx(a.InputNumber,{field:"sms_rate_limit_count",label:e("卿å
æå¤§å鿬¡æ°"),placeholder:"1",min:1,max:10,initValue:l.sms_rate_limit_count,onChange:e=>{r(t=>({...t,sms_rate_limit_count:e}))},style:{width:"100%"}})})]})}),n.jsx(o,{style:{marginTop:8},children:n.jsx(c,{children:n.jsx(d,{type:"primary",onClick:()=>{s(!0);const t={...l};t.sms_secret_id||delete t.sms_secret_id,t.sms_secret_key||delete t.sms_secret_key,t.sms_mos_password||delete t.sms_mos_password,ye.post("/api/option/updateagentoption",t).then(t=>{const{success:n,message:i}=t.data;n?(be(e("ä¿åæå")),p(structuredClone(l))):je(i||e("ä¿å失败"))}).catch(t=>{je(t.message||e("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{s(!1)})},loading:i,children:e("ä¿åç信设置")})})})]})})},{Text:Ys}=u,Zs="https://meiye.clife.cn/v1/homing/auth/oauth2/token",el="https://homing.clife.cn/v1/homing/open/api/user/getUserinfo",tl=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,u]=t.useState(!1),[p,x]=t.useState(!1),[g,j]=t.useState({hongming_sso_enabled:!1,hongming_app_key:"",hongming_app_secret:"",hongming_token_url:Zs,hongming_user_info_url:el,hongming_register_api_key:""}),[f,b]=t.useState(null);t.useEffect(()=>{(async()=>{s(!0);try{const e=await ye.get("/api/option/getagentoptions"),{success:t,message:n,data:i}=e.data;t?j(e=>({...e,hongming_sso_enabled:!!i.hongming_sso_enabled,hongming_app_key:i.hongming_app_key||"",hongming_app_secret:i.hongming_app_secret||"",hongming_token_url:i.hongming_token_url||Zs,hongming_user_info_url:i.hongming_user_info_url||el,hongming_register_api_key:i.hongming_register_api_key||""})):je(n)}catch(e){je(e.message)}finally{s(!1)}})()},[]);const _=async e=>{try{await navigator.clipboard.writeText(e),y.success({content:"å·²å¤å¶",duration:2})}catch{y.error({content:"å¤å¶å¤±è´¥ï¼è¯·æå¨å¤å¶",duration:3})}},S=`${window.location.origin}/oauth/hongming`;return n.jsx(m,{spinning:i,children:n.jsxs(a,{style:{marginBottom:15},children:[n.jsx(a.Section,{text:"åç¹ç»å½æ¥å
¥è¯´æ",children:n.jsx(h,{type:"info",description:n.jsxs("div",{children:[n.jsx("div",{style:{marginBottom:8,fontWeight:500},children:"ç»å½æµç¨"}),n.jsxs("ol",{style:{margin:"0 0 12px 0",paddingLeft:20,lineHeight:"1.8"},children:[n.jsxs("li",{children:["ç¨æ·å¨é¸¿æºä¸å¡ç³»ç»ç¹å»ç»å½ï¼é¸¿æºå¹³å°çæ ",n.jsx("code",{children:"auth_code"})]}),n.jsxs("li",{children:["鸿æºå¹³å°å°ç¨æ·éå®åè³æ¬ç«åè°å°åï¼æºå¸¦ ",n.jsx("code",{children:"auth_code"})," åæ°"]}),n.jsxs("li",{children:["æ¬ç«åç«¯ç¨ ",n.jsx("code",{children:"auth_code"}
1)," åé¸¿æºæ¢åç¨æ· ",n.jsx("code",{children:"orgId"}),"ï¼å®æç»å½"]})]}),n.jsx("div",{style:{marginBottom:6,fontWeight:500},children:"éå¨é¸¿æºå¹³å°é
ç½®çåè°å°å"}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("code",{style:{background:"#f5f5f5",padding:"6px 12px",borderRadius:4,fontSize:13,flex:1,wordBreak:"break-all"},children:S}),n.jsx(d,{size:"small",icon:n.jsx(yt,{size:16}),onClick:()=>_(S)})]}),n.jsxs("div",{style:{marginTop:8,fontSize:12,color:"#888"},children:["鸿æºå¹³å°å®é
跳转示ä¾ï¼",n.jsxs("code",{children:[S,"?auth_code=xxxxxx"]})]})]}),style:{marginBottom:0}})}),n.jsxs(a.Section,{text:"鸿æºå¹³å°é
ç½®",children:[n.jsx(o,{gutter:16,children:n.jsx(c,{span:24,children:n.jsx(a.Slot,{label:{text:"å¯ç¨é¸¿æºSSO"},children:n.jsx(E,{checked:g.hongming_sso_enabled,onChange:e=>j(t=>({...t,hongming_sso_enabled:e})),checkedText:"å¼",uncheckedText:"å
³"})})})}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,children:n.jsx(a.Slot,{label:{text:"AppKeyï¼client_idï¼"},children:n.jsx(k,{value:g.hongming_app_key,onChange:e=>j(t=>({...t,hongming_app_key:e})),placeholder:"请è¾å
¥é¸¿æºå¹³å° AppKey",showClear:!0})})}),n.jsx(c,{xs:24,sm:12,children:n.jsx(a.Slot,{label:{text:"AppSecret"},children:n.jsx(k,{value:g.hongming_app_secret,onChange:e=>j(t=>({...t,hongming_app_secret:e})),placeholder:"请è¾å
¥é¸¿æºå¹³å° AppSecret",mode:"password",showClear:!0})})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,children:n.jsx(a.Slot,{label:{text:"Token æ¥å£å°å"},children:n.jsx(k,{value:g.hongming_token_url,onChange:e=>j(t=>({...t,hongming_token_url:e})),placeholder:Zs,showClear:!0})})}),n.jsx(c,{xs:24,sm:12,children:n.jsx(a.Slot,{label:{text:"getUserInfo æ¥å£å°å"},children:n.jsx(k,{value:g.hongming_user_info_url,onChange:e=>j(t=>({...t,hongming_user_info_url:e})),placeholder:el,showClear:!0})})})]}),n.jsx(d,{type:"primary",loading:l,onClick:async()=>{u(!0);try{const t=await ye.post("/api/option/updateagentoption",{hongming_sso_enabled:g.hongming_sso_enabled,hongming_app_key:g.hongming_app_key,hongming_app_secret:g.hongming_app_secret,hongming_token_url:g.hongming_token_url,hongming_user_info_url:g.hongming_user_info_url}),{success:n,message:i}=t.data;n?be(e("ä¿åæå")):je(i)}catch(t){je(t.message)}finally{u(!1)}},style:{marginTop:8},children:"ä¿å鸿æºå¹³å°é
ç½®"})]}),n.jsxs(a.Section,{text:"注å API åæ®",children:[n.jsx(h,{type:"info",description:n.jsxs("div",{children:[n.jsx("div",{style:{marginBottom:8},children:"鸿æºä¸å¡ç³»ç»è°ç¨ä»¥ä¸æ¥å£åæ¬ç«æ³¨åç¨æ·ï¼"}),n.jsxs("div",{style:{fontFamily:"monospace",background:"#f5f5f5",padding:"8px 12px",borderRadius:6,fontSize:13},children:["POST ",window.location.origin,"/api/sso/hongming/register"]}),n.jsxs("div",{style:{marginTop:8,fontSize:12,color:"#666"},children:["请æ±å¤´ï¼",n.jsx("code",{children:"X-Api-Key"})," å ",n.jsx("code",{children:"X-Api-Secret"}),n.jsx("br",{}),"请æ±ä½ï¼",n.jsx("code",{children:"org_id"}),"ï¼å¿
å¡«ï¼é¸¿æºå¹³å°ç orgIdï¼"]})]}),style:{marginBottom:16}}),n.jsxs(o,{gutter:16,style:{alignItems:"center"},children:[n.jsx(c,{xs:24,sm:16,children:n.jsx(a.Slot,{label:{text:"å½å Api Key"},children:n.jsx(k,{value:g.hongming_register_api_key,placeholder:"å°æªçæ",disabled:!0,suffix:g.hongming_register_api_key?n.jsx(yt,{size:16,style:{cursor:"pointer"},onClick:()=>_(g.hongming_register_api_key)}):null})})}),n.jsx(c,{xs:24,sm:8,children:n.jsx("div",{style:{paddingTop:28},children:n.jsx(d,{icon:n.jsx(et,{size:16}),loading:p,onClick:async()=>{if(g.hongming_sso_enabled){x(!0);try{const e=await ye.post("/api/oauth/hongming/credentials"),{success:t,message:n,data:i}=e.data;t?(b(i),j(e=>({...e,hongming_register_api_key:i.api_key})),y.success({content:"åæ®çææåï¼è¯·ç«å³ä¿å api_secretï¼",duration:6})):je(n)}catch(e){je(e.message)}finally{x(!1)}}else y.warning({content:"请å
å¯ç¨é¸¿æºSSO",duration:3})},type:"secondary",children:"çææ³¨ååæ®"})})})]}),f&&n.jsxs(r,{style:{marginTop:16,border:"1px solid #faad14",background:"#fffbe6"}
1,title:"â ï¸ è¯·ç«å³ä¿å以ä¸åæ®ï¼Api Secret ä»
æ¾ç¤ºä¸æ¬¡",children:[n.jsxs("div",{style:{marginBottom:12},children:[n.jsx(Ys,{strong:!0,children:"Api Keyï¼"}),n.jsx(Ys,{code:!0,style:{marginLeft:8,marginRight:8},children:f.api_key}),n.jsx(d,{size:"small",icon:n.jsx(yt,{size:16}),onClick:()=>_(f.api_key)})]}),n.jsxs("div",{children:[n.jsx(Ys,{strong:!0,children:"Api Secretï¼"}),n.jsx(Ys,{code:!0,style:{marginLeft:8,marginRight:8},children:f.api_secret}),n.jsx(d,{size:"small",icon:n.jsx(yt,{size:16}),onClick:()=>_(f.api_secret)})]})]})]})]})})},{Text:nl}=u,il=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,r]=t.useState({enabled_menus:"",agent_announcements:"",agent_api_info:"",agent_faq:"",agent_domain:"",github_oauth_enabled:!1,github_client_id:"",github_client_secret:"",linuxdo_oauth_enabled:!1,linuxdo_client_id:"",linuxdo_client_secret:"",telegram_oauth_enabled:!1,wechat_auth_enabled:!1,wechat_server_address:"",wechat_server_token:"",wechat_account_qrcode_image_url:"",turnstile_check_enabled:!1,show_hongming_sso_settings:!1}),[o,c]=t.useState(l),d=t.useRef(),[u,p]=t.useState([]),[h,g]=t.useState(!1),[y,j]=t.useState({path:"",title:"",description:"",keywords:""}),[f,S]=t.useState(-1);t.useEffect(()=>{k()},[]);const k=async()=>{try{const e=await ye.get("/api/option/getagentoptions"),{success:t,message:n,data:i}=e.data;if(t){const e={};for(let t in i)Object.keys(l).includes(t)&&(e[t]=i[t]);if(e.github_oauth_enabled=!0===i.github_oauth_enabled,e.linuxdo_oauth_enabled=!0===i.linuxdo_oauth_enabled,e.telegram_oauth_enabled=!0===i.telegram_oauth_enabled,e.wechat_auth_enabled=!0===i.wechat_auth_enabled,e.turnstile_check_enabled=!0===i.turnstile_check_enabled,e.domain_restricted=!0===i.domain_restricted,e.invite_reward_enabled=!0===i.invite_reward_enabled,e.checkin_enabled=!0===i.checkin_enabled,e.invite_reward_rate=i.invite_reward_rate||10,r(e),c(structuredClone(e)),d.current){const t={...e,enabled_menus:e.enabled_menus?e.enabled_menus.split(","):[]};d.current.setValues(t)}}else je(n)}catch(e){je(e.message)}};t.useEffect(()=>{if(l&&l.seo_page_configs)try{const e=JSON.parse(l.seo_page_configs||"[]");p(e)}catch(e){p([])}},[l]);const v=(e,t)=>{j({...y,[e]:t})};return n.jsxs(m,{spinning:i,children:[n.jsx(le,{style:{padding:"24px"},children:n.jsxs(b,{type:"line",style:{marginBottom:"20px"},children:[n.jsx(_,{tab:n.jsxs("span",{children:[n.jsx(it,{size:16,style:{marginRight:8}}),e("åºç¡è®¾ç½®")]}),itemKey:"basic",children:n.jsx(cs,{})}),n.jsx(_,{tab:n.jsxs("span",{children:[n.jsx(ft,{size:16,style:{marginRight:8}}),e("è´§å¸åå®ä»·")]}),itemKey:"pricing",children:n.jsx(Ds,{})}),n.jsx(_,{tab:n.jsxs("span",{children:[n.jsx(bt,{size:16,style:{marginRight:8}}),e("SEO设置")]}),itemKey:"seo",children:n.jsx(us,{})}),n.jsx(_,{tab:n.jsxs("span",{children:[n.jsx(_t,{size:16,style:{marginRight:8}}),e("èç³»æ¹å¼")]}),itemKey:"contact",children:n.jsx(Es,{})}),n.jsx(_,{tab:n.jsxs("span",{children:[n.jsx(_t,{size:16,style:{marginRight:8}}),e("SMTP设置")]}),itemKey:"smtp",children:n.jsx(Rs,{})}),n.jsx(_,{tab:n.jsxs("span",{children:[n.jsx(St,{size:16,style:{marginRight:8}}),e("å¿«æ·ç»å½è®¾ç½®")]}),itemKey:"oauth",children:n.jsx(Ps,{})}),n.jsx(_,{tab:n.jsxs("span",{children:[n.jsx(_t,{size:16,style:{marginRight:8}}),e("ç信设置")]}),itemKey:"sms",children:n.jsx(Xs,{})}),n.jsx(_,{tab:n.jsxs("span",{children:[n.jsx(mt,{size:16,style:{marginRight:8}}),e("ç¨æ·åè®®")]}),itemKey:"disclaimer",children:n.jsx(Ns,{})}),n.jsx(_,{tab:n.jsxs("span",{children:[n.jsx(kt,{size:16,style:{marginRight:8}}),e("èå设置")]}),itemKey:"menu",children:n.jsx(Ms,{})}),n.jsx(_,{tab:n.jsxs("span",{children:[n.jsx(mt,{size:16,style:{marginRight:8}}),e("ç³»ç»å
¬å")]}),itemKey:"announcements",children:n.jsx(Ws,{})}),n.jsx(_,{tab:n.jsxs("span",{children:[n.jsx(it,{size:16,style:{marginRight:8}}),e("APIä¿¡æ¯")]}),itemKey:"apiinfo",children:n.jsx(Ks,{})}),n.jsx(_,{tab:n.jsxs("span",{children:[n.jsx(mt,{size:16,style:{marginRight:8}}),e("常è§é®ç")]}),itemKey:"faq",children:n.jsx(Hs,{})}),l.show_hongming_sso_settings&&n.jsx(_,{tab:n.jsxs("span",{children:["ð ",e("鸿æºSSO")]}),itemKey:"hongmingsso",children:n.jsx(tl,{})})]})}),n.jsx(x,{title:e(f>=0?"ç¼è¾é¡µé¢SEO":"æ·»å 页é¢SEO"),visible:h,onOk:()=>
1{if(y.path){if(f>=0){const e=[...u];e[f]=y,p(e)}else{if(u.some(e=>e.path===y.path))return void je(e("该页é¢è·¯å¾å·²åå¨"));p([...u,y])}g(!1)}else je(e("页é¢è·¯å¾ä¸è½ä¸ºç©º"))},onCancel:()=>g(!1),closeOnEsc:!0,width:600,children:h&&n.jsxs(a,{initValues:y,children:[n.jsx(a.Input,{field:"path",label:e("页é¢è·¯å¾"),placeholder:e("ä¾å¦: /chat æ /chat/* (éé
符å¹é
ææchatå页é¢)"),onChange:e=>v("path",e),help:e("以/å¼å¤´çè·¯å¾ã使ç¨*ä½ä¸ºéé
符å¯ä»¥å¹é
以ç¸ååç¼å¼å¤´çææé¡µé¢"),required:!0}),n.jsx(a.Input,{field:"title",label:e("页颿 é¢"),placeholder:e("页颿 é¢"),onChange:e=>v("title",e),help:e("ä¸éè¦å
å«ç³»ç»åç§°ï¼ç³»ç»ä¼èªå¨æ·»å ")}),n.jsx(a.TextArea,{field:"description",label:e("é¡µé¢æè¿°"),placeholder:e("é¡µé¢æè¿°"),onChange:e=>v("description",e),rows:3}),n.jsx(a.TextArea,{field:"keywords",label:e("页é¢å
³é®è¯"),placeholder:e("页é¢å
³é®è¯ï¼å¤ä¸ªå
³é®è¯ç¨è±æéå·åé"),onChange:e=>v("keywords",e),rows:3}),n.jsx("div",{style:{marginTop:8},children:n.jsxs(nl,{type:"tertiary",children:[e("å½åå¼"),": ",JSON.stringify(y)]})})]})})]})};function sl(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,p]=t.useState({ImageProxyEnabled:!1,ImageProxyServiceUrl:"",MjImageModeDefault:"origin",MjCustomProxyDefault:"https://mj.zhongzhuan.chat"}),[h,x]=t.useState(r),g=t.useRef();return t.useEffect(()=>{const t={};for(let n in e.options)"ImageProxyEnabled"===n?t[n]=!0===e.options[n]:"ImageProxyServiceUrl"===n?t[n]=e.options[n]||"":("MjImageModeDefault"===n||"MjCustomProxyDefault"===n)&&(t[n]=e.options[n]);Object.keys(t).length>0&&(p(t),x(structuredClone(t)),g.current?.setValues(t),setTimeout(()=>{g.current?.setValues(t)},100))},[e.options]),n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>g.current=e,style:{marginBottom:15},initValues:r,children:n.jsxs(a.Section,{text:i("å¾ç代ç设置"),children:[n.jsx(o,{gutter:16,children:n.jsx(c,{span:8,children:n.jsx(a.Switch,{field:"ImageProxyEnabled",label:i("å¯ç¨å¾ç代çï¼é²æ¢ä¸æ¸¸éè¿å¾çURL追踪ï¼"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{p({...r,ImageProxyEnabled:e})}})})}),r.ImageProxyEnabled&&n.jsx(o,{gutter:16,children:n.jsxs(c,{span:12,children:[n.jsx(a.Input,{field:"ImageProxyServiceUrl",label:i("å¾ç代çæå¡å°å"),placeholder:i("请è¾å
¥å¾ç代çæå¡å°åï¼å¦: https://your-domain.com"),onChange:e=>{p({...r,ImageProxyServiceUrl:e})}}),n.jsx(u.Text,{type:"secondary",style:{display:"block",marginTop:4},children:i("ç¬ç«çå¾ç代çæå¡å°åï¼ç¨äºå¤çéç¨å¾ç代ç请æ±")})]})}),n.jsx("div",{style:{marginTop:16,borderTop:"1px solid hsl(var(--border))",paddingTop:16},children:n.jsx(u.Text,{strong:!0,style:{marginBottom:8,display:"block"},children:i("Midjourney å¾ç代ç设置 (ç³»ç»é»è®¤)")})}),n.jsx(o,{gutter:16,children:n.jsxs(c,{span:8,children:[n.jsxs(a.Select,{field:"MjImageModeDefault",label:i("å¾çä»£çæ¹å¼"),defaultValue:r.MjImageModeDefault,value:r.MjImageModeDefault,onChange:e=>{p({...r,MjImageModeDefault:e})},children:[n.jsx(a.Select.Option,{value:"origin",children:i("Discord å龿¥")}),n.jsx(a.Select.Option,{value:"proxy",children:i("å¾ç代çå°å")})]}),!1]})}),"proxy"===r.MjImageModeDefault&&n.jsx(o,{gutter:16,children:n.jsxs(c,{span:12,children:[n.jsx(a.Input,{field:"MjCustomProxyDefault",label:i("èªå®ä¹å¾ç代ç"),placeholder:i("请è¾å
¥èªå®ä¹å¾ç代çå°å"),onChange:e=>{p({...r,MjCustomProxyDefault:e})}}),n.jsx(u.Text,{type:"secondary",style:{display:"block",marginTop:4},children:i("æ¿æ¢ https://cdn.discordapp.com çå°åï¼å¿
须以 httpsï¼http å¼å¤´")})]})}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:function(){const t=ke(r,h);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));l(!0);const n=Se(),s=t.map(e=>ye.put(n,{key:e.key,value:"boolean"==typeof r[e.key]?String(r[e.key]):r[e.key]}));Promise.all(s).then(t=>{if(1===s.length){if(t.includes(void 0))return}else if(s.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿åå¾ç代ç设置")})})]})})})}function ll(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState([]),[h,x]=t.useState(""),[g,y]=t.useState([]),[j,f]=t.useState(""),[b,_]=t.useState([]),[S,v]=t.useState(""),[C,w]=t.useState({AutoSortChannelEnabled:!1,MinRequestsForSuccessRate:5,ExplorationEpsilon:.1,MinRequestsForPenalty:100,MinSuccessRateThreshold:.05,PenaltyScoreMultiplier:.3,SuccessRateAutoBanEnabled:!1,SuccessRateAutoBanMinRequests:1e3,SuccessRateAutoBanThreshold:.02,MaxRetryDuration:0,DynamicTimeoutEnabled:!1,DynamicTimeoutScope:"retry_only",DynamicTimeoutPercentile:99,DynamicTimeoutMultiplier:1.2,DynamicTimeoutMin:30,DynamicTimeoutMax:600,DynamicTimeoutFallback:0,TimeoutPenaltyMultiplier:.5,TimeoutAutoBanCount:3,ErrorCountWhitelist:"",AutoSortChannelWhitelist:"",Pri
1orityWeight:10,WeightItemWeight:5,SuccessRateWeight:40,SpeedWeight:30,PriceWeight:15,DefaultSuccessRate:1,DefaultSpeedScore:.3,DefaultPriceScore:.5,EnableSigmoidSmoothing:!1,SigmoidPriceSteepness:10,SigmoidPrioritySteepness:10,SigmoidWeightSteepness:8,SigmoidSpeedSteepness:12,SpeedLogNormalization:!0,TimeoutStreakPenaltyRate:.03,ShortTermStatWeight:5,MediumTermStatWeight:3,LongTermStatWeight:2,UltraShortTermPeriod:120,ShortTermPeriod:300,MediumTermPeriod:1800,LongTermPeriod:10800}),[T,I]=t.useState(C),E=t.useRef();function R(){const t=ke(C,T);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));l(!0);const n=Se(),s=t.map(e=>{let t="";if("boolean"==typeof C[e.key])t=String(C[e.key]);else if("ExplorationEpsilon"===e.key){const n=parseFloat(C[e.key]);if(n<0||n>.5)return ve(i("æ¢ç´¢æ¦çåºå¨0å°0.5ä¹é´")),l(!1),null;t=String(n)}else if(["SigmoidPriceSteepness","SigmoidPrioritySteepness","SigmoidWeightSteepness","SigmoidSpeedSteepness"].includes(e.key)){const n=parseFloat(C[e.key]);if(n<4||n>20)return ve(i("Sigmoid é¡å³åº¦åºå¨4å°20ä¹é´")),l(!1),null;t=String(n)}else if(["UltraShortTermPeriod","ShortTermPeriod","MediumTermPeriod","LongTermPeriod","MinRequestsForSuccessRate","MaxRetryDuration","DynamicTimeoutMin","DynamicTimeoutMax","DynamicTimeoutFallback","TimeoutAutoBanCount","SuccessRateAutoBanMinRequests"].includes(e.key)){const n=parseInt(C[e.key]);if(t=String(n),"UltraShortTermPeriod"===e.key&&(n<30||n>600))return ve(i("è¶
çæç»è®¡æ¶é´åºå¨30ç§å°600ç§ä¹é´")),l(!1),null;if("ShortTermPeriod"===e.key&&(n<60||n>3600))return ve(i("çæç»è®¡æ¶é´åºå¨60ç§å°3600ç§ä¹é´")),l(!1),null;if("MediumTermPeriod"===e.key&&(n<600||n>7200))return ve(i("䏿ç»è®¡æ¶é´åºå¨600ç§å°7200ç§ä¹é´")),l(!1),null;if("LongTermPeriod"===e.key&&(n<3600||n>86400))return ve(i("é¿æç»è®¡æ¶é´åºå¨3600ç§å°86400ç§ä¹é´")),l(!1),null}else t=String(C[e.key]);return ye.put(n,{key:e.key,value:t})}).filter(e=>null!==e);0!==s.length?Promise.all(s).then(t=>{if(1===s.length){if(t.includes(void 0))return}else if(s.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)}):l(!1)}function P(){const e=parseFloat(C.PriorityWeight)+parseFloat(C.WeightItemWeight)+parseFloat(C.SuccessRateWeight)+parseFloat(C.SpeedWeight)+parseFloat(C.PriceWeight);return Math.abs(e-100)<.1}const z=()=>{const e=h.trim();e&&!r.includes(e)&&(u([...r,e]),x(""))},N=()=>{const e=j.trim();e&&!g.includes(e)&&(y([...g,e]),f(""))},A=()=>{const e=S.trim();e&&!b.includes(e)&&(_([...b,e]),v(""))};return t.useEffect(()=>{const t={AutoSortChannelEnabled:!1,MinRequestsForSuccessRate:5,ExplorationEpsilon:.1,MinRequestsForPenalty:100,MinSuccessRateThreshold:.05,PenaltyScoreMultiplier:.3,SuccessRateAutoBanEnabled:!1,SuccessRateAutoBanMinRequests:1e3,SuccessRateAutoBanThreshold:.02,MaxRetryDuration:0,DynamicTimeoutEnabled:!1,DynamicTimeoutScope:"retry_only",DynamicTimeoutPercentile:99,DynamicTimeoutMultiplier:1.2,DynamicTimeoutMin:30,DynamicTimeoutMax:600,DynamicTimeoutFallback:0,TimeoutPenaltyMultiplier:.5,TimeoutAutoBanCount:3,ErrorCountWhitelist:"",AutoSortChannelWhitelist:"",PriorityWeight:10,WeightItemWeight:5,SuccessRateWeight:40,SpeedWeight:30,PriceWeight:15,DefaultSuccessRate:1,DefaultSpeedScore:.3,DefaultPriceScore:.5,EnableSigmoidSmoothing:!1,SigmoidPriceSteepness:10,SigmoidPrioritySteepness:10,SigmoidWeightSteepness:8,SigmoidSpeedSteepness:12,SpeedLogNormalization:!0,TimeoutStreakPenaltyRate:.03,ShortTermStatWeight:5,MediumTermStatWeight:3,LongTermStatWeight:2,UltraShortTermPeriod:120,ShortTermPeriod:300,MediumTermPeriod:1800,LongTermPeriod:10800},n={...t};for(let i in e.options)t.hasOwnProperty(i)&&(["AutoSortChannelEnabled","EnableSigmoidSmoothing","DynamicTimeoutEnabled","SpeedLogNormalization","SuccessRateAutoBanEnabled"].includes(i)?n[i]=!0===e.options[i]||"true"===e.options[i]:["MinRequestsForSuccessRate","MinRequestsForPenalty","UltraShortTermPeriod","ShortTermPeriod","MediumTermPeriod","LongTermPeriod","MaxRetryDuration","DynamicTimeoutMin","DynamicTimeoutMax","DynamicTimeoutFallback","TimeoutAutoBanCount","SuccessRateAutoBanMinRequests"].includes(i)?n[i]=parseInt(e.options[i]):n[i]="DynamicTimeoutScope"===i?e.options[i]||"retry_only":"ErrorCountWhitelist"===i||"AutoSortChannelWhitelist"===i?e.options[i]||"":parseFloat(e.options[i]));if(w(n),I(structuredClone(n)),E.current?.setValues(n),e.options.ErrorCountWhitelist){const t=e.options.ErrorCountWhitelist.split(/[\n,]/).map(e=>e.trim()).filter(e=>e);u(t)}else u([]);if(e.options.AutoSortChannelWhitelist){const t=e.options.AutoSortChannelWhitelist.split(/[\n,]/).map(e=>e.trim()).filter(e=>e);y(t)}else y([]);if(e.options.DynamicTimeoutModels){const t=e.options.DynamicTimeoutModels.split(/[\n,]/).map(e=>e.trim()).filter(e=>e);_(t)}else _([])},[e.options]),n.jsx(m,{spinning:s,children:n.jsxs(a,{values:C,getFormApi:e=>E.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:i("æ¸ éæºè½æåºè®¾ç½®"),children:[n.jsx(o,{gutter:16,children:n.jsx(c,{span:8,children:n.jsx(a.Switch,{field:"AutoSortChannelEnabled",label:i("å¯ç¨æ¸ éæºè½æåºï¼èªå¨éæ©æ§è½æä½³æ¸ éï¼"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{w({...C,AutoSortChannelEnabled:e})}})})}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("æå°è¯·æ±æ°éå¼"),step:1,min:1,max:100,suffix:i("次"),extraText:i("è®¡ç®æåçæéçæå°è¯·æ±æ°ï¼ä½äºæ¤å¼çæ¸ éä¸èèæåç"),field:"MinRequestsForSuccessRate",onCh
1ange:e=>w({...C,MinRequestsForSuccessRate:e})})}),n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("æ¢ç´¢æ¦ç (Epsilon)"),step:.01,min:0,max:.5,precision:2,extraText:i("æ°æ®ä¸è¶³æ¸ éçéæºæ¢ç´¢æ¦çï¼æ¨è: 0.05-0.15ï¼ï¼ç¨äºå·å¯å¨"),field:"ExplorationEpsilon",onChange:e=>w({...C,ExplorationEpsilon:e})})}),n.jsx(c,{span:8,children:n.jsxs("div",{style:{padding:"10px",border:"1px solid #e8e8e8",borderRadius:"4px",marginTop:"24px",backgroundColor:"#f6f7f9"},children:[n.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:"ð¡ æ¢ç´¢æ¦ç说æ"}),n.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:["⢠",n.jsx("strong",{children:"0.05-0.10"}),": è°¨æ
æ¢ç´¢ï¼æ¨èï¼",n.jsx("br",{}),"⢠",n.jsx("strong",{children:"0.10-0.15"}),": ç§¯ææ¢ç´¢",n.jsx("br",{}),"⢠",n.jsx("strong",{children:"0.0"}),": å
³éæ¢ç´¢ï¼ä¸æ¨èï¼"]})]})})]}),n.jsxs(a.Section,{text:i("æ¸ éæ©ç½æºå¶é
ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("æ©ç½æå°è¯·æ±æ°"),step:10,min:50,max:1e3,suffix:i("次"),extraText:i("è§¦åæ©ç½æºå¶æéçæå°è¯·æ±æ°ï¼é¿æç»è®¡ï¼ï¼å»ºè®®100"),field:"MinRequestsForPenalty",onChange:e=>w({...C,MinRequestsForPenalty:e})})}),n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("æä½æåçéå¼"),step:.01,min:0,max:.5,precision:2,extraText:i("ä½äºæ¤æåççæ¸ éå°è¢«ä¸¥åæ©ç½ï¼æ¨è: 0.05å³5%ï¼"),field:"MinSuccessRateThreshold",onChange:e=>w({...C,MinSuccessRateThreshold:e})})}),n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("æ©ç½å¾ååç"),step:.05,min:.1,max:1,precision:2,extraText:i("被æ©ç½æ¸ éçæ»åå°ä¹ä»¥æ¤åçï¼æ¨è: 0.3峿3æï¼"),field:"PenaltyScoreMultiplier",onChange:e=>w({...C,PenaltyScoreMultiplier:e})})}),n.jsx(c,{span:6,children:n.jsx(a.Switch,{label:i("使åçèªå¨ç¦ç¨æ¨¡å"),field:"SuccessRateAutoBanEnabled",extraText:i("æ»¡è¶³ä¸æ¹æ¡ä»¶æ¶èªå¨ä¸´æ¶ç¦ç¨è¯¥æ¸ éç该模å(ä¸å½±åå
¶ä»æ¨¡å)ï¼åå¤è§¦åå°å»¶é¿ç¦ç¨æ¶é´(30åéâ1hâ2hâ...â24h)ï¼æ¢æ´»æåèªå¨æ¢å¤"),onChange:e=>w({...C,SuccessRateAutoBanEnabled:e})})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("èªå¨ç¦ç¨æå°è¯·æ±æ°"),step:100,min:100,max:1e4,suffix:i("次"),extraText:i("触åèªå¨ç¦ç¨æéçæå°è¯·æ±æ°ï¼é¿æç»è®¡ï¼ï¼å»ºè®®1000"),field:"SuccessRateAutoBanMinRequests",disabled:!C.SuccessRateAutoBanEnabled,onChange:e=>w({...C,SuccessRateAutoBanMinRequests:e})})}),n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("èªå¨ç¦ç¨æåçéå¼"),step:.01,min:0,max:.2,precision:2,extraText:i("ä½äºæ¤æåçå°èªå¨ç¦ç¨è¯¥æ¨¡åï¼æ¨è: 0.02å³2%ï¼"),field:"SuccessRateAutoBanThreshold",disabled:!C.SuccessRateAutoBanEnabled,onChange:e=>w({...C,SuccessRateAutoBanThreshold:e})})})]})]}),n.jsxs(a.Section,{text:i("卿è¶
æ¶ä¸æ¸ éè¶
æ¶æ©ç½"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("æ»éè¯æ¶é´é¢ç®(ç§)"),step:10,min:0,max:600,suffix:i("ç§"),extraText:i("ææéè¯çæ»æ¶é´ä¸é(0=ä¸éå¶)"),field:"MaxRetryDuration",onChange:e=>w({...C,MaxRetryDuration:e})})}),n.jsx(c,{span:6,children:n.jsx(a.Switch,{field:"DynamicTimeoutEnabled",label:i("å¯ç¨å¨æè¶
æ¶(åºäºæ¨¡åP99ç»è®¡)"),size:"default",checkedText:"|",uncheckedText:"O",onChange:e=>{w({...C,DynamicTimeoutEnabled:e})}})}),n.jsx(c,{span:6,children:n.jsxs(a.Select,{field:"DynamicTimeoutScope",label:i("卿è¶
æ¶åºç¨èå´"),disabled:!C.DynamicTimeoutEnabled,onChange:e=>w({...C,DynamicTimeoutScope:e}),children:[n.jsx(a.Select.Option,{value:"retry_only",children:i("ä»
éè¯è¯·æ±")}),n.jsx(a.Select.Option,{value:"all",children:i("ææè¯·æ±")})]})}),n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("ç»è®¡ç¾å使°"),step:.5,min:90,max:99.9,precision:1,extraText:i("使ç¨çç¾å使°(æ¨è99å³P99)"),field:"DynamicTimeoutPercentile",disabled:!C.DynamicTimeoutEnabled,onChange:e=>w({...C,DynamicTimeoutPercentile:e})})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("è¶
æ¶å®å
¨ç³»æ°"),step:.1,min:1,max:3,precision:1,extraText:i("P99ä¹ä»¥æ¤ç³»æ°ä½ä¸ºè¶
æ¶éå¼(æ¨è1.2)"),field:"DynamicTimeoutMultiplier",disabled:!C.DynamicTimeoutEnabled,onChange:e=>w({...C,DynamicTimeoutMultiplier:e})})}),n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("æå°è¶
æ¶(ç§)"),step:5,min:5,max:300,suffix:i("ç§"),extraText:i("卿è¶
æ¶çä¸é(æ¨è30ç§)"),field:"DynamicTimeoutMin",disabled:!C.DynamicTimeoutEnabled,onChange:e=>w({...C,DynamicTimeoutMin:e})})}),n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("æå¤§è¶
æ¶(ç§)"),step:30,min:60,max:1e5,suffix:i("ç§"),extraText:i("卿è¶
æ¶çä¸é(æ¨è600ç§)"),field:"DynamicTimeoutMax",disabled:!C.DynamicTimeoutEnabled,onChange:e=>w({...C,DynamicTimeoutMax:e})})}),n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("æ æ°æ®æ¶é»è®¤è¶
æ¶(ç§)"),step:10,min:0,max:600,suffix:i("ç§"),extraText:i("æ¨¡åæ ç»è®¡æ°æ®æ¶çè¶
æ¶(0=ä¸éå¶)"),field:"DynamicTimeoutFallback",disabled:!C.DynamicTimeoutEnabled,onChange:e=>w({...C,DynamicTimeoutFallback:e})})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("è¶
æ¶æ©ç½åç"),step:.
105,min:.1,max:1,precision:2,extraText:i("è¶
æ¶æ¸ éè¯åä¹ä»¥æ¤åç(æ¨è0.5)"),field:"TimeoutPenaltyMultiplier",disabled:!C.DynamicTimeoutEnabled,onChange:e=>w({...C,TimeoutPenaltyMultiplier:e})})}),n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("è¿ç»è¶
æ¶ç¦ç¨éå¼"),step:1,min:1,max:20,suffix:i("次"),extraText:i("å䏿¨¡åè¿ç»è¶
æ¶N次临æ¶ç¦ç¨è¯¥æ¸ éç该模å(ä¸å½±åå
¶ä»æ¨¡å)ï¼åå¤è§¦åå°èªå¨å»¶é¿ï¼30åéâ1hâ2hâ4hâ8hâ24h"),field:"TimeoutAutoBanCount",disabled:!C.DynamicTimeoutEnabled,onChange:e=>w({...C,TimeoutAutoBanCount:e})})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("宿¶è¶
æ¶éææ¯ä¾"),step:.01,min:0,max:.5,precision:2,extraText:i("æ¯æ¬¡è¿ç»è¶
æ¶å®æ¶éä½çå¾åæ¯ä¾ï¼ç»è¿ç¼åç«å³çæ(0.03=æ¯æ¬¡é3%)"),field:"TimeoutStreakPenaltyRate",disabled:!C.DynamicTimeoutEnabled,onChange:e=>w({...C,TimeoutStreakPenaltyRate:e})})}),n.jsx(c,{span:12,children:n.jsxs("div",{style:{padding:"10px",border:"1px solid #e8e8e8",borderRadius:"4px",marginTop:"24px",backgroundColor:"#f0f9ff"},children:[n.jsxs("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:["* ",i("卿è¶
æ¶è¯´æ")]}),n.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:[i("æ ¹æ®æ¯ä¸ªæ¨¡ååå²è¯·æ±çææçå¾
æ¶é´ç»è®¡å¼ï¼èªå¨è®¡ç®è¶
æ¶éå¼"),n.jsx("br",{}),"* ",n.jsx("strong",{children:i("æµå¼")}),": ",i("ç»è®¡é¦åæ¶é´(TTFT)ï¼éå¶çå¾
ååºå¤´é¶æ®µ(ResponseHeaderTimeout)ï¼ä¸å½±åæµæ°æ®ä¼ è¾"),n.jsx("br",{}),"* ",n.jsx("strong",{children:i("éæµå¼")}),": ",i("ç»è®¡æ»ååºæ¶é´ï¼éå¶æ´ä¸ªè¯·æ±å¨æ(Client.Timeout)"),n.jsx("br",{}),"* ",i("è¶
æ¶çæ¸ éä¼è¢«éæï¼è¿ç»è¶
æ¶ä¼èªå¨ç¦ç¨ï¼åå°ä¸æ¸¸è®¡è´¹æå¤±")]})]})})]}),n.jsxs(o,{gutter:16,style:{marginTop:16},children:[n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("æå®å¯ç¨å¨æè¶
æ¶ç模å")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("çç©ºè¡¨ç¤ºæææ¨¡åé½å¯ç¨å¨æè¶
æ¶, æ¯æéé
符(å¦ gemini-*)")})]}),n.jsx(p,{value:b,onChange:_,placeholder:i("è¾å
¥æ¨¡ååç§°åå车"),style:{width:"100%"},disabled:!C.DynamicTimeoutEnabled})]}),n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("æ·»å æ¨¡å")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("è¾å
¥åç¹å»æ·»å ææå车, æ¯æ * åç¼éé
符")})]}),n.jsx(k,{placeholder:i("å¦: gemini-3-pro-image-preview æ gemini-*"),value:S,onChange:e=>v(e),disabled:!C.DynamicTimeoutEnabled,suffix:n.jsx(d,{onClick:A,disabled:!C.DynamicTimeoutEnabled,children:i("æ·»å ")}),onEnterPress:A})]})]}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:async()=>{l(!0);try{const t=Se(),n=b.join("\n");await ye.put(t,{key:"DynamicTimeoutModels",value:n}),be(i("ä¿åæå")),e.refresh()}catch(t){je(i("ä¿å失败ï¼è¯·éè¯"))}finally{l(!1)}},disabled:!C.DynamicTimeoutEnabled,children:i("ä¿å卿è¶
æ¶æ¨¡åå表")})})]}),n.jsx(o,{style:{marginTop:16,marginBottom:24},children:n.jsx(d,{size:"default",onClick:R,children:i("ä¿åæ¸ éæåºè®¾ç½®")})}),n.jsxs(a.Section,{text:i("æºè½æåºç½ååé
ç½®"),children:[n.jsxs(o,{gutter:16,style:{marginTop:16},children:[n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("已添å çç½åååç»")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("ç¹å»æ ç¾å¯å é¤è¯¥é¡¹")})]}),n.jsx(p,{value:g,onChange:y,placeholder:i("è¾å
¥åç»åç§°åå车"),style:{width:"100%"}})]}),n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("æ·»å æ°çç½åååç»")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("è¾å
¥åç¹å»æ·»å æé®ææå车")})]}),n.jsx(k,{placeholder:i("è¾å
¥åç»åç§°ï¼å¦ï¼Claude Codeä¸å±ï¼"),value:j,onChange:e=>f(e),suffix:n.jsx(d,{onClick:N,children:i("æ·»å ")}),onEnterPress:N})]})]}),n.jsx(o,{gutter:16,style:{marginTop:16},children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{padding:"10px",border:"1px solid #e8e8e8",borderRadius:"4px",backgroundColor:"#fff7e6"},children:[n.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:"ð¡ æºè½æåºç½åå说æ"}),n.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:["⢠å¨ç½ååä¸çåç»å°",n.jsx("strong",{children:"è·³è¿æºè½æåº"}),"ï¼ç´æ¥æç
§",n.jsx("strong",{children:"ä¼å
级åæé"}),"éæ©æ¸ é",n.jsx("br",{}),"⢠éç¨åºæ¯ï¼éè¦åºå®è·¯ç±çç¥çåç»ãä¸å¸æåç»è®¡æ°æ®å½±åçä¸ç¨åç
1»",n.jsx("br",{}),"⢠常è§ç¤ºä¾ï¼",n.jsx("code",{children:"Claude Codeä¸å±"}),"ã",n.jsx("code",{children:"Codexä¸å±"}),"ã",n.jsx("code",{children:"ç¹æ®æ¨¡åä¸ç¨"}),n.jsx("br",{}),"⢠注æï¼åç»åç§°å¿
须䏿¸ éé
ç½®ä¸çåç»åç§°",n.jsx("strong",{children:"å®å
¨ä¸è´"}),"ï¼åºå大å°åï¼"]})]})})}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:async()=>{if(Array.isArray(g)){l(!0);try{const t=Se(),n=g.join("\n");await ye.put(t,{key:"AutoSortChannelWhitelist",value:n}),be(i("ä¿åæå")),e.refresh()}catch(t){je(i("ä¿å失败ï¼è¯·éè¯"))}finally{l(!1)}}else je(i("æºè½æåºç½ååæ ¼å¼ä¸æ£ç¡®"))},children:i("ä¿åæºè½æåºç½åå")})})]}),n.jsxs(a.Section,{text:i("é误计æ°ç½ååé
ç½®"),children:[n.jsxs(o,{gutter:16,style:{marginTop:16},children:[n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("已添å çç½åå项")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("ç¹å»æ ç¾å¯å é¤è¯¥é¡¹")})]}),n.jsx(p,{value:r,onChange:u,placeholder:i("è¾å
¥éè¯¯ç æéè¯¯æ¶æ¯å
³é®è¯åå车"),style:{width:"100%"}})]}),n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("æ·»å æ°çç½åå项")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("è¾å
¥åç¹å»æ·»å æé®ææå车")})]}),n.jsx(k,{placeholder:i("è¾å
¥éè¯¯ç æéè¯¯æ¶æ¯å
³é®è¯"),value:h,onChange:e=>x(e),suffix:n.jsx(d,{onClick:z,children:i("æ·»å ")}),onEnterPress:z})]})]}),n.jsx(o,{gutter:16,style:{marginTop:16},children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{padding:"10px",border:"1px solid #e8e8e8",borderRadius:"4px",backgroundColor:"#f0f9ff"},children:[n.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:"ð¡ ç½åå说æ"}),n.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:["⢠å½è¯·æ±å¤±è´¥æ¶ï¼å¦æéè¯¯ç æéè¯¯æ¶æ¯",n.jsx("strong",{children:"å
å«"}),"ç½ååä¸çä»»ä½ä¸é¡¹ï¼åä¸ä¼è®°å½ä¸ºæ¸ é失败",n.jsx("br",{}),"⢠éç¨åºæ¯ï¼ç¨æ·è¯·æ±ä½é®é¢ãé
é¢ä¸è¶³ç鿏 éåå 导è´ç失败",n.jsx("br",{}),"⢠常è§ç¤ºä¾ï¼",n.jsx("code",{children:"invalid_request_error"}),"ã",n.jsx("code",{children:"insufficient_quota"}),"ã",n.jsx("code",{children:"content_filter"}),"ã",n.jsx("code",{children:"rate_limit_exceeded"})]})]})})}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:async()=>{if(Array.isArray(r)){l(!0);try{const t=Se(),n=r.join("\n");await ye.put(t,{key:"ErrorCountWhitelist",value:n}),be(i("ä¿åæå")),e.refresh()}catch(t){je(i("ä¿å失败ï¼è¯·éè¯"))}finally{l(!1)}}else je(i("é误计æ°ç½ååæ ¼å¼ä¸æ£ç¡®"))},children:i("ä¿åé误计æ°ç½åå")})})]})]}),n.jsxs(a.Section,{text:i("ç»ä¸æéç³»ç»ï¼æææéæ»ååºä¸º100%ï¼"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("ä¼å
级æé"),step:1,min:0,max:50,precision:1,suffix:"%",extraText:i("æ¸ éä¼å
çº§å¨æç»å¾åä¸çæé"),field:"PriorityWeight",onCh
1ange:e=>w({...C,PriorityWeight:e})})}),n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("æé项æé"),step:1,min:0,max:50,precision:1,suffix:"%",extraText:i("æ¸ éæé项卿ç»å¾åä¸çæé"),field:"WeightItemWeight",onChange:e=>w({...C,WeightItemWeight:e})})}),n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("æåçæé"),step:1,min:0,max:100,precision:1,suffix:"%",extraText:i("æåç卿ç»å¾åä¸çæé"),field:"SuccessRateWeight",onChange:e=>w({...C,SuccessRateWeight:e})})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("é度æé"),step:1,min:0,max:50,precision:1,suffix:"%",extraText:i("éåº¦å¨æç»å¾åä¸çæé"),field:"SpeedWeight",onChange:e=>w({...C,SpeedWeight:e})})}),n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("ä»·æ ¼æé"),step:1,min:0,max:50,precision:1,suffix:"%",extraText:i("ä»·æ ¼å¨æç»å¾åä¸çæéï¼ä»·æ ¼è¶ä½å¾åè¶é«ï¼"),field:"PriceWeight",onChange:e=>w({...C,PriceWeight:e})})}),n.jsx(c,{span:8,children:n.jsxs("div",{style:{padding:"10px",border:P()?"1px solid #52c41a":"1px solid #ff4d4f",borderRadius:"4px",marginTop:"24px"},children:[n.jsxs("div",{style:{fontWeight:"bold"},children:["æéæ»åï¼",(parseFloat(C.PriorityWeight)+parseFloat(C.WeightItemWeight)+parseFloat(C.SuccessRateWeight)+parseFloat(C.SpeedWeight)+parseFloat(C.PriceWeight)).toFixed(1),"%"]}),n.jsx("div",{style:{color:P()?"#52c41a":"#ff4d4f"},children:P()?"â æéæ»åæ£ç¡®":"â æéæ»ååºä¸º100%"})]})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("é»è®¤æåç"),step:.1,min:0,max:1,precision:2,extraText:i("æ æ°æ®æ¸ éçé»è®¤æåçï¼0-1ï¼"),field:"DefaultSuccessRate",onCh
1ange:e=>w({...C,DefaultSuccessRate:e})})}),n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("é»è®¤é度å¾å"),step:.1,min:0,max:1,precision:2,extraText:i("æ æ°æ®æ¸ éçé»è®¤é度å¾åï¼0-1ï¼"),field:"DefaultSpeedScore",onChange:e=>w({...C,DefaultSpeedScore:e})})}),n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("é»è®¤ä»·æ ¼å¾å"),step:.1,min:0,max:1,precision:2,extraText:i("æ æ°æ®æ¸ éçé»è®¤ä»·æ ¼å¾åï¼0-1ï¼"),field:"DefaultPriceScore",onChange:e=>w({...C,DefaultPriceScore:e})})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:R,children:i("ä¿åç»ä¸æéç³»ç»è®¾ç½®")})})]}),n.jsxs(a.Section,{text:i("å½ä¸åçç¥è®¾ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:12,children:n.jsx(a.Switch,{label:i("é度对æ°å½ä¸å"),field:"SpeedLogNormalization",extraText:i("ä½¿ç¨ log(1+speed)/log(1+maxSpeed) å½ä¸åé度å¾åï¼åç¼é度边é
éåæåºï¼æ¨èå¼å¯ï¼"),onChange:e=>w({...C,SpeedLogNormalization:e})})}),n.jsx(c,{span:12,children:n.jsx(a.Switch,{label:i("å¯ç¨ Sigmoid å¹³æ»"),field:"EnableSigmoidSmoothing",extraText:i("对æé/ä¼å
级/ä»·æ ¼ä½¿ç¨ Sigmoid 彿°å½ä¸åï¼ä¸æ¨èï¼é»è®¤å
³é使ç¨çº¿æ§å½ä¸åï¼"),onChange:e=>w({...C,EnableSigmoidSmoothing:e})})})]}),C.EnableSigmoidSmoothing&&n.jsxs(n.Fragment,{children:[n.jsx(o,{gutter:16,style:{marginTop:"16px"},children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{padding:"12px",backgroundColor:"#f6f7f9",borderRadius:"4px",marginBottom:"16px"},children:[n.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:"ð¡ Sigmoid é¡å³åº¦è¯´æ"}),n.jsxs("div",{children:["⢠",n.jsx("strong",{children:"é¡å³åº¦ 6-8"}),": å¹³ç¼è¿æ¸¡ï¼æ¥è¿çº¿æ§ï¼éåæé项"]}),n.jsxs("div",{children:["⢠",n.jsx("strong",{children:"é¡å³åº¦ 10"}),": ä¸çé¡å³ï¼æ¨èï¼ï¼å¹³è¡¡å¹³æ»ä¸åºå度ï¼éåä»·æ ¼åä¼å
级"]}),n.jsxs("div",{children:["⢠",n.jsx("strong",{children:"é¡å³åº¦ 12-15"}),": é¡å³æ²çº¿ï¼ä¸é´å·®å¼ææ¾ï¼éåé度"]}),n.jsx("div",{style:{marginTop:"8px",color:"#666"},children:"⢠é¡å³åº¦è¶å¤§ï¼ä¸é´åºå(0.3-0.7)çå·®å¼è¶ææ¾ï¼è¾¹ç¼è¶å¹³ç¼"})]})})}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:12,children:n.jsx(a.InputNumber,{label:i("ä»·æ ¼ Sigmoid é¡å³åº¦"),step:.5,min:4,max:20,precision:1,extraText:i("æ§å¶ä»·æ ¼å½ä¸åæ²çº¿çé¡å³ç¨åº¦ï¼æ¨è: 8-12ï¼"),field:"SigmoidPriceSteepness",onChange:e=>w({...C,SigmoidPriceSteepness:e})})}),n.jsx(c,{span:12,children:n.jsx(a.InputNumber,{label:i("ä¼å
级 Sigmoid é¡å³åº¦"),step:.5,min:4,max:20,precision:1,extraText:i("æ§å¶ä¼å
级å½ä¸åæ²çº¿çé¡å³ç¨åº¦ï¼æ¨è: 8-12ï¼"),field:"SigmoidPrioritySteepness",onChange:e=>w({...C,SigmoidPrioritySteepness:e})})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:12,children:n.jsx(a.InputNumber,{label:i("æé Sigmoid é¡å³åº¦"),step:.5,min:4,max:20,precision:1,extraText:i("æ§å¶æéå½ä¸åæ²çº¿çé¡å³ç¨åº¦ï¼æ¨è: 6-10ï¼"),field:"SigmoidWeightSteepness",onChange:e=>w({...C,SigmoidWeightSteepness:e})})}),n.jsx(c,{span:12,children:n.jsx(a.InputNumber,{label:i("é度 Sigmoid é¡å³åº¦"),step:.5,min:4,max:20,precision:1,extraText:i("æ§å¶é度å½ä¸åæ²çº¿çé¡å³ç¨åº¦ï¼æ¨è: 10-15ï¼"),field:"SigmoidSpeedSteepness",onChange:e=>w({...C,SigmoidSpeedSteepness:e})})})]})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:R,children:i("ä¿å Sigmoid 设置")})})]}),n.jsxs(a.Section,{text:i("ç»è®¡å¨æè®¾ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("çæç»è®¡æé"),step:.5,min:0,max:50,precision:1,extraText:i("çæç»è®¡æ°æ®å¨è®¡ç®å æå¹³å弿¶çæé"),field:"ShortTermStatWeight",onChange:e=>w({...C,ShortTermStatWeight:e})})}),n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("䏿ç»è®¡æé"),step:.5,min:0,max:50,precision:1,extraText:i("䏿ç»è®¡æ°æ®å¨è®¡ç®å æå¹³å弿¶çæé"),field:"MediumTermStatWeight",onChange:e=>w({...C,MediumTermStatWeight:e})})}),n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("é¿æç»è®¡æé"),step:.5,min:0,max:50,precision:1,extraText:i("é¿æç»è®¡æ°æ®å¨è®¡ç®å æå¹³å弿¶çæé"),field:"LongTermStatWeight",onCh
1ange:e=>w({...C,LongTermStatWeight:e})})})]}),n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("è¶
çæå¤ææ¶é´"),step:30,min:30,max:600,suffix:i("ç§"),extraText:i("ç¨äºå¤ææ°æ®å
è¶³çæ¶é´çªå£ï¼å»ºè®®120ç§(2åé)"),field:"UltraShortTermPeriod",onChange:e=>w({...C,UltraShortTermPeriod:e})})}),n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("çæç»è®¡æ¶é´"),step:60,min:60,max:3600,suffix:i("ç§"),extraText:i("çæç»è®¡çæ¶é´èå´ï¼å»ºè®®300ç§(5åé)"),field:"ShortTermPeriod",onChange:e=>w({...C,ShortTermPeriod:e})})}),n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("䏿ç»è®¡æ¶é´"),step:300,min:600,max:7200,suffix:i("ç§"),extraText:i("䏿ç»è®¡çæ¶é´èå´ï¼å»ºè®®1800ç§(30åé)"),field:"MediumTermPeriod",onChange:e=>w({...C,MediumTermPeriod:e})})}),n.jsx(c,{span:6,children:n.jsx(a.InputNumber,{label:i("é¿æç»è®¡æ¶é´"),step:600,min:3600,max:86400,suffix:i("ç§"),extraText:i("é¿æç»è®¡çæ¶é´èå´ï¼å»ºè®®10800ç§(3å°æ¶)"),field:"LongTermPeriod",onChange:e=>w({...C,LongTermPeriod:e})})})]}),n.jsx(o,{children:n.jsx(d,{size:"default",onClick:R,children:i("ä¿åç»è®¡å¨æè®¾ç½®")})})]})]})})}function al(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState([]),[h,x]=t.useState(""),[g,y]=t.useState({ModelErrorRequestRateLimitEnabled:!1,ModelErrorRequestRateLimitDurationMinutes:0,ModelErrorRequestRateLimitCount:0,ResponseReorderEnabled:!1,ModelIgnoreThinkWhitelist:""}),j=t.useRef(),[f,b]=t.useState(g),_=()=>{const e=h.trim();e&&!r.includes(e)&&(u([...r,e]),x(""))};return t.useEffect(()=>{const t={};for(let n in e.options)Object.keys(g).includes(n)&&(n.endsWith("Enabled")?t[n]=!0===e.options[n]:n.includes("Count")||n.includes("Minutes")?t[n]=parseInt(e.options[n]):t[n]=e.options[n]);if(Object.keys(t).length>0&&(y(t),b(structuredClone(t)),j.current?.setValues(t)),e.options.ModelIgnoreThinkWhitelist){const t=e.options.ModelIgnoreThinkWhitelist.split(/[\n,]/).map(e=>e.trim()).filter(e=>e);u(t)}else u([])},[e.options]),n.jsx(m,{spinning:s,children:n.jsxs(a,{values:g,getFormApi:e=>j.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:i("模å请æ±é«çº§éå¶"),children:[n.jsx(o,{gutter:16,children:n.jsx(c,{span:8,children:n.jsx(a.Switch,{field:"ModelErrorRequestRateLimitEnabled",label:i("å¯ç¨é误请æ±éçéå¶"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{y({...g,ModelErrorRequestRateLimitEnabled:e})}})})}),n.jsx(o,{children:n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("é误请æ±éå¶å¨æ"),step:1,min:0,suffix:i("åé"),extraText:i("é误请æ±é¢çéå¶ç卿ï¼åéï¼"),field:"ModelErrorRequestRateLimitDurationMinutes",onChange:e=>y({...g,ModelErrorRequestRateLimitDurationMinutes:String(e)})})})}),n.jsx(o,{children:n.jsx(c,{span:8,children:n.jsx(a.InputNumber,{label:i("ç¸åéè¯¯è¯·æ±æ¬¡æ°éå¶"),step:1,min:0,suffix:i("次"),extraText:i("åæ ·çé误请æ±å¨å¨æå
å
è®¸å¤±è´¥çæ¬¡æ°ï¼0代表ä¸éå¶"),field:"ModelErrorRequestRateLimitCount",onChange:e=>y({...g,ModelErrorRequestRateLimitCount:String(e)})})})}),n.jsx(o,{gutter:16,children:n.jsx(c,{span:8,children:n.jsx(a.Switch,{field:"ResponseReorderEnabled",label:i("å¯ç¨è¿åæ°æ®å¼ºå¶æåº"),size:"default",checkedText:"ï½",uncheckedText:"ã",extraText:i("å¼å¯åç³»ç»å°å¯¹è¿åçæ°æ®è¿è¡å¼ºå¶æåº"),onChange:e=>{y({...g,ResponseReorderEnabled:e})}})})}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:function(){const t=ke(g,f);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=Se(),s=t.map(e=>{let t="";return t="boolean"==typeof g[e.key]?String(g[e.key]):g[e.key],ye.put(n,{key:e.key,value:t})});l(!0),Promise.all(s).then(t=>{if(1===s.length){if(t.includes(void 0))return}else if(s.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿åé«çº§éå¶è®¾ç½®")})})]}),n.jsxs(a.Section,{text:i("模å忽ç¥thinkå¤çç½ååé
ç½®"),children:[n.jsxs(o,{gutter:16,style:{marginTop:16},children:[n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("已添å çç½å忍¡å")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("ç¹å»æ ç¾å¯å é¤è¯¥æ¨¡å")})]}),n.jsx(p,{value:r,onChange:u,placeholder:i("è¾å
¥æ¨¡åååå车添å "),style:{width:"100%"}})]}),n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("æ·»å æ°çç½å忍¡å")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("è¾å
¥åç¹å»æ·»å æé®ææå车")})]}),n.jsx(k,{placeholder:i("è¾å
¥æ¨¡ååï¼ä¾å¦ï¼gpt-4o-thinking"),value:h,onChange:e=>x(e),suffix:n.jsx(d,{onClick:_,children:i("æ·»å ")}),onEnterPress:_})]})]}),n.jsx(o,{gutter:16,style:{marginTop:16},children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{padding:"10px",border:"1px solid #e8e8e8",borderRadius:"4px",backgroundColor:"#f0f9ff"},children:[n.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:"ð¡ ç½åå说æ"}),n.jsxs("div",{style:{fontSize:"12px",color:"#666"},children:["â¢ å¨æ¤å表ä¸ç模åå°è·³è¿ææthinkingç¸å
³åç¼çèªå¨å»é¤å¤ç",
1n.jsx("br",{}),"⢠éç¨åºæ¯ï¼éè¦ä¿çåå§thinkingè¾åºçæè类模å",n.jsx("br",{}),"⢠常è§ç¤ºä¾ï¼",n.jsx("code",{children:"gpt-4o-thinking"}),"ã",n.jsx("code",{children:"claude-3-5-sonnet-thinking"}),"ã",n.jsx("code",{children:"deepseek-chat-thinking"})]})]})})}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:async()=>{if(Array.isArray(r)){l(!0);try{const t=Se(),n=r.join(",");await ye.put(t,{key:"ModelIgnoreThinkWhitelist",value:n}),be(i("ä¿åæå")),e.refresh()}catch(t){je(i("ä¿å失败ï¼è¯·éè¯"))}finally{l(!1)}}else je(i("模åç½ååæ ¼å¼ä¸æ£ç¡®"))},children:i("ä¿å模åç½åå")})})]})]})})}const{Text:rl}=u,{Text:ol}=u,{Text:cl,Title:dl}=u;function ul(){const{t:e}=ge(),[i,s]=t.useState(!1),[l,o]=t.useState(""),[c,u]=t.useState({global_enabled:!1,default_token_field:"max_tokens",model_limits:[]}),[p,h]=t.useState(null),[y,j]=t.useState(!1),[f,b]=t.useState(null),[_,C]=t.useState(null),[w,T]=t.useState(!1),[R,P]=t.useState(!1),[z,A]=t.useState(""),[M,O]=t.useState(""),D=e=>{b(e),j(!0)},L=[{title:e("模ååç§°"),dataIndex:"model_name",width:200,render:e=>n.jsx(cl,{strong:!0,children:e})},{title:e("Tokenåæ®µç±»å"),dataIndex:"token_field",width:180,render:e=>n.jsx(cl,{type:"max_completion_tokens"===e?"warning":"primary",children:e})},{title:e("è¾åºTokenéå¶"),dataIndex:"output_token_limit",width:150,render:t=>t>0?t.toLocaleString():e("æ éå¶")},{title:e("è¾å
¥Tokenéå¶"),dataIndex:"input_token_limit",width:150,render:t=>t>0?t.toLocaleString():e("æ éå¶")},{title:e("å¯ç¨ç¶æ"),dataIndex:"enabled",width:100,render:e=>n.jsx(cl,{type:e?"success":"tertiary",children:e?"å·²å¯ç¨":"å·²ç¦ç¨"})},{title:e("æä½"),dataIndex:"operation",width:200,render:(t,i,s)=>n.jsxs(g,{children:[n.jsx(d,{type:"primary",icon:n.jsx(at,{size:16}),onClick:()=>D({...i,index:s}),size:"small",children:e("ç¼è¾")}),n.jsx(d,{type:"danger",icon:n.jsx(He,{size:16}),onClick:()=>(e=>{const t=c.model_limits.filter((t,n)=>n!==e);u(e=>({...e,model_limits:t})),T(!0)})(s),size:"small",children:e("å é¤")})]})}];t.useEffect(()=>{B()},[]);const B=async()=>{s(!0);try{const e=Se(),t=await ye.get(e),{success:n,message:i,data:s}=t.data;if(n){const e=s.find(e=>"TokenLimitSettings"===e.key);if(e&&e.value){const t=JSON.parse(e.value);u(t),h(t)}}else je(i)}catch(e){je(e.message)}s(!1)},F=c.model_limits.filter(e=>!l||e.model_name.toLowerCase().includes(l.toLowerCase())||e.token_field.toLowerCase().includes(l.toLowerCase())),W=e=>{A(e);try{const t=JSON.parse(e);if(O(""),(e.match(/\n/g)||[]).length<3&&e.trim().length>50){const e=JSON.stringify(t,null,2);A(e)}}catch(t){O("JSONæ ¼å¼é误: "+t.message)}};return n.jsxs(m,{spinning:i,children:[n.jsxs(g,{vertical:!0,align:"start",style:{width:"100%"},children:[n.jsx(r,{title:n.jsx(dl,{heading:5,children:"ð å
¨å±è®¾ç½®"}),style:{width:"100%"},children:n.jsxs(g,{vertical:!0,style:{width:"100%"},children:[n.jsxs(g,{children:[n.jsx(cl,{strong:!0,children:e("åè½å¼å
³ï¼")}),n.jsx(E,{checked:c.global_enabled,onChange:e=>{u(t=>({...t,global_enabled:e})),T(!0)},"aria-label":e("å
¨å±Tokenéå¶å¼å
³")}),n.jsx(cl,{type:c.global_enabled?"success":"tertiary",children:c.global_enabled?"å·²å¯ç¨":"å·²ç¦ç¨"})]}),n.jsx(I,{margin:"12px"}),n.jsx(g,{wrap:!0,children:n.jsxs(g,{children:[n.jsx(cl,{strong:!0,children:e("é»è®¤Tokenåæ®µï¼")}),n.jsxs(N,{value:c.default_token_field,onChange:e=>((e,t)=>{u(n=>({...n,[e]:t})),T(!0)})("default_token_field",e),style:{width:200},children:[n.jsx(N.Option,{value:"max_tokens",children:"max_tokens"}),n.jsx(N.Option,{value:"max_completion_tokens",children:"max_completion_tokens"})]})]})})]})}),n.jsxs(r,{title:n.jsx(dl,{heading:5,children:"ð¤ æ¨¡åéå¶é
ç½®"}),style:{width:"100%"},children:[n.jsxs(g,{style:{marginBottom:16},children:[n.jsx(d,{icon:n.jsx(Ye,{size:16}),onClick:()=>{b({model_name:"",token_field:"max_tokens",output_token_limit:4096,input_token_limit:128e3,enabled:!0}),j(!0)},disabled:!c.global_enabled,children:e("æ·»å æ¨¡åéå¶")}),n.jsx(d,{icon:n.jsx(Ze,{size:16}),type:"primary",onClick:async()=>{s(!0);
1try{const t=Se(),n=await ye.put(t,{key:"TokenLimitSettings",value:JSON.stringify(c)}),{success:i,message:s}=n.data;i?(be(e("ä¿åæå")),T(!1),h(c)):je(s)}catch(t){je(t.message)}s(!1)},theme:"solid",disabled:!w,children:e("ä¿åæ´æ¹")}),n.jsx(d,{icon:n.jsx(et,{size:16}),onClick:()=>{p&&(u(p),T(!1))},disabled:!w,children:e("éç½®")}),n.jsx(d,{icon:n.jsx(it,{size:16}),onClick:()=>{const e=c||{global_enabled:!1,default_token_field:"max_tokens",model_limits:[]},t=JSON.stringify(e,null,2);A(t),O(""),P(!0)},type:"tertiary",children:e("JSONç¼è¾")}),n.jsx(k,{prefix:e("æç´¢")+"ï¼",placeholder:e("è¾å
¥æ¨¡ååç§°æå段类å"),value:l,onChange:e=>{o(e)},style:{width:300},showClear:!0})]}),n.jsx(v,{columns:L,dataSource:F,pagination:{pageSize:20,showSizeChanger:!0,showTotal:!0},scroll:{x:1200,y:600},size:"small",rowKey:(e,t)=>`${e.model_name}_${t}`,onRow:(e,t)=>({onDoubleClick:()=>D({...e,index:t})}),empty:n.jsx("div",{style:{textAlign:"center",padding:"20px"},children:n.jsx(cl,{type:"tertiary",children:c.global_enabled?'ææ æ¨¡åéå¶é
ç½®ï¼ç¹å»"æ·»å æ¨¡åéå¶"å¼å§é
ç½®':"请å
å¯ç¨å
¨å±å¼å
³"})})})]})]}),n.jsx(x,{title:e(void 0!==f?.index?"ç¼è¾æ¨¡åéå¶":"æ·»å æ¨¡åéå¶"),visible:y,onOk:()=>_.submitForm(),onCancel:()=>j(!1),centered:!0,children:n.jsxs(a,{getFormApi:e=>C(e),onSubmit:e=>{const t=[...c.model_limits];if(f&&void 0!==f.index)t[f.index]={...e,output_token_limit:parseInt(e.output_token_limit)||0,input_token_limit:parseInt(e.input_token_limit)||0};else{const n={...e,output_token_limit:parseInt(e.output_token_limit)||0,input_token_limit:parseInt(e.input_token_limit)||0,enabled:!1!==e.enabled};t.unshift(n)}u(e=>({...e,model_limits:t})),T(!0),j(!1)},initValues:f,children:[n.jsx(a.Input,{field:"model_name",label:e("模ååç§°"),rules:[{required:!0,message:e("请è¾å
¥æ¨¡ååç§°")}],style:{width:"100%"},placeholder:e("ä¾å¦ï¼gpt-4, claude-3-sonnet")}),n.jsxs(a.Select,{field:"token_field",label:e("Tokenåæ®µç±»å"),rules:[{required:!0,message:e("è¯·éæ©Tokenåæ®µç±»å")}],style:{width:"100%"},children:[n.jsx(a.Select.Option,{value:"max_tokens",children:"max_tokens"}),n.jsx(a.Select.Option,{value:"max_completion_tokens",children:"max_completion_tokens"})]}),n.jsx(a.InputNumber,{field:"output_token_limit",label:e("è¾åºTokenéå¶"),rules:[{required:!0,message:e("请è¾å
¥è¾åºTokenéå¶")}],style:{width:"100%"},placeholder:e("0表示æ éå¶"),min:0}),n.jsx(a.InputNumber,{field:"input_token_limit",label:e("è¾å
¥Tokenéå¶"),rules:[{required:!0,message:e("请è¾å
¥è¾å
¥Tokenéå¶")}],style:{width:"100%"},placeholder:e("0表示æ éå¶"),min:0}),n.jsx(a.Switch,{field:"enabled",label:e("å¯ç¨ç¶æ"),extraText:e("æ¯å¦å¯¹æ¤æ¨¡åå¯ç¨Tokenéå¶")})]})}),n.jsx(x,{title:n.jsxs(g,{children:[n.jsx(it,{size:16}),e("JSONé
ç½®ç¼è¾å¨")]}),visible:R,onOk:()=>{try{const t=JSON.parse(z);if("boolean"!=typeof t.global_enabled)return void O("global_enabled åæ®µå¿
é¡»æ¯å¸å°å¼");if(!Array.isArray(t.model_limits))return void O("model_limits åæ®µå¿
é¡»æ¯æ°ç»");for(let e=0;e<t.model_limits.length;e++){const n=t.model_limits[e];if(!n.model_name||"string"!=typeof n.model_name)return void O(`模å ${e+1}: model_name åæ®µå¿
é¡»æ¯é空å符串`);if(!["max_tokens","max_completion_tokens"].includes(n.token_field))return void O(`模å ${e+1}: token_field å¿
é¡»æ¯ max_tokens æ max_completion_tokens`)}u(t),T(!0),P(!1),be(e("JSONé
置已åºç¨"))}catch(t){O("JSONæ ¼å¼é误: "+t.message)}},onCancel:()=>P(!1),centered:!0,okText:e("åºç¨é
ç½®"),cancelText:e("åæ¶"),okButtonProps:{disabled:!!M},children:n.jsxs(g,{vertical:!0,style:{width:"100%"},children:[n.jsxs(g,{wrap:!0,children:[n.jsx(d,{onClick:async()=>{try{await navigator.clipboard.writeText(z),be(e("å·²å¤å¶å°åªè´´æ¿"))}catch(t){je(e("å¤å¶å¤±è´¥")+": "+t.message)}},size:"small",children:e("å¤å¶å°åªè´´æ¿")}),n.jsx(d,{onClick:async()=>{try{const n=await navigator.clipboard.readText();try{const t=JSON.parse(n),i=JSON.stringify(t,null,2);A(i),O(""),be(e("å·²æåä»åªè´´æ¿å¯¼å
¥é
ç½®"))}catch(t){O("åªè´´æ¿å
容䏿¯ææç JSON æ ¼å¼: "+t.message),je(e("åªè´´æ¿å
容䏿¯ææç JSON æ ¼å¼"))}}catch(n){je(e("ä»åªè´´æ¿è¯»å失败")+": "+n.message)}},size:"small",children:e("ä»åªè´´æ¿å¯¼å
¥")}),n.jsx(d,{onClick:()=>{try{const t=JSON.parse(z),n=JSON.stringify(t,null,2);A(n),be(e("JSON å·²æ ¼å¼å"))}catch(t){je(e("æ æ³æ ¼å¼åï¼JSON æ ¼å¼é误"))}},size:"small",disabled:!!M,children:e("æ ¼å¼å")}),n.jsx(d,{onClick:()=>{const e=JSON.stringify({global_enabled:!0,default_token_field:"max_tokens",model_limits:[{model_name:"gpt-4",token_field:"max_tokens",output_token_limit:4096,input_token_limit:128e3,enabled:!0},{model_name:"gpt-4o",token_field:"max_tokens",output_token_limit:4096,input_token_limit:128e3,enabled:!0},{model_name:"o1",token_field:"max_completion_tokens",output_token_limit:1e5,input_token_limit:2e5,enabled:!0},{model_name:"claude-3-5-sonnet-20241022",token_field:"max_tokens",output_token_limit:8192,input_token_limit:2e5,enabled:!0}]},null,2);A(e),W(e)},size:"small",type:"tertiary",children:e("å 载示ä¾é
ç½®")})]}),n.jsx(cl,{type:"tertiary",style:{fontSize:"12px"},children:e("æç¤ºï¼æ¨å¯ä»¥å¤å¶æ¤é
ç½®åäº«ç»æåï¼æä»æåé£é导å
¥é
ç½®")}),M&&n.jsx("div",{style:{padding:"8px 12px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px"},children:n.jsx(cl,{type:"danger",children:M})}),n.jsx(S,{value:z,onChange:W,placeholder:e("请è¾å
¥JSONé
ç½®"),style:{fontFamily:'Consolas, Monaco, "Courier New", monospace',fontSize:"14px",lineHeight:"1.5",minHeight:"400px",
1whiteSpace:"pre-wrap"},autosize:{minRows:20,maxRows:25}}),n.jsx("div",{style:{padding:"8px 12px",backgroundColor:"#f3f4f6",borderRadius:"6px",fontSize:"12px"},children:n.jsxs(cl,{type:"tertiary",children:[n.jsx("strong",{children:e("é
置说æ")+"ï¼"}),n.jsx("br",{}),"⢠global_enabled: å
¨å±å¼å
³ (true/false)",n.jsx("br",{}),'⢠default_token_field: é»è®¤å段类å ("max_tokens" æ "max_completion_tokens")',n.jsx("br",{}),"⢠model_limits: 模åéå¶æ°ç»ï¼æ¯ä¸ªæ¨¡åå
å« model_name, token_field, output_token_limit, input_token_limit, enabled åæ®µ"]})})]})})]})}function pl(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,p]=t.useState({GeminiEmptyResponseCheckEnabled:!1,GeminiImageErrorCheckEnabled:!1,GeminiImageErrorCheckModels:[],GeminiImageErrorCheckParams:[]}),[h,x]=t.useState(r),y=t.useRef(),[j,f]=t.useState(""),[b,_]=t.useState(""),S=()=>{const e=j.trim();if(!e)return;if(r.GeminiImageErrorCheckModels.includes(e))return void ve(i("该模åå·²åå¨"));const t=[...r.GeminiImageErrorCheckModels,e];p({...r,GeminiImageErrorCheckModels:t}),y.current?.setValue("GeminiImageErrorCheckModels",t),f("")},v=()=>{const e=b.trim();if(!e)return;if(r.GeminiImageErrorCheckParams.includes(e))return void ve(i("è¯¥åæ°å·²åå¨"));const t=[...r.GeminiImageErrorCheckParams,e];p({...r,GeminiImageErrorCheckParams:t}),y.current?.setValue("GeminiImageErrorCheckParams",t),_("")};return t.useEffect(()=>{const t={GeminiEmptyResponseCheckEnabled:!1,GeminiImageErrorCheckEnabled:!1,GeminiImageErrorCheckModels:[],GeminiImageErrorCheckParams:[]};for(let n in e.options)"GeminiEmptyResponseCheckEnabled"===n||"GeminiImageErrorCheckEnabled"===n?t[n]=!0===e.options[n]:"GeminiImageErrorCheckModels"!==n&&"GeminiImageErrorCheckParams"!==n||("string"==typeof e.options[n]?t[n]=e.options[n]?e.options[n].split(",").map(e=>e.trim()).filter(e=>e):[]:Array.isArray(e.options[n])?t[n]=e.options[n]:t[n]=[]);p(t),x(structuredClone(t)),y.current?.setValues(t),setTimeout(()=>{y.current?.setValues(t)},100)},[e.options]),n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>y.current=e,style:{marginBottom:15},initValues:r,children:n.jsxs(a.Section,{text:i("Gemini 模å设置"),children:[n.jsx(o,{gutter:16,children:n.jsx(c,{span:8,children:n.jsx(a.Switch,{field:"GeminiEmptyResponseCheckEnabled",label:i("å¯ç¨ç©ºå夿£æµ"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{p({...r,GeminiEmptyResponseCheckEnabled:e})}})})}),n.jsx(o,{gutter:16,children:n.jsxs(c,{span:16,children:[n.jsx(u.Text,{type:"secondary",style:{display:"block",marginTop:8},children:i("æ£æµ Gemini 模åè¿åç空åå¤ï¼ä»
æ role 使 å
容çååºï¼ï¼å¹¶å°å
¶è§ä¸ºå¤±è´¥ã")}),n.jsx(u.Text,{type:"secondary",style:{display:"block",marginTop:4},children:i("å¯ç¨åï¼å½ Gemini è¿å空åéå
容æ¶ï¼ç³»ç»ä¼è¿åé误è䏿¯ç©ºååºã")})]})}),n.jsx(o,{gutter:16,style:{marginTop:24},children:n.jsx(c,{span:8,children:n.jsx(a.Switch,{field:"GeminiImageErrorCheckEnabled",label:i("å¯ç¨çå¾éè¯¯æ£æµ"),size:"default",checkedText:"ï½",uncheckedText:"ã",onChange:e=>{p({...r,GeminiImageErrorCheckEnabled:e})}})})}),r.GeminiImageErrorCheckEnabled&&n.jsxs(n.Fragment,{children:[n.jsx(o,{gutter:16,style:{marginTop:16},children:n.jsxs(c,{span:24,children:[n.jsx(u.Text,{strong:!0,children:i("æ£æ¥ç模å")}),n.jsxs(g,{style:{width:"100%",marginTop:8},children:[n.jsx(k,{value:j,onChange:f,placeholder:i("请è¾å
¥æ¨¡ååç§°"),style:{width:400},onEnterPress:S}),n.jsx(d,{onClick:S,children:i("æ·»å ")})]}),n.jsx(u.Text,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:4},children:i("gemini_hint_001")}),r.GeminiImageErrorCheckModels.length>0&&n.jsx("div",{style:{marginTop:12},children:n.jsx(ae,{tagList:r.GeminiImageErrorCheckModels.map(e=>({tagKey:e,children:e,closable:!0,onClose:()=>(e=>{const t=r.GeminiImageErrorCheckModels.filter(t=>t!==e);p({...r,GeminiImageErrorCheckModels:t}),y.current?.setValue("GeminiImageErrorCheckModels",t)})(e)})),size:"large"})})]})}),n.jsx(o,{gutter:16,style:{marginTop:24},children:n.jsxs(c,{span:24,children:[n.jsx(u.Text,{strong:!0,children:i("æ£æ¥ç finishReason åæ°")}),n.jsxs(g,{style:{width:"100%",marginTop:8},children:[n.jsx(k,{value:b,onChange:_,placeholder:i("请è¾å
¥ finishReason å¼"),style:{width:400},onEnterPress:v}),n.jsx(d,{onClick:v,children:i("æ·»å ")})]}),n.jsx(u.Text,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:4},children:i("常è§å¼å¸¸ï¼SAFETY, RECITATION, MAX_TOKENS, OTHER, IMAGE_SAFETY, NO_IMAGE")}),r.GeminiImageErrorCheckParams.length>0&&n.jsx("div",{style:{marginTop:12},children:n.jsx(ae,{tagList:r.GeminiImageErrorCheckParams.map(e=>({tagKey:e,children:e,closable:!0,onClose:()=>(e=>{const t=r.GeminiImageErrorCheckParams.filter(t=>t!==e);p({...r,GeminiImageErrorCheckParams:t}),y.current?.setValue("GeminiImageErrorCheckParams",t)})(e)})),size:"large"})})]})}),n.jsx(o,{gutter:16,children:n.jsxs(c,{span:24,children:[n.jsx(u.Text,{type:"secondary",style:{display:"block",marginTop:8},children:i("æ£æµ Gemini ç徿¨¡åè¿åç finishReason åæ°ï¼å½æ£æµå°éä¸çå¼å¸¸å¼æ¶å°å
¶è§ä¸ºå¤±è´¥ã")}),n.jsx(u.Text,{type:"secondary",style:{display:"block",marginTop:4}
1,children:i("常è§å¼å¸¸ï¼SAFETYï¼å®å
¨è¿æ»¤ï¼ãRECITATIONï¼éå¤å
容ï¼ãMAX_TOKENSï¼è¶
åºéå¶ï¼ãOTHERï¼å
¶ä»é误ï¼")})]})})]}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:function(){const t=ke(r,h);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));l(!0);const n=Se(),s=t.map(e=>{let t=r[e.key];return"boolean"==typeof t?t=String(t):Array.isArray(t)&&(t=t.join(",")),ye.put(n,{key:e.key,value:t})});Promise.all(s).then(t=>{if(1===s.length){if(t.includes(void 0))return}else if(s.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh()}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿å Gemini 设置")})})]})})})}const{Title:hl}=u,xl=e=>[{label:e("å¯¹è¯ (chat)"),value:"chat"},{label:e("å¾ççæ (image)"),value:"image"},{label:e("è§é¢ (video)"),value:"video"},{label:e("é³ä¹ (music)"),value:"music"},{label:e("å
¶ä» (other)"),value:"other"}],ml={rank:1,model_name:"",provider:"",calls:0,tokens:0,pct:0,growth:0,enabled:!0};function gl(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,o]=t.useState(!1),[c,p]=t.useState(!1),[y,j]=t.useState({total_calls:0,total_tokens:0,active_models:0}),[f,b]=t.useState([]),[_,S]=t.useState(!1),[k,C]=t.useState(-1),[w,T]=t.useState(-1),[I,R]=t.useState({...ml}),[P,z]=t.useState(!1),[N,A]=t.useState("chat"),[M,O]=t.useState(0);t.useEffect(()=>{e.options&&p(!!e.options.RankingEnabled)},[e.options]);const D=t.useCallback(async()=>{l(!0);try{const e=await ye.get("/api/ranking/admin");if(e.data.success&&e.data.data){const t=e.data.data;j(t.summary||{total_calls:0,total_tokens:0,active_models:0}),b(t.categories||[])}}catch(e){je(i("å è½½æè¡æ¦æ°æ®å¤±è´¥: ")+e.message)}finally{l(!1)}},[i]);t.useEffect(()=>{D()},[D]);const L=[{title:i("æå"),dataIndex:"rank",width:60},{title:i("模ååç§°"),dataIndex:"model_name",width:180},{title:i("ä¾åºå"),dataIndex:"provider",width:120},{title:i("è°ç¨æ¬¡æ°"),dataIndex:"calls",width:120,render:e=>(e||0).toLocaleString()},{title:i("Token æ°"),dataIndex:"tokens",width:120,render:e=>(e||0).toLocaleString()},{title:i("å æ¯(%)"),dataIndex:"pct",width:80,render:e=>(e||0).toFixed(1)},{title:i("å¢é¿(%)"),dataIndex:"growth",width:80,render:e=>(e||0).toFixed(1)},{title:i("å¯ç¨"),dataIndex:"enabled",width:60,render:(e,t)=>n.jsx(E,{size:"small",checked:!1!==e,onChange:e=>{const n=[...f];n[t._catIdx].models[t._modelIdx].enabled=e,b(n)}})},{title:i("æä½"),width:100,render:(e,t)=>n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx(at,{size:16}),size:"small",theme:"borderless",onClick:()=>{return e=t._catIdx,n=t._modelIdx,C(e),T(n),R({...f[e].models[n]}),void S(!0);var e,n}}),n.jsx(d,{icon:n.jsx(He,{size:16}),size:"small",theme:"borderless",type:"danger",onClick:()=>((e,t)=>{const n=[...f],i={...n[e]},s=[...i.models];s.splice(t,1),s.forEach((e,t)=>e.rank=t+1),i.models=s,n[e]=i,b(n)})(t._catIdx,t._modelIdx)})]})}];return n.jsxs(m,{spinning:s,children:[n.jsxs("div",{style:{marginBottom:24},children:[n.jsxs(g,{align:"center",style:{marginBottom:16},children:[n.jsx(hl,{heading:5,style:{margin:0},children:i("æè¡æ¦å¼å
³")}),n.jsx(E,{checked:c,onChange:async t=>{try{const n=Se(),s=await ye.put(n,{key:"RankingEnabled",value:String(t)});s.data.success?(p(t),be(i(t?"æè¡æ¦å·²å¼å¯":"æè¡æ¦å·²å
³é")),e.refresh&&e.refresh()):je(s.data.message||i("ä¿å失败"))}catch(n){je(i("ä¿å失败")+": "+n.message)}}}),n.jsx(u.Text,{type:"tertiary",children:i(c?"å·²å¼å¯ - é¦é¡µå±ç¤ºæè¡æ¦ï¼åå°æ¯12å°æ¶èªå¨èåæ°æ®":"å·²å
³é - é¦é¡µä¸å±ç¤ºï¼èå任塿å")})]}),!c&&n.jsx(h,{type:"info",description:i("æè¡æ¦åè½å·²å
³éï¼å端ä¸ä¼å±ç¤ºæè¡æ¦ï¼åå°èåä»»å¡ä¹ä¸ä¼æ§è¡ãä½ ä»ç¶å¯ä»¥å¨ä¸æ¹æå¨ç¼è¾æ°æ®ï¼å¼å¯åå³å¯çæã"),style:{marginBottom:16}})]}),n.jsxs("div",{style:{marginBottom:24},children:[n.jsx(hl,{heading:5,children:i("æ±æ»æ°æ®")}),n.jsx(h,{type:"info",description:i("æ±æ»æ°æ®ç±åå°æ¯12å°æ¶èªå¨èåçæï¼ä¹å¯ä»¥å¨æ¤æå¨ä¿®æ¹ãæå¨ä¿®æ¹å°å¨ä¸ä¸æ¬¡èªå¨èåæ¶è¢«è¦çã"),style:{marginBottom:12}}),n.jsxs(g,{style:{gap:24},children:[n.jsx(a.InputNumber,{field:"total_calls",label:i("æè°ç¨æ¬¡æ°"),value:y.total_calls,onChange:e=>j({...y,total_calls:e||0}),style:{width:200}}),n.jsx(a.InputNumber,{field:"total_tokens",label:i("æ Token æ°"),value:y.total_tokens,onChange:e=>j({...y,total_tokens:e||0}),style:{width:200}}),n.jsx(a.InputNumber,{field:"active_models",label:i("æ´»è·æ¨¡åæ°"),value:y.active_models,onChange:e=>j({...y,active_models:e||0}),style:{width:200}})]})]}),n.jsxs("div",{style:{marginBottom:16},children:[n.jsxs(g,{align:"center",style:{marginBottom:12},children:[n.jsx(hl,{heading:5,style:{margin:0},children:i("æè¡æ°æ®")}),n.jsx(d,{icon:n.jsx(Ye,{size:16}),size:"small",onClick:()=>z(!0),children:i("æ·»å åç±»")})]}),f.map((e,t)=>n.jsxs("div",{style:{marginBottom:24,border:"1px solid hsl(var(--border))",borderRadius:8,padding:16},children:[n.jsxs(g,{align:"center",style:{marginBottom:12,justifyContent:"space-between",width:"100%"},children:[n.jsxs(g,{align:"center",children:[n.jsx(hl,{heading:6,style:{margin:0},children:xl(i).find(t=>t.value===e.category)?.label||e.category}),n.jsxs(u.Text,{type:"tertiary",children:[i("å¢é¿"),": ",(e.growth||0).toFixed(1),"%"]})]}),n.jsxs(g,{children:[n.jsx(d,{icon:n.jsx(Ye,{size:16}),size:"small",onClick:()=>(e=>{C(e),T(-1);const t=f[e],n=t.models?t.models.length+1:1;R({...ml,rank:n}),S(!0)})(t),children:i("æ·»å æ¨¡å")}),n.jsx(d,{icon:n.jsx(He,{size:16}),size:"small",type:"danger",theme:"borderless",onClick:()=>(e=>{const t=[...f];t.splice(e,1),b(t)})(t)})]})]}),n.jsx(v,{columns:L,dataSource:(e.models||[]).map((e,n)=>({...e,key:`${t}-${n}`,_catIdx:t,_modelIdx:n})),pagination:!1,size:"small",empty:n.jsx(u.Text,{type:"tertiary",children:i('ææ æ¨¡åï¼ç¹å»"æ·»å æ¨¡å"å¼å§é
ç½®')})})]},e.category)),0===f.length&&n.jsx(h,{type:"info",description:i("ææ æè¡åç±»æ°æ®ãå¼å¯æè¡æ¦å¼å
³åï¼
1åå°ä¼èªå¨èåæ°æ®ï¼ä¹å¯ä»¥ç¹å»ãæ·»å åç±»ãæå¨é
ç½®ã"),style:{marginBottom:16}})]}),n.jsx(d,{type:"primary",loading:r,onClick:async()=>{o(!0);try{const e={summary:y,categories:f},t=await ye.put("/api/ranking/admin",e);t.data.success?be(i("æè¡æ¦æ°æ®å·²ä¿å")):je(t.data.message||i("ä¿å失败"))}catch(e){je(i("ä¿å失败")+": "+e.message)}finally{o(!1)}},style:{marginTop:8},children:i("ä¿åæè¡æ¦æ°æ®")}),n.jsx(x,{title:i(w>=0?"ç¼è¾æ¨¡å":"æ·»å æ¨¡å"),visible:_,onOk:()=>{if(!I.model_name.trim())return void ve(i("模ååç§°ä¸è½ä¸ºç©º"));const e=[...f],t={...e[k]},n=[...t.models||[]];w>=0?n[w]={...I}:n.push({...I}),t.models=n,e[k]=t,b(e),S(!1)},onCancel:()=>S(!1),width:480,children:n.jsxs(a,{layout:"vertical",initValues:I,onValueChange:e=>R({...I,...e}),children:[n.jsx(a.Input,{field:"model_name",label:i("模ååç§°"),placeholder:i("å¦ gpt-4o")}),n.jsx(a.Input,{field:"provider",label:i("ä¾åºå"),placeholder:i("å¦ OpenAI")}),n.jsx(a.InputNumber,{field:"rank",label:i("æå"),min:1}),n.jsx(a.InputNumber,{field:"calls",label:i("è°ç¨æ¬¡æ°"),min:0}),n.jsx(a.InputNumber,{field:"tokens",label:i("Token æ°"),min:0}),n.jsx(a.InputNumber,{field:"pct",label:i("å æ¯(%)"),min:0,max:100,precision:1}),n.jsx(a.InputNumber,{field:"growth",label:i("å¢é¿(%)"),precision:1}),n.jsx(a.Switch,{field:"enabled",label:i("å¯ç¨")})]})}),n.jsx(x,{title:i("æ·»å åç±»"),visible:P,onOk:()=>{f.find(e=>e.category===N)?ve(i("该å类已åå¨")):(b([...f,{category:N,growth:M,models:[]}]),z(!1),A("chat"),O(0))},onCancel:()=>z(!1),width:360,children:n.jsxs(a,{layout:"vertical",children:[n.jsx(a.Select,{field:"category",label:i("åç±»"),initValue:N,onChange:e=>A(e),optionList:xl(i),style:{width:"100%"}}),n.jsx(a.InputNumber,{field:"growth",label:i("åç±»å¢é¿(%)"),initValue:M,onChange:e=>O(e||0),precision:1})]})})]})}const{Text:yl}=u;function jl(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,d]=t.useState(!1),[u,p]=t.useState({CaptchaLoginEnabled:!1,SMSLoginEnabled:!1,SMSProvider:"",SMSSecretId:"",SMSSecretKey:"",SMSRegion:"",SMSSdkAppId:"",SMSSignName:"",SMSTemplateId:"",SMSCodeExpireMinutes:"5",SMSRateLimitMinutes:"1",SMSRateLimitCount:"1",SMSMosUsername:"",SMSMosPassword:"",SMSMosSignature:"",SMSMosContentTemplate:"æ¨çéªè¯ç 为{code}ï¼{expire}åéå
ææï¼è¯·å¿æ³é²ã",SMSMosBizType:"",SMSMosEndpoint:"https://ns.mosapi.cn:9100",ChannelModelRedirect:""}),h=t.useRef(),[x,m]=t.useState(u),g=async(e,t)=>{try{const n=await ye.put("/api/option/",{key:e,value:t}),{success:s,message:l}=n.data;return s?(be(i("ä¿åæå")),p(n=>({...n,[e]:t})),m(n=>({...n,[e]:t})),h.current&&h.current.setValue(e,t),!0):(je(l),!1)}catch(n){return je(i("ä¿å失败")+": "+n.message),!1}};return t.useEffect(()=>{const t={},n=["CaptchaLoginEnabled","SMSLoginEnabled","SMSProvider","SMSSecretId","SMSSecretKey","SMSRegion","SMSSdkAppId","SMSSignName","SMSTemplateId","SMSCodeExpireMinutes","SMSRateLimitMinutes","SMSRateLimitCount","SMSMosUsername","SMSMosPassword","SMSMosSignature","SMSMosContentTemplate","SMSMosBizType","SMSMosEndpoint","ChannelModelRedirect"];for(let i in e.options)if(n.includes(i)){let n=e.options[i];"CaptchaLoginEnabled"===i||"SMSLoginEnabled"===i?n="true"===n||!0===n:null==n&&(n=""),t[i]=n}Object.keys(t).length>0&&(p(e=>({...e,...t})),m(e=>({...e,...t})),setTimeout(()=>{h.current&&h.current.setValues(t)},100))},[e.options]),n.jsxs(a,{style:{marginBottom:15},getFormApi:e=>h.current=e,autoComplete:"off",children:[n.jsxs("div",{style:{position:"absolute",opacity:0,height:0,overflow:"hidden",pointerEvents:"none"},children:[n.jsx("input",{type:"text",name:"prevent_autofill_username",tabIndex:-1,autoComplete:"username"}),n.jsx("input",{type:"password",name:"prevent_autofill_password",tabIndex:-1,autoComplete:"current-password"})]}),n.jsxs(a.Section,{text:i("æ©å±åè½é
ç½®"),children:[n.jsx(o,{gutter:16,children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{padding:"60px 40px",textAlign:"center",background:"linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%)",borderRadius:"12px",border:"2px dashed #d0d7de"}
1,children:[n.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"ð"}),n.jsx(yl,{strong:!0,style:{fontSize:"18px",display:"block",marginBottom:"12px",color:"#24292e"},children:i("æ¤åºåç¨äºæ·»å æ°çäºå¼æ©å±åè½")}),n.jsx(yl,{type:"tertiary",style:{fontSize:"14px",display:"block",marginBottom:"8px"},children:i("åæåè½å·²æåè³å个ç¬ç«æ¨¡åï¼")})]})})}),n.jsx(o,{gutter:16,style:{marginTop:"24px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"SMSLoginEnabled",label:i("å¯ç¨çä¿¡éªè¯ç ç»å½"),initValue:u.SMSLoginEnabled,checkedText:i("å¼"),uncheckedText:i("å
³"),onChange:async t=>{await g("SMSLoginEnabled",String(t))&&e.refresh&&e.refresh()}}),n.jsx(yl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¼å¯åï¼ç¨æ·å¯ä»¥ä½¿ç¨ææºå·+éªè¯ç ç»å½ç³»ç»")}),n.jsx(yl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("â ï¸ éè¦é
ç½®çä¿¡æå¡æä¾åï¼å¦è
¾è®¯äºçä¿¡ï¼æè½ä½¿ç¨")})]})})]}),u.SMSLoginEnabled&&n.jsxs(a.Section,{text:i("çä¿¡æå¡é
ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{span:12,children:n.jsxs(a.Select,{field:"SMSProvider",label:i("çä¿¡æå¡æä¾å"),placeholder:i("è¯·éæ©çä¿¡æå¡æä¾å"),initValue:u.SMSProvider,onChange:async t=>{p(e=>({...e,SMSProvider:t})),await g("SMSProvider",t)&&e.refresh&&await e.refresh()},style:{width:"100%"},children:[n.jsx(a.Select.Option,{value:"tencent",children:i("è
¾è®¯äºçä¿¡")}),n.jsx(a.Select.Option,{value:"aliyun",children:i("é¿éäºçä¿¡")}),n.jsx(a.Select.Option,{value:"huawei",children:i("å为äºçä¿¡")}),n.jsx(a.Select.Option,{value:"xuanwu",children:i("çæ¦äºMOSçä¿¡")})]})}),"xuanwu"!==u.SMSProvider&&n.jsx(c,{span:12,children:n.jsx(a.Input,{field:"SMSRegion",label:i("æå¡åºå"),placeholder:"ap-guangzhou",initValue:u.SMSRegion,onChange:e=>{p(t=>({...t,SMSRegion:e}))},onBlur:async e=>{await g("SMSRegion",e.target.value)}})}),"xuanwu"===u.SMSProvider&&n.jsxs(c,{span:12,children:[n.jsx(a.Input,{field:"SMSMosEndpoint",label:i("æ¥å
¥å°å"),placeholder:"https://ns.mosapi.cn:9100",initValue:u.SMSMosEndpoint,onChange:e=>{p(t=>({...t,SMSMosEndpoint:e}))},onBlur:async e=>{await g("SMSMosEndpoint",e.target.value)}}),n.jsx(yl,{type:"tertiary",style:{fontSize:"11px",display:"block",marginTop:"4px"},children:i("é»è®¤ https://ns.mosapi.cn:9100ï¼ä¸è¬æ éä¿®æ¹")})]})]}),"xuanwu"!==u.SMSProvider&&n.jsxs(n.Fragment,{children:[n.jsxs(o,{gutter:16,style:{marginTop:"16px"},children:[n.jsx(c,{span:12,children:n.jsx(a.Input,{field:"SMSSecretId",label:i("Secret ID"),placeholder:u.SMSSecretId?i("å·²é
ç½®ï¼è¾å
¥æ°å¼ä»¥æ´æ°ï¼"):i("请è¾å
¥ Secret ID"),mode:"password",autoComplete:"new-password",name:"sms_secret_id_setting",onChange:e=>{p(t=>({...t,SMSSecretId:e}))},onBlur:async e=>{const t=e.target.value;t&&await g("SMSSecretId",t)}})}),n.jsx(c,{span:12,children:n.jsx(a.Input,{field:"SMSSecretKey",label:i("Secret Key"),placeholder:u.SMSSecretKey?i("å·²é
ç½®ï¼è¾å
¥æ°å¼ä»¥æ´æ°ï¼"):i("请è¾å
¥ Secret Key"),mode:"password",autoComplete:"new-password",name:"sms_secret_key_setting",onChange:e=>{p(t=>({...t,SMSSecretKey:e}))},onBlur:async e=>{const t=e.target.value;t&&await g("SMSSecretKey",t)}})})]}),n.jsxs(o,{gutter:16,style:{marginTop:"16px"},children:[n.jsxs(c,{span:12,children:[n.jsx(a.Input,{field:"SMSSdkAppId",label:i("çä¿¡åºç¨ SDK App ID"),placeholder:"1400xxxxxx",initValue:u.SMSSdkAppId,onChange:e=>{p(t=>({...t,SMSSdkAppId:e}))},onBlur:async e=>{await g("SMSSdkAppId",e.target.value)}}),n.jsx(yl,{type:"tertiary",style:{fontSize:"11px",display:"block",marginTop:"4px"},children:i("è
¾è®¯äºï¼å¨çä¿¡æ§å¶å°çåºç¨å表ä¸è·å")})]}),n.jsxs(c,{span:12,children:[n.jsx(a.Input,{field:"SMSSignName",label:i("çä¿¡ç¾å"),placeholder:i("请è¾å
¥çä¿¡ç¾å"),initValue:u.SMSSignName,onChange:e=>{p(t=>({...t,SMSSignName:e}))},onBlur:async e=>{await g("SMSSignName",e.target.value)}}),n.jsx(yl,{type:"tertiary",style:{fontSize:"11px",display:"block",marginTop:"4px"},children:i("éè¦å¨çä¿¡æ§å¶å°åå»ºå¹¶å®¡æ ¸éè¿")})]})]}),n.jsx(o,{gutter:16,style:{marginTop:"16px"},children:n.jsxs(c,{span:12,children:[n.jsx(a.Input,{field:"SMSTemplateId",label:i("çä¿¡æ¨¡æ¿ ID"),placeholder:"123456",initV
1alue:u.SMSTemplateId,onChange:e=>{p(t=>({...t,SMSTemplateId:e}))},onBlur:async e=>{await g("SMSTemplateId",e.target.value)}}),n.jsx(yl,{type:"tertiary",style:{fontSize:"11px",display:"block",marginTop:"4px"},children:i("æ¨¡æ¿æ ¼å¼: æ¨çéªè¯ç æ¯{1}ï¼{2}åéå
ææ")})]})})]}),"xuanwu"===u.SMSProvider&&n.jsxs(n.Fragment,{children:[n.jsxs(o,{gutter:16,style:{marginTop:"16px"},children:[n.jsx(c,{span:12,children:n.jsx(a.Input,{field:"SMSMosUsername",label:i("MOS è´¦å·"),placeholder:i("请è¾å
¥çæ¦äº MOS è´¦å·"),initValue:u.SMSMosUsername,onChange:e=>{p(t=>({...t,SMSMosUsername:e}))},onBlur:async e=>{await g("SMSMosUsername",e.target.value)}})}),n.jsx(c,{span:12,children:n.jsx(a.Input,{field:"SMSMosPassword",label:i("MOS å¯ç "),placeholder:u.SMSMosPassword?i("å·²é
ç½®ï¼è¾å
¥æ°å¼ä»¥æ´æ°ï¼"):i("请è¾å
¥çæ¦äº MOS å¯ç "),mode:"password",autoComplete:"new-password",name:"sms_mos_password_setting",onChange:e=>{p(t=>({...t,SMSMosPassword:e}))},onBlur:async e=>{const t=e.target.value;t&&await g("SMSMosPassword",t)}})})]}),n.jsxs(o,{gutter:16,style:{marginTop:"16px"},children:[n.jsxs(c,{span:12,children:[n.jsx(a.Input,{field:"SMSMosSignature",label:i("çä¿¡ç¾å"),placeholder:i("å¦ï¼çæ¦ç§æ"),initValue:u.SMSMosSignature,onChange:e=>{p(t=>({...t,SMSMosSignature:e}))},onBlur:async e=>{await g("SMSMosSignature",e.target.value)}}),n.jsx(yl,{type:"tertiary",style:{fontSize:"11px",display:"block",marginTop:"4px"},children:i("ä¼èªå¨æ¼æ¥å°çä¿¡å
容å¼å¤´ï¼æ éåå¨å
容模æ¿é")})]}),n.jsx(c,{span:12,children:n.jsx(a.Input,{field:"SMSMosBizType",label:i("ä¸å¡ç±»å IDï¼bizTypeï¼å¯éï¼"),placeholder:"100",initValue:u.SMSMosBizType,onChange:e=>{p(t=>({...t,SMSMosBizType:e}))},onBlur:async e=>{await g("SMSMosBizType",e.target.value)}})})]}),n.jsx(o,{gutter:16,style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"SMSMosContentTemplate",label:i("éªè¯ç å
容模æ¿"),placeholder:"æ¨çéªè¯ç 为{code}ï¼{expire}åéå
ææï¼è¯·å¿æ³é²ã",initValue:u.SMSMosContentTemplate,onChange:e=>{p(t=>({...t,SMSMosContentTemplate:e}))},onBlur:async e=>{await g("SMSMosContentTemplate",e.target.value)}}),n.jsx(yl,{type:"tertiary",style:{fontSize:"11px",display:"block",marginTop:"4px"},children:i("å ä½ç¬¦ {code} 为éªè¯ç ï¼{expire} ä¸ºæææåéæ°ï¼å¿
é¡»å
å« {code}")})]})})]}),n.jsx(o,{gutter:16,style:{marginTop:"16px"},children:n.jsx(c,{span:12,children:n.jsx(a.InputNumber,{field:"SMSCodeExpireMinutes",label:i("éªè¯ç æææï¼åéï¼"),placeholder:"5",min:1,max:30,initValue:Number(u.SMSCodeExpireMinutes)||5,onChange:async t=>{p(e=>({...e,SMSCodeExpireMinutes:String(t)})),await g("SMSCodeExpireMinutes",String(t))&&e.refresh&&e.refresh()},style:{width:"100%"}})})}),n.jsxs(o,{gutter:16,style:{marginTop:"16px"},children:[n.jsx(c,{span:12,children:n.jsx(a.InputNumber,{field:"SMSRateLimitMinutes",label:i("åéé¢çéå¶å¨æï¼åéï¼"),placeholder:"1",min:1,max:60,initValue:Number(u.SMSRateLimitMinutes)||1,onChange:async t=>{p(e=>({...e,SMSRateLimitMinutes:String(t)})),await g("SMSRateLimitMinutes",String(t))&&e.refresh&&e.refresh()},style:{width:"100%"}})}),n.jsx(c,{span:12,children:n.jsx(a.InputNumber,{field:"SMSRateLimitCount",label:i("卿å
æå¤§å鿬¡æ°"),placeholder:"1",min:1,max:10,initValue:Number(u.SMSRateLimitCount)||1,onChange:async t=>{p(e=>({...e,SMSRateLimitCount:String(t)})),await g("SMSRateLimitCount",String(t))&&e.refresh&&e.refresh()},style:{width:"100%"}})})]}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{padding:"12px",background:"#fff7e6",border:"1px solid #ffd591",borderRadius:"6px"},children:[n.jsxs(yl,{style:{fontSize:"13px",color:"#ad6800"},children:["ð¡ ",n.jsx("strong",{children:i("é
ç½®æç¤º")})]}),n.jsxs("ul",{style:{margin:"8px 0 0 0",paddingLeft:"20px"},children:[n.jsxs("li",{style:{fontSize:"12px",color:"#ad6800",marginTop:"4px"},children:[i("è
¾è®¯äºï¼éè¦å¨"),n.jsx("a",{href:"https://console.cloud.tencent.com/smsv2",target:"_blank",rel:"noopener noreferrer",children:i("çä¿¡æ§å¶å°")}),i("å建åºç¨ãç¾å忍¡æ¿")]}),n.jsxs("li",{style:{fontSize:"12px",color:"#ad6800",marginTop:"4px"},children:[i("Secret ID/Key å¨"),n.jsx("a",{href:"https://console.cloud.tencent.com/cam/capi",target:"_blank",rel:"noopener noreferrer",children:i("访é®ç®¡ç-APIå¯é¥")}),i("ä¸è·å")]}),n.jsx("li",{style:{fontSize:"12px",color:"#ad6800",marginTop:"4px"}
1,children:i("建议å¯ç¨æ»åéªè¯ç 鲿¢æ¶æå·çä¿¡")})]})]})})})]}),n.jsx(a.Section,{text:i("æ¸ éæ¨¡åéå®å"),children:n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(a.TextArea,{field:"ChannelModelRedirect",label:i("模åéå®åé
ç½®ï¼å¤ç»´å符串æ°ç»ï¼"),placeholder:'[\n ["deepseek-chat", "deepseek-v3", "deepseek-v3-250324"],\n ["deepseek-r1", "deepseek-reasoner", "deepseek-r1-250120"],\n ["gpt-4", "gpt-4-turbo", "gpt-4-0613"]\n]',autosize:{minRows:6,maxRows:15},onChange:async e=>{p(t=>({...t,ChannelModelRedirect:e}))}}),n.jsx(yl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("ð¡ 说æï¼æ¯ä¸ªåæ°ç»æ¯ä¸ä¸ªç价模åç»ï¼ç»å
çæ¨¡åå¯ä»¥äºç¸éå®å")}),n.jsx(yl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i('ð æ ¼å¼ï¼[["model1","model2"],["model3","model4"]]ï¼æ¯æå¤è¡ä¹¦å')})]})})})]})}function fl(e){const{t:i}=ge(),[s,l]=t.useState(!1),[h,x]=t.useState([]),[g,y]=t.useState([]),[j,f]=t.useState(""),[b,_]=t.useState(""),[S,v]=t.useState([]),[C,w]=t.useState(""),[T,I]=t.useState([]),[R,P]=t.useState(""),[z,N]=t.useState([]),[A,O]=t.useState(""),[D,L]=t.useState([]),[B,F]=t.useState(""),[W,J]=t.useState([]),[U,V]=t.useState(""),[K,G]=t.useState(!1),[q,$]=t.useState([]),[H,Q]=t.useState([]),[X,Y]=t.useState(0),[Z,ee]=t.useState(null),[te,ne]=t.useState({enabled_menus:[],enabled_side_menus:[],log_query_limit:"100000",fixed_log_total_enabled:!0}),ie=[{label:i("é¦é¡µ"),value:"home"},{label:i("æ§å¶å°"),value:"console"},{label:i("OpenClaw ä¸é®é¨ç½²"),value:"openclaw"},{label:i("模åä»·æ ¼"),value:"pricing"},{label:i("代çå ç"),value:"affiliate"},{label:i("å
³äº"),value:"about"},{label:i("å
¬å"),value:"announcement"},{label:i("æç¨"),value:"tutorial"},{label:i("è¯è¨åæ¢"),value:"language"},{label:i("ç»å½"),value:"login"},{label:i("注å"),value:"register"},{label:i("èç³»æä»¬"),value:"customersupport"},{label:i("æç« èµè®¯"),value:"news"},{label:i("æè½ä¸å¿"),value:"skills"}],se=[{label:i("æ§å¶å°"),value:"console"},{label:i("å®éªå®¤"),value:"playground"},{label:i("æ¸ é管ç"),value:"channel"},{label:i("è天/ç»ç»"),value:"chat"},{label:i("API令ç"),value:"token"},{label:i("å
æ¢ç "),value:"redemption"},{label:i("ä½é¢å
å¼"),value:"topup"},{label:i("èç³»æä»¬"),value:"customersupport"},{label:i("ç¨æ·ç®¡ç"),value:"user"},{label:i("æ¥å¿ç®¡ç"),value:"logs"},{label:i("个人设置"),value:"personal"},{label:i("ç³»ç»è®¾ç½®"),value:"setting"},{label:i("æ¨é管ç"),value:"push_manage"},{label:i("OpenClaw é¨ç½²"),value:"openclaw"}],le=async e=>{l(!0);try{const t=Se(),n=e.map(e=>ye.put(t,{key:e.key,value:"boolean"==typeof e.value?e.value.toString():e.value})),s=(await Promise.all(n)).filter(e=>!e.data.success);s.length>0?s.forEach(e=>{je(e.data.message)}):be(i("æ´æ°æå"))}catch(t){je(i("æ´æ°å¤±è´¥"))}l(!1)},ae=()=>{const e=R.trim();e&&!T.includes(e)&&(I([...T,e]),P(""))},re=()=>{const e=A.trim();e&&!z.includes(e)&&(N([...z,e]),O(""))},oe=()=>{const e=B.trim();e&&!D.includes(e)&&(L([...D,e]),F(""))},ce=()=>{const e=U.trim();e&&!W.includes(e)&&(J([...W,e]),V(""))},de=()=>{j&&!h.includes(j)&&(x([...h,j]),f(""))},ue=()=>{b&&!g.includes(b)&&(y([...g,b]),_(""))},pe=()=>{C&&!S.includes(C)&&(v([...S,C]),w(""))},he=(e,t,n)=>{const i=[...q];i[e]={...i[e],[t]:n},$(i)},xe=(e,t,n)=>{const i=[...H];i[e]={...i[e],[t]:n},Q(i)};return t.useEffect(()=>{if(e.options,e.options.RedirectRequestCodes&&x(e.options.RedirectRequestCodes.split(",").filter(e=>e)),e.options.RedirectErrorMessages&&y(e.options.RedirectErrorMessages.split(",").filter(e=>e)),e.options.ErrorLogWhitelist?v(e.options.ErrorLogWhitelist.split("\n").filter(e=>e.trim())):v([]),e.options.AutomaticDisableKeywords){const t=e.options.AutomaticDisableKeywords.split("\n").map(e=>e.trim()).filter(e=>e);I(t)}else I([]);if(e.options.NoRetryErrors){const t=e.options.NoRetryErrors.split("\n").map(e=>e.trim()).filter(e=>e);N(t)}else N([]);if(e.options.AutoSortChannelWhitelist){const t=e.options.AutoSortChannelWhitelist.split("\n").map(e=>e.trim()).filter(e=>e);L(t)}else L([]);if(e.options.ErrorCountWhitelist){const t=e.options.ErrorCountWhitelist.split("\n").map(e=>e.trim()).filter(e=>e);J(t)}else J([]);const t=e.options.EnabledMenus?e.options.EnabledMenus.split(",").filter(e=>e):[],n=e.options.EnabledSideMenus?e.options.EnabledSideMenus.split(",").filter(e=>e):[],i=e.options.LogQueryLimit||"100000",s="true"===e.options.FixedLogTotalEnabled||!0===e.options.FixedLogTotalEnabled;if(e.options.AccountDailyLimitSettings)try{const t=JSON.parse(e.options.AccountDailyLimitSettings);G(t.enabled||!1);const n=Ne(),i=(t.groups||[]).map(e=>({accounts:e.accounts,limit:parseFloat((e.limit/n).toFixed(2))}));$(i)}catch(a){console.error("è§£æè´¦å·æ¯æ¥æ¶èéå¶è®¾ç½®å¤±è´¥:",a),G(!1),$([])}if(e.options.CustomMenuLinks)try{const t=JSON.parse(e.options.CustomMenuLinks);Q(Array.isArray(t)?t:[])}catch(a){console.error("è§£æèªå®ä¹èå龿¥è®¾ç½®å¤±è´¥:",a),Q([])}else Q([]);const l={enabled_menus:t,enabled_side_menus:n,log_query_limit:i,fixed_log_total_enabled:s};ne(l),Z&&Z.setValues(l)},[e.options,Z]),n.jsx(m,{spinning:s,children:n.jsxs(a,{initValues:te,getFormApi:e=>{ee(e),(te.enabled_menus.length||te.enabled_side_menus.length)&&setTimeout(()=>{e.setValues(te)},0)},onValueChange:e=>{},style:{marginBottom:15},children:[n.jsxs(a.Section,{text:i("æ¥å¿æ¥è¯¢è®¾ç½®"),children:[n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},style:{marginTop:16},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"log_query_limit",label:i("æ¥å¿æ¥è¯¢è®°å½éå¶"),placeholder:i("é»è®¤å¼ï¼100000"),helpText:i("设置æ¥å¿æ¥è¯¢æ¶çæå¤§è®°å½æ°éå¶ï¼ç¨äºæåå¤§æ°æ®éæ¥è¯¢æ§è½ãå¦æè®¾ç½®ä¸º0æè´æ°ï¼å°ä½¿ç¨é»è®¤å¼100000"),style:{width:"100%"}})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Switch,{field:"fixed_log_total_enabled",label:i("å¯ç¨åºå®æ¥å¿æ»æ°"),checkedText:i("å¼"),uncheckedText:i("å
³"),helpText:i("å¼å¯å使ç¨åºå®æ°éä½ä¸ºæ¥å¿æ»æ°ï¼ä¸æ§è¡COUNTæ¥è¯¢ä»¥æåæ§è½ï¼å
³éåå°æ¾ç¤ºçå®çæ¥å¿æ»æ°")})})]}),n.jsx(d,{onClick:async()=>
1{if(!Z)return;const t=Z.getValues(),n=parseInt(t.log_query_limit,10);isNaN(n)?je(i("请è¾å
¥ææçæ°å")):(await le([{key:"LogQueryLimit",value:t.log_query_limit},{key:"FixedLogTotalEnabled",value:t.fixed_log_total_enabled?"true":"false"}]),e.refresh())},style:{marginTop:16},children:i("ä¿åæ¥å¿æ¥è¯¢è®¾ç½®")})]}),n.jsxs(a.Section,{text:i("é误æ¥å¿è¯¦ç»è®°å½ç½åå"),children:[n.jsx(u.Text,{type:"tertiary",style:{display:"block",marginBottom:16},children:i("妿é误æ¥å¿å
å«ç½ååä¸çå
³é®è¯ï¼å°å¨æ¥å¿contentåæ®µè®°å½è¿æ¡é误信æ¯ï¼å±ç°ç»ç¨æ·æ¥ç")}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},style:{marginTop:16},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(p,{value:S,onChange:v,placeholder:i("è¾å
¥å
³é®è¯åå车"),style:{width:"100%"}})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{placeholder:i("è¾å
¥æ°çç½ååå
³é®è¯"),value:C,onChange:e=>w(e),suffix:n.jsx(d,{onClick:pe,children:i("æ·»å ")}),onEnterPress:pe})})]}),n.jsx(d,{onClick:async()=>{Array.isArray(S)?(await le([{key:"ErrorLogWhitelist",value:S.join("\n")}]),e.refresh()):je(i("é误æ¥å¿ç½ååæ ¼å¼ä¸æ£ç¡®"))},style:{marginTop:16},children:i("ä¿åé误æ¥å¿ç½åå")})]}),n.jsxs(a.Section,{text:i("ç¨æ·æ¯æ¥æ¶èéå¶"),children:[n.jsx(u.Text,{type:"tertiary",style:{display:"block",marginBottom:16},children:i("æ§å¶ç¨æ·çæ¯æ¥æ»æ¶èä¸éãåä¸ç»å
çç¨æ·å
±äº«æ¶èä¸éï¼è¾¾å°ä¸éå该ç»ç¨æ·ç请æ±å°è¢«æç»ã")}),n.jsx(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},style:{marginTop:16},children:n.jsx(c,{xs:24,children:n.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:16},children:[n.jsx("span",{style:{marginRight:8},children:i("å¯ç¨ç¨æ·æ¯æ¥æ¶èéå¶")}),n.jsx(E,{checked:K,onChange:G,checkedText:i("å¼"),uncheckedText:i("å
³")})]})})}),K&&n.jsxs(n.Fragment,{children:[q.map((e,t)=>n.jsx(r,{style:{marginBottom:16},title:`${i("é
ç½®ç»")} ${t+1}`,headerExtraContent:n.jsx(d,{type:"danger",theme:"borderless",icon:n.jsx(He,{size:16}),onClick:()=>(e=>{const t=[...q];t.splice(e,1),$(t)})(t),children:i("å é¤")}),children:n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsxs(c,{xs:24,sm:24,md:16,lg:16,xl:16,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx(u.Text,{strong:!0,children:i("ç¨æ·åå表")}),n.jsx(u.Text,{type:"tertiary",style:{marginLeft:8},children:i("è¾å
¥ç¨æ·ååå车添å ")})]}),n.jsx(p,{value:e.accounts,onChange:e=>he(t,"accounts",e),placeholder:i("è¾å
¥ç¨æ·ååå车ï¼ä¾å¦ï¼hw-1"),style:{width:"100%"}})]}),n.jsxs(c,{xs:24,sm:24,md:8,lg:8,xl:8,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx(u.Text,{strong:!0,children:i("æ¯æ¥æ¶èä¸é")}),n.jsx(u.Text,{type:"tertiary",style:{marginLeft:8},children:i("åä½ï¼ç¾å
")})]}),n.jsx(M,{value:e.limit,onChange:e=>he(t,"limit",e),min:.01,step:.1,precision:2,style:{width:"100%"},placeholder:i("ä¾å¦ï¼10 表示 $10"),prefix:"$"})]})]})},t)),n.jsx(d,{icon:n.jsx(Ye,{size:16}),onClick:()=>{$([...q,{accounts:[],limit:10}])},style:{marginBottom:16},children:i("æ·»å é
ç½®ç»")})]}),n.jsx("div",{children:n.jsx(d,{onClick:async()=>{for(let e=0;e<q.length;e++){const t=q[e];if(!t.accounts||0===t.accounts.length)return void je(i("ç¨æ·æ¯æ¥æ¶èéå¶é
ç½®")+` ${e+1}: `+i("ç¨æ·åå表ä¸è½ä¸ºç©º"));if(!t.limit||t.limit<=0)return void je(i("ç¨æ·æ¯æ¥æ¶èéå¶é
ç½®")+` ${e+1}: `+i("æ¶èä¸éå¿
须大äº0"))}const t=Ne(),n=q.map(e=>({accounts:e.accounts,limit:Math.round(e.limit*t)})),s={enabled:K,groups:n};await le([{key:"AccountDailyLimitSettings",value:JSON.stringify(s)}]),e.refresh()},style:{marginTop:16},children:i("ä¿åç¨æ·æ¯æ¥æ¶èéå¶è®¾ç½®")})})]}),n.jsxs(a.Section,{text:i("èåæ¾ç¤ºè®¾ç½®"),children:[n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},style:{marginTop:16},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Select,{field:"enabled_menus",label:i("é¡¶é¨èå"),placeholder:i("éæ©è¦æ¾ç¤ºçé¡¶é¨èå"),multiple:!0,style:{width:"100%"},optionList:ie.map(e=>({label:e.label,value:e.value}))})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Select,{field:"enabled_side_menus",label:i("ä¾§è¾¹æ èå"),placeholder:i("éæ©è¦æ¾ç¤ºçä¾§è¾¹æ èå"),multiple:!0,style:{width:"100%"},optionList:se.map(e=>({label:e.label,value:e.value}))})})]}),n.jsx(d,{onClick:async()=>
1{if(!Z)return;const t=Z.getValues();await le([{key:"EnabledMenus",value:(t.enabled_menus||[]).join(",")},{key:"EnabledSideMenus",value:(t.enabled_side_menus||[]).join(",")}]),e.refresh()},style:{marginTop:16},children:i("ä¿åèå设置")})]}),n.jsxs(a.Section,{text:i("èªå®ä¹èå龿¥"),children:[n.jsx(u.Text,{type:"tertiary",style:{display:"block",marginBottom:16},children:i("æ·»å èªå®ä¹èå龿¥ï¼å°å¨é¡¶é¨å¯¼èªæ åä¾§è¾¹æ 䏿¾ç¤ºï¼ç¹å»åè·³è½¬å°æå®å°å")}),H.map((e,t)=>n.jsx(r,{style:{marginBottom:16},title:`${i("龿¥")} ${t+1}`,headerExtraContent:n.jsx(d,{type:"danger",theme:"borderless",icon:n.jsx(He,{size:16}),onClick:()=>(e=>{const t=[...H];t.splice(e,1),Q(t)})(t),children:i("å é¤")}),children:n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsxs(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx(u.Text,{strong:!0,children:i("åç§°")}),n.jsx(u.Text,{type:"tertiary",style:{marginLeft:8},children:i("æ¾ç¤ºå¨èåä¸çåç§°")})]}),n.jsx(k,{value:e.name,onChange:e=>xe(t,"name",e),placeholder:i("ä¾å¦ï¼å¸®å©ä¸å¿"),style:{width:"100%"}})]}),n.jsxs(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx(u.Text,{strong:!0,children:i("龿¥å°å")}),n.jsx(u.Text,{type:"tertiary",style:{marginLeft:8},children:i("ç¹å»å跳转çURL")})]}),n.jsx(k,{value:e.url,onChange:e=>xe(t,"url",e),placeholder:i("ä¾å¦ï¼https://help.example.com"),style:{width:"100%"}})]})]})},t)),n.jsx(d,{icon:n.jsx(Ye,{size:16}),onClick:()=>{Q([...H,{name:"",url:""}])},style:{marginBottom:16},children:i("æ·»å 龿¥")}),n.jsx("div",{children:n.jsx(d,{onClick:async()=>{for(let e=0;e<H.length;e++){const t=H[e];if(!t.name||""===t.name.trim())return void je(i("èªå®ä¹èå龿¥")+` ${e+1}: `+i("åç§°ä¸è½ä¸ºç©º"));if(!t.url||""===t.url.trim())return void je(i("èªå®ä¹èå龿¥")+` ${e+1}: `+i("龿¥å°åä¸è½ä¸ºç©º"))}await le([{key:"CustomMenuLinks",value:JSON.stringify(H)}]),e.refresh()},style:{marginTop:16},children:i("ä¿åèªå®ä¹èå龿¥")})})]}),n.jsxs(a.Section,{text:i("éå®åé误ç 设置"),children:[n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},style:{marginTop:16},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(p,{value:h,onChange:x,placeholder:i("è¾å
¥é误ç åå车"),style:{width:"100%"}})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{placeholder:i("è¾å
¥æ°çéå®åé误ç "),value:j,onChange:e=>f(e),suffix:n.jsx(d,{onClick:de,children:i("æ·»å ")}),onEnterPress:de})})]}),n.jsx(d,{onClick:async()=>{Array.isArray(h)?(await le([{key:"RedirectRequestCodes",value:h.join(",")}]),e.refresh()):je(i("éå®åéè¯¯ç æ ¼å¼ä¸æ£ç¡®"))},style:{marginTop:16},children:i("ä¿åéå®åé误ç 设置")})]}),n.jsxs(a.Section,{text:i("ææé误信æ¯å±è½è®¾ç½®"),children:[n.jsx(u.Text,{type:"tertiary",style:{display:"block",marginBottom:16},children:i("å±è½å
嫿æå
³é®è¯çé误信æ¯ï¼é²æ¢ææä¿¡æ¯ï¼å¦ä½é¢ä¸è¶³ãAPIå¯é¥çï¼æ³é²ç»ç¨æ·")}),n.jsxs(o,{gutter:16,style:{marginTop:16},children:[n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("已添å çå±è½å
³é®è¯")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("ç¹å»æ ç¾å¯å é¤è¯¥å
³é®è¯")})]}),n.jsx(p,{value:g,onChange:y,placeholder:i("è¾å
¥å
³é®è¯åå车添å "),style:{width:"100%"}})]}),n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("æ·»å æ°çå±è½å
³é®è¯")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("è¾å
¥åç¹å»æ·»å æé®ææå车")})]}),n.jsx(k,{placeholder:i("è¾å
¥å
³é®è¯ï¼ä¾å¦ï¼ä½é¢ä¸è¶³"),value:b,onChange:e=>_(e),suffix:n.jsx(d,{onClick:ue,children:i("æ·»å ")}),onEnterPress:ue})]})]}),n.jsx(o,{gutter:16,style:{marginTop:16},children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{padding:"10px",border:"1px solid #e8e8e8",borderRadius:"4px",backgroundColor:"#fff1f0"},children:[n.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:i("sensitive_info_shield_title")}),n.jsx("div",{style:{fontSize:"12px",color:"#666"},children:n.jsx(ln,{i18nKey:"sensitive_info_shield_desc",components:{br:n.jsx("br",{}),code:n.jsx("code",{})}})})]})})}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:async()=>{Array.isArray(g)?(await le([{key:"RedirectErrorMessages",value:g.join(",")}]),e.refresh()):je(i("éå®åéè¯¯æ¶æ¯æ ¼å¼ä¸æ£ç¡®"))},children:i("ä¿åææä¿¡æ¯å±è½è®¾ç½®")})})]}),n.jsxs(a.Section,{text:i("æ¸ é失败ç»è®¡è±å
ç½åå"),children:[n.jsx(u.Text,{type:"tertiary",style:{display:"block",marginBottom:16},children:i("å½è¯·æ±å¤±è´¥æ¶ï¼å¦æéè¯¯ç æéè¯¯æ¶æ¯å
å«ç½ååä¸çä»»ä½ä¸é¡¹ï¼
1åä¸ä¼è®°å½ä¸ºæ¸ é失败")}),n.jsxs(o,{gutter:16,style:{marginTop:16},children:[n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("已添å çè±å
å
³é®è¯")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("ç¹å»æ ç¾å¯å é¤è¯¥å
³é®è¯")})]}),n.jsx(p,{value:W,onChange:J,placeholder:i("è¾å
¥å
³é®è¯åå车添å "),style:{width:"100%"}})]}),n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("æ·»å æ°çè±å
å
³é®è¯")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("è¾å
¥åç¹å»æ·»å æé®ææå车")})]}),n.jsx(k,{placeholder:i("è¾å
¥å
³é®è¯ï¼ä¾å¦ï¼invalid_request_error"),value:U,onChange:e=>V(e),suffix:n.jsx(d,{onClick:ce,children:i("æ·»å ")}),onEnterPress:ce})]})]}),n.jsx(o,{gutter:16,style:{marginTop:16},children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{padding:"10px",border:"1px solid #e8e8e8",borderRadius:"4px",backgroundColor:"#f0f9ff"},children:[n.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:i("error_count_whitelist_title")}),n.jsx("div",{style:{fontSize:"12px",color:"#666"},children:n.jsx(ln,{i18nKey:"error_count_whitelist_desc",components:{br:n.jsx("br",{}),code:n.jsx("code",{}),strong:n.jsx("strong",{})}})})]})})}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:async()=>{Array.isArray(W)?(await le([{key:"ErrorCountWhitelist",value:W.join("\n")}]),e.refresh()):je(i("é误计æ°ç½ååæ ¼å¼ä¸æ£ç¡®"))},children:i("ä¿åæ¸ é失败ç»è®¡è±å
ç½åå")})})]}),n.jsxs(a.Section,{text:i("æºè½æåºè·³è¿åç»ç½åå"),children:[n.jsx(u.Text,{type:"tertiary",style:{display:"block",marginBottom:16},children:i("å¨ç½ååä¸çåç»å°è·³è¿æºè½æåºï¼ç´æ¥æç
§ä¼å
级åæééæ©æ¸ é")}),n.jsxs(o,{gutter:16,style:{marginTop:16},children:[n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("已添å çåç»å")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("ç¹å»æ ç¾å¯å é¤è¯¥åç»")})]}),n.jsx(p,{value:D,onChange:L,placeholder:i("è¾å
¥åç»ååå车添å "),style:{width:"100%"}})]}),n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("æ·»å æ°çåç»å")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("è¾å
¥åç¹å»æ·»å æé®ææå车")})]}),n.jsx(k,{placeholder:i("è¾å
¥åç»åï¼ä¾å¦ï¼default"),value:B,onChange:e=>F(e),suffix:n.jsx(d,{onClick:oe,children:i("æ·»å ")}),onEnterPress:oe})]})]}),n.jsx(o,{gutter:16,style:{marginTop:16},children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{padding:"10px",border:"1px solid #e8e8e8",borderRadius:"4px",backgroundColor:"#fffbe6"},children:[n.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:i("auto_sort_whitelist_title")}),n.jsx("div",{style:{fontSize:"12px",color:"#666"},children:n.jsx(ln,{i18nKey:"auto_sort_whitelist_desc",components:{br:n.jsx("br",{}),code:n.jsx("code",{})}})})]})})}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:async()=>{Array.isArray(D)?(await le([{key:"AutoSortChannelWhitelist",value:D.join("\n")}]),e.refresh()):je(i("æºè½æåºç½ååæ ¼å¼ä¸æ£ç¡®"))},children:i("ä¿åæºè½æåºè·³è¿åç»ç½åå")})})]}),n.jsxs(a.Section,{text:i("请æ±å¤±è´¥ä¸éè¯é误é
ç½®"),children:[n.jsx(u.Text,{type:"tertiary",style:{display:"block",marginBottom:16},children:i("å½ä¸æ¸¸ééè¿åé误ä¸å
å«è¿äºé误æ¶,ä¸éè¯å
¶ä»æ¸ é,ç´æ¥è¿åé误ç»ç¨æ·")}),n.jsxs(o,{gutter:16,style:{marginTop:16},children:[n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("已添å çé误å
³é®è¯")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("ç¹å»æ ç¾å¯å é¤è¯¥å
³é®è¯")})]}),n.jsx(p,{value:z,onChange:N,placeholder:i("è¾å
¥é误å
³é®è¯åå车添å "),style:{width:"100%"}})]}),n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("æ·»å æ°çé误å
³é®è¯")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("è¾å
¥åç¹å»æ·»å æé®ææå车")})]}),n.jsx(k,{placeholder:i("è¾å
¥é误å
³é®è¯ï¼ä¾å¦ï¼content_filter"),value:A,onChange:e=>O(e),suffix:n.jsx(d,{onClick:re,children:i("æ·»å ")}),onEnterPress:re})]})]}),n.jsx(o,{gutter:16,style:{marginTop:16},children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{padding:"10px",border:"1px solid #e8e8e8",borderRadius:"4px",backgroundColor:"#f6ffed"},children:[n.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:i("no_retry_error_title")}),n.jsx("div",{style:{fontSize:"12px",color:"#666"},children:n.jsx(ln,{i18nKey:"no_retry_error_desc",components:{br:n.jsx("br",{}),code:n.jsx("code",{})}})})]})})}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:async()=>{Array.isArray(z)?(await le([{key:"NoRetryErrors",value:z.join("\n")}]),e.refresh()):je(i("ä¸éè¯éè¯¯æ ¼å¼ä¸æ£ç¡®"))},children:i("ä¿åä¸éè¯é误设置")})})]}),n.jsxs(a.Section,{text:i("æ¸ éç¦ç¨è§¦åå
³é®è¯é
ç½®"),children:[n.jsx(u.Text,{type:"tertiary",style:{display:"block",marginBottom:16},children:i("å½ä¸æ¸¸ééè¿åé误ä¸å
å«è¿äºå
³é®è¯æ¶(ä¸åºå大å°å),å°èªå¨ç¦ç¨è¯¥æ¸ é")}),n.jsxs(o,{gutter:16,style:{marginTop:16},children:[n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8},children:[n.jsx("strong",{children:i("已添å ç触åå
³é®è¯")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("ç¹å»æ ç¾å¯å é¤è¯¥å
³é®è¯")})]}),n.jsx(p,{value:T,onChange:I,placeholder:i("è¾å
¥å
³é®è¯åå车添å "),style:{width:"100%"}})]}),n.jsxs(c,{span:12,children:[n.jsxs("div",{style:{marginBottom:8}
1,children:[n.jsx("strong",{children:i("æ·»å æ°ç触åå
³é®è¯")}),n.jsx("div",{style:{fontSize:"12px",color:"#666",marginTop:4},children:i("è¾å
¥åç¹å»æ·»å æé®ææå车")})]}),n.jsx(k,{placeholder:i("è¾å
¥å
³é®è¯ï¼ä¾å¦ï¼invalid_api_key"),value:R,onChange:e=>P(e),suffix:n.jsx(d,{onClick:ae,children:i("æ·»å ")}),onEnterPress:ae})]})]}),n.jsx(o,{gutter:16,style:{marginTop:16},children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{padding:"10px",border:"1px solid #e8e8e8",borderRadius:"4px",backgroundColor:"#fff7e6"},children:[n.jsx("div",{style:{fontWeight:"bold",marginBottom:"4px"},children:i("auto_disable_title")}),n.jsx("div",{style:{fontSize:"12px",color:"#666"},children:n.jsx(ln,{i18nKey:"auto_disable_desc",components:{br:n.jsx("br",{}),code:n.jsx("code",{})}})})]})})}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:async()=>{Array.isArray(T)?(await le([{key:"AutomaticDisableKeywords",value:T.join("\n")}]),e.refresh()):je(i("èªå¨ç¦ç¨å
³é®è¯æ ¼å¼ä¸æ£ç¡®"))},children:i("ä¿åæ¸ éç¦ç¨è§¦åå
³é®è¯")})})]})]},X)})}function bl(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({WxPusherToken:"",WxPusherUid:"",WxPusherNotificationEnabled:!1,EmailNotificationEnabled:!1,ServerAddress:""}),p=t.useRef(null),h=async(e,t)=>{const n=t.target.checked,i={...r};i[e]=n,u(i),p.current&&p.current.setValue(e,n)};return t.useEffect(()=>{e.options;const t={WxPusherToken:e.options.WxPusherToken||"",WxPusherUid:e.options.WxPusherUid||"",WxPusherNotificationEnabled:!0===e.options.WxPusherNotificationEnabled,EmailNotificationEnabled:!0===e.options.EmailNotificationEnabled,ServerAddress:e.options.ServerAddress||""};u(t),p.current&&p.current.setValues(t)},[e.options]),n.jsx(m,{spinning:s,children:n.jsx(a,{initValues:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("éç¥æ¨é设置"),children:[n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Checkbox,{field:"WxPusherNotificationEnabled",noLabel:!0,onChange:e=>h("WxPusherNotificationEnabled",e),children:i("å¯ç¨å¾®ä¿¡æ¨ééç¥")})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Checkbox,{field:"EmailNotificationEnabled",noLabel:!0,onChange:e=>h("EmailNotificationEnabled",e),children:i("å¯ç¨é®ä»¶éç¥")})})]}),n.jsxs(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:[n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"WxPusherToken",label:i("微信æ¨éToken"),placeholder:i("请è¾å
¥WxPusherçToken"),style:{width:"100%"}})}),n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"WxPusherUid",label:i("微信æ¨éUID"),placeholder:i("请è¾å
¥WxPusherçUID"),style:{width:"100%"}})})]}),n.jsx(a.Label,{children:i("åè°å°å")}),n.jsx(k,{readOnly:!0,suffix:n.jsx(d,{icon:"copy",onClick:()=>{navigator.clipboard.writeText(`${r.ServerAddress}/api/push/wxpusher_callback`),be(i("åè°å°åå·²å¤å¶å°åªè´´æ¿"))},children:i("å¤å¶")}),value:`${r.ServerAddress||""}/api/push/wxpusher_callback`,style:{marginTop:8,marginBottom:16}}),n.jsx(d,{onClick:async()=>{const t=p.current.getValues();await(async e=>{l(!0);try{const t=Se(),n=e.map(e=>ye.put(t,{key:e.key,value:"boolean"==typeof e.value?e.value.toString():e.value})),s=(await Promise.all(n)).filter(e=>!e.data.success);s.length>0?s.forEach(e=>{je(e.data.message)}):be(i("æ´æ°æå"))}catch(t){je(i("æ´æ°å¤±è´¥"))}l(!1)})([{key:"WxPusherToken",value:t.WxPusherToken||""},{key:"WxPusherUid",value:t.WxPusherUid||""},{key:"WxPusherNotificationEnabled",value:t.WxPusherNotificationEnabled},{key:"EmailNotificationEnabled",value:t.EmailNotificationEnabled}]),e.refresh()},style:{marginTop:16},children:i("ä¿åéç¥è®¾ç½®")}),n.jsxs("div",{style:{marginTop:8,fontSize:"12px",color:"#666"},children:[i("微信æ¨é: ")+(r.WxPusherNotificationEnabled?i("å·²å¯ç¨"):i("æªå¯ç¨")),n.jsx("br",{}),i("é®ä»¶éç¥")+": "+(r.EmailNotificationEnabled?i("å·²å¯ç¨"):i("æªå¯ç¨"))]})]})})})}function _l(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({RatioChangeNotifyEnabled:!1,RatioChangeNotifyWebhookURL:""}),p=t.useRef(null);return t.useEffect(()=>{const t={RatioChangeNotifyEnabled:!0===e.options.RatioChangeNotifyEnabled,RatioChangeNotifyWebhookURL:e.options.RatioChangeNotifyWebhookURL||""};u(t),p.current&&p.current.setValues(t)},[e.options]),n.jsx(m,{spinning:s,children:n.jsx(a,{initValues:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("模ååçåæ´éç¥"),children:[n.jsx(h,{type:"info",description:i("å¼å¯åï¼å½æ¨¡ååçãè¡¥å
¨åçææ¨¡ååºå®ä»·æ ¼è¢«ä¿®æ¹å¹¶å®é
åçååæ
1¶ï¼ç³»ç»ä¼èªå¨å°åæ´ç模åï¼æ§å¼âæ°å¼ï¼åå¹¶æ¨éå°ä¼ä¸å¾®ä¿¡ç¾¤ã"),style:{marginBottom:16}}),n.jsx(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:n.jsx(c,{xs:24,sm:24,md:12,lg:12,xl:12,children:n.jsx(a.Checkbox,{field:"RatioChangeNotifyEnabled",noLabel:!0,onChange:e=>((e,t)=>{const n=t.target.checked,i={...r};i[e]=n,u(i),p.current&&p.current.setValue(e,n)})("RatioChangeNotifyEnabled",e),children:i("å¯ç¨æ¨¡ååçåæ´éç¥")})})}),n.jsx(o,{gutter:{xs:8,sm:16,md:24,lg:24,xl:24,xxl:24},children:n.jsx(c,{xs:24,sm:24,md:24,lg:18,xl:18,children:n.jsx(a.Input,{field:"RatioChangeNotifyWebhookURL",label:i("ä¼ä¸å¾®ä¿¡ç¾¤æºå¨äºº Webhook å°å"),placeholder:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxxx",style:{width:"100%"}})})}),n.jsx(d,{onClick:async()=>{const t=p.current.getValues();await(async e=>{l(!0);try{const t=Se(),n=e.map(e=>ye.put(t,{key:e.key,value:"boolean"==typeof e.value?e.value.toString():e.value})),s=(await Promise.all(n)).filter(e=>!e.data.success);s.length>0?s.forEach(e=>{je(e.data.message)}):be(i("æ´æ°æå"))}catch(t){je(i("æ´æ°å¤±è´¥"))}l(!1)})([{key:"RatioChangeNotifyEnabled",value:!!t.RatioChangeNotifyEnabled},{key:"RatioChangeNotifyWebhookURL",value:t.RatioChangeNotifyWebhookURL||""}]),e.refresh()},style:{marginTop:16},children:i("ä¿å设置")}),n.jsxs("div",{style:{marginTop:8,fontSize:"12px",color:"#666"},children:[i("åçåæ´éç¥")+": ",r.RatioChangeNotifyEnabled?i("å·²å¯ç¨"):i("æªå¯ç¨")]})]})})})}const{Text:Sl}=u,kl=e=>{const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({Keywords:"",BaiduOcpcToken:"",StatisticsCode:"",SEOPageConfigs:"[]",SeoTitle:"",Disclaimer:""}),p=t.useRef(),[h,g]=t.useState(r),[y,f]=t.useState([]),[b,_]=t.useState(!1),[S,k]=t.useState({path:"",title:"",description:"",keywords:""}),[C,w]=t.useState(-1);function T(e){return t=>{u(n=>({...n,[e]:t}))}}t.useEffect(()=>{const t={};for(let s in e.options)Object.keys(r).includes(s)&&(t[s]=e.options[s]);const n={...r,...t};u(n),g(structuredClone(n)),p.current&&p.current.setValues(n);try{const t=e.options?.SEOPageConfigs||"[]",n=JSON.parse(t).map(e=>({path:e.path||"",title:e.title||"",description:e.description||"",keywords:e.keywords||""}));f(n)}catch(i){console.error("è§£æSEOé
置失败:",i),f([])}},[e.options]);const I=(e,t)=>{k(n=>({...n,[e]:t}))},E=[{title:i("页é¢è·¯å¾"),dataIndex:"path",render:e=>e.endsWith("*")?n.jsxs(n.Fragment,{children:[e," ",n.jsx(j,{color:"blue",children:i("åç¼å¹é
")})]}):e},{title:i("æ é¢"),dataIndex:"title",width:200},{title:i("æè¿°"),dataIndex:"description",width:300,ellipsis:!0},{title:i("å
³é®è¯"),dataIndex:"keywords",width:200,ellipsis:!0},{title:i("æä½"),width:120,render:(e,t,s)=>n.jsxs(n.Fragment,{children:[n.jsx(d,{theme:"light",type:"primary",style:{marginRight:8},onClick:()=>((e,t)=>{k({path:e.path||"",title:e.title||"",description:e.description||"",keywords:e.keywords||""}),w(t),_(!0)})(t,s),children:i("ç¼è¾")}),n.jsx(d,{theme:"light",type:"danger",onClick:()=>(e=>{const t=[...y];t.splice(e,1),f(t)})(s),children:i("å é¤")})]})}];return n.jsxs(n.Fragment,{children:[n.jsx(m,{spinning:s,children:n.jsxs(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:i("ç½ç«åºç¡è®¾ç½®"),children:[n.jsx(o,{children:n.jsx(c,{span:24,children:n.jsx(a.Input,{field:"SeoTitle",label:i("ç½ç«SEOæ é¢"),placeholder:i("卿¤è¾å
¥ç½ç«çSEOæ é¢ï¼å°æ¾ç¤ºå¨æµè§å¨æ ç¾é¡µåæç´¢ç»æä¸"),onChange:T("SeoT
1itle")})})}),n.jsx(o,{children:n.jsx(c,{span:24,children:n.jsx(a.TextArea,{field:"Disclaimer",label:i("ç¨æ·åè®®/å
责声æ"),placeholder:i("卿¤è¾å
¥ç¨æ·åè®®å
å®¹ï¼æ¯æ Markdown & HTML 代ç "),onChange:T("Disclaimer"),style:{fontFamily:"JetBrains Mono, Consolas"},autosize:{minRows:4,maxRows:8}})})})]}),n.jsxs(a.Section,{text:i("SEOå
¨å±è®¾ç½®"),children:[n.jsx(o,{children:n.jsx(c,{span:24,children:n.jsx(a.TextArea,{field:"Keywords",label:i("å
¨å±å
³é®è¯"),placeholder:i("请è¾å
¥å
³é®è¯,å¤ä¸ªå
³é®è¯ç¨è±æéå·åé"),onChange:T("Keywords")})})}),n.jsx(o,{style:{marginTop:16},children:n.jsxs(c,{span:24,children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[n.jsx(Sl,{strong:!0,children:i("页é¢SEO设置")}),n.jsx(d,{icon:n.jsx(Ye,{size:16}),type:"primary",onClick:()=>{k({path:"",title:"",description:"",keywords:""}),w(-1),_(!0)},children:i("æ·»å 页é¢")})]}),n.jsx(v,{columns:E,dataSource:y,pagination:!1,size:"small",empty:i("ææ é¡µé¢SEOé
ç½®")})]})})]}),n.jsxs(a.Section,{text:i("ç»è®¡ä»£ç "),children:[n.jsx(o,{children:n.jsx(c,{span:24,children:n.jsx(a.Input,{field:"BaiduOcpcToken",label:i("ç¾åº¦ OCPC Token"),placeholder:i("请è¾å
¥ç¾åº¦ OCPC Tokenï¼ä¾å¦ï¼_f7L2XwGXjyszb4d1e2oxPybgDï¼"),onChange:T("BaiduOcpcToken")})})}),n.jsx(o,{children:n.jsx(c,{span:24,children:n.jsx(a.TextArea,{field:"StatisticsCode",label:i("ç»è®¡ä»£ç "),placeholder:i("请è¾å
¥ç»è®¡ä»£ç ï¼å¦Google Analyticsãç¾åº¦ç»è®¡çï¼"),onChange:T("StatisticsCode"),style:{fontFamily:"JetBrains Mono, Consolas"},autosize:{minRows:3,maxRows:6}})})})]}),n.jsx(o,{style:{marginTop:8},children:n.jsx(d,{size:"default",onClick:function(){const t=JSON.stringify(y),n={...r,SEOPageConfigs:t},s=t!==(h.SEOPageConfigs||"[]"),a=ke(n,h);if(!a.length&&!s)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const o=[],c=Se();if(a.forEach(e=>{let t="";t="boolean"==typeof n[e.key]?String(n[e.key]):n[e.key],o.push(ye.put(c,{key:e.key,value:t}))}),s&&o.push(ye.put(c,{key:"SEOPageConfigs",value:t})),0===o.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));l(!0),Promise.all(o).then(t=>{if(1===o.length){if(t.includes(void 0))return}else if(o.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh(),u(n),g({...n})}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿åSEOä¸ç½ç«è®¾ç½®")})})]})}),n.jsx(x,{title:i(C>=0?"ç¼è¾é¡µé¢SEO":"æ·»å 页é¢SEO"),visible:b,onOk:()=>{if(S.path){if(C>=0){const e=[...y];e[C]={...S},f(e)}else{if(y.some(e=>e.path===S.path))return void je(i("该页é¢è·¯å¾å·²åå¨"));f([...y,{...S}])}_(!1)}else je(i("页é¢è·¯å¾ä¸è½ä¸ºç©º"))},onCancel:()=>{_(!1)},closeOnEsc:!0,width:600,children:b&&n.jsxs(a,{initValues:S,children:[n.jsx(a.Input,{field:"path",label:i("页é¢è·¯å¾"),placeholder:i("ä¾å¦: /chat æ /chat/* (éé
符å¹é
ææchatå页é¢)"),onChange:e=>I("path",e),help:i("以/å¼å¤´çè·¯å¾ã使ç¨*ä½ä¸ºéé
符å¯ä»¥å¹é
以ç¸ååç¼å¼å¤´çææé¡µé¢"),required:!0}),n.jsx(a.Input,{field:"title",label:i("页颿 é¢"),placeholder:i("页颿 é¢"),onChange:e=>I("title",e),help:i("ä¸éè¦å
å«ç³»ç»åç§°ï¼ç³»ç»ä¼èªå¨æ·»å ")}),n.jsx(a.TextArea,{field:"description",label:i("é¡µé¢æè¿°"),placeholder:i("é¡µé¢æè¿°"),onChange:e=>I("description",e),rows:3}
1),n.jsx(a.TextArea,{field:"keywords",label:i("页é¢å
³é®è¯"),placeholder:i("页é¢å
³é®è¯ï¼å¤ä¸ªå
³é®è¯ç¨è±æéå·åé"),onChange:e=>I("keywords",e),rows:3}),n.jsx("div",{style:{marginTop:8},children:n.jsxs(Sl,{type:"tertiary",children:[i("å½åå¼"),": ",JSON.stringify(S)]})})]})})]})},vl=e=>{const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({DetailLogEnabled:!1,DetailLogBodyEnabled:!0,StreamTruncationLogEnabled:!1,StreamTruncationLogRetentionDays:7,DetailLogExcludeUserIds:"",SecurityAuditEnabled:!1,SecurityAuditMonitorUserIds:"",MaxDetailLogNum:1e4,BigDataThreshold:2e4,LogBodyMaxLength:5e4,LogPageSizeLimit:5e3,DefaultLabGroup:"default",MaxPromptTokens:1e6,ProporTions:"",InviteRewardEnabled:!1,RequestBodySizeLimitEnabled:!1,MaxRequestBodySizeMB:20,RegisterRateLimitEnabled:!1,RegisterRateLimitPerHour:20,RegisterRateLimitPerDay:50,SysLoadShedEnabled:!1,SysLoadCPUThreshold:85,SysLoadMemThreshold:85,SysLoadSampleInterval:5,ExportGlobalConcurrencyLimit:100,ExportPerUserConcurrencyLimit:1,"hongming_sso.show_agent_domains":"",ExternalDisableChannelEnabled:!1,ExternalDisableChannelSecret:""}),p=t.useRef(),[h,x]=t.useState(r);function g(e){return t=>{u(n=>({...n,[e]:t}))}}return t.useEffect(()=>{const t={};for(let i in e.options)if(Object.keys(r).includes(i)){const n=e.options[i];"boolean"==typeof r[i]?t[i]=!0===n||"true"===n:t[i]=n}const n={...r,...t};u(n),x(structuredClone(n)),p.current&&p.current.setValues(n)},[e.options]),n.jsx(m,{spinning:s,children:n.jsxs(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:[n.jsxs(a.Section,{text:i("ç³»ç»æ¥å¿é
ç½®"),children:[n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"DetailLogEnabled",label:i("å¯ç¨è¯¦ç»æ¥å¿è®°å½"),size:"large",checkedText:"ï½",uncheckedText:"ã",onChange:g("DetailLogEnabled")})}),n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"DetailLogBodyEnabled",label:i("åå¨è¯·æ±/ååºä½"),size:"large",checkedText:"ï½",uncheckedText:"ã",onChange:g("DetailLogBodyEnabled"),extraText:i("å
³éåä¸åå¨è¯·æ±ä½ä¸ååºä½ï¼ä»
ä¿çé误æ¥å¿")})}),n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"StreamTruncationLogEnabled",label:i("å¯ç¨æµå¼æªææ¥å¿"),size:"large",checkedText:"ï½",uncheckedText:"ã",onChange:g("StreamTruncationLogEnabled"),extraText:i("è®°å½ä¸æ¸¸/æ¬æå¡ä¾§å¯¼è´çå¼å¸¸æµå¼ä¸æï¼ä¸å«ç¨æ·ä¸»å¨æå¼ï¼")})}),n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"StreamTruncationLogRetentionDays",label:i("æµå¼æªææ¥å¿ä¿ç天æ°"),placeholder:i("请è¾å
¥ä¿ç天æ°"),onChange:g("StreamTruncationLogRetentionDays"),extraText:i("è¶
è¿è¯¥å¤©æ°çæµå¼æªææ¥å¿å°è¢«å®æ¶æ¸
ç"),showClear:!0})}),n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"DetailLogExcludeUserIds",label:i("è¯¦ç»æ¥å¿æé¤ç¨æ·ID"),placeholder:i("è¾å
¥ç¨æ·IDï¼å¤ä¸ªç¨éå·åé"),onChange:g("DetailLogExcludeUserIds"),extraText:i("è¿äºç¨æ·ä¸è®°å½è¯¦ç»æ¥å¿ï¼ä»è®°å½æ¶è´¹æ¥å¿ï¼ï¼ç¨äºåå°åæ¥ç¨æ·çæ¥å¿é"),showClear:!0})}),n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"MaxDetailLogNum",label:i("è¯¦ç»æ¥å¿è®°å½æå¤§æ¡æ°"),placeholder:i("请è¾å
¥è¯¦ç»æ¥å¿è®°å½æå¤§æ¡æ°"),onChange:g("MaxDetailLogNum"),showClear:!0})}),n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"BigDataThreshold",label:i("å¤§æ°æ®åæ®µè¿æ»¤éå¼(åè)"),placeholder:i("请è¾å
¥å¤§æ°æ®åæ®µè¿æ»¤éå¼"),onChange:g("BigDataThreshold"),extraText:i("设置为0表示å卿¶ä¸è¿æ»¤ï¼æ¥çæ¶ä½¿ç¨é»è®¤å¼20000åè"),showClear:!0})}),n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"LogBodyMaxLength",label:i("æ¥å¿ä½æå¤§é¿åº¦(å符æ°)"),placeholder:i("请è¾å
¥æ¥å¿ä½æå¤§é¿åº¦"),onChange:g("LogBodyMaxLength"),extraText:i("设置为0表示ä¸éå¶ï¼ä»
å¨å卿¶çæï¼æ¥çæ¶ä¸éå¶"),showClear:!0})}),n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"LogPageSizeLimit",label:i("æ¥å¿æ¥è¯¢å页æå¤§è®°å½æ°"),placeholder:i("请è¾å
¥æ¥å¿æ¥è¯¢å页æå¤§è®°å½æ°"),onChange:g("LogPageSizeLimit"),showClear:!0})})]}),n.jsx(o,{gutter:16,style:{marginTop:16},children:n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"MaxPromptTokens",label:i("æå¤§å
许çæç¤ºè¯Tokenæ°"),placeholder:i("请è¾å
¥æå¤§å
许çæç¤ºè¯Tokenæ°"),onChange:g("MaxPromptTokens"),showClear:!0})})}),n.jsxs(o,{gutter:16,style:{marginTop:16},children:[n.jsx(c,{xs:24,sm:8,md:6,lg:6,xl:6,children:n.jsx(a.Switch,{field:"SecurityAuditEnabled",label:i("å¯ç¨æ¶å¯å®¡è®¡éé"),size:"large",checkedText:"ï½",uncheckedText:"ã",onChange:g("SecurityAuditEnabled"),extraText:i("æ»å¼å
³ï¼é»è®¤å
³éãå
³éåæ è®ºæ¯å¦é
ç½®çæ§ç¨æ·ID
1é½ä¸ééï¼å¼å¯åä»
ééå³ä¾§çæ§ç¨æ·ID")})}),n.jsx(c,{xs:24,sm:16,md:18,lg:18,xl:18,children:n.jsx(a.Input,{field:"SecurityAuditMonitorUserIds",label:i("æ¶å¯å®¡è®¡çæ§ç¨æ·ID"),placeholder:i("è¾å
¥ç¨æ·IDï¼å¤ä¸ªç¨éå·åé"),onChange:g("SecurityAuditMonitorUserIds"),extraText:i("ä»
è¿äºç¨æ·ç请æ±ä½/ååºä½ä¼è¢«ééå°ç¬ç«åºè¡¨ï¼éå¼å¯å·¦ä¾§æ»å¼å
³ãé
ç½®ç¯å¢åé SECURITY_AUDIT_SQL_DSN ä¸å¼å¯è¯¦ç»æ¥å¿ééï¼"),showClear:!0})})]})]}),n.jsx(a.Section,{text:i("å®éªå®¤åç»è®¾ç½®"),children:n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Select,{field:"DefaultLabGroup",label:i("å®éªå®¤é»è®¤åç»"),placeholder:i("è¯·éæ©å®éªå®¤é»è®¤åç»"),onChange:g("DefaultLabGroup"),children:Object.entries((()=>{try{const t=e.options?.UserUsableGroups||"{}";return JSON.parse(t)}catch(t){return{}}})()).map(([e,t])=>n.jsx(a.Select.Option,{value:e,children:t},e))})})})}),n.jsx(a.Section,{text:i("ç¨æ·å¥å±è®¾ç½®"),children:n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"InviteRewardEnabled",label:i("å¯ç¨é请å¥å±åè½"),size:"large",checkedText:"ï½",uncheckedText:"ã",onChange:g("InviteRewardEnabled")})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Input,{field:"ProporTions",label:i("å¥å±æ¯ä¾"),placeholder:i("请è¾å
¥å¥å±æ¯ä¾ï¼ç¾åæ¯ï¼"),onChange:g("ProporTions"),showClear:!0})})]})}),n.jsx(a.Section,{text:i("请æ±ä½å¤§å°éå¶"),children:n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"RequestBodySizeLimitEnabled",label:i("å¯ç¨è¯·æ±ä½å¤§å°éå¶"),size:"large",checkedText:"ï½",uncheckedText:"ã",onChange:g("RequestBodySizeLimitEnabled")})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"MaxRequestBodySizeMB",label:i("æå¤§è¯·æ±ä½å¤§å°ï¼MBï¼"),placeholder:i("请è¾å
¥æå¤§è¯·æ±ä½å¤§å°ï¼MBï¼"),onChange:g("Max
1RequestBodySizeMB"),min:1,max:1024,style:{width:"100%"}})})]})}),n.jsx(a.Section,{text:i("注åé¢çéå¶"),children:n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.Switch,{field:"RegisterRateLimitEnabled",label:i("å¯ç¨æ³¨åé¢çéå¶"),size:"large",checkedText:"ï½",uncheckedText:"ã",onChange:g("RegisterRateLimitEnabled"),extraText:i("éå¶åä¸IPçæ³¨åé¢çï¼é²æ¢æºå¨äººæ¹éå·å·")})}),n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"RegisterRateLimitPerHour",label:i("åIPæ¯å°æ¶æ³¨åä¸é"),placeholder:"20",onChange:g("RegisterRateLimitPerHour"),min:1,max:1e3,style:{width:"100%"},extraText:i("建议å¼ï¼20ï¼å岿°æ®ï¼æ£å¸¸VPNå³°å¼çº¦10次/å°æ¶ï¼")})}),n.jsx(c,{xs:24,sm:8,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"RegisterRateLimitPerDay",label:i("åIPæ¯æ¥æ³¨åä¸é"),placeholder:"50",onChange:g("RegisterRateLimitPerDay"),min:1,max:1e4,style:{width:"100%"},extraText:i("建议å¼ï¼50ï¼å岿°æ®ï¼æ£å¸¸VPNå³°å¼çº¦15次/天ï¼")})})]})}),n.jsx(a.Section,{text:i("æå¡å¨è´è½½çæ"),children:n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:8,md:6,lg:6,xl:6,children:n.jsx(a.Switch,{field:"SysLoadShedEnabled",label:i("å¯ç¨è´è½½çæ"),size:"large",checkedText:"ï½",uncheckedText:"ã",onChange:g("SysLoadShedEnabled"),extraText:i("CPU æå
åè¶
é弿¶èªå¨æç»æ°è¯·æ±ï¼è¿å 503")})}),n.jsx(c,{xs:24,sm:8,md:6,lg:6,xl:6,children:n.jsx(a.InputNumber,{field:"SysLoadCPUThreshold",label:i("CPU çæéå¼ï¼%ï¼"),placeholder:"85",onChange:g("SysLoadCPUThreshold"),min:50,max:99,style:{width:"100%"},extraText:i("建议å¼ï¼80ï¼ç 5% ä½é鲿¢ GC æå¨è¯¯è§¦")})}),n.jsx(c,{xs:24,sm:8,md:6,lg:6,xl:6,children:n.jsx(a.InputNumber,{field:"SysLoadMemThreshold",label:i("å
åçæéå¼ï¼%ï¼"),placeholder:"85",onChange:g("SysLoadMemThreshold"),min:50,max:99,style:{width:"100%"},extraText:i("建议å¼ï¼80ï¼è¶
è¿å GC å忥å§ä¸å")})}),n.jsx(c,{xs:24,sm:8,md:6,lg:6,xl:6,children:n.jsx(a.InputNumber,{field:"SysLoadSampleInterval",label:i("ééé´éï¼ç§ï¼"),placeholder:"5",onChange:g("SysLoadSampleInterval"),min:1,max:60,style:{width:"100%"},extraText:i("è´è½½æ°æ®æ´æ°é¢çï¼é»è®¤ 5 ç§")})})]})}),n.jsx(a.Section,{text:i("导åºä»»å¡å¹¶åéå¶"),children:n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"ExportGlobalConcurrencyLimit",label:i("åå°æå¡å¨åæ¶è¿è¡ç导åºä»»å¡ä¸é"),placeholder:"100",onChange:g("ExportGlobalConcurrencyLimit"),min:1,max:1e3,style:{width:"100%"},extraText:i("æ¯å°æå¡å¨ï¼èç¹ï¼è¿ç¨å
åæ¶å¤çç导åºä»»å¡ä¸éãé群ä¸å¯¼åºä»»å¡å¨æ¥æ¶è¯·æ±çèç¹æ§è¡ï¼æåèç¹å
åæ§å¶ï¼å¼è¶å¤§è¯¥èç¹å
åååè¶é«ï¼è´è½½é«æ¶å»ºè®®è°å°")})}),n.jsx(c,{xs:24,sm:12,md:8,lg:8,xl:8,children:n.jsx(a.InputNumber,{field:"ExportPerUserConcurrencyLimit",label:i("åç¨æ·åæ¶è¿è¡ç导åºä»»å¡ä¸é"),placeholder:"1",onChange:g("ExportPerUserConcurrencyLimit"),min:1,max:100,style:{width:"100%"},extraText:i("åä¸ªç¨æ·åæ¶è¿è¡ï¼çå¾
ä¸/å¤çä¸ï¼ç导åºä»»å¡æ°éä¸é")})})]})}),n.jsx(a.Section,{text:i("å¤é¨æ¸ éç¦ç¨æ¥å£"),children:n.jsxs(o,{gutter:16,children:[n.jsx(c,{xs:24,sm:8,md:6,lg:6,xl:6,children:n.jsx(a.Switch,{field:"ExternalDisableChannelEnabled",label:i("å¯ç¨å¤é¨æ¸ éç¦ç¨æ¥å£"),size:"large",checkedText:"ï½",uncheckedText:"ã",onChange:g("ExternalDisableChannelEnabled"),extraText:i("å¼å¯åï¼ç¬¬ä¸æ¹å¹³å°å¯éè¿ HMAC-SHA256 ç¾åè°ç¨æ¥å£ç¦ç¨æ¸ é")})}),n.jsx(c,{xs:24,sm:16,md:12,lg:12,xl:12,children:n.jsx(a.Input,{field:"ExternalDisableChannelSecret",label:i("æ¥å£ç¾åå¯é¥"),placeholder:i("ç空åä¸ä¿®æ¹ç°æå¯é¥"),mode:"password",onChange:g("ExternalDisableChannelSecret"),extraText:i("ç¬¬ä¸æ¹å¹³å°ä½¿ç¨æ¤å¯é¥å¯¹è¯·æ±å HMAC-SHA256 ç¾åï¼å»ºè®®ä½¿ç¨ 32 ä½ä»¥ä¸éæºå符串"),showClear:!0})})]})}),n.jsx(a.Section,{text:i("鸿æºSSOæ¾ç¤ºæ§å¶"),children:n.jsx(o,{gutter:16,children:n.jsx(c,{xs:24,sm:24,md:16,lg:16,xl:16,children:n.jsx(a.TextArea,{field:"hongming_sso.show_agent_domains",label:i("å
许æ¾ç¤ºé¸¿æºSSO设置ç代çç«åå"),placeholder:i("å¤ä¸ªååç¨è±æéå·åéï¼ä¾å¦ï¼a.example.com,b.example.com"),rows:3,onChange:g("hongming_sso.show_agent_domains")})})})}),n.jsx(o,{style:{marginTop:8},children:n.jsx(d,{size:"default",onClick:function(){const t=ke(r,h);if(!t.length)return ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const n=Se(),s=t.map(e=>{let t="";return t="boolean"==typeof r[e.key]||"number"==typeof r[e.key]?String(r[e.key]):r[e.key],ye.put(n,{key:e.key,value:t})});l(!0),Promise.all(s).then(t=>{if(1===s.length){if(t.includes(void 0))return}else if(s.length>1&&t.includes(void 0))return je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),e.refresh();const n=structuredClone(r);n.ExternalDisableChannelSecret="",u(e=>
1({...e,ExternalDisableChannelSecret:""})),x(n),p.current&&p.current.setValue("ExternalDisableChannelSecret","")}).catch(()=>{je(i("ä¿å失败ï¼è¯·éè¯"))}).finally(()=>{l(!1)})},children:i("ä¿åæå¡å¨é
ç½®")})})]})})},Cl={[Ft.EMAIL]:"CustomerSupportEmail",[Ft.PHONE]:"CustomerSupportPhone",[Ft.ONLINE_TIME]:"CustomerSupportOnlineTime",[Ft.WEIXIN]:"CustomerSupportWeixinLink",[Ft.WHATSAPP]:"CustomerSupportWhatsApp",[Ft.QRCODE]:"QRCodeUrl"};function wl(e){const t={};for(const[n,i]of Object.entries(Cl))t[n]=e[i]||"";return t}function Tl(e,t){const n=Wt(e.CustomerSupportContactOrder),i=Object.keys(Cl),s=t.map(e=>e.id);return Jt(n||Vt,i,s)}function Il(e){if(!e)return!0;try{const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}}const El=["email","phone","qrcode","link"],Rl=e=>{const{t:i}=ge(),[s,l]=t.useState(!1),[a,r]=t.useState({QRCodeUrl:"",CustomerSupportEmail:"",CustomerSupportPhone:"",CustomerSupportOnlineTime:"",CustomerSupportWeixinLink:"",CustomerSupportWhatsApp:"",CustomerSupportCustomEntries:"[]",CustomerSupportContactOrder:""}),[p,h]=t.useState(a),y=t.useRef(p);y.current=p;const[j,f]=t.useState(!1),[b,_]=t.useState("email"),[S,k]=t.useState(""),[v,C]=t.useState(""),[w,T]=t.useState(""),[I,E]=t.useState(""),[R,P]=t.useState(""),[z,N]=t.useState(""),A=an(e.options?.["translation_setting.enabled"]),M=hs(a.CustomerSupportCustomEntries),O=Tl(a,M);function D(e){r(t=>({...t,CustomerSupportContactOrder:JSON.stringify(e)}))}function L(e){r(t=>({...t,CustomerSupportCustomEntries:JSON.stringify(e)}))}t.useEffect(()=>{r(t=>{const n=y.current,i={...t},s=e.options||{};for(const e in s){if(!Object.prototype.hasOwnProperty.call(t,e))continue;const l=t[e]!==n[e];i[e]=l?t[e]:s[e]}i.CustomerSupportCustomEntries||(i.CustomerSupportCustomEntries="[]"),i.CustomerSupportContactOrder||(i.CustomerSupportContactOrder="");const l=Object.keys(t).some(e=>t[e]!==n[e]);return queueMicrotask(()=>{l||h(structuredClone(i))}),i})},[e.options]);const B=e=>({email:i("èªå®ä¹èç³»åç±»_email"),phone:i("èªå®ä¹èç³»åç±»_phone"),qrcode:i("èªå®ä¹èç³»åç±»_qrcode"),link:i("èªå®ä¹èç³»åç±»_link")}[e]||e);return n.jsxs(m,{spinning:s,children:[n.jsxs(g,{align:"center",style:{marginBottom:12},children:[n.jsx(u.Title,{heading:6,style:{margin:0},children:i("è系客æè®¾ç½®")}),n.jsx(d,{icon:n.jsx(Ye,{size:16}),type:"tertiary",size:"small",onClick:()=>{_("email"),k(""),C(""),T(""),E(""),P(""),N(""),f(!0)},children:i("æ·»å èªå®ä¹èç³»æ¡ç®")})]}),n.jsx(bs,{order:O,builtinValues:wl(a),customEntries:M,onOrderChange:function(e){D(e)},onBuiltinChange:function(e,t){const n=Cl[e];n&&r(e=>({...e,[n]:t}))},onCustomEntriesChange:function(e){L(e);const t=new Set(e.map(e=>e.id));D(Tl(a,M).filter(e=>e.startsWith("builtin:")||t.has(e)))},translationEnabled:A}),A&&n.jsx(o,{style:{marginTop:8},children:n.jsx(c,{children:n.jsx(u.Text,{type:"warning",size:14,children:i("å·²å¼å¯èªå¨ç¿»è¯ï¼ä¿å设置æ¶ç±å端并åç¿»è¯ä¸º 6 ç§è¯è¨ï¼èæ¶åå³äºæ¡ç®æ°ä¸æ¨¡åï¼é常 30 ç§~2 åéï¼")})})}),n.jsx(o,{style:{marginTop:16},children:n.jsx(d,{size:"default",onClick:async function(){const t=M.find(e=>"link"===e.category&&!Il(e.payload?.url||""));if(t)x.error({title:i("æç¤º"),content:i("请è¾å
¥ææçURLå°å")+`ï¼${t.title}ï¼`});else{l(!0);try{const t={...a,CustomerSupportCustomEntries:xs(a.CustomerSupportCustomEntries),CustomerSupportContactOrder:a.CustomerSupportContactOrder||JSON.stringify(O)},n=ke(t,p);if(!n.length)return void ve(i("ä½ ä¼¼ä¹å¹¶æ²¡æä¿®æ¹ä»ä¹"));const s=Se(),l=n.map(e=>{const n="boolean"==typeof t[e.key]?String(t[e.key]):t[e.key];return ye.put(s,{key:e.key,value:n})}),o=await Promise.all(l);if(1===l.length&&o.includes(void 0))return;if(l.length>1&&o.includes(void 0))return void je(i("é¨åä¿å失败ï¼è¯·éè¯"));be(i("ä¿åæå")),r(t),h(structuredClone(t)),e.refresh&&e.refresh()}catch(n){je(n?.message||i("ä¿å失败ï¼è¯·éè¯"))}finally{l(!1)}}},children:i("ä¿å客æè®¾ç½®")})}),n.jsx(x,{title:i("æ·»å èªå®ä¹èç³»æ¡ç®"),visible:j,onOk:function(){const e=S.trim();if(!e)return void x.error({title:i("æç¤º"),content:i("请è¾å
¥å±ç¤ºæ é¢")});let t={};if("email"===b)t={address:v.trim()};else if("phone"===b)t={number:w.trim()};else if("qrcode"===b)t={image_url:I.trim()},R.trim()&&(t.subtitle=R.trim());else if("link"===b){const e=z.trim();if(!Il(e))return void x.error({title:i("æç¤º"),content:i("请è¾å
¥ææçURLå°å")});t={url:e}}const n={id:"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():`ce-${Date.now()}-${Math.random().toString(36).slice(2,11)}`,category:b,title:e,payload:t};L([...M,n]);const s=Tl(a,M);D(Ut(s,n.id)),f(!1),k(""),C(""),T(""),E(""),P(""),N("")},onCancel:()=>f(!1),width:520,children:n.jsxs(g,{vertical:!0,align:"start",style:{width:"100%"},spacing:"loose",children:[n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:i("èç³»æ¡ç®åç±»")}),n.jsx("select",{value:b,onChange:e=>_(e.target.value),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)"},children:El.map(e=>n.jsx("option",{value:e,children:B(e)},e))})]}),n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:i("å±ç¤ºæ é¢")}),n.jsx("input",{value:S,onChange:e=>k(e.target.value),placeholder:i("请è¾å
¥å±ç¤ºæ é¢"),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)",boxSizing:"border-box"}})]}),"email"===b&&n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:i("é®ç®±å°å")}
1),n.jsx("input",{value:v,onChange:e=>C(e.target.value),placeholder:i("请è¾å
¥é®ç®±å°å"),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)",boxSizing:"border-box"}})]}),"phone"===b&&n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:i("çµè¯å·ç ")}),n.jsx("input",{value:w,onChange:e=>T(e.target.value),placeholder:i("请è¾å
¥çµè¯å·ç "),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)",boxSizing:"border-box"}})]}),"qrcode"===b&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:i("å¾çURL")}),n.jsx("input",{value:I,onChange:e=>E(e.target.value),placeholder:i("请è¾å
¥äºç»´ç å¾çURL"),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)",boxSizing:"border-box"}})]}),n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:i("坿æ¡")}),n.jsx("input",{value:R,onChange:e=>P(e.target.value),placeholder:i("å¯é坿æ¡"),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)",boxSizing:"border-box"}})]})]}),"link"===b&&n.jsxs("div",{style:{width:"100%"},children:[n.jsx(u.Text,{strong:!0,style:{display:"block",marginBottom:8},children:i("龿¥å°å")}),n.jsx("input",{value:z,onChange:e=>N(e.target.value),placeholder:i("请è¾å
¥é¾æ¥å°åï¼å¦ https://example.com"),style:{width:"100%",padding:"6px 8px",borderRadius:4,border:"1px solid var(--semi-color-border)",boxSizing:"border-box"}})]})]})})]})},{Text:Pl}=u,{Text:zl}=u,Nl=[{value:"slide-basic",label:"æ»åæ¼å¾"},{value:"rotate",label:"æè½¬éªè¯"},{value:"click-text",label:"æåç¹é"},{value:"click-shape",label:"å¾å½¢ç¹é"}];function Al(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,d]=t.useState({CaptchaLoginEnabled:!1,CaptchaCheckinEnabled:!1,CaptchaSendCodeEnabled:!1,CaptchaType:"slide-basic"}),u=t.useRef(),p=async(e,t)=>{try{const n=Se(),s=await ye.put(n,{key:e,value:t}),{success:l,message:a}=s.data;return l?(be(i("ä¿åæå")),d(n=>({...n,[e]:t})),!0):(je(a),!1)}catch(n){return je(i("ä¿å失败")+": "+n.message),!1}};return t.useEffect(()=>{(async()=>{l(!0);try{const e=Se(),t=await ye.get(e),{success:n,message:i,data:s}=t.data;if(n){let e={};s.forEach(t=>{"CaptchaLoginEnabled"===t.key||"CaptchaCheckinEnabled"===t.key||"CaptchaSendCodeEnabled"===t.key?e[t.key]="true"===t.value:"CaptchaType"===t.key&&(e[t.key]=t.value||"slide-basic")});const t={...r,...e};d(t),u.current&&u.current.setValues(t)}else je(i)}catch(e){je(i("å 载失败")+": "+e.message)}l(!1)})().then()},[]),n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>u.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("ç»å½å®å
¨è®¾ç½®"),children:[n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(a.Label,{children:i("éªè¯ç ç±»å")}),n.jsx(L,{value:r.CaptchaType,onChange:async t=>{const n=t.target.value;await p("CaptchaType",n)&&e.refresh&&e.refresh()},style:{marginTop:"8px",marginBottom:"4px"},children:Nl.map(e=>n.jsx(B,{value:e.value,children:i(e.label)},e.value))}),n.jsx(zl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px",marginBottom:"20px"},children:i("éæ©å端å±ç¤ºçéªè¯ç äº¤äºæ¹å¼ï¼ä¿®æ¹å峿¶çæ")})]})}),n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"CaptchaLoginEnabled",label:i("å¯ç¨æ»åéªè¯ç ç»å½"),checkedText:i("å¼"),uncheckedText:i("å
³"),onChange:async t=>{await p("CaptchaLoginEnabled",String(t))&&e.refresh&&e.refresh()}}),n.jsx(zl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¼å¯åï¼ææç»å½æ¹å¼ï¼å¯ç ç»å½ãOAuthãTelegramçï¼é½éè¦å
宿æ»åéªè¯ç éªè¯")}),n.jsx(zl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð¡ éªè¯ç æ°æ®åå¨å¨MySQLæ°æ®åºä¸ï¼èªå¨è¿ææ¸
ç")})]})}),n.jsx(o,{style:{marginTop:"20px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"CaptchaCheckinEnabled",label:i("å¯ç¨æ»åéªè¯ç ç¾å°"),checkedText:i("å¼"),uncheckedText:i("å
³"),onChange:async t=>{await p("CaptchaCheckinEnabled",String(t))&&e.refresh&&e.refresh()}}),n.jsx(zl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¼å¯åï¼ç¨æ·ç¾å°æ¶éè¦å
宿æ»åéªè¯ç éªè¯ï¼ææé²æ¢æ¹éç¾å°")}),n.jsx(zl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð¡ 建议å¨åç°æ¶ææ¹éç¾å°è¡ä¸ºæ¶å¯ç¨æ¤åè½")})]})}),n.jsx(o,{style:{marginTop:"20px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"CaptchaSendCodeEnabled",label:i("å¯ç¨æ»åéªè¯ç åéé®ä»¶"),checkedText:i("å¼"),uncheckedText:i("å
³"),onChange:async t=>{await p("CaptchaSendCodeEnabled",String(t))&&e.refresh&&e.refresh()}}),n.jsx(zl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¼å¯åï¼åéé®ç®±éªè¯ç ï¼æ³¨å/æ¾åå¯ç çï¼éè¦å
宿æ»åéªè¯ç éªè¯ï¼ææé²æ¢å·é®ä»¶")}),n.jsx(zl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð¡ æ¯æ¬¡ç¹å»åéåééæ°æ»å¨ï¼token 䏿¬¡æ§ä½¿ç¨")})]})})]})})})}const{Text:Ml}=u;function Ol(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState(!1),[p,h]=t.useState(null),[x,g]=t.useState(null),[y,j]=t.useState("smart"),[f,S]=t.useState({ChannelModelRedirect:"",GlobalModelMapping:""}),k=t.useRef(),v=t.useRef(null),C=t.useRef(null),w=async(e,t)=>{try{const n=Se(),s=await ye.put(n,{key:e,value:t}),{success:l,message:a}=s.data;return l?(be(i("ä¿åæå")),S(n=>({...n,[e]:t}
1)),!0):(je(a),!1)}catch(n){return je(i("ä¿å失败")+": "+n.message),!1}};return t.useEffect(()=>((async()=>{l(!0);try{const e=Se(),t=await ye.get(e),{success:n,message:i,data:s}=t.data;if(n){let e={};s.forEach(t=>{"ChannelModelRedirect"!==t.key&&"GlobalModelMapping"!==t.key||(e[t.key]=t.value||"")});const t={...f,...e};S(t),k.current&&k.current.setValues(t)}else je(i)}catch(e){je(i("å 载失败")+": "+e.message)}l(!1)})().then(),()=>{v.current&&(clearTimeout(v.current),v.current=null),C.current&&(clearTimeout(C.current),C.current=null)}),[]),n.jsx(m,{spinning:s,children:n.jsxs(a,{values:f,getFormApi:e=>k.current=e,style:{marginBottom:15},children:[n.jsx(a.Section,{text:i("å
¨å±æ¨¡åéå®å"),children:n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(a.TextArea,{field:"GlobalModelMapping",label:i("å
¨å±æ¨¡åéå®åé
ç½®ï¼JSON 对象ï¼"),placeholder:'{\n "gpt-4": "gpt-4o",\n "gpt-3.5-turbo": "gpt-4o-mini",\n "claude-3-opus": "claude-sonnet-4-20250514"\n}',autosize:{minRows:6,maxRows:15},onChange:async e=>{S(t=>({...t,GlobalModelMapping:e}))}}),n.jsx(Ml,{type:"warning",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("â ï¸ ä¼å
级æé«ï¼å
¨å±éå®åä¼å¨æ¸ é级å«éå®åä¹åçæï¼å½ä¸åä¸åèµ°æ¸ éç model_mapping")}),n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð æ ¼å¼ï¼JSON 对象ï¼é®ä¸ºç¨æ·è¯·æ±ç模ååï¼å¼ä¸ºå®é
转åçæ¨¡åå")}),n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð¡ éç¨åºæ¯ï¼ç»ä¸å°æä¸ªæ¨¡ååéå®åå°æ°çæ¬ï¼æ ééä¸ªæ¸ éé
ç½®")}),n.jsx("div",{style:{marginTop:"16px"},children:n.jsx(d,{type:"primary",onClick:async()=>{if(f.GlobalModelMapping)try{JSON.parse(f.GlobalModelMapping)}catch(t){return void je(i("JSON æ ¼å¼ä¸æ£ç¡®ï¼è¯·æ£æ¥é
ç½®"))}await w("GlobalModelMapping",f.GlobalModelMapping)&&e.refresh&&e.refresh()},children:i("ä¿åå
¨å±éå®åé
ç½®")})})]})})}),n.jsx(a.Section,{text:i("æ¸ éæ¨¡åéå®å"),children:n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(a.TextArea,{field:"ChannelModelRedirect",label:i("模åéå®åé
ç½®ï¼å¤ç»´å符串æ°ç»ï¼"),placeholder:'[\n ["deepseek-chat", "deepseek-v3", "deepseek-v3-250324"],\n ["deepseek-r1", "deepseek-reasoner", "deepseek-r1-250120"],\n ["gpt-4", "gpt-4-turbo", "gpt-4-0613"]\n]',autosize:{minRows:6,maxRows:15},onChange:async e=>{S(t=>({...t,ChannelModelRedirect:e}))}}),n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("ð¡ 说æï¼æ¯ä¸ªåæ°ç»æ¯ä¸ä¸ªç价模åç»ï¼ç»å
çæ¨¡åå¯ä»¥äºç¸éå®å")}),n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i('ð æ ¼å¼ï¼[["model1","model2"],["model3","model4"]]ï¼æ¯æå¤è¡ä¹¦å')}),n.jsx("div",{style:{marginTop:"16px"},children:n.jsx(d,{type:"primary",onClick:async()=>{await w("ChannelModelRedirect",f.ChannelModelRedirect)&&e.refresh&&e.refresh()},children:i("ä¿åé
ç½®")})})]})})}),n.jsx(a.Section,{text:i("æ¸ éæ¨¡åèªå¨æ£æµä¸æ´æ°"),children:n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsxs("div",{style:{marginBottom:"16px"},children:[n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px",display:"block",marginBottom:"12px"},children:i("ð èªå¨æ£æµææå¯ç¨æ¸ 鿝æç模ååä½ï¼å¹¶æ´æ°æ¨¡ååè¡¨åæ¨¡åæ å°")}),n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px",display:"block",marginBottom:"8px"},children:i("â
åè½è¯´æï¼")}),n.jsxs("ul",{style:{fontSize:"12px",color:"#666",marginLeft:"20px",marginBottom:"12px"},children:[n.jsx("li",{children:i("èªå¨æ£æµæ¸ 鿝æç模ååä½ï¼å¦ deepseek-chatãdeepseek-v3 çï¼")}),n.jsx("li",{children:i("æ ¹æ®æ£æµç»ææ´æ°æ¸ éçæ¨¡åå表")}),n.jsx("li",{children:i("èªå¨çææ¨¡åæ å°å
³ç³»ï¼ä¸æ¯æçåä½ â æ¯æçåä½ï¼")}),n.jsx("li",{children:i("æ¯æå¹¶åå¤çï¼é»è®¤5个并åï¼æå¤§20个")}),n.jsx("li",{children:i("éç¨å¼æ¥ä»»å¡æ¨¡å¼ï¼å¯å®æ¶æ¥çå¤çè¿åº¦")})]})]}
1),n.jsxs("div",{style:{marginBottom:"16px",padding:"12px",background:"#f6f8fa",borderRadius:"6px",border:"1px solid #e1e4e8"},children:[n.jsxs(Ml,{strong:!0,style:{display:"block",marginBottom:"8px",fontSize:"13px"},children:["ð¯ ",i("éæ©æ£æµæ¨¡å¼")]}),n.jsxs(L,{type:"button",value:y,onChange:e=>j(e.target.value),disabled:r,children:[n.jsx(B,{value:"smart",children:n.jsxs("div",{style:{padding:"4px 0"},children:[n.jsxs(Ml,{strong:!0,children:["ð ",i("æºè½æ¨¡å¼")]}),n.jsx(Ml,{type:"tertiary",style:{display:"block",fontSize:"11px",marginTop:"2px"},children:i("æ¾å°ç¬¬ä¸ä¸ªæ¯æç模åå³åæ¢ï¼èç50-66%èµæºï¼æ¨èï¼")})]})}),n.jsx(B,{value:"fast",children:n.jsxs("div",{style:{padding:"4px 0"},children:[n.jsxs(Ml,{strong:!0,children:["â¡ ",i("å¿«éæ¨¡å¼")]}),n.jsx(Ml,{type:"tertiary",style:{display:"block",fontSize:"11px",marginTop:"2px"},children:i("ä¸å®é
æµè¯ï¼ç´æ¥åºç¨è§åï¼æå¿«ä½å¯è½ä¸åç¡®")})]})}),n.jsx(B,{value:"full",children:n.jsxs("div",{style:{padding:"4px 0"},children:[n.jsxs(Ml,{strong:!0,children:["ð ",i("宿´æ¨¡å¼")]}),n.jsx(Ml,{type:"tertiary",style:{display:"block",fontSize:"11px",marginTop:"2px"},children:i("æµè¯ææåä½ï¼æç²¾ç¡®ä½èæ¶é¿ãæ¶èé
é¢å¤")})]})})]})]}),n.jsx(d,{type:"primary",loading:r,onClick:async()=>{try{v.current&&(clearTimeout(v.current),v.current=null),C.current&&(clearTimeout(C.current),C.current=null),u(!0),h(null),g(null);const e=await ye.post(`/api/channel/detect_and_update_all?async=true&concurrency=5&delay_ms=100&mode=${y}`),{success:t,message:n,data:s}=e.data;if(!t)return je(n||i("å¯å¨æ´æ°ä»»å¡å¤±è´¥")),void u(!1);const l=s?.task_id;if(!l)return je(i("æªè·åå°ä»»å¡ID")),void u(!1);be(i("æ¹éæ´æ°ä»»å¡å·²å¯å¨ï¼æ£å¨åå°å¤ç..."));const a=async()=>{try{const e=await ye.get(`/api/channel/detect_and_update_all/progress/${l}`),{success:t,data:n}=e.data;if(!t)return u(!1),void h(null);const{is_completed:s,processed:r,total:o,success_count:c,fail_count:d,skip_count:p}=n;if(h({processed:r,total:o,success_count:c,fail_count:d,skip_count:p,percentage:o>0?Math.round(r/o*100):0}),s)return u(!1),g({total:o,processed:r,success_count:c,fail_count:d,skip_count:p,results:n.results||[],start_time:n.start_time,end_time:n.end_time,duration:n.end_time-n.start_time}),void be(i(`ð èªå¨æ´æ°å®æï¼æ»è®¡: ${o}, æå: ${c}, 失败: ${d}, è·³è¿: ${p}`));v.current=setTimeout(a,2e3)}catch(e){console.error("æ¥è¯¢è¿åº¦å¤±è´¥:",e),u(!1),h(null),je(i("æ¥è¯¢è¿åº¦å¤±è´¥")+": "+(e.message||e))}};v.current=setTimeout(a,2e3)}catch(e){u(!1),h(null),je(i("èªå¨æ´æ°å¤±è´¥")+": "+(e.message||e))}},style:{marginBottom:"16px"},children:i(r?"æ£å¨æ£æµæ´æ°ä¸...":"ð èªå¨æ´æ°æææ¸ 鿍¡å")}),p&&n.jsxs("div",{style:{marginTop:"16px",marginBottom:"16px"},children:[n.jsx(re,{percent:p.percentage,showInfo:!0,stroke:100===p.percentage?"#52c41a":"#1890ff"}),n.jsx("div",{style:{marginTop:"8px",fontSize:"13px",color:"#666"},children:n.jsxs(Ml,{type:"secondary",children:[i("å·²å¤ç"),": ",p.processed,"/",p.total," |",n.jsxs("span",{style:{color:"#52c41a",marginLeft:"8px"},children:[i("æå"),": ",p.success_count]})," |",n.jsxs("span",{style:{color:"#f5222d",marginLeft:"8px"},children:[i("失败"),": ",p.fail_count]})," |",n.jsxs("span",{style:{color:"#faad14",marginLeft:"8px"},children:[i("è·³è¿"),": ",p.skip_count]})]})})]}),x&&n.jsxs("div",{style:{marginTop:"20px",padding:"20px",background:"#f6f8fa",borderRadius:"8px",border:"1px solid #e1e4e8"},children:[n.jsx("div",{style:{marginBottom:"16px"},children:n.jsxs(Ml,{strong:!0,style:{fontSize:"15px",color:"#24292e"},children:["ð ",i("æ§è¡ç»ææè¦")]})}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"12px",marginBottom:"16px"},children:[n.jsxs("div",{style:{padding:"12px",background:"#fff",borderRadius:"6px",border:"1px solid #e1e4e8"},children:[n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px",display:"block"},children:i("æ»æ¸ éæ°")}),n.jsx(Ml,{strong:!0,style:{fontSize:"20px",color:"#0969da"},children:x.total})]}),n.jsxs("div",{style:{padding:"12px",background:"#fff",borderRadius:"6px",border:"1px solid #e1e4e8"},children:[n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px",display:"block"},children:i("æåæ´æ°")}),n.jsx(Ml,{strong:!0,style:{fontSize:"20px",color:"#1a7f37"},children:x.success_count})]}),n.jsxs("div",{style:{padding:"12px",background:"#fff",borderRadius:"6px",border:"1px solid #e1e4e8"},children:[n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px",display:"block"},children:i("æ´æ°å¤±è´¥")}),n.jsx(Ml,{strong:!0,style:{fontSize:"20px",color:"#cf222e"},children:x.fail_count})]}),n.jsxs("div",{style:{padding:"12px",background:"#fff",borderRadius:"6px",border:"1px solid #e1e4e8"},children:[n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px",display:"block"},children:i("è·³è¿å¤ç")}),n.jsx(Ml,{strong:!0,style:{fontSize:"20px",color:"#bf8700"},children:x.skip_count})]}),n.jsxs("div",{style:{padding:"12px",background:"#fff",borderRadius:"6px",border:"1px solid #e1e4e8"},children:[n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px",display:"block"},children:i("æ§è¡èæ¶")}),n.jsx(Ml,{strong:!0,style:{fontSize:"20px",color:"#6e7781"},children:x.duration?`${x.duration}${i("ç§")}`:"-"})]})]}),x.results&&x.results.length>0&&n.jsxs("div",{style:{marginTop:"16px"},children:[n.jsxs(Ml,{strong:!0,style:{fontSize:"14px",display:"block",marginBottom:"12px"},children:["ð ",i("详ç»ç»æ")]}),n.jsxs(b,{type:"line",style:{background:"#fff",borderRadius:"6px",border:"1px solid #e1e4e8",padding:"8px"},children:[n.jsx(_,{tab:n.jsxs("span",{children:[i("å
¨é¨")," ",n.jsx(oe,{count:x.results.length,type:"primary"})]}),itemKey:"all",children:n.jsx("div",{style:{maxHeight:"300px",overflowY:"auto"},children:x.results.map((e,t)=>n.jsx("div",{style:{padding:"10px 14px",borderBottom:t<x.results.length-1?"1px solid #e1e4e8":"none",fontSize:"13px"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[1===e.status&&n.jsx("span",{style:{color:"#1a7f37",fontSize:"16px"},children:"â"}),2===e.status&&n.jsx("span",{style:{color:"#cf222e",fontSize:"16px"},children:"â"}),3===e.status&&n.jsx("span",{style:{color:"#bf8700",fontSize:"16px"},children:"â"}),0===e.status&&n.jsx("span",{style:{color:"#6e7781",fontSize:"16px"},children:"-"}),n.jsxs(Ml,{strong:!0,style:{color:"#24292e"},children:["#",e.channel_id," ",e.channel_name]}),n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px"},children:e.message})]})},t))})}),n.jsx(_,{tab:n.jsxs("span",{style:{color:"#1a7f37"},children:[i("æåæ´æ°")," ",n.jsx(oe,{count:x.success_count,style:{backgroundColor:"#1a7f37"}})]}),itemKey:"success",children:n.jsxs("div",{style:{maxHeight:"300px",overflowY:"auto"},children:[x.results.filter(e=>1===e.status).map((e,t,i)=>n.jsx("div",{style:{padding:"10px 14px",borderBottom:t<i.length-1?"1px solid #e1e4e8":"none",fontSize:"13px",background:t%2==0?"#f6fff8":"#fff"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{style:{color:"#1a7f37",fontSize:"16px"},children:"â"}),n.jsxs(Ml,{strong:!0,style:{color:"#24292e"},children:["#",e.channel_id," ",e.channel_name]}),n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px"},children:e.message})]})},t)),0===x.results.filter(e=>1===e.status).length&&n.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6e7781"},children:i("ææ æåæ´æ°çæ¸ é")})]})}),n.jsx(_,{tab:n.jsxs("span",{style:{color:"#cf222e"},children:[i("æ´æ°å¤±è´¥")," ",n.jsx(oe,{count:x.fail_count,style:{backgroundColor:"#cf222e"}})]}),itemKey:"fail",children:n.jsxs("div",{style:{maxHeight:"300px",overflowY:"auto"},children:[x.results.filter(e=>2===e.status).map((e,t,i)=>n.jsx("div",{style:{padding:"10px 14px",borderBottom:t<i.length-1?"1px solid #e1e4e8":"none",fontSize:"13px",background:t%2==0?"#fff5f5":"#fff"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{style:{color:"#cf222e",fontSize:"16px"},children:"â"}),n.jsxs(Ml,{strong:!0,style:{color:"#24292e"},children:["#",e.channel_id," ",e.channel_name]}),n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px",color:"#cf222e"},children:e.message})]})},t)),0===x.results.filter(e=>2===e.status).length&&n.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6e7781"},children:i("ææ å¤±è´¥çæ¸ é")})]})}),n.jsx(_,{tab:n.jsxs("span",{style:{color:"#bf8700"},children:[i("è·³è¿å¤ç")," ",n.jsx(oe,{count:x.skip_count,style:{backgroundColor:"#bf8700"}})]}),itemKey:"skip",children:n.jsxs("div",{style:{maxHeight:"300px",overflowY:"auto"},children:[x.results.filter(e=>3===e.status||0===e.status).map((e,t,i)=>n.jsx("div",{style:{padding:"10px 14px",borderBottom:t<i.length-1?"1px solid #e1e4e8":"none",fontSize:"13px",background:t%2==0?"#fffbf0":"#fff"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[3===e.status&&n.jsx("span",{style:{color:"#bf8700",fontSize:"16px"},children:"â"}),0===e.status&&n.jsx("span",{style:{color:"#6e7781",fontSize:"16px"},children:"-"}),n.jsxs(Ml,{strong:!0,style:{color:"#24292e"},children:["#",e.channel_id," ",e.channel_name]}),n.jsx(Ml,{type:"tertiary",style:{fontSize:"12px"},children:e.message})]})},t)),0===x.results.filter(e=>3===e.status||0===e.status).length&&n.jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6e7781"},children:i("ææ è·³è¿çæ¸ é")})]})})]})]}),n.jsx("div",{style:{marginTop:"16px",textAlign:"right"},children:n.jsx(d,{size:"small",onClick:()=>{g(null),h(null)},children:i("å
³éç»æ")})})]})]})})})]})})}const{Text:Dl}=u;function Ll(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({"aliyun_setting.access_key_id":"","aliyun_setting.access_key_secret":"","aliyun_setting.personal_auth_code":"","aliyun_setting.enterprise_auth_code":""}),p=t.useRef(),h=async(e,t)=>{try{const n=Se(),s=await ye.put(n,{key:e,value:t}),{success:l,message:a}=s.data;return l?(be(i("ä¿åæå")),u(n=>({...n,[e]:t}
1)),!0):(je(a),!1)}catch(n){return je(i("ä¿å失败")+": "+n.message),!1}};return t.useEffect(()=>{(async()=>{l(!0);try{const e=Se(),t=await ye.get(e),{success:n,message:i,data:s}=t.data;if(n){let e={};s.forEach(t=>{"aliyun_setting.access_key_id"!==t.key&&"aliyun_setting.access_key_secret"!==t.key&&"aliyun_setting.personal_auth_code"!==t.key&&"aliyun_setting.enterprise_auth_code"!==t.key||(e[t.key]=t.value||"")});const t={...r,...e};u(t),p.current&&p.current.setValues(t)}else je(i)}catch(e){je(i("å 载失败")+": "+e.message)}l(!1)})().then()},[]),n.jsx(m,{spinning:s,children:n.jsx(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},children:n.jsxs(a.Section,{text:i("é¿éäºå®åéªè¯é
ç½®"),children:[n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"aliyun_setting.access_key_id",label:i("é¿éäº AccessKeyId"),placeholder:i("请è¾å
¥é¿éäºAccessKeyId"),autoComplete:"off",onChange:async e=>{u(t=>({...t,"aliyun_setting.access_key_id":e}))}}),n.jsx(Dl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¨é¿éäºæ§å¶å°è·åAccessKey")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"aliyun_setting.access_key_secret",label:i("é¿éäº AccessKeySecret"),placeholder:i("请è¾å
¥é¿éäºAccessKeySecret"),mode:"password",autoComplete:"new-password",onChange:async e=>{u(t=>({...t,"aliyun_setting.access_key_secret":e}))}}),n.jsx(Dl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("AccessKeySecretå°å å¯åå¨")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"aliyun_setting.personal_auth_code",label:i("个人äºè¦ç´ éªè¯ææç "),placeholder:i("请è¾å
¥ä¸ªäººäºè¦ç´ éªè¯ææç "),autoComplete:"off",onChange:async e=>{u(t=>({...t,"aliyun_setting.personal_auth_code":e}))}}),n.jsx(Dl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("ç¨äºä¸ªäººå®åéªè¯ï¼éªè¯å§å + 身份è¯å·ï¼")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"aliyun_setting.enterprise_auth_code",label:i("ä¼ä¸ä¸è¦ç´ éªè¯ææç "),placeholder:i("请è¾å
¥ä¼ä¸ä¸è¦ç´ éªè¯ææç "),autoComplete:"off",onChange:async e=>{u(t=>({...t,"aliyun_setting.enterprise_auth_code":e}))}}),n.jsx(Dl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("ç¨äºä¼ä¸å®åéªè¯ï¼éªè¯ä¼ä¸åç§° + æ³äººå§å + ç»ä¸ç¤¾ä¼ä¿¡ç¨ä»£ç ï¼")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsx(c,{span:24,children:n.jsx(d,{type:"primary",onClick:async()=>{const t=await h("aliyun_setting.access_key_id",r["aliyun_setting.access_key_id"]),n=await h("aliyun_setting.access_key_secret",r["aliyun_setting.access_key_secret"]),i=await h("aliyun_setting.personal_auth_code",r["aliyun_setting.personal_auth_code"]),s=await h("aliyun_setting.enterprise_auth_code",r["aliyun_setting.enterprise_auth_code"]);t&&n&&i&&s&&e.refresh&&e.refresh()},children:i("ä¿åé¿éäºé
ç½®")})})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(Dl,{type:"tertiary",style:{fontSize:"12px"},children:i("â ï¸ æ³¨æäºé¡¹ï¼")}),n.jsxs("ul",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",marginTop:"8px"},children:[n.jsx("li",{children:i("个人äºè¦ç´ éªè¯ï¼éªè¯å§å + 身份è¯å·")}),n.jsx("li",{children:i("ä¼ä¸ä¸è¦ç´ éªè¯ï¼éªè¯ä¼ä¸åç§° + æ³äººå§å + ç»ä¸ç¤¾ä¼ä¿¡ç¨ä»£ç ")}),n.jsx("li",{children:i("æ¯ä¸ªç¨æ·æ¯å¤©æ3次éªè¯æºä¼ï¼ä¸ªäººåä¼ä¸åå«è®¡ç®ï¼")}),n.jsx("li",{children:i("éè¦å¨é¿éäºæ§å¶å°è·åAccessKeyåææç ")}),n.jsx("li",{children:i("ææç éå¨é¿éäºå·ç è®¤è¯æå¡ä¸è´ä¹°")})]})]})})]})})})}const{Text:Bl}=u;function Fl(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState([]),[h,x]=t.useState(""),g=t.useRef(),y=()=>{if(h&&""!==h.trim()){const e=h.trim();if(r.includes(e))return void je(i("该模åå·²åå¨äºç½ååä¸"));u([...r,e]),x(""),be(i("已添å å°ç½åå"))}};return t.useEffect(()=>{(async()=>
1{l(!0);try{const e=Se(),t=await ye.get(e),{success:n,message:i,data:s}=t.data;n?s.forEach(e=>{"ModelIgnoreThinkWhitelist"===e.key&&e.value&&u(e.value.split(",").filter(e=>""!==e.trim()))}):je(i)}catch(e){je(i("å 载失败")+": "+e.message)}l(!1)})().then()},[]),n.jsx(m,{spinning:s,children:n.jsx(a,{getFormApi:e=>g.current=e,style:{marginBottom:15},children:n.jsx(a.Section,{text:i("模å忽ç¥Thinkå¤çç½åå"),children:n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(Bl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginBottom:"16px"},children:i("é
置该ç½åååï¼ç½ååä¸ç模åå°è·³è¿ææthinkç¸å
³çåç¼å¤çï¼å¦ -thinking-æ°åï¼")}),n.jsx(Bl,{strong:!0,style:{display:"block",marginBottom:"8px"},children:i("已添å çç½åå项")}),n.jsx(p,{value:r,onChange:u,placeholder:i("è¾å
¥æ¨¡ååç§°åå车"),style:{width:"100%",marginBottom:"16px"}}),n.jsx(a.Input,{placeholder:i("è¾å
¥è¦æ·»å çæ¨¡ååç§°ï¼å¦ï¼qwen3-vl-32b-thinkingï¼"),value:h,onChange:e=>x(e),style:{marginBottom:"16px"},suffix:n.jsx(d,{theme:"solid",type:"primary",onClick:y,children:i("æ·»å ")}),onEnterPress:y}),n.jsx(d,{type:"primary",onClick:async()=>{Array.isArray(r)?await(async(e,t)=>{try{const e=Se(),n=await ye.put(e,{key:"ModelIgnoreThinkWhitelist",value:t}),{success:s,message:l}=n.data;return s?(be(i("ä¿åæå")),!0):(je(l),!1)}catch(n){return je(i("ä¿å失败")+": "+n.message),!1}})(0,r.join(","))&&e.refresh&&e.refresh():je(i("模åç½ååæ ¼å¼ä¸æ£ç¡®"))},children:i("ä¿å模åç½åå设置")})]})})})})})}const{Text:Wl}=u;function Jl(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState({SyncMainEnabled:!1,SyncToken:"",SyncSourceURL:"",SyncAccountId:"",SyncInterval:"600",SyncWhitelistUserIds:"",SyncRatioEnabled:!1,SyncSquareEnabled:!1,SyncGroupEnabled:!1,SyncChannelEnabled:!1}),p=t.useRef(),[h,x]=t.useState(r),g=async(e,t)=>{try{const n=Se(),s=await ye.put(n,{key:e,value:t}),{success:l,message:a}=s.data;return l?(be(i("ä¿åæå")),u(n=>({...n,[e]:t})),x(n=>({...n,[e]:t})),!0):(je(a),!1)}catch(n){return je(i("ä¿å失败")+": "+n.message),!1}};return t.useEffect(()=>{const t={};for(let n in e.options)Object.keys(r).includes(n)&&(t[n]=e.options[n]||"");Object.keys(t).length>0&&(u(t),x(structuredClone(t)),p.current?.setValues(t))},[e.options]),n.jsx(m,{spinning:s,children:n.jsxs(a,{values:r,getFormApi:e=>p.current=e,style:{marginBottom:15},autoComplete:"off",children:[n.jsxs(a.Section,{text:i("忥åè½æ»æ§å¶"),children:[n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"SyncMainEnabled",label:i("å¯ç¨åæ¥åè½æ»å¼å
³"),checkedText:i("å¼"),uncheckedText:i("å
³"),onChange:async t=>{await g("SyncMainEnabled",String(t))&&e.refresh&&e.refresh()}}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¼å¯åï¼å°å¯ç¨ææåæ¥åè½ï¼å
³é忿忥åè½åä¸çæ")}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð¡ è¿æ¯ææåæ¥åè½ç主å¼å
³ï¼å
¶ä»åæ¥å¼å
³éè¦æ¤å¼å
³å¼å¯æè½çæ")})]})}),n.jsx(o,{style:{marginTop:"20px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"SyncToken",label:i("忥 Token"),mode:"password",placeholder:i("请è¾å
¥åæ¥ Token"),autoComplete:"new-password",onChange:e=>{u(t=>({...t,SyncToken:e}))},style:{width:"100%"}}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("ç¨äºéªè¯åæ¥åè½ç身份åè¯ï¼ä¿ååå端å°å å¯åå¨")}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð Token å°ä»¥å 坿¹å¼åå¨ï¼è¯·å¦¥åä¿ç®¡")}),n.jsx("div",{style:{marginTop:"12px"},children:n.jsx(d,{type:"primary",onClick:async()=>{r.SyncToken&&""!==r.SyncToken.trim()?await g("SyncToken",r.SyncToken)&&e.refresh&&e.refresh():je(i("Token ä¸è½ä¸ºç©º"))},children:i("ä¿å Token")})})]})}),n.jsx(o,{style:{marginTop:"20px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"SyncSourceURL",label:i("忥æºURL"),placeholder:i("请è¾å
¥åæ¥æºURLï¼ä¾å¦ï¼https://source.yunwu.ai"),onChange:e=>{u(t=>({...t,SyncSourceURL:e}))},style:{width:"100%"}}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("æºç³»ç»çAPIå°åï¼ç¨äºè·ååæ¥æ°æ®")}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð¡ 示ä¾ï¼https://source.yunwu.aiï¼ä¸è¦å¨æ«å°¾æ·»å ææ ï¼")}),n.jsx("div",{style:{marginTop:"12px"},children:n.jsx(d,{type:"primary",onClick:async()=>{r.SyncSourceURL&&""!==r.SyncSourceURL.trim()?await g("SyncSourceURL",r.SyncSourceURL)&&e.refresh&&e.refresh():je(i("忥æºURLä¸è½ä¸ºç©º"))},children:i("ä¿åURL")})})]})}),n.jsx(o,{style:{marginTop:"20px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"SyncAccountId",label:i("è´¦æ·ID"),placeholder:i("请è¾å
¥è´¦æ·Id"),onChange:e=>{u(t=>({...t,SyncAccountId:e}))},style:{width:"100%"}}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("ç¨äºæ è¯åæ¥è´¦æ·çå¯ä¸ID")}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð¡ å¯éåæ°ï¼å¦ææºç³»ç»éè¦è´¦æ·IDæè½åæ¥æ°æ®ï¼è¯·å¡«åæ¤é¡¹")}),n.jsx("div",{style:{marginTop:"12px"},children:n.jsx(d,{type:"primary",onClick:async()=>{await g("SyncAccountId",r.SyncAccountId||"")&&e.refresh&&e.refresh()},children:i("ä¿åè´¦æ·Id")})})]})}),n.jsx(o,{style:{marginTop:"20px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.InputNumber,{field:"SyncInterval",label:i("忥é´éï¼ç§ï¼"),placeholder:i("请è¾å
¥åæ¥é´é"),min:60,max:86400,step:60,onChange:e=>{u(t=>({...t,SyncInterval:String(e)}))},style:{width:"100%"}}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("èªå¨åæ¥çæ¶é´é´éï¼åä½ä¸ºç§ï¼æå°60ç§ï¼æå¤§86400ç§/24å°æ¶ï¼")}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð¡ æ¨è设置ï¼600ç§ï¼10åéï¼ï¼é»è®¤å¼ï¼600ç§")}),n.jsx("div",{style:{marginTop:"12px"},children:n.jsx(d,{type:"primary",onClick:async()=>{const t=parseInt(r.SyncInterval);isNaN(t)||t<60?je(i("忥é´éä¸è½å°äº60ç§")):await g("SyncInterval",String(t))&&e.refresh&&e.refresh()},children:i("ä¿åé´é")})})]})}),n.jsx(o,{style:{marginTop:"20px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.TextArea,{field:"SyncWhitelistUserIds",label:i("忥åè½ç½ååç¨æ·ID"),placeholder:i("ä¸è¡ä¸ä¸ªç¨æ·ID"),onChange:e=>{u(t=>({...t,SyncWhitelistUserIds:e}))},style:{fontFamily:"JetBrains Mono, Consolas"},autosize:{minRows:4,maxRows:12}}
1),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("åªæç½ååä¸çç¨æ·æè½éè¿åæ¥æ¥å£è·åæ°æ®ï¼ä¸è¡ä¸ä¸ªç¨æ·ID")}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("æ¤é
ç½®å¨æºç«è®¾ç½®ï¼ç¨äºæ§å¶åªäºç¨æ·ç Access Token å¯ä»¥è°ç¨åæ¥æ¥å£")}),n.jsx("div",{style:{marginTop:"12px"},children:n.jsx(d,{type:"primary",onClick:async()=>{await g("SyncWhitelistUserIds",r.SyncWhitelistUserIds||"")&&e.refresh&&e.refresh()},children:i("ä¿åç½åå")})})]})})]}),n.jsx(a.Section,{text:i("åç忥"),children:n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"SyncRatioEnabled",label:i("å¯ç¨åç忥å¼å
³"),checkedText:i("å¼"),uncheckedText:i("å
³"),onChange:async t=>{await g("SyncRatioEnabled",String(t))&&e.refresh&&e.refresh()}}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¼å¯åï¼å°åæ¥åçç¸å
³çé
ç½®åæ°æ®")}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð¡ éè¦åæ¥åè½æ»å¼å
³å¼å¯")})]})})}),n.jsx(a.Section,{text:i("广åºåæ¥"),children:n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"SyncSquareEnabled",label:i("å¯ç¨å¹¿åºåæ¥å¼å
³"),checkedText:i("å¼"),uncheckedText:i("å
³"),onChange:async t=>{await g("SyncSquareEnabled",String(t))&&e.refresh&&e.refresh()}}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¼å¯åï¼å°åæ¥å¹¿åºç¸å
³çé
ç½®åæ°æ®")}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð¡ éè¦åæ¥åè½æ»å¼å
³å¼å¯")})]})})}),n.jsx(a.Section,{text:i("åç»åæ¥"),children:n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"SyncGroupEnabled",label:i("å¯ç¨åç»åæ¥å¼å
³"),checkedText:i("å¼"),uncheckedText:i("å
³"),onChange:async t=>{await g("SyncGroupEnabled",String(t))&&e.refresh&&e.refresh()}}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¼å¯åï¼å°åæ¥åç»ç¸å
³çé
ç½®åæ°æ®")}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð¡ éè¦åæ¥åè½æ»å¼å
³å¼å¯")})]})})}),n.jsx(a.Section,{text:i("æ¸ é忥"),children:n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"SyncChannelEnabled",label:i("å¯ç¨æ¸ é忥å¼å
³"),checkedText:i("å¼"),uncheckedText:i("å
³"),onChange:async t=>{await g("SyncChannelEnabled",String(t))&&e.refresh&&e.refresh()}}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¼å¯åï¼å°åæ¥æ¸ éç¸å
³çé
ç½®åæ°æ®")}),n.jsx(Wl,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"4px"},children:i("ð¡ éè¦åæ¥åè½æ»å¼å
³å¼å¯")})]})})})]})})}const{Text:Ul}=u,Vl=["api_storage_setting.enabled","api_storage_setting.endpoint","api_storage_setting.token"],Kl=new Set(["api_storage_setting.enabled"]),Gl={api_storage_setting:{enabled:!1,endpoint:"",token:""}};function ql(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState(!1),p=t.useRef(),x=e=>{if(!p.current)return"";return p.current.getValue(e)??""},g=async(e,t)=>{try{const n=await ye.put(Se(),{key:e,value:t}),{success:i,message:s}=n.data;return!!i||(je(s),!1)}catch(n){return je(i("ä¿å失败")+": "+n.message),!1}};return t.useEffect(()=>{(async()=>{l(!0);try{const e=await ye.get(Se()),{success:t,message:n,data:i}=e.data;if(t){let e={};i.forEach(t=>{Vl.includes(t.key)&&(Kl.has(t.key)?e[t.key]="true"===t.value:e[t.key]=t.value||"")});const t=function(e,t){const n=JSON.parse(JSON.stringify(t));for(const[i,s]of Object.entries(e)){const e=i.split(".");2===e.length&&(n[e[0]]||(n[e[0]]={}),n[e[0]][e[1]]=s)}return n}(e,Gl);p.current&&p.current.setValues(t)}else je(n)}catch(e){je(i("å 载失败")+": "+e.message)}l(!1)})()},[]),n.jsx(m,{spinning:s,children:n.jsxs(a,{initValues:Gl,getFormApi:e=>p.current=e,style:{marginBottom:15,marginTop:24},autoComplete:"off",children:[n.jsxs("div",{style:{position:"absolute",opacity:0,height:0,overflow:"hidden",pointerEvents:"none"},children:[n.jsx("input",{type:"text",name:"prevent_autofill_username",tabIndex:-1,autoComplete:"username"}),n.jsx("input",{type:"password",name:"prevent_autofill_password",tabIndex:-1,autoComplete:"current-password"})]}),n.jsx(h,{type:"info",description:i("API ä¸ä¼ åå¨ç¨äºæç« å¾çç²è´´ä¸ä¼ ãå票 PDF ä¸ä¼ çåºæ¯ï¼éè¿ HTTP POST + Bearer Token å°æä»¶ä¸ä¼ å°å¤é¨å卿å¡ãæ¤é
ç½®ç¬ç«äºä¸æ¹ç S3/GCP 对象åå¨ã"),style:{marginBottom:20}}),n.jsxs(a.Section,{text:i("API ä¸ä¼ åå¨é
ç½®"),children:[n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"api_storage_setting.enabled",label:i("å¯ç¨ API ä¸ä¼ åå¨")}),n.jsx(Ul,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¯ç¨åï¼æç« ç²è´´å¾çåå票 PDF ä¸ä¼ å°ä½¿ç¨æ¤å卿å¡")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"api_storage_setting.endpoint",label:i("ä¸ä¼ æ¥å£å°å
1(Endpoint)"),placeholder:i("ä¾å¦ï¼https://image.zhongzhuan.chat/upload"),autoComplete:"new-password",name:"api_endpoint_url_setting"}),n.jsx(Ul,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("æä»¶ä¸ä¼ ç API å°åï¼ä½¿ç¨ multipart/form-data æ ¼å¼ POST ä¸ä¼ ï¼å段å为 file")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"api_storage_setting.token",label:i("Bearer Token"),placeholder:i("请è¾å
¥è®¤è¯ Token"),autoComplete:"new-password",name:"api_bearer_token_setting",mode:"password",onChange:()=>u(!0)}),n.jsx(Ul,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("请æ±å¤´ä¸ Authorization: Bearer <Token> ç认è¯ä»¤ç")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsx(c,{span:24,children:n.jsx(d,{type:"primary",onClick:async()=>{l(!0);try{const t=!!x("api_storage_setting.enabled"),n=[g("api_storage_setting.enabled",String(t)),g("api_storage_setting.endpoint",String(x("api_storage_setting.endpoint")))];r&&n.push(g("api_storage_setting.token",String(x("api_storage_setting.token")))),(await Promise.all(n)).every(Boolean)?(be(i("ä¿åæå")),e.refresh&&e.refresh()):je(i("é¨åé
ç½®ä¿å失败ï¼è¯·éè¯"))}catch(t){je(i("ä¿å失败")+": "+t.message)}l(!1)},loading:s,children:i("ä¿åé
ç½®")})})})]})]})})}const{Text:$l}=u,Hl=["s3_storage_setting.enabled","s3_storage_setting.access_key","s3_storage_setting.secret_key","s3_storage_setting.endpoint","s3_storage_setting.bucket_name","s3_storage_setting.region","s3_storage_setting.use_path_style","s3_storage_setting.presign_expire_hours","gcp_storage_setting.enabled","gcp_storage_setting.project_id","gcp_storage_setting.bucket_name","gcp_storage_setting.region","gcp_storage_setting.service_account_json","gcp_storage_setting.presign_expire_hours"],Ql=new Set(["s3_storage_setting.enabled","s3_storage_setting.use_path_style","gcp_storage_setting.enabled"]),Xl=new Set(["s3_storage_setting.presign_expire_hours","gcp_storage_setting.presign_expire_hours"]),Yl={s3_storage_setting:{enabled:!1,access_key:"",secret_key:"",endpoint:"",bucket_name:"",region:"",use_path_style:!0,presign_expire_hours:24},gcp_storage_setting:{enabled:!1,project_id:"",bucket_name:"",region:"",service_account_json:"",presign_expire_hours:24}};function Zl(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,u]=t.useState(!1),[p,x]=t.useState("disabled"),g=t.useRef(),y=e=>{if(!g.current)return"";return g.current.getValue(e)??""},j=async(e,t)=>{try{const n=await ye.put(Se(),{key:e,value:t}),{success:i,message:s}=n.data;return!!i||(je(s),!1)}catch(n){return je(i("ä¿å失败")+": "+n.message),!1}};return t.useEffect(()=>{(async()=>{l(!0);try{const t=await ye.get(Se()),{success:n,message:i,data:s}=t.data;if(n){let t={};s.forEach(e=>{Hl.includes(e.key)&&(Ql.has(e.key)?t[e.key]="true"===e.value:Xl.has(e.key)?t[e.key]=parseInt(e.value,10)||24:t[e.key]=e.value||"")});const n=function(e,t){const n=JSON.parse(JSON.stringify(t));for(const[i,s]of Object.entries(e)){const e=i.split(".");2===e.length&&(n[e[0]]||(n[e[0]]={}),n[e[0]][e[1]]=s)}return n}(t,Yl);x((e=n,e?.s3_storage_setting?.enabled?"s3":e?.gcp_storage_setting?.enabled?"gcp":"disabled")),g.current&&g.current.setValues(n)}else je(i)}catch(t){je(i("å 载失败")+": "+t.message)}var e;l(!1)})()},[]),n.jsxs(n.Fragment,{children:[n.jsx(m,{spinning:s,children:n.jsxs(a,{initValues:Yl,getFormApi:e=>g.current=e,style:{marginBottom:15},autoComplete:"off",children:[n.jsxs("div",{style:{position:"absolute",opacity:0,height:0,overflow:"hidden",pointerEvents:"none"},children:[n.jsx("input",{type:"text",name:"prevent_autofill_username",tabIndex:-1,autoComplete:"username"}),n.jsx("input",{type:"password",name:"prevent_autofill_password",tabIndex:-1,autoComplete:"current-password"})]}),n.jsx(h,{type:"info",description:i("object_storage_hint_002"),style:{marginBottom:20}}),n.jsxs(a.Section,{text:i("对象åå¨é
ç½®"),children:[n.jsx(o,{children:n.jsxs(c,{span:24,children:[n.jsx("div",{style:{marginBottom:"8px",fontWeight:600}
1,children:i("åå¨ç±»å")}),n.jsxs(L,{value:p,onChange:e=>x(e.target.value),direction:"horizontal",children:[n.jsx(B,{value:"disabled",children:i("å
³é")}),n.jsx(B,{value:"s3",children:i("S3 å
¼å®¹åè®®")}),n.jsx(B,{value:"gcp",children:i("GCP Cloud Storage")})]}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i('å䏿¶é´åªè½å¯ç¨ä¸ç§å¯¹è±¡åå¨ï¼åæ¢ç±»åå请ç¹å»"ä¿åé
ç½®"çæ')})]})}),n.jsx("div",{style:{display:"s3"===p?void 0:"none"},children:n.jsxs(n.Fragment,{children:[n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"s3_storage_setting.access_key",label:i("Access Key"),placeholder:i("请è¾å
¥ Access Key"),autoComplete:"new-password",name:"s3_access_key_setting"}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("S3 å
¼å®¹åå¨ç访é®å¯é¥ ID")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"s3_storage_setting.secret_key",label:i("Secret Key"),placeholder:i("请è¾å
¥ Secret Key"),autoComplete:"new-password",name:"s3_secret_key_setting",mode:"password"}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("S3 å
¼å®¹åå¨çç§å¯è®¿é®å¯é¥")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"s3_storage_setting.endpoint",label:i("端ç¹"),placeholder:i("ä¾å¦ï¼https://s3.amazonaws.com æ https://storage.googleapis.com"),autoComplete:"new-password",name:"s3_endpoint_url_setting"}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("S3 å
¼å®¹æå¡ç端ç¹å°åï¼AWS S3 å¯å¡« https://s3.amazonaws.com")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"s3_storage_setting.bucket_name",label:i("å卿¡¶åç§°"),placeholder:i("请è¾å
¥å卿¡¶åç§°"),autoComplete:"new-password"}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å卿¡¶éè¦æåå¨å¯¹åºçå卿塿§å¶å°ä¸å建")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"s3_storage_setting.region",label:i("åºå"),placeholder:i("ä¾å¦ï¼us-east-1ãauto"),autoComplete:"new-password"}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å卿¡¶æå¨åºåï¼ä¸ç¡®å®å¯å¡« auto")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"s3_storage_setting.use_path_style",label:i("ä½¿ç¨ Path Style")}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("object_storage_hint_001")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.InputNumber,{field:"s3_storage_setting.presign_expire_hours",label:i("é¢ç¾å URL æææ¶é¿ï¼å°æ¶ï¼"),placeholder:"24",min:1,max:168,style:{width:"200px"}}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("çæçé¢ç¾åä¸è½½é¾æ¥çæææ¶é¿ï¼é»è®¤ 24 å°æ¶ãAWS S3 æå¤§ 168 å°æ¶ï¼7天ï¼")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx($l,{type:"tertiary",style:{fontSize:"12px"},children:i("é
置说æ")+"ï¼"}),n.jsxs("ul",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",marginTop:"8px"},children:[n.jsx("li",{children:i("1. å¨å¯¹åºçäºæå¡æ§å¶å°å建å卿¡¶")}),n.jsx("li",{children:i("2. è·å Access Key å Secret Key åè¯")}),n.jsx("li",{children:i("3. å¡«åæ£ç¡®ç Endpoint å°å")}),n.jsx("li",{children:i("4. MinIOãGCS çèªå»º/å
¼å®¹æå¡éè¦å¼å¯ Path Style")}),n.jsx("li",{children:i('5. ä¿åé
ç½®åç¹å»"æµè¯è¿æ¥"éªè¯é
ç½®æ¯å¦æ£ç¡®')})]})]})})]})}),n.jsx("div",{style:{display:"gcp"===p?void 0:"none"},children:n.jsxs(n.Fragment,{children:[n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"gcp_storage_setting.project_id",label:i("GCP é¡¹ç® ID"),placeholder:i("请è¾å
¥ GCP é¡¹ç® IDï¼ä¾å¦ï¼my-project-123456"),autoComplete:"new-password"}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¨ GCP Console 䏿¥çæ¨çé¡¹ç® ID")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"gcp_storage_setting.bucket_name",label:i("å卿¡¶åç§°"),placeholder:i("请è¾å
¥å卿¡¶åç§°ï¼ä¾å¦ï¼my-app-invoices"),autoComplete:"new-password"}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"}
1,children:i("å卿¡¶éè¦æåå¨ GCP Console ä¸å建")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.Input,{field:"gcp_storage_setting.region",label:i("åºåï¼å¯éï¼"),placeholder:i("ä¾å¦ï¼asia-east1"),autoComplete:"new-password"}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å卿¡¶æå¨åºåï¼å¯éå¡«")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.TextArea,{field:"gcp_storage_setting.service_account_json",label:i("Service Account JSON åè¯"),placeholder:i("请ç²è´´å®æ´ç Service Account JSON å
容"),autoComplete:"new-password",name:"gcp_service_account_json_setting",rows:8}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("å¨ GCP Console > IAM & Admin > Service Accounts ä¸å建æå¡è´¦å·å¹¶ä¸è½½ JSON å¯é¥æä»¶")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(a.InputNumber,{field:"gcp_storage_setting.presign_expire_hours",label:i("é¢ç¾å URL æææ¶é¿ï¼å°æ¶ï¼"),placeholder:"24",min:1,max:168,style:{width:"200px"}}),n.jsx($l,{type:"tertiary",style:{fontSize:"12px",display:"block",marginTop:"8px"},children:i("çæçç¾åä¸è½½é¾æ¥çæææ¶é¿ï¼é»è®¤ 24 å°æ¶ãGCS V4 ç¾åæå¤§ 168 å°æ¶ï¼7天ï¼")})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx($l,{type:"tertiary",style:{fontSize:"12px"},children:i("é
置说æ")+"ï¼"}),n.jsxs("ul",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",marginTop:"8px"},children:[n.jsx("li",{children:i("1. å¨ GCP Console å建 Cloud Storage å卿¡¶")}),n.jsx("li",{children:i('2. å建 Service Account å¹¶æäº "Storage Object Admin" è§è²')}),n.jsx("li",{children:i("3. ä¸è½½ Service Account ç JSON å¯é¥æä»¶")}),n.jsx("li",{children:i("4. å° JSON æä»¶å
容宿´ç²è´´å°ä¸æ¹ææ¬æ¡ä¸")}),n.jsx("li",{children:i('5. ä¿åé
ç½®åç¹å»"æµè¯è¿æ¥"éªè¯é
ç½®æ¯å¦æ£ç¡®')})]})]})})]})}),n.jsx(o,{style:{marginTop:"16px"},children:n.jsxs(c,{span:24,children:[n.jsx(d,{type:"primary",onClick:async()=>{l(!0);try{const t=[];"s3"===p?(t.push(j("s3_storage_setting.enabled","true")),t.push(j("s3_storage_setting.access_key",String(y("s3_storage_setting.access_key")))),t.push(j("s3_storage_setting.secret_key",String(y("s3_storage_setting.secret_key")))),t.push(j("s3_storage_setting.endpoint",String(y("s3_storage_setting.endpoint")))),t.push(j("s3_storage_setting.bucket_name",String(y("s3_storage_setting.bucket_name")))),t.push(j("s3_storage_setting.region",String(y("s3_storage_setting.region")))),t.push(j("s3_storage_setting.use_path_style",String(y("s3_storage_setting.use_path_style")))),t.push(j("s3_storage_setting.presign_expire_hours",String(y("s3_storage_setting.presign_expire_hours")||24))),t.push(j("gcp_storage_setting.enabled","false"))):"gcp"===p?(t.push(j("gcp_storage_setting.enabled","true")),t.push(j("gcp_storage_setting.project_id",String(y("gcp_storage_setting.project_id")))),t.push(j("gcp_storage_setting.bucket_name",String(y("gcp_storage_setting.bucket_name")))),t.push(j("gcp_storage_setting.region",String(y("gcp_storage_setting.region")))),t.push(j("gcp_storage_setting.service_account_json",String(y("gcp_storage_setting.service_account_json")))),t.push(j("gcp_storage_setting.presign_expire_hours",String(y("gcp_storage_setting.presign_expire_hours")||24))),t.push(j("s3_storage_setting.enabled","false"))):(t.push(j("s3_storage_setting.enabled","false")),t.push(j("gcp_storage_setting.enabled","false"))),(await Promise.all(t)).every(Boolean)&&(be(i("ä¿åæå")),e.refresh&&e.refresh())}catch(t){je(i("ä¿å失败")+": "+t.message)}l(!1)},loading:s,style:{marginRight:"10px"},children:i("ä¿åé
ç½®")}),n.jsx(d,{type:"secondary",onClick:async()=>{u(!0);try{const e=Se(),t=await ye.post(e.replace(/\/(admin)?$/,"/admin/storage/test-connection")),{success:n,message:s}=t.data;n?be(i("è¿æ¥æµè¯æåï¼å¯¹è±¡åå¨é
ç½®æ£ç¡®")):je(i("è¿æ¥æµè¯å¤±è´¥")+": "+s)}catch(e){je(i("è¿æ¥æµè¯å¤±è´¥")+": "+e.message)}u(!1)},loading:r,disabled:"disabled"===p,children:i("æµè¯è¿æ¥")})]})})]})]})}),n.jsx(ql,{options:e.options,refresh:e.refresh})]})}const{Text:ea}=u,ta={default:1800,"sora-2-pro":4200,veo:4200};function na(e){const{t:i}=ge(),[s,l]=t.useState(!1),[a,r]=t.useState(""),[u,p]=t.useState("");return t.useEffect(()=>{const t=e.options?.TaskTimeoutConfig;if(t)try{const e=JSON.parse(t);r(JSON.stringify(e,null,2))}catch{r(JSON.stringify(ta,null,2))}else r(JSON.stringify(ta,null,2));p("")},[e.options]),n.jsxs(m,{spinning:s,children:[n.jsx(o,{gutter:16,children:n.jsxs(c,{span:24,children:[n.jsx("div",{style:{marginBottom:8}
1,children:n.jsx(ea,{strong:!0,children:i("弿¥ä»»å¡è¶
æ¶é
ç½®ï¼JSONï¼")})}),n.jsxs("div",{style:{marginBottom:8,fontSize:13,color:"#666"},children:[i("key ä¸ºä»»å¡ ID åç¼ï¼æåç¼å¹é
ï¼ï¼value 为è¶
æ¶ç§æ°ï¼æ´æ°ï¼ã"),n.jsx("br",{}),i('"default" 为é»è®¤è¶
æ¶ï¼æªå¹é
å°ä»»ä½åç¼æ¶ä½¿ç¨ã'),n.jsx("br",{}),i("示ä¾ï¼sora-2-pro â 4200ç§ï¼70åéï¼ï¼veo â 4200ç§ï¼default â 1800ç§ï¼30åéï¼")]}),n.jsx(S,{value:a,onChange:function(e){r(e);try{JSON.parse(e),p("")}catch(t){p(t.message)}},autosize:{minRows:8,maxRows:20},style:{fontFamily:"monospace",fontSize:13,borderColor:u?"#ff4d4f":void 0}}),u&&n.jsxs("div",{style:{color:"#ff4d4f",fontSize:12,marginTop:4},children:[i("JSON é误ï¼"),u]})]})}),n.jsx(o,{gutter:16,style:{marginTop:12},children:n.jsx(c,{span:24,children:n.jsxs("div",{style:{padding:"10px 14px",border:"1px solid #e8e8e8",borderRadius:4,backgroundColor:"#f6f7f9",fontSize:12,color:"#555"},children:[n.jsx("div",{style:{fontWeight:"bold",marginBottom:6},children:i("é
置说æ")}),n.jsxs("div",{children:["⢠",n.jsx("code",{children:"default"}),"ï¼",i("é»è®¤è¶
æ¶ï¼æªå¹é
å°åç¼æ¶çæï¼åä½ç§")]}),n.jsxs("div",{children:["⢠",i('å
¶ä» key æä»»å¡ ID åç¼å¹é
ï¼è¶é¿è¶ç²¾ç¡®ï¼å¦ "sora-2-pro" ä¼å¹é
å
嫿¤åç¼çä»»å¡ IDï¼')]}),n.jsx("div",{style:{marginTop:4},children:i("å¸¸ç¨æ¢ç®ï¼30åé=1800ï¼50åé=3000ï¼70åé=4200ï¼90åé=5400")})]})})}),n.jsxs(o,{style:{marginTop:16},gutter:8,children:[n.jsx(c,{children:n.jsx(d,{onClick:async function(){if(u)return void ve(i("JSON æ ¼å¼ä¸æ£ç¡®ï¼è¯·ä¿®å¤ååä¿å"));let t;try{t=JSON.parse(a)}catch(n){return void ve(i("JSON æ ¼å¼ä¸æ£ç¡®ï¼")+n.message)}for(const[e,s]of Object.entries(t))if("number"!=typeof s||!Number.isInteger(s)||s<=0)return void ve(i(`"${e}" çå¼å¿
é¡»æ¯æ£æ´æ°ï¼åä½ï¼ç§ï¼`));l(!0);try{const n=Se();await ye.put(n,{key:"TaskTimeoutConfig",value:JSON.stringify(t)}),be(i("ä¿åæå")),e.refresh()}catch{je(i("ä¿å失败ï¼è¯·éè¯"))}finally{l(!1)}},type:"primary",disabled:!!u,children:i("ä¿åè¶
æ¶é
ç½®")})}),n.jsx(c,{children:n.jsx(d,{onClick:function(){r(JSON.stringify(ta,null,2)),p("")},theme:"light",children:i("æ¢å¤é»è®¤å¼")})})]})]})}const{Text:ia,Paragraph:sa}=u,la=[{value:"ErrorCountWhitelist",label:"æ¸ é失败ç»è®¡è±å
",desc:"å½ä¸åä¸è®¡å
¥æ¸ é失败çï¼ä¸å½±åæºè½æåºï¼æå¸¸ç¨ï¼",color:"green"},{value:"NoRetryErrors",label:"请æ±å¤±è´¥ä¸éè¯",desc:"å½ä¸åä¸ä¼éè¯å
¶ä»æ¸ éï¼ç´æ¥æé误è¿åç»ç¨æ·",color:"orange"},{value:"ErrorLogWhitelist",label:"é误æ¥å¿è¯¦ç»è®°å½",desc:"å½ä¸å伿é误详æ
åå
¥æ¥å¿ content åæ®µå±ç°ç»ç¨æ·",color:"blue"},{value:"RedirectErrorMessages",label:"ææé误信æ¯å±è½",desc:"å½ä¸åå±è½ææä¿¡æ¯ï¼å¯é¥ãä½é¢çï¼ï¼ä¸æ´é²ç»ç¨æ·",color:"red"}];function aa(e){if(!e)return"-";const t=new Date(1e3*e),n=(Date.now()-t.getTime())/1e3;return n<60?`${Math.floor(n)}ç§å`:n<3600?`${Math.floor(n/60)}åéå`:n<86400?`${Math.floor(n/3600)}å°æ¶å`:t.toLocaleString()}function ra(e){return e&&8===e.length?`${e.slice(4,6)}-${e.slice(6,8)}`:e}function oa(e){const{t:i}=ge(),[s,l]=t.useState(!0),[u,p]=t.useState(7),[h,y]=t.useState(!1),[b,_]=t.useState([]),[k,C]=t.useState(""),[w,T]=t.useState([]),[I,R]=t.useState(0),[P,z]=t.useState(1),[N,A]=t.useState(50),[D,F]=t.useState(!1),[W,J]=t.useState(!1),[U,V]=t.useState(null),[K,G]=t.useState(""),[q,$]=t.useState("ErrorCountWhitelist"),[H,Q]=t.useState(!1);t.useEffect(()=>{if(!e.options)return;const t=e.options.ErrorCandidateRecordEnabled;void 0!==t&&l(!0===t||"true"===t);const n=e.options.ErrorCandidateRetentionDays;if(void 0!==n&&""!==n){const e=parseInt(n,10);!isNaN(e)&&e>0&&p(e)}},[e.options]);const X=async(e,t=1,n=50,s=!1)=>{if(e){y(!0);try{const l=await ye.get(`/api/error_candidates/?date=${e}&page=${t}&size=${n}&include_ignored=${s}`),{success:a,data:r,message:o}=l.data;a&&r?(T(r.items||[]),R(r.total||0)):(je(o||i("å è½½é误åé失败")),T([]),R(0))}catch(l){je(i("å 载失败")+": "+l.message),T([]),R(0)}finally{y(!1)}}};t.useEffect(()=>{(async()=>{try{const e=await ye.get("/api/error_candidates/dates"),{success:t,data:n,message:s}=e.data;t&&Array.isArray(n)?(_(n),!k&&n.length>0&&C(n[0].date)):t||je(s||i("å è½½æ¥æå表失败"))}catch(e){je(i("å è½½æ¥æå表失败")+": "+e.message)}})()},[]),t.useEffect(()=>{k&&X(k,P,N,D)},[k,P,N,D]);const Y=async(t,n)=>{try{const s=Se(),l=await ye.put(s,{key:t,value:String(n)}),{success:a,message:r}=l.data;return a?(be(i("ä¿åæå")),e.refresh&&e.refresh(),!0):(je(r),!1)}catch(s){return je(i("ä¿å失败")+": "+s.message),!1}},Z=t.useMemo(()=>[{title:i("ç¶æç "),dataIndex:"status_code",width:80,render:e=>e?n.jsx(j,{color:"blue",children:e}):"-"},{title:i("é误ç "),dataIndex:"error_code",width:200,render:e=>
1e?n.jsx(ia,{code:!0,style:{fontSize:12},children:e}):"-"},{title:i("éè¯¯æ¶æ¯"),dataIndex:"message_sample",render:e=>n.jsx(f,{content:e,children:n.jsx(sa,{ellipsis:{rows:2,showTooltip:!1},style:{margin:0,fontSize:12},children:e})})},{title:i("颿¬¡"),dataIndex:"count",width:80,sorter:(e,t)=>e.count-t.count,render:e=>n.jsx(j,{color:e>=100?"red":e>=10?"orange":"grey",children:e})},{title:i("æ¸ é"),dataIndex:"channels",width:150,render:e=>{if(!e||0===e.length)return"-";const t=e.slice(0,3).join(", "),i=e.length>3?" +"+(e.length-3):"";return n.jsx(f,{content:e.join(", "),children:n.jsxs(ia,{style:{fontSize:12},children:[t,i]})})}},{title:i("模å"),dataIndex:"models",width:180,render:e=>{if(!e||0===e.length)return"-";const t=e.slice(0,2).join(", "),i=e.length>2?" +"+(e.length-2):"";return n.jsx(f,{content:e.join(", "),children:n.jsxs(ia,{style:{fontSize:12},children:[t,i]})})}},{title:i("æååºç°"),dataIndex:"last_at",width:110,render:e=>n.jsx(ia,{style:{fontSize:12},children:aa(e)})},{title:i("æä½"),width:220,fixed:"right",render:(e,t)=>n.jsxs(g,{children:[n.jsx(d,{size:"small",type:"primary",theme:"solid",disabled:t.ignored,onClick:()=>(e=>{V(e),G(e.message_sample||""),$("ErrorCountWhitelist"),J(!0)})(t),children:i("å å
¥ç½åå")}),t.ignored?n.jsx(d,{size:"small",onClick:()=>(async e=>{try{const t=await ye.post("/api/error_candidates/unignore",{fingerprint:e.fingerprint}),{success:n,message:s}=t.data;n?(be(i("å·²æ¢å¤")),X(k,P,N,D)):je(s)}catch(t){je(i("æä½å¤±è´¥")+": "+t.message)}})(t),children:i("åæ¶å¿½ç¥")}):n.jsx(O,{title:i("ç¡®å®å¿½ç¥è¿æ¡é误åï¼"),content:i('忽ç¥åå°ä¸åå±ç¤ºï¼å¯å¨"æ¾ç¤ºå·²å¿½ç¥"䏿¾åã'),onConfirm:()=>(async e=>{try{const t=await ye.post("/api/error_candidates/ignore",{fingerprint:e.fingerprint}),{success:n,message:s}=t.data;n?(be(i("已忽ç¥")),X(k,P,N,D)):je(s)}catch(t){je(i("æä½å¤±è´¥")+": "+t.message)}})(t),children:n.jsx(d,{size:"small",type:"tertiary",children:i("忽ç¥")})})]})}],[k,P,N,D]),ee=la.find(e=>e.value===q);return n.jsxs(m,{spinning:h,children:[n.jsx(r,{style:{marginBottom:16},bodyStyle:{padding:16},children:n.jsx(a,{labelPosition:"left",labelAlign:"left",labelWidth:140,children:n.jsxs(o,{gutter:24,children:[n.jsx(c,{span:12,children:n.jsxs(a.Slot,{label:i("å¯ç¨é误åééé"),children:[n.jsx(E,{checked:s,checkedText:i("å¼"),uncheckedText:i("å
³"),onChange:async e=>{await Y("ErrorCandidateRecordEnabled",e)&&l(e)}}),n.jsx(ia,{type:"tertiary",style:{marginLeft:12,fontSize:12},children:i('å¼å¯åä¼èªå¨æ¶é"被å¤å®ä¸ºæ¸ éå¤±è´¥ä½æªå½ä¸ç½åå"çé误')})]})}),n.jsx(c,{span:12,children:n.jsx(a.Slot,{label:i("æ°æ®ä¿ç天æ°"),children:n.jsx(M,{value:u,min:1,max:30,onBlur:async e=>{const t=parseInt(e.target.value,10);!isNaN(t)&&t>0&&t!==u&&await Y("ErrorCandidateRetentionDays",t)&&p(t)},onChange:e=>p(e),suffix:i("天")})})})]})})}),n.jsxs(r,{bodyStyle:{padding:16},children:[n.jsxs(o,{type:"flex",align:"middle",justify:"space-between",style:{marginBottom:16,flexWrap:"wrap",gap:8},children:[n.jsx(c,{children:n.jsxs(g,{wrap:!0,children:[n.jsx(ia,{strong:!0,children:i("æ¥æï¼")}),b.map(e=>n.jsxs(j,{color:e.date===k?"blue":"white",type:e.date===k?"solid":"light",onClick:()=>{C(e.date),z(1)},style:{cursor:"pointer"},children:[ra(e.date)," (",e.count,")"]},e.date))]})}),n.jsx(c,{children:n.jsxs(g,{children:[n.jsx(E,{size:"small",checked:D,checkedText:i("å«å¿½ç¥"),uncheckedText:i("éè忽ç¥"),onChange:e=>{F(e),z(1)}}),n.jsx(d,{onClick:()=>X(k,P,N,D),children:i("å·æ°")})]})})]}),n.jsx(v,{rowKey:"fingerprint",columns:Z,dataSource:w,scroll:{x:1300},pagination:{currentPage:P,pageSize:N,total:I,showSizeChanger:!0,pageSizeOpts:[20,50,100,200],onPageChange:z,onPageSizeChange:e=>{A(e),z(1)},showTotal:!0},empty:n.jsx("div",{style:{padding:32,textAlign:"center",color:"#999"},children:i("ææ æ°æ®ãå¯è½åå ï¼ä»å¤©è¿æ²¡ææªè¦ççéè¯¯ï¼æééå¼å
³æªå¯ç¨ã")})})]}),n.jsx(x,{title:i("å å
¥ç½åå"),visible:W,onCancel:()=>J(!1),onOk:async()=>{if(K.trim()){Q(!0);try{const t=await ye.post("/api/error_candidates/whitelist",{fingerprint:U?.f
1ingerprint||"",date:k,whitelist_type:q,keyword:K.trim()}),{success:n,message:s}=t.data;n?(be(i("å·²å å
¥ç½åå")),J(!1),e.refresh&&e.refresh()):je(s||i("å å
¥å¤±è´¥"))}catch(t){je(i("å å
¥å¤±è´¥")+": "+t.message)}finally{Q(!1)}}else je(i("å
³é®è¯ä¸è½ä¸ºç©º"))},confirmLoading:H,okText:i("确认å å
¥"),width:680,children:U&&n.jsxs("div",{children:[n.jsxs(r,{bodyStyle:{padding:12,background:"#fafafa"},style:{marginBottom:16},children:[n.jsxs("div",{style:{marginBottom:6},children:[n.jsx(j,{color:"blue",children:U.status_code||"-"}),n.jsx(ia,{code:!0,style:{fontSize:12,marginLeft:8},children:U.error_code||"-"}),n.jsxs(j,{style:{marginLeft:8},color:"orange",children:[i("颿¬¡"),": ",U.count]})]}),n.jsx(ia,{type:"tertiary",style:{fontSize:12},children:i("åå§æ¶æ¯æ ·æ¬")}),n.jsx(sa,{style:{margin:"4px 0 0",fontSize:12},children:U.message_sample})]}),n.jsx("div",{style:{marginBottom:12},children:n.jsx(ia,{strong:!0,children:i("éæ©ç½ååç±»å")})}),n.jsx(L,{value:q,onChange:e=>$(e.target.value),direction:"vertical",style:{marginBottom:16,width:"100%"},children:la.map(e=>n.jsx(B,{value:e.value,children:n.jsxs("div",{children:[n.jsx(j,{color:e.color,style:{marginRight:8},children:i(e.label)}),n.jsx(ia,{type:"tertiary",style:{fontSize:12},children:i(e.desc)})]})},e.value))}),n.jsx("div",{style:{marginBottom:8},children:n.jsx(ia,{strong:!0,children:i("å®é
å å
¥çå
³é®è¯ï¼å¯ç¼è¾ï¼å»ºè®®æªå稳å®çç¹å¾ç段ï¼")})}),n.jsx(S,{value:K,onChange:G,autosize:{minRows:3,maxRows:6},maxLength:500,showClear:!0,placeholder:i("ä»åå§æ¶æ¯ä¸æªå䏿®µè½ç¨³å®å¹é
çå
³é®è¯")}),n.jsxs(ia,{type:"tertiary",style:{fontSize:12,marginTop:8,display:"block"},children:[i("æç¤ºï¼å
³é®è¯å¤ªé¿å¯è½å¹é
ä¸å°ï¼å¤ªçå¯è½è¯¯ä¼¤å
¶ä»é误ã建议æªåé误ä¸ç¬ç¹çè±æçæ®µã"),"RedirectErrorMessages"===ee?.value&&i(" RedirectErrorMessages 使ç¨éå·åéï¼å
³é®è¯å
ä¸è½å
å«éå·ã")]})]})})]})}const{Text:ca}=u;function da(e){const{t:i}=ge(),[s,l]=t.useState(!1),[r,d]=t.useState(!1);return t.useEffect(()=>{if(!e.options)return;const t=e.options.TopupStarLevelEnabled;void 0!==t&&l(!0===t||"true"===t)},[e.options]),n.jsxs(m,{spinning:r,children:[n.jsx(h,{type:"info",bordered:!0,closeIcon:null,style:{marginBottom:16},description:i("æ»å¼å
³å
³éæ¶ï¼ç¨æ·å
å¼æçº§ç¸å
³åè½å
¨é¨ä¸çæï¼å«è®¡ä»·ä¸ä¸ªäººå
å¼é¡µå±ç¤ºï¼ï¼å·²ç»å®æçº§çç¨æ·ææ®é/代ç/ç³»ç»ä»·å
å¼ï¼æçº§åä»·é
ç½®æ°æ®ä»ä¿çï¼å¼å¯åèªå¨æ¢å¤ã")}),n.jsx(a,{labelPosition:"left",labelAlign:"left",labelWidth:200,children:n.jsx(o,{gutter:16,children:n.jsxs(c,{span:24,children:[n.jsx(a.Switch,{field:"TopupStarLevelEnabled",label:i("å¯ç¨ç¨æ·å
å¼æçº§åè½"),checked:s,checkedText:i("å¼"),uncheckedText:i("å
³"),onChange:async t=>{await(async(t,n)=>{try{d(!0);const t=Se(),s=await ye.put(t,{key:"TopupStarLevelEnabled",value:String(n)}),{success:l,message:a}=s.data;return l?(be(i("ä¿åæå")),e.refresh&&e.refresh(),!0):(je(a),!1)}catch(s){return je(i("ä¿å失败")+": "+s.message),!1}finally{d(!1)}})(0,t)&&l(t)}}),n.jsx(ca,{type:"tertiary",style:{fontSize:12,display:"block",marginTop:8},children:i("æçº§åç§°ä¸åä»·å¨ãè¿è¥è®¾ç½® - ç¨æ·æçº§å价设置ãä¸é
ç½®ï¼ç¨æ·ä¸æçº§çç»å®å¨ãç¨æ·ç®¡ç - ç¼è¾ç¨æ·ã䏿ä½ã")})]})})})]})}function ua(e){const{t:i}=ge(),[,s]=t.useContext(Te),[l,a]=t.useState(!1),[r,d]=t.useState({InvoiceEnabled:!0,InvoicePersonalEnabled:!0,PersonalVerifyEnabled:!0,InvoiceEnterpriseEnabled:!0,InvoiceMinAmount:0,InvoiceMaxAmount:0});t.useEffect(()=>{if(!e.options)return;const t=e=>{const t=parseFloat(e);return Number.isFinite(t)&&t>=0?t:0};d({InvoiceEnabled:!0===e.options.InvoiceEnabled||"true"===e.options.InvoiceEnabled,InvoicePersonalEnabled:void 0===e.options.InvoicePersonalEnabled||!0===e.options.InvoicePersonalEnabled||"true"===e.options.InvoicePersonalEnabled,PersonalVerifyEnabled:void 0===e.options.PersonalVerifyEnabled||!0===e.options.PersonalVerifyEnabled||"true"===e.options.PersonalVerifyEnabled,InvoiceEnterpriseEnabled:void 0===e.options.InvoiceEnterpriseEnabled||!0===e.options.InvoiceEnterpriseEnabled||"true"===e.options.InvoiceEnterpriseEnabled,InvoiceMinAmount:t(e.options.InvoiceMinAmount),InvoiceMaxAmount:t(e.options.InvoiceMaxAmount)})},[e.options]);const p=(e,t)=>{if("InvoiceMinAmount"!==e&&"InvoiceMaxAmount"!==e)return String(t);const n=Number(t);return!Number.isFinite(n)||n<0?"0":n.toFixed(2)},h=async(t,n)=>{const l=r[t];d(e=>({...e,[t]:n})),a(!0);try{const a=await ye.put(Se(),{key:t,value:p(t,n)}),{success:r,message:c}=a.data;if(r){be(i("设置ä¿åæå"));try{const e=await ye.get("/api/status");e.data?.success&&s({type:"set",payload:e.data.data})}catch(o){}e.refresh&&e.refresh()}else je(c),d(e=>({...e,[t]:l}))}catch(c){je(i("设置ä¿å失败")),d(e=>({...e,[t]:l}))}finally{a(!1)}},x=({field:e,label:t,description:i})=>n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx(E,{checked:r[e],onChange:t=>h(e,t),disabled:l}),n.jsx(u.Text,{children:t})]}),i&&n.jsx(u.Text,{type:"tertiary",style:{marginLeft:44},children:i})]});return n.jsxs(m,{spinning:l,children:[n.jsx(u.Title,{heading:6,style:{marginBottom:16},children:i("å票设置")}),n.jsx(o,{gutter:16,children:n.jsx(c,{span:8,children:n.jsx(x,{field:"InvoiceEnabled",label:i("å¯ç¨å票åè½"),description:i("å¼å¯åï¼ç¨æ·å¯ä»¥å¨å
å¼é¡µé¢ç³è¯·å¼å
·å票ï¼å¹¶æ¥çå¼ç¥¨è®°å½ã")})})}),r.InvoiceEnabled&&n.jsxs(o,{gutter:16,style:{marginTop:16},children:[n.jsx(c,{span:8,children:n.jsx(x,{field:"InvoicePersonalEnabled",label:i("å
许个人å¼ç¥¨"),description:i("å
³éåï¼ç¨æ·å°æ æ³ä»¥ä¸ªäººåä¹ç³è¯·å¼ç¥¨ã")})}),n.jsx(c,{span:8,children:n.jsx(x,{field:"PersonalVerifyEnabled",label:i("å
许个人å®å认è¯"),description:i("å
³éåï¼ç¨æ·å°æ æ³è¿è¡ä¸ªäººå®å认è¯ï¼ä»
å¯è¿è¡ä¼ä¸è®¤è¯ã")})}),n.jsx(c,{span:8,children:n.jsx(x,{field:"InvoiceEnterpriseEnabled",label:i("å
许ä¼ä¸å¼ç¥¨"),description:i("å
³éåï¼ç¨æ·å°æ æ³ä»¥ä¼ä¸åä¹ç³è¯·å¼ç¥¨ã")})})]}),r.InvoiceEnabled&&n.jsxs(o,{gutter:16,style:{marginTop:16},children:[n.jsx(c,{span:8,children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.jsx(u.Text,{children:i("åç¬å¼ç¥¨æå°éé¢ï¼å
ï¼")}),n.jsx(M,{min:0,precision:2,value:r.InvoiceMinAmount,disabled:l,onChange:e=>d(t=>({...t,InvoiceMinAmount:null==e?0:Number(e)})),onBlur:()=>h("InvoiceMinAmount",r.InvoiceMinAmount)}),n.jsx(u.Text,{type:"tertiary",children:i("å¡« 0 表示ä¸éå¶æå°éé¢ã")})]})}),n.jsx(c,{span:8,children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.jsx(u.Text,{children:i("åç¬å¼ç¥¨æå¤§éé¢ï¼å
ï¼")}),n.jsx(M,{min:0,precision:2,value:r.InvoiceMaxAmount,disabled:l,onChange:e=>d(t=>({...t,InvoiceMaxAmount:null==e?0:Number(e)})),onBlur:()=>h("InvoiceMaxAmount",r.InvoiceMaxAmount)}),n.jsx(u.Text,{type:"tertiary",children:i("å¡« 0 表示ä¸é嶿大éé¢ã")})]})})]})]})}const pa=e=>{const{t:i}=ge(),[s,l]=t.useState("seoAndWebsite"),[a,o]=t.useState("modelRateLimit"),[c,d]=t.useState("notification"),[u,p]=t.useState("imageProxy");return n.jsx(r,{style:{marginBottom:20},children:n.jsxs(b,{type:"line",activeKey:s,onChange:e=>
1l(e),children:[n.jsx(_,{tab:i("ð SEOä¸ç½ç«"),itemKey:"seoAndWebsite",style:{marginTop:20},children:n.jsx(kl,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð¥ï¸ æå¡å¨é
ç½®"),itemKey:"serverConfig",style:{marginTop:20},children:n.jsx(vl,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð¤ æ¨¡å䏿¸ é"),itemKey:"modelAndChannel",style:{marginTop:20},children:n.jsxs(b,{type:"card",activeKey:a,onChange:e=>o(e),style:{marginTop:10},children:[n.jsx(_,{tab:i("ð¦ æ¨¡åéå¶"),itemKey:"modelRateLimit",style:{marginTop:20},children:n.jsx(al,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð æ¸ éæåº"),itemKey:"channelSort",style:{marginTop:20},children:n.jsx(ll,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð¦ æ¨¡åè¾å
¥è¾åºéå¶"),itemKey:"tokenLimit",style:{marginTop:20},children:n.jsx(ul,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð Gemini 设置"),itemKey:"geminiSettings",style:{marginTop:20},children:n.jsx(pl,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð çé¨æè¡æ¦"),itemKey:"ranking",style:{marginTop:20},children:n.jsx(gl,{options:e.options,refresh:e.refresh})})]})}),n.jsx(_,{tab:i("ð¤ ç¨æ·ä½éª"),itemKey:"userExperience",style:{marginTop:20},children:n.jsx(fl,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð éç¥å®¢æ"),itemKey:"notification",style:{marginTop:20},children:n.jsxs(b,{type:"card",activeKey:c,onChange:e=>d(e),style:{marginTop:10},children:[n.jsx(_,{tab:i("ð æ¨ééç¥"),itemKey:"notification",style:{marginTop:20},children:n.jsx(bl,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð¬ 客æè®¾ç½®"),itemKey:"customerSupport",style:{marginTop:20},children:n.jsx(Rl,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð± åçåæ´éç¥"),itemKey:"ratioNotify",style:{marginTop:20},children:n.jsx(_l,{options:e.options,refresh:e.refresh})})]})}),n.jsx(_,{tab:i("â¡ é«çº§åè½"),itemKey:"advanced",style:{marginTop:20},children:n.jsxs(b,{type:"card",activeKey:u,onChange:e=>p(e),style:{marginTop:10},children:[n.jsx(_,{tab:i("ð¼ï¸ å¾ç代ç"),itemKey:"imageProxy",style:{marginTop:20},children:n.jsx(sl,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð ç»å½å®å
¨"),itemKey:"loginSecurity",style:{marginTop:20},children:n.jsx(Al,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð æ¸ 鿍¡å管ç"),itemKey:"channelModel",style:{marginTop:20},children:n.jsx(Ol,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("âï¸ é¿éäºå®åéªè¯"),itemKey:"aliyunVerify",style:{marginTop:20},children:n.jsx(Ll,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð¯ æ¨¡åç½åå"),itemKey:"modelWhitelist",style:{marginTop:20},children:n.jsx(Fl,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("âï¸ å¯¹è±¡åå¨"),itemKey:"objectStorage",style:{marginTop:20},children:n.jsx(Zl,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("â±ï¸ ä»»å¡è¶
æ¶"),itemKey:"taskTimeout",style:{marginTop:20},children:n.jsx(na,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð¡ é误åéåæ"),itemKey:"errorCandidate",style:{marginTop:20},children:n.jsx(oa,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("â å
å¼æçº§"),itemKey:"topupStarLevel",style:{marginTop:20},children:n.jsx(da,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð§ å
¶ä»æ©å±"),itemKey:"otherSettings",style:{marginTop:20},children:n.jsx(jl,{options:e.options,refresh:e.refresh})})]})}),n.jsx(_,{tab:i("ð 忥åè½"),itemKey:"syncSettings",style:{marginTop:20},children:n.jsx(Jl,{options:e.options,refresh:e.refresh})}),n.jsx(_,{tab:i("ð§¾ å票管ç"),itemKey:"invoiceSettings",style:{marginTop:20},children:n.jsx(ua,{options:e.options,refresh:e.refresh})})]})})},ha=()=>{const{t:e}=ge(),[i,s]=t.useState(!1),[l,a]=t.useState({});async function o(){try{s(!0),await(async()=>{const t=Ee()?"/api/option/":"/api/option/admin";try{const e=await ye.get(t),{success:n,message:i,data:s}=e.data;if(n){let e={};s.forEach(t=>
1{t.key.endsWith("Enabled")?e[t.key]="true"===t.value:e[t.key]=t.value}),a(e),Object.keys(e).length}else je(i),console.error("CustomSettingsWrapper - APIè¿å失败:",i)}catch(n){console.error("CustomSettingsWrapper - APIè°ç¨å¼å¸¸:",n),je(e("å è½½é
置失败ï¼è¯·æ£æ¥æé"))}})()}catch(t){je(e("å·æ°å¤±è´¥")),console.error("CustomSettingsWrapper - å·æ°å¤±è´¥:",t)}finally{s(!1)}}return t.useEffect(()=>{const t=Ee()||Pe();Ee(),Pe(),t?o():je(e("æ¨æ²¡æè®¿é®æ¤é¡µé¢çæé"))},[]),Ee()||Pe()?n.jsx(m,{spinning:i,size:"large",children:n.jsxs(r,{style:{marginBottom:"10px"},children:[n.jsx(r.Meta,{title:e("äºå¼æ©å±åè½è®¾ç½®")}),n.jsx("div",{style:{marginTop:"16px"},children:n.jsx(pa,{options:l,refresh:o})})]})}):n.jsx(r,{style:{marginBottom:"10px"},children:n.jsx(h,{type:"warning",description:e("æ¨æ²¡æè®¿é®äºå¼åè½è®¾ç½®çæéï¼éè¦ç®¡çåæè¶
级管çåè§è²ã")})})},xa=()=>{const{t:e}=ge(),i=s(),a=l(),[r,o]=t.useState("1");let c=[];Ee()&&(c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(it,{size:18}),e("è¿è¥è®¾ç½®")]}),content:n.jsx(Jn,{}),itemKey:"operation"}),c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(vt,{size:18}),e("仪表ç设置")]}),content:n.jsx(Ri,{}),itemKey:"dashboard"}),c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(Ct,{size:18}),e("è天设置")]}),content:n.jsx(Qi,{}),itemKey:"chats"}),c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(wt,{size:18}),e("ç»å¾è®¾ç½®")]}),content:n.jsx(Yi,{}),itemKey:"drawing"}),c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(ft,{size:18}),e("æ¯ä»è®¾ç½®")]}),content:n.jsx(ss,{}),itemKey:"payment"}),c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(Tt,{size:18}),e("åç设置")]}),content:n.jsx($i,{}),itemKey:"ratio"}),c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(It,{size:18}),e("éçéå¶è®¾ç½®")]}),content:n.jsx(Vn,{}),itemKey:"ratelimit"}),c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(Et,{size:18}),e("模åç¸å
³è®¾ç½®")]}),content:n.jsx(xi,{}),itemKey:"models"}),c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(Rt,{size:18}),e("ç³»ç»è®¾ç½®")]}),content:n.jsx(on,{}),itemKey:"system"}),c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(Pt,{size:18}),e("å
¶ä»è®¾ç½®")]}),content:n.jsx(Rn,{}),itemKey:"other"}),c.push({tab:e("äºå¼åè½è®¾ç½®"),content:n.jsx(ha,{}),itemKey:"custom"})),Pe()&&!Ee()&&(c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(vt,{size:18}),e("仪表ç设置")]}),content:n.jsx(En,{}),itemKey:"dashboard"}),c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(Tt,{size:18}),e("åç设置")]}),content:n.jsx($i,{}),itemKey:"ratio"}),c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(Rt,{size:18}),e("ç³»ç»è®¾ç½®")]}),content:n.jsx(un,{}),itemKey:"system"}),c.push({tab:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[n.jsx(Pt,{size:18}),e("äºå¼åè½è®¾ç½®")]}),content:n.jsx(ha,{}),itemKey:"custom"})),De()&&c.push({tab:e("ç«ç¹ç®¡ç"),content:n.jsx(il,{}),itemKey:"agent"});const d=e=>{o(e),i(`/console/setting?tab=${e}`,{replace:!0})},u=t.useRef(c);u.current=c;const p=()=>Ee()?"operation":Pe()?"dashboard":De()?"agent":"operation";return t.useEffect(()=>{if(!a.pathname.startsWith("/console/setting"))return;const e=new URLSearchParams(a.search).get("tab");e&&u.current.find(t=>t.itemKey===e)?o(e):d(p())},[a.pathname,a.search]),n.jsx("div",{className:"px-2",children:n.jsx(le,{children:n.jsx(le.Content,{children:n.jsx(b,{type:"card",collapsible:!0,activeKey:r,onChange:e=>d(e),children:c.map(e=>n.jsx(_,{itemKey:e.itemKey,tab:e.tab,children:r===e.itemKey&&e.content},e.itemKey))})})})})};export{xa 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.