1import{r as e,j as s}from"./vendor-react-DejgYtBM.js";import{u as t,S as a,a as r,v as l,w as i,aH as n,A as o,O as c,s as d,Y as m,aI as u,W as p,K as h,N as x,aj as g,Z as j,ag as y}from"./index-BeIIFw6E.js";import{M as f,j as v,f as b,B as w,W as _,l as k,o as N,m as C,A as S,R as $,C as z,v as I,aq as T,i as q,u as A,r as O,z as P,ar as W,as as B,k as L,at as R,au as M,av as V,aw as E,ax as H,ay as D,az as F,aA as K,aB as U,aC as G,P as J,F as Y,aD as X,E as Z,J as Q,K as ee}from"./vendor-semi-D8d7bTtM.js";import{g as se}from"./cherryStudioUtils-BalcJ1dl.js";import{k as te,E as ae,V as re,C as le,K as ie,Z as ne,t as oe,u as ce,bm as de,bB as me,ba as ue,I as pe,q as he,at as xe,bt as ge,j as je,bC as ye,d as fe,e as ve,X as be}from"./vendor-icons-EJvJ5X-w.js";import{u as we}from"./useTableCompactMode-DWLN7NUj.js";import{C as _e}from"./CardTable-Cq0lqlnD.js";import{C as ke}from"./CardPro-DfDWu9ok.js";import{u as Ne}from"./useIsMobile-D_kfVI0u.js";import"./vendor-motion-Chfy_MiU.js";const{Text:Ce}=b;function Se(e){return String(e||"").replace(/\/$/,"")}function $e(e){if(!e)return!1;const s=String(e).toLowerCase();return"localhost"===s||"127.0.0.1"===s||"[::1]"===s||s.endsWith(".localhost")}function ze(){if("undefined"==typeof localStorage)return null;try{const e=localStorage.getItem("status");return e?JSON.parse(e):null}catch(e){return null}}function Ie(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function Te(e){return e.replace(/'/g,"'\\''")}function qe({visible:n,onClose:o,keys:c=[],groups:d=[]}){const{t:m}=t(),[u]=e.useContext(a),[p,h]=e.useState("openai"),[x,g]=e.useState("python"),[j,y]=e.useState(!1),b=r(),_=e.useMemo(()=>function(e){let s=e&&e.server_address||("undefined"!=typeof localStorage?localStorage.getItem("server_address"):"")||"";if(!s&&"undefined"!=typeof localStorage){const e=ze();e&&"object"==typeof e&&(s=e.server_address||"")}if("undefined"==typeof window)return Se(s)||"";const t=window.location.origin;if(!$e(window.location.hostname))return Se(t);if(s){const e=Se(String(s).trim());try{if(!$e(new URL(e).hostname))return e}catch(a){}}return Se(t)}(u?.status),[u?.status?.server_address,n]),k=u?.status?.system_name||ze()?.system_name||"API",N=_||function(){const e=("undefined"!=typeof window?window.location.origin:"")||"";return String(e).replace(/\/$/,"")}(),C=`${N}/v1`,S=`${N}/v1`,$=`${N}/v1beta`,z=c[0]||"",I=z.startsWith("sk-")?z.slice(3):z,T=z.length>12?`${z.slice(0,7)}${"*".repeat(Math.min(16,z.length-12))}${z.slice(-4)}`:z,q="openai"===p?C:N,A=e.useMemo(()=>function(e,s,t,a){const r="gpt-5.5-pro",l="claude-opus-4-7",i="gemini-3.1-pro-preview",n=t.replace("/v1",""),o="ä½ å¥½ï¼è¯·ç¨ä¸å¥è¯ä»ç»ä½ èªå·±ã",c=JSON.stringify({model:r,messages:[{role:"user",content:o}],temperature:.7}),d=JSON.stringify({model:l,max_tokens:1024,messages:[{role:"user",content:o}]}),m=JSON.stringify({contents:[{role:"user",parts:[{text:o}]}]}),u=["# Windowsï¼CMD / PowerShellï¼ï¼è¯·ç¨ curl.exeï¼åè¡ç²è´´ï¼ä¸è¦ç¨ bash ç \\ ç»è¡",`curl.exe -sS "${s}/chat/completions" -H "Authorization: Bearer ${e}" -H "Content-Type: application/json" -d "${Ie(c)}"`,"","# Linux / macOS / Git Bashï¼",`curl -sS "${s}/chat/completions" \\`,` -H "Authorization: Bearer ${e}" \\`,' -H "Content-Type: application/json" \\',` -d '${Te(c)}'`].join("\n");return{openai:{python:`# POST ${s}/chat/completionsï¼OpenAI å
¼å®¹ï¼\nfrom openai import OpenAI\n\nclient = OpenAI(api_key="${e}", base_url="${s}")\n\nresp = client.chat.completions.create(\n model="${r}",\n messages=[{"role": "user", "content": "${o}"}],\n temperature=0.7,\n)\nprint(resp.choices[0].message.content)`,node:`// POST ${s}/chat/completions\nimport OpenAI from "openai";\n\nconst client = new OpenAI({ apiKey: "${e}", baseURL: "${s}" });\n\nconst resp = await client.chat.completions.create({\n model: "${r}",\n messages: [{ role: "user", content: "${o}" }],\n temperature: 0.7,\n});\nconsole.log(resp.choices[0]?.message?.content);`,curl:u},anthropic:{python:`# POST ${t}/messagesï¼Claude Messagesï¼ä»¤çä¹å¯ç¨ Authorization: Bearerï¼\nfrom anthropic import Anthropic\n\nclient = Anthropic(api_key="${e}", base_url="${n}")\n\nmsg = client.messages.create(\n model="${l}",\n max_tokens=1024,\n messages=[{"role": "user", "content": "${o}"}],\n)\nprint(msg.content[0].text)`,node:`// POST ${t}/messages\nimport Anthropic from "@anthropic-ai/sdk";\n\nconst client = new Anthropic({ apiKey: "${e}", baseURL: "${n}" });\n\nconst msg = await client.messages.create({\n model: "${l}",\n max_tokens: 1024,\n messages: [{ role: "user", content: "${o}" }],\n});\nconsole.log(msg.content[0]?.text);`,curl:["# Windowsï¼CMD / PowerShellï¼",`curl.exe -sS "${t}/messages" -H "x-api-key: ${e}" -H "anthropic-version: 2023-06-01" -H "Content-Type: application/json" -d "${Ie(d)}"`,"","# Linux / macOS / Git Bashï¼",`curl -sS "${t}/messages" \\`,` -H "x-api-key: ${e}" \\`,' -H "anthropic-version: 2023-06-01" \\',' -H "Content-Type: application/json" \\',` -d '${Te(d)}'`].join("\n")},gemini:{python:`# POST ${a}/models/${i}:generateContentï¼ä¹å¯ç¨ Authorization Bearer æ URL ?key=ï¼\nimport requests\n\nurl = "${a}/models/${i}:generateContent"\nheaders = {"x-goog-api-key": "${e}", "Content-Type": "application/json"}\nbody = {"contents": [{"role": "user", "parts": [{"text": "${o}"}]}]}\nr = requests.post(url, headers=headers, json=body, timeout=120)\nprint(r.json())`,node:`// POST ${a}/models/${i}:generateContent\nconst apiKey = "${e}";\nconst url = "${a}/models/${i}:generateContent";\nconst res = await fetch(url, {\n method: "POST",\n headers: {\n "x-goog-api-key": apiKey,\n "Content-Type": "application/json",\n },\n body: JSON.stringify({\n contents: [{ role: "user", parts: [{ text: "${o}" }] }],\n }),\n});\nconsole.log(await res.json());`,curl:["# Windowsï¼CMD / PowerShellï¼",`curl.exe -sS "${a}/models/${i}:generateContent" -H "x-goog-api-key: ${e}" -H "Content-Type: application/json" -d "${Ie(m)}"`,"","# Linux / macOS / Git Bashï¼",`curl -sS "${a}/models/${i}:generateContent" \\`,` -H "x-goog-api-key: ${e}" \\`,' -H "Content-Type: application/json" \\',` -d '${Te(m)}'`].join("\n")},cherry:{python:`# Cherry Studioï¼æ·»å ä¾åºå â éãOpenAIãæãOpenAI å
¼å®¹ã\n# API å°åï¼Base URLï¼ï¼${s}\n# API å¯é¥ï¼${e}\n# 亦å¯ä½¿ç¨åºç¨å
ã导å
¥ãåè½ï¼ç²è´´ Base64ï¼è§å¼¹çªå
ãå¤å¶ Cherry 导å
¥ãæé®ï¼\n#\n# 以ä¸ä¸ºä¸æ¬ç« OpenAI å
¼å®¹æ¥å£ç¸åçå½ä»¤è¡éªè¯ï¼\nfrom openai import OpenAI\n\nclient = OpenAI(api_key="${e}", base_url="${s}
1")\n\nresp = client.chat.completions.create(\n model="${r}",\n messages=[{"role": "user", "content": "${o}"}],\n temperature=0.7,\n)\nprint(resp.choices[0].message.content)`,node:`// Cherry Studioï¼Base URL = ${s}ï¼API Key = 䏿¹ä»¤ç\n// 导å
¥ Base64 å¯ç¨ä¸æ¹ãå¤å¶ Cherry 导å
¥ã\n//\n// éªè¯è¯·æ±ï¼POST ${s}/chat/completionsï¼\nimport OpenAI from "openai";\n\nconst client = new OpenAI({ apiKey: "${e}", baseURL: "${s}" });\n\nconst resp = await client.chat.completions.create({\n model: "${r}",\n messages: [{ role: "user", content: "${o}" }],\n temperature: 0.7,\n});\nconsole.log(resp.choices[0]?.message?.content);`,curl:["# Cherry Studio å¡«åç Base URL æ«çº§ä¸è¬ä¸º /v1ï¼è¯·æ±è·¯å¾ä»ä¸º chat/completions","# éªè¯è¯·æ±ï¼ä¸ OpenAI å
¼å®¹ chat/completions ç¸åï¼ï¼","",...u.split("\n")].join("\n")}}}(z,C,S,$),[z,C,S,$]),O=A[p]?.[x]||A.openai.python,P=async e=>{await l(e)&&i(m("å·²å¤å¶å°åªè´´æ¿")+"ï¼")};return e.useMemo(()=>{if(!I)return"";try{return se("anthropic"===p?"anthropic":"gemini"===p?"gemini":"openai",I,N,k,d)}catch{return""}},[I,N,p,k,d]),e.useMemo(()=>{try{const e=localStorage.getItem("chats");if(!e)return[];const s=JSON.parse(e);return Array.isArray(s)?s.map((e,s)=>{const t=Object.keys(e)[0];return{key:`chat-${s}`,label:t,urlTemplate:e[t]}}).filter(e=>e.label&&e.urlTemplate):[]}catch{return[]}},[n]),s.jsx(f,{title:null,visible:n,onCancel:o,footer:null,size:b?"full-width":void 0,width:b?void 0:560,maskClosable:!1,closeOnEsc:!0,bodyStyle:{maxWidth:"100%",overflowX:"hidden",overflowY:"auto",maxHeight:"calc(90vh - 48px)",boxSizing:"border-box"},children:s.jsxs("div",{style:{padding:"4px 0 8px",maxWidth:"100%",minWidth:0,boxSizing:"border-box"},children:[s.jsx("div",{className:"flex items-start justify-between gap-3",children:s.jsxs(v,{spacing:10,align:"start",children:[s.jsx(te,{size:22,className:"text-green-600 flex-shrink-0 mt-0.5",strokeWidth:2.4}),s.jsxs("div",{children:[s.jsx(Ce,{strong:!0,style:{fontSize:b?15:17},children:m("API Key å·²å建")}),s.jsx("div",{style:{marginTop:6,color:"hsl(var(--muted-foreground))",fontSize:b?12:13},children:m("请ç«å³å¤å¶ä¿åï¼åç»å¯å¨ä»¤çåè¡¨åæ¬¡æ¥çï¼è¯·å¿æ³é²ç»ä»äºº")})]})]})}),s.jsxs("div",{style:{marginTop:14,display:"flex",alignItems:"center",gap:8,padding:"10px 12px",borderRadius:8,background:"hsl(var(--foreground) / 0.02)",border:"1px solid hsl(var(--border))",minWidth:0,maxWidth:"100%"},children:[s.jsx("span",{style:{flex:1,minWidth:0,fontFamily:"ui-monospace, monospace",fontSize:13,wordBreak:"break-all",overflowWrap:"anywhere"}
1,children:j?z:T}),s.jsx(w,{type:"tertiary",theme:"borderless",icon:j?s.jsx(ae,{size:16}):s.jsx(re,{size:16}),onClick:()=>y(!j),"aria-label":m("æ¾ç¤º/éè")}),s.jsx(w,{type:"tertiary",theme:"borderless",icon:s.jsx(le,{size:16}),onClick:()=>P(c.length>1?c.join("\n"):z)})]}),c.length>1&&s.jsx(Ce,{type:"tertiary",size:"small",style:{display:"block",marginTop:8},children:m("æ¬æ¬¡å
±å建 {{count}} 个令çï¼ç¹å»å¤å¶å°å
å«å
¨é¨å¯é¥ï¼æ¯è¡ä¸ä¸ªï¼",{count:c.length})}),s.jsxs("div",{style:{marginTop:22},children:[s.jsx(Ce,{strong:!0,style:{fontSize:b?14:15},children:m("å¿«éæ¥å
¥")}),s.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:[{id:"openai",name:"OpenAI"},{id:"anthropic",name:"Anthropic"},{id:"gemini",name:"Gemini"}].map(e=>s.jsx(w,{size:"small",type:p===e.id?"primary":"tertiary",theme:p===e.id?"solid":"light",onClick:()=>h(e.id),children:e.name},e.id))}),s.jsxs("div",{style:{marginTop:12,padding:"10px 12px",borderRadius:8,background:"hsl(var(--foreground) / 0.02)",border:"1px solid hsl(var(--border))",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8,minWidth:0,maxWidth:"100%"},children:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs(Ce,{size:"small",style:{wordBreak:"break-all",overflowWrap:"anywhere"},children:["Base URLï¼",q]}),"openai"!==p?s.jsx(Ce,{type:"tertiary",size:"small",style:{display:"block",marginTop:4}}):null]}),s.jsx(w,{type:"tertiary",size:"small",icon:s.jsx(le,{size:16}),style:{flexShrink:0},onClick:()=>P(q),children:m("å¤å¶")})]}),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:[{id:"python",name:"Python"},{id:"node",name:"Node.js"},{id:"curl",name:"cURL"}].map(e=>s.jsx(w,{size:"small",type:x===e.id?"primary":"tertiary",theme:x===e.id?"solid":"light",onClick:()=>g(e.id),children:e.name},e.id))}),s.jsxs("div",{style:{position:"relative",marginTop:10,width:"100%",minWidth:0,maxWidth:"100%"},children:[s.jsx(w,{type:"tertiary",theme:"borderless",icon:s.jsx(le,{size:16}),style:{position:"absolute",right:8,top:8,zIndex:1},onClick:()=>P(O)}),s.jsx("pre",{style:{margin:0,padding:b?"32px 10px 12px":"36px 12px 14px",borderRadius:10,background:"#1e1e1e",color:"#d4d4d4",fontSize:b?11:12,lineHeight:1.55,overflow:"auto",overflowX:"auto",maxHeight:b?220:360,maxWidth:"100%",whiteSpace:"pre-wrap",wordBreak:"break-all",overflowWrap:"anywhere",boxSizing:"border-box"},children:s.jsx("code",{style:{display:"block",whiteSpace:"pre-wrap",wordBreak:"break-all",overflowWrap:"anywhere"},children:O})})]})]})]}),!1,s.jsx("div",{className:"flex justify-end mt-6",children:s.jsx(w,{type:"primary",theme:"solid",onClick:o,children:m("ç¥éäº")})})]})})}const{Text:Ae,Title:Oe}=b,Pe=e=>e<=1?"green":e<=3?"blue":e<=7?"orange":"red",We=e=>[{label:e("æºè½èªå¨"),value:"auto",extra:e("综åä»·æ ¼ãé度ãæåçèªå¨éæ©"),detail:e("å¨å·²éåç»çå¯ç¨æ¸ éå
ï¼ç»¼åä»·æ ¼ãé度ãæåççè¿ææ°æ®èªå¨æåºï¼ä¸æ¯æ§ç auto åç»ã"),icon:ne,accent:"hsl(217 91% 60%)",bg:"hsl(217 91% 60% / 0.1)"},{label:e("ä»·æ ¼ä¼å
"),value:"price",extra:e("ä¼å
éæ©ææ¬æ´ä½çæ¸ é"),detail:e("å¨å¯ç¨æ¸ éå
ä¼å
éæ©ææ¬æ´ä½çæ¸ éï¼éåé¢ç®ææåºæ¯ã"),icon:xe,accent:"hsl(142 71% 36%)",bg:"hsl(142 71% 36% / 0.1)"},{label:e("é度ä¼å
"),value:"speed",extra:e("ä¼å
éæ©ååºæ´å¿«çæ¸ é"),detail:e("å¨å¯ç¨æ¸ éå
ä¼å
éæ©ååºæ´å¿«çæ¸ éï¼éåå¯¹å»¶è¿ææç请æ±ã"),icon:ge,accent:"hsl(32 95% 44%)",bg:"hsl(32 95% 44% / 0.1)"},{label:e("æåçä¼å
"),value:"success_rate",extra:e("ä¼å
éæ©è¿ææ´ç¨³å®çæ¸ é"),detail:e("å¨å¯ç¨æ¸ éå
ä¼å
éæ©è¿ææåçæ´é«çæ¸ éï¼éåç¨³å®æ§ä¼å
åºæ¯ã"),icon:je,accent:"hsl(345 83% 50%)",bg:"hsl(345 83% 50% / 0.1)"}],Be=({value:e,onChange:t,disabled:a,t:r})=>s.jsxs("div",{className:"space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsxs("div",{className:"text-sm font-medium flex-shrink-0",style:{color:"var(--semi-color-text-0)"},children:[r("æºè½è·¯ç±")," ",s.jsx("span",{style:{color:"var(--semi-color-danger)"},children:"*"})]}),s.jsx(Ae,{type:"tertiary",className:"text-xs flex-shrink-0",children:r("请æ±çº§å¯è¦ç")})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Ae,{type:"tertiary",className:"text-xs whitespace-nowrap",children:r(e?"æºè½è·¯ç±å·²å¼å¯":"å·²å
³é")}),s.jsx(O,{checked:!!e,disabled:a,onChange:e=>t(e?"auto":""),"aria-label":r("æºè½è·¯ç±"),size:"small",style:{backgroundColor:e?"hsl(217 91% 60%)":"rgba(0,0,0,0.75)"}})]})]}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:We(r).map(r=>{const l=r.icon,i=(e??"auto")===r.value;return s.jsx("button",{type:"button",disabled:a,"aria-pressed":i,onClick:()=>t(r.value),className:"w-full text-left rounded-lg px-3 py-2.5 transition-all",style:{minHeight:64,border:i?`1px solid ${r.accent}`:"1px solid var(--semi-color-border)",background:i?r.bg:"var(--semi-color-bg-0)",boxShadow:i?`0 0 0 2px ${r.bg}`:"none",cursor:a?"not-allowed":"pointer",opacity:a?.55:1},children:s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx("span",{className:"inline-flex items-center justify-center rounded-md flex-shrink-0",style:{width:28,height:28,color:r.accent,background:i?"var(--semi-color-bg-0)":r.bg},children:s.jsx(l,{size:15})}),s.jsxs("span",{className:"min-w-0",children:[s.jsxs("span",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"block text-sm font-medium truncate",style:{color:"var(--semi-color-text-0)"},children:r.label}),s.jsx(P,{content:r.detail,position:"top",showArrow:!0,style:{maxWidth:280},children:s.jsx(he,{size:14,className:"flex-shrink-0",style:{color:"var(--semi-color-text-2)"}})})]}),s.jsx("span",{className:"block text-xs mt-0.5 leading-snug",style:{color:"var(--semi-color-text-2)",display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden"},children:r.extra})]})]})},r.value)})}),s.jsxs("div",{className:"flex items-start gap-1.5 rounded-md px-2.5 py-1.5 text-xs leading-relaxed",style:{color:"var(--semi-color-text-2)"},children:[s.jsx(pe,{size:14,className:"mt-0.5 flex-shrink-0"}),s.jsx("span",{children:r("API 请æ±ä¸ç模ååç¼å provider.sort ä¼è¦ç令ç级æºè½è·¯ç±ã")})]})]}),Le=({groupValue:e,index:t,group:a,onRemove:r,t:l})=>{const{attributes:i,listeners:n,setNodeRef:o,transform:c,transition:d,isDragging:m}=U({id:e}),u={transform:G.Transform.toString(c),transition:d,opacity:m?.5:1,backgroundColor:"hsl(var(--secondary))",border:m?"1px dashed hsl(var(--primary))":"1px solid hsl(var(--border))",zIndex:m?1e3:"auto"};return s.jsxs("div",{ref:o,style:u,className:"flex items-center justify-between p-2 rounded hover:shadow-sm transition-shadow",children:[s.jsx("div",{...i,...n,className:"cursor-grab active:cursor-grabbing mr-2 p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700",style:{touchAction:"none"},title:l("ææ½è°æ´é¡ºåº"),children:s.jsx(ye,{size:14,style:{color:"hsl(var(--muted-foreground))"}})}),s.jsxs("div",{className:"flex items-center flex-1 min-w-0",children:[s.jsxs(q,{color:"blue",size:"small",className:"mr-2 flex-shrink-0",children:[l("ä¼å
级")," ",t+1]}),s.jsx("span",{className:"font-medium text-sm truncate",children:e}),s.jsx("span",{className:"text-xs ml-2 truncate",style:{color:"hsl(var(--muted-foreground))"},children:a?.description||""})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a?.parsedInfo&&s.jsxs(q,{color:Pe(a.parsedInfo.multiplier),size:"small",children:[a.parsedInfo.multiplier,"å"]}),s.jsx(w,{type:"tertiary",theme:"borderless",size:"small",icon:s.jsx(ue,{size:16}),onClick:r,className:"!w-6 !h-6 !p-0",style:{minWidth:"24px",color:"hsl(var(--muted-foreground))"}})]})]})},Re=({groups:e,selectedGroups:a,onGroupsChange:r})=>{const{t:l}
1=t(),i=Array.isArray(a)?a.filter(Boolean):[],n=W(B(K,{activationConstraint:{distance:8}}),B(F,{coordinateGetter:D}));return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"font-medium",children:l("åç»ä¼å
çº§éæ©")}),s.jsx(Ae,{type:"secondary",className:"text-xs",children:i.length>0?`已鿩 ${i.length} 个åç»`:"æªéæ©åç»"})]}),s.jsx(L,{placeholder:l("éæ©åç»ï¼å¯å¤éï¼éæ©é¡ºåºå³ä¸ºä¼å
级顺åº"),multiple:!0,value:i,onChange:e=>{r(e)},renderSelectedItem:(t,{index:a,onClose:r})=>{let l=t?.value||t?.props?.value||t;!l&&a<i.length&&(l=i[a]);const n=e.find(e=>e.value===l);return n&&n.parsedInfo?{isRenderInTag:!1,content:s.jsx(q,{closable:!0,onClose:r,color:Pe(n.parsedInfo.multiplier),size:"small",className:"!px-3 !py-1",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-medium",children:l}),s.jsx("span",{className:"opacity-75",children:"â¢"}),s.jsxs("span",{className:"text-xs px-1.5 py-0.5 rounded font-mono",style:{backgroundColor:"hsl(var(--foreground) / 0.2)"},children:[n.parsedInfo.multiplier,"Ã"]})]})})}:{isRenderInTag:!1,content:s.jsx(q,{closable:!0,onClose:r,size:"small",className:"!px-3 !py-1",color:"grey",children:s.jsx("span",{className:"font-medium",children:l||`åç»${a+1}`})})}},filter:!0,showClear:!0,maxTagCount:2,showRestTagsPopover:!0,restTagsPopoverProps:{position:"top"},expandRestTagsOnClick:!0,getPopupContainer:()=>document.body,zIndex:1100,dropdownStyle:{maxWidth:"min(100vw - 24px, 560px)",boxSizing:"border-box"},dropdownClassName:"token-group-select-dropdown",className:"w-full",onChangeWithObject:!1,children:e.map(e=>s.jsx(L.Option,{value:e.value,children:e.parsedInfo?s.jsxs("div",{className:"w-full max-w-full box-border py-2 px-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"text-sm font-medium",style:{color:"var(--semi-color-text-0)",wordBreak:"break-word",overflowWrap:"anywhere"},children:e.value}),s.jsx(q,{color:Pe(e.parsedInfo.multiplier),size:"small",className:"!m-0 flex-shrink-0",children:`${e.parsedInfo.multiplier}å`})]}),(e.description||e.parsedInfo.description)&&s.jsx("div",{className:"text-xs mt-1",style:{color:"var(--semi-color-text-2)",wordBreak:"break-word",overflowWrap:"anywhere"},children:e.description||e.parsedInfo.description})]}):s.jsx("div",{className:"py-2 px-3",children:s.jsx("div",{className:"text-sm",children:e.label})})},e.value))}),s.jsxs("div",{className:"mt-2 flex items-start gap-2 rounded-lg border px-3 py-2 text-xs leading-relaxed",style:{color:"var(--semi-color-text-2)",borderColor:"var(--semi-color-border)",backgroundColor:"var(--semi-color-fill-0)"},children:[s.jsx(pe,{size:14,className:"mt-0.5 flex-shrink-0"}),s.jsx("span",{children:l("éæ©é¡ºåºå³å®åç»ä¼å
çº§ï¼æºè½è·¯ç±å³å®æ¸ éæåºï¼æªéæ©æ¶ä½¿ç¨è´¦å·é»è®¤åç»ã")})]})]}),i.length>0&&s.jsxs("div",{className:"mt-3 p-3 rounded-lg",style:{backgroundColor:"hsl(var(--foreground) / 0.02)"},children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx(Ae,{strong:!0,className:"text-sm",children:l("å½åä¼å
级顺åº")}),s.jsx(Ae,{type:"tertiary",className:"text-xs",children:l("ææ½è°æ´é¡ºåº")})]}),s.jsx(R,{sensors:n,collisionDetection:M,onDragEnd:e=>{const{active:s,over:t}=e;if(s.id!==t?.id){const e=i.indexOf(s.id),a=i.indexOf(t.id),l=H(i,e,a);r(l)}},children:s.jsx(V,{items:i,strategy:E,children:s.jsx("div",{className:"space-y-2",children:i.map((t,a)=>{const n=e.find(e=>e.value===t);
1return s.jsx(Le,{groupValue:t,index:a,group:n,t:l,onRemove:()=>{const e=i.filter(e=>e!==t);r(e)}},t)})})})})]})]})},Me=a=>{const{t:l}=t(),[x,g]=e.useState(!1),j=r(),y=e.useRef(null),[b,O]=e.useState([]),[P,W]=e.useState([]),B=void 0!==a.editingToken.id,[L,R]=e.useState([]),[M,V]=e.useState([]),[E,H]=e.useState(!1),[D,F]=e.useState(0),[K,U]=e.useState(!1),[G,J]=e.useState("never"),[Y,X]=e.useState(!1),[Z,Q]=e.useState([]),[ee,se]=e.useState([]),te=a.isBatchMode||!1,[ae,re]=e.useState({routing:!1,group:!1,expiry:!1,quota:!1,modelLimits:!1,allowIps:!1,midjourney:!1}),le=()=>{H(!1),F(0),V([]),U(!1),te&&re({routing:!1,group:!1,expiry:!1,quota:!1,modelLimits:!1,allowIps:!1,midjourney:!1}),J("never"),a.handleClose()},he=(e,s,t,a)=>{let r=(new Date).getTime()/1e3,l=30*e*24*60*60;l+=24*s*60*60,l+=60*t*60,l+=60*a,y.current&&(0!==l?(r+=l,y.current.setValue("expired_time",m(r)),J(1===e&&0===s&&0===t&&0===a?"1m":0===e&&1===s&&0===t&&0===a?"1d":0===e&&0===s&&1===t&&0===a?"1h":"custom")):(y.current.setValue("expired_time",-1),J("never")))},xe=()=>{if(!y.current)return;const e=new Date,s=new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59),t=Math.floor(s.getTime()/1e3);y.current.setValue("expired_time",m(t)),J("eom")},ge=async e=>{let s=await o.get("/api/user/models"+(e?`?group=${e}`:""));const{success:t,message:a,data:r}=s.data;if(t){c(l);let e=r.map(e=>({label:e,value:e}));O(e)}else d(l(a))};e.useEffect(()=>{y.current&&(B||(y.current.setValues({name:"",remain_quota:0,expired_time:-1,unlimited_quota:!0,model_limits_enabled:!1,model_limits:[],allow_ips:"",group:"",routing_priority:"auto",tokenCount:1,mj_image_mode:"default",mj_custom_proxy:"",selected_groups:[]}),J("never"))),ge(),(async()=>{let e=await o.get("/api/user/self/groups");const{success:s,message:t,data:a}=e.data;if(s){let e;if(a&&a.data&&a.ratios){const{data:s,ratios:t}=a;e=Object.keys(s).map(e=>({label:`${e} ${s[e]}`,value:e,description:s[e],parsedInfo:{tag:e,description:s[e],multiplier:t[e]||1}}))}else{if(!a||"object"!=typeof a)return console.error("ð¯ äºå¼åè½ï¼æªç¥çAPIååºæ ¼å¼",a),void d(l("åç»æ°æ®æ ¼å¼é误"));e=Object.entries(a).map(([e,s])=>({label:s.desc,value:e,ratio:s.ratio}))}e=e.filter(e=>"auto"!==e.value);const s=e=>{const s=e.parsedInfo?.multiplier??e.ratio??1,t=Number(s);return Number.isNaN(t)?1:t};e.sort((e,t)=>{const a=s(e),r=s(t);return a!==r?a-r:String(e.value).localeCompare(String(t.value))}),R(e),W(e)}else d(l(t))})()},[a.editingToken.id]),e.useEffect(()=>{if(a.visiable)if(te){const e={name:"",remain_quota:0,expired_time:-1,unlimited_quota:!0,model_limits_enabled:!1,model_limits:[],allow_ips:"",group:"",routing_priority:"auto",tokenCount:1,mj_image_mode:"default",mj_custom_proxy:"",selected_groups:[],unlimited_quota:!1};y.current?.setValues(e),V([]),re({routing:!1,group:!1,expiry:!1,quota:!1,modelLimits:!1,allowIps:!1,midjourney:!1})}else if(B)(async()=>{g(!0);let e=await o.get(`/api/token/${a.editingToken.id}`);const{success:s,message:t,data:r}=e.data;if(s){-1!==r.expired_time&&(r.expired_time=m(r.expired_time)),r.model_limits=u(r.model_limits);try{p&&"function"==typeof p&&(r.remain_quota=p(r.remain_quota))}catch(l){console.error("ð¯ äºå¼åè½ï¼é¢åº¦è½¬æ¢åºé",l)}const e=r.group?r.group.split(",").map(e=>e.trim()).filter(e=>e&&"auto"!==e):[];V(e);const{group:s,...t}=r;y.current&&y.current.setValues({name:"",remain_quota:0,expired_time:-1,unlimited_quota:!0,model_limits_enabled:!1,model_limits:[],allow_ips:"",group:"",routing_priority:"auto",tokenCount:1,mj_image_mode:"default",mj_custom_proxy:"",selected_groups:[],...t,routing_priority:t.routing_priority??"auto",group:e.length>0?e[0]:"",selected_groups:e}),J(-1===r.expired_time?"never":"custom"),e.length>0&&ge(e[0])}else d(t);g(!1)})();else{J("never");const e={name:"",remain_quota:0,expired_time:-1,unlimited_quota:!0,model_limits_enabled:!1,model_limits:[],allow_ips:"",group:"",routing_priority:"auto",tokenCount:1,mj_image_mode:"default",mj_custom_proxy:"",selected_groups:[]};y.current?.setValues(e),V([])}else y.current?.reset(),V([]),J("never")},[a.visiable,a.editingToken.id]);const je=()=>{let e="";for(let s=0;s<6;s++)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return e},ye=e=>{const s=e.filter(Boolean);V(s);const t=s[0]||"";y.current&&(y.current.setValue("group",t),y.current.setValue("selected_groups",s)),t&&ge(t)},fe=()=>{H(!0)};return s.jsxs(s.Fragment,{children:[s.jsx(qe,{visible:Y,keys:Z,groups:ee,onClose:()=>{X(!1),Q([]),se([])}}),s.jsx(_,{placement:te||B?"right":"left",title:s.jsxs(v,{children:[te?s.jsx(q,{color:"orange",shape:"circle",children:l("æ¹éä¿®æ¹")}):B?s.jsx(q,{color:"blue",shape:"circle",children:l("æ´æ°")}):s.jsx(q,{color:"green",shape:"circle",children:l("æ°å»º")}),s.jsx(Oe,{heading:4,className:"m-0",children:te?`${l("æ¹éä¿®æ¹ä»¤ç")} (${a.batchTokenIds?.length||0}
1)`:l(B?"æ´æ°ä»¤çä¿¡æ¯":"å建æ°ç令ç")})]}),bodyStyle:{padding:"0"},visible:a.visiable,width:j?"100%":600,footer:s.jsx("div",{className:"flex justify-end p-4",style:{backgroundColor:"hsl(var(--secondary))"},children:s.jsxs(v,{children:[s.jsx(w,{theme:"solid",className:"!rounded-lg",onClick:()=>y.current?.submitForm(),icon:s.jsx(me,{size:16}),loading:x,children:l("æäº¤")}),s.jsx(w,{theme:"light",className:"!rounded-lg",type:"primary",onClick:le,icon:s.jsx(ue,{size:16}),children:l("åæ¶")})]})}),closeIcon:null,onCancel:()=>le(),children:s.jsx(k,{spinning:x,children:s.jsx(N,{initValues:{name:"",remain_quota:0,expired_time:-1,unlimited_quota:!0,model_limits_enabled:!1,model_limits:[],allow_ips:"",group:"",routing_priority:"auto",tokenCount:1,mj_image_mode:"default",mj_custom_proxy:"",selected_groups:[]},getFormApi:e=>y.current=e,onSubmit:async e=>{if(te)return(async e=>{const s=a.batchTokenIds||[];if(0!==s.length)if(0!==Object.entries(ae).filter(([,e])=>e).length){g(!0);try{const r={ids:s},n=[];if(ae.group){n.push("group");const s=M.filter(Boolean);r.group=s.length>0?s.join(","):e.group||""}if(ae.routing&&(n.push("routing_priority"),r.routing_priority=e.routing_priority??""),ae.expiry)if(n.push("expired_time"),-1!==e.expired_time){let s=Date.parse(e.expired_time);if(isNaN(s))return d(l("è¿ææ¶é´æ ¼å¼é误ï¼")),void g(!1);r.expired_time=Math.ceil(s/1e3)}else r.expired_time=-1;if(ae.quota){n.push("remain_quota"),n.push("unlimited_quota");try{r.remain_quota=h&&"function"==typeof h?parseInt(h(e.remain_quota)):parseInt(e.remain_quota)}catch(t){r.remain_quota=parseInt(e.remain_quota)}r.unlimited_quota=e.unlimited_quota}ae.modelLimits&&(n.push("model_limits"),r.model_limits=e.model_limits.join(","),r.model_limits_enabled=e.model_limits.length>0),ae.allowIps&&(n.push("allow_ips"),r.allow_ips=e.allow_ips||""),ae.midjourney&&(n.push("mj_image_mode"),n.push("mj_custom_proxy"),r.mj_image_mode=e.mj_image_mode||"default",r.mj_custom_proxy=e.mj_custom_proxy||""),r.update_fields=n;const c=await o.put("/api/token/batch",r);c?.data?.success?(i(l("å·²æ¹éæ´æ° {{num}} 个令çï¼",{num:c.data.data||0})),a.refresh(),a.handleClose()):d(c?.data?.message||l("æ¹éæ´æ°å¤±è´¥"))}catch(r){d(r.message)}g(!1),y.current?.setValues({name:"",remain_quota:0,expired_time:-1,unlimited_quota:!0,model_limits_enabled:!1,model_limits:[],allow_ips:"",group:"",routing_priority:"auto",tokenCount:1,mj_image_mode:"default",mj_custom_proxy:"",selected_groups:[]}),V([]),re({routing:!1,group:!1,expiry:!1,quota:!1,modelLimits:!1,allowIps:!1,midjourney:!1})}else d(l("请è³å°éæ©ä¸ä¸ªè¦ä¿®æ¹çåæ®µï¼"));else d(l("没æéæ©è¦ä¿®æ¹ç令çï¼"))})(e);if(g(!0),B){let{tokenCount:t,...r}=e;try{r.remain_quota=h&&"function"==typeof h?parseInt(h(r.remain_quota)):parseInt(r.remain_quota)}catch(s){console.error("ð¯ äºå¼åè½ï¼é¢åº¦è½¬æ¢åºé",s),r.remain_quota=parseInt(r.remain_quota)}if(-1!==r.expired_time){let e=Date.parse(r.expired_time);if(isNaN(e))return d(l("è¿ææ¶é´æ ¼å¼é误ï¼")),void g(!1);r.expired_time=Math.ceil(e/1e3)}r.model_limits=r.model_limits.join(","),r.model_limits_enabled=r.model_limits.length>0,r.routing_priority=r.routing_priority??"auto";const n=M.filter(Boolean),c=n.length>0?n.join(","):r.group;r.group=c;let m=await o.put("/api/token/",{...r,id:parseInt(a.editingToken.id)});const{success:u,message:p}=m.data;u?(i(l("ä»¤çæ´æ°æåï¼")),a.refresh(),a.handleClose()):d(l(p))}else{const t=parseInt(e.tokenCount,10)||1;let r=0;const n=[];for(let a=0;a<t;a++){let{tokenCount:t,...i}=e;const c=""===e.name.trim()?"default":e.name.trim();0!==a||""===e.name.trim()?i.name=`${c}-${je()}`:i.name=c;try{i.remain_quota=h&&"function"==typeof h?parseInt(h(i.remain_quota)):parseInt(i.remain_quota)}catch(s){console.error("ð¯ äºå¼åè½ï¼å建令ç-é¢åº¦è½¬æ¢åºé",s),i.remain_quota=parseInt(i.remain_quota)}if(-1!==i.expired_time){let e=Date.parse(i.expired_time);if(isNaN(e)){d(l("è¿ææ¶é´æ ¼å¼é误ï¼")),g(!1);break}i.expired_time=Math.ceil(e/1e3)}i.model_limits=i.model_limits.join(","),i.model_limits_enabled=i.model_limits.length>0,i.routing_priority=i.routing_priority??"auto";
1const m=M.filter(Boolean).join(",");i.group=m;let u=await o.post("/api/token/",i);const{success:p,message:x}=u.data;if(!p){d(l(x));break}{r++;const e=u.data?.data;"string"==typeof e&&e.startsWith("sk-")&&n.push(e)}}r>0&&(a.refresh(),a.handleClose(),n.length>0?(Q(n),se(M.filter(Boolean)),X(!0)):i(l("令çå建æåï¼è¯·å¨å表页é¢ç¹å»å¤å¶è·å令çï¼")))}g(!1),y.current?.setValues({name:"",remain_quota:0,expired_time:-1,unlimited_quota:!0,model_limits_enabled:!1,model_limits:[],allow_ips:"",group:"",routing_priority:"auto",tokenCount:1,mj_image_mode:"default",mj_custom_proxy:"",selected_groups:[]}),V([]),J("never")},children:({values:e})=>s.jsxs("div",{className:"p-6 space-y-6",children:[s.jsx(N.Input,{field:"routing_priority",style:{display:"none"}}),s.jsxs(C,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-4",children:[s.jsx(S,{size:"small",color:"blue",className:"mr-3 shadow-md",children:s.jsx(ie,{size:16})}),s.jsxs("div",{children:[s.jsx(Ae,{className:"text-lg font-medium",children:l("åºæ¬ä¿¡æ¯")}),s.jsx("div",{className:"text-sm mt-1",style:{color:"hsl(var(--muted-foreground))"},children:l(te?"å¾ééè¦ä¿®æ¹çåæ®µ":"设置令ççåºæ¬ä¿¡æ¯")})]})]}),s.jsxs($,{gutter:16,children:[!te&&s.jsx(z,{span:24,children:s.jsx(N.Input,{field:"name",label:l("åç§°"),placeholder:l("请è¾å
¥åç§°"),rules:[{required:!0,message:l("请è¾å
¥åç§°")}],showClear:!0})}),s.jsxs(z,{span:24,children:[te&&s.jsx(I,{checked:ae.routing,onChange:e=>re(s=>({...s,routing:e.target.checked})),className:"mb-2",children:s.jsx(Ae,{strong:!0,children:l("ä¿®æ¹æºè½è·¯ç±")})}),s.jsxs("div",{style:te&&!ae.routing?{opacity:.4,pointerEvents:"none"}:{},children:[s.jsx(Be,{value:e.routing_priority,disabled:te&&!ae.routing,t:l,onChange:e=>{y.current?.setValue("routing_priority",e)}}),e.routing_priority?s.jsxs("div",{className:"flex items-start gap-1.5 mt-2 rounded-md px-2.5 py-2 text-xs leading-relaxed",style:{backgroundColor:"hsl(217 91% 60% / 0.08)",color:"hsl(217 60% 45%)"},children:[s.jsx(ne,{size:13,className:"mt-0.5 flex-shrink-0"}),s.jsx("span",{children:l("æºè½è·¯ç±å·²æ¿æ´» â ç³»ç»èªå¨å¨æ¨ææå¯è®¿é®åç»ä¸éæ©æä¼æ¸ éï¼ä»¥ä¸åç»è®¾ç½®å°è¢«å¿½ç¥ã")})]}):s.jsx("div",{className:"flex items-start gap-1.5 mt-2 rounded-md px-2.5 py-2 text-xs leading-relaxed",style:{backgroundColor:"hsl(0 0% 50% / 0.08)",color:"var(--semi-color-text-2)"},children:s.jsx("span",{children:l("æºè½è·¯ç±å·²å
³é â 尿䏿¹æå¨éæ©çåç»è·¯ç±è¯·æ±ã")})})]})]}),s.jsxs(z,{span:24,children:[te&&s.jsx(I,{checked:ae.group,onChange:e=>re(s=>({...s,group:e.target.checked})),className:"mb-2",children:s.jsx(Ae,{strong:!0,children:l("ä¿®æ¹åç»")})}),s.jsx("div",{style:te&&!ae.group||!te&&e.routing_priority?{opacity:.4,pointerEvents:"none"}:{},children:L.length>0?s.jsx("div",{children:s.jsx(Re,{groups:L,selectedGroups:M,onGroupsChange:ye})}):s.jsxs("div",{children:[s.jsx(Ae,{strong:!0,className:"block mb-2",children:l("令çåç»")}),s.jsxs("div",{className:"text-center py-8",style:{color:"hsl(var(--muted-foreground))"},children:[s.jsx(oe,{size:48,className:"mx-auto mb-4 opacity-30"}),s.jsx(Ae,{type:"secondary",children:l("æ£å¨å è½½åç»æ°æ®...")}),s.jsx(Ae,{type:"tertiary",className:"block text-sm mt-2",children:l("å¦æé¿æ¶é´æªæ¾ç¤ºï¼è¯·æ£æ¥ç½ç»è¿æ¥æå·æ°é¡µé¢")})]})]})})]}),s.jsxs(z,{span:24,children:[te&&s.jsx(I,{checked:ae.expiry,onChange:e=>re(s=>({...s,expiry:e.target.checked})),className:"mb-2",children:s.jsx(Ae,{strong:!0,children:l("ä¿®æ¹è¿ææ¶é´")})}),s.jsx("div",{style:te&&!ae.expiry?{opacity:.4,pointerEvents:"none"}:{},children:s.jsxs($,{gutter:16,children:[s.jsx(z,{xs:24,sm:24,md:24,lg:12,xl:12,children:s.jsx(N.DatePicker,{field:"expired_time",label:l("è¿ææ¶é´"),type:"dateTime",placeholder:l("è¯·éæ©è¿ææ¶é´"),rules:te?[]:[{required:!0,message:l("è¯·éæ©è¿ææ¶é´")},{validator:(e,s)=>{if(-1===s||!s)return Promise.resolve();const t=Date.parse(s);return isNaN(t)?Promise.reject(l("è¿ææ¶é´æ ¼å¼é误ï¼")):t<=Date.now()?Promise.reject(l("è¿ææ¶é´ä¸è½æ©äºå½åæ¶é´ï¼")):Promise.resolve()}}],showClear:!0,onChange:e=>{J(-1===e||null==e?"never":"custom")}})}),s.jsx(z,{xs:24,sm:24,md:24,lg:12,xl:12,children:s.jsx(N.Slot,{label:te?"":l("è¿ææ¶é´å¿«æ·è®¾ç½®"),children:s.jsxs(v,{wrap:!0,children:[s.jsx(w,{theme:"light",type:"never"===G?"primary":"tertiary",size:"small",onClick:()=>he(0,0,0,0),className:"!rounded-lg",children:l("æ°¸ä¸è¿æ")}),s.jsx(w,{theme:"light",type:"1m"===G?"primary":"tertiary",size:"small",onClick:()=>he(1,0,0,0),className:"!rounded-lg",children:l("ä¸ä¸ªæ")}),s.jsx(w,{theme:"light",type:"1d"===G?"primary":"tertiary",size:"small",onClick:()=>he(0,1,0,0),className:"!rounded-lg",children:l("ä¸å¤©")}),s.jsx(w,{theme:"light",type:"1h"===G?"primary":"tertiary",size:"small",onClick:()=>he(0,0,1,0),className:"!rounded-lg",children:l("ä¸å°æ¶")}),s.jsx(w,{theme:"light",type:"eom"===G?"primary":"tertiary",size:"small",onClick:xe,className:"!rounded-lg",children:l("æåº")})]})})})]})})]}),!B&&!te&&s.jsx(z,{span:24,children:s.jsx(N.InputNumber,{field:"tokenCount",label:l("æ°å»ºæ°é"),min:1,extraText:l("æ¹éå建æ¶ä¼å¨åç§°åèªå¨æ·»å éæºåç¼"),rules:[{required:!0,message:l("请è¾å
¥æ°å»ºæ°é")}]})})]})]}),s.jsxs(C,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-4",children:[te&&s.jsx(I,{checked:ae.quota,onChange:e=>re(s=>({...s,quota:e.target.checked})),className:"mr-2"}),s.jsx(S,{size:"small",color:"green",className:"mr-3 shadow-md",children:s.jsx(ce,{size:16})}),s.jsxs("div",{children:[s.jsx(Ae,{className:"text-lg font-medium",children:l("é¢åº¦è®¾ç½®")}),s.jsx("div",{className:"text-sm mt-1",style:{color:"hsl(var(--muted-foreground))"}
1,children:l("设置令çå¯ç¨é¢åº¦åæ°é")})]})]}),s.jsx("div",{style:te&&!ae.quota?{opacity:.4,pointerEvents:"none"}:{},children:s.jsxs($,{gutter:16,children:[s.jsx(z,{span:24,children:s.jsxs("div",{className:"flex gap-3",children:[s.jsx(N.AutoComplete,{field:"remain_quota",label:l("é¢åº¦"),placeholder:l("请è¾å
¥é¢åº¦"),type:"number",disabled:e.unlimited_quota,extraText:(()=>{if(!e.remain_quota)return"";const s=parseFloat(e.remain_quota);if(isNaN(s))return"";const t=parseFloat(localStorage.getItem("quota_per_unit"))||5e5;return n(s*t,2)})(),rules:e.unlimited_quota||te?[]:[{required:!0,message:l("请è¾å
¥é¢åº¦")}],data:[{value:1,label:"1$"},{value:10,label:"10$"},{value:50,label:"50$"},{value:100,label:"100$"},{value:500,label:"500$"},{value:1e3,label:"1000$"},{value:5e3,label:"5000$"},{value:1e4,label:"10000$"},{value:5e4,label:"50000$"},{value:1e5,label:"100000$"},{value:5e5,label:"500000$"},{value:1e6,label:"1000000$"}],className:"flex-1"}),s.jsx(w,{theme:"light",onClick:fe,disabled:e.unlimited_quota,className:"mt-8 !rounded-lg",children:l("å¢å é¢åº¦")})]})}),s.jsx(z,{span:24,children:s.jsx(N.Switch,{field:"unlimited_quota",label:l("æ éé¢åº¦"),size:"large",extraText:l("令ççé¢åº¦ä»
ç¨äºéå¶ä»¤çæ¬èº«çæå¤§é¢åº¦ä½¿ç¨éï¼å®é
ç使ç¨åå°è´¦æ·çå©ä½é¢åº¦éå¶")})})]})})]}),s.jsxs(C,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-4",children:[te&&s.jsx(I,{checked:ae.modelLimits,onChange:e=>re(s=>({...s,modelLimits:e.target.checked})),className:"mr-2"}),s.jsx(S,{size:"small",color:"purple",className:"mr-3 shadow-md",children:s.jsx(de,{size:16})}),s.jsxs("div",{children:[s.jsx(Ae,{className:"text-lg font-medium",children:l("访é®éå¶")}),s.jsx("div",{className:"text-sm mt-1",style:{color:"hsl(var(--muted-foreground))"},children:l("设置令çç访é®éå¶")})]})]}),s.jsx("div",{style:te&&!ae.modelLimits?{opacity:.4,pointerEvents:"none"}:{},children:s.jsxs($,{gutter:16,children:[s.jsx(z,{span:24,children:s.jsx(N.Select,{field:"model_limits",label:l("模åéå¶å表"),placeholder:l("è¯·éæ©è¯¥ä»¤çæ¯æç模åï¼çç©ºæ¯ææææ¨¡å"),multiple:!0,optionList:b,extraText:l("éå¿
è¦ï¼ä¸å»ºè®®å¯ç¨æ¨¡åéå¶"),searchPosition:"dropdown",searchPlaceholder:l("æç´¢æ¨¡å..."),filter:(e,s)=>{if(!e)return!0;const t=(s?.value||"").toString(),a=(s?.label||s?.value||"").toString(),r=e.toString().toLowerCase();return t.toLowerCase().includes(r)||a.toLowerCase().includes(r)},showFilteredOnly:!0,showClear:!0})}),s.jsxs(z,{span:24,children:[te&&s.jsx(I,{checked:ae.allowIps,onChange:e=>re(s=>({...s,allowIps:e.target.checked})),className:"mb-2",children:s.jsx(Ae,{strong:!0,children:l("ä¿®æ¹IPç½åå")})}),s.jsx("div",{style:te&&!ae.allowIps?{opacity:.4,pointerEvents:"none"}:{},children:s.jsx(N.TextArea,{field:"allow_ips",label:l("IPç½åå"),placeholder:l("å
许çIPï¼ä¸è¡ä¸ä¸ªï¼ä¸å¡«ååä¸éå¶"),autosize:!0,rows:2,extraText:l("请å¿è¿åº¦ä¿¡ä»»æ¤åè½ï¼IPå¯è½è¢«ä¼ªé "),showClear:!0})})]})]})})]}),s.jsxs(C,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-4",children:[te&&s.jsx(I,{checked:ae.midjourney,onChange:e=>re(s=>({...s,midjourney:e.target.checked})),className:"mr-2"}),s.jsx(S,{size:"small",color:"violet",className:"mr-3 shadow-md",children:s.jsx(T,{size:16})}),s.jsxs("div",{children:[s.jsx(Ae,{className:"text-lg font-medium",children:l("Midjourney 设置")}),s.jsx("div",{className:"text-sm mt-1",style:{color:"hsl(var(--muted-foreground))"},children:l("é
ç½®å¾çä»£çæ¹å¼")})]})]}),s.jsx("div",{style:te&&!ae.midjourney?{opacity:.4,pointerEvents:"none"}:{},children:s.jsxs($,{gutter:16,children:[s.jsx(z,{span:24,children:s.jsx(N.Select,{field:"mj_image_mode",label:l("å¾çä»£çæ¹å¼"),placeholder:l("è¯·éæ©å¾çä»£çæ¹å¼"),optionList:[{value:"default",label:l("é»è®¤")}
1,{value:"origin",label:l("(origin) Discord å龿¥(å½å¤å¾å¿«ï¼å½å
æ æ³è®¿é®)")},{value:"proxy",label:l("(proxy) å¾ç代çå°å(å½å¤å¾æ
¢ï¼å½å
å¯ä»¥è®¿é®)")}]})}),"proxy"===e.mj_image_mode&&s.jsx(z,{span:24,children:s.jsx(N.Input,{field:"mj_custom_proxy",label:l("èªå®ä¹å¾ç代ç"),placeholder:l("请è¾å
¥èªå®ä¹å¾ç代çå°å"),extraText:l("æ¿æ¢ https://cdn.discordapp.com çå°åï¼å¿
须以 httpsï¼http å¼å¤´"),showClear:!0})})]})})]})]})},B?"edit":"new")})}),s.jsx(f,{title:s.jsxs("div",{className:"flex items-center",children:[s.jsx(S,{size:"extra-small",color:"green",className:"mr-2",children:s.jsx(ce,{size:12})}),l("å¢å é¢åº¦")]}),visible:E,onOk:()=>{const e=y.current?.getValue("remain_quota")||0,s=parseFloat(e)+parseFloat(D);y.current?.setValue("remain_quota",s.toFixed(2)),H(!1),F(0)},onCancel:()=>H(!1),closeOnEsc:!0,centered:!0,className:"!rounded-2xl",okText:l("确认å¢å "),cancelText:l("åæ¶"),children:s.jsxs("div",{className:"py-4",children:[s.jsx("div",{className:"mb-2",children:s.jsx("label",{className:"text-sm font-medium",children:l("å¢å éé¢")})}),s.jsx(A,{prefix:"$",placeholder:l("请è¾å
¥è¦å¢å çé¢åº¦"),value:D,onChange:e=>F(e),className:"w-full",min:0,step:1,precision:2})]})}),s.jsx(f,{title:s.jsxs("div",{className:"flex items-center",children:[s.jsx(S,{size:"extra-small",color:"blue",className:"mr-2",children:s.jsx(pe,{size:12})}),l("åç»è¯´æ")]}),visible:K,onOk:()=>U(!1),onCancel:()=>U(!1),width:700,centered:!0,className:"!rounded-2xl",footer:s.jsx("div",{className:"flex justify-center",children:s.jsx(w,{type:"primary",theme:"solid",onClick:()=>U(!1),className:"!rounded-lg px-8",children:l("ç¥éäº")})}),children:s.jsx("div",{className:"py-4",children:s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx(Oe,{heading:4,className:"mb-4",children:l("åç»ç¹ç¹åéæ©æå")}),s.jsx(Ae,{type:"secondary",children:l("æä»¬çåç»ç³»ç»ç»è¿ç²¾å¿è®¾è®¡ï¼æ¨å¨æ»¡è¶³ä¸åç¨æ·ç夿 ·åéæ±ãæ¯ä¸ªåç»é½æå
¶ç¬ç¹çä¼å¿ï¼æ¨å¯ä»¥æ ¹æ®èªèº«éæ±éæ©æéåçåç»ã")})]}),s.jsxs("div",{children:[s.jsx(Oe,{heading:5,className:"mb-3",children:l("åç»ç¹ç¹å¯¹æ¯")}),s.jsx("div",{className:"p-4 rounded-lg space-y-3",style:{backgroundColor:"hsl(var(--foreground) / 0.02)"},children:P.map((e,t)=>{const a=e.parsedInfo?.multiplier??e.ratio??1,r=e.parsedInfo?.description||e.label||e.description||"";return s.jsx(C,{className:"!rounded-lg border p-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx(Ae,{strong:!0,children:e.value}),s.jsx(Ae,{type:"secondary",className:"block text-sm mt-1",children:r})]}),s.jsxs(q,{color:Pe(a),children:[a,"å"]})]})},`${e.value}-${t}`)})})]}),s.jsxs("div",{children:[s.jsx(Oe,{heading:5,className:"mb-3",children:l("éæ©å»ºè®®")}),s.jsx("div",{className:"space-y-2",children:[l("é¢ç®ä¼å
ï¼éæ©ä½åçåç»ï¼æ§ä»·æ¯æ´é«"),l('稳å®ä¼å
ï¼éæ©æ 注"ç¨³å®æ§é«"çåç»ï¼è½ç¶è´¹çè¾é«ä½æå¡æ´å¯é '),l("åè¡¡éæ©ï¼å¯ä»¥éæ©ä¸çåçåç»ï¼å¨ææ¬åç¨³å®æ§é´åå¾å¹³è¡¡")].map((e,t)=>s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"w-2 h-2 rounded-full mt-2 mr-3 flex-shrink-0",style:{backgroundColor:"hsl(var(--primary))"}}),s.jsx(Ae,{children:e})]},`suggestion-${t}`))})]})]})})})]})},{Text:Ve}=b;function Ee(e){return s.jsx(s.Fragment,{children:m(e)})}const He=()=>{const{t:a}=t(),r=Ne(),[n,m]=e.useState(null),p=[{title:a("åç§°"),dataIndex:"name"},{mobileTitle:a("ç¶æ"),title:s.jsxs("span",{className:"inline-flex items-center gap-1 select-none",children:[s.jsx("span",{children:a("ç¶æ")}),s.jsxs("span",{className:"inline-flex flex-col justify-center cursor-pointer",style:{gap:-2,lineHeight:0},role:"group","aria-label":a("æå©ä½é¢åº¦æåº"),onClick:e=>e.stopPropagation(),children:[s.jsx(fe,{size:11,style:{display:"block",color:"asc"===n?"hsl(var(--primary))":"hsl(var(--muted-foreground))",marginBottom:-3},onClick:e=>{e.stopPropagation(),"asc"===n?(m(null),R(1),ue(1,h,null)):(m("asc"),R(1),ue(1,h,"asc"))}}),s.jsx(ve,{size:11,style:{display:"block",color:"desc"===n?"hsl(var(--primary))":"hsl(var(--muted-foreground))"},onClick:e=>{e.stopPropagation(),"desc"===n?(m(null),R(1),ue(1,h,null)):(m("desc"),R(1),ue(1,h,"desc"))}})]})]}),dataIndex:"status",key:"status",render:(e,t)=>{const r=1===e,l=parseInt(t.used_quota)||0,i=parseInt(t.remain_quota)||0,n=l+i,o=n>0?i/n*100:0;let c="black",d=a("æªç¥ç¶æ");r?0!==o||t.unlimited_quota?(c="green",d=a("å·²å¯ç¨")):(c="yellow",d=a("å·²ç¨å°½")):2===e?(c="red",d=a("å·²ç¦ç¨")):3===e?(c="yellow",d=a("å·²è¿æ")):4===e&&(c="grey",d=a("å·²èå°½"));const m="green"===c?"hsl(var(--success))":"red"===c?"hsl(var(--destructive))":"yellow"===c?"hsl(var(--warning))":"hsl(var(--muted-foreground))",u=s.jsxs("div",{className:"flex flex-col gap-1 items-end",style:{minWidth:120},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(O,{size:"small",checked:r,onChange:e=>
1{xe(t.id,e?"enable":"disable",t)},"aria-label":"token status switch"}),s.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-foreground",children:[s.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:m}}),d]})]}),t.unlimited_quota?s.jsx("span",{className:"text-[11px] text-foreground/40 text-right",children:a("æ éé¢åº¦")}):s.jsxs("div",{className:"space-y-0.5 w-full",children:[s.jsxs("div",{className:"flex justify-between text-[11px] text-foreground/50",children:[s.jsx("span",{children:x(i)}),s.jsxs("span",{className:"text-foreground/30",children:["/ ",x(n)]})]}),s.jsx(J,{percent:0===o?1:o,stroke:(p=o,100===p?"hsl(var(--success))":0===p?"hsl(var(--warning))":p<=10?"hsl(var(--destructive))":p<=30?"hsl(var(--warning))":void 0),showInfo:!1,"aria-label":"quota usage",style:{width:"100%",marginTop:0,marginBottom:0}})]})]});var p;return t.unlimited_quota?s.jsx(P,{content:s.jsx("div",{className:"text-xs",children:s.jsxs("div",{children:[a("å·²ç¨é¢åº¦"),": ",x(l)]})}),position:"top",showArrow:!0,children:u}):s.jsx(P,{content:s.jsxs("div",{className:"text-xs",children:[s.jsxs("div",{children:[a("å·²ç¨é¢åº¦"),": ",x(l)]}),s.jsxs("div",{children:[a("å©ä½é¢åº¦"),": ",x(i)," (",o.toFixed(0),"%)"]}),s.jsxs("div",{children:[a("æ»é¢åº¦"),": ",x(n)]})]}),children:u})}},{title:a("åç»"),dataIndex:"group",key:"group",render:e=>"auto"===e?s.jsx(P,{content:a("æ§ç auto åç»å·²ä¸åä½ä¸ºæ°ä»¤çå
¥å£ï¼è¯·æ¹ç¨ä»¤çæºè½è·¯ç±ã"),position:"top",children:s.jsxs(q,{color:"orange",shape:"circle",children:[" ",a("æ§ auto åç»")," "]})}):g(e)},{title:a("æºè½è·¯ç±"),dataIndex:"routing_priority",key:"routing_priority",render:e=>{if(!e)return s.jsx(q,{color:"grey",shape:"circle",children:a("æå¨")});const t={auto:{color:"blue",label:a("æºè½èªå¨")},price:{color:"green",label:a("ä»·æ ¼ä¼å
")},speed:{color:"orange",label:a("é度ä¼å
")},success_rate:{color:"red",label:a("æåçä¼å
")}}[e]||{color:"grey",label:a("æªè®¾ç½®")};return s.jsx(q,{color:t.color,shape:"circle",children:t.label})}},{title:a("å¯é¥"),key:"token_key",render:(e,t)=>{const a="sk-"+t.key,r="sk-"+t.key.slice(0,4)+"**********"+t.key.slice(-4),l=!!K[t.id];return s.jsx("div",{className:"w-[210px]",children:s.jsx(Y,{readOnly:!0,value:l?a:r,size:"small",suffix:s.jsxs("div",{className:"flex items-center",children:[s.jsx(w,{theme:"borderless",size:"small",type:"tertiary",icon:l?s.jsx(re,{size:16}):s.jsx(ae,{size:16}),"aria-label":"toggle token visibility",onClick:e=>{e.stopPropagation(),U(e=>({...e,[t.id]:!l}))}}),s.jsx(w,{theme:"borderless",size:"small",type:"tertiary",icon:s.jsx(le,{size:16}),"aria-label":"copy token key",onClick:async e=>{e.stopPropagation(),await he(a)}})]})})})}},{title:a("å¯ç¨æ¨¡å"),dataIndex:"model_limits",render:(e,t)=>{if(t.model_limits_enabled&&e){const t=u(e),r=c(a),l=[],i=new Set;Object.entries(r).forEach(([e,a])=>{if("all"===e)return;if(!a.icon||!a.filter)return;const r=t.filter(e=>a.filter({model_name:e}));r.length>0&&(l.push(s.jsx(P,{content:r.join(", "),position:"top",showArrow:!0,children:s.jsx(S,{size:"extra-extra-small",alt:a.label,style:{background:"transparent"},children:a.icon})},e)),r.forEach(e=>i.add(e)))});const n=t.filter(e=>!i.has(e));return n.length>0&&l.push(s.jsx(P,{content:n.join(", "),position:"top",showArrow:!0,children:s.jsx(S,{size:"extra-extra-small",alt:"unknown",children:a("å
¶ä»")})},"unknown")),s.jsx(X,{size:"extra-extra-small",children:l})}return s.jsx(q,{color:"white",shape:"circle",children:a("æ éå¶")})}},{title:a("IPéå¶"),dataIndex:"allow_ips",render:e=>{if(!e||""===e.trim())return s.jsx(q,{color:"white",shape:"circle",children:a("æ éå¶")});const t=e.split("\n").map(e=>e.trim()).filter(Boolean),r=t.slice(0,1),l=t.length-r.length,i=r.map((e,t)=>s.jsx(q,{shape:"circle",children:e},t));return l>0&&i.push(s.jsx(P,{content:t.slice(1).join(", "),position:"top",showArrow:!0,children:s.jsx(q,{shape:"circle",children:"+"+l})},"extra")),s.jsx(v,{wrap:!0,children:i})}},{title:a("å建æ¶é´"),dataIndex:"created_time",render:(e,t,a)=>s.jsx("div",{children:Ee(e)})},{title:a("è¿ææ¶é´"),dataIndex:"expired_time",render:(e,t,r)=>s.jsx("div",{children:-1===t.expired_time?a("æ°¸ä¸è¿æ"):Ee(e)})},{title:"",dataIndex:"operate",fixed:"right",render:(e,t,r)=>s.jsxs(v,{wrap:!0,children:[s.jsx(w,{type:"tertiary",size:"small",onClick:()=>{H(t),k(!0)},children:a("ç¼è¾")}),s.jsx(w,{theme:"borderless",type:"danger",size:"small",onClick:()=>{f.confirm({title:a("ç¡®å®æ¯å¦è¦å 餿¤ä»¤çï¼"),content:a("æ¤ä¿®æ¹å°ä¸å¯é"),onOk:()=>{(async()=>{await xe(t.id,"delete",t),await pe()})()}})},children:a("å é¤")})]})}],[h,b]=e.useState(j),[_,k]=e.useState(!1),[C,$]=e.useState([]),[z,I]=e.useState([]),[T,A]=e.useState(h),[W,B]=e.useState(!0),[L,R]=e.useState(1),[M,V]=e.useState(!1),[E,H]=e.useState({id:void 0}),[D,F]=we("tokens"),[K,U]=e.useState({}),[G,se]=e.useState(!1),[te,ne]=e.useState([]),[oe,ce]=e.useState(!1),[de,me]=e.useState(null),ue=async(e=1,s=h,t)=>{B(!0);try{const a=void 0!==t?t:n,{searchKeyword:l,searchToken:i,searchGroup:c}=(()=>{const e=de?de.getValues():{};return{searchKeyword:e.searchKeyword||"",searchToken:e.searchToken||"",searchGroup:e.searchGroup||""}})(),m=new URLSearchParams;m.set("p",e),m.set("size",s),l&&m.set("keyword",l),i&&m.set("token",
1i),c&&m.set("group",c),"asc"!==a&&"desc"!==a||(m.set("sort","remain_quota"),m.set("order",a));const u=await o.get(`/api/token/filter?${m.toString()}`),{success:p,message:x,data:g}=u.data;p?($((r=g).items||[]),A(r.total||0),R(r.page||1),b(r.page_size||h)):d(x)}catch(l){console.error("å 载令çå表失败:",l),d(a("å 载令çå表失败ï¼è¯·éè¯"))}finally{B(!1)}var r},pe=async(e=L)=>{await ue(e,h),I([])},he=async e=>{await l(e)?i(a("å·²å¤å¶å°åªè´´æ¿")+"ï¼"):f.error({title:a("æ æ³å¤å¶å°åªè´´æ¿ï¼è¯·æå¨å¤å¶"),content:e,size:"large"})};e.useEffect(()=>{ue(1).then().catch(e=>{d(e)}),(async()=>{try{const e=await o.get("/api/user/self/groups"),{success:s,data:t}=e.data;if(s&&t?.data){const e=t.data,s=Object.keys(e).filter(e=>"auto"!==e).map(s=>({label:e[s]?`${s} `:s,value:s}));ne(s)}}catch(e){console.error("å è½½åç»å表失败:",e)}})()},[h]);const xe=async(e,s,t)=>{B(!0);try{let r,l={id:e};switch(s){case"delete":r=await o.delete(`/api/token/${e}/`);break;case"enable":l.status=1,r=await o.put("/api/token/?status_only=true",l);break;case"disable":l.status=2,r=await o.put("/api/token/?status_only=true",l)}const{success:n,message:c}=r.data;if(n){i(a("æä½æå宿ï¼"));let e=r.data.data,l=[...C];"delete"===s||(t.status=e.status),$(l)}else d(c)}catch(r){console.error("令çæä½å¤±è´¥:",r),d(a("令çæä½å¤±è´¥ï¼è¯·éè¯"))}finally{B(!1)}},ge={selectedRowKeys:z.map(e=>e.id),onSelect:(e,s)=>{},onSelectAll:(e,s)=>{},onChange:(e,s)=>{I(s)}},je=s.jsx("div",{className:"mb-2",children:s.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full",children:[s.jsxs("div",{className:"flex items-center text-foreground/50",children:[s.jsx(ie,{size:16,className:"mr-2"}),s.jsx(Ve,{children:a("令çç¨äºAPI访é®è®¤è¯ï¼å¯ä»¥è®¾ç½®é¢åº¦éå¶å模åæéã")})]}),!r&&s.jsx(w,{type:"tertiary",className:"w-full md:w-auto",onClick:()=>F(!D),size:"small",children:a(D?"èªéåºå表":"ç´§åå表")})]})}),ye=s.jsxs("div",{className:"flex flex-wrap gap-2 w-full md:w-auto",children:[s.jsx(w,{type:"primary",className:"flex-1 md:flex-initial",onClick:()=>{H({id:void 0}),k(!0)},size:"small",children:a("æ·»å 令ç")}),s.jsx(w,{type:"tertiary",className:"flex-1 md:flex-initial",onClick:()=>{0!==z.length?f.info({title:a("å¤å¶ä»¤ç"),icon:null,content:a("è¯·éæ©ä½ çå¤å¶æ¹å¼"),footer:s.jsxs(v,{children:[s.jsx(w,{type:"tertiary",onClick:async()=>{let e="";for(let s=0;s<z.length;s++)e+=z[s].name+" sk-"+z[s].key+"\n";await he(e),f.destroyAll()},children:a("åç§°+å¯é¥")}),s.jsx(w,{onClick:async()=>{let e="";for(let s=0;s<z.length;s++)e+="sk-"+z[s].key+"\n";await he(e),f.destroyAll()},children:a("ä»
å¯é¥")})]})}):d(a("请è³å°éæ©ä¸ä¸ªä»¤çï¼"))},size:"small",children:a("å¤å¶æé令ç")}),s.jsx(w,{type:"tertiary",className:"w-full md:w-auto",onClick:()=>{0!==z.length?se(!0):d(a("请è³å°éæ©ä¸ä¸ªä»¤çï¼"))},size:"small",children:a("æ¹éä¿®æ¹")}),s.jsx(w,{type:"tertiary",className:"w-full md:w-auto",onClick:async()=>{ce(!0);try{const e=new URLSearchParams;z.length>0&&e.set("ids",z.map(e=>e.id).join(","));const s=await o.get(`/api/token/export?${e.toString()}`,{responseType:"blob"}),t=new Blob([s.data],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),r=window.URL.createObjectURL(t),l=document.createElement("a");l.href=r;const n=new Date,c=`${n.getFullYear()}${String(n.getMonth()+1).padStart(2,"0")}${String(n.getDate()).padStart(2,"0")}_${String(n.getHours()).padStart(2,"0")}${String(n.getMinutes()).padStart(2,"0")}${String(n.getSeconds()).padStart(2,"0")}`;l.download=`令çå表_${c}.xlsx`,document.body.appendChild(l),l.click(),window.URL.revokeObjectURL(r),document.body.removeChild(l),i(a("å¯¼åºæå"))}catch(e){d(a("导åºå¤±è´¥ï¼è¯·éè¯")),console.error("导åºä»¤ç失败:",e)}finally{ce(!1)}},loading:oe,size:"small",children:z.length>0?a("å¯¼åºæé令ç"):a("导åºå
¨é¨ä»¤ç")}),s.jsx(w,{type:"tertiary",className:"w-full md:w-auto",onClick:()=>{0!==z.length?f.confirm({title:a("æ¹éå é¤ä»¤ç"),content:s.jsx("div",{children:a("ç¡®å®è¦å 餿éç {{num}} 个令çåï¼",{num:z.length})}),onOk:()=>(async()=>
1{if(0!==z.length){B(!0);try{const e=z.map(e=>e.id),s=await o.post("/api/token/batch",{ids:e});if(s?.data?.success){const e=s.data.data||0;i(a("å·²å é¤ {{num}} 个令çï¼",{num:e})),await pe(),setTimeout(()=>{0===C.length&&L>1&&pe(L-1)},100)}else d(s?.data?.message||a("å é¤å¤±è´¥"))}catch(e){d(e.message)}finally{B(!1)}}else d(a("请å
éæ©è¦å é¤ç令çï¼"))})()}):d(a("请è³å°éæ©ä¸ä¸ªä»¤çï¼"))},size:"small",children:a("å 餿é令ç")})]}),Ce=s.jsx(N,{initValues:{searchKeyword:"",searchToken:"",searchGroup:""},getFormApi:e=>me(e),onSubmit:async()=>{V(!0);try{await ue(1)}finally{V(!1)}},allowEmpty:!0,autoComplete:"on",layout:"horizontal",trigger:"change",stopValidateWithError:!1,className:"w-full md:w-auto",children:s.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-4 w-full md:w-auto",children:[s.jsx("div",{className:"relative w-full md:w-56",children:s.jsx(N.Input,{field:"searchKeyword",name:"tokens_search_keyword",prefix:s.jsx(be,{size:16}),placeholder:a("æç´¢å
³é®å"),showClear:!0,pure:!0,size:"small"})}),s.jsx("div",{className:"relative w-full md:w-56",children:s.jsx(N.Input,{field:"searchToken",name:"tokens_search_token",prefix:s.jsx(be,{size:16}),placeholder:a("å¯é¥"),showClear:!0,pure:!0,size:"small"})}),s.jsx("div",{className:"relative w-full md:w-44",children:s.jsx(N.Select,{field:"searchGroup",placeholder:a("çéåç»"),optionList:[{label:a("å
¨é¨åç»"),value:""},...te],showClear:!0,size:"small",pure:!0,style:{width:"100%"}})}),s.jsxs("div",{className:"flex gap-2 w-full md:w-auto",children:[s.jsx(w,{type:"tertiary",htmlType:"submit",loading:W||M,className:"flex-1 md:flex-initial md:w-auto",size:"small",children:a("æ¥è¯¢")}),s.jsx(w,{type:"tertiary",onClick:()=>{de&&(de.reset(),m(null),setTimeout(()=>{ue(1,h,null)},100))},className:"flex-1 md:flex-initial md:w-auto",size:"small",children:a("éç½®")})]})]})}),Se=y({currentPage:L,pageSize:h,total:T,onPageChange:e=>{ue(e,h).then()},onPageSizeChange:async e=>{b(e),await ue(1,e)},isMobile:r,t:a});return s.jsxs(s.Fragment,{children:[s.jsx(Me,{refresh:pe,editingToken:E,visiable:_,handleClose:()=>{k(!1),setTimeout(()=>{H({id:void 0})},500)}}),s.jsx(Me,{refresh:pe,editingToken:{id:void 0},visiable:G,handleClose:()=>{se(!1)},isBatchMode:!0,batchTokenIds:z.map(e=>e.id)}),s.jsx(ke,{type:"type1",shadows:"always",bordered:!1,descriptionArea:je,actionsArea:ye,searchArea:Ce,paginationArea:Se,children:s.jsx(_e,{columns:D?p.map(e=>{if("operate"===e.dataIndex){const{fixed:s,...t}=e;return t}return e}):p,dataSource:C,rowKey:"id",scroll:D?void 0:{x:"max-content"},loading:W,rowSelection:ge,onRow:(e,s)=>1!==e.status?{style:{background:"hsl(var(--border))"}}:{},empty:s.jsx(Z,{image:s.jsx(ee,{style:{width:150,height:150}}),darkModeImage:s.jsx(Q,{style:{width:150,height:150}}),description:a("æç´¢æ ç»æ"),style:{padding:30}}),className:"rounded-xl overflow-hidden",size:"middle",hidePagination:!0})})]})},De=()=>{const{t:r}=t(),[l]=e.useContext(a),[i,n]=e.useState(""),{Text:o}=b;return e.useEffect(()=>{const e=l?.status?.server_address||localStorage.getItem("status")&&JSON.parse(localStorage.getItem("status")).server_address||window.location.origin;n(e)},[l?.status]),s.jsx("div",{className:"px-2",children:s.jsx(He,{})})};export{De 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.