import{r as a,z as f,j as e,s as v}from"./main.js";import{d as y,B as N}from"./button-D4VgS8ri.js";import{I as q}from"./input-CbL6Bfs6.js";import{C as S,a as C}from"./card-D6OLc_JP.js";import{L as b}from"./label-Bemsalkj.js";import{S as g}from"./skeleton-huerLprc.js";import{S as B,a as E,b as K,c as L,d as k}from"./select-BNSL7nj6.js";import{B as A}from"./bot-kknvMwap.js";import{E as Q}from"./eye-off-pMzODnxR.js";import{E as I}from"./eye-xgHnmW9o.js";import{L as O}from"./loader-circle-CEJBtRy6.js";import{S as P}from"./save-BelE_Mj2.js";import"./index-hZlSoXYO.js";import"./Combination-B6GbgrNn.js";import"./index-DArTFRYQ.js";import"./check-VUVUvqaV.js";const T=[{value:"qwen-turbo",label:"qwen-turbo",desc:"Fast"},{value:"qwen-plus",label:"qwen-plus",desc:"Enhanced"},{value:"qwen-max",label:"qwen-max",desc:"Strongest"},{value:"qwen-7b-chat",label:"qwen-7b-chat",desc:"7B"},{value:"qwen-14b-chat",label:"qwen-14b-chat",desc:"14B"},{value:"qwen-72b-chat",label:"qwen-72b-chat",desc:"72B"},{value:"qwen3-turbo",label:"qwen3-turbo",desc:"Qwen3 Fast"},{value:"qwen3-plus",label:"qwen3-plus",desc:"Qwen3 Enhanced"},{value:"qwen3-max",label:"qwen3-max",desc:"Qwen3 Strongest"},{value:"qwen3-7b-instruct",label:"qwen3-7b-instruct",desc:"7B"},{value:"qwen3-14b-instruct",label:"qwen3-14b-instruct",desc:"14B"},{value:"qwen3-32b-instruct",label:"qwen3-32b-instruct",desc:"32B"},{value:"qwen3-72b-instruct",label:"qwen3-72b-instruct",desc:"72B"}];function ee(){const{t:s}=y(),[o,r]=a.useState(!0),[l,i]=a.useState(!1),[n,w]=a.useState(!1),[d,m]=a.useState(""),[u,x]=a.useState("qwen-turbo"),c=a.useCallback(async()=>{r(!0);try{const h=(await f.get("v3/console/copilot/config")).data||{};m(h.apiKey||""),x(h.model||"qwen-turbo")}catch{}finally{r(!1)}},[]);a.useEffect(()=>{c()},[c]);const j=async()=>{i(!0);try{const t={apiKey:d.trim(),model:u||"qwen-turbo"};await f.post("v3/console/copilot/config",JSON.stringify(t),{headers:{"Content-Type":"application/json"}}),v.success(s("settings.saveSuccess")),c()}catch{}finally{i(!1)}};return e.jsxs("div",{className:"flex flex-col gap-6 max-w-3xl",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:s("settings.title")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("settings.description")})]}),e.jsx(S,{className:"py-0",children:e.jsxs(C,{className:"py-6",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-6",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(A,{className:"h-[18px] w-[18px] text-primary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-none mt-0.5",children:s("settings.copilotConfig")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1.5",children:s("settings.copilotConfigDesc")})]})]}),o?e.jsx("div",{className:"space-y-6",children:Array.from({length:2}).map((t,p)=>e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx(g,{className:"h-4 w-24"}),e.jsx(g,{className:"h-10 w-full"})]},p))}):e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(b,{children:s("settings.apiKey")}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{type:n?"text":"password",placeholder:s("settings.apiKeyPlaceholder"),value:d,onChange:t=>m(t.target.value),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>w(!n),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:n?e.jsx(Q,{className:"h-4 w-4"}):e.jsx(I,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settings.apiKeyHint")})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(b,{children:s("settings.model")}),e.jsxs(B,{value:u,onValueChange:x,children:[e.jsx(E,{children:e.jsx(K,{placeholder:s("settings.modelPlaceholder")})}),e.jsx(L,{children:T.map(t=>e.jsxs(k,{value:t.value,children:[e.jsx("span",{children:t.label}),e.jsxs("span",{className:"ml-2 text-muted-foreground text-xs",children:["(",t.desc,")"]})]},t.value))})]})]})]}),e.jsx("div",{className:"flex justify-end mt-6 pt-5 border-t",children:e.jsxs(N,{onClick:j,disabled:l||o,className:"gap-2 min-w-[120px]",children:[l?e.jsx(O,{className:"h-4 w-4 animate-spin"}):e.jsx(P,{className:"h-4 w-4"}),s(l?"common.loading":"common.save")]})})]})})]})}export{ee as default};
