blade-code 0.7.7 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blade.js +2 -2
- package/dist/{chunk-60se4kxq.js → chunk-0e0z8yc1.js} +2 -2
- package/dist/{chunk-x466sb8s.js → chunk-1w6tqkxd.js} +2 -2
- package/dist/{chunk-8e0rv3j5.js → chunk-2049tv49.js} +3 -3
- package/dist/chunk-4745ktjj.js +1570 -0
- package/dist/{chunk-54vk4tw8.js → chunk-48q9msfk.js} +43 -43
- package/dist/{chunk-v61bja34.js → chunk-4dmdn3a9.js} +1 -1
- package/dist/{chunk-4n7fsts0.js → chunk-5be6qr2v.js} +1 -1
- package/dist/chunk-67vzgcs5.js +2 -0
- package/dist/{chunk-2j3tb2dm.js → chunk-6811kbxn.js} +1 -1
- package/dist/{chunk-p7rf3zp8.js → chunk-6hn2jgw5.js} +1 -1
- package/dist/chunk-6js5wp6t.js +1 -0
- package/dist/{chunk-0y895nft.js → chunk-6kp3z956.js} +2 -2
- package/dist/{chunk-7e5hzpmp.js → chunk-71n472hj.js} +1 -1
- package/dist/chunk-78txnq4n.js +151 -0
- package/dist/{chunk-x24ddbhs.js → chunk-7r1hm0qz.js} +1 -1
- package/dist/{chunk-6087cgst.js → chunk-9kejtkey.js} +1 -1
- package/dist/{chunk-h79044h0.js → chunk-a7yjnqhd.js} +2 -2
- package/dist/chunk-bwaqaktn.js +1 -0
- package/dist/chunk-cb82rf5h.js +1 -0
- package/dist/chunk-ce11m8bq.js +1 -0
- package/dist/{chunk-2qckpa16.js → chunk-cjmxggke.js} +1 -1
- package/dist/chunk-e4rhdg3h.js +1 -0
- package/dist/{chunk-zet4zjc3.js → chunk-f9ybv4ph.js} +1 -1
- package/dist/{chunk-89j9pm90.js → chunk-faq7ay4j.js} +2 -2
- package/dist/{chunk-w1m1ehs1.js → chunk-fb7amc2s.js} +1 -1
- package/dist/{chunk-c6rtexw1.js → chunk-g6ted982.js} +1 -1
- package/dist/{chunk-9ad7tt9s.js → chunk-g7caymjr.js} +1 -1
- package/dist/{chunk-6y58y4rx.js → chunk-jm2xhnrv.js} +1 -1
- package/dist/chunk-ky8ctbdc.js +1 -0
- package/dist/chunk-mpskff34.js +1 -0
- package/dist/{chunk-6cry51vb.js → chunk-pd1yqxcv.js} +5 -5
- package/dist/{chunk-d61d6m07.js → chunk-phhmmybg.js} +2 -2
- package/dist/{chunk-ebcmqx1k.js → chunk-qnevwq1q.js} +1 -1
- package/dist/{chunk-778h8815.js → chunk-r1spf93b.js} +2 -2
- package/dist/{chunk-0b3m5qn6.js → chunk-rnfd5ebv.js} +1 -1
- package/dist/{chunk-yyw9bbfd.js → chunk-s4mke0t6.js} +1 -1
- package/dist/{chunk-5xjj88wd.js → chunk-t2spryz0.js} +1 -1
- package/dist/{chunk-2n8a87ds.js → chunk-t70aqrm4.js} +1 -1
- package/dist/{chunk-ptt8s7nd.js → chunk-z4c68ve0.js} +1 -1
- package/dist/chunk-z9zbcenc.js +6 -0
- package/dist/web/assets/{FilePreview-B2anY2d1.js → FilePreview-DRKRs8i2.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-BVfRG88x.js → MarkdownRenderer-DFqPpAnM.js} +1 -1
- package/dist/web/assets/{McpModal-BVvb-dzr.js → McpModal-CX5-hlNv.js} +1 -1
- package/dist/web/assets/{SettingsModal-aseVv-gp.js → SettingsModal-CfR_q6N7.js} +1 -1
- package/dist/web/assets/{SettingsStore-B87y64B4.js → SettingsStore-jup_Kikq.js} +1 -1
- package/dist/web/assets/{SkillsModal-BXYaF2KK.js → SkillsModal-DaAUrwXO.js} +1 -1
- package/dist/web/assets/{TerminalPanel-B-NRhOXN.js → TerminalPanel-DzlllDH7.js} +1 -1
- package/dist/web/assets/index-BJTSF3fc.js +9 -0
- package/dist/web/assets/index-CL6apjgo.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-3fcze972.js +0 -1
- package/dist/chunk-8p98nt9v.js +0 -151
- package/dist/chunk-94vj1hjp.js +0 -1
- package/dist/chunk-c8cxeve8.js +0 -1
- package/dist/chunk-gsn659hw.js +0 -1
- package/dist/chunk-kppxkh33.js +0 -1
- package/dist/chunk-qnh7np1s.js +0 -6
- package/dist/chunk-ran4gsmy.js +0 -1
- package/dist/chunk-swyvd7hd.js +0 -1
- package/dist/chunk-t9zdypqp.js +0 -2
- package/dist/chunk-x1khkevy.js +0 -1563
- package/dist/web/assets/index-9kl44E8k.js +0 -9
- package/dist/web/assets/index-CUVe9dGs.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as e}from"./vendor-react-BalntB5F.js";import{D as U,a as z,b as K,c as b,u as J,d as Q}from"./index-9kl44E8k.js";import{u as V}from"./SettingsStore-B87y64B4.js";import{X as P,k as M,E as G,w as _,d as W,e as X}from"./vendor-icons-BuFpOlRn.js";import"./vendor-markdown-Bo4W9Tae.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-CESj0OOY.js";const L={id:"custom",name:"Custom (OpenAI Compatible)",icon:"🔌",description:"Any OpenAI-compatible API",envVars:[],bladeProvider:"openai-compatible"};function Y({open:p,onOpenChange:c,onSave:u}){const[E,d]=n.useState([L]),[x,s]=n.useState([]),[r,j]=n.useState("custom"),[o,i]=n.useState({bladeProvider:"openai-compatible",baseUrl:"",apiKey:"",modelId:"",name:""}),[y,N]=n.useState(!1),[w,v]=n.useState(!1),[k,S]=n.useState(!1);n.useEffect(()=>{p&&fetch("/providers").then(a=>a.json()).then(a=>d([L,...a])).catch(a=>console.error("Failed to load providers:",a))},[p]),n.useEffect(()=>{r&&r!=="custom"?fetch(`/providers/${r}/models`).then(a=>a.json()).then(a=>s(a)).catch(a=>console.error("Failed to load models:",a)):s([])},[r]);const F=a=>{j(a.id),i({...o,bladeProvider:a.bladeProvider,baseUrl:a.defaultBaseUrl||"",modelId:"",name:""}),N(!1)},A=()=>{!o.modelId||!o.apiKey||(u({...o,name:o.name||o.modelId}),i({bladeProvider:"openai-compatible",baseUrl:"",apiKey:"",modelId:"",name:""}),j("custom"),c(!1))},h=E.find(a=>a.id===r),B=x.find(a=>a.id===o.modelId),C=!(r==="custom")&&x.length>0,I=o.modelId&&o.apiKey;return e.jsx(U,{open:p,onOpenChange:c,children:e.jsxs(z,{className:"sm:max-w-[480px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl [&>button]:hidden","aria-describedby":void 0,children:[e.jsx(K,{className:"sr-only",children:"Add Model"}),e.jsxs("div",{className:"p-6 flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Add Model"}),e.jsx("button",{onClick:()=>c(!1),className:"text-[#9CA3AF] hover:text-[#111827] dark:text-[#71717a] dark:hover:text-[#E5E5E5] transition-colors",children:e.jsx(P,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Provider"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>N(!y),className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#27272a] transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{children:h==null?void 0:h.icon}),e.jsx("span",{children:h==null?void 0:h.name})]}),e.jsx(M,{className:"h-4 w-4 text-[#9CA3AF] dark:text-[#71717a]"})]}),y&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>N(!1)}),e.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-[#18181b] border border-[#E5E7EB] dark:border-zinc-800 rounded-md py-1 z-50 max-h-64 overflow-y-auto shadow-lg",children:E.map(a=>e.jsx("button",{type:"button",className:b("w-full text-left px-3 py-2 text-sm font-mono hover:bg-[#F3F4F6] dark:hover:bg-[#27272a] transition-colors",r===a.id?"text-[#111827] dark:text-[#E5E5E5] bg-[#F3F4F6] dark:bg-[#27272a]":"text-[#6B7280] dark:text-[#a1a1aa]"),onClick:()=>F(a),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:a.icon}),e.jsx("span",{className:"font-medium",children:a.name})]})},a.id))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Base URL"}),e.jsx("input",{type:"text",value:o.baseUrl,onChange:a=>i({...o,baseUrl:a.target.value}),placeholder:(h==null?void 0:h.defaultBaseUrl)||"https://api.openai.com/v1",className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none focus:ring-1 focus:ring-[#D1D5DB] dark:focus:ring-zinc-600"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:k?"text":"password",value:o.apiKey,onChange:a=>i({...o,apiKey:a.target.value}),placeholder:"sk-........................",className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 pr-10 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none focus:ring-1 focus:ring-[#D1D5DB] dark:focus:ring-zinc-600"}),e.jsx("button",{type:"button",onClick:()=>S(!k),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[#9CA3AF] hover:text-[#111827] dark:text-[#71717a] dark:hover:text-[#E5E5E5] transition-colors",children:k?e.jsx(G,{className:"h-4 w-4"}):e.jsx(_,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Model ID"}),C&&e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>v(!w),className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#27272a] transition-colors",children:[(B==null?void 0:B.name)||o.modelId||"Select model",e.jsx(M,{className:"h-4 w-4 text-[#9CA3AF] dark:text-[#71717a]"})]}),w&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>v(!1)}),e.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-[#18181b] border border-[#E5E7EB] dark:border-zinc-800 rounded-md py-1 z-50 max-h-48 overflow-y-auto shadow-lg",children:x.map(a=>e.jsx("button",{type:"button",className:b("w-full text-left px-3 py-2 text-sm font-mono hover:bg-[#F3F4F6] dark:hover:bg-[#27272a] transition-colors",o.modelId===a.id?"text-[#111827] dark:text-[#E5E5E5] bg-[#F3F4F6] dark:bg-[#27272a]":"text-[#6B7280] dark:text-[#a1a1aa]"),onClick:()=>{i({...o,modelId:a.id,name:a.name}),v(!1)},children:a.name},a.id))})]})]}),e.jsx("input",{type:"text",value:o.modelId,onChange:a=>i({...o,modelId:a.target.value,name:a.target.value}),placeholder:"gpt-4o, claude-3-opus, deepseek-chat, etc.",className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none focus:ring-1 focus:ring-[#D1D5DB] dark:focus:ring-zinc-600"}),C&&e.jsx("p",{className:"text-[12px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"You can select a listed model or type a custom model ID."})]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>c(!1),className:"flex-1 px-4 py-2 rounded-md text-sm text-[#6B7280] dark:text-[#a1a1aa] font-mono hover:bg-[#F3F4F6] dark:hover:bg-[#18181b] transition-colors",children:"Cancel"}),e.jsx("button",{type:"button",onClick:A,disabled:!I,className:"flex-1 px-4 py-2 rounded-md text-sm text-white font-semibold font-mono bg-[#16A34A] hover:bg-[#15803d] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Save Model"})]})]})]})})}function q({open:p,onOpenChange:c,model:u,onSave:E}){const[d,x]=n.useState({baseUrl:"",apiKey:"",model:""}),[s,r]=n.useState(!1);n.useEffect(()=>{u&&x({baseUrl:u.baseUrl||"",apiKey:u.apiKey||"",model:u.model||""})},[u]);const j=()=>{!u||!d.model||(E(u.id,{baseUrl:d.baseUrl||void 0,apiKey:d.apiKey||void 0,model:d.model}),c(!1))},o=d.model;return e.jsx(U,{open:p,onOpenChange:c,children:e.jsxs(z,{className:"sm:max-w-[480px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl [&>button]:hidden","aria-describedby":void 0,children:[e.jsx(K,{className:"sr-only",children:"Edit Model"}),e.jsxs("div",{className:"p-6 flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Edit Model"}),e.jsx("button",{onClick:()=>c(!1),className:"text-[#9CA3AF] hover:text-[#111827] dark:text-[#71717a] dark:hover:text-[#E5E5E5] transition-colors",children:e.jsx(P,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Model ID"}),e.jsx("input",{type:"text",value:d.model,onChange:i=>x({...d,model:i.target.value}),placeholder:"gpt-4o, claude-3-opus, etc.",className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none focus:ring-1 focus:ring-[#D1D5DB] dark:focus:ring-zinc-600"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Base URL"}),e.jsx("input",{type:"text",value:d.baseUrl,onChange:i=>x({...d,baseUrl:i.target.value}),placeholder:"https://api.openai.com/v1",className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none focus:ring-1 focus:ring-[#D1D5DB] dark:focus:ring-zinc-600"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:s?"text":"password",value:d.apiKey,onChange:i=>x({...d,apiKey:i.target.value}),placeholder:"Leave empty to keep current key",className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 pr-10 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none focus:ring-1 focus:ring-[#D1D5DB] dark:focus:ring-zinc-600"}),e.jsx("button",{type:"button",onClick:()=>r(!s),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[#9CA3AF] hover:text-[#111827] dark:text-[#71717a] dark:hover:text-[#E5E5E5] transition-colors",children:s?e.jsx(G,{className:"h-4 w-4"}):e.jsx(_,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>c(!1),className:"flex-1 px-4 py-2 rounded-md text-sm text-[#6B7280] dark:text-[#a1a1aa] font-mono hover:bg-[#F3F4F6] dark:hover:bg-[#18181b] transition-colors",children:"Cancel"}),e.jsx("button",{type:"button",onClick:j,disabled:!o,className:"flex-1 px-4 py-2 rounded-md text-sm text-white font-semibold font-mono bg-[#16A34A] hover:bg-[#15803d] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Save Changes"})]})]})]})})}const Z={"openai-compatible":{bg:"#10a37f",label:"OA"},anthropic:{bg:"#d97757",label:"A"},gemini:{bg:"#4285f4",label:"G"},"azure-openai":{bg:"#0078d4",label:"Az"},"gpt-openai-platform":{bg:"#10a37f",label:"GP"}};function re(){var O;const{isSettingsOpen:p,toggleSettings:c,isSidebarOpen:u,setSidebarOpen:E}=J(),{configuredModels:d,loadModels:x}=Q(),s=V(),[r,j]=n.useState("general"),[o,i]=n.useState(!1),[y,N]=n.useState(null),[w,v]=n.useState(null),[k,S]=n.useState(""),[F,A]=n.useState("all"),h=[{value:"general",label:"General"},{value:"models",label:"Models"},{value:"shortcuts",label:"Shortcuts"}],D=n.useMemo(()=>[{action:"Open command palette",combo:["Ctrl","K"],scope:"Global"},{action:"New chat",combo:["Ctrl","N"],scope:"Chat"},{action:"Focus input",combo:["Ctrl","L"],scope:"Chat"},{action:"Toggle sidebar",combo:["Ctrl","B"],scope:"Layout"},{action:"Search history",combo:["Ctrl","H"],scope:"History"}],[]).filter(t=>{const l=t.action.toLowerCase().includes(k.toLowerCase()),m=F==="all"||t.scope.toLowerCase()===F;return l&&m}),C=d.reduce((t,l)=>{const m=l.provider||"unknown";return t[m]||(t[m]=[]),t[m].push(l),t},{});n.useEffect(()=>{p&&(x(),s.loadSettings())},[p,x,s.loadSettings]);const I=async t=>{try{if(!(await fetch("/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.bladeProvider,name:t.name||t.modelId,model:t.modelId,baseUrl:t.baseUrl||void 0,apiKey:t.apiKey||void 0})})).ok)throw new Error("Failed to save model");await x()}catch(l){console.error("Failed to save model:",l)}},a=async t=>{try{if(!(await fetch(`/models/${t}`,{method:"DELETE"})).ok)throw new Error("Failed to delete model");await x()}catch(l){console.error("Failed to delete model:",l)}},$=async(t,l)=>{try{if(!(await fetch(`/models/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})).ok)throw new Error("Failed to update model");await x()}catch(m){console.error("Failed to update model:",m)}},H=t=>{N(y===t?null:t)};return e.jsxs(e.Fragment,{children:[e.jsx(U,{open:p,onOpenChange:c,children:e.jsxs(z,{className:"sm:max-w-[800px] h-[600px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl flex flex-col","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(K,{className:"sr-only",children:"Settings"}),e.jsxs("div",{className:"flex h-full",children:[e.jsx("div",{className:"w-[200px] h-full bg-[#F3F4F6] dark:bg-[#18181b] p-6 flex flex-col gap-2",children:h.map(t=>e.jsx("button",{onClick:()=>j(t.value),className:b("w-full text-left px-3 py-2 rounded-md text-sm font-mono transition-colors",r===t.value?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5] font-medium":"text-[#6B7280] hover:text-[#111827] hover:bg-[#E5E7EB]/60 dark:text-[#a1a1aa] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a]/50"),children:t.label},t.value))}),e.jsxs("div",{className:"flex-1 p-8 flex flex-col gap-6 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:r==="general"?"Settings":(O=h.find(t=>t.value===r))==null?void 0:O.label}),e.jsx("button",{onClick:c,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(P,{className:"h-4 w-4"})})]}),r==="models"&&e.jsxs("div",{className:"flex flex-col gap-6 flex-1 min-h-0 overflow-hidden",children:[e.jsx("p",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono shrink-0",children:"Configure API keys and model settings for different providers."}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:e.jsxs("div",{className:"flex flex-col gap-2 pr-2",children:[Object.entries(C).map(([t,l])=>{const m=Z[t]||{bg:"#71717a",label:"?"},T=l.some(f=>f.apiKey),R=y===t;return e.jsxs("div",{className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>H(t),className:"w-full p-4 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded flex items-center justify-center text-white text-xs font-bold",style:{backgroundColor:m.bg},children:m.label}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-left",children:[e.jsx("span",{className:"text-sm font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono capitalize",children:t.replace(/-/g," ")}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono",children:[l.length," model",l.length>1?"s":""]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:b("text-xs font-mono",T?"text-[#16A34A]":"text-[#9CA3AF] dark:text-[#71717a]"),children:T?"● Connected":"○ Not Connected"}),e.jsx(M,{className:b("h-4 w-4 text-[#9CA3AF] dark:text-[#71717a] transition-transform",R&&"rotate-180")})]})]}),R&&e.jsx("div",{className:"border-t border-[#E5E7EB] dark:border-zinc-800",children:l.map(f=>e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] group",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm text-[#111827] dark:text-[#E5E5E5] font-mono truncate",children:f.model}),e.jsx("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono truncate",children:f.baseUrl||"Default URL"})]}),e.jsxs("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>v(f),className:"p-1.5 text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(W,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>a(f.id),className:"p-1.5 text-[#9CA3AF] hover:text-red-500 hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-red-400 dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(X,{className:"h-3.5 w-3.5"})})]})]},f.id))})]},t)}),Object.keys(C).length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No models configured yet"})]})}),e.jsx("button",{onClick:()=>i(!0),className:"w-full py-3 rounded-md text-[#6B7280] dark:text-[#a1a1aa] text-[13px] font-mono hover:bg-[#F3F4F6] dark:bg-[#18181b] transition-colors shrink-0",children:"+ Add New Model"})]}),r==="general"&&e.jsxs("div",{className:"flex flex-col gap-6 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"General"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Response Language"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"AI will respond in this language"})]}),e.jsxs("select",{value:s.language,onChange:t=>s.updateSettings({language:t.target.value}),className:"h-8 bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono rounded-md px-3 border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("option",{value:"en-US",children:"English (US)"}),e.jsx("option",{value:"zh-CN",children:"简体中文"}),e.jsx("option",{value:"zh-TW",children:"繁體中文"}),e.jsx("option",{value:"ja-JP",children:"日本語"}),e.jsx("option",{value:"ko-KR",children:"한국어"}),e.jsx("option",{value:"es-ES",children:"Español"}),e.jsx("option",{value:"fr-FR",children:"Français"}),e.jsx("option",{value:"de-DE",children:"Deutsch"}),e.jsx("option",{value:"pt-BR",children:"Português (BR)"}),e.jsx("option",{value:"ru-RU",children:"Русский"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Auto-save sessions"}),e.jsx(g,{enabled:s.autoSaveSessions,onChange:t=>s.updateSettings({autoSaveSessions:t})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Appearance"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Theme Preference"}),e.jsx("div",{className:"flex items-center gap-2 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md p-1",children:["dark","light","system"].map(t=>e.jsx("button",{onClick:()=>s.updateSettings({uiTheme:t}),className:b("px-3 py-1 rounded text-[12px] font-mono transition-colors",s.uiTheme===t?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5]":"text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5]"),children:t==="dark"?"Dark":t==="light"?"Light":"System"},t))})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Compact sidebar"}),e.jsx(g,{enabled:!u,onChange:t=>E(!t)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Code theme"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"Syntax highlighting colors"})]}),e.jsxs("select",{value:s.theme,onChange:t=>s.updateSettings({theme:t.target.value}),className:"h-8 bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono rounded-md px-3 border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("option",{value:"dracula",children:"Dracula"}),e.jsx("option",{value:"monokai",children:"Monokai"}),e.jsx("option",{value:"nord",children:"Nord"}),e.jsx("option",{value:"tokyo-night",children:"Tokyo Night"}),e.jsx("option",{value:"one-dark",children:"One Dark"}),e.jsx("option",{value:"catppuccin",children:"Catppuccin"}),e.jsx("option",{value:"gruvbox",children:"Gruvbox"}),e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"solarized-light",children:"Solarized Light"}),e.jsx("option",{value:"solarized-dark",children:"Solarized Dark"}),e.jsx("option",{value:"ayu-dark",children:"Ayu Dark"}),e.jsx("option",{value:"rose-pine",children:"Rose Pine"}),e.jsx("option",{value:"kanagawa",children:"Kanagawa"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Notifications"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Build finished"}),e.jsx(g,{enabled:s.notifyBuild,onChange:t=>s.updateSettings({notifyBuild:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Errors only"}),e.jsx(g,{enabled:s.notifyErrors,onChange:t=>s.updateSettings({notifyErrors:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"System sounds"}),e.jsx(g,{enabled:s.notifySounds,onChange:t=>s.updateSettings({notifySounds:t})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Privacy"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Telemetry"}),e.jsx(g,{enabled:s.privacyTelemetry,onChange:t=>s.updateSettings({privacyTelemetry:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Crash reports"}),e.jsx(g,{enabled:s.privacyCrash,onChange:t=>s.updateSettings({privacyCrash:t})})]})]})]}),r==="shortcuts"&&e.jsxs("div",{className:"flex flex-col gap-4 flex-1 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx("input",{value:k,onChange:t=>S(t.target.value),placeholder:"Search actions...",className:"flex-1 h-9 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono"}),e.jsxs("select",{value:F,onChange:t=>A(t.target.value),className:"h-9 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono",children:[e.jsx("option",{value:"all",children:"All scopes"}),e.jsx("option",{value:"global",children:"Global"}),e.jsx("option",{value:"chat",children:"Chat"}),e.jsx("option",{value:"layout",children:"Layout"}),e.jsx("option",{value:"history",children:"History"})]}),e.jsx("button",{onClick:()=>{S(""),A("all")},className:"h-9 px-3 rounded-md bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:"Reset"})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto border border-[#E5E7EB] dark:border-[#27272a] rounded-lg bg-[#E5E7EB] dark:bg-[#111827]",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 bg-white dark:bg-[#0C0C0C] text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono font-semibold",children:[e.jsx("span",{children:"Action"}),e.jsx("span",{children:"Shortcut"}),e.jsx("span",{children:"Scope"})]}),D.map((t,l)=>e.jsxs("div",{className:b("grid grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 text-[13px] font-mono",l%2===0?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C]"),children:[e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:t.action}),e.jsx("div",{className:"flex items-center gap-1",children:t.combo.map(m=>e.jsx("span",{className:"px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:m},m))}),e.jsx("span",{className:"text-[#6B7280] dark:text-[#94a3b8] text-[12px]",children:t.scope})]},`${t.action}-${t.scope}`)),D.length===0&&e.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono",children:"No shortcuts found."})]})]})]})]})]})}),e.jsx(Y,{open:o,onOpenChange:i,onSave:I}),e.jsx(q,{open:!!w,onOpenChange:t=>!t&&v(null),model:w,onSave:$})]})}function g({enabled:p,onChange:c}){return e.jsx("button",{onClick:()=>c(!p),className:b("w-10 h-5 rounded-full px-0.5 flex items-center transition-colors",p?"bg-[#22C55E]":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:b("h-4 w-4 rounded-full transition-transform",p?"translate-x-5 bg-white":"translate-x-0 bg-white dark:bg-[#a1a1aa]")})})}export{re as SettingsModal};
|
|
1
|
+
import{r as n,j as e}from"./vendor-react-BalntB5F.js";import{D as U,a as z,b as K,c as b,u as J,d as Q}from"./index-BJTSF3fc.js";import{u as V}from"./SettingsStore-jup_Kikq.js";import{X as P,k as M,E as G,w as _,d as W,e as X}from"./vendor-icons-BuFpOlRn.js";import"./vendor-markdown-Bo4W9Tae.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-CESj0OOY.js";const L={id:"custom",name:"Custom (OpenAI Compatible)",icon:"🔌",description:"Any OpenAI-compatible API",envVars:[],bladeProvider:"openai-compatible"};function Y({open:p,onOpenChange:c,onSave:u}){const[E,d]=n.useState([L]),[x,s]=n.useState([]),[r,j]=n.useState("custom"),[o,i]=n.useState({bladeProvider:"openai-compatible",baseUrl:"",apiKey:"",modelId:"",name:""}),[y,N]=n.useState(!1),[w,v]=n.useState(!1),[k,S]=n.useState(!1);n.useEffect(()=>{p&&fetch("/providers").then(a=>a.json()).then(a=>d([L,...a])).catch(a=>console.error("Failed to load providers:",a))},[p]),n.useEffect(()=>{r&&r!=="custom"?fetch(`/providers/${r}/models`).then(a=>a.json()).then(a=>s(a)).catch(a=>console.error("Failed to load models:",a)):s([])},[r]);const F=a=>{j(a.id),i({...o,bladeProvider:a.bladeProvider,baseUrl:a.defaultBaseUrl||"",modelId:"",name:""}),N(!1)},A=()=>{!o.modelId||!o.apiKey||(u({...o,name:o.name||o.modelId}),i({bladeProvider:"openai-compatible",baseUrl:"",apiKey:"",modelId:"",name:""}),j("custom"),c(!1))},h=E.find(a=>a.id===r),B=x.find(a=>a.id===o.modelId),C=!(r==="custom")&&x.length>0,I=o.modelId&&o.apiKey;return e.jsx(U,{open:p,onOpenChange:c,children:e.jsxs(z,{className:"sm:max-w-[480px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl [&>button]:hidden","aria-describedby":void 0,children:[e.jsx(K,{className:"sr-only",children:"Add Model"}),e.jsxs("div",{className:"p-6 flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Add Model"}),e.jsx("button",{onClick:()=>c(!1),className:"text-[#9CA3AF] hover:text-[#111827] dark:text-[#71717a] dark:hover:text-[#E5E5E5] transition-colors",children:e.jsx(P,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Provider"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>N(!y),className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#27272a] transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{children:h==null?void 0:h.icon}),e.jsx("span",{children:h==null?void 0:h.name})]}),e.jsx(M,{className:"h-4 w-4 text-[#9CA3AF] dark:text-[#71717a]"})]}),y&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>N(!1)}),e.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-[#18181b] border border-[#E5E7EB] dark:border-zinc-800 rounded-md py-1 z-50 max-h-64 overflow-y-auto shadow-lg",children:E.map(a=>e.jsx("button",{type:"button",className:b("w-full text-left px-3 py-2 text-sm font-mono hover:bg-[#F3F4F6] dark:hover:bg-[#27272a] transition-colors",r===a.id?"text-[#111827] dark:text-[#E5E5E5] bg-[#F3F4F6] dark:bg-[#27272a]":"text-[#6B7280] dark:text-[#a1a1aa]"),onClick:()=>F(a),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:a.icon}),e.jsx("span",{className:"font-medium",children:a.name})]})},a.id))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Base URL"}),e.jsx("input",{type:"text",value:o.baseUrl,onChange:a=>i({...o,baseUrl:a.target.value}),placeholder:(h==null?void 0:h.defaultBaseUrl)||"https://api.openai.com/v1",className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none focus:ring-1 focus:ring-[#D1D5DB] dark:focus:ring-zinc-600"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:k?"text":"password",value:o.apiKey,onChange:a=>i({...o,apiKey:a.target.value}),placeholder:"sk-........................",className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 pr-10 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none focus:ring-1 focus:ring-[#D1D5DB] dark:focus:ring-zinc-600"}),e.jsx("button",{type:"button",onClick:()=>S(!k),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[#9CA3AF] hover:text-[#111827] dark:text-[#71717a] dark:hover:text-[#E5E5E5] transition-colors",children:k?e.jsx(G,{className:"h-4 w-4"}):e.jsx(_,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Model ID"}),C&&e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>v(!w),className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#27272a] transition-colors",children:[(B==null?void 0:B.name)||o.modelId||"Select model",e.jsx(M,{className:"h-4 w-4 text-[#9CA3AF] dark:text-[#71717a]"})]}),w&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>v(!1)}),e.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-[#18181b] border border-[#E5E7EB] dark:border-zinc-800 rounded-md py-1 z-50 max-h-48 overflow-y-auto shadow-lg",children:x.map(a=>e.jsx("button",{type:"button",className:b("w-full text-left px-3 py-2 text-sm font-mono hover:bg-[#F3F4F6] dark:hover:bg-[#27272a] transition-colors",o.modelId===a.id?"text-[#111827] dark:text-[#E5E5E5] bg-[#F3F4F6] dark:bg-[#27272a]":"text-[#6B7280] dark:text-[#a1a1aa]"),onClick:()=>{i({...o,modelId:a.id,name:a.name}),v(!1)},children:a.name},a.id))})]})]}),e.jsx("input",{type:"text",value:o.modelId,onChange:a=>i({...o,modelId:a.target.value,name:a.target.value}),placeholder:"gpt-4o, claude-3-opus, deepseek-chat, etc.",className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none focus:ring-1 focus:ring-[#D1D5DB] dark:focus:ring-zinc-600"}),C&&e.jsx("p",{className:"text-[12px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"You can select a listed model or type a custom model ID."})]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>c(!1),className:"flex-1 px-4 py-2 rounded-md text-sm text-[#6B7280] dark:text-[#a1a1aa] font-mono hover:bg-[#F3F4F6] dark:hover:bg-[#18181b] transition-colors",children:"Cancel"}),e.jsx("button",{type:"button",onClick:A,disabled:!I,className:"flex-1 px-4 py-2 rounded-md text-sm text-white font-semibold font-mono bg-[#16A34A] hover:bg-[#15803d] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Save Model"})]})]})]})})}function q({open:p,onOpenChange:c,model:u,onSave:E}){const[d,x]=n.useState({baseUrl:"",apiKey:"",model:""}),[s,r]=n.useState(!1);n.useEffect(()=>{u&&x({baseUrl:u.baseUrl||"",apiKey:u.apiKey||"",model:u.model||""})},[u]);const j=()=>{!u||!d.model||(E(u.id,{baseUrl:d.baseUrl||void 0,apiKey:d.apiKey||void 0,model:d.model}),c(!1))},o=d.model;return e.jsx(U,{open:p,onOpenChange:c,children:e.jsxs(z,{className:"sm:max-w-[480px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl [&>button]:hidden","aria-describedby":void 0,children:[e.jsx(K,{className:"sr-only",children:"Edit Model"}),e.jsxs("div",{className:"p-6 flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Edit Model"}),e.jsx("button",{onClick:()=>c(!1),className:"text-[#9CA3AF] hover:text-[#111827] dark:text-[#71717a] dark:hover:text-[#E5E5E5] transition-colors",children:e.jsx(P,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Model ID"}),e.jsx("input",{type:"text",value:d.model,onChange:i=>x({...d,model:i.target.value}),placeholder:"gpt-4o, claude-3-opus, etc.",className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none focus:ring-1 focus:ring-[#D1D5DB] dark:focus:ring-zinc-600"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Base URL"}),e.jsx("input",{type:"text",value:d.baseUrl,onChange:i=>x({...d,baseUrl:i.target.value}),placeholder:"https://api.openai.com/v1",className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none focus:ring-1 focus:ring-[#D1D5DB] dark:focus:ring-zinc-600"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:s?"text":"password",value:d.apiKey,onChange:i=>x({...d,apiKey:i.target.value}),placeholder:"Leave empty to keep current key",className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 py-2.5 pr-10 text-sm text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] focus:outline-none focus:ring-1 focus:ring-[#D1D5DB] dark:focus:ring-zinc-600"}),e.jsx("button",{type:"button",onClick:()=>r(!s),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[#9CA3AF] hover:text-[#111827] dark:text-[#71717a] dark:hover:text-[#E5E5E5] transition-colors",children:s?e.jsx(G,{className:"h-4 w-4"}):e.jsx(_,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>c(!1),className:"flex-1 px-4 py-2 rounded-md text-sm text-[#6B7280] dark:text-[#a1a1aa] font-mono hover:bg-[#F3F4F6] dark:hover:bg-[#18181b] transition-colors",children:"Cancel"}),e.jsx("button",{type:"button",onClick:j,disabled:!o,className:"flex-1 px-4 py-2 rounded-md text-sm text-white font-semibold font-mono bg-[#16A34A] hover:bg-[#15803d] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Save Changes"})]})]})]})})}const Z={"openai-compatible":{bg:"#10a37f",label:"OA"},anthropic:{bg:"#d97757",label:"A"},gemini:{bg:"#4285f4",label:"G"},"azure-openai":{bg:"#0078d4",label:"Az"},"gpt-openai-platform":{bg:"#10a37f",label:"GP"}};function re(){var O;const{isSettingsOpen:p,toggleSettings:c,isSidebarOpen:u,setSidebarOpen:E}=J(),{configuredModels:d,loadModels:x}=Q(),s=V(),[r,j]=n.useState("general"),[o,i]=n.useState(!1),[y,N]=n.useState(null),[w,v]=n.useState(null),[k,S]=n.useState(""),[F,A]=n.useState("all"),h=[{value:"general",label:"General"},{value:"models",label:"Models"},{value:"shortcuts",label:"Shortcuts"}],D=n.useMemo(()=>[{action:"Open command palette",combo:["Ctrl","K"],scope:"Global"},{action:"New chat",combo:["Ctrl","N"],scope:"Chat"},{action:"Focus input",combo:["Ctrl","L"],scope:"Chat"},{action:"Toggle sidebar",combo:["Ctrl","B"],scope:"Layout"},{action:"Search history",combo:["Ctrl","H"],scope:"History"}],[]).filter(t=>{const l=t.action.toLowerCase().includes(k.toLowerCase()),m=F==="all"||t.scope.toLowerCase()===F;return l&&m}),C=d.reduce((t,l)=>{const m=l.provider||"unknown";return t[m]||(t[m]=[]),t[m].push(l),t},{});n.useEffect(()=>{p&&(x(),s.loadSettings())},[p,x,s.loadSettings]);const I=async t=>{try{if(!(await fetch("/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.bladeProvider,name:t.name||t.modelId,model:t.modelId,baseUrl:t.baseUrl||void 0,apiKey:t.apiKey||void 0})})).ok)throw new Error("Failed to save model");await x()}catch(l){console.error("Failed to save model:",l)}},a=async t=>{try{if(!(await fetch(`/models/${t}`,{method:"DELETE"})).ok)throw new Error("Failed to delete model");await x()}catch(l){console.error("Failed to delete model:",l)}},$=async(t,l)=>{try{if(!(await fetch(`/models/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})).ok)throw new Error("Failed to update model");await x()}catch(m){console.error("Failed to update model:",m)}},H=t=>{N(y===t?null:t)};return e.jsxs(e.Fragment,{children:[e.jsx(U,{open:p,onOpenChange:c,children:e.jsxs(z,{className:"sm:max-w-[800px] h-[600px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl flex flex-col","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(K,{className:"sr-only",children:"Settings"}),e.jsxs("div",{className:"flex h-full",children:[e.jsx("div",{className:"w-[200px] h-full bg-[#F3F4F6] dark:bg-[#18181b] p-6 flex flex-col gap-2",children:h.map(t=>e.jsx("button",{onClick:()=>j(t.value),className:b("w-full text-left px-3 py-2 rounded-md text-sm font-mono transition-colors",r===t.value?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5] font-medium":"text-[#6B7280] hover:text-[#111827] hover:bg-[#E5E7EB]/60 dark:text-[#a1a1aa] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a]/50"),children:t.label},t.value))}),e.jsxs("div",{className:"flex-1 p-8 flex flex-col gap-6 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:r==="general"?"Settings":(O=h.find(t=>t.value===r))==null?void 0:O.label}),e.jsx("button",{onClick:c,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(P,{className:"h-4 w-4"})})]}),r==="models"&&e.jsxs("div",{className:"flex flex-col gap-6 flex-1 min-h-0 overflow-hidden",children:[e.jsx("p",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono shrink-0",children:"Configure API keys and model settings for different providers."}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:e.jsxs("div",{className:"flex flex-col gap-2 pr-2",children:[Object.entries(C).map(([t,l])=>{const m=Z[t]||{bg:"#71717a",label:"?"},T=l.some(f=>f.apiKey),R=y===t;return e.jsxs("div",{className:"w-full bg-[#F3F4F6] dark:bg-[#18181b] rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>H(t),className:"w-full p-4 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded flex items-center justify-center text-white text-xs font-bold",style:{backgroundColor:m.bg},children:m.label}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-left",children:[e.jsx("span",{className:"text-sm font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono capitalize",children:t.replace(/-/g," ")}),e.jsxs("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono",children:[l.length," model",l.length>1?"s":""]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:b("text-xs font-mono",T?"text-[#16A34A]":"text-[#9CA3AF] dark:text-[#71717a]"),children:T?"● Connected":"○ Not Connected"}),e.jsx(M,{className:b("h-4 w-4 text-[#9CA3AF] dark:text-[#71717a] transition-transform",R&&"rotate-180")})]})]}),R&&e.jsx("div",{className:"border-t border-[#E5E7EB] dark:border-zinc-800",children:l.map(f=>e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between hover:bg-[#E5E7EB] dark:hover:bg-[#1f1f23] group",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[e.jsx("span",{className:"text-sm text-[#111827] dark:text-[#E5E5E5] font-mono truncate",children:f.model}),e.jsx("span",{className:"text-xs text-[#9CA3AF] dark:text-[#71717a] font-mono truncate",children:f.baseUrl||"Default URL"})]}),e.jsxs("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>v(f),className:"p-1.5 text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(W,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>a(f.id),className:"p-1.5 text-[#9CA3AF] hover:text-red-500 hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-red-400 dark:hover:bg-[#27272a] rounded transition-colors",children:e.jsx(X,{className:"h-3.5 w-3.5"})})]})]},f.id))})]},t)}),Object.keys(C).length===0&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No models configured yet"})]})}),e.jsx("button",{onClick:()=>i(!0),className:"w-full py-3 rounded-md text-[#6B7280] dark:text-[#a1a1aa] text-[13px] font-mono hover:bg-[#F3F4F6] dark:bg-[#18181b] transition-colors shrink-0",children:"+ Add New Model"})]}),r==="general"&&e.jsxs("div",{className:"flex flex-col gap-6 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"General"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Response Language"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"AI will respond in this language"})]}),e.jsxs("select",{value:s.language,onChange:t=>s.updateSettings({language:t.target.value}),className:"h-8 bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono rounded-md px-3 border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("option",{value:"en-US",children:"English (US)"}),e.jsx("option",{value:"zh-CN",children:"简体中文"}),e.jsx("option",{value:"zh-TW",children:"繁體中文"}),e.jsx("option",{value:"ja-JP",children:"日本語"}),e.jsx("option",{value:"ko-KR",children:"한국어"}),e.jsx("option",{value:"es-ES",children:"Español"}),e.jsx("option",{value:"fr-FR",children:"Français"}),e.jsx("option",{value:"de-DE",children:"Deutsch"}),e.jsx("option",{value:"pt-BR",children:"Português (BR)"}),e.jsx("option",{value:"ru-RU",children:"Русский"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Auto-save sessions"}),e.jsx(g,{enabled:s.autoSaveSessions,onChange:t=>s.updateSettings({autoSaveSessions:t})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Appearance"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Theme Preference"}),e.jsx("div",{className:"flex items-center gap-2 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md p-1",children:["dark","light","system"].map(t=>e.jsx("button",{onClick:()=>s.updateSettings({uiTheme:t}),className:b("px-3 py-1 rounded text-[12px] font-mono transition-colors",s.uiTheme===t?"bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5]":"text-[#9CA3AF] dark:text-[#71717a] hover:text-[#111827] dark:hover:text-[#E5E5E5]"),children:t==="dark"?"Dark":t==="light"?"Light":"System"},t))})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Compact sidebar"}),e.jsx(g,{enabled:!u,onChange:t=>E(!t)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Code theme"}),e.jsx("span",{className:"text-[11px] text-[#9CA3AF] dark:text-[#71717a] font-mono",children:"Syntax highlighting colors"})]}),e.jsxs("select",{value:s.theme,onChange:t=>s.updateSettings({theme:t.target.value}),className:"h-8 bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono rounded-md px-3 border border-[#E5E7EB] dark:border-[#27272a]",children:[e.jsx("option",{value:"dracula",children:"Dracula"}),e.jsx("option",{value:"monokai",children:"Monokai"}),e.jsx("option",{value:"nord",children:"Nord"}),e.jsx("option",{value:"tokyo-night",children:"Tokyo Night"}),e.jsx("option",{value:"one-dark",children:"One Dark"}),e.jsx("option",{value:"catppuccin",children:"Catppuccin"}),e.jsx("option",{value:"gruvbox",children:"Gruvbox"}),e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"solarized-light",children:"Solarized Light"}),e.jsx("option",{value:"solarized-dark",children:"Solarized Dark"}),e.jsx("option",{value:"ayu-dark",children:"Ayu Dark"}),e.jsx("option",{value:"rose-pine",children:"Rose Pine"}),e.jsx("option",{value:"kanagawa",children:"Kanagawa"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Notifications"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Build finished"}),e.jsx(g,{enabled:s.notifyBuild,onChange:t=>s.updateSettings({notifyBuild:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Errors only"}),e.jsx(g,{enabled:s.notifyErrors,onChange:t=>s.updateSettings({notifyErrors:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"System sounds"}),e.jsx(g,{enabled:s.notifySounds,onChange:t=>s.updateSettings({notifySounds:t})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-[14px] text-[#111827] dark:text-[#E5E5E5] font-mono font-semibold",children:"Privacy"}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Telemetry"}),e.jsx(g,{enabled:s.privacyTelemetry,onChange:t=>s.updateSettings({privacyTelemetry:t})})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-[13px] text-[#6B7280] dark:text-[#a1a1aa] font-mono",children:"Crash reports"}),e.jsx(g,{enabled:s.privacyCrash,onChange:t=>s.updateSettings({privacyCrash:t})})]})]})]}),r==="shortcuts"&&e.jsxs("div",{className:"flex flex-col gap-4 flex-1 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx("input",{value:k,onChange:t=>S(t.target.value),placeholder:"Search actions...",className:"flex-1 h-9 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono"}),e.jsxs("select",{value:F,onChange:t=>A(t.target.value),className:"h-9 bg-[#F3F4F6] dark:bg-[#18181b] border border-[#E5E7EB] dark:border-[#27272a] rounded-md px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono",children:[e.jsx("option",{value:"all",children:"All scopes"}),e.jsx("option",{value:"global",children:"Global"}),e.jsx("option",{value:"chat",children:"Chat"}),e.jsx("option",{value:"layout",children:"Layout"}),e.jsx("option",{value:"history",children:"History"})]}),e.jsx("button",{onClick:()=>{S(""),A("all")},className:"h-9 px-3 rounded-md bg-[#E5E7EB] dark:bg-[#27272a] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:"Reset"})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto border border-[#E5E7EB] dark:border-[#27272a] rounded-lg bg-[#E5E7EB] dark:bg-[#111827]",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 bg-white dark:bg-[#0C0C0C] text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono font-semibold",children:[e.jsx("span",{children:"Action"}),e.jsx("span",{children:"Shortcut"}),e.jsx("span",{children:"Scope"})]}),D.map((t,l)=>e.jsxs("div",{className:b("grid grid-cols-[1fr_180px_120px] gap-2 px-3 py-2 text-[13px] font-mono",l%2===0?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C]"),children:[e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:t.action}),e.jsx("div",{className:"flex items-center gap-1",children:t.combo.map(m=>e.jsx("span",{className:"px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[12px] font-mono font-semibold",children:m},m))}),e.jsx("span",{className:"text-[#6B7280] dark:text-[#94a3b8] text-[12px]",children:t.scope})]},`${t.action}-${t.scope}`)),D.length===0&&e.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-[#6B7280] dark:text-[#94a3b8] font-mono",children:"No shortcuts found."})]})]})]})]})]})}),e.jsx(Y,{open:o,onOpenChange:i,onSave:I}),e.jsx(q,{open:!!w,onOpenChange:t=>!t&&v(null),model:w,onSave:$})]})}function g({enabled:p,onChange:c}){return e.jsx("button",{onClick:()=>c(!p),className:b("w-10 h-5 rounded-full px-0.5 flex items-center transition-colors",p?"bg-[#22C55E]":"bg-[#E5E7EB] dark:bg-[#27272a]"),children:e.jsx("span",{className:b("h-4 w-4 rounded-full transition-transform",p?"translate-x-5 bg-white":"translate-x-0 bg-white dark:bg-[#a1a1aa]")})})}export{re as SettingsModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as n}from"./index-
|
|
1
|
+
import{g as n}from"./index-BJTSF3fc.js";const c=s=>s==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches:s==="dark",i=s=>{const t=document.documentElement;if(t.classList.remove("light","dark"),s==="system"){const r=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";t.classList.add(r)}else t.classList.add(s)},o={language:"zh-CN",theme:"dracula",uiTheme:"system",autoSaveSessions:!0,notifyBuild:!0,notifyErrors:!1,notifySounds:!1,privacyTelemetry:!1,privacyCrash:!0},l=n((s,t)=>({...o,isLoading:!1,error:null,loadSettings:async()=>{s({isLoading:!0,error:null});try{const r=await fetch("/configs");if(!r.ok)throw new Error("Failed to load settings");const e=await r.json(),a=e.uiTheme??o.uiTheme;s({language:e.language??o.language,theme:e.theme??o.theme,uiTheme:a,autoSaveSessions:e.autoSaveSessions??o.autoSaveSessions,notifyBuild:e.notifyBuild??o.notifyBuild,notifyErrors:e.notifyErrors??o.notifyErrors,notifySounds:e.notifySounds??o.notifySounds,privacyTelemetry:e.privacyTelemetry??o.privacyTelemetry,privacyCrash:e.privacyCrash??o.privacyCrash,isLoading:!1}),i(a)}catch(r){s({error:r.message,isLoading:!1})}},updateSettings:async r=>{const e=t();s({...r,error:null}),r.uiTheme&&i(r.uiTheme);try{if(!(await fetch("/configs",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:r,options:{scope:"global"}})})).ok)throw new Error("Failed to save settings")}catch(a){s({language:e.language,theme:e.theme,uiTheme:e.uiTheme,autoSaveSessions:e.autoSaveSessions,notifyBuild:e.notifyBuild,notifyErrors:e.notifyErrors,notifySounds:e.notifySounds,privacyTelemetry:e.privacyTelemetry,privacyCrash:e.privacyCrash,error:a.message}),r.uiTheme&&i(e.uiTheme)}}}));i(o.uiTheme);const u=()=>l(s=>c(s.uiTheme));export{u as a,l as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,j as e}from"./vendor-react-BalntB5F.js";import{u as q,D as I,a as D,b as T,c as h}from"./index-9kl44E8k.js";import{e as v}from"./useRequest-DITGl55G.js";import{P as z,z as M,X as L,e as H}from"./vendor-icons-BuFpOlRn.js";import"./vendor-markdown-Bo4W9Tae.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-CESj0OOY.js";const J=async()=>{const a=await fetch("/skills");if(!a.ok)throw new Error("Failed to fetch skills");return a.json()},$=async()=>{const a=await fetch("/skills/catalog");if(!a.ok)throw new Error("Failed to fetch catalog");return a.json()};function te(){const{isSkillsOpen:a,toggleSkills:r}=q(),[d,c]=o.useState(null),[f,n]=o.useState(""),[p,u]=o.useState(!1),[C,i]=o.useState(!1),[F,x]=o.useState("confirm"),[w,m]=o.useState(null),[k,j]=o.useState(null),{data:b=[],loading:E,run:g}=v(J,{refreshDeps:[a],ready:a,onSuccess:t=>{t.length>0&&!d&&c(t[0].id)}}),{data:s=[]}=v($,{refreshDeps:[a],ready:a}),{runAsync:y}=v(async t=>{await fetch(`/skills/${encodeURIComponent(t)}`,{method:"DELETE"})},{manual:!0,onSuccess:g}),{runAsync:A,loading:S}=v(async(t,N)=>{if(!(await fetch(`/skills/${encodeURIComponent(t)}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:N})})).ok)throw new Error("Failed to toggle skill")},{manual:!0,onSuccess:g}),O=b.filter(t=>t.name.toLowerCase().includes(f.toLowerCase())),l=o.useMemo(()=>b.find(t=>t.id===d)??b[0],[b,d]),R=()=>{u(!0)},P=t=>{j(t),m(null),x("confirm"),i(!0)},U=async()=>{if(k){x("installing"),m(null);try{const t=await fetch("/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)}),N=await t.json().catch(()=>({}));if(!t.ok||N.success===!1)throw new Error(N.error||"Failed to install skill");await g(),i(!1),u(!1)}catch(t){m(t instanceof Error?t.message:"Failed to install skill"),x("failed")}}};return e.jsxs(o.Fragment,{children:[e.jsx(I,{open:a,onOpenChange:r,children:e.jsxs(D,{className:"sm:max-w-[820px] h-[620px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl flex flex-col","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Skills"}),e.jsx("div",{className:"flex h-full min-h-0",children:e.jsxs("div",{className:"flex-1 p-8 flex flex-col gap-5 min-h-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:R,className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(z,{className:"h-3.5 w-3.5"}),"Install skill"]}),e.jsx("button",{onClick:g,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",disabled:E,children:e.jsx(M,{className:h("h-4 w-4",E&&"animate-spin")})}),e.jsx("button",{onClick:r,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(L,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex gap-5 flex-1 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-[220px] flex flex-col gap-3 min-h-0 overflow-hidden",children:[e.jsx("div",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:"Installed"}),e.jsx("input",{value:f,onChange:t=>n(t.target.value),placeholder:"Search skills...",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a] shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-2 overflow-y-auto flex-1 min-h-0 pr-1",children:[O.length===0&&!E&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No skills installed"}),O.map(t=>e.jsxs("button",{onClick:()=>c(t.id),className:h("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors",t.id===d?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("span",{className:h("text-[11px] font-mono font-semibold",t.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#f59e0b]"),children:t.enabled?"Enabled":"Disabled"})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:t.description||"No description"})]},t.id))]})]}),l?e.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-y-auto pr-2 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:l.name}),e.jsxs("span",{className:"text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["v",l.version]})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:l.description||"No description available"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>A(l.name,!l.enabled),disabled:S,className:h("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",l.enabled?"bg-[#E5E7EB] text-[#111827] hover:bg-[#D1D5DB] dark:bg-[#27272a] dark:text-[#E5E5E5] dark:hover:bg-[#32323a]":"bg-[#16A34A] text-white hover:bg-[#15803D] dark:bg-[#22C55E] dark:text-[#0C0C0C] dark:hover:bg-[#1ea34b]",S&&"opacity-60 cursor-not-allowed"),children:S?"Saving...":l.enabled?"Disable":"Enable"}),e.jsx("button",{disabled:!0,title:"Editing not supported yet",className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold opacity-60 cursor-not-allowed",children:"Edit"}),e.jsxs("button",{onClick:()=>y(l.name),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold flex items-center gap-1",children:[e.jsx(H,{className:"h-3 w-3"}),"Uninstall"]})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[12px] font-mono",children:[e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:"Provider"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:l.provider}),e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:"Location"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5] truncate",children:l.location})]})]}),l.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Capabilities"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.capabilities.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))})]}),l.allowedTools.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:["Allowed Tools (",l.allowedTools.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.allowedTools.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"Select a skill to view details"})})]})]})})]})}),e.jsx(G,{open:p,catalog:s,installed:b.map(t=>t.name),onOpenChange:u,onInstall:P}),e.jsx(Q,{open:C,status:F,error:w,onCancel:()=>i(!1),onConfirm:U,onRetry:()=>x("confirm")})]})}function B({active:a,children:r,onClick:d}){return e.jsx("button",{onClick:d,className:h("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",a?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:r})}function G({open:a,onOpenChange:r,onInstall:d,catalog:c,installed:f}){const[n,p]=o.useState("catalog"),[u,C]=o.useState(""),[i,F]=o.useState(null),[x,w]=o.useState(""),[m,k]=o.useState(""),j=c.filter(s=>s.name.toLowerCase().includes(u.toLowerCase())),b=()=>{if(n==="catalog"){if(!i)return;d({source:"catalog",name:i});return}if(n==="repo"){if(!x)return;d({source:"repo",url:x});return}m&&d({source:"local",path:m})},E=i?f.includes(i):!1,g=n==="catalog"&&(!i||E)||n==="repo"&&!x||n==="local"&&!m;return e.jsx(I,{open:a,onOpenChange:r,children:e.jsxs(D,{className:"sm:max-w-[540px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Install Skill"}),e.jsxs("div",{className:"p-6 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Install Skill"}),e.jsx("button",{onClick:()=>r(!1),className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(L,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(B,{active:n==="catalog",onClick:()=>p("catalog"),children:"Catalog"}),e.jsx(B,{active:n==="repo",onClick:()=>p("repo"),children:"Repo"}),e.jsx(B,{active:n==="local",onClick:()=>p("local"),children:"Local"})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[n==="catalog"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{value:u,onChange:s=>C(s.target.value),placeholder:"Search catalog...",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsxs("div",{className:"flex flex-col gap-2 max-h-[240px] overflow-y-auto",children:[j.length===0&&e.jsx("div",{className:"text-center py-6 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No skills found"}),j.map(s=>{const y=f.includes(s.name),A=i===s.name;return e.jsxs("button",{onClick:()=>F(s.name),className:h("rounded-lg px-3 py-2 flex flex-col gap-1 text-left transition-colors",A?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:s.name}),e.jsx("span",{className:h("text-[10px] font-mono px-2 py-0.5 rounded",s.tag==="Official"?"bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:s.tag})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:s.description}),e.jsxs("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["by ",s.author]}),y&&e.jsx("span",{className:"text-[10px] font-mono text-[#16A34A] dark:text-[#22C55E]",children:"Installed"})]},s.name)})]})]}),n==="repo"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"GitHub URL"}),e.jsx("input",{value:x,onChange:s=>w(s.target.value),placeholder:"https://github.com/org/skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsx("span",{className:"inline-flex w-fit px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Private repo supported (backend support required)"})]}),n==="local"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Local path"}),e.jsx("input",{value:m,onChange:s=>k(s.target.value),placeholder:"/Users/bytedance/skills/my-skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:()=>r(!1),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:b,disabled:g,className:h("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",g?"bg-[#E5E7EB] text-[#9CA3AF] cursor-not-allowed dark:bg-[#27272a] dark:text-[#71717a]":"bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C]"),children:"Install"})]})]})]})})}function Q({open:a,status:r,error:d,onCancel:c,onConfirm:f,onRetry:n}){return e.jsx(I,{open:a,onOpenChange:p=>!p&&c(),children:e.jsxs(D,{className:"sm:max-w-[320px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Install Status"}),e.jsxs("div",{className:"p-5 flex flex-col gap-3",children:[r==="confirm"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Confirm Install"}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Install selected skill?"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:c,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:f,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Install"})]})]}),r==="installing"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Installing"}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Downloading and verifying…"}),e.jsx("div",{className:"h-1.5 rounded-full bg-[#E5E7EB] dark:bg-[#18181b] overflow-hidden",children:e.jsx("div",{className:"h-full w-[45%] bg-[#16A34A] dark:bg-[#22C55E]"})}),e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"~35%"}),e.jsx("button",{onClick:c,className:"self-end h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Hide"})]}),r==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Install Failed"}),e.jsx("p",{className:"text-[12px] font-mono text-[#f87171]",children:d||"Installation failed."}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Check access and try again."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:c,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Close"}),e.jsx("button",{onClick:n,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Retry"})]})]})]})]})})}export{te as SkillsModal};
|
|
1
|
+
import{r as o,j as e}from"./vendor-react-BalntB5F.js";import{u as q,D as I,a as D,b as T,c as h}from"./index-BJTSF3fc.js";import{e as v}from"./useRequest-DITGl55G.js";import{P as z,z as M,X as L,e as H}from"./vendor-icons-BuFpOlRn.js";import"./vendor-markdown-Bo4W9Tae.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-CESj0OOY.js";const J=async()=>{const a=await fetch("/skills");if(!a.ok)throw new Error("Failed to fetch skills");return a.json()},$=async()=>{const a=await fetch("/skills/catalog");if(!a.ok)throw new Error("Failed to fetch catalog");return a.json()};function te(){const{isSkillsOpen:a,toggleSkills:r}=q(),[d,c]=o.useState(null),[f,n]=o.useState(""),[p,u]=o.useState(!1),[C,i]=o.useState(!1),[F,x]=o.useState("confirm"),[w,m]=o.useState(null),[k,j]=o.useState(null),{data:b=[],loading:E,run:g}=v(J,{refreshDeps:[a],ready:a,onSuccess:t=>{t.length>0&&!d&&c(t[0].id)}}),{data:s=[]}=v($,{refreshDeps:[a],ready:a}),{runAsync:y}=v(async t=>{await fetch(`/skills/${encodeURIComponent(t)}`,{method:"DELETE"})},{manual:!0,onSuccess:g}),{runAsync:A,loading:S}=v(async(t,N)=>{if(!(await fetch(`/skills/${encodeURIComponent(t)}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:N})})).ok)throw new Error("Failed to toggle skill")},{manual:!0,onSuccess:g}),O=b.filter(t=>t.name.toLowerCase().includes(f.toLowerCase())),l=o.useMemo(()=>b.find(t=>t.id===d)??b[0],[b,d]),R=()=>{u(!0)},P=t=>{j(t),m(null),x("confirm"),i(!0)},U=async()=>{if(k){x("installing"),m(null);try{const t=await fetch("/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)}),N=await t.json().catch(()=>({}));if(!t.ok||N.success===!1)throw new Error(N.error||"Failed to install skill");await g(),i(!1),u(!1)}catch(t){m(t instanceof Error?t.message:"Failed to install skill"),x("failed")}}};return e.jsxs(o.Fragment,{children:[e.jsx(I,{open:a,onOpenChange:r,children:e.jsxs(D,{className:"sm:max-w-[820px] h-[620px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl flex flex-col","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Skills"}),e.jsx("div",{className:"flex h-full min-h-0",children:e.jsxs("div",{className:"flex-1 p-8 flex flex-col gap-5 min-h-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:R,className:"h-8 px-3 rounded-md bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5] text-xs font-mono font-semibold flex items-center gap-1 hover:bg-[#D1D5DB] dark:hover:bg-[#32323a]",children:[e.jsx(z,{className:"h-3.5 w-3.5"}),"Install skill"]}),e.jsx("button",{onClick:g,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",disabled:E,children:e.jsx(M,{className:h("h-4 w-4",E&&"animate-spin")})}),e.jsx("button",{onClick:r,className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(L,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex gap-5 flex-1 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-[220px] flex flex-col gap-3 min-h-0 overflow-hidden",children:[e.jsx("div",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5] shrink-0",children:"Installed"}),e.jsx("input",{value:f,onChange:t=>n(t.target.value),placeholder:"Search skills...",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a] shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-2 overflow-y-auto flex-1 min-h-0 pr-1",children:[O.length===0&&!E&&e.jsx("div",{className:"text-center py-8 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No skills installed"}),O.map(t=>e.jsxs("button",{onClick:()=>c(t.id),className:h("text-left rounded-lg px-3 py-2 flex flex-col gap-1 transition-colors",t.id===d?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:t.name}),e.jsx("span",{className:h("text-[11px] font-mono font-semibold",t.enabled?"text-[#16A34A] dark:text-[#22C55E]":"text-[#f59e0b]"),children:t.enabled?"Enabled":"Disabled"})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8] truncate",children:t.description||"No description"})]},t.id))]})]}),l?e.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-y-auto pr-2 min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-base font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:l.name}),e.jsxs("span",{className:"text-xs font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["v",l.version]})]}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:l.description||"No description available"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>A(l.name,!l.enabled),disabled:S,className:h("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",l.enabled?"bg-[#E5E7EB] text-[#111827] hover:bg-[#D1D5DB] dark:bg-[#27272a] dark:text-[#E5E5E5] dark:hover:bg-[#32323a]":"bg-[#16A34A] text-white hover:bg-[#15803D] dark:bg-[#22C55E] dark:text-[#0C0C0C] dark:hover:bg-[#1ea34b]",S&&"opacity-60 cursor-not-allowed"),children:S?"Saving...":l.enabled?"Disable":"Enable"}),e.jsx("button",{disabled:!0,title:"Editing not supported yet",className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold opacity-60 cursor-not-allowed",children:"Edit"}),e.jsxs("button",{onClick:()=>y(l.name),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#ef4444] text-[11px] font-mono font-semibold flex items-center gap-1",children:[e.jsx(H,{className:"h-3 w-3"}),"Uninstall"]})]}),e.jsx("div",{className:"h-px bg-[#E5E7EB] dark:bg-[#1f2937]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[12px] font-mono",children:[e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:"Provider"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5]",children:l.provider}),e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a]",children:"Location"}),e.jsx("span",{className:"text-[#111827] dark:text-[#E5E5E5] truncate",children:l.location})]})]}),l.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Capabilities"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.capabilities.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))})]}),l.allowedTools.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:["Allowed Tools (",l.allowedTools.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.allowedTools.map(t=>e.jsx("span",{className:"px-2 py-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#111827] dark:text-[#E5E5E5]",children:t},t))})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("span",{className:"text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"Select a skill to view details"})})]})]})})]})}),e.jsx(G,{open:p,catalog:s,installed:b.map(t=>t.name),onOpenChange:u,onInstall:P}),e.jsx(Q,{open:C,status:F,error:w,onCancel:()=>i(!1),onConfirm:U,onRetry:()=>x("confirm")})]})}function B({active:a,children:r,onClick:d}){return e.jsx("button",{onClick:d,className:h("px-3 py-1 rounded text-[12px] font-mono font-semibold transition-colors",a?"bg-[#E5E7EB] text-[#111827] dark:bg-[#27272a] dark:text-[#E5E5E5]":"text-[#6B7280] dark:text-[#a1a1aa]"),children:r})}function G({open:a,onOpenChange:r,onInstall:d,catalog:c,installed:f}){const[n,p]=o.useState("catalog"),[u,C]=o.useState(""),[i,F]=o.useState(null),[x,w]=o.useState(""),[m,k]=o.useState(""),j=c.filter(s=>s.name.toLowerCase().includes(u.toLowerCase())),b=()=>{if(n==="catalog"){if(!i)return;d({source:"catalog",name:i});return}if(n==="repo"){if(!x)return;d({source:"repo",url:x});return}m&&d({source:"local",path:m})},E=i?f.includes(i):!1,g=n==="catalog"&&(!i||E)||n==="repo"&&!x||n==="local"&&!m;return e.jsx(I,{open:a,onOpenChange:r,children:e.jsxs(D,{className:"sm:max-w-[540px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Install Skill"}),e.jsxs("div",{className:"p-6 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-[#111827] dark:text-[#E5E5E5] font-mono",children:"Install Skill"}),e.jsx("button",{onClick:()=>r(!1),className:"h-8 w-8 rounded-md text-[#9CA3AF] hover:text-[#111827] hover:bg-[#E5E7EB] dark:text-[#71717a] dark:hover:text-[#E5E5E5] dark:hover:bg-[#27272a] transition-colors flex items-center justify-center",children:e.jsx(L,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] w-fit",children:[e.jsx(B,{active:n==="catalog",onClick:()=>p("catalog"),children:"Catalog"}),e.jsx(B,{active:n==="repo",onClick:()=>p("repo"),children:"Repo"}),e.jsx(B,{active:n==="local",onClick:()=>p("local"),children:"Local"})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[n==="catalog"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{value:u,onChange:s=>C(s.target.value),placeholder:"Search catalog...",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsxs("div",{className:"flex flex-col gap-2 max-h-[240px] overflow-y-auto",children:[j.length===0&&e.jsx("div",{className:"text-center py-6 text-[#9CA3AF] dark:text-[#71717a] text-sm font-mono",children:"No skills found"}),j.map(s=>{const y=f.includes(s.name),A=i===s.name;return e.jsxs("button",{onClick:()=>F(s.name),className:h("rounded-lg px-3 py-2 flex flex-col gap-1 text-left transition-colors",A?"bg-[#E5E7EB] dark:bg-[#111827]":"bg-white dark:bg-[#0C0C0C] hover:bg-[#F3F4F6] dark:hover:bg-[#18181b]"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:s.name}),e.jsx("span",{className:h("text-[10px] font-mono px-2 py-0.5 rounded",s.tag==="Official"?"bg-[#22C55E]/20 text-[#16A34A] dark:text-[#22C55E]":"bg-[#3b82f6]/20 text-[#3b82f6]"),children:s.tag})]}),e.jsx("span",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:s.description}),e.jsxs("span",{className:"text-[10px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:["by ",s.author]}),y&&e.jsx("span",{className:"text-[10px] font-mono text-[#16A34A] dark:text-[#22C55E]",children:"Installed"})]},s.name)})]})]}),n==="repo"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"GitHub URL"}),e.jsx("input",{value:x,onChange:s=>w(s.target.value),placeholder:"https://github.com/org/skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"}),e.jsx("span",{className:"inline-flex w-fit px-2 py-0.5 rounded bg-[#F3F4F6] dark:bg-[#18181b] text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Private repo supported (backend support required)"})]}),n==="local"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#a1a1aa]",children:"Local path"}),e.jsx("input",{value:m,onChange:s=>k(s.target.value),placeholder:"/Users/bytedance/skills/my-skill",className:"h-8 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] px-3 text-[12px] text-[#111827] dark:text-[#E5E5E5] font-mono placeholder:text-[#9CA3AF] dark:placeholder:text-[#71717a] border border-transparent focus:outline-none focus:border-[#E5E7EB] dark:focus:border-[#27272a]"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:()=>r(!1),className:"h-7 px-3 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:b,disabled:g,className:h("h-7 px-3 rounded-md text-[11px] font-mono font-semibold",g?"bg-[#E5E7EB] text-[#9CA3AF] cursor-not-allowed dark:bg-[#27272a] dark:text-[#71717a]":"bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C]"),children:"Install"})]})]})]})})}function Q({open:a,status:r,error:d,onCancel:c,onConfirm:f,onRetry:n}){return e.jsx(I,{open:a,onOpenChange:p=>!p&&c(),children:e.jsxs(D,{className:"sm:max-w-[320px] p-0 overflow-hidden gap-0 bg-white dark:bg-[#09090b] border border-[#E5E7EB] dark:border-zinc-800 rounded-xl","aria-describedby":void 0,hideCloseButton:!0,children:[e.jsx(T,{className:"sr-only",children:"Install Status"}),e.jsxs("div",{className:"p-5 flex flex-col gap-3",children:[r==="confirm"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Confirm Install"}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Install selected skill?"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:c,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Cancel"}),e.jsx("button",{onClick:f,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Install"})]})]}),r==="installing"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Installing"}),e.jsx("p",{className:"text-[12px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Downloading and verifying…"}),e.jsx("div",{className:"h-1.5 rounded-full bg-[#E5E7EB] dark:bg-[#18181b] overflow-hidden",children:e.jsx("div",{className:"h-full w-[45%] bg-[#16A34A] dark:bg-[#22C55E]"})}),e.jsx("span",{className:"text-[11px] font-mono text-[#9CA3AF] dark:text-[#71717a]",children:"~35%"}),e.jsx("button",{onClick:c,className:"self-end h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Hide"})]}),r==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-sm font-mono font-semibold text-[#111827] dark:text-[#E5E5E5]",children:"Install Failed"}),e.jsx("p",{className:"text-[12px] font-mono text-[#f87171]",children:d||"Installation failed."}),e.jsx("p",{className:"text-[11px] font-mono text-[#6B7280] dark:text-[#94a3b8]",children:"Check access and try again."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:c,className:"h-6 px-2.5 rounded-md bg-[#F3F4F6] dark:bg-[#18181b] text-[#111827] dark:text-[#E5E5E5] text-[11px] font-mono font-semibold",children:"Close"}),e.jsx("button",{onClick:n,className:"h-6 px-2.5 rounded-md bg-[#16A34A] text-white dark:bg-[#22C55E] dark:text-[#0C0C0C] text-[11px] font-mono font-semibold",children:"Retry"})]})]})]})]})})}export{te as SkillsModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as t}from"./vendor-react-BalntB5F.js";import{u as B,c as m}from"./index-
|
|
1
|
+
import{r,j as t}from"./vendor-react-BalntB5F.js";import{u as B,c as m}from"./index-BJTSF3fc.js";import{a as z}from"./SettingsStore-jup_Kikq.js";import{D as y,o as A,L as v}from"./vendor-xterm-DuYZoU4T.js";import{T as j,M as C,X as N}from"./vendor-icons-BuFpOlRn.js";import"./vendor-markdown-Bo4W9Tae.js";import"./vendor-monaco-w6PwaWGP.js";import"./vendor-radix-CESj0OOY.js";const I=()=>{const{isTerminalOpen:s,toggleTerminal:x}=B(),[i,p]=r.useState(!1),[E,l]=r.useState(!1),d=z(),u=r.useRef(null),o=r.useRef(null),b=r.useRef(null),c=r.useRef(null),k=r.useCallback(()=>{var a;if(((a=c.current)==null?void 0:a.readyState)===WebSocket.OPEN)return;const n=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/terminal/ws`,e=new WebSocket(n);c.current=e,e.onopen=()=>{l(!0)},e.onmessage=h=>{var f;(f=o.current)==null||f.write(h.data)},e.onclose=()=>{l(!1)},e.onerror=()=>{l(!1)}},[]),g=r.useCallback(()=>{c.current&&(c.current.close(),c.current=null),l(!1)},[]),w=r.useCallback(n=>{var e;((e=c.current)==null?void 0:e.readyState)===WebSocket.OPEN&&c.current.send(n)},[]);return r.useEffect(()=>{if(!s||!u.current||o.current)return;const n={background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"},e=new y({cursorBlink:!0,cursorStyle:"bar",fontSize:14,fontFamily:"JetBrains Mono, Menlo, Monaco, Consolas, monospace",allowTransparency:!0,scrollback:1e4,theme:d?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:n}),a=new A,h=new v;return e.loadAddon(a),e.loadAddon(h),e.open(u.current),a.fit(),e.onData(f=>{w(f)}),o.current=e,b.current=a,k(),()=>{g(),e.dispose(),o.current=null,b.current=null}},[s,k,g,w]),r.useEffect(()=>{o.current&&(o.current.options.theme=d?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:{background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"})},[d]),r.useEffect(()=>{if(!s||i)return;const n=()=>{var a;(a=b.current)==null||a.fit()};window.addEventListener("resize",n);const e=setTimeout(n,100);return()=>{window.removeEventListener("resize",n),clearTimeout(e)}},[s,i]),s?t.jsxs("div",{className:m("fixed bottom-0 left-0 right-0 z-40 bg-white dark:bg-[#0a0a0a] border-t border-[#E5E7EB] dark:border-zinc-800 transition-all duration-200",i?"h-10":"h-72"),children:[t.jsxs("div",{className:"flex items-center justify-between h-10 px-3 border-b border-[#E5E7EB] dark:border-zinc-800 bg-[#F9FAFB] dark:bg-zinc-900/50",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(j,{className:"h-4 w-4 text-[#9CA3AF] dark:text-zinc-400"}),t.jsx("span",{className:"text-sm text-[#6B7280] dark:text-zinc-400",children:"Terminal"}),t.jsx("span",{className:m("w-2 h-2 rounded-full",E?"bg-green-500":"bg-zinc-600")})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>p(!i),className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:t.jsx(C,{className:"h-4 w-4"})}),t.jsx("button",{onClick:()=>{g(),x()},className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:t.jsx(N,{className:"h-4 w-4"})})]})]}),t.jsx("div",{ref:u,className:m("h-[calc(100%-40px)] p-2",i&&"hidden")})]}):null};export{I as TerminalPanel};
|