@yxp934/prompt-tree 0.2.0 → 0.4.0
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/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +4 -4
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/react-loadable-manifest.json +9 -1
- package/.next/standalone/.next/server/app/_global-error/page.js +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +2 -2
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/agent/route.js +2 -2
- package/.next/standalone/.next/server/app/api/agent/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/route.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/providers/health/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/providers/models/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/providers/test/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tools/mcp/call-tool/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tools/mcp/list-tools/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tools/mcp/test/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tools/python/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/tools/search/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/index.html +2 -2
- package/.next/standalone/.next/server/app/index.rsc +4 -4
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page.js +5 -3
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/page.js +2 -2
- package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings.html +1 -1
- package/.next/standalone/.next/server/app/settings.rsc +4 -4
- package/.next/standalone/.next/server/app/settings.segments/_full.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings.segments/settings.segment.rsc +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +4 -4
- package/.next/standalone/.next/server/chunks/270.js +2 -0
- package/.next/standalone/.next/server/chunks/471.js +4 -4
- package/.next/standalone/.next/server/chunks/689.js +1 -1
- package/.next/standalone/.next/server/chunks/732.js +4 -4
- package/.next/standalone/.next/server/chunks/734.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/.next/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +2 -2
- package/.next/standalone/.next/static/chunks/394-ce05579db22c8557.js +30 -0
- package/.next/standalone/.next/static/chunks/619.cfe242be4c0b83c0.js +1 -0
- package/.next/standalone/.next/static/chunks/787-849e95c38cdb12c0.js +1 -0
- package/.next/standalone/.next/static/chunks/991-3901e4f7973e3bc4.js +4 -0
- package/.next/standalone/.next/static/chunks/9b0008ae.ebbbe0264e8b748d.js +2 -0
- package/.next/standalone/.next/static/chunks/app/_global-error/page-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/agent/route-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/chat/route-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/providers/health/route-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/providers/models/route-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/providers/test/route-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tools/mcp/call-tool/route-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tools/mcp/list-tools/route-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tools/mcp/test/route-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tools/python/route-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/app/api/tools/search/route-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/app/page-92589c153be1ab8e.js +1 -0
- package/.next/standalone/.next/static/chunks/app/settings/page-ed3f1cc8a5f36f5c.js +1 -0
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-f2489837ae5d03e0.js +1 -0
- package/.next/standalone/.next/static/chunks/webpack-d7f56a24ad86f880.js +1 -0
- package/.next/standalone/.next/static/css/94729c1505529f29.css +1 -0
- package/.next/standalone/package.json +2 -1
- package/README.md +134 -120
- package/README.zh-CN.md +200 -0
- package/package.json +2 -1
- package/.next/standalone/.next/static/chunks/308-9aca2a7bf1797568.js +0 -2
- package/.next/standalone/.next/static/chunks/394-1e8c9367852fd6d7.js +0 -30
- package/.next/standalone/.next/static/chunks/787-56a48f915165efd3.js +0 -1
- package/.next/standalone/.next/static/chunks/app/_global-error/page-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/agent/route-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/chat/route-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/providers/health/route-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/providers/models/route-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/providers/test/route-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tools/mcp/call-tool/route-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tools/mcp/list-tools/route-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tools/mcp/test/route-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tools/python/route-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/app/api/tools/search/route-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/app/page-c273f2f3b7ce1609.js +0 -1
- package/.next/standalone/.next/static/chunks/app/settings/page-0fc8a4cbf639025c.js +0 -1
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-f941084711d16ad3.js +0 -1
- package/.next/standalone/.next/static/chunks/webpack-03a911206b5adca4.js +0 -1
- package/.next/standalone/.next/static/css/100bba9d1b2ebade.css +0 -1
- /package/.next/standalone/.next/static/{wYfac0R-RsurEa801s_qH → bgKGmnmkLXkhuKgbJwKVn}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{wYfac0R-RsurEa801s_qH → bgKGmnmkLXkhuKgbJwKVn}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
package/.next/standalone/.next/static/chunks/app/api/providers/health/route-f2489837ae5d03e0.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
package/.next/standalone/.next/static/chunks/app/api/providers/models/route-f2489837ae5d03e0.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
package/.next/standalone/.next/static/chunks/app/api/tools/mcp/call-tool/route-f2489837ae5d03e0.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
package/.next/standalone/.next/static/chunks/app/api/tools/mcp/list-tools/route-f2489837ae5d03e0.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{109:(e,t,r)=>{Promise.resolve().then(r.bind(r,5499))},5499:(e,t,r)=>{"use strict";r.d(t,{default:()=>eF});var n=r(5155),o=r(2115),a=r(513),s=r(8353),l=r(3271),i=r(1115),d=r(4394),c=r(6728);function m({variant:e="primary",className:t="",...r}){return(0,n.jsx)("button",{type:"button",className:`inline-flex items-center justify-center rounded-[10px] px-4 py-2 font-body text-[0.85rem] font-medium transition-all duration-150 disabled:cursor-not-allowed disabled:opacity-60 ${{primary:"bg-ink text-cream hover:bg-charcoal",secondary:"border border-parchment bg-paper text-ink hover:border-copper hover:bg-copper-glow",ghost:"bg-transparent text-clay hover:bg-paper hover:text-ink"}[e]} ${t}`,...r})}var p=r(966);function u(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",className:"h-full w-full",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}function x(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",className:"h-full w-full",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12h14M12 5l7 7-7 7"})})}function h({onSend:e,onAttachFiles:t,disabled:r,modelLabel:l,temperatureLabel:i,tokenLabel:d,modelOptions:c=[],selectedModels:h=[],onSelectedModelsChange:f,selectedTools:g=[],onSelectedToolsChange:b,toolSettings:v}){let j=(0,a.k)(),[y,w]=(0,o.useState)(""),[k,N]=(0,o.useState)(!1),[C,S]=(0,o.useState)(!1),_=(0,o.useRef)(null),M=(0,o.useRef)(null),U=(0,o.useRef)(null),E=(0,o.useRef)(null);(0,o.useEffect)(()=>{_.current&&(_.current.style.height="auto",_.current.style.height=`${Math.min(_.current.scrollHeight,180)}px`)},[y]);let T=async()=>{let t=y.trim();t&&(await e(t),w(""))},I=(0,o.useMemo)(()=>new Set(h.map(s.R)),[h]),A=(0,o.useMemo)(()=>new Set(g),[g]),L=(0,o.useMemo)(()=>[{id:"web_search",title:j("chat.input.tool.webSearch"),subtitle:"Exa / Tavily"},{id:"python",title:j("chat.input.tool.python"),subtitle:j("chat.input.tool.pythonSubtitle")},...(v?.mcp.servers??[]).map(e=>({id:`mcp:${e.id}`,title:e.name||e.id,subtitle:`MCP \xb7 ${e.transport} \xb7 ${e.id}`}))],[j,v?.mcp.servers]);return(0,o.useEffect)(()=>{if(!k&&!C)return;let e=e=>{let t=e.target;M.current&&M.current.contains(t)||U.current&&U.current.contains(t)||(N(!1),S(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[k,C]),(0,n.jsxs)("div",{className:"input-area-gradient shrink-0 px-8 pb-6 pt-5",children:[(0,n.jsxs)("div",{className:"relative max-w-[680px]",children:[(0,n.jsx)("textarea",{ref:_,className:"min-h-[60px] max-h-[180px] w-full resize-none rounded-2xl border border-parchment bg-paper px-6 py-4 pr-[120px] font-body text-[0.95rem] text-ink outline-none transition-all duration-200 placeholder:text-sand focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",placeholder:j("chat.input.placeholder"),rows:1,value:y,disabled:r,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),T())}}),(0,n.jsxs)("div",{className:"absolute bottom-3 right-3 flex gap-2",children:[(0,n.jsx)("button",{type:"button",className:"flex h-9 w-9 items-center justify-center rounded-[10px] bg-transparent text-sand transition-all duration-150 hover:bg-cream hover:text-ink disabled:opacity-50",disabled:r,"aria-label":j("chat.input.attach"),onClick:()=>E.current?.click(),children:(0,n.jsx)("div",{className:"h-[18px] w-[18px]",children:(0,n.jsx)(u,{})})}),(0,n.jsx)("input",{ref:E,className:"hidden",type:"file",multiple:!0,accept:(0,p.X)(),onChange:e=>{let r=Array.from(e.target.files??[]);r.length>0&&t?.(r),e.target.value=""}}),(0,n.jsx)(m,{variant:"primary",className:"h-10 w-10 rounded-[10px] px-0 hover:scale-105",disabled:r||!y.trim(),"aria-label":j("chat.input.send"),onClick:()=>void T(),children:(0,n.jsx)("div",{className:"h-7 w-7",children:(0,n.jsx)(x,{})})})]})]}),(0,n.jsxs)("div",{className:"mt-2 flex max-w-[680px] items-center gap-3 px-1 font-mono text-[0.7rem] text-sand",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("span",{children:l?j("chat.input.modelMeta",{model:l,tempPart:i?j("chat.input.tempPart",{temp:i}):""}):j("chat.input.modelMetaNone")}),c.length>0&&f?(0,n.jsxs)("div",{ref:M,className:"relative",children:[(0,n.jsxs)("button",{type:"button",className:"flex items-center gap-2 rounded-[10px] border border-parchment bg-paper px-3 py-1.5 text-[0.7rem] text-sand transition-all duration-150 hover:border-copper hover:text-ink",onClick:()=>N(e=>!e),disabled:r,children:[(0,n.jsx)("span",{children:j("chat.input.models")}),(0,n.jsx)("span",{className:"rounded-full bg-cream px-2 py-0.5 font-mono text-[0.65rem] text-clay",children:h.length})]}),k&&(0,n.jsxs)("div",{className:"absolute bottom-full left-0 mb-2 w-[260px] rounded-xl border border-parchment bg-paper p-3 shadow-[0_16px_40px_rgba(35,31,28,0.18)]",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between text-[0.65rem] uppercase tracking-[0.12em] text-sand",children:[(0,n.jsx)("span",{children:j("chat.input.enabledModels")}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{type:"button",className:"rounded-md border border-parchment px-2 py-1 text-[0.6rem] text-sand hover:border-copper hover:text-ink",onClick:()=>f(c.map(e=>({providerId:e.providerId,modelId:e.modelId}))),children:j("common.selectAll")}),(0,n.jsx)("button",{type:"button",className:"rounded-md border border-parchment px-2 py-1 text-[0.6rem] text-sand hover:border-copper hover:text-ink",onClick:()=>f([]),children:j("common.clear")})]})]}),(0,n.jsx)("div",{className:"max-h-[240px] space-y-2 overflow-y-auto pr-1",children:c.map(e=>{let t=I.has((0,s.R)(e));return(0,n.jsxs)("button",{type:"button",className:`flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-all ${t?"border-copper/50 bg-copper/10":"border-parchment/30 bg-shoji-white hover:border-copper/40"}`,onClick:()=>(e=>{if(!f)return;let t=(0,s.R)(e);f(I.has(t)?h.filter(e=>(0,s.R)(e)!==t):[...h,{providerId:e.providerId,modelId:e.modelId}])})(e),children:[(0,n.jsx)("span",{className:`flex h-4.5 w-4.5 items-center justify-center rounded border text-[0.6rem] ${t?"border-copper bg-copper text-white":"border-parchment bg-transparent text-transparent"}`,children:"✓"}),(0,n.jsxs)("div",{className:"flex-1",children:[(0,n.jsx)("div",{className:"font-mono text-[0.75rem] text-ink",children:e.modelId}),(0,n.jsx)("div",{className:"text-[0.65rem] text-sand",children:e.providerName})]})]},`${e.providerId}-${e.modelId}`)})})]})]}):null,b?(0,n.jsxs)("div",{ref:U,className:"relative",children:[(0,n.jsxs)("button",{type:"button",className:"flex items-center gap-2 rounded-[10px] border border-parchment bg-paper px-3 py-1.5 text-[0.7rem] text-sand transition-all duration-150 hover:border-copper hover:text-ink",onClick:()=>S(e=>!e),disabled:r,children:[(0,n.jsx)("span",{children:j("common.tools")}),(0,n.jsx)("span",{className:"rounded-full bg-cream px-2 py-0.5 font-mono text-[0.65rem] text-clay",children:g.length})]}),C&&(0,n.jsxs)("div",{className:"absolute bottom-full left-0 mb-2 w-[240px] rounded-xl border border-parchment bg-paper p-3 shadow-[0_16px_40px_rgba(35,31,28,0.18)]",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between text-[0.65rem] uppercase tracking-[0.12em] text-sand",children:[(0,n.jsx)("span",{children:j("chat.input.toolUse")}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{type:"button",className:"rounded-md border border-parchment px-2 py-1 text-[0.6rem] text-sand hover:border-copper hover:text-ink",onClick:()=>{b&&b(L.map(e=>e.id))},children:j("common.selectAll")}),(0,n.jsx)("button",{type:"button",className:"rounded-md border border-parchment px-2 py-1 text-[0.6rem] text-sand hover:border-copper hover:text-ink",onClick:()=>b([]),children:j("common.clear")})]})]}),(0,n.jsx)("div",{className:"space-y-2",children:L.map(e=>{let t=A.has(e.id);return(0,n.jsxs)("button",{type:"button",className:`flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-all ${t?"border-copper/50 bg-copper/10":"border-parchment/30 bg-shoji-white hover:border-copper/40"}`,onClick:()=>{var t;return t=e.id,void(!b||b(A.has(t)?g.filter(e=>e!==t):[...g,t]))},children:[(0,n.jsx)("span",{className:`flex h-4.5 w-4.5 items-center justify-center rounded border text-[0.6rem] ${t?"border-copper bg-copper text-white":"border-parchment bg-transparent text-transparent"}`,children:"✓"}),(0,n.jsxs)("div",{className:"flex-1",children:[(0,n.jsx)("div",{className:"font-mono text-[0.75rem] text-ink",children:e.title}),(0,n.jsx)("div",{className:"text-[0.65rem] text-sand",children:e.subtitle})]})]},e.id)})})]})]}):null]}),(0,n.jsx)("span",{className:"ml-auto",children:d??""})]})]})}var f=r(1766),g=r(7348);let b=["think","analysis","reasoning","thinking","thought","thoughts"],v=RegExp(`<\\s*(${b.join("|")})\\b[^>]*>`,"gi");function j(e){return function(e){let t=e.split(/\r?\n/),r=[],n=[],o=!1,a=[],s=()=>{if(0===a.length)return;let e=a.join("\n");a=[];let t=function(e){let t=[],r="",n=0;for(;;){v.lastIndex=n;let o=v.exec(e);if(!o)break;let a=o.index,s=a+o[0].length,l=(o[1]??"").toLowerCase();r+=e.slice(n,a);let i=RegExp(`</\\s*${l}\\s*>`,"gi");i.lastIndex=s;let d=i.exec(e);if(!d){t.push(e.slice(s)),n=e.length;break}t.push(e.slice(s,d.index)),n=d.index+d[0].length}return r+=e.slice(n),{visible:r=r.replace(RegExp(`</\\s*(${b.join("|")})\\s*>`,"gi"),""),thinkingBlocks:t}}(e);r.push(t.visible),n.push(...t.thinkingBlocks)};for(let e of t){if(e.trimStart().startsWith("```")){o||s(),o=!o,r.push(e);continue}if(o){r.push(e);continue}a.push(e)}return s(),{visible:r.join("\n"),thinkingBlocks:n}}(e)}var y=r(8426),w=r(2957);function k({content:e}){return(0,n.jsx)(y.oz,{remarkPlugins:[w.A],components:{p:({children:e,...t})=>(0,n.jsx)("p",{className:"whitespace-pre-wrap",...t,children:e}),li:({children:e,...t})=>(0,n.jsx)("li",{className:"whitespace-pre-wrap",...t,children:e})},children:e})}function N(){return(0,n.jsxs)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M8 8h9a2 2 0 012 2v9a2 2 0 01-2 2H8a2 2 0 01-2-2v-9a2 2 0 012-2z"}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M6 16H5a2 2 0 01-2-2V5a2 2 0 012-2h9a2 2 0 012 2v1"})]})}function C(){return(0,n.jsxs)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M3 12a9 9 0 0115.3-6.36M21 12a9 9 0 01-15.3 6.36"}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M3 4v6h6M21 20v-6h-6"})]})}function S(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 12l5 5L19 7"})})}function _(e,t=1800){if("string"==typeof e)return e.length>t?`${e.slice(0,t)}…`:e;try{let r=JSON.stringify(e,null,2);return r.length>t?`${r.slice(0,t)}…`:r}catch{return"[unserializable]"}}function M({node:e}){let t,r,s=(0,a.k)(),l=(0,d.CU)(e=>e.isSending),i=(r=(t=e.type===c.Z.ASSISTANT?e.metadata.modelName??s("node.author.assistant"):e.type===c.Z.USER?s("node.author.you"):e.type===c.Z.SYSTEM?s("node.author.system"):s("node.author.compressed")).trim()?t.trim()[0].toUpperCase():"?",{role:e.type===c.Z.USER?"human":e.type===c.Z.ASSISTANT?"machine":"system",author:t,avatar:r}),m=(0,g.GP)(new Date(e.createdAt),"HH:mm"),p=e.type===c.Z.COMPRESSED?e.summary??e.content:e.content,u=e.type===c.Z.ASSISTANT?j(p):null,x=u?u.visible:p,h=e.type===c.Z.ASSISTANT,f=e.type===c.Z.USER,b=(0,d.CU)(e=>e.retryAssistant),v=(0,d.CU)(e=>e.toolSettings.mcp.servers),[y,w]=(0,o.useState)(!1),[M,U]=(0,o.useState)(!1),E=(0,o.useRef)(null),T=e.metadata.toolLogs??[];return(0,o.useEffect)(()=>()=>{E.current&&window.clearTimeout(E.current)},[]),(0,n.jsxs)("div",{className:"animate-message-in mb-8 max-w-[680px]",children:[(0,n.jsxs)("div",{className:"mb-3 flex items-center gap-3",children:[(0,n.jsx)("div",{className:`flex h-8 w-8 items-center justify-center rounded-full font-display text-[0.9rem] italic text-cream ${"human"===i.role?"bg-human":"machine"===i.role?"bg-machine":"bg-system"}`,children:i.avatar}),(0,n.jsx)("span",{className:"text-[0.9rem] font-medium text-ink",children:i.author}),(0,n.jsx)("span",{className:"font-mono text-[0.7rem] text-sand",children:m})]}),f&&e.metadata.toolUses&&e.metadata.toolUses.length>0?(0,n.jsx)("div",{className:"-mt-1 mb-3 flex flex-wrap gap-2 pl-11",children:e.metadata.toolUses.map(e=>(0,n.jsx)("span",{className:"rounded-full border border-parchment bg-paper px-2.5 py-1 font-mono text-[0.65rem] text-sand",title:s("chat.message.toolUseEnabledTitle"),children:(()=>{if("web_search"===e)return s("chat.input.tool.webSearch");if("python"===e)return s("chat.input.tool.python");if("mcp"===e)return"MCP";if(e.startsWith("mcp:")){let t=e.slice(4).trim(),r=v.find(e=>e.id===t)??null;return r?`MCP \xb7 ${r.name}`:`MCP \xb7 ${t||e}`}return e})()},e))}):null,(0,n.jsx)("div",{className:"prose-prompt-tree pl-11 text-[0.95rem] leading-relaxed text-charcoal",children:h&&l&&!x.trim()?(0,n.jsx)("span",{className:"font-mono text-[0.85rem] text-sand",children:s("chat.thinking")}):(0,n.jsx)(k,{content:x})}),h&&T.length>0?(0,n.jsxs)("div",{className:"mt-4 pl-11",children:[(0,n.jsxs)("button",{type:"button",className:"flex items-center gap-2 rounded-xl border border-parchment bg-paper px-4 py-2 text-left font-mono text-[0.7rem] text-sand transition-all duration-150 hover:border-copper hover:text-ink",onClick:()=>U(e=>!e),children:[(0,n.jsx)("span",{className:"font-semibold text-ink",children:s("common.tools")}),(0,n.jsx)("span",{className:"rounded-full bg-cream px-2 py-0.5 text-[0.65rem] text-clay",children:T.length}),(0,n.jsx)("span",{className:"ml-auto text-[0.65rem] text-sand",children:M?s("common.hide"):s("common.show")})]}),M?(0,n.jsx)("div",{className:"mt-2 space-y-2",children:T.map(e=>{let t="number"==typeof e.endedAt?`${Math.max(0,e.endedAt-e.startedAt)}ms`:"running"===e.status?s("chat.tool.status.running"):"",r="success"===e.status?s("chat.tool.status.ok"):"error"===e.status?s("chat.tool.status.error"):s("chat.tool.status.running");return(0,n.jsxs)("div",{className:"rounded-xl border border-parchment bg-shoji-white px-4 py-3",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-3",children:[(0,n.jsx)("div",{className:"font-mono text-[0.75rem] text-ink",children:e.tool}),(0,n.jsxs)("div",{className:"flex items-center gap-2 font-mono text-[0.65rem] text-sand",children:[(0,n.jsx)("span",{className:"error"===e.status?"text-red-500":"",children:r}),t?(0,n.jsx)("span",{children:t}):null]})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"mb-1 font-mono text-[0.65rem] uppercase tracking-[0.12em] text-sand",children:s("chat.tool.args")}),(0,n.jsx)("pre",{className:"max-h-[180px] overflow-auto rounded-lg bg-paper px-3 py-2 font-mono text-[0.7rem] text-ink",children:_(e.args)})]}),"error"===e.status?(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"mb-1 font-mono text-[0.65rem] uppercase tracking-[0.12em] text-sand",children:s("chat.tool.error")}),(0,n.jsx)("pre",{className:"max-h-[180px] overflow-auto rounded-lg bg-red-50 px-3 py-2 font-mono text-[0.7rem] text-red-700",children:e.error??s("chat.tool.unknownError")})]}):null,"success"===e.status?(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"mb-1 font-mono text-[0.65rem] uppercase tracking-[0.12em] text-sand",children:s("chat.tool.result")}),(0,n.jsx)("pre",{className:"max-h-[220px] overflow-auto rounded-lg bg-paper px-3 py-2 font-mono text-[0.7rem] text-ink",children:_(e.result)})]}):null]})]},e.id)})}):null]}):null,h?(0,n.jsxs)("div",{className:"mt-3 flex justify-end gap-2 pl-11",children:[(0,n.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 rounded-full border border-parchment px-3 py-1 text-[0.65rem] text-sand transition-all duration-150 hover:border-copper hover:text-ink disabled:opacity-50",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(x),w(!0),E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{w(!1)},1600)}catch{}})()},disabled:l,"aria-label":s("chat.message.copyResponseAria"),children:[(0,n.jsx)("div",{className:"h-3.5 w-3.5",children:y?(0,n.jsx)(S,{}):(0,n.jsx)(N,{})}),y?s("common.copied"):s("common.copy")]}),(0,n.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 rounded-full border border-parchment px-3 py-1 text-[0.65rem] text-sand transition-all duration-150 hover:border-copper hover:text-ink disabled:opacity-50",onClick:()=>void b(e.id),disabled:l,"aria-label":s("chat.message.retryResponseAria"),children:[(0,n.jsx)("div",{className:"h-3.5 w-3.5",children:(0,n.jsx)(C,{})}),s("chat.message.retry")]})]}):null]})}function U(){let e=(0,a.k)();return(0,n.jsxs)("div",{className:"mb-8 max-w-[680px]",children:[(0,n.jsx)("div",{className:"mb-3 flex items-center gap-3",children:(0,n.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-machine font-display text-[0.9rem] italic text-cream",children:"…"})}),(0,n.jsxs)("div",{className:"flex items-center gap-3 pl-11 text-[0.85rem] text-sand",children:[(0,n.jsxs)("div",{className:"flex gap-1",children:[(0,n.jsx)("span",{className:"animate-typing h-1.5 w-1.5 rounded-full bg-copper"}),(0,n.jsx)("span",{className:"animate-typing animate-typing-delay-1 h-1.5 w-1.5 rounded-full bg-copper"}),(0,n.jsx)("span",{className:"animate-typing animate-typing-delay-2 h-1.5 w-1.5 rounded-full bg-copper"})]}),(0,n.jsx)("span",{children:e("chat.thinking")})]})]})}function E({messages:e,isSending:t,error:r}){let s=(0,a.k)(),l=(0,o.useRef)(null),i=(0,o.useRef)(!0),d=(()=>{for(let t=e.length-1;t>=0;t-=1)if(e[t]?.type===c.Z.USER)return t;return -1})(),m=d>=0?e.slice(d+1).some(e=>e.type===c.Z.ASSISTANT):e.some(e=>e.type===c.Z.ASSISTANT),p=t&&!m;return(0,o.useEffect)(()=>{let e=l.current;if(!e)return;let t=()=>{i.current=e.scrollHeight-e.scrollTop-e.clientHeight<96};return e.addEventListener("scroll",t,{passive:!0}),t(),()=>e.removeEventListener("scroll",t)},[]),(0,o.useEffect)(()=>{let e=l.current;if(!e||!i.current)return;let r=window.requestAnimationFrame(()=>{e.scrollTo({top:e.scrollHeight,behavior:t?"auto":"smooth"})});return()=>window.cancelAnimationFrame(r)},[e,t]),(0,n.jsxs)("div",{ref:l,className:"min-h-0 overflow-y-auto p-8",children:[e.map(e=>(0,n.jsx)(M,{node:e},e.id)),r?(0,n.jsx)("div",{className:"mb-6 max-w-[680px] rounded-xl border border-[#e74c3c]/30 bg-[#e74c3c]/10 p-4 font-body text-[0.85rem] text-[#b1382c]",children:(0,f.d)(r)?s(r):r}):null,p?(0,n.jsx)(U,{}):null]})}function T(){let e=(0,a.k)(),t=(0,d.CU)(e=>e.locale),r=(0,d.CU)(e=>e.nodes),m=(0,d.CU)(e=>e.activeNodeId),p=(0,d.CU)(e=>e.getCurrentTree()),u=(0,d.CU)(e=>e.folders),x=(0,d.CU)(e=>e.isLoading),f=(0,d.CU)(e=>e.isSending),g=(0,d.CU)(e=>e.llmError??e.error),b=(0,d.CU)(e=>e.providers),v=(0,d.CU)(e=>e.model),j=(0,d.CU)(e=>e.temperature),y=(0,d.CU)(e=>e.contextBox),w=(0,d.CU)(e=>e.selectedModels),k=(0,d.CU)(e=>e.setSelectedModels),N=(0,d.CU)(e=>e.toolSettings),C=(0,d.CU)(e=>e.draftToolUses),S=(0,d.CU)(e=>e.setDraftToolUses),_=(0,d.CU)(e=>e.addFilesToContext),M=(0,d.CU)(e=>e.sendMessage),U=(0,o.useMemo)(()=>(function(e,t){let r=function(e,t){if(!t)return[];let r=new Set,n=[],o=e.get(t)??null;for(;o&&!r.has(o.id)&&(r.add(o.id),n.unshift(o),o.parentId);)o=e.get(o.parentId)??null;return n}(e,t);if(0===r.length)return[];let n=[...r].reverse().findIndex(e=>e.type===c.Z.USER);if(-1===n)return r;let o=r.length-1-n,a=r[o],s=Array.from(e.values()).filter(e=>e.parentId===a.id&&e.type===c.Z.ASSISTANT).sort((e,t)=>e.createdAt-t.createdAt);return s.length<=1?r:[...r.slice(0,o+1),...s]})(r,m).filter(e=>e.type!==c.Z.SYSTEM),[r,m]),T=(0,o.useMemo)(()=>(0,s.n)(b),[b]),I=(0,o.useMemo)(()=>{let e=p?.folderId??null;if(!e)return T;let t=u.get(e)??null,r=t?.enabledModels;if(null==r)return T;let n=new Set(r.map(s.R));return T.filter(e=>n.has((0,s.R)(e)))},[p?.folderId,T,u]);(0,o.useEffect)(()=>{let e=p?.folderId??null;if(!e)return;let t=u.get(e)??null;if(null==t?.enabledModels)return;let r=new Set(I.map(s.R)),n=w.filter(e=>r.has((0,s.R)(e)));n.length!==w.length&&k(n)},[p?.folderId,I,u,w,k]);let A=(0,o.useMemo)(()=>{if(0===w.length)return v;let t=new Map(T.map(e=>[(0,s.R)(e),e])),r=w.map(e=>{let r=t.get((0,s.R)(e));return r?.modelId??e.modelId});return r.length<=2?r.join(", "):e("chat.modelLabel.count",{count:r.length})},[w,T,v,e]),L=(0,o.useMemo)(()=>(0,i.d)(C,N).reduce((e,t)=>{var r;return e+(r=t.content,(0,l.b)(r))},0),[C,N]),R=y&&y.maxTokens?e("chat.contextTokens",{used:(y.totalTokens+L).toLocaleString(t),max:y.maxTokens.toLocaleString(t)}):"";return p?(0,n.jsxs)("div",{className:"grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)_auto] overflow-hidden",children:[(0,n.jsx)(E,{messages:U,isSending:f,error:g}),(0,n.jsx)(h,{onSend:async e=>{await M(e)},onAttachFiles:async e=>{await _(e)},disabled:x||f,modelLabel:A,temperatureLabel:j.toFixed(1),tokenLabel:R,modelOptions:I,selectedModels:w,onSelectedModelsChange:k,selectedTools:C,onSelectedToolsChange:S,toolSettings:N})]}):(0,n.jsx)("div",{className:"flex min-h-0 flex-1 items-center justify-center p-8 text-sand",children:x?e("common.loading"):e("chat.noConversationLoaded")})}var I=r(8500),A=r.n(I),L=r(7734),R=r(6623),D=r(4395),$=r(1379);function P({open:e,title:t,description:r,confirmText:o,cancelText:s,confirmDisabled:l=!1,onConfirm:i,onClose:d}){let c=(0,a.k)(),p=o??c("common.delete"),u=s??c("common.cancel");return(0,n.jsxs)($.a,{open:e,title:t,onClose:d,children:[r?(0,n.jsx)("div",{className:"text-[0.9rem] leading-relaxed text-clay",children:r}):null,(0,n.jsxs)("div",{className:"mt-6 flex items-center justify-end gap-2",children:[(0,n.jsx)(m,{variant:"secondary",onClick:d,disabled:l,children:u}),(0,n.jsx)(m,{className:"bg-[#e74c3c] text-white hover:bg-[#d64533]",onClick:i,disabled:l,children:p})]})]})}function B({className:e="",...t}){return(0,n.jsx)("input",{className:`w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-body text-[0.9rem] text-ink outline-none transition-all duration-200 placeholder:text-sand focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)] ${e}`,...t})}function z({className:e=""}){return(0,n.jsx)("svg",{className:e,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M3 6h18M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})})}var F=r(51);let Z=new(r(279)).w,W=new Map;async function O(e,t=60){let r=await Z.read(e);if(!r)return[];let n=[r],o=[r.id],a=new Set([r.id]);for(;o.length>0&&n.length<t;){let e=o.shift();if(e)for(let r of(await Z.getChildren(e))){if(n.length>=t)break;a.has(r.id)||(a.add(r.id),n.push(r),o.push(r.id))}}return n}function V({treeId:e,rootId:t,revision:r,className:s=""}){let l=(0,a.k)(),i=W.get(e),d=i?.revision===r?i.geometry:null,[c,m]=(0,o.useState)(d);(0,o.useEffect)(()=>{if(d)return void m(d);let n=!1;return m(null),(async()=>{let o=function(e,t){let r=(0,F.$u)(e,t,{xSpacing:160,ySpacing:90}),n=function(e){let t=1/0,r=-1/0,n=1/0,o=-1/0;for(let a of e.values())t=Math.min(t,a.x),r=Math.max(r,a.x),n=Math.min(n,a.y),o=Math.max(o,a.y);return Number.isFinite(t)&&Number.isFinite(n)?{minX:t,maxX:r,minY:n,maxY:o}:null}(r);if(!n)return{circles:[],lines:[]};let o=Math.max(1,n.maxX-n.minX),a=Math.max(1,n.maxY-n.minY),s=e=>({x:14+(e.x-n.minX)/o*172,y:14+(e.y-n.minY)/a*92}),l=new Set(e.map(e=>e.id)),i=[],d=[];for(let n of e){let e=r.get(n.id);if(!e)continue;let o=s(e);if(i.push({x:o.x,y:o.y,r:n.id===t?4:3,kind:n.id===t?"root":"node"}),n.parentId&&l.has(n.parentId)){let e=r.get(n.parentId);if(!e)continue;let t=s(e);d.push({x1:t.x,y1:t.y,x2:o.x,y2:o.y})}}return{circles:i,lines:d}}(await O(t),t);n||(W.set(e,{revision:r,geometry:o}),m(o))})(),()=>{n=!0}},[d,r,t,e]);let p=(0,o.useMemo)(()=>c?(0,n.jsxs)("svg",{viewBox:"0 0 200 120",className:"h-full w-full",children:[(0,n.jsx)("g",{className:"stroke-parchment/80",strokeWidth:"1.25",children:c.lines.map((e,t)=>(0,n.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2},`${e.x1}-${e.y1}-${e.x2}-${e.y2}-${t}`))}),(0,n.jsx)("g",{children:c.circles.map((e,t)=>(0,n.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,className:"root"===e.kind?"fill-copper stroke-ink/10":"fill-ink/60 stroke-ink/10"},`${e.x}-${e.y}-${t}`))})]}):null,[c]);return(0,n.jsx)("div",{className:`relative h-[74px] w-[124px] overflow-hidden rounded-xl border border-parchment bg-cream/60 ${s}`,"aria-label":l("folder.threadPreviewAria"),children:p??(0,n.jsx)("div",{className:"h-full w-full animate-pulse bg-parchment/25"})})}function H(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",className:"h-4 w-4",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 4v16m8-8H4"})})}function Y({open:e}){return(0,n.jsx)("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",className:`transition-transform duration-200 ${e?"rotate-180":""}`,children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M19 9l-7 7-7-7"})})}function K(){let e=(0,a.k)(),t=(0,d.CU)(e=>e.locale),r=(0,d.CU)(e=>e.currentFolderId),l=(0,d.CU)(e=>e.getCurrentFolder()),i=(0,d.CU)(e=>e.folders),c=(0,d.CU)(e=>e.trees),p=(0,d.CU)(e=>e.loadTree),u=(0,d.CU)(e=>e.createTreeInFolder),x=(0,d.CU)(e=>e.deleteTree),h=(0,d.CU)(e=>e.deleteFolder),f=(0,d.CU)(e=>e.updateFolderName),g=(0,d.CU)(e=>e.updateFolderSystemPrompt),b=(0,d.CU)(e=>e.updateFolderEnabledModels),v=(0,d.CU)(e=>e.providers),j=(0,o.useMemo)(()=>(0,s.n)(v),[v]),y=(0,o.useMemo)(()=>r?Array.from(c.values()).filter(e=>(e.folderId??null)===r).slice().sort((e,t)=>t.updatedAt-e.updatedAt):[],[r,c]),[w,k]=(0,o.useState)(""),[N,C]=(0,o.useState)(""),[S,_]=(0,o.useState)(!1),[M,U]=(0,o.useState)(!1),[E,T]=(0,o.useState)(!1),[I,F]=(0,o.useState)(new Set),Z=(0,o.useRef)(!0),[W,O]=(0,o.useState)(null),[K,q]=(0,o.useState)(!1);(0,o.useEffect)(()=>(Z.current=!0,()=>{Z.current=!1}),[]),(0,o.useEffect)(()=>{k(l?.name??""),C(l?.systemPrompt??"")},[l?.id,l?.name,l?.systemPrompt]);let X=(0,o.useMemo)(()=>{if(!l)return[];if(null==l.enabledModels)return j;let e=new Set(l.enabledModels.map(s.R));return j.filter(t=>e.has((0,s.R)(t)))},[j,l]),G=(0,o.useMemo)(()=>l?null==l.enabledModels?e("folder.models.allEnabled"):0===X.length?e("folder.models.none"):e("folder.models.selectedCount",{count:X.length}):"",[l,X.length,e]),J=W?.kind==="folder"?e("sidebar.confirmDeleteFolderTitle"):e("sidebar.confirmDeleteThreadTitle"),Q=W&&"folder"===W.kind&&W.threadCount>0?e("sidebar.confirmDeleteFolderThreadNote",{count:W.threadCount}):"",ee=W&&"folder"===W.kind?e("sidebar.confirmDeleteFolderBody",{name:W.name,threadNote:Q}):W&&"thread"===W.kind?e("sidebar.confirmDeleteThreadBody",{title:W.title}):null,et=()=>{l&&(F(new Set(null==l.enabledModels?j.map(s.R):l.enabledModels.map(s.R))),T(!0))};return r?l||i.has(r)?(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden bg-paper",children:[(0,n.jsx)("div",{className:"border-b border-parchment bg-paper px-6 py-6 lg:px-8",children:(0,n.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"mb-2 font-mono text-[0.65rem] uppercase tracking-[0.15em] text-sand",children:e("folder.label")}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,n.jsx)("div",{className:"min-w-[220px] flex-1",children:(0,n.jsx)(B,{value:w,placeholder:e("folder.namePlaceholder",{count:6}),className:"h-[46px] py-0",onChange:e=>{var t;let r;k((t=e.target.value,(r=Array.from(t)).length<=6?t:r.slice(0,6).join("")))},onBlur:()=>{l&&w!==l.name&&f(l.id,w)}})}),(0,n.jsxs)(m,{className:"h-[46px] shrink-0 gap-2 px-5",onClick:()=>void u(r),children:[(0,n.jsx)(H,{}),e("folder.newThread")]}),(0,n.jsxs)(m,{variant:"secondary",className:"h-[46px] shrink-0 gap-2 px-5 border-[#e74c3c]/40 text-[#e74c3c] hover:border-[#e74c3c] hover:bg-[#e74c3c]/10",onClick:()=>{l&&O({kind:"folder",id:l.id,name:l.name,threadCount:y.length})},children:[(0,n.jsx)(z,{}),e("folder.deleteFolder")]})]})]}),(0,n.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,n.jsxs)("div",{className:"rounded-2xl border border-parchment bg-cream p-4 shadow-[0_10px_28px_rgba(26,24,22,0.06)]",children:[(0,n.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between gap-3 text-left",onClick:()=>_(e=>!e),children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"font-mono text-[0.65rem] uppercase tracking-[0.15em] text-sand",children:e("folder.systemPrompt.title")}),S?(0,n.jsx)("div",{className:"mt-1 line-clamp-1 text-[0.85rem] text-clay",children:N.trim()?N.trim():e("folder.systemPrompt.collapsedEmpty")}):null]}),(0,n.jsx)("div",{className:"text-sand",children:(0,n.jsx)(Y,{open:!S})})]}),S?null:(0,n.jsxs)("div",{className:"mt-3",children:[(0,n.jsx)("textarea",{value:N,placeholder:e("folder.systemPrompt.placeholder"),onChange:e=>C(e.target.value),onBlur:()=>{l&&N!==l.systemPrompt&&g(l.id,N)},className:"min-h-[120px] w-full resize-none rounded-xl border border-parchment bg-paper px-4 py-3 font-body text-[0.9rem] leading-relaxed text-ink outline-none transition-all duration-200 placeholder:text-sand focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]"}),(0,n.jsx)("div",{className:"mt-2 font-mono text-[0.7rem] text-sand",children:e("folder.systemPrompt.note")})]})]}),(0,n.jsxs)("div",{className:"rounded-2xl border border-parchment bg-cream p-4 shadow-[0_10px_28px_rgba(26,24,22,0.06)]",children:[(0,n.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between gap-3 text-left",onClick:()=>U(e=>!e),children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"font-mono text-[0.65rem] uppercase tracking-[0.15em] text-sand",children:e("folder.models.title")}),M?(0,n.jsx)("div",{className:"mt-1 text-[0.85rem] text-clay",children:G}):null]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sand",children:[(0,n.jsx)("span",{className:"rounded-full border border-parchment bg-paper px-2 py-0.5 font-mono text-[0.65rem] text-clay",children:X.length}),(0,n.jsx)(Y,{open:!M})]})]}),M?null:(0,n.jsx)("div",{className:"mt-3",children:0===j.length?(0,n.jsxs)("div",{className:"rounded-xl border border-parchment bg-paper p-4 text-[0.85rem] text-clay",children:[e("folder.models.noneEnabled")," ",(0,n.jsx)(A(),{href:"/settings",className:"text-ink underline underline-offset-2",children:e("folder.models.configureInSettings")}),"."]}):(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsx)("div",{className:"font-mono text-[0.7rem] text-sand",children:e("folder.models.help")}),(0,n.jsx)("button",{type:"button",className:"rounded-lg border border-parchment bg-paper px-3 py-2 text-[0.75rem] text-ink transition-all duration-150 hover:border-copper hover:bg-copper-glow",onClick:e=>{e.stopPropagation(),et()},children:e("common.edit")})]}),(0,n.jsx)("button",{type:"button",className:"flex w-full flex-wrap gap-2 rounded-xl border border-parchment bg-paper p-4 text-left transition-all duration-150 hover:border-copper",onClick:()=>et(),children:0===X.length?(0,n.jsx)("span",{className:"text-[0.85rem] text-clay",children:e("folder.models.noneSelected")}):X.map(e=>(0,n.jsx)("span",{className:"rounded-full border border-parchment bg-cream px-3 py-1 font-mono text-[0.7rem] text-ink",title:e.label,children:e.label},`${e.providerId}:${e.modelId}`))})]})})]})]})]})}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[(0,n.jsx)("div",{className:"border-b border-parchment bg-paper/50 px-6 py-3 lg:px-8",children:(0,n.jsx)("div",{className:"font-mono text-[0.65rem] uppercase tracking-[0.15em] text-sand",children:e("folder.threads.title",{count:y.length})})}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-6 lg:px-8",children:0===y.length?(0,n.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-4 rounded-2xl border border-dashed border-parchment bg-cream p-10 text-center",children:[(0,n.jsx)("div",{className:"font-display text-[1.2rem] text-ink",children:e("folder.threads.empty.title")}),(0,n.jsx)("div",{className:"max-w-[42ch] text-[0.9rem] leading-relaxed text-clay",children:e("folder.threads.empty.description")}),(0,n.jsxs)(m,{className:"gap-2",onClick:()=>void u(r),children:[(0,n.jsx)(H,{}),e("folder.threads.empty.action")]})]}):(0,n.jsx)("div",{className:"space-y-3",children:y.map(r=>{let o=(0,L.m)(new Date(r.updatedAt),{addSuffix:!0,locale:"zh-CN"===t?R.g:D.c});return(0,n.jsxs)("div",{className:"group relative",children:[(0,n.jsxs)("button",{type:"button",className:"flex w-full items-stretch justify-between gap-5 rounded-2xl border border-parchment bg-paper p-4 text-left shadow-[0_8px_24px_rgba(26,24,22,0.05)] transition-all duration-200 hover:-translate-y-px hover:border-copper hover:shadow-[0_14px_38px_rgba(184,115,51,0.12)]",onClick:()=>void p(r.id),children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"mb-1 flex items-start justify-between gap-3",children:(0,n.jsx)("div",{className:"truncate text-[0.95rem] font-medium text-ink",children:r.title})}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-3 font-mono text-[0.7rem] text-sand",children:[(0,n.jsx)("span",{children:o}),(0,n.jsxs)("span",{className:"opacity-70",children:["id: ",r.id.slice(0,8)]})]})]}),(0,n.jsx)(V,{treeId:r.id,rootId:r.rootId,revision:r.updatedAt,className:"shrink-0"})]}),(0,n.jsx)("button",{type:"button",className:"absolute right-4 top-4 z-10 rounded-md p-1 text-sand opacity-0 transition-all duration-150 hover:bg-paper hover:text-[#e74c3c] group-hover:opacity-100","aria-label":e("folder.deleteThreadAria"),onClick:()=>O({kind:"thread",id:r.id,title:r.title}),children:(0,n.jsx)(z,{})})]},r.id)})})})]}),(0,n.jsx)($.a,{open:E,title:e("folder.models.picker.title"),onClose:()=>T(!1),children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsx)("div",{className:"font-mono text-[0.7rem] text-sand",children:e("folder.models.picker.description")}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{type:"button",className:"rounded-lg border border-parchment bg-paper px-3 py-2 text-[0.75rem] text-sand transition-all duration-150 hover:border-copper hover:text-ink",onClick:()=>F(new Set(j.map(s.R))),children:e("common.selectAll")}),(0,n.jsx)("button",{type:"button",className:"rounded-lg border border-parchment bg-paper px-3 py-2 text-[0.75rem] text-sand transition-all duration-150 hover:border-copper hover:text-ink",onClick:()=>F(new Set),children:e("common.clear")})]})]}),(0,n.jsx)("div",{className:"max-h-[52vh] space-y-2 overflow-y-auto rounded-xl border border-parchment bg-paper p-3",children:j.map(e=>{let t=(0,s.R)(e),r=I.has(t);return(0,n.jsxs)("button",{type:"button",className:`flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-all ${r?"border-copper/50 bg-copper/10":"border-parchment/30 bg-shoji-white hover:border-copper/40"}`,onClick:()=>{let t;return t=(0,s.R)(e),void F(e=>{let r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r})},children:[(0,n.jsx)("span",{className:`flex h-4.5 w-4.5 items-center justify-center rounded border text-[0.6rem] ${r?"border-copper bg-copper text-white":"border-parchment bg-transparent text-transparent"}`,children:"✓"}),(0,n.jsxs)("div",{className:"flex-1",children:[(0,n.jsx)("div",{className:"font-mono text-[0.8rem] text-ink",children:e.modelId}),(0,n.jsx)("div",{className:"text-[0.65rem] text-sand",children:e.providerName})]})]},t)})}),(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"font-mono text-[0.75rem] text-sand",children:[e("folder.models.picker.selected")," ",(0,n.jsx)("span",{className:"font-medium text-ink",children:I.size})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(m,{variant:"secondary",onClick:()=>T(!1),children:e("common.cancel")}),(0,n.jsx)(m,{onClick:()=>{if(!l)return;let e=new Set(j.map(s.R)),t=Array.from(I).filter(t=>e.has(t)),r=j.filter(e=>I.has((0,s.R)(e))).map(e=>({providerId:e.providerId,modelId:e.modelId})),n=t.length===e.size?null:r;b(l.id,n),T(!1)},children:e("common.save")})]})]})]})}),(0,n.jsx)(P,{open:null!=W,title:J,description:ee,confirmText:e("common.delete"),cancelText:e("common.cancel"),confirmDisabled:K,onConfirm:()=>{W&&!K&&(q(!0),(async()=>{try{"thread"===W.kind?await x(W.id):await h(W.id),Z.current&&O(null)}finally{Z.current&&q(!1)}})())},onClose:()=>{K||O(null)}})]}):(0,n.jsx)("div",{className:"flex min-h-0 flex-1 items-center justify-center p-10 text-sand",children:e("folder.empty.notFound")}):(0,n.jsx)("div",{className:"flex min-h-0 flex-1 items-center justify-center p-10 text-sand",children:e("folder.empty.selectFolder")})}var q=r(7650),X=r(6161),G=r(9157),J=r(125);r(3235);let Q="application/x-prompt-tree-node-id";function ee(){return(0,n.jsx)("svg",{width:"14",height:"14",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 6h.01M8 12h.01M8 18h.01M16 6h.01M16 12h.01M16 18h.01"})})}let et=(0,o.memo)(function({data:e}){let t=(0,a.k)(),r=(0,d.CU)(e=>e.locale),s=e.node,l=s.type===c.Z.COMPRESSED,i=s.metadata.collapsed??!1,m=s.type===c.Z.ASSISTANT?s.metadata.modelName??t("node.author.assistant"):s.type===c.Z.USER?t("node.author.you"):s.type===c.Z.SYSTEM?t("node.author.system"):t("node.author.compressed"),p=(0,o.useMemo)(()=>{if(s.type===c.Z.COMPRESSED)return s.summary??t("tree.node.emptySummary");let e=s.content.trim()?s.content:t("tree.node.emptyContent");return s.type===c.Z.ASSISTANT?j(e).visible:e},[s,t]),u=e.isActive?"shadow-[0_10px_36px_rgba(184,115,51,0.32),0_0_0_2px_var(--copper)]":e.isSelected?"shadow-[0_8px_28px_rgba(26,24,22,0.18),0_0_0_2px_rgba(196,189,180,0.9)]":e.isInActivePath?"shadow-[0_8px_28px_rgba(26,24,22,0.14),0_0_0_1px_rgba(184,115,51,0.35)]":"shadow-[0_8px_28px_rgba(26,24,22,0.12),0_0_0_1px_rgba(255,255,255,0.08)]";return(0,n.jsxs)("div",{className:`node-transition group relative w-[200px] cursor-pointer rounded-[18px] px-4 py-3 ${function(e){switch(e){case c.Z.SYSTEM:return"bg-gradient-to-br from-system to-[#3d4a5c] text-cream";case c.Z.USER:return"bg-gradient-to-br from-human to-[#5a4a3f] text-cream";case c.Z.ASSISTANT:return"bg-gradient-to-br from-machine to-[#3a5432] text-cream";case c.Z.COMPRESSED:return"bg-gradient-to-br from-copper to-[#9a5e2a] text-cream"}}(s.type)} ${u}`,"data-prompt-tree-node-type":s.type,"data-node-id":s.id,children:[(0,n.jsx)(X.h7,{type:"target",position:X.yX.Left,className:"!h-2.5 !w-2.5 !border-0 !bg-[rgba(250,249,247,0.55)] opacity-0 transition-opacity duration-150 group-hover:opacity-100"}),(0,n.jsx)(X.h7,{type:"source",position:X.yX.Right,className:"!h-2.5 !w-2.5 !border-0 !bg-[rgba(250,249,247,0.55)] opacity-0 transition-opacity duration-150 group-hover:opacity-100"}),(0,n.jsxs)("div",{className:"mb-1 flex items-center gap-2",children:[(0,n.jsx)("button",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-[rgba(255,255,255,0.12)] text-cream opacity-0 transition-opacity duration-150 group-hover:opacity-100",draggable:!0,"aria-label":t("tree.node.dragToContextAria"),onPointerDown:e=>{e.stopPropagation()},onDragStart:e=>{e.dataTransfer.setData(Q,s.id),e.dataTransfer.setData("text/plain",s.id),e.dataTransfer.effectAllowed="copy"},children:(0,n.jsx)(ee,{})}),(0,n.jsx)("div",{className:"flex-1",children:(0,n.jsx)("div",{className:"font-mono text-[0.65rem] uppercase tracking-wide opacity-75",children:m})}),l&&(0,n.jsx)("button",{type:"button",className:"flex h-5 w-5 items-center justify-center rounded-full border border-[rgba(255,255,255,0.4)] text-[0.7rem] font-semibold text-cream/80 transition-colors hover:border-[rgba(255,255,255,0.7)]",onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),e.onToggleCollapse?.(s.id)},"aria-label":i?t("tree.node.expandCompressedAria"):t("tree.node.collapseCompressedAria"),children:i?"+":"−"}),(0,n.jsx)("div",{className:"font-mono text-[0.7rem] opacity-80",children:s.tokenCount.toLocaleString(r)})]}),(0,n.jsx)("div",{className:"line-clamp-2 text-[0.85rem] leading-snug opacity-95",children:p})]})});function er(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M20 12H4"})})}function en(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M12 4v16m8-8H4"})})}function eo(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}function ea(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M4 6h16M4 12h10M4 18h16"})})}function es({onAutoLayout:e}){let t=(0,a.k)(),{fitView:r,zoomIn:o,zoomOut:s}=(0,X.VH)();return(0,n.jsxs)("div",{"data-tree-controls":!0,className:"pointer-events-none absolute bottom-5 left-8 z-20 flex gap-2",children:[(0,n.jsx)("button",{className:"pointer-events-auto flex h-10 w-10 items-center justify-center rounded-[10px] border border-parchment bg-paper text-clay transition-all duration-150 hover:border-copper hover:text-copper",onClick:()=>void s?.(),"aria-label":t("tree.controls.zoomOut"),type:"button",children:(0,n.jsx)("div",{className:"h-[18px] w-[18px]",children:(0,n.jsx)(er,{})})}),(0,n.jsx)("button",{className:"pointer-events-auto flex h-10 w-10 items-center justify-center rounded-[10px] border border-parchment bg-paper text-clay transition-all duration-150 hover:border-copper hover:text-copper",onClick:()=>void o?.(),"aria-label":t("tree.controls.zoomIn"),type:"button",children:(0,n.jsx)("div",{className:"h-[18px] w-[18px]",children:(0,n.jsx)(en,{})})}),(0,n.jsx)("button",{className:"pointer-events-auto flex h-10 w-10 items-center justify-center rounded-[10px] border border-parchment bg-paper text-clay transition-all duration-150 hover:border-copper hover:text-copper",onClick:()=>void r?.({padding:.25}),"aria-label":t("tree.controls.fitView"),type:"button",children:(0,n.jsx)("div",{className:"h-[18px] w-[18px]",children:(0,n.jsx)(eo,{})})}),(0,n.jsx)("button",{className:"pointer-events-auto flex h-10 w-10 items-center justify-center rounded-[10px] border border-parchment bg-paper text-clay transition-all duration-150 hover:border-copper hover:text-copper",onClick:e,"aria-label":t("tree.controls.autoLayout"),type:"button",children:(0,n.jsx)("div",{className:"h-[18px] w-[18px]",children:(0,n.jsx)(ea,{})})})]})}et.displayName="TreeNode";let el={treeNode:et},ei={treeEdge:function({id:e,sourceX:t,sourceY:r,targetX:o,targetY:a,data:s}){let[l]=(0,X.Fp)({sourceX:t,sourceY:r,targetX:o,targetY:a}),i=s?.isInActivePath??!1;return(0,n.jsx)(X.tE,{id:e,path:l,style:{stroke:i?"var(--copper)":"var(--parchment)",strokeWidth:i?2.6:2}})}};function ed({children:e,onClick:t,disabled:r}){return(0,n.jsx)("button",{className:`w-full rounded-lg px-3 py-2 text-left text-[0.85rem] transition-colors duration-150 ${r?"cursor-not-allowed opacity-40":"hover:bg-cream hover:text-ink"}`,onClick:t,disabled:r,type:"button",children:e})}function ec({fitViewOnInit:e=!0,fitViewTrigger:t}){let r=(0,a.k)(),s=(0,d.CU)(e=>e.getCurrentTree()),l=(0,d.CU)(e=>e.nodes),i=(0,d.CU)(e=>e.activeNodeId),p=(0,d.CU)(e=>e.selectedNodeIds),u=(0,o.useRef)(!1),x=(0,d.CU)(e=>e.setActiveNode),h=(0,d.CU)(e=>e.setSelectedNodeIds),f=(0,d.CU)(e=>e.clearSelection),g=(0,d.CU)(e=>e.addToContext),b=(0,d.CU)(e=>e.deleteNode),v=(0,d.CU)(e=>e.updateNode),j=(0,d.CU)(e=>e.openCompression),y=(0,d.CU)(e=>e.decompressNode),[w,k,N]=(0,X.ck)([]),[C,S,_]=(0,X.fM)([]),[M,U]=(0,o.useState)(null),E=(0,o.useCallback)(e=>{if(!s)return;let t=e??l.values(),r=(0,F.$u)(t,s.rootId);k(e=>e.map(e=>({...e,position:r.get(e.id)??e.position}))),(async()=>{for(let[e,t]of r)await v(e,{position:t})})()},[s,l,k,v]),T=(0,o.useCallback)(async e=>{let t=l.get(e);if(!t||t.type!==c.Z.COMPRESSED)return;u.current=!0;let r=t.metadata.collapsed??!1,n=t.metadata.compressedNodeIds??[],o=n[n.length-1]??null,a=(o?l.get(o)?.position??null:null)??t.position??null,s=!r,i=a&&!s?{x:a.x,y:a.y-96}:a&&s?{...a}:null;try{await v(e,{metadata:{...t.metadata,collapsed:s},...i?{position:i}:{}})}catch{u.current=!1;return}if(E(d.jL.getState().nodes.values()),s){let t=d.jL.getState().activeNodeId;t&&n.includes(t)&&x(e),f()}window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{u.current=!1})})},[E,f,l,x,v]),I=(0,o.useMemo)(()=>s?(0,F.bz)({nodes:l.values(),rootId:s.rootId,activeNodeId:i,selectedNodeIds:p,onToggleCollapse:T}):{nodes:[],edges:[],branchCount:0},[s,l,i,p,T]);(0,o.useEffect)(()=>{k(I.nodes),S(I.edges)},[I.nodes,I.edges,k,S]);let A=(0,o.useCallback)((e,t)=>{x(t.id)},[x]),L=(0,o.useCallback)(({nodes:e})=>{if(u.current)return;let t=e.map(e=>e.id);if(t.length===p.length){let e=new Set(t);if(p.every(t=>e.has(t)))return}h(t)},[p,h]),[R,D]=(0,o.useState)(null),P=(0,o.useRef)(null),[B,z]=(0,o.useState)(!1),[Z,W]=(0,o.useState)(null),[O,V]=(0,o.useState)(""),H=(0,o.useCallback)(()=>{D(null)},[]),[Y,K]=(0,o.useState)(()=>new Map),Q=(0,o.useCallback)(e=>{let t=l.get(e);if(!t)return;let r=t.type===c.Z.COMPRESSED?t.summary??"":t.content??"";W(e),V(r),z(!0)},[l]),ee=(0,o.useCallback)(()=>{H(),f()},[H,f]),et=(0,o.useCallback)((e,t)=>{e.preventDefault(),D({nodeId:t.id,x:e.clientX+8,y:e.clientY+8})},[]);(0,o.useEffect)(()=>{if(!R)return;let e=e=>{let t=P.current;t&&t.contains(e.target)||D(null)},t=e=>{"Escape"===e.key&&D(null)};return document.addEventListener("mousedown",e,!0),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e,!0),document.removeEventListener("keydown",t)}},[R]),(0,o.useEffect)(()=>{if(!R)return;let e=P.current;if(!e)return;let t=window.requestAnimationFrame(()=>{let t=e.getBoundingClientRect(),r=window.innerWidth-t.width-8,n=window.innerHeight-t.height-8,o=Math.min(Math.max(R.x,8),r),a=Math.min(Math.max(R.y,8),n);(o!==R.x||a!==R.y)&&D(e=>e?{...e,x:o,y:a}:e)});return()=>window.cancelAnimationFrame(t)},[R]);let er=(0,o.useCallback)((e,t)=>{K(e=>{let r=new Map(e);return r.set(t.id,{...t.position}),r})},[]),en=(0,o.useCallback)((e,t)=>{let r=document.querySelector('[data-testid="context-dropzone"]'),n=Y.get(t.id),o=e?.clientX??null,a=e?.clientY??null;if(r&&null!==o&&null!==a){let e=r.getBoundingClientRect();if(o>=e.left&&o<=e.right&&a>=e.top&&a<=e.bottom){let e=Array.from(r.querySelectorAll("[data-context-card-id]")),o=0;if(e.length>0){o=e.length;for(let t=0;t<e.length;t+=1){let r=e[t]?.getBoundingClientRect();if(r&&a<r.top+r.height/2){o=t;break}}}g(t.id,o),n&&(k(e=>e.map(e=>e.id===t.id?{...e,position:n}:e)),v(t.id,{position:n})),K(e=>{let r=new Map(e);return r.delete(t.id),r});return}}if(null!==o&&null!==a){let e=Array.from(document.querySelectorAll("[data-node-id]")).find(e=>{let r=e.getAttribute("data-node-id");if(!r||r===t.id)return!1;let n=e.getBoundingClientRect();return o>=n.left&&o<=n.right&&a>=n.top&&a<=n.bottom}),r=e?.getAttribute("data-node-id")??null;if(r){let e=l.get(r)??null,n=!1;for(;e?.parentId;){if(e.parentId===t.id){n=!0;break}e=l.get(e.parentId)??null}if(!n){v(t.id,{parentId:r,position:t.position}),K(e=>{let r=new Map(e);return r.delete(t.id),r});return}}}v(t.id,{position:t.position}),K(e=>{let r=new Map(e);return r.delete(t.id),r})},[g,Y,l,k,v]),eo=R?l.get(R.nodeId)??null:null,ea=!!(eo&&s&&eo.id===s.rootId),ec=(0,o.useMemo)(()=>eo&&s?(0,F.VK)(l,eo.id).filter(e=>e!==s.rootId):[],[s,eo,l]),em=ec.length>=2,ep=!!(eo&&eo.type===c.Z.COMPRESSED);return(0,o.useEffect)(()=>{if(!M||"number"!=typeof t)return;let e=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{M.fitView({padding:.25})})});return()=>window.cancelAnimationFrame(e)},[t,M]),(0,n.jsxs)("div",{className:"relative h-full w-full",children:[(0,n.jsxs)(X.Gc,{nodes:w,edges:C,nodeTypes:el,edgeTypes:ei,onInit:U,onNodesChange:N,onEdgesChange:_,onNodeClick:A,onNodeContextMenu:et,onSelectionChange:L,onNodeDragStart:er,onNodeDragStop:en,onPaneClick:ee,fitView:e,minZoom:.2,maxZoom:2,panOnDrag:!1,panOnScroll:!1,autoPanOnNodeDrag:!1,selectionOnDrag:!0,children:[(0,n.jsx)(G.V,{color:"var(--parchment)",gap:48,size:1}),(0,n.jsx)(J.o,{pannable:!0,zoomable:!0,className:"!rounded-xl !bg-paper/70 !backdrop-blur-sm",maskColor:"transparent",maskStrokeColor:"transparent",nodeColor:e=>{let t=e.data.node.type;return t===c.Z.SYSTEM?"var(--system)":t===c.Z.USER?"var(--human)":t===c.Z.ASSISTANT?"var(--machine)":"var(--copper)"}}),(0,n.jsx)(es,{onAutoLayout:E})]}),R&&(0,q.createPortal)((0,n.jsxs)("div",{ref:P,className:"fixed z-[60] w-52 rounded-xl border border-parchment bg-paper p-2 shadow-[0_16px_38px_rgba(26,24,22,0.12)]",style:{left:R.x,top:R.y},onContextMenu:e=>e.preventDefault(),children:[(0,n.jsx)(ed,{onClick:()=>{x(R.nodeId),H()},children:r("tree.menu.continueFromHere")}),(0,n.jsx)(ed,{disabled:!em,onClick:()=>{em&&(h(ec),j(),H())},children:r("tree.menu.compressBranch")}),(0,n.jsx)(ed,{disabled:!ep,onClick:()=>{eo&&ep&&window.confirm(r("tree.menu.decompressConfirm"))&&(y(eo.id),H())},children:r("tree.menu.decompress")}),(0,n.jsx)(ed,{onClick:()=>{g(R.nodeId),H()},children:r("tree.menu.addToContext")}),(0,n.jsx)(ed,{onClick:()=>{Q(R.nodeId),H()},children:r("tree.menu.editNode")}),(0,n.jsx)(ed,{disabled:ea,onClick:()=>{ea||(b(R.nodeId),H())},children:r("tree.menu.deleteSubtree")})]}),document.body),(0,n.jsx)($.a,{open:B,title:r("tree.editor.title"),onClose:()=>z(!1),children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("textarea",{className:"h-48 w-full resize-none rounded-xl border border-parchment bg-paper p-3 font-body text-[0.9rem] leading-relaxed text-ink outline-none focus:border-copper",value:O,onChange:e=>V(e.target.value)}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(m,{variant:"secondary",onClick:()=>{z(!1)},children:r("common.cancel")}),(0,n.jsx)(m,{variant:"primary",onClick:()=>{if(!Z)return;let e=l.get(Z);e&&(v(Z,e.type===c.Z.COMPRESSED?{summary:O}:{content:O}),z(!1))},children:r("common.save")})]})]})})]})}function em(){let[e,t]=(0,o.useState)(0),r=(0,o.useCallback)(()=>{window.setTimeout(()=>{t(e=>e+1)},220)},[]);return(0,n.jsx)("div",{className:"pointer-events-none absolute right-6 top-6 z-20 lg:right-8 lg:top-6",children:(0,n.jsx)("div",{className:"group pointer-events-auto relative h-[110px] w-[170px] overflow-hidden rounded-xl transition-all duration-200 lg:h-[130px] lg:w-[210px] lg:hover:h-[min(640px,62vh)] lg:hover:w-[min(920px,calc(100vw_-_3rem))] lg:focus-within:h-[min(640px,62vh)] lg:focus-within:w-[min(920px,calc(100vw_-_3rem))] lg:hover:bg-paper lg:focus-within:bg-paper",onMouseEnter:()=>r(),onFocusCapture:()=>r(),children:(0,n.jsx)("div",{className:"relative h-full w-full [&_.react-flow__attribution]:hidden [&_.react-flow__background]:opacity-0 [&_.react-flow__background]:transition-opacity [&_.react-flow__background]:duration-200 [&_.react-flow__renderer]:pointer-events-none [&_.react-flow__renderer]:opacity-0 [&_.react-flow__renderer]:transition-opacity [&_.react-flow__renderer]:duration-200 [&_.react-flow__panel]:!m-0 [&_.react-flow__minimap]:!inset-0 [&_.react-flow__minimap]:!h-full [&_.react-flow__minimap]:!w-full [&_.react-flow__minimap]:overflow-hidden [&_.react-flow__minimap_svg]:!h-full [&_.react-flow__minimap_svg]:!w-full [&_[data-tree-controls]]:hidden lg:group-hover:[&_.react-flow__background]:opacity-100 lg:group-hover:[&_.react-flow__renderer]:pointer-events-auto lg:group-hover:[&_.react-flow__renderer]:opacity-100 lg:group-hover:[&_.react-flow__minimap]:!top-auto lg:group-hover:[&_.react-flow__minimap]:!left-auto lg:group-hover:[&_.react-flow__minimap]:!right-4 lg:group-hover:[&_.react-flow__minimap]:!bottom-4 lg:group-hover:[&_.react-flow__minimap]:!h-[150px] lg:group-hover:[&_.react-flow__minimap]:!w-[210px] lg:group-hover:[&_.react-flow__minimap_svg]:!h-[150px] lg:group-hover:[&_.react-flow__minimap_svg]:!w-[210px] lg:group-hover:[&_[data-tree-controls]]:!flex lg:group-focus-within:[&_.react-flow__background]:opacity-100 lg:group-focus-within:[&_.react-flow__renderer]:pointer-events-auto lg:group-focus-within:[&_.react-flow__renderer]:opacity-100 lg:group-focus-within:[&_.react-flow__minimap]:!top-auto lg:group-focus-within:[&_.react-flow__minimap]:!left-auto lg:group-focus-within:[&_.react-flow__minimap]:!right-4 lg:group-focus-within:[&_.react-flow__minimap]:!bottom-4 lg:group-focus-within:[&_.react-flow__minimap]:!h-[150px] lg:group-focus-within:[&_.react-flow__minimap]:!w-[210px] lg:group-focus-within:[&_.react-flow__minimap_svg]:!h-[150px] lg:group-focus-within:[&_.react-flow__minimap_svg]:!w-[210px] lg:group-focus-within:[&_[data-tree-controls]]:!flex",children:(0,n.jsx)(ec,{fitViewOnInit:!1,fitViewTrigger:e})})})})}var ep=r(5772);function eu(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2z"})})}function ex(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}function eh(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 10V3L4 14h7v7l9-11h-7z"})})}function ef(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}function eg(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M14.7 6.3a4 4 0 0 1-5.65 5.65L3 18v3h3l6.05-6.05a4 4 0 0 1 5.65-5.65l-2.1 2.1 1.4 1.4 2.1-2.1Z"})})}function eb(){return(0,n.jsxs)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8l-6-6z"}),(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M14 2v6h6"})]})}function ev(){return(0,n.jsx)("svg",{width:"10",height:"10",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})}function ej(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})})}function ey(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}function ew(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",className:"h-4 w-4",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M9 5l7 7-7 7"})})}function ek({card:e,onRemove:t,onClick:r,draggable:o,onDragStart:s,onDragEnter:l,onDragEnd:i}){let d=(0,a.k)(),c="compressed"===e.type;return(0,n.jsxs)("div",{className:`context-card-hover relative mb-2.5 rounded-xl border p-3.5 transition-all duration-200 ${o?"cursor-grab active:cursor-grabbing":"cursor-default"} ${c?"border-copper bg-copper-glow":"border-parchment bg-paper"}`,"data-context-card-id":e.id,draggable:o,onClick:r,onDragStart:e=>{o&&(e.dataTransfer.effectAllowed="move",s?.())},onDragEnter:()=>l?.(),onDragOver:e=>{o&&e.preventDefault()},onDragEnd:()=>i?.(),children:[(0,n.jsx)("button",{className:"context-card-remove absolute right-2.5 top-2.5 flex h-5 w-5 items-center justify-center rounded-full bg-cream opacity-0 text-sand transition-all duration-150 hover:bg-[#e74c3c] hover:text-white",onClick:r=>{r.stopPropagation(),t(e.id)},"aria-label":d("context.removeFromContextAria"),children:(0,n.jsx)(ev,{})}),(0,n.jsxs)("div",{className:"mb-2 flex items-center gap-2.5",children:[(0,n.jsx)("div",{className:`flex h-6 w-6 items-center justify-center rounded-md text-cream ${function(e){switch(e){case"system":return"bg-system";case"human":return"bg-human";case"machine":return"bg-machine";case"compressed":case"tool":case"file":return"bg-copper"}}(e.type)}`,children:(0,n.jsx)("div",{className:"h-3 w-3",children:function(e){switch(e){case"system":return(0,n.jsx)(eu,{});case"human":return(0,n.jsx)(ex,{});case"machine":return(0,n.jsx)(eh,{});case"compressed":return(0,n.jsx)(ef,{});case"tool":return(0,n.jsx)(eg,{});case"file":return(0,n.jsx)(eb,{})}}(e.type)})}),(0,n.jsx)("span",{className:"flex-1 text-[0.8rem] font-medium text-ink",children:e.title}),(0,n.jsx)("span",{className:"font-mono text-[0.7rem] text-sand",children:e.tokens})]}),(0,n.jsx)("div",{className:"line-clamp-2 text-[0.8rem] leading-snug text-clay",children:e.preview})]})}function eN(){let e=(0,a.k)(),t=(0,d.CU)(e=>e.locale),r=(0,d.CU)(e=>e.nodes),s=(0,d.CU)(e=>e.contextBox),u=(0,d.CU)(e=>e.getCurrentTree()),x=(0,d.CU)(e=>e.activeNodeId),h=(0,d.CU)(e=>e.selectedNodeIds),g=(0,d.CU)(e=>e.addToContext),b=(0,d.CU)(e=>e.addFilesToContext),v=(0,d.CU)(e=>e.removeFromContext),y=(0,d.CU)(e=>e.clearContext),w=(0,d.CU)(e=>e.reorderContext),k=(0,d.CU)(e=>e.buildContextContent),N=(0,d.CU)(e=>e.toolSettings),C=(0,d.CU)(e=>e.draftToolUses),S=(0,d.CU)(e=>e.toggleDraftToolUse),_=(0,d.CU)(e=>e.compressionOpen),M=(0,d.CU)(e=>e.openCompression),U=(0,d.CU)(e=>e.closeCompression),E=(0,d.CU)(e=>e.compressNodes),T=(0,d.CU)(e=>e.generateCompressionSuggestion),I=(0,d.CU)(e=>e.isCompressing),A=(0,d.CU)(e=>e.compressionError),[L,R]=(0,o.useState)(null),[D,P]=(0,o.useState)(null),z=(0,o.useMemo)(()=>D??s?.blocks?.map(e=>e.id)??[],[D,s?.blocks]),Z=(0,o.useMemo)(()=>new Map(s?.blocks?.map(e=>[e.id,e])??[]),[s?.blocks]),W=(0,o.useMemo)(()=>{if(!s)return[];let t=[];for(let n of z){let o=Z.get(n);if(!o)continue;if("file"===o.kind){let r="image"===o.fileKind?`${o.mimeType} \xb7 ${(o.size/1024).toFixed(1)} KB`:o.content.trim().slice(0,160)+(o.truncated?"…":"");t.push({id:o.id,type:"file",title:o.filename,preview:r||("image"===o.fileKind?e("common.data"):e("tree.node.emptyContent")),tokens:o.tokenCount});continue}let a=r.get(o.nodeId);if(!a)continue;let s=a.type===c.Z.SYSTEM?"system":a.type===c.Z.USER?"human":a.type===c.Z.ASSISTANT?"machine":"compressed",l="system"===s?e("context.card.system"):"human"===s?e("context.card.user"):"machine"===s?a.metadata.modelName??e("node.author.assistant"):e("context.card.compressed"),i=a.type===c.Z.COMPRESSED?a.summary??a.content:a.content,d=a.type===c.Z.ASSISTANT?j(i).visible:i;t.push({id:o.id,type:s,title:l,preview:d,tokens:a.tokenCount})}return t},[s,z,Z,r,e]),O=(0,o.useMemo)(()=>(0,i.d)(C,N),[C,N]),V=(0,o.useMemo)(()=>O.map(e=>{var t;return{id:e.id,type:"tool",title:e.title,preview:e.content,tokens:(t=e.content,(0,l.b)(t))}}),[O]),H=V.reduce((e,t)=>e+t.tokens,0),Y=(s?.totalTokens??0)+H,K=s?.maxTokens??8192,q=K>0?Y/K*100:0,X=(0,o.useRef)(null),[G,J]=(0,o.useState)(!1),[ee,et]=(0,o.useState)(!1),[er,en]=(0,o.useState)(null),[eo,ea]=(0,o.useState)(null),es=(0,o.useRef)(null),el=(0,o.useMemo)(()=>{let e=u?.rootId??null,t=s?.blocks?.filter(e=>"node"===e.kind).map(e=>e.nodeId)??[];return e?t.filter(t=>t!==e):t},[s?.blocks,u?.rootId]),ei=x??el[el.length-1]??null,ed=h.length>=2&&!!(ei&&h.includes(ei))&&h.every(e=>el.includes(e)),ec=(0,o.useMemo)(()=>ed?h:el,[ed,h,el]),em=ec.length>=2,eu=ed?e("context.compress.selected",{count:h.length}):e("context.compress.context",{count:el.length}),{compressionNodeIds:ex,compressionSelectionError:eh}=(0,o.useMemo)(()=>{if(!_)return{compressionNodeIds:[],compressionSelectionError:null};try{return{compressionNodeIds:function(e,t,r,n){let o=Array.from(new Set(e)).filter(e=>t.has(e));if(o.length<2)throw Error("context.compress.errors.minTwoNodes");let a=new Set(o),s=null;if(n&&t.has(n)){let e=(0,F.VK)(t,n);if(!o.every(t=>e.includes(t)))throw Error("context.compress.errors.noGaps");s=e}else for(let e of o){let r=(0,F.VK)(t,e);if(o.every(e=>r.includes(e))){if(s)throw Error("context.compress.errors.noBranches");s=r}}if(!s)throw Error("context.compress.errors.noGaps");let l=s.findIndex(e=>a.has(e));if(-1===l)throw Error("context.compress.errors.noGaps");let i=s.slice(l);if(r&&(i=i.filter(e=>e!==r)),i.length<2)throw Error("context.compress.errors.minTwoNodes");return i}(ec,r,u?.rootId??null,ed?null:ei),compressionSelectionError:null}}catch(e){return{compressionNodeIds:[],compressionSelectionError:e instanceof Error?e.message:"context.compress.errors.invalidSelection"}}},[_,ec,r,ei,u?.rootId,ed]),[eg,eb]=(0,o.useState)(""),[ev,eN]=(0,o.useState)(""),[eC,eS]=(0,o.useState)(""),[e_,eM]=(0,o.useState)(""),eU=async()=>{et(!0),en(null);try{let e=await k();en(e)}catch(r){let t=r instanceof Error?r.message:"context.preview.failed";en((0,f.d)(t)?e(t):t)}},eE=eh&&(0,f.d)(eh)?e(eh):eh,eT=A&&(0,f.d)(A)?e(A):A,eI=e=>{let t=X.current;if(!t)return W.length;let r=Array.from(t.querySelectorAll("[data-context-card-id]"));if(0===r.length)return 0;for(let t=0;t<r.length;t+=1){let n=r[t]?.getBoundingClientRect();if(n&&e<n.top+n.height/2)return t}return r.length};return(0,n.jsxs)("aside",{className:"flex h-full min-h-0 flex-col overflow-hidden border-l border-parchment bg-cream",children:[(0,n.jsxs)("div",{className:"border-b border-parchment px-6 pb-5 pt-7",children:[(0,n.jsx)("div",{className:"font-display text-[1.1rem] text-ink",children:e("context.title")}),(0,n.jsx)("div",{className:"mt-1 font-mono text-[0.7rem] uppercase tracking-widest text-sand",children:e("context.subtitle")})]}),(0,n.jsxs)("div",{className:"border-b border-parchment p-6",children:[(0,n.jsxs)("div",{className:"mb-4 flex items-baseline justify-between",children:[(0,n.jsx)("span",{className:"font-mono text-[0.7rem] uppercase tracking-widest text-sand",children:e("context.tokenUsage")}),(0,n.jsxs)("span",{className:"font-mono text-[0.85rem] text-ink",children:[(0,n.jsx)("strong",{className:"font-medium text-copper",children:Y.toLocaleString(t)})," ","/ ",K.toLocaleString(t)]})]}),(0,n.jsx)("div",{className:"h-1.5 overflow-hidden rounded-sm bg-paper",children:(0,n.jsx)("div",{className:"h-full rounded-sm bg-gradient-to-r from-copper to-copper-light transition-all duration-500",style:{width:`${Math.min(100,q)}%`}})}),(0,n.jsxs)("div",{className:"mt-2 flex justify-between font-mono text-[0.65rem] text-sand",children:[(0,n.jsx)("span",{children:"0"}),(0,n.jsx)("span",{children:"4K"}),(0,n.jsx)("span",{children:"8K"})]})]}),(0,n.jsxs)("div",{className:"flex flex-1 min-h-0 flex-col p-5",children:[(0,n.jsxs)("div",{className:"mb-3 flex items-center justify-between font-mono text-[0.65rem] uppercase tracking-[0.15em] text-sand",children:[(0,n.jsx)("span",{children:e("context.activeNodes")}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("button",{className:"border-none bg-transparent font-body text-[0.75rem] normal-case tracking-normal text-copper hover:underline",onClick:()=>es.current?.click(),children:e("chat.input.attach")}),(0,n.jsx)("button",{className:"border-none bg-transparent font-body text-[0.75rem] normal-case tracking-normal text-copper hover:underline",onClick:y,children:e("context.clearAll")}),(0,n.jsx)("input",{ref:es,className:"hidden",type:"file",multiple:!0,accept:(0,p.X)(),onChange:e=>{let t=Array.from(e.target.files??[]);t.length>0&&b(t),e.target.value=""}})]})]}),V.length>0?(0,n.jsxs)("div",{className:"mb-4",children:[(0,n.jsx)("div",{className:"mb-3 font-mono text-[0.65rem] uppercase tracking-[0.15em] text-sand",children:e("context.toolBlocks")}),(0,n.jsx)("div",{className:"max-h-[140px] overflow-y-auto pr-1",children:V.map(e=>(0,n.jsx)(ek,{card:e,onRemove:e=>{("web_search"===e||"python"===e||"mcp"===e||e.startsWith("mcp:")&&e.slice(4).trim())&&S(e)}},e.id))})]}):null,(0,n.jsx)("div",{ref:X,className:`flex-1 min-h-0 overflow-y-auto pr-1 transition-colors duration-150 ${G?"rounded-xl bg-copper-glow":""}`,"data-testid":"context-dropzone",onDragOver:e=>{e.preventDefault(),L||J(!0)},onDragLeave:()=>J(!1),onDrop:e=>{if(e.preventDefault(),J(!1),L)return;let t=Array.from(e.dataTransfer.files??[]);if(t.length>0)return void b(t,eI(e.clientY));let r=e.dataTransfer.getData(Q)||e.dataTransfer.getData("text/plain");r&&g(r,eI(e.clientY))},children:0===W.length?(0,n.jsx)("div",{className:"flex h-full items-center justify-center rounded-xl border border-parchment bg-paper/60 p-4 text-center text-sand",children:(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("div",{className:"mx-auto flex h-9 w-9 items-center justify-center rounded-xl bg-paper text-sand",children:(0,n.jsx)("div",{className:"h-5 w-5",children:(0,n.jsx)(ej,{})})}),(0,n.jsx)("div",{className:"text-[0.85rem] text-clay",children:e("context.dropzone.title")}),(0,n.jsx)("div",{className:"text-[0.75rem]",children:e("context.dropzone.subtitle")})]})}):W.map(e=>(0,n.jsx)(ek,{card:e,onRemove:v,onClick:()=>{let t=Z.get(e.id)??null;t&&"file"===t.kind&&ea(t)},draggable:!0,onDragStart:()=>{R(e.id),P(z)},onDragEnter:()=>{L&&P(t=>{let r=t??z,n=r.indexOf(L),o=r.indexOf(e.id);return -1===n||-1===o||n===o?r:((e,t,r)=>{if(t===r)return e;let n=e.slice(),[o]=n.splice(t,1);return o?(n.splice(r,0,o),n):e})(r,n,o)})},onDragEnd:()=>{w(D??z),R(null),P(null)}},e.id))})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-2.5 border-t border-parchment p-5",children:[(0,n.jsxs)("button",{className:`flex w-full items-center gap-3 rounded-[10px] border border-parchment bg-paper px-5 py-3.5 font-body text-[0.85rem] text-ink transition-all duration-150 ${em?"hover:border-copper hover:bg-copper-glow":"cursor-not-allowed opacity-60"}`,disabled:!em,onClick:()=>{em&&(eb(""),eN(""),eS(""),eM(""),M())},children:[(0,n.jsx)("div",{className:"h-[18px] w-[18px] text-copper",children:(0,n.jsx)(ef,{})}),eu]}),(0,n.jsxs)("button",{className:"flex w-full items-center gap-3 rounded-[10px] border border-parchment bg-paper px-5 py-3.5 font-body text-[0.85rem] text-ink opacity-60 transition-all duration-150",disabled:!0,children:[(0,n.jsx)("div",{className:"h-[18px] w-[18px] text-copper",children:(0,n.jsx)(ey,{})}),e("context.optimize")]})]}),(0,n.jsxs)("button",{className:"flex items-center justify-between border-t border-parchment bg-transparent px-5 py-4 font-body text-[0.85rem] text-clay transition-all duration-150 hover:bg-paper hover:text-ink",onClick:()=>void eU(),children:[(0,n.jsx)("span",{children:e("context.preview.button")}),(0,n.jsx)(ew,{})]}),(0,n.jsx)($.a,{open:ee,title:e("context.preview.title"),onClose:()=>et(!1),children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("div",{className:"max-h-[50vh] overflow-auto rounded-xl border border-parchment bg-paper p-4 font-mono text-[0.75rem] leading-relaxed text-ink",children:er??e("context.preview.building")}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)(m,{variant:"secondary",onClick:()=>et(!1),children:e("common.close")})})]})}),(0,n.jsx)($.a,{open:_,title:e("context.compress.title"),onClose:()=>{U(),eb(""),eN(""),eS(""),eM("")},children:(0,n.jsxs)("div",{className:"space-y-4",children:[eE&&(0,n.jsx)("div",{className:"rounded-xl border border-[#e74c3c]/40 bg-[#fff5f2] p-3 text-[0.85rem] text-[#b73c2b]",children:eE}),eT&&(0,n.jsx)("div",{className:"rounded-xl border border-[#e74c3c]/40 bg-[#fff5f2] p-3 text-[0.85rem] text-[#b73c2b]",children:eT}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"mb-2 font-mono text-[0.7rem] uppercase tracking-widest text-sand",children:e("context.compress.selection",{count:ex.length})}),(0,n.jsx)("div",{className:"max-h-44 space-y-2 overflow-auto rounded-xl border border-parchment bg-paper p-3 text-[0.8rem] text-clay",children:0===ex.length?(0,n.jsx)("div",{className:"text-sand",children:e("context.compress.noneSelected")}):ex.map(e=>r.get(e)).filter(e=>!!e).map(t=>(0,n.jsxs)("div",{className:"rounded-lg bg-cream p-2",children:[(0,n.jsxs)("div",{className:"mb-1 flex items-center justify-between font-mono text-[0.65rem] uppercase tracking-wide text-sand",children:[(0,n.jsx)("span",{children:(t=>{switch(t){case c.Z.SYSTEM:return e("node.type.system");case c.Z.USER:return e("node.type.user");case c.Z.ASSISTANT:return e("node.type.assistant");case c.Z.COMPRESSED:return e("node.type.compressed")}})(t.type)}),(0,n.jsx)("span",{children:t.tokenCount})]}),(0,n.jsx)("div",{className:"line-clamp-2 whitespace-pre-wrap",children:t.type===c.Z.COMPRESSED?t.summary??t.content:t.content})]},t.id))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"mb-2 font-mono text-[0.7rem] uppercase tracking-widest text-sand",children:e("context.compress.summary")}),(0,n.jsx)("textarea",{className:"h-32 w-full resize-none rounded-xl border border-parchment bg-paper p-3 font-body text-[0.9rem] leading-relaxed text-ink outline-none focus:border-copper",value:eg,onChange:e=>eb(e.target.value),placeholder:e("context.compress.summaryPlaceholder")})]}),(0,n.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"mb-2 font-mono text-[0.7rem] uppercase tracking-widest text-sand",children:e("context.compress.language")}),(0,n.jsx)(B,{value:ev,onChange:e=>eN(e.target.value),placeholder:e("context.compress.languagePlaceholder"),autoComplete:"off"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"mb-2 font-mono text-[0.7rem] uppercase tracking-widest text-sand",children:e("context.compress.format")}),(0,n.jsx)(B,{value:eC,onChange:e=>eS(e.target.value),placeholder:e("context.compress.formatPlaceholder"),autoComplete:"off"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"mb-2 font-mono text-[0.7rem] uppercase tracking-widest text-sand",children:e("context.compress.role")}),(0,n.jsx)(B,{value:e_,onChange:e=>eM(e.target.value),placeholder:e("context.compress.rolePlaceholder"),autoComplete:"off"})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)(m,{variant:"secondary",onClick:()=>U(),disabled:I,children:e("common.cancel")}),(0,n.jsx)(m,{variant:"ghost",onClick:()=>{(async()=>{if(!(ex.length<2))try{let e=await T(ex);eb(e.summary),eN(e.metaInstructions.language??""),eS(e.metaInstructions.format??""),eM(e.metaInstructions.role??"")}catch{}})()},disabled:I||ex.length<2,children:e("context.compress.generate")}),(0,n.jsx)(m,{variant:"primary",onClick:()=>{(async()=>{if(ex.length<2||eh)return;let e={};ev.trim()&&(e.language=ev.trim()),eC.trim()&&(e.format=eC.trim()),e_.trim()&&(e.role=e_.trim());try{await E(ex,{summary:eg,metaInstructions:e}),U()}catch{}})()},disabled:I||!!eh,children:e("context.compress.confirm")})]})]})}),(0,n.jsx)($.a,{open:!!eo,title:eo?.kind==="file"?eo.filename:e("context.preview.title"),onClose:()=>ea(null),children:eo?.kind==="file"?"image"===eo.fileKind?(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)(ep.default,{src:eo.dataUrl,alt:eo.filename,width:1200,height:900,unoptimized:!0,className:"max-h-[60vh] w-full rounded-xl border border-parchment bg-paper object-contain"}),(0,n.jsxs)("div",{className:"font-mono text-[0.7rem] text-sand",children:[eo.mimeType," \xb7 ",(eo.size/1024).toFixed(1)," KB"]})]}):(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)("div",{className:"max-h-[60vh] overflow-auto rounded-xl border border-parchment bg-paper p-4 font-mono text-[0.75rem] leading-relaxed text-ink",children:eo.content}),eo.truncated?(0,n.jsx)("div",{className:"font-mono text-[0.7rem] text-sand",children:"[Truncated]"}):null]}):null})]})}function eC(){return(0,n.jsxs)("svg",{width:"14",height:"14",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:"1.5"})]})}function eS(){let e=(0,a.k)(),t=(0,d.CU)(e=>e.currentView),r=(0,d.CU)(e=>e.getCurrentTree()),s=(0,d.CU)(e=>e.getCurrentFolder()),l=(0,d.CU)(e=>e.currentFolderId),i=(0,d.CU)(e=>e.trees),c=(0,d.CU)(e=>e.nodes.size),m=(0,d.CU)(e=>e.nodes),p=(0,d.CU)(e=>e.theme),u=(0,d.CU)(e=>e.toggleTheme),x=(0,d.CU)(e=>e.toggleSidebar),h=(0,d.CU)(e=>e.toggleContextPanel),f=(0,o.useMemo)(()=>"tree"===t&&r?(0,F.qi)(m.values(),r.rootId):0,[r,t,m]),g=(0,o.useMemo)(()=>{if("folder"!==t||!l)return 0;let e=0;for(let t of i.values())(t.folderId??null)===l&&(e+=1);return e},[l,t,i]),b="folder"===t?s?.name??e("header.fallback.folder"):r?.title??e("header.fallback.loading");return(0,n.jsxs)("header",{className:"flex flex-col gap-4 border-b border-parchment bg-paper px-6 py-4 lg:flex-row lg:items-center lg:justify-between lg:px-8 lg:py-5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("button",{type:"button",className:"rounded-full border border-parchment px-3 py-1 text-[0.65rem] font-semibold uppercase tracking-[0.2em] text-clay transition-all duration-150 hover:border-copper hover:text-ink lg:hidden",onClick:()=>x(),"aria-label":e("header.menu"),children:e("header.menu")}),(0,n.jsx)("h2",{className:"font-display text-[1.35rem] font-normal text-ink",children:b})]}),(0,n.jsx)("button",{type:"button",className:"rounded-full border border-parchment px-3 py-1 text-[0.65rem] font-semibold uppercase tracking-[0.2em] text-clay transition-all duration-150 hover:border-copper hover:text-ink lg:hidden",onClick:()=>h(),"aria-label":e("header.context"),children:e("header.context")})]}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-4 lg:gap-6",children:["folder"===t?(0,n.jsx)("div",{className:"flex flex-wrap gap-4 font-mono text-[0.75rem] text-sand",children:(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:"font-medium text-ink",children:g})," ",e("header.threads")]})}):(0,n.jsxs)("div",{className:"flex flex-wrap gap-4 font-mono text-[0.75rem] text-sand",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:"font-medium text-ink",children:c})," ",e("header.nodes")]}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:"font-medium text-ink",children:f})," ",e("header.branches")]})]}),(0,n.jsxs)(A(),{href:"/settings",className:"flex items-center gap-1.5 rounded-full border border-parchment px-3 py-1 text-[0.65rem] font-semibold uppercase tracking-[0.2em] text-clay transition-all duration-150 hover:border-copper hover:text-ink",children:[(0,n.jsx)(eC,{}),e("common.settings")]}),(0,n.jsx)("button",{type:"button",className:"flex items-center gap-2 rounded-full border border-parchment px-3 py-1 text-[0.65rem] font-semibold uppercase tracking-[0.2em] text-clay transition-all duration-150 hover:border-copper hover:text-ink",onClick:()=>u(),"aria-label":e("header.toggleTheme"),children:e("light"===p?"header.theme.light":"header.theme.dark")})]})]})}var e_=r(3653),eM=r(9),eU=r(4833);async function eE(e){if("u"<typeof indexedDB||0===e.length)return{};let t=(await (0,e_.xA)()).transaction([eU.w.stores.nodes.name],"readonly"),r=t.objectStore(eU.w.stores.nodes.name),n=await (0,eM.k7)(r.getAll());await (0,eM.PE)(t);let o=new Set,a=new Map;for(let e of n??[]){if(o.add(e.id),!e.parentId)continue;let t=a.get(e.parentId);t?t.push(e.id):a.set(e.parentId,[e.id])}let s={};for(let t of e){let e=t.rootId;if(!o.has(e))continue;let r=0,n=[e],l=new Set;for(;n.length>0;){let e=n.pop();if(!(!e||l.has(e))){if(l.add(e),o.has(e))for(let t of(r+=1,a.get(e)??[]))n.push(t)}}s[t.id]=r}return s}function eT(){return(0,n.jsxs)("svg",{width:"12",height:"12",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:"2"}),(0,n.jsx)("path",{strokeWidth:"2",d:"M12 6v6l4 2"})]})}function eI(){return(0,n.jsx)("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",className:"h-4 w-4",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 4v16m8-8H4"})})}function eA(){return(0,n.jsx)("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M3 7a2 2 0 012-2h5l2 2h7a2 2 0 012 2v10a2 2 0 01-2 2H5a2 2 0 01-2-2V7z"})})}function eL(){return(0,n.jsxs)("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:"1.5"})]})}function eR({tree:e,isActive:t,nodeCount:r,onClick:s,onDelete:l}){let i=(0,a.k)(),d=(0,o.useMemo)(()=>(0,L.m)(new Date(e.updatedAt),{addSuffix:!0}),[e.updatedAt]);return(0,n.jsxs)("div",{className:`group relative mb-1 cursor-pointer rounded-[10px] p-4 transition-all duration-150 ${t?"bg-paper":"hover:bg-paper"}`,onClick:s,children:[(0,n.jsx)("button",{type:"button",className:"absolute right-3 top-3 rounded-md p-1 text-sand opacity-0 transition-all duration-150 hover:bg-paper hover:text-[#e74c3c] group-hover:opacity-100","aria-label":i("sidebar.deleteThreadAria"),onClick:e=>{e.stopPropagation(),l()},children:(0,n.jsx)(z,{})}),(0,n.jsx)("div",{className:`absolute left-0 top-1/2 w-[3px] -translate-y-1/2 rounded-r-sm bg-copper transition-all duration-200 ${t?"h-6":"h-0"}`}),(0,n.jsx)("div",{className:"mb-1.5 text-[0.9rem] font-medium leading-tight text-ink",children:e.title}),(0,n.jsxs)("div",{className:"flex items-center gap-3 font-mono text-[0.7rem] text-sand",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)(eT,{}),d]}),(0,n.jsx)("span",{children:i("sidebar.nodeCount",{count:r??"—"})})]})]})}function eD({folder:e,isActive:t,threadCount:r,activityAt:s,onClick:l,onDelete:i}){let d=(0,a.k)(),c=(0,o.useMemo)(()=>(0,L.m)(new Date(s),{addSuffix:!0}),[s]);return(0,n.jsxs)("div",{className:`group relative mb-1 cursor-pointer rounded-[10px] p-4 transition-all duration-150 ${t?"bg-paper":"hover:bg-paper"}`,onClick:l,children:[(0,n.jsx)("div",{className:`absolute left-0 top-1/2 w-[3px] -translate-y-1/2 rounded-r-sm bg-copper transition-all duration-200 ${t?"h-6":"h-0"}`}),(0,n.jsxs)("div",{className:"mb-1.5 flex items-center justify-between gap-3",children:[(0,n.jsx)("div",{className:"text-[0.9rem] font-medium leading-tight text-ink",children:e.name}),(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sand",children:[(0,n.jsx)("button",{type:"button",className:"rounded-md p-1 text-sand opacity-0 transition-all duration-150 hover:bg-paper hover:text-[#e74c3c] group-hover:opacity-100","aria-label":d("sidebar.deleteFolderAria"),onClick:e=>{e.stopPropagation(),i()},children:(0,n.jsx)(z,{})}),(0,n.jsx)(eA,{})]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3 font-mono text-[0.7rem] text-sand",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)(eT,{}),c]}),(0,n.jsx)("span",{children:d("sidebar.threadCount",{count:r})})]})]})}function e$(){let e=(0,a.k)(),t=(0,d.CU)(e=>e.trees),r=(0,d.CU)(e=>e.folders),s=(0,d.CU)(e=>e.currentTreeId),l=(0,d.CU)(e=>e.getCurrentTree()),i=(0,d.CU)(e=>e.currentView),c=(0,d.CU)(e=>e.currentFolderId),m=(0,d.CU)(e=>e.nodes.size),p=(0,d.CU)(e=>e.createTree),u=(0,d.CU)(e=>e.createFolder),x=(0,d.CU)(e=>e.deleteTree),h=(0,d.CU)(e=>e.deleteFolder),f=(0,d.CU)(e=>e.loadTree),g=(0,d.CU)(e=>e.loadFolder),b=(0,o.useMemo)(()=>Array.from(t.values()),[t]),v=(0,o.useMemo)(()=>Array.from(r.values()),[r]),[j,y]=(0,o.useState)({}),[w,k]=(0,o.useState)(null),[N,C]=(0,o.useState)(!1),S=(0,o.useMemo)(()=>{let e=b.filter(e=>(e.folderId??null)===null).map(e=>({kind:"thread",id:e.id,activityAt:e.updatedAt,tree:e})),t=new Map;for(let e of b){let r=e.folderId??null;if(!r)continue;let n=t.get(r);n?n.push(e):t.set(r,[e])}return[...v.map(e=>{let r=t.get(e.id)??[],n=r.reduce((e,t)=>Math.max(e,t.updatedAt),-1/0);return{kind:"folder",id:e.id,activityAt:Math.max(e.updatedAt,n),folder:e,threadCount:r.length}}),...e].sort((e,t)=>t.activityAt-e.activityAt)},[v,b]);(0,o.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await eE(b);if(e)return;y(t)}catch{}})(),()=>{e=!0}},[b]),(0,o.useEffect)(()=>{s&&y(e=>e[s]===m?e:{...e,[s]:m})},[m,s]);let _=e(w?.kind==="folder"?"sidebar.confirmDeleteFolderTitle":"sidebar.confirmDeleteThreadTitle"),M=w&&"folder"===w.kind&&w.threadCount>0?e("sidebar.confirmDeleteFolderThreadNote",{count:w.threadCount}):"",U=w&&"folder"===w.kind?e("sidebar.confirmDeleteFolderBody",{name:w.name,threadNote:M}):w&&"thread"===w.kind?e("sidebar.confirmDeleteThreadBody",{title:w.title}):null;return(0,n.jsxs)("aside",{className:"flex h-full min-h-0 flex-col border-r border-parchment bg-cream",children:[(0,n.jsxs)("div",{className:"border-b border-parchment px-7 pb-6 pt-8",children:[(0,n.jsx)("h1",{className:"brand-dot flex items-baseline gap-2 font-display text-[1.75rem] font-normal tracking-tight text-ink",children:e("common.appName")}),(0,n.jsx)("div",{className:"mt-1 font-mono text-[0.7rem] uppercase tracking-widest text-sand",children:e("sidebar.tagline")})]}),(0,n.jsxs)("div",{className:"mx-5 mt-5 grid grid-cols-2 gap-3",children:[(0,n.jsxs)("button",{className:"flex items-center justify-center gap-2.5 rounded-lg bg-ink px-4 py-3.5 font-body text-[0.85rem] font-medium text-cream transition-all duration-200 hover:-translate-y-px hover:bg-charcoal",onClick:()=>void p(),children:[(0,n.jsx)(eI,{}),e("sidebar.newThread")]}),(0,n.jsxs)("button",{className:"flex items-center justify-center gap-2.5 rounded-lg border border-parchment bg-paper px-4 py-3.5 font-body text-[0.85rem] font-medium text-ink transition-all duration-200 hover:-translate-y-px hover:border-copper hover:bg-copper-glow",onClick:()=>void u(),children:[(0,n.jsx)(eA,{}),e("sidebar.newFolder")]})]}),(0,n.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto px-3 py-5",children:[(0,n.jsx)("div",{className:"mb-3 px-4 font-mono text-[0.65rem] uppercase tracking-[0.15em] text-sand",children:e("sidebar.library")}),S.map(e=>"folder"===e.kind?(0,n.jsx)(eD,{folder:e.folder,threadCount:e.threadCount,activityAt:e.activityAt,isActive:"folder"===i&&c===e.folder.id||"tree"===i&&(l?.folderId??null)===e.folder.id,onClick:()=>g(e.folder.id),onDelete:()=>k({kind:"folder",id:e.folder.id,name:e.folder.name,threadCount:e.threadCount})},e.id):(0,n.jsx)(eR,{tree:e.tree,isActive:"tree"===i&&s===e.tree.id,nodeCount:"tree"===i&&s===e.tree.id?m:j[e.tree.id]??null,onClick:()=>void f(e.tree.id),onDelete:()=>k({kind:"thread",id:e.tree.id,title:e.tree.title})},e.id))]}),(0,n.jsx)("div",{className:"border-t border-parchment p-5",children:(0,n.jsxs)(A(),{href:"/settings",className:"flex w-full items-center gap-2.5 rounded-lg border border-parchment bg-transparent px-4 py-3 font-body text-[0.85rem] text-clay transition-all duration-150 hover:border-sand hover:text-ink",children:[(0,n.jsx)(eL,{}),e("common.settings")]})}),(0,n.jsx)(P,{open:null!=w,title:_,description:U,confirmText:e("common.delete"),cancelText:e("common.cancel"),confirmDisabled:N,onConfirm:()=>{w&&!N&&(C(!0),(async()=>{try{"thread"===w.kind?await x(w.id):await h(w.id),k(null)}finally{C(!1)}})())},onClose:()=>{N||k(null)}})]})}let eP="prompt-tree.layout.v1",eB="cortex.layout.v1";function ez(e,t,r){return Math.min(Math.max(e,t),r)}function eF(){let e=(0,a.k)(),t=(0,d.CU)(e=>e.initialize),r=(0,d.CU)(e=>e.currentView),s=(0,d.CU)(e=>e.sidebarOpen),l=(0,d.CU)(e=>e.setSidebarOpen),i=(0,d.CU)(e=>e.contextPanelOpen),c=(0,d.CU)(e=>e.setContextPanelOpen),m=(0,o.useRef)(null),[p,u]=(0,o.useState)(280),[x,h]=(0,o.useState)(340),[f,g]=(0,o.useState)(null);(0,o.useEffect)(()=>{t()},[t]),(0,o.useEffect)(()=>{let e=window.matchMedia("(min-width: 1024px)"),t=()=>{e.matches?(l(!0),c(!0)):(l(!1),c(!1))};return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[c,l]),(0,o.useEffect)(()=>{let e=window.localStorage.getItem(eP),t=e?null:window.localStorage.getItem(eB),r=e??t;if(r)try{let e=JSON.parse(r);"number"==typeof e.sidebarWidth&&u(e.sidebarWidth),"number"==typeof e.contextWidth&&h(e.contextWidth),t&&(window.localStorage.setItem(eP,r),window.localStorage.removeItem(eB))}catch{return}},[]);let b=(0,o.useCallback)(e=>{if(!m.current)return;let t=m.current.getBoundingClientRect();if("sidebar"===f){let r=Math.max(220,t.width-360-x-16);u(ez(e.clientX-t.left,220,r));return}if("context"===f){let r=Math.max(260,t.width-360-p-16);h(ez(t.right-e.clientX,260,r));return}},[x,f,p]);(0,o.useEffect)(()=>{if(!f)return;let e=()=>g(null);return window.addEventListener("pointermove",b),window.addEventListener("pointerup",e),document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",e),document.body.style.userSelect="",document.body.style.cursor=""}},[f,b]),(0,o.useEffect)(()=>{f||window.localStorage.setItem(eP,JSON.stringify({sidebarWidth:p,contextWidth:x}))},[x,f,p]),(0,o.useEffect)(()=>{let e=()=>{if(!m.current)return;let e=m.current.getBoundingClientRect(),t=Math.max(220,e.width-360-x-16);p>t&&u(t);let r=Math.max(260,e.width-360-p-16);x>r&&h(r)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[x,p]);let v={gridTemplateColumns:`${p}px 8px minmax(0, 1fr) 8px ${x}px`};return(0,n.jsxs)("div",{ref:m,className:"relative flex h-screen min-h-0 flex-col lg:grid lg:grid-rows-[minmax(0,1fr)]",style:v,children:[(0,n.jsx)("div",{className:`fixed inset-y-0 left-0 z-40 min-h-0 w-[82vw] max-w-[280px] -translate-x-full bg-cream transition-transform duration-200 lg:static lg:z-auto lg:h-full lg:w-full lg:max-w-none lg:translate-x-0 ${s?"translate-x-0":""}`,children:(0,n.jsx)(e$,{})}),(0,n.jsx)("div",{role:"separator","aria-orientation":"vertical",className:"group hidden h-full cursor-col-resize select-none touch-none items-center justify-center border-r border-parchment/60 bg-paper/40 transition-colors lg:flex",onPointerDown:e=>{0===e.button&&(e.preventDefault(),g("sidebar"))},children:(0,n.jsx)("div",{className:"h-12 w-[3px] rounded-full bg-parchment transition-colors group-hover:bg-copper"})}),s?(0,n.jsx)("button",{type:"button",className:"fixed inset-0 z-30 bg-ink/30 lg:hidden","aria-label":e("layout.closeSidebarAria"),onClick:()=>l(!1)}):null,(0,n.jsxs)("main",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden bg-paper",children:[(0,n.jsx)(eS,{}),"folder"===r?(0,n.jsx)(K,{}):(0,n.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[(0,n.jsx)(em,{}),(0,n.jsx)(T,{})]})]}),(0,n.jsx)("div",{role:"separator","aria-orientation":"vertical",className:"group hidden h-full cursor-col-resize select-none touch-none items-center justify-center border-l border-parchment/60 bg-paper/40 transition-colors lg:flex",onPointerDown:e=>{0===e.button&&(e.preventDefault(),g("context"))},children:(0,n.jsx)("div",{className:"h-12 w-[3px] rounded-full bg-parchment transition-colors group-hover:bg-copper"})}),(0,n.jsx)("div",{className:`fixed inset-y-0 right-0 z-40 min-h-0 w-[90vw] max-w-[360px] translate-x-full bg-cream transition-transform duration-200 lg:static lg:z-auto lg:h-full lg:w-full lg:max-w-none lg:translate-x-0 ${i?"translate-x-0":""}`,children:(0,n.jsx)(eN,{})}),i?(0,n.jsx)("button",{type:"button",className:"fixed inset-0 z-30 bg-ink/30 lg:hidden","aria-label":e("layout.closeContextPanelAria"),onClick:()=>c(!1)}):null]})}}},e=>{e.O(0,[642,702,307,991,394,787,441,794,358],()=>e(e.s=109)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[662],{92:(e,t,s)=>{"use strict";s.d(t,{ConnectedModelSelector:()=>x});var r=s(5155),n=s(2115),o=s(4394),a=s(513),l=s(1766),i=s(6222);function d({category:e,models:t,selectedIds:s,onToggle:o,onAddSelected:l}){let d=(0,a.k)(),[c,x]=(0,n.useState)(!0);if(0===t.length)return null;let h=t.filter(e=>s.has(e.id)),m=d("chat"===e?"modelCategory.chat":"reasoning"===e?"modelCategory.reasoning":"vision"===e?"modelCategory.vision":"embedding"===e?"modelCategory.embedding":"tool"===e?"modelCategory.tool":"modelCategory.other");return(0,r.jsxs)("div",{className:"mb-3 rounded-xl border border-parchment bg-cream overflow-hidden",children:[(0,r.jsxs)("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-paper/50",onClick:()=>x(!c),children:[(0,r.jsx)("span",{className:`transition-transform duration-200 ${c?"rotate-0":"-rotate-90"}`,children:(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})}),(0,r.jsx)("span",{className:"flex-1 font-body text-[0.9rem] font-medium text-ink",children:m}),(0,r.jsx)("span",{className:"rounded-full bg-parchment px-2 py-0.5 font-mono text-[0.7rem] text-clay",children:t.length}),h.length>0&&(0,r.jsx)("button",{type:"button",className:"rounded-lg bg-copper px-2.5 py-1 font-body text-[0.8rem] text-white transition-colors hover:bg-copper/90",onClick:e=>{e.stopPropagation(),l()},children:d("modelSelector.addCount",{count:h.length})})]}),c&&(0,r.jsx)("div",{className:"border-t border-parchment px-4 pb-3",children:(0,r.jsx)("div",{className:"space-y-1 pt-2",children:t.map(e=>{let t=s.has(e.id);return(0,r.jsxs)("div",{className:`group flex items-center gap-3 rounded-lg px-3 py-2.5 transition-all ${t?"bg-copper/10":"hover:bg-paper/50"}`,children:[(0,r.jsx)("button",{type:"button",className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded border transition-all ${t?"border-copper bg-copper text-white":"border-parchment bg-transparent hover:border-sand"}`,onClick:()=>o(e.id),children:t&&(0,r.jsx)(i.Sr,{})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"font-mono text-[0.85rem] text-ink truncate",children:e.id}),e.name!==e.id&&(0,r.jsx)("div",{className:"font-body text-[0.75rem] text-sand truncate",children:e.name})]})]},e.id)})})})]})}function c({open:e,onClose:t}){let s=(0,a.k)(),c=(0,o.CU)(e=>e.providers),x=(0,o.CU)(e=>e.modelSelector);(0,o.CU)(e=>e.closeModelSelector);let h=(0,o.CU)(e=>e.setModelSelectorSearch),m=(0,o.CU)(e=>e.setModelSelectorTab),p=(0,o.CU)(e=>e.fetchModelsForSelector),g=(0,o.CU)(e=>e.addFetchedModels),[u,b]=(0,n.useState)(new Set),f=c.find(e=>e.id===x.providerId),y=new Set(f?.models.map(e=>e.id)||[]),j=x.fetchedModels.filter(e=>!y.has(e.id)).filter(e=>{let t=!x.searchQuery||e.id.toLowerCase().includes(x.searchQuery.toLowerCase())||e.name.toLowerCase().includes(x.searchQuery.toLowerCase()),s="all"===x.activeTab||e.category===x.activeTab;return t&&s}),v={};for(let e of j){let t=e.category||"chat";v[t]||(v[t]=[]),v[t].push(e)}let N=e=>{b(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})};return((0,n.useEffect)(()=>{e&&f&&0===x.fetchedModels.length&&p(f.id)},[e]),(0,n.useEffect)(()=>{e||b(new Set)},[e]),e)?(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-ink/20 backdrop-blur-sm",onClick:t}),(0,r.jsxs)("div",{className:"relative mx-auto my-8 flex h-full w-full max-w-xl flex-col rounded-2xl bg-paper shadow-xl",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-parchment px-6 py-4",children:[(0,r.jsxs)("h3",{className:"font-display text-xl text-ink",children:[f?.name||s("modelSelector.providerFallback")," - ",s("modelSelector.models")]}),(0,r.jsx)("button",{type:"button",className:"rounded-lg p-2 text-clay transition-colors hover:text-ink",onClick:t,children:(0,r.jsx)(i.US,{})})]}),(0,r.jsx)("div",{className:"border-b border-parchment px-6 py-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("div",{className:"flex-1 relative",children:[(0,r.jsx)(i.WI,{}),(0,r.jsx)("input",{type:"text",value:x.searchQuery,onChange:e=>h(e.target.value),placeholder:s("modelSelector.searchPlaceholder"),className:"w-full rounded-xl border border-parchment bg-cream pl-10 pr-4 py-2.5 font-body text-[0.9rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]"})]}),(0,r.jsx)("button",{type:"button",className:`flex-shrink-0 rounded-xl border border-parchment p-2.5 text-clay transition-all hover:border-copper hover:text-copper ${x.isLoading?"animate-spin":""}`,onClick:()=>{f&&p(f.id)},disabled:x.isLoading,children:(0,r.jsx)(i.fN,{})})]})}),(0,r.jsx)("div",{className:"flex items-center gap-1 border-b border-parchment px-6 py-3 overflow-x-auto",children:["all","chat","reasoning","vision","embedding","tool"].map(e=>(0,r.jsx)("button",{type:"button",className:`whitespace-nowrap rounded-lg px-3 py-1.5 font-body text-[0.8rem] transition-all ${x.activeTab===e?"bg-copper text-white":"text-clay hover:bg-cream hover:text-ink"}`,onClick:()=>m(e),children:(e=>{switch(e){case"all":return s("modelCategory.all");case"chat":return s("modelCategory.chat");case"reasoning":return s("modelCategory.reasoning");case"vision":return s("modelCategory.vision");case"embedding":return s("modelCategory.embedding");case"tool":return s("modelCategory.tool");default:return s("modelCategory.other")}})(e)},e))}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:x.isLoading?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,r.jsx)("div",{className:"mb-4 h-8 w-8 animate-spin rounded-full border-2 border-copper border-t-transparent"}),(0,r.jsx)("p",{className:"font-body text-[0.9rem] text-sand",children:s("modelSelector.fetching")})]}):x.error?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,r.jsx)("div",{className:"mb-4 text-red-400",children:(0,r.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"m15 9-6 6m0-6 6 6"})]})}),(0,r.jsx)("p",{className:"mb-1 font-body text-[0.9rem] text-clay",children:s("modelSelector.fetchFailed")}),(0,r.jsx)("p",{className:"font-body text-[0.8rem] text-sand",children:(0,l.d)(x.error)?s(x.error):x.error})]}):0===j.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,r.jsx)("div",{className:"mb-4 text-sand",children:(0,r.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,r.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,r.jsx)("path",{d:"M9 9h6v6H9z"})]})}),(0,r.jsx)("p",{className:"mb-1 font-body text-[0.9rem] text-clay",children:x.searchQuery?s("modelSelector.noMatches"):s("modelSelector.noModels")}),(0,r.jsx)("p",{className:"font-body text-[0.8rem] text-sand",children:x.searchQuery?s("modelSelector.tryOtherQuery"):s("modelSelector.configureApiKey")})]}):(0,r.jsx)("div",{children:Object.entries(v).map(([e,t])=>(0,r.jsx)(d,{category:e,models:t,selectedIds:u,onToggle:N,onAddSelected:()=>{let e=t.filter(e=>u.has(e.id)).map(e=>e.id);e.length>0&&(g(e),e.forEach(e=>u.delete(e)),b(new Set(u)))}},e))})}),u.size>0&&(0,r.jsxs)("div",{className:"flex items-center justify-between border-t border-parchment px-6 py-4",children:[(0,r.jsx)("span",{className:"font-body text-[0.85rem] text-sand",children:s("modelSelector.selectedCount",{count:u.size})}),(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-2 rounded-lg bg-copper px-4 py-2.5 font-body text-[0.9rem] text-white transition-colors hover:bg-copper/90",onClick:()=>{u.size>0&&(g(Array.from(u)),b(new Set))},children:[(0,r.jsx)(i.c1,{}),s("modelSelector.addSelected")]})]})]})]}):null}function x(){let e=(0,o.CU)(e=>e.modelSelector),t=(0,o.CU)(e=>e.closeModelSelector);return(0,r.jsx)(c,{open:e.open,onClose:t})}},3409:(e,t,s)=>{Promise.resolve().then(s.bind(s,92)),Promise.resolve().then(s.bind(s,9362)),Promise.resolve().then(s.bind(s,6531)),Promise.resolve().then(s.bind(s,4333)),Promise.resolve().then(s.bind(s,7977))},4333:(e,t,s)=>{"use strict";s.d(t,{SettingsPage:()=>T});var r=s(5155),n=s(8500),o=s.n(n),a=s(2115),l=s(4394),i=s(513),d=s(6531),c=s(9362),x=s(7977),h=s(92),m=s(1379),p=s(3653),g=s(6290),u=s(4752),b=s(9113),f=s(8353),y=s(5746),j=s(5989),v=s(5432),N=s(6222);function w(e){return"object"==typeof e&&null!==e}function k({title:e,description:t,action:s,children:n}){return(0,r.jsxs)("div",{className:"flex h-full flex-1 flex-col bg-shoji-white",children:[(0,r.jsx)("div",{className:"border-b border-parchment/10 px-8 py-8",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"font-zen-display text-2xl font-light text-ink-black tracking-wide",children:e}),t&&(0,r.jsx)("p",{className:"mt-2 max-w-xl font-zen-body text-sm text-stone-gray font-light",children:t})]}),s]})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,r.jsx)("div",{className:"max-w-3xl px-8 py-8",children:n})})]})}function C({title:e,description:t}){return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center rounded-2xl border-1.5 border-dashed border-parchment/20 bg-washi-cream/50 p-10 text-center",children:[(0,r.jsx)("div",{className:"mb-4 rounded-xl bg-shoji-white p-4 text-stone-gray",children:(0,r.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"M12 16v-4"}),(0,r.jsx)("path",{d:"M12 8h.01"})]})}),(0,r.jsx)("p",{className:"mb-2 font-zen-body text-sm text-stone-gray font-light",children:e}),(0,r.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:t})]})}function M(){let e=(0,i.k)(),t=(0,l.CU)(e=>e.providers),s=(0,l.CU)(e=>e.compressionModel),n=(0,l.CU)(e=>e.summaryModel),o=(0,l.CU)(e=>e.setLLMSettings),d=(0,l.CU)(e=>e.selectedModels),c=(0,l.CU)(e=>e.setSelectedModels),[x,h]=(0,a.useState)("idle"),[m,p]=(0,a.useState)(null),[g,u]=(0,a.useState)(null),b=(0,a.useMemo)(()=>(0,f.n)(t),[t]),j=(0,a.useMemo)(()=>new Set(d.map(f.R)),[d]),w=(0,a.useMemo)(()=>{let e=new Map;for(let t of b)e.has(t.providerId)||e.set(t.providerId,{providerId:t.providerId,providerName:t.providerName,models:[]}),e.get(t.providerId).models.push(t);return Array.from(e.values()).sort((e,t)=>e.providerName.localeCompare(t.providerName))},[b]);(0,a.useEffect)(()=>{let e=new Set(b.map(f.R)),t=d.filter(t=>e.has((0,f.R)(t)));t.length!==d.length&&c(t)},[b,d,c]),(0,a.useEffect)(()=>{let e=new Set(b.map(f.R)),t=s?(0,f.R)(s):null;t&&!e.has(t)&&o({compressionModel:null});let r=n?(0,f.R)(n):null;r&&!e.has(r)&&o({summaryModel:null})},[s,b,o,n]);let M=e=>({providerId:e.providerId,modelId:e.modelId}),S=async()=>{let s=d[0];if(!s){h("error"),p(e("settings.defaultModel.test.selectModelFirst"));return}let r=t.find(e=>e.id===s.providerId)??null;if(!r){h("error"),p(e("settings.defaultModel.test.providerMissing"));return}let n=(0,v.aA)(r);if(!n){h("error"),p(e("errors.missingApiKey"));return}h("running"),p(null),u(null);let o=await (0,y.DT)(n.value,r.baseUrl,s.modelId,{headers:r.headers,timeout:r.timeout,prompt:"ping"});if(u(o.responseTime??null),"healthy"===o.status){h("success"),p(o.content||e("settings.defaultModel.test.success"));return}h("error"),p(o.error||e("settings.defaultModel.test.failed"))},z=s?(0,f.R)(s):"",L=n?(0,f.R)(n):"";return(0,r.jsx)(k,{title:e("settings.defaultModel.title"),description:e("settings.defaultModel.description"),children:(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:e("settings.defaultModel.enabledModels.title")}),(0,r.jsx)("p",{className:"mt-2 font-zen-body text-sm text-stone-gray font-light",children:e("settings.defaultModel.enabledModels.description")})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/20 bg-shoji-white px-3 py-2 text-xs text-stone-gray transition-all duration-200 hover:border-matcha-green/40 hover:text-matcha-green",onClick:()=>{c(b.map(e=>M(e)))},disabled:0===b.length,children:e("common.selectAll")}),(0,r.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/20 bg-shoji-white px-3 py-2 text-xs text-stone-gray transition-all duration-200 hover:border-matcha-green/40 hover:text-matcha-green",onClick:()=>{c([])},disabled:0===d.length,children:e("common.clear")})]})]}),0===b.length?(0,r.jsx)("div",{className:"mt-6",children:(0,r.jsx)(C,{title:e("settings.defaultModel.enabledModels.emptyTitle"),description:e("settings.defaultModel.enabledModels.emptyDescription")})}):(0,r.jsx)("div",{className:"mt-6 space-y-6",children:w.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-3 font-zen-body text-xs text-stone-gray font-light",children:e.providerName}),(0,r.jsx)("div",{className:"space-y-2",children:e.models.map(e=>{let t=j.has((0,f.R)(e));return(0,r.jsxs)("button",{type:"button",className:`flex w-full items-center gap-3 rounded-xl border px-4 py-3 text-left transition-all duration-200 ${t?"border-matcha-green/40 bg-matcha-green/10":"border-parchment/20 bg-shoji-white hover:border-matcha-green/30"}`,onClick:()=>{let t;return t=(0,f.R)(e),void c(j.has(t)?d.filter(e=>(0,f.R)(e)!==t):[...d,M(e)])},children:[(0,r.jsx)("span",{className:`flex h-5 w-5 items-center justify-center rounded border text-[0.7rem] ${t?"border-matcha-green bg-matcha-green text-shoji-white":"border-parchment bg-transparent text-transparent"}`,children:"✓"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"font-mono text-sm text-ink-black",children:e.modelId}),(0,r.jsx)("div",{className:"text-xs text-stone-gray font-light",children:e.label})]})]},e.modelId)})})]},e.providerId))})]}),(0,r.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,r.jsx)("div",{className:"mb-3 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:e("settings.defaultModel.compressionModel.title")}),(0,r.jsxs)("select",{value:z,onChange:e=>{var t;let s;return t=e.target.value,void o({compressionModel:(s=b.find(e=>(0,f.R)(e)===t))?M(s):null,...s?{model:s.modelId}:{}})},disabled:0===b.length,className:"w-full rounded-xl border border-parchment/20 bg-shoji-white px-5 py-4 font-mono text-sm text-ink-black outline-none transition-all duration-300 focus:border-matcha-green/50 disabled:opacity-60",children:[(0,r.jsx)("option",{value:"",children:e("settings.defaultModel.compressionModel.placeholder")}),b.map(e=>(0,r.jsx)("option",{value:(0,f.R)(e),children:e.label},`${e.providerId}-${e.modelId}`))]}),(0,r.jsx)("p",{className:"mt-3 font-zen-body text-xs text-stone-gray font-light",children:e("settings.defaultModel.compressionModel.description")})]}),(0,r.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,r.jsx)("div",{className:"mb-3 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:e("settings.defaultModel.summaryModel.title")}),(0,r.jsxs)("select",{value:L,onChange:e=>{var t;let s;return t=e.target.value,void o({summaryModel:(s=b.find(e=>(0,f.R)(e)===t))?M(s):null})},disabled:0===b.length,className:"w-full rounded-xl border border-parchment/20 bg-shoji-white px-5 py-4 font-mono text-sm text-ink-black outline-none transition-all duration-300 focus:border-matcha-green/50 disabled:opacity-60",children:[(0,r.jsx)("option",{value:"",children:e("settings.defaultModel.summaryModel.placeholder")}),b.map(e=>(0,r.jsx)("option",{value:(0,f.R)(e),children:e.label},`${e.providerId}-${e.modelId}`))]}),(0,r.jsx)("p",{className:"mt-3 font-zen-body text-xs text-stone-gray font-light",children:e("settings.defaultModel.summaryModel.description")})]}),(0,r.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:e("settings.defaultModel.test.title")}),null!==g&&(0,r.jsx)("div",{className:"mt-2 font-mono text-xs text-stone-gray",children:e("settings.defaultModel.test.latency",{ms:g})})]}),(0,r.jsx)("button",{type:"button",className:`flex items-center gap-2 rounded-lg px-4 py-2.5 font-zen-body text-sm transition-all duration-300 ${"running"===x?"bg-washi-cream text-stone-gray cursor-wait":"bg-matcha-green/10 text-matcha-green hover:bg-matcha-green/20 font-light"}`,onClick:S,disabled:"running"===x||0===d.length,children:"running"===x?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.fN,{}),e("settings.defaultModel.test.running")]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.Sr,{}),e("settings.defaultModel.test.button")]})})]}),m&&(0,r.jsx)("p",{className:`mt-3 font-zen-body text-xs font-light ${{idle:"text-stone-gray",running:"text-kintsugi-gold",success:"text-matcha-green",error:"text-red-500"}[x]}`,children:m})]})]})})}function S(){let e=(0,i.k)(),t=(0,l.CU)(e=>e.temperature),s=(0,l.CU)(e=>e.maxTokens),n=(0,l.CU)(e=>e.setLLMSettings),[o,d]=(0,a.useState)(t.toString()),[c,x]=(0,a.useState)(s.toString()),[h,m]=(0,a.useState)(null);return(0,a.useEffect)(()=>{d(t.toString())},[t]),(0,a.useEffect)(()=>{x(s.toString())},[s]),(0,r.jsx)(k,{title:e("settings.general.title"),description:e("settings.general.description"),children:(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,r.jsx)("div",{className:"mb-4 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:e("settings.general.generation.title")}),(0,r.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-2 block font-zen-body text-xs text-stone-gray font-light",children:e("settings.general.generation.temperature")}),(0,r.jsx)("input",{type:"number",min:"0",max:"2",step:"0.1",value:o,onChange:e=>d(e.target.value),className:"w-full rounded-xl border border-parchment/20 bg-shoji-white px-5 py-4 font-zen-body text-sm text-ink-black outline-none transition-all duration-300 focus:border-matcha-green/50"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-2 block font-zen-body text-xs text-stone-gray font-light",children:e("settings.general.generation.maxTokens")}),(0,r.jsx)("input",{type:"number",min:"1",value:c,onChange:e=>x(e.target.value),className:"w-full rounded-xl border border-parchment/20 bg-shoji-white px-5 py-4 font-zen-body text-sm text-ink-black outline-none transition-all duration-300 focus:border-matcha-green/50"})]})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,r.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:h??e("settings.general.saveHint")}),(0,r.jsx)("button",{type:"button",className:"rounded-lg bg-matcha-green px-6 py-3 font-zen-body text-sm text-shoji-white transition-all duration-200 hover:bg-bamboo-light",onClick:()=>{let r=Number.parseFloat(o),a=Number.parseInt(c,10);n({temperature:Number.isFinite(r)?r:t,maxTokens:Number.isFinite(a)?a:s}),m(e("settings.general.saved")),setTimeout(()=>m(null),2e3)},children:e("settings.general.saveButton")})]})]})})}function z(){let e=(0,i.k)(),t=(0,l.CU)(e=>e.theme),s=(0,l.CU)(e=>e.setTheme),n=(0,l.CU)(e=>e.locale),o=(0,l.CU)(e=>e.setLocale),a=[{id:"light",label:e("settings.display.theme.light"),description:e("settings.display.theme.lightDesc")},{id:"dark",label:e("settings.display.theme.dark"),description:e("settings.display.theme.darkDesc")}],d=[{id:"en",label:e("settings.display.language.en"),description:e("settings.display.language.enDesc")},{id:"zh-CN",label:e("settings.display.language.zhCN"),description:e("settings.display.language.zhCNDesc")}];return(0,r.jsx)(k,{title:e("settings.display.title"),description:e("settings.display.description"),children:(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsxs)("section",{children:[(0,r.jsx)("div",{className:"mb-4 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:e("settings.display.theme")}),(0,r.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:a.map(e=>(0,r.jsxs)("button",{type:"button",className:`rounded-2xl border px-6 py-5 text-left transition-all duration-300 ${t===e.id?"border-matcha-green/40 bg-matcha-green/10":"border-parchment/20 bg-washi-cream/50 hover:border-matcha-green/40"}`,onClick:()=>s(e.id),children:[(0,r.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:e.label}),(0,r.jsx)("div",{className:"mt-2 font-zen-body text-xs text-stone-gray font-light",children:e.description})]},e.id))})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("div",{className:"mb-4 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:e("settings.display.language")}),(0,r.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:d.map(e=>(0,r.jsxs)("button",{type:"button",className:`rounded-2xl border px-6 py-5 text-left transition-all duration-300 ${n===e.id?"border-matcha-green/40 bg-matcha-green/10":"border-parchment/20 bg-washi-cream/50 hover:border-matcha-green/40"}`,onClick:()=>o(e.id),children:[(0,r.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:e.label}),(0,r.jsx)("div",{className:"mt-2 font-zen-body text-xs text-stone-gray font-light",children:e.description})]},e.id))})]})]})})}function L(){let e=(0,i.k)(),t=(0,l.CU)(e=>e.setLLMSettings),s=(0,l.CU)(e=>e.setTheme),[n,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(!1),[x,h]=(0,a.useState)(!1),[m,f]=(0,a.useState)(!1),[y,v]=(0,a.useState)(null),N=async()=>{o(!0),v(null);try{await (0,p.MR)(),v(e("settings.data.clear.success")),setTimeout(()=>window.location.reload(),800)}catch(t){v(t instanceof Error?t.message:e("settings.data.clear.failed")),o(!1)}},w=async()=>{c(!0),v(null);try{(0,g.YA)(""),(0,u.$t)(""),(0,j.Ny)(),(0,j.k8)(),t(b.ES),s("light"),v(e("settings.data.reset.success")),setTimeout(()=>window.location.reload(),800)}catch(t){v(t instanceof Error?t.message:e("settings.data.reset.failed")),c(!1)}};return(0,r.jsx)(k,{title:e("settings.data.title"),description:e("settings.data.description"),children:(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:e("settings.data.clear.title")}),(0,r.jsx)("p",{className:"mt-2 font-zen-body text-xs text-stone-gray font-light",children:e("settings.data.clear.description")})]}),x?(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("button",{type:"button",className:"rounded-lg bg-red-500 px-4 py-2 text-sm text-white",onClick:N,disabled:n,children:n?e("settings.data.clear.running"):e("settings.data.clear.confirm")}),(0,r.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/30 px-4 py-2 text-sm text-stone-gray",onClick:()=>h(!1),children:e("common.cancel")})]}):(0,r.jsx)("button",{type:"button",className:"rounded-lg border border-red-200 bg-red-50 px-5 py-2.5 font-zen-body text-sm text-red-600 transition-all duration-200 hover:bg-red-100",onClick:()=>h(!0),children:e("settings.data.clear.button")})]})}),(0,r.jsx)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:e("settings.data.reset.title")}),(0,r.jsx)("p",{className:"mt-2 font-zen-body text-xs text-stone-gray font-light",children:e("settings.data.reset.description")})]}),m?(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("button",{type:"button",className:"rounded-lg bg-matcha-green px-4 py-2 text-sm text-shoji-white",onClick:w,disabled:d,children:d?e("settings.data.reset.running"):e("settings.data.reset.confirm")}),(0,r.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/30 px-4 py-2 text-sm text-stone-gray",onClick:()=>f(!1),children:e("common.cancel")})]}):(0,r.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/30 bg-shoji-white px-5 py-2.5 font-zen-body text-sm text-stone-gray transition-all duration-200 hover:border-matcha-green/50 hover:text-matcha-green",onClick:()=>f(!0),children:e("settings.data.reset.button")})]})}),y&&(0,r.jsx)("p",{className:"font-zen-body text-xs text-stone-gray font-light",children:y})]})})}function _(){let e=(0,i.k)(),t=[{label:e("settings.about.version.label"),value:e("settings.about.version.value")},{label:e("settings.about.framework.label"),value:e("settings.about.framework.value")},{label:e("settings.about.storage.label"),value:e("settings.about.storage.value")},{label:e("settings.about.contact.email"),value:"yxp934@outlook.com"},{label:e("settings.about.contact.wechat"),value:"WanguA8"}];return(0,r.jsx)(k,{title:e("settings.about.title"),description:e("settings.about.description"),children:(0,r.jsx)("div",{className:"space-y-4",children:t.map(e=>(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-parchment/20 bg-washi-cream/50 px-6 py-4",children:[(0,r.jsx)("span",{className:"font-zen-body text-sm text-stone-gray font-light",children:e.label}),(0,r.jsx)("span",{className:"font-zen-display text-lg font-light text-ink-black",children:e.value})]},e.label))})})}function U(){let e=(0,i.k)(),t=(0,l.CU)(e=>e.toolSettings),s=(0,l.CU)(e=>e.setToolSettings),n=(0,l.CU)(e=>e.upsertMcpServer),o=(0,l.CU)(e=>e.deleteMcpServer),[d,c]=(0,a.useState)(!1),[x,h]=(0,a.useState)(!1),[p,g]=(0,a.useState)({status:"idle"}),u=async()=>{let s=t.search.provider,r="exa"===s?t.search.exaApiKey:t.search.tavilyApiKey;if(!r.trim())return void g({status:"error",message:e("settings.tools.search.missingApiKey",{provider:"exa"===s?"Exa":"Tavily"})});g({status:"running",message:void 0,latencyMs:void 0});let n=Date.now();try{let o=await fetch("/api/tools/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:s,apiKey:r,query:"OpenAI",maxResults:1,searchDepth:t.search.searchDepth})}),a=Math.max(0,Date.now()-n),l=await o.json().catch(()=>null);if(!o.ok){let t=w(l)&&"error"in l?String(l.error??""):"";throw Error(t||e("errors.requestFailedWithStatus",{status:o.status}))}let i=w(l)&&Array.isArray(l.results)&&l.results[0]&&w(l.results[0])&&"string"==typeof l.results[0].title?l.results[0].title:"";g({status:"success",latencyMs:a,message:i?e("settings.tools.search.test.successWithTitle",{title:i}):e("settings.tools.search.test.success")})}catch(t){g({status:"error",message:t instanceof Error?t.message:e("settings.tools.search.test.failed")})}},b={idle:"text-stone-gray",running:"text-kintsugi-gold",success:"text-matcha-green",error:"text-red-500"}[p.status],[f,y]=(0,a.useState)({}),[j,v]=(0,a.useState)({}),[M,S]=(0,a.useState)({}),z=(e,t)=>{let s=t.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g,"").replace(/\r/g,"").split("\n").map(e=>e.trimEnd()).filter(Boolean);0!==s.length&&y(t=>{let r=t[e],n=[...r?.logs??[],...s],o=n.slice(Math.max(0,n.length-200));return{...t,[e]:{...r??{status:"running"},logs:o}}})},L=async s=>{let r=t.mcp.servers.find(e=>e.id===s)??null;if(!r)return void y(t=>({...t,[s]:{status:"error",message:e("settings.tools.mcp.serverNotFound")}}));y(e=>({...e,[s]:{status:"running",message:void 0,tools:void 0,logs:[]}})),S(e=>({...e,[s]:!0}));let n=Date.now();try{let t=await fetch("/api/tools/mcp/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({server:r})});if(!t.ok){let s=await t.json().catch(()=>null),r="object"==typeof s&&null!==s&&"error"in s?String(s.error??""):"";throw Error(r||e("errors.requestFailedWithStatus",{status:t.status}))}let o=t.headers.get("content-type")??"";if(!t.body||!o.includes("text/event-stream"))throw Error(e("settings.tools.mcp.invalidTestResponse"));let a=t.body.getReader(),l=new TextDecoder("utf-8"),i="",d=!1,c=!1;for(;!d;){let t=await a.read();if(t.done)break;let r=(i+=l.decode(t.value,{stream:!0})).split(/\r?\n\r?\n/);for(let t of(i=r.pop()??"",r)){for(let r of t.split(/\r?\n/)){if(!r.startsWith("data:"))continue;let t=r.replace(/^data:\s*/,"");if(t){if("[DONE]"===t){d=!0;break}try{let r=JSON.parse(t);if("log"===r.type)z(s,r.text);else if("status"===r.type)y(e=>({...e,[s]:{...e[s]??{status:"running"},message:r.phase}}));else if("result"===r.type)c=!0,y(t=>({...t,[s]:{...t[s]??{status:"success"},status:"success",message:e("settings.tools.mcp.test.success",{count:r.tools.length}),latencyMs:r.latencyMs??Math.max(0,Date.now()-n),tools:r.tools,testedAt:Date.now()}})),v(e=>({...e,[s]:!0}));else if("error"===r.type)throw Error(r.message)}catch(r){let t=r instanceof Error?r.message:e("settings.tools.mcp.test.failed");z(s,t)}}}if(d)break}}if(!c)throw Error(e("settings.tools.mcp.test.noResult"))}catch(o){let t=Math.max(0,Date.now()-n),r=o instanceof Error?o.message:e("settings.tools.mcp.test.failed");y(e=>({...e,[s]:{...e[s]??{status:"error"},status:"error",message:r,latencyMs:t,tools:e[s]?.tools??[],testedAt:Date.now()}}))}},[_,U]=(0,a.useState)(!1),[P,T]=(0,a.useState)(null),[W,E]=(0,a.useState)(null),A=()=>{E(null),T({id:`mcp_${Date.now().toString(36)}`,name:e("settings.tools.mcp.newServerName"),transport:"http",token:"",configJson:JSON.stringify({url:"http://localhost:3000/mcp",protocolVersion:"2024-11-05"},null,2)}),U(!0)};return(0,r.jsxs)(k,{title:e("settings.tools.title"),description:e("settings.tools.description"),action:(0,r.jsx)("button",{type:"button",className:"rounded-lg bg-matcha-green px-4 py-2 text-sm text-shoji-white transition-all duration-200 hover:bg-matcha-green/90",onClick:A,children:e("settings.tools.mcp.add")}),children:[(0,r.jsxs)("div",{className:"space-y-10",children:[(0,r.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,r.jsx)("div",{className:"mb-5 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:e("settings.tools.search.title")}),(0,r.jsxs)("div",{className:"grid gap-5 md:grid-cols-2",children:[(0,r.jsxs)("label",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:e("settings.tools.search.defaultProvider")}),(0,r.jsxs)("select",{className:"w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-body text-[0.9rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:t.search.provider,onChange:e=>s({...t,search:{...t.search,provider:"exa"===e.target.value?"exa":"tavily"}}),children:[(0,r.jsx)("option",{value:"tavily",children:"Tavily"}),(0,r.jsx)("option",{value:"exa",children:"Exa"})]})]}),(0,r.jsxs)("label",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:e("settings.tools.search.searchDepth")}),(0,r.jsxs)("select",{className:"w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-body text-[0.9rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:t.search.searchDepth,onChange:e=>s({...t,search:{...t.search,searchDepth:"advanced"===e.target.value?"advanced":"basic"}}),children:[(0,r.jsx)("option",{value:"basic",children:e("settings.tools.search.depth.basic")}),(0,r.jsx)("option",{value:"advanced",children:e("settings.tools.search.depth.advanced")})]})]}),(0,r.jsxs)("label",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:e("settings.tools.search.maxResults")}),(0,r.jsx)("input",{type:"number",min:1,max:20,className:"w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-body text-[0.9rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:t.search.maxResults,onChange:e=>s({...t,search:{...t.search,maxResults:Math.max(1,Math.min(20,Number(e.target.value||0)))}})})]})]}),(0,r.jsxs)("div",{className:"mt-6 grid gap-5 md:grid-cols-2",children:[(0,r.jsxs)("label",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:"Tavily API Key"}),(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-2 rounded-lg border border-parchment/20 bg-shoji-white px-3 py-2 text-xs text-stone-gray transition-all duration-200 hover:border-matcha-green/40 hover:text-matcha-green",onClick:()=>c(e=>!e),children:[d?(0,r.jsx)(N.aR,{}):(0,r.jsx)(N.bM,{}),d?e("common.hide"):e("common.show")]})]}),(0,r.jsx)("input",{type:d?"text":"password",className:"w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-body text-[0.9rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:t.search.tavilyApiKey,onChange:e=>s({...t,search:{...t.search,tavilyApiKey:e.target.value}}),placeholder:"tvly-..."})]}),(0,r.jsxs)("label",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:"Exa API Key"}),(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-2 rounded-lg border border-parchment/20 bg-shoji-white px-3 py-2 text-xs text-stone-gray transition-all duration-200 hover:border-matcha-green/40 hover:text-matcha-green",onClick:()=>h(e=>!e),children:[x?(0,r.jsx)(N.aR,{}):(0,r.jsx)(N.bM,{}),x?e("common.hide"):e("common.show")]})]}),(0,r.jsx)("input",{type:x?"text":"password",className:"w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-body text-[0.9rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:t.search.exaApiKey,onChange:e=>s({...t,search:{...t.search,exaApiKey:e.target.value}}),placeholder:"exa_..."})]})]}),(0,r.jsxs)("div",{className:"mt-6 flex flex-wrap items-center justify-between gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:e("settings.tools.search.test.title")}),void 0!==p.latencyMs?(0,r.jsx)("div",{className:"mt-2 font-mono text-xs text-stone-gray",children:e("settings.tools.search.test.latency",{ms:p.latencyMs})}):null]}),(0,r.jsx)("button",{type:"button",className:`flex items-center gap-2 rounded-lg px-4 py-2.5 font-zen-body text-sm transition-all duration-300 ${"running"===p.status?"bg-washi-cream text-stone-gray cursor-wait":"bg-matcha-green/10 text-matcha-green hover:bg-matcha-green/20 font-light"}`,onClick:()=>void u(),disabled:"running"===p.status,children:"running"===p.status?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.fN,{}),e("settings.tools.search.test.running")]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.Sr,{}),e("settings.tools.search.test.button")]})})]}),p.message?(0,r.jsx)("p",{className:`mt-3 font-zen-body text-xs font-light ${b}`,children:p.message}):null]}),(0,r.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,r.jsxs)("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"MCP Servers"}),(0,r.jsx)("p",{className:"mt-2 font-zen-body text-sm text-stone-gray font-light",children:e("settings.tools.mcp.description")})]}),(0,r.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/30 bg-shoji-white px-4 py-2 text-sm text-stone-gray transition-all duration-200 hover:border-matcha-green/40 hover:text-matcha-green",onClick:A,children:e("common.new")})]}),0===t.mcp.servers.length?(0,r.jsx)(C,{title:e("settings.tools.mcp.empty.title"),description:e("settings.tools.mcp.empty.description")}):(0,r.jsx)("div",{className:"space-y-3",children:t.mcp.servers.map(s=>{let n,a,l,i;return(0,r.jsx)("div",{className:"rounded-2xl border border-parchment/20 bg-shoji-white px-6 py-4",children:(n=f[s.id]??{status:"idle"},a=j[s.id]??!1,l=M[s.id]??!1,i="success"===n.status?"text-matcha-green":"error"===n.status?"text-red-500":"running"===n.status?"text-kintsugi-gold":"text-stone-gray",(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:s.name}),(0,r.jsxs)("div",{className:"mt-1 font-mono text-[0.7rem] text-stone-gray",children:[s.id," \xb7 ",s.transport.toUpperCase()]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/20 bg-washi-cream px-3 py-2 text-xs text-stone-gray transition-all duration-200 hover:border-matcha-green/40 hover:text-matcha-green disabled:opacity-60",onClick:()=>void L(s.id),disabled:"running"===n.status,children:"running"===n.status?e("settings.tools.mcp.test.running"):e("settings.tools.mcp.test.button")}),(0,r.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/20 bg-washi-cream px-3 py-2 text-xs text-stone-gray transition-all duration-200 hover:border-matcha-green/40 hover:text-matcha-green",onClick:()=>{var e;let r;return e=s.id,void((r=t.mcp.servers.find(t=>t.id===e))&&(E(null),T({id:r.id,name:r.name,transport:r.transport,token:r.token,configJson:r.configJson}),U(!0)))},children:e("common.edit")}),(0,r.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/20 bg-washi-cream px-3 py-2 text-xs text-stone-gray transition-all duration-200 hover:border-red-300 hover:text-red-500",onClick:()=>o(s.id),children:e("common.delete")})]})]}),"idle"!==n.status?(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsxs)("div",{className:`font-mono text-[0.75rem] ${i}`,children:[n.message??("running"===n.status?e("settings.tools.mcp.test.running"):""),"number"==typeof n.latencyMs?(0,r.jsxs)("span",{className:"ml-2 text-stone-gray",children:[n.latencyMs,"ms"]}):null]}),n.logs&&n.logs.length>0?(0,r.jsxs)("div",{className:"mt-2 rounded-xl border border-parchment/20 bg-washi-cream/60 px-4 py-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("div",{className:"font-mono text-[0.65rem] uppercase tracking-[0.12em] text-stone-gray",children:e("settings.tools.mcp.logs")}),(0,r.jsxs)("button",{type:"button",className:"rounded-lg border border-parchment/30 bg-shoji-white px-3 py-1.5 text-xs text-stone-gray transition-all duration-200 hover:border-matcha-green/40 hover:text-matcha-green",onClick:()=>S(e=>({...e,[s.id]:!l})),children:[l?e("settings.tools.mcp.collapse"):e("settings.tools.mcp.expand")," (",n.logs.length,")"]})]}),l?(0,r.jsx)("pre",{className:"mt-3 max-h-[260px] overflow-auto rounded-lg bg-shoji-white px-3 py-2 font-mono text-[0.7rem] text-ink-black",children:n.logs.join("\n")}):null]}):null,"success"===n.status&&n.tools&&(0,r.jsxs)("div",{className:"mt-2 rounded-xl border border-parchment/20 bg-washi-cream/60 px-4 py-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("div",{className:"font-mono text-[0.65rem] uppercase tracking-[0.12em] text-stone-gray",children:e("settings.tools.mcp.tools")}),(0,r.jsxs)("button",{type:"button",className:"rounded-lg border border-parchment/30 bg-shoji-white px-3 py-1.5 text-xs text-stone-gray transition-all duration-200 hover:border-matcha-green/40 hover:text-matcha-green",onClick:()=>v(e=>({...e,[s.id]:!a})),children:[a?e("settings.tools.mcp.collapse"):e("settings.tools.mcp.expand")," (",n.tools.length,")"]})]}),a?(0,r.jsx)("div",{className:"mt-3 max-h-[260px] space-y-2 overflow-auto pr-1",children:0===n.tools.length?(0,r.jsx)("div",{className:"rounded-lg bg-shoji-white px-3 py-2 text-xs text-stone-gray",children:e("settings.tools.mcp.noTools")}):n.tools.map(e=>(0,r.jsxs)("div",{className:"rounded-lg bg-shoji-white px-3 py-2",children:[(0,r.jsx)("div",{className:"font-mono text-[0.75rem] text-ink-black",children:e.name}),e.description?(0,r.jsx)("div",{className:"mt-1 text-xs text-stone-gray",children:e.description}):null]},e.name))}):null]})]}):null]}))},s.id)})})]}),(0,r.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,r.jsx)("div",{className:"mb-5 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:e("settings.tools.python.title")}),(0,r.jsxs)("div",{className:"grid gap-5 md:grid-cols-2",children:[(0,r.jsxs)("label",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:e("settings.tools.python.timeoutSeconds")}),(0,r.jsx)("input",{type:"number",min:1,max:120,className:"w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-body text-[0.9rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:Math.round(t.python.timeoutMs/1e3),onChange:e=>{let r=Math.max(1,Math.min(120,Number(e.target.value||0)));s({...t,python:{...t.python,timeoutMs:1e3*r}})}})]}),(0,r.jsxs)("label",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:e("settings.tools.python.maxOutputChars")}),(0,r.jsx)("input",{type:"number",min:1e3,max:2e5,className:"w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-body text-[0.9rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:t.python.maxOutputChars,onChange:e=>{let r=Math.max(1e3,Math.min(2e5,Number(e.target.value||0)));s({...t,python:{...t.python,maxOutputChars:r}})}})]}),(0,r.jsxs)("label",{className:"space-y-2 md:col-span-2",children:[(0,r.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:e("settings.tools.python.command")}),(0,r.jsx)("input",{className:"w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-body text-[0.9rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:t.python.pythonCommand,onChange:e=>s({...t,python:{...t.python,pythonCommand:e.target.value}}),placeholder:"python3"}),(0,r.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:e("settings.tools.python.note")})]})]})]})]}),(0,r.jsx)(m.a,{open:_,title:P?e("settings.tools.mcp.modal.titleWithName",{name:P.name}):e("settings.tools.mcp.modal.title"),onClose:()=>U(!1),children:P?(0,r.jsxs)("div",{className:"space-y-4",children:[W?(0,r.jsx)("div",{className:"rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:W}):null,(0,r.jsxs)("label",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs text-sand",children:e("settings.tools.mcp.editor.serverId")}),(0,r.jsx)("input",{className:"w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-mono text-[0.85rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:P.id,onChange:e=>T({...P,id:e.target.value})})]}),(0,r.jsxs)("label",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs text-sand",children:e("settings.tools.mcp.editor.name")}),(0,r.jsx)("input",{className:"w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-body text-[0.9rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:P.name,onChange:e=>T({...P,name:e.target.value})})]}),(0,r.jsxs)("label",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs text-sand",children:e("settings.tools.mcp.editor.transport")}),(0,r.jsxs)("select",{className:"w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-body text-[0.9rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:P.transport,onChange:e=>{let t="stdio"===e.target.value?"stdio":"sse"===e.target.value?"sse":"http",s="http"===t?JSON.stringify({url:"http://localhost:3000/mcp",protocolVersion:"2024-11-05"},null,2):"sse"===t?JSON.stringify({sseUrl:"http://localhost:3000/mcp",messagesUrl:"http://localhost:3000/messages",protocolVersion:"2024-11-05"},null,2):JSON.stringify({command:"node",args:["server.js"],protocolVersion:"2024-11-05",stdioFraming:"content-length"},null,2);T({...P,transport:t,configJson:P.configJson.trim()?P.configJson:s})},children:[(0,r.jsx)("option",{value:"http",children:"streamable http"}),(0,r.jsx)("option",{value:"sse",children:"legacy sse"}),(0,r.jsx)("option",{value:"stdio",children:"stdio"})]})]}),(0,r.jsxs)("label",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs text-sand",children:e("settings.tools.mcp.editor.token")}),(0,r.jsx)("input",{type:"password",className:"w-full rounded-xl border border-parchment bg-paper px-4 py-3 font-mono text-[0.85rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:P.token,onChange:e=>T({...P,token:e.target.value}),placeholder:e("settings.tools.mcp.editor.tokenPlaceholder")})]}),(0,r.jsxs)("label",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs text-sand",children:e("settings.tools.mcp.editor.configJson")}),(0,r.jsx)("textarea",{className:"h-[220px] w-full resize-none rounded-xl border border-parchment bg-paper px-4 py-3 font-mono text-[0.8rem] text-ink outline-none transition-all duration-200 focus:border-copper focus:shadow-[0_0_0_3px_var(--copper-glow)]",value:P.configJson,onChange:e=>T({...P,configJson:e.target.value}),spellCheck:!1}),(0,r.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:e("settings.tools.mcp.editor.configNote")})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/30 bg-shoji-white px-4 py-2 text-sm text-stone-gray",onClick:()=>U(!1),children:e("common.cancel")}),(0,r.jsx)("button",{type:"button",className:"rounded-lg bg-matcha-green px-4 py-2 text-sm text-shoji-white",onClick:()=>{if(!P)return;let t=P.id.trim(),s=P.name.trim();t?s?(n({id:t,name:s,transport:P.transport,token:P.token,configJson:P.configJson}),U(!1)):E(e("settings.tools.mcp.editor.nameRequired")):E(e("settings.tools.mcp.editor.idRequired"))},children:e("common.save")})]})]}):null})]})}function P(){let e=(0,i.k)();return(0,r.jsxs)(o(),{href:"/",className:"fixed bottom-8 left-8 z-50 flex items-center gap-3 rounded-2xl border border-parchment/30 bg-shoji-white/95 backdrop-blur-sm px-5 py-3 font-zen-body text-sm text-stone-gray shadow-lg transition-all duration-200 hover:border-matcha-green/50 hover:text-matcha-green hover:shadow-xl",children:[(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),e("settings.backToHome")]})}function T(){let e=(0,l.CU)(e=>e.providers),t=(0,l.CU)(e=>e.selectedProviderId),s=(0,l.CU)(e=>e.loadProviders),n=(0,a.useRef)(null),[o,i]=(0,a.useState)("providers");(0,a.useEffect)(()=>{s()},[s]),(0,a.useEffect)(()=>{!t&&e.length>0&&l.jL.getState().selectProvider(e[0].id)},[t,e]);let m=()=>"providers"===o?(0,r.jsx)(c.ProviderConfig,{}):"models"===o?(0,r.jsx)(M,{}):"general"===o?(0,r.jsx)(S,{}):"display"===o?(0,r.jsx)(z,{}):"tools"===o?(0,r.jsx)(U,{}):"data"===o?(0,r.jsx)(L,{}):"about"===o?(0,r.jsx)(_,{}):(0,r.jsx)(c.ProviderConfig,{}),p="providers"===o||"models"===o;return(0,r.jsxs)("div",{ref:n,className:"fixed inset-0 z-[100] flex bg-shoji-white",style:{height:"100vh",maxHeight:"100vh"},children:[(0,r.jsx)(x.SettingsSidebar,{activeId:o,onSelect:i}),p?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.ProviderList,{}),m(),(0,r.jsx)(h.ConnectedModelSelector,{})]}):m(),(0,r.jsx)(P,{})]})}},6222:(e,t,s)=>{"use strict";s.d(t,{GQ:()=>o,PX:()=>c,RY:()=>b,Sr:()=>g,Td:()=>f,US:()=>u,WI:()=>m,aR:()=>v,bM:()=>j,bN:()=>i,c1:()=>x,fN:()=>p,hp:()=>n,mo:()=>d,qY:()=>y,uc:()=>h,v1:()=>a,yo:()=>l});var r=s(5155);function n(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M17.5 19c0-1.7-1.3-3-3-3h-11c-1.7 0-3 1.3-3 3s1.3 3 3 3h11c1.7 0 3-1.3 3-3z"}),(0,r.jsx)("path",{d:"M19 16c2.8 0 5-2.2 5-5s-2.2-5-5-5c-.5 0-1 .1-1.4.2"}),(0,r.jsx)("path",{d:"M6.5 6C8.4 3.7 11.5 2.5 14.5 3c2.3.4 4.3 1.9 5.5 4"})]})}function o(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,r.jsx)("path",{d:"M9 9h6v6H9z"}),(0,r.jsx)("path",{d:"M9 1v3"}),(0,r.jsx)("path",{d:"M15 1v3"}),(0,r.jsx)("path",{d:"M9 20v3"}),(0,r.jsx)("path",{d:"M15 20v3"}),(0,r.jsx)("path",{d:"M20 9h3"}),(0,r.jsx)("path",{d:"M20 15h3"}),(0,r.jsx)("path",{d:"M1 9h3"}),(0,r.jsx)("path",{d:"M1 15h3"})]})}function a(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"13.5",cy:"6.5",r:"0.5",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"17.5",cy:"10.5",r:"0.5",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"8.5",cy:"7.5",r:"0.5",fill:"currentColor"}),(0,r.jsx)("circle",{cx:"6.5",cy:"12.5",r:"0.5",fill:"currentColor"}),(0,r.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z"})]})}function l(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),(0,r.jsx)("path",{d:"M8 21h8"}),(0,r.jsx)("path",{d:"M12 17v4"})]})}function i(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),(0,r.jsx)("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),(0,r.jsx)("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function d(){return(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"M12 16v-4"}),(0,r.jsx)("path",{d:"M12 8h.01"})]})}function c(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M14.7 6.3a4 4 0 0 1-5.65 5.65L3 18v3h3l6.05-6.05a4 4 0 0 1 5.65-5.65l-2.1 2.1 1.4 1.4 2.1-2.1Z"})})}function x(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M12 5v14M5 12h14"})})}function h(){return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M3 6h18M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})})}function m(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("path",{d:"m21 21-4.35-4.35"})]})}function p(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,r.jsx)("path",{d:"M3 3v5h5"}),(0,r.jsx)("path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"}),(0,r.jsx)("path",{d:"M16 16h5v5"})]})}function g(){return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})})}function u(){return(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M18 6 6 18M6 6l12 12"})})}function b(){return(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})})}function f(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})}function y(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),(0,r.jsx)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function j(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}function v(){return(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}),(0,r.jsx)("path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"}),(0,r.jsx)("path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"}),(0,r.jsx)("line",{x1:"2",x2:"22",y1:"2",y2:"22"})]})}},6531:(e,t,s)=>{"use strict";s.d(t,{ProviderList:()=>h});var r=s(5155),n=s(2115),o=s(4394),a=s(513),l=s(6222);function i({name:e}){let t=e.trim().charAt(0).toUpperCase(),s=["bg-matcha-green","bg-kintsugi-gold","bg-stone-gray"],n=e.charCodeAt(0)%s.length,o=s[n];return(0,r.jsx)("div",{className:`flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg ${o} text-shoji-white text-lg font-medium shadow-sm`,children:t})}function d({enabled:e,onToggle:t}){return(0,r.jsx)("button",{type:"button",className:`relative flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-all duration-300 ${e?"bg-matcha-green":"bg-stone-gray/30"}`,onClick:e=>{e.stopPropagation(),t()},"aria-pressed":e,children:(0,r.jsx)("span",{className:`block h-4.5 w-4.5 transform rounded-full bg-white shadow-sm transition-all duration-300 ${e?"translate-x-6":"translate-x-0.5"}`})})}function c({provider:e,isActive:t,onSelect:s,onToggle:n,onDelete:o}){let c=(0,a.k)();return(0,r.jsx)("div",{className:`group relative mb-2 cursor-pointer rounded-xl p-4 transition-all duration-300 ${t?"bg-washi-cream/70 border border-matcha-green/20 shadow-sm":"hover:bg-washi-cream/30 border border-transparent"}`,onClick:s,role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&s(),children:(0,r.jsxs)("div",{className:"flex w-full items-center gap-4 text-left",children:[(0,r.jsx)(i,{name:e.name}),(0,r.jsx)("span",{className:"flex-1 truncate font-zen-body text-sm font-normal text-ink-black",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(d,{enabled:e.enabled,onToggle:n}),(0,r.jsx)("button",{type:"button",className:"flex-shrink-0 rounded-lg p-2 text-stone-gray opacity-0 transition-all duration-200 hover:bg-sakura-pink/30 hover:text-red-500 group-hover:opacity-100 group-hover:pointer-events-auto pointer-events-none",onClick:e=>{e.stopPropagation(),o()},"aria-label":c("providers.deleteAria"),children:(0,r.jsx)(l.uc,{})})]})]})})}function x({open:e,onClose:t,onAdd:s}){let o=(0,a.k)(),[l,i]=(0,n.useState)("");return e?(0,r.jsx)("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-ink-black/20 backdrop-blur-sm",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-2xl bg-shoji-white p-8 shadow-lg border border-parchment/10",children:[(0,r.jsx)("h3",{className:"mb-6 font-zen-display text-2xl font-light text-ink-black tracking-wide",children:o("providers.dialog.title")}),(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault();let r=l.trim();r&&(s(r),i(""),t())},children:[(0,r.jsxs)("div",{className:"mb-6",children:[(0,r.jsx)("label",{className:"mb-3 block font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:o("providers.dialog.nameLabel")}),(0,r.jsx)("input",{type:"text",value:l,onChange:e=>i(e.target.value),placeholder:o("providers.dialog.namePlaceholder"),className:"w-full rounded-xl border border-parchment/20 bg-washi-cream px-5 py-4 font-zen-body text-sm text-ink-black outline-none transition-all duration-300 focus:border-matcha-green/50 focus:shadow-sm",autoFocus:!0})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,r.jsx)("button",{type:"button",className:"rounded-xl border border-parchment/20 px-6 py-3 font-zen-body text-sm text-stone-gray transition-all duration-200 hover:border-stone-gray/30 hover:text-ink-black",onClick:t,children:o("common.cancel")}),(0,r.jsx)("button",{type:"submit",className:"rounded-xl bg-matcha-green px-6 py-3 font-zen-body text-sm text-shoji-white transition-all duration-200 hover:bg-bamboo-light",children:o("common.add")})]})]})]})}):null}function h(){let e=(0,a.k)(),t=(0,o.CU)(e=>e.providers),s=(0,o.CU)(e=>e.selectedProviderId),i=(0,o.CU)(e=>e.selectProvider),d=(0,o.CU)(e=>e.toggleProviderEnabled),h=(0,o.CU)(e=>e.deleteProvider),m=(0,o.CU)(e=>e.addProvider),[p,g]=(0,n.useState)(!1),[u,b]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{b(!0)},[]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex h-full w-[320px] flex-shrink-0 flex-col border-r border-parchment/10 bg-washi-cream/50",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-parchment/10 px-6 py-6",children:[(0,r.jsx)("div",{className:"font-zen-display text-xl font-normal text-ink-black tracking-wide",children:e("providers.title")}),(0,r.jsx)("div",{className:"flex h-7 min-h-7 w-7 min-w-7 items-center justify-center rounded-full bg-washi-cream font-zen-body text-xs text-stone-gray font-light",children:u?t.length:"-"})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-6",children:0===t.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,r.jsx)("div",{className:"mb-4 rounded-2xl bg-washi-cream/50 p-6 text-stone-gray",children:(0,r.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",className:"mx-auto",children:[(0,r.jsx)("path",{d:"M17.5 19c0-1.7-1.3-3-3-3h-11c-1.7 0-3 1.3-3 3s1.3 3 3 3h11c1.7 0 3-1.3 3-3z"}),(0,r.jsx)("path",{d:"M19 16c2.8 0 5-2.2 5-5s-2.2-5-5-5c-.5 0-1 .1-1.4.2"}),(0,r.jsx)("path",{d:"M6.5 6C8.4 3.7 11.5 2.5 14.5 3c2.3.4 4.3 1.9 5.5 4"})]})}),(0,r.jsx)("p",{className:"mb-2 font-zen-body text-sm text-stone-gray font-light",children:e("providers.empty.title")}),(0,r.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:e("providers.empty.description")})]}):t.map((e,t)=>(0,r.jsx)("div",{style:{animation:`slideInUp 0.5s ease-out ${.05*t}s backwards`},children:(0,r.jsx)(c,{provider:e,isActive:s===e.id,onSelect:()=>i(e.id),onToggle:()=>d(e.id),onDelete:()=>h(e.id)})},e.id))}),(0,r.jsx)("div",{className:"border-t border-parchment/10 p-5",children:(0,r.jsxs)("button",{type:"button",className:"flex w-full items-center justify-center gap-2 rounded-xl border-1.5 border-dashed border-parchment/30 px-5 py-4 font-zen-body text-sm text-stone-gray font-light transition-all duration-300 hover:border-matcha-green/50 hover:bg-matcha-green/5 hover:text-matcha-green",onClick:()=>g(!0),children:[(0,r.jsx)(l.c1,{}),e("providers.add")]})})]}),(0,r.jsx)(x,{open:p,onClose:()=>g(!1),onAdd:e=>m(e)})]})}},7977:(e,t,s)=>{"use strict";s.d(t,{SettingsSidebar:()=>i});var r=s(5155),n=s(513),o=s(6222);let a=[{id:"providers",labelKey:"settings.nav.providers",icon:(0,r.jsx)(o.hp,{})},{id:"models",labelKey:"settings.nav.defaultModel",icon:(0,r.jsx)(o.GQ,{})},{id:"tools",labelKey:"settings.nav.tools",icon:(0,r.jsx)(o.PX,{})},{id:"general",labelKey:"settings.nav.general",icon:(0,r.jsx)(o.yo,{})},{id:"display",labelKey:"settings.nav.display",icon:(0,r.jsx)(o.v1,{})}],l=[{id:"data",labelKey:"settings.nav.data",icon:(0,r.jsx)(o.bN,{})},{id:"about",labelKey:"settings.nav.about",icon:(0,r.jsx)(o.mo,{})}];function i({activeId:e,onSelect:t}){let s=(0,n.k)(),o=[{label:s("settings.nav.configuration"),items:a},{label:s("settings.nav.data"),items:l}];return(0,r.jsxs)("nav",{className:"flex h-full w-[240px] flex-shrink-0 flex-col border-r border-parchment/10 bg-shoji-white",children:[(0,r.jsxs)("div",{className:"border-b border-parchment/10 px-8 py-12",children:[(0,r.jsx)("div",{className:"font-zen-display text-2xl font-light tracking-[0.15em] text-ink-black",children:s("common.settings")}),(0,r.jsx)("div",{className:"mt-1 font-zen-body text-[0.6rem] tracking-[0.2em] text-stone-gray font-light uppercase",children:s("common.appName")})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-8",children:o.map((n,o)=>(0,r.jsxs)("div",{className:0===o?"mb-8":"",children:[(0,r.jsx)("div",{className:"mb-5 px-3 font-zen-body text-[0.65rem] tracking-[0.25em] text-stone-gray uppercase font-light",children:n.label}),(0,r.jsx)("div",{className:"space-y-1",children:n.items.map((n,o)=>(0,r.jsxs)("button",{className:`group relative flex w-full items-center gap-3 rounded-lg px-5 py-3 font-zen-body text-sm font-light transition-all duration-300 ${e===n.id?"bg-washi-cream text-matcha-green border border-matcha-green/15 shadow-sm":"text-stone-gray hover:bg-washi-cream/50 hover:text-ink-black"}`,style:{animation:`fadeIn 0.8s ease-out ${.05*o}s backwards`},onClick:()=>t(n.id),children:[(0,r.jsx)("div",{className:`absolute left-0 top-0 h-full w-0.5 bg-matcha-green transition-transform duration-300 ${e===n.id?"scale-y-100":"scale-y-0"}`}),(0,r.jsx)("span",{className:"flex-shrink-0 text-base opacity-70 group-hover:opacity-100 transition-opacity",children:n.icon}),(0,r.jsx)("span",{className:"font-light tracking-wide",children:s(n.labelKey)})]},n.id))})]},n.label))}),(0,r.jsx)("div",{className:"border-t border-parchment/10 px-8 py-7",children:(0,r.jsxs)("div",{className:"font-zen-display text-sm text-stone-gray font-light tracking-[0.1em]",children:[s("common.appName")," v0.4.0"]})})]})}},9362:(e,t,s)=>{"use strict";s.d(t,{ProviderConfig:()=>m});var r=s(5155),n=s(2115),o=s(4394),a=s(513),l=s(5746),i=s(6222);function d({apiKey:e,onUpdate:t,onDelete:s,onSetPrimary:o,isPrimary:l}){let d=(0,a.k)(),[c,x]=(0,n.useState)(!1),h=async()=>{try{await navigator.clipboard.writeText(e.value)}catch{}},m={healthy:"text-matcha-green",error:"text-red-500",checking:"text-kintsugi-gold",unknown:"text-stone-gray"}[e.healthStatus||"unknown"];return(0,r.jsxs)("div",{className:"group relative rounded-xl border border-parchment/10 bg-washi-cream p-5 transition-all duration-300 hover:border-matcha-green/20 hover:shadow-sm",children:[(0,r.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"text",value:e.name||"",onChange:e=>t({name:e.target.value}),placeholder:d("providerConfig.apiKeys.namePlaceholder"),className:"w-32 bg-transparent font-zen-body text-sm font-normal text-ink-black outline-none placeholder:text-stone-gray/50"}),l&&(0,r.jsx)("span",{className:"rounded-lg bg-kintsugi-gold/10 px-2 py-1 font-zen-body text-xs text-kintsugi-gold font-light",children:d("providerConfig.apiKeys.primary")})]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)("span",{className:`flex-shrink-0 ${m}`,children:"healthy"===e.healthStatus?(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"})}):"error"===e.healthStatus?(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"m15 9-6 6m0-6 6 6"})]}):(0,r.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"M12 6v6l4 2"})]})})})]}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)("input",{type:c?"text":"password",value:e.value,onChange:e=>t({value:e.target.value}),placeholder:"sk-...",className:"w-full rounded-lg border border-parchment/20 bg-shoji-white px-4 py-3 pr-10 font-mono text-sm text-ink-black outline-none transition-all duration-300 focus:border-matcha-green/50"}),(0,r.jsx)("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-stone-gray transition-colors hover:text-ink-black",onClick:()=>x(!c),children:c?(0,r.jsx)(i.aR,{}):(0,r.jsx)(i.bM,{})})]})}),(0,r.jsxs)("div",{className:"mt-3 flex items-center justify-between",children:[(0,r.jsx)("div",{className:"flex items-center gap-1",children:!l&&(0,r.jsx)("button",{type:"button",className:"rounded-lg px-3 py-1.5 font-zen-body text-xs text-stone-gray font-light transition-colors hover:text-matcha-green",onClick:o,children:d("providerConfig.apiKeys.setPrimary")})}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",className:"rounded-lg p-2 text-stone-gray transition-colors hover:text-ink-black",onClick:h,title:d("common.copy"),children:(0,r.jsx)(i.Td,{})}),(0,r.jsx)("button",{type:"button",className:"rounded-lg p-2 text-stone-gray transition-colors hover:text-red-500",onClick:s,title:d("common.delete"),children:(0,r.jsx)(i.uc,{})})]})]})]})}function c({model:e,onRemove:t,onToggleEnabled:s,onToggleStreaming:n}){let o=(0,a.k)(),l=e.supportsStreaming??!1;return(0,r.jsxs)("div",{className:"group flex items-center gap-3 rounded-lg border border-parchment/10 bg-washi-cream px-4 py-3 transition-all duration-300 hover:border-matcha-green/20",children:[(0,r.jsx)("button",{type:"button",className:`flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-lg border transition-all duration-300 ${e.enabled?"border-matcha-green bg-matcha-green text-shoji-white":"border-stone-gray/30 bg-transparent text-transparent hover:border-stone-gray/50"}`,onClick:s,children:(0,r.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:(0,r.jsx)("path",{d:"M5 12l6 6 8-8"})})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"font-mono text-sm text-ink-black truncate font-light",children:e.id}),e.name!==e.id&&(0,r.jsx)("div",{className:"font-zen-body text-xs text-stone-gray truncate font-light",children:e.name})]}),(0,r.jsxs)("button",{type:"button",className:`flex items-center gap-1.5 rounded-full border px-3 py-1 text-[0.65rem] transition-all ${l?"border-copper/50 bg-copper/10 text-copper":"border-parchment/40 text-sand hover:border-copper/40 hover:text-ink"}`,onClick:n,children:[(0,r.jsx)("span",{className:`h-2 w-2 rounded-full border ${l?"border-copper bg-copper":"border-parchment/60 bg-transparent"}`}),o("providerConfig.models.streaming")]}),(0,r.jsx)("button",{type:"button",className:"flex-shrink-0 rounded-lg p-2 text-stone-gray opacity-0 transition-all hover:text-red-500 group-hover:opacity-100",onClick:t,children:(0,r.jsx)(i.uc,{})})]})}function x({icon:e,title:t,description:s}){return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center rounded-2xl border-1.5 border-dashed border-parchment/20 bg-washi-cream/50 p-10 text-center",children:[(0,r.jsx)("div",{className:"mb-4 rounded-xl bg-shoji-white p-4 text-stone-gray",children:(0,r.jsx)(e,{className:"h-8 w-8"})}),(0,r.jsx)("p",{className:"mb-2 font-zen-body text-sm text-stone-gray font-light",children:t}),(0,r.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:s})]})}function h({open:e,onClose:t,onAdd:s}){let o=(0,a.k)(),[l,i]=(0,n.useState)(""),[d,c]=(0,n.useState)("");return((0,n.useEffect)(()=>{e||(i(""),c(""))},[e]),e)?(0,r.jsx)("div",{className:"fixed inset-0 z-[220] flex items-center justify-center bg-ink-black/20 backdrop-blur-sm",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-2xl bg-shoji-white p-8 shadow-lg border border-parchment/10",children:[(0,r.jsx)("h3",{className:"mb-6 font-zen-display text-2xl font-light text-ink-black tracking-wide",children:o("providerConfig.addKey.title")}),(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault();let r=d.trim(),n=l.trim();r&&(s(r,n||void 0),t())},children:[(0,r.jsxs)("div",{className:"mb-5",children:[(0,r.jsx)("label",{className:"mb-2 block font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:o("providerConfig.addKey.nameLabel")}),(0,r.jsx)("input",{type:"text",value:l,onChange:e=>i(e.target.value),placeholder:o("providerConfig.addKey.namePlaceholder"),className:"w-full rounded-xl border border-parchment/20 bg-washi-cream px-5 py-4 font-zen-body text-sm text-ink-black outline-none transition-all duration-300 focus:border-matcha-green/50"})]}),(0,r.jsxs)("div",{className:"mb-6",children:[(0,r.jsx)("label",{className:"mb-2 block font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:o("providerConfig.addKey.valueLabel")}),(0,r.jsx)("input",{type:"password",value:d,onChange:e=>c(e.target.value),placeholder:"sk-...",className:"w-full rounded-xl border border-parchment/20 bg-washi-cream px-5 py-4 font-mono text-sm text-ink-black outline-none transition-all duration-300 focus:border-matcha-green/50",autoFocus:!0})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,r.jsx)("button",{type:"button",className:"rounded-xl border border-parchment/20 px-6 py-3 font-zen-body text-sm text-stone-gray transition-all duration-200 hover:border-stone-gray/30 hover:text-ink-black",onClick:t,children:o("common.cancel")}),(0,r.jsx)("button",{type:"submit",className:"rounded-xl bg-matcha-green px-6 py-3 font-zen-body text-sm text-shoji-white transition-all duration-200 hover:bg-bamboo-light",children:o("common.add")})]})]})]})}):null}function m(){let e=(0,a.k)(),t=(0,o.CU)(e=>e.providers),s=(0,o.CU)(e=>e.selectedProviderId),m=(0,o.CU)(e=>e.updateProvider),p=(0,o.CU)(e=>e.updateModel),g=(0,o.CU)(e=>e.addApiKey),u=(0,o.CU)(e=>e.updateApiKey),b=(0,o.CU)(e=>e.deleteApiKey),f=(0,o.CU)(e=>e.setPrimaryApiKey),y=(0,o.CU)(e=>e.removeModel),j=(0,o.CU)(e=>e.toggleModelEnabled),v=(0,o.CU)(e=>e.checkProviderHealth),N=(0,o.CU)(e=>e.openModelSelector),[w,k]=(0,n.useState)(""),[C,M]=(0,n.useState)(""),[S,z]=(0,n.useState)(!1),[L,_]=(0,n.useState)(!1),[U,P]=(0,n.useState)(null),T=t.find(e=>e.id===s)||null;(0,n.useEffect)(()=>{T?(k(T.name),M(T.baseUrl)):(k(""),M("")),P(null)},[s]);let W=async()=>{if(T){z(!0),P(null);try{await v(T.id)}catch(t){P(t instanceof Error?t.message:e("errors.connectionFailed"))}finally{z(!1)}}},E=T?.models.filter(e=>e.enabled)??[],A=T?.models.filter(e=>!e.enabled)??[];return T?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex h-full flex-1 flex-col bg-shoji-white",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-parchment/10 px-8 py-8",children:[(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)("div",{className:"flex h-12 w-12 items-center justify-center rounded-lg bg-matcha-green text-xl font-medium text-shoji-white shadow-sm",children:T.name.charAt(0).toUpperCase()}),(0,r.jsx)("input",{type:"text",value:w,onChange:e=>{var t;k(t=e.target.value),T&&m(T.id,{name:t})},className:"bg-transparent font-zen-display text-2xl font-light text-ink-black outline-none tracking-wide"})]}),(0,r.jsxs)("div",{className:"flex flex-col items-end gap-2",children:[(0,r.jsx)("button",{type:"button",className:`flex items-center gap-2.5 rounded-lg px-5 py-3 font-zen-body text-sm transition-all duration-300 ${S?"bg-washi-cream text-stone-gray cursor-wait":"bg-matcha-green/10 text-matcha-green hover:bg-matcha-green/20 font-light"}`,onClick:W,disabled:S,children:S?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.fN,{}),e("providerConfig.check.running")]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.fN,{}),e("providerConfig.check.button")]})}),U&&(0,r.jsx)("p",{className:"font-zen-body text-xs text-red-500 font-light",children:U})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,r.jsxs)("div",{className:"max-w-3xl px-8 py-8",children:[(0,r.jsxs)("section",{className:"mb-10",children:[(0,r.jsxs)("div",{className:"mb-5 flex items-center gap-3",children:[(0,r.jsx)("div",{className:"rounded-lg bg-washi-cream p-2.5 text-stone-gray",children:(0,r.jsx)(i.RY,{})}),(0,r.jsx)("h3",{className:"font-zen-display text-xl font-light text-ink-black tracking-wide",children:e("providerConfig.apiKeys.title")})]}),(0,r.jsx)("div",{className:"space-y-3",children:T.apiKeys.map(e=>(0,r.jsx)(d,{apiKey:e,onUpdate:t=>u(T.id,e.id,t),onDelete:()=>b(T.id,e.id),onSetPrimary:()=>f(T.id,e.id),isPrimary:e.isPrimary||1===T.apiKeys.length},e.id))}),(0,r.jsxs)("button",{type:"button",className:"mt-4 flex w-full items-center justify-center gap-2.5 rounded-xl border-1.5 border-dashed border-parchment/30 bg-washi-cream/50 px-5 py-4 font-zen-body text-sm text-stone-gray transition-all duration-300 hover:border-matcha-green/50 hover:bg-matcha-green/5 hover:text-matcha-green font-light",onClick:()=>{T&&_(!0)},children:[(0,r.jsx)(i.c1,{}),e("providerConfig.apiKeys.add")]})]}),(0,r.jsxs)("section",{className:"mb-10",children:[(0,r.jsxs)("div",{className:"mb-5 flex items-center gap-3",children:[(0,r.jsx)("div",{className:"rounded-lg bg-washi-cream p-2.5 text-stone-gray",children:(0,r.jsx)(i.qY,{})}),(0,r.jsx)("h3",{className:"font-zen-display text-xl font-light text-ink-black tracking-wide",children:e("providerConfig.baseUrl.title")})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("input",{type:"text",value:C,onChange:e=>{var t;M(t=e.target.value),T&&m(T.id,{baseUrl:(0,l.qT)(t)})},placeholder:"https://api.openai.com/v1",className:"w-full rounded-xl border border-parchment/20 bg-washi-cream px-5 py-4 font-mono text-sm text-ink-black outline-none transition-all duration-300 focus:border-matcha-green/50"}),(0,r.jsx)("p",{className:"mt-3 font-zen-body text-xs text-stone-gray font-light",children:e("providerConfig.baseUrl.preview",{url:`${(0,l.qT)(C)}/chat/completions`})})]})]}),(0,r.jsxs)("section",{children:[(0,r.jsxs)("div",{className:"mb-5 flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"rounded-lg bg-washi-cream p-2.5 text-stone-gray",children:(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,r.jsx)("path",{d:"M9 9h6v6H9z"})]})}),(0,r.jsx)("h3",{className:"font-zen-display text-xl font-light text-ink-black tracking-wide",children:e("providerConfig.models.title")}),(0,r.jsx)("span",{className:"rounded-full bg-washi-cream px-3 py-1 font-mono text-xs text-stone-gray font-light",children:T.models.length})]}),(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-2 rounded-lg border border-parchment/20 bg-washi-cream px-4 py-2.5 font-zen-body text-sm text-stone-gray transition-all duration-300 hover:border-matcha-green/50 hover:text-matcha-green font-light",onClick:()=>N(T.id),children:[(0,r.jsx)(i.WI,{}),e("providerConfig.models.select")]})]}),0===T.models.length?(0,r.jsx)(x,{icon:e=>(0,r.jsxs)("svg",{...e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,r.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,r.jsx)("path",{d:"M9 9h6v6H9z"})]}),title:e("providerConfig.models.empty.title"),description:e("providerConfig.models.empty.description")}):(0,r.jsxs)("div",{className:"space-y-6",children:[E.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-3 font-mono text-xs text-stone-gray font-light",children:e("providerConfig.models.enabled",{count:E.length})}),(0,r.jsx)("div",{className:"space-y-2",children:E.map(e=>(0,r.jsx)(c,{model:e,onRemove:()=>y(T.id,e.id),onToggleEnabled:()=>j(T.id,e.id),onToggleStreaming:()=>p(T.id,e.id,{supportsStreaming:!e.supportsStreaming})},e.id))})]}),A.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-3 font-mono text-xs text-stone-gray font-light",children:e("providerConfig.models.disabled",{count:A.length})}),(0,r.jsx)("div",{className:"space-y-2",children:A.map(e=>(0,r.jsx)(c,{model:e,onRemove:()=>y(T.id,e.id),onToggleEnabled:()=>j(T.id,e.id),onToggleStreaming:()=>p(T.id,e.id,{supportsStreaming:!e.supportsStreaming})},e.id))})]})]})]})]})})]}),(0,r.jsx)(h,{open:L,onClose:()=>_(!1),onAdd:(e,t)=>{T&&g(T.id,e,t)}})]}):(0,r.jsx)("div",{className:"flex h-full flex-1 items-center justify-center bg-shoji-white",children:(0,r.jsx)(x,{icon:e=>(0,r.jsxs)("svg",{...e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,r.jsx)("path",{d:"M17.5 19c0-1.7-1.3-3-3-3h-11c-1.7 0-3 1.3-3 3s1.3 3 3 3h11c1.7 0 3-1.3 3-3z"}),(0,r.jsx)("path",{d:"M19 16c2.8 0 5-2.2 5-5s-2.2-5-5-5c-.5 0-1 .1-1.4.2"}),(0,r.jsx)("path",{d:"M6.5 6C8.4 3.7 11.5 2.5 14.5 3c2.3.4 4.3 1.9 5.5 4"})]}),title:e("providerConfig.empty.title"),description:e("providerConfig.empty.description")})})}}},e=>{e.O(0,[307,394,787,441,794,358],()=>e(e.s=3409)),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46,164,167,233,276,429,669,703,777,779,819,851,895,896,988],{4441:()=>{}},_=>{_.O(0,[441,794,358],()=>_(_.s=4441)),_N_E=_.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{"use strict";var e,t,r,o,n,a,i,u,l={},c={};function s(e){var t=c[e];if(void 0!==t)return t.exports;var r=c[e]={exports:{}},o=!0;try{l[e].call(r.exports,r,r.exports,s),o=!1}finally{o&&delete c[e]}return r.exports}s.m=l,e=[],s.O=(t,r,o,n)=>{if(r){n=n||0;for(var a=e.length;a>0&&e[a-1][2]>n;a--)e[a]=e[a-1];e[a]=[r,o,n];return}for(var i=1/0,a=0;a<e.length;a++){for(var[r,o,n]=e[a],u=!0,l=0;l<r.length;l++)(!1&n||i>=n)&&Object.keys(s.O).every(e=>s.O[e](r[l]))?r.splice(l--,1):(u=!1,n<i&&(i=n));if(u){e.splice(a--,1);var c=o();void 0!==c&&(t=c)}}return t},s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(e,o){if(1&o&&(e=this(e)),8&o||"object"==typeof e&&e&&(4&o&&e.__esModule||16&o&&"function"==typeof e.then))return e;var n=Object.create(null);s.r(n);var a={};t=t||[null,r({}),r([]),r(r)];for(var i=2&o&&e;"object"==typeof i&&!~t.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach(t=>a[t]=()=>e[t]);return a.default=()=>e,s.d(n,a),n},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce((t,r)=>(s.f[r](e,t),t),[])),s.u=e=>"static/chunks/"+(84===e?"9b0008ae":e)+"."+({84:"ebbbe0264e8b748d",619:"cfe242be4c0b83c0"})[e]+".js",s.miniCssF=e=>{},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o={},s.l=(e,t,r,n)=>{if(o[e])return void o[e].push(t);if(void 0!==r)for(var a,i,u=document.getElementsByTagName("script"),l=0;l<u.length;l++){var c=u[l];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")=="_N_E:"+r){a=c;break}}a||(i=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack","_N_E:"+r),a.src=s.tu(e)),o[e]=[t];var f=(t,r)=>{a.onerror=a.onload=null,clearTimeout(d);var n=o[e];if(delete o[e],a.parentNode&&a.parentNode.removeChild(a),n&&n.forEach(e=>e(r)),t)return t(r)},d=setTimeout(f.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=f.bind(null,a.onerror),a.onload=f.bind(null,a.onload),i&&document.head.appendChild(a)},s.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.tt=()=>(void 0===n&&(n={createScriptURL:e=>e},"u">typeof trustedTypes&&trustedTypes.createPolicy&&(n=trustedTypes.createPolicy("nextjs#bundler",n))),n),s.tu=e=>s.tt().createScriptURL(e),s.p="/_next/",a={68:0,334:0,642:0},s.f.j=(e,t)=>{var r=s.o(a,e)?a[e]:void 0;if(0!==r)if(r)t.push(r[2]);else if(/^(334|642|68)$/.test(e))a[e]=0;else{var o=new Promise((t,o)=>r=a[e]=[t,o]);t.push(r[2]=o);var n=s.p+s.u(e),i=Error();s.l(n,t=>{if(s.o(a,e)&&(0!==(r=a[e])&&(a[e]=void 0),r)){var o=t&&("load"===t.type?"missing":t.type),n=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+o+": "+n+")",i.name="ChunkLoadError",i.type=o,i.request=n,r[1](i)}},"chunk-"+e,e)}},s.O.j=e=>0===a[e],i=(e,t)=>{var r,o,[n,i,u]=t,l=0;if(n.some(e=>0!==a[e])){for(r in i)s.o(i,r)&&(s.m[r]=i[r]);if(u)var c=u(s)}for(e&&e(t);l<n.length;l++)o=n[l],s.o(a,o)&&a[o]&&a[o][0](),a[o]=0;return s.O(c)},(u=self.webpackChunk_N_E=self.webpackChunk_N_E||[]).forEach(i.bind(null,0)),u.push=i.bind(null,u.push.bind(u))})();
|