@yxp934/prompt-tree 0.1.0 → 0.2.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.
Files changed (85) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +3 -3
  3. package/.next/standalone/.next/build-manifest.json +2 -2
  4. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  5. package/.next/standalone/.next/server/app/_global-error.html +2 -2
  6. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found/page.js +2 -2
  14. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  15. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.rsc +14 -13
  18. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +14 -13
  19. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  20. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +5 -4
  21. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  22. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  23. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  24. package/.next/standalone/.next/server/app/api/agent/route_client-reference-manifest.js +1 -1
  25. package/.next/standalone/.next/server/app/api/chat/route_client-reference-manifest.js +1 -1
  26. package/.next/standalone/.next/server/app/api/providers/health/route.js +1 -1
  27. package/.next/standalone/.next/server/app/api/providers/health/route_client-reference-manifest.js +1 -1
  28. package/.next/standalone/.next/server/app/api/providers/models/route.js +1 -1
  29. package/.next/standalone/.next/server/app/api/providers/models/route_client-reference-manifest.js +1 -1
  30. package/.next/standalone/.next/server/app/api/providers/test/route.js +1 -1
  31. package/.next/standalone/.next/server/app/api/providers/test/route_client-reference-manifest.js +1 -1
  32. package/.next/standalone/.next/server/app/api/tools/mcp/call-tool/route_client-reference-manifest.js +1 -1
  33. package/.next/standalone/.next/server/app/api/tools/mcp/list-tools/route_client-reference-manifest.js +1 -1
  34. package/.next/standalone/.next/server/app/api/tools/mcp/test/route_client-reference-manifest.js +1 -1
  35. package/.next/standalone/.next/server/app/api/tools/python/route_client-reference-manifest.js +1 -1
  36. package/.next/standalone/.next/server/app/api/tools/search/route_client-reference-manifest.js +1 -1
  37. package/.next/standalone/.next/server/app/index.html +2 -2
  38. package/.next/standalone/.next/server/app/index.rsc +15 -14
  39. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  40. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +15 -14
  41. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  42. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +5 -4
  43. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  44. package/.next/standalone/.next/server/app/page.js +3 -3
  45. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  46. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  47. package/.next/standalone/.next/server/app/settings/page.js +2 -2
  48. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  50. package/.next/standalone/.next/server/app/settings.html +1 -1
  51. package/.next/standalone/.next/server/app/settings.rsc +15 -14
  52. package/.next/standalone/.next/server/app/settings.segments/_full.segment.rsc +15 -14
  53. package/.next/standalone/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  54. package/.next/standalone/.next/server/app/settings.segments/_index.segment.rsc +5 -4
  55. package/.next/standalone/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  56. package/.next/standalone/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
  57. package/.next/standalone/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  58. package/.next/standalone/.next/server/app-paths-manifest.json +3 -3
  59. package/.next/standalone/.next/server/chunks/{368.js → 116.js} +1 -1
  60. package/.next/standalone/.next/server/chunks/689.js +1 -0
  61. package/.next/standalone/.next/server/chunks/732.js +30 -0
  62. package/.next/standalone/.next/server/chunks/734.js +1 -0
  63. package/.next/standalone/.next/server/chunks/913.js +2 -2
  64. package/.next/standalone/.next/server/pages/404.html +1 -1
  65. package/.next/standalone/.next/server/pages/500.html +2 -2
  66. package/.next/standalone/.next/static/chunks/308-9aca2a7bf1797568.js +2 -0
  67. package/.next/standalone/.next/static/chunks/394-1e8c9367852fd6d7.js +30 -0
  68. package/.next/standalone/.next/static/chunks/787-56a48f915165efd3.js +1 -0
  69. package/.next/standalone/.next/static/chunks/app/layout-7950581b06dcfcd2.js +1 -0
  70. package/.next/standalone/.next/static/chunks/app/page-c273f2f3b7ce1609.js +1 -0
  71. package/.next/standalone/.next/static/chunks/app/settings/page-0fc8a4cbf639025c.js +1 -0
  72. package/.next/standalone/.next/static/css/100bba9d1b2ebade.css +1 -0
  73. package/.next/standalone/package.json +1 -1
  74. package/README.md +32 -26
  75. package/package.json +1 -1
  76. package/.next/standalone/.next/server/chunks/852.js +0 -30
  77. package/.next/standalone/.next/server/chunks/918.js +0 -1
  78. package/.next/standalone/.next/static/chunks/745-34771ca05b57a010.js +0 -2
  79. package/.next/standalone/.next/static/chunks/769-1bd3beb633de2683.js +0 -30
  80. package/.next/standalone/.next/static/chunks/app/layout-cf74cd021b6f9316.js +0 -1
  81. package/.next/standalone/.next/static/chunks/app/page-bba3294cfe651287.js +0 -1
  82. package/.next/standalone/.next/static/chunks/app/settings/page-9b21761d8caa6149.js +0 -1
  83. package/.next/standalone/.next/static/css/990efe10b798511e.css +0 -1
  84. /package/.next/standalone/.next/static/{YhDyHybhyTmPCC6Vg7eEa → wYfac0R-RsurEa801s_qH}/_buildManifest.js +0 -0
  85. /package/.next/standalone/.next/static/{YhDyHybhyTmPCC6Vg7eEa → wYfac0R-RsurEa801s_qH}/_ssgManifest.js +0 -0
@@ -1,2 +1,2 @@
1
- (()=>{var a={};a.id=662,a.ids=[662],a.modules={100:(a,b,c)=>{"use strict";c.d(b,{ConnectedModelSelector:()=>k});var d=c(8249),e=c(7484),f=c(9157),g=c(6684),h=c(1098);function i({category:a,models:b,selectedIds:c,onToggle:f,onAddSelected:i}){let[j,k]=(0,e.useState)(!0);if(0===b.length)return null;let l=b.filter(a=>c.has(a.id));return(0,d.jsxs)("div",{className:"mb-3 rounded-xl border border-parchment bg-cream overflow-hidden",children:[(0,d.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:()=>k(!j),children:[(0,d.jsx)("span",{className:`transition-transform duration-200 ${j?"rotate-0":"-rotate-90"}`,children:(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,d.jsx)("path",{d:"m6 9 6 6 6-6"})})}),(0,d.jsx)("span",{className:"flex-1 font-body text-[0.9rem] font-medium text-ink",children:(0,g.jY)(a)}),(0,d.jsx)("span",{className:"rounded-full bg-parchment px-2 py-0.5 font-mono text-[0.7rem] text-clay",children:b.length}),l.length>0&&(0,d.jsxs)("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:a=>{a.stopPropagation(),i()},children:["添加 ",l.length]})]}),j&&(0,d.jsx)("div",{className:"border-t border-parchment px-4 pb-3",children:(0,d.jsx)("div",{className:"space-y-1 pt-2",children:b.map(a=>{let b=c.has(a.id);return(0,d.jsxs)("div",{className:`group flex items-center gap-3 rounded-lg px-3 py-2.5 transition-all ${b?"bg-copper/10":"hover:bg-paper/50"}`,children:[(0,d.jsx)("button",{type:"button",className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded border transition-all ${b?"border-copper bg-copper text-white":"border-parchment bg-transparent hover:border-sand"}`,onClick:()=>f(a.id),children:b&&(0,d.jsx)(h.Sr,{})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"font-mono text-[0.85rem] text-ink truncate",children:a.id}),a.name!==a.id&&(0,d.jsx)("div",{className:"font-body text-[0.75rem] text-sand truncate",children:a.name})]})]},a.id)})})})]})}function j({open:a,onClose:b}){let c=(0,f.CU)(a=>a.providers),j=(0,f.CU)(a=>a.modelSelector);(0,f.CU)(a=>a.closeModelSelector);let k=(0,f.CU)(a=>a.setModelSelectorSearch),l=(0,f.CU)(a=>a.setModelSelectorTab),m=(0,f.CU)(a=>a.fetchModelsForSelector),n=(0,f.CU)(a=>a.addFetchedModels),[o,p]=(0,e.useState)(new Set),q=c.find(a=>a.id===j.providerId),r=new Set(q?.models.map(a=>a.id)||[]),s=j.fetchedModels.filter(a=>!r.has(a.id)).filter(a=>{let b=!j.searchQuery||a.id.toLowerCase().includes(j.searchQuery.toLowerCase())||a.name.toLowerCase().includes(j.searchQuery.toLowerCase()),c="all"===j.activeTab||a.category===j.activeTab;return b&&c}),t={};for(let a of s){let b=a.category||"chat";t[b]||(t[b]=[]),t[b].push(a)}let u=a=>{p(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})};return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-ink/20 backdrop-blur-sm",onClick:b}),(0,d.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,d.jsxs)("div",{className:"flex items-center justify-between border-b border-parchment px-6 py-4",children:[(0,d.jsxs)("h3",{className:"font-display text-xl text-ink",children:[q?.name||"提供商"," - 模型"]}),(0,d.jsx)("button",{type:"button",className:"rounded-lg p-2 text-clay transition-colors hover:text-ink",onClick:b,children:(0,d.jsx)(h.US,{})})]}),(0,d.jsx)("div",{className:"border-b border-parchment px-6 py-4",children:(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsxs)("div",{className:"flex-1 relative",children:[(0,d.jsx)(h.WI,{}),(0,d.jsx)("input",{type:"text",value:j.searchQuery,onChange:a=>k(a.target.value),placeholder:"搜索模型 ID 或名称",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,d.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 ${j.isLoading?"animate-spin":""}`,onClick:()=>{q&&m(q.id)},disabled:j.isLoading,children:(0,d.jsx)(h.fN,{})})]})}),(0,d.jsx)("div",{className:"flex items-center gap-1 border-b border-parchment px-6 py-3 overflow-x-auto",children:g.NR.map(a=>(0,d.jsx)("button",{type:"button",className:`whitespace-nowrap rounded-lg px-3 py-1.5 font-body text-[0.8rem] transition-all ${j.activeTab===a.value?"bg-copper text-white":"text-clay hover:bg-cream hover:text-ink"}`,onClick:()=>l(a.value),children:a.label},a.value))}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:j.isLoading?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,d.jsx)("div",{className:"mb-4 h-8 w-8 animate-spin rounded-full border-2 border-copper border-t-transparent"}),(0,d.jsx)("p",{className:"font-body text-[0.9rem] text-sand",children:"正在获取模型列表..."})]}):j.error?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,d.jsx)("div",{className:"mb-4 text-red-400",children:(0,d.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,d.jsx)("path",{d:"m15 9-6 6m0-6 6 6"})]})}),(0,d.jsx)("p",{className:"mb-1 font-body text-[0.9rem] text-clay",children:"获取模型列表失败"}),(0,d.jsx)("p",{className:"font-body text-[0.8rem] text-sand",children:j.error})]}):0===s.length?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,d.jsx)("div",{className:"mb-4 text-sand",children:(0,d.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,d.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,d.jsx)("path",{d:"M9 9h6v6H9z"})]})}),(0,d.jsx)("p",{className:"mb-1 font-body text-[0.9rem] text-clay",children:j.searchQuery?"未找到匹配的模型":"暂无可用模型"}),(0,d.jsx)("p",{className:"font-body text-[0.8rem] text-sand",children:j.searchQuery?"尝试其他搜索关键词":"请先配置 API 密钥并刷新"})]}):(0,d.jsx)("div",{children:Object.entries(t).map(([a,b])=>(0,d.jsx)(i,{category:a,models:b,selectedIds:o,onToggle:u,onAddSelected:()=>{let a=b.filter(a=>o.has(a.id)).map(a=>a.id);a.length>0&&(n(a),a.forEach(a=>o.delete(a)),p(new Set(o)))}},a))})}),o.size>0&&(0,d.jsxs)("div",{className:"flex items-center justify-between border-t border-parchment px-6 py-4",children:[(0,d.jsxs)("span",{className:"font-body text-[0.85rem] text-sand",children:["已选择 ",o.size," 个模型"]}),(0,d.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:()=>{o.size>0&&(n(Array.from(o)),p(new Set))},children:[(0,d.jsx)(h.c1,{}),"添加选中"]})]})]})]}):null}function k(){let a=(0,f.CU)(a=>a.modelSelector),b=(0,f.CU)(a=>a.closeModelSelector);return(0,d.jsx)(j,{open:a.open,onClose:b})}},261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},729:(a,b,c)=>{"use strict";c.r(b),c.d(b,{GlobalError:()=>C.a,__next_app__:()=>K,handler:()=>M,routeModule:()=>L});var d=c(7553),e=c(4006),f=c(7798),g=c(4775),h=c(9373),i=c(3461),j=c(1020),k=c(6349),l=c(4365),m=c(6023),n=c(3747),o=c(4235),p=c(3938),q=c(261),r=c(6758),s=c(7243),t=c(6713),u=c(7527),v=c(2820),w=c(8216),x=c(7929),y=c(9551),z=c(9125),A=c(6439),B=c(5547),C=c.n(B),D=c(1287),E=c(1494),F=c(722),G=c(753),H=c(3954),I={};for(let a in D)0>["default","GlobalError","__next_app__","routeModule","handler"].indexOf(a)&&(I[a]=()=>D[a]);c.d(b,I);let J={children:["",{children:["settings",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,1561)),"/Users/yxp/Documents/new-chat/ai-chat-client/src/app/settings/page.tsx"]}]},{metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(c.bind(c,6537)),"/Users/yxp/Documents/new-chat/ai-chat-client/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.t.bind(c,5547,23)),"next/dist/client/components/builtin/global-error.js"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,5091,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,5270,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,8193,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]}.children,K={require:c,loadChunk:()=>Promise.resolve()},L=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/settings/page",pathname:"/settings",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:J},distDir:".next",relativeProjectDir:""});async function M(a,b,d){var B;L.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let I=!!(0,h.getRequestMeta)(a,"minimalMode"),N="/settings/page";"/index"===N&&(N="/");let O=await L.prepare(a,b,{srcPage:N,multiZoneDraftMode:!1});if(!O)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:P,query:Q,params:R,pageIsDynamic:S,buildManifest:T,nextFontManifest:U,reactLoadableManifest:V,serverActionsManifest:W,clientReferenceManifest:X,subresourceIntegrityManifest:Y,prerenderManifest:Z,isDraftMode:$,resolvedPathname:_,revalidateOnlyGenerated:aa,routerServerContext:ab,nextConfig:ac,parsedUrl:ad,interceptionRoutePatterns:ae,deploymentId:af}=O,ag=(0,q.normalizeAppPath)(N),{isOnDemandRevalidate:ah}=O,ai=ac.experimental.ppr&&!ac.cacheComponents&&(0,H.isInterceptionRouteAppPath)(_)?null:L.match(_,Z),aj=!!Z.routes[_],ak=a.headers["user-agent"]||"",al=(0,t.getBotType)(ak),am=(0,p.isHtmlBotRequest)(a),an=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[s.NEXT_ROUTER_PREFETCH_HEADER],ao=(0,h.getRequestMeta)(a,"isRSCRequest")??!!a.headers[s.RSC_HEADER],ap=(0,r.getIsPossibleServerAction)(a),aq=(0,m.checkIsAppPPREnabled)(ac.experimental.ppr);if(!(0,h.getRequestMeta)(a,"postponed")&&aq&&"1"===a.headers[x.NEXT_RESUME_HEADER]&&"POST"===a.method){let b=[];for await(let c of a)b.push(c);let c=Buffer.concat(b).toString("utf8");(0,h.addRequestMeta)(a,"postponed",c)}let ar=aq&&(null==(B=Z.routes[ag]??Z.dynamicRoutes[ag])?void 0:B.renderingMode)==="PARTIALLY_STATIC",as=!1,at=!1,au=ar?(0,h.getRequestMeta)(a,"postponed"):void 0,av=ar&&ao&&!an;I&&(av=av&&!!au);let aw=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),ax=(!am||!ar)&&(!ak||(0,p.shouldServeStreamingMetadata)(ak,ac.htmlLimitedBots)),ay=!!((ai||aj||Z.routes[ag])&&!(am&&ar)),az=ar&&!0===ac.cacheComponents,aA=!0===L.isDev||!ay||"string"==typeof au||(az&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?av&&!I:av),aB=am&&ar,aC=null;$||!ay||aA||ap||au||av||(aC=_);let aD=aC;!aD&&L.isDev&&(aD=_),L.isDev||$||!ay||!ao||av||(0,k.d)(a.headers);let aE={...D,tree:J,GlobalError:C(),handler:M,routeModule:L,__next_app__:K};W&&X&&(0,o.setManifestsSingleton)({page:N,clientReferenceManifest:X,serverActionsManifest:W});let aF=a.method||"GET",aG=(0,g.getTracer)(),aH=aG.getActiveScopeSpan(),aI=async()=>((null==ab?void 0:ab.render404)?await ab.render404(a,b,ad,!1):b.end("This page could not be found"),null);try{let f=L.getVaryHeader(_,ae);b.setHeader("Vary",f);let k=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return L.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aG.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aF} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a)}else c.updateName(`${aF} ${N}`)})},m=(0,h.getRequestMeta)(a,"incrementalCache"),o=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let l={query:Q,params:R,page:ag,sharedContext:{buildId:P},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aE,Component:(0,j.T)(aE),params:R,routeModule:L,page:N,postponed:f,shouldWaitOnAllReady:aB,serveStreamingMetadata:ax,supportsDynamicResponse:"string"==typeof f||aA,buildManifest:T,nextFontManifest:U,reactLoadableManifest:V,subresourceIntegrityManifest:Y,setCacheStatus:null==ab?void 0:ab.setCacheStatus,setIsrStatus:null==ab?void 0:ab.setIsrStatus,setReactDebugChannel:null==ab?void 0:ab.setReactDebugChannel,sendErrorsToBrowser:null==ab?void 0:ab.sendErrorsToBrowser,dir:c(3873).join(process.cwd(),L.relativeProjectDir),isDraftMode:$,botType:al,isOnDemandRevalidate:ah,isPossibleServerAction:ap,assetPrefix:ac.assetPrefix,nextConfigOutput:ac.output,crossOrigin:ac.crossOrigin,trailingSlash:ac.trailingSlash,images:ac.images,previewProps:Z.preview,deploymentId:af,enableTainting:ac.experimental.taint,htmlLimitedBots:ac.htmlLimitedBots,reactMaxHeadersLength:ac.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:m,cacheLifeProfiles:ac.cacheLife,basePath:ac.basePath,serverActions:ac.experimental.serverActions,...as||at?{nextExport:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:as}:{},cacheComponents:!!ac.cacheComponents,experimental:{isRoutePPREnabled:ar,expireTime:ac.expireTime,staleTimes:ac.experimental.staleTimes,dynamicOnHover:!!ac.experimental.dynamicOnHover,inlineCss:!!ac.experimental.inlineCss,authInterrupts:!!ac.experimental.authInterrupts,clientTraceMetadata:ac.experimental.clientTraceMetadata||[],clientParamParsingOrigins:ac.experimental.clientParamParsingOrigins},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>L.onRequestError(a,b,d,e,ab),err:(0,h.getRequestMeta)(a,"invokeError"),dev:L.isDev}};as&&(l.renderOpts.nextExport=!0,l.renderOpts.supportsDynamicResponse=!1,l.renderOpts.isDebugDynamicAccesses=as),i&&(l.renderOpts.supportsDynamicResponse=!1);let n=await k(e,l),{metadata:o}=n,{cacheControl:p,headers:q={},fetchTags:r,fetchMetrics:s}=o;if(r&&(q[x.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,ay&&(null==p?void 0:p.revalidate)===0&&!L.isDev&&!ar){let a=o.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${_}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
2
- see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:u.CachedRouteKind.APP_PAGE,html:n,headers:q,rscData:o.flightData,postponed:o.postponed,status:o.statusCode,segmentData:o.segmentData},cacheControl:p}},p=async({hasResolved:c,previousCacheEntry:f,isRevalidating:g,span:i,forceStaticRender:j=!1})=>{let k,l=!1===L.isDev,q=c||b.writableEnded;if(ah&&aa&&!f&&!I)return(null==ab?void 0:ab.render404)?await ab.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(ai&&(k=(0,v.parseFallbackField)(ai.fallback)),k===v.FallbackMode.PRERENDER&&(0,t.isBot)(ak)&&(!ar||am)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),(null==f?void 0:f.isStale)===-1&&(ah=!0),ah&&(k!==v.FallbackMode.NOT_FOUND||f)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),!I&&k!==v.FallbackMode.BLOCKING_STATIC_RENDER&&aD&&!q&&!$&&S&&(l||!aj)){if((l||ai)&&k===v.FallbackMode.NOT_FOUND){if(ac.experimental.adapterPath)return await aI();throw new A.NoFallbackError}if(ar&&(ac.cacheComponents?!av:!ao)){let b=l&&"string"==typeof(null==ai?void 0:ai.fallback)?ai.fallback:ag,c=l&&(null==ai?void 0:ai.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ai.fallbackRouteParams):at?(0,n.getFallbackRouteParams)(ag,L):null,f=await L.handleResponse({cacheKey:b,req:a,nextConfig:ac,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:Z,isRoutePPREnabled:ar,responseGenerator:async()=>o({span:i,postponed:void 0,fallbackRouteParams:c,forceStaticRender:!1}),waitUntil:d.waitUntil,isMinimalMode:I});if(null===f)return null;if(f)return delete f.cacheControl,f}}let r=ah||g||!au?void 0:au;if(az&&!I&&m&&av&&!j){let b=await m.get(_,{kind:u.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===u.CachedRouteKind.APP_PAGE&&(r=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,G.scheduleOnNextTick)(async()=>{let b=L.getResponseCache(a);try{await b.revalidate(_,m,ar,!1,a=>p({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if(as&&void 0!==r)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:u.CachedRouteKind.PAGES,html:w.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let s=l&&(null==ai?void 0:ai.fallbackRouteParams)&&(0,h.getRequestMeta)(a,"renderFallbackShell")?(0,n.createOpaqueFallbackRouteParams)(ai.fallbackRouteParams):at?(0,n.getFallbackRouteParams)(ag,L):null;return o({span:i,postponed:r,fallbackRouteParams:s,forceStaticRender:j})},q=async c=>{var f,g,i,j,k;let l,m=await L.handleResponse({cacheKey:aC,responseGenerator:a=>p({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ah,isRoutePPREnabled:ar,req:a,nextConfig:ac,prerenderManifest:Z,waitUntil:d.waitUntil,isMinimalMode:I});if($&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),L.isDev&&b.setHeader("Cache-Control","no-store, must-revalidate"),!m){if(aC)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=m.value)?void 0:f.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=m.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let n="string"==typeof m.value.postponed;ay&&!av&&(!n||an)&&(I||b.setHeader("x-nextjs-cache",ah?"REVALIDATED":m.isMiss?"MISS":m.isStale?"STALE":"HIT"),b.setHeader(s.NEXT_IS_PRERENDER_HEADER,"1"));let{value:q}=m;if(au)l={revalidate:0,expire:void 0};else if(av)l={revalidate:0,expire:void 0};else if(!L.isDev)if($)l={revalidate:0,expire:void 0};else if(ay){if(m.cacheControl)if("number"==typeof m.cacheControl.revalidate){if(m.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${m.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:m.cacheControl.revalidate,expire:(null==(j=m.cacheControl)?void 0:j.expire)??ac.expireTime}}else l={revalidate:x.CACHE_ONE_YEAR,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(m.cacheControl=l,"string"==typeof aw&&(null==q?void 0:q.kind)===u.CachedRouteKind.APP_PAGE&&q.segmentData){b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=q.headers)?void 0:k[x.NEXT_CACHE_TAGS_HEADER];I&&ay&&c&&"string"==typeof c&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,c);let d=q.segmentData.get(aw);return void 0!==d?(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:w.default.fromStatic(d,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl}):(b.statusCode=204,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl}))}let r=az?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(r&&await r(m,{url:(0,h.getRequestMeta)(a,"initURL")??a.url}))return null;if(q.headers){let a={...q.headers};for(let[c,d]of(I&&ay||delete a[x.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let t=null==(g=q.headers)?void 0:g[x.NEXT_CACHE_TAGS_HEADER];if(I&&ay&&t&&"string"==typeof t&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,t),!q.status||ao&&ar||(b.statusCode=q.status),!I&&q.status&&E.RedirectStatusCode[q.status]&&ao&&(b.statusCode=200),n&&!av&&b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"1"),ao&&!$){if(void 0===q.rscData){if(q.html.contentType!==s.RSC_CONTENT_TYPE_HEADER)if(ac.cacheComponents)return b.statusCode=404,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl});else throw Object.defineProperty(new F.InvariantError(`Expected RSC response, got ${q.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:q.html,cacheControl:m.cacheControl})}return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:w.default.fromStatic(q.rscData,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl})}let v=q.html;if(!n||I||ao)return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:v,cacheControl:m.cacheControl});if(as)return v.push(new ReadableStream({start(a){a.enqueue(y.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}});let A=new TransformStream;return v.push(A.readable),o({span:c,postponed:q.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(A.writable)}).catch(a=>{A.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})};if(!aH)return await aG.withPropagatedContext(a.headers,()=>aG.trace(i.BaseServerSpan.handleRequest,{spanName:`${aF} ${N}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aF,"http.target":a.url}},q));await q(aH)}catch(b){throw b instanceof A.NoFallbackError||await L.onRequestError(a,b,{routerKind:"App Router",routePath:N,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:ay,isOnDemandRevalidate:ah})},!1,ab),b}}},813:(a,b,c)=>{"use strict";c.d(b,{ProviderList:()=>l});var d=c(8249),e=c(7484),f=c(9157),g=c(1098);function h({name:a}){let b=a.trim().charAt(0).toUpperCase(),c=["bg-matcha-green","bg-kintsugi-gold","bg-stone-gray"],e=a.charCodeAt(0)%c.length,f=c[e];return(0,d.jsx)("div",{className:`flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg ${f} text-shoji-white text-lg font-medium shadow-sm`,children:b})}function i({enabled:a,onToggle:b}){return(0,d.jsx)("button",{type:"button",className:`relative flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-all duration-300 ${a?"bg-matcha-green":"bg-stone-gray/30"}`,onClick:a=>{a.stopPropagation(),b()},"aria-pressed":a,children:(0,d.jsx)("span",{className:`block h-4.5 w-4.5 transform rounded-full bg-white shadow-sm transition-all duration-300 ${a?"translate-x-6":"translate-x-0.5"}`})})}function j({provider:a,isActive:b,onSelect:c,onToggle:e,onDelete:f}){return(0,d.jsx)("div",{className:`group relative mb-2 cursor-pointer rounded-xl p-4 transition-all duration-300 ${b?"bg-washi-cream/70 border border-matcha-green/20 shadow-sm":"hover:bg-washi-cream/30 border border-transparent"}`,onClick:c,role:"button",tabIndex:0,onKeyDown:a=>"Enter"===a.key&&c(),children:(0,d.jsxs)("div",{className:"flex w-full items-center gap-4 text-left",children:[(0,d.jsx)(h,{name:a.name}),(0,d.jsx)("span",{className:"flex-1 truncate font-zen-body text-sm font-normal text-ink-black",children:a.name}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(i,{enabled:a.enabled,onToggle:e}),(0,d.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:a=>{a.stopPropagation(),f()},"aria-label":"删除提供商",children:(0,d.jsx)(g.uc,{})})]})]})})}function k({open:a,onClose:b,onAdd:c}){let[f,g]=(0,e.useState)("");return a?(0,d.jsx)("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-ink-black/20 backdrop-blur-sm",children:(0,d.jsxs)("div",{className:"w-full max-w-md rounded-2xl bg-shoji-white p-8 shadow-lg border border-parchment/10",children:[(0,d.jsx)("h3",{className:"mb-6 font-zen-display text-2xl font-light text-ink-black tracking-wide",children:"添加提供商"}),(0,d.jsxs)("form",{onSubmit:a=>{a.preventDefault();let d=f.trim();d&&(c(d),g(""),b())},children:[(0,d.jsxs)("div",{className:"mb-6",children:[(0,d.jsx)("label",{className:"mb-3 block font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"Provider Name"}),(0,d.jsx)("input",{type:"text",value:f,onChange:a=>g(a.target.value),placeholder:"OpenAI, Anthropic, DeepSeek...",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,d.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,d.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:b,children:"取消"}),(0,d.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:"添加"})]})]})]})}):null}function l(){let a=(0,f.CU)(a=>a.providers),b=(0,f.CU)(a=>a.selectedProviderId),c=(0,f.CU)(a=>a.selectProvider),h=(0,f.CU)(a=>a.toggleProviderEnabled),i=(0,f.CU)(a=>a.deleteProvider),l=(0,f.CU)(a=>a.addProvider),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(!1);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex h-full w-[320px] flex-shrink-0 flex-col border-r border-parchment/10 bg-washi-cream/50",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between border-b border-parchment/10 px-6 py-6",children:[(0,d.jsx)("div",{className:"font-zen-display text-xl font-normal text-ink-black tracking-wide",children:"服务提供商"}),(0,d.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:o?a.length:"-"})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-6",children:0===a.length?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,d.jsx)("div",{className:"mb-4 rounded-2xl bg-washi-cream/50 p-6 text-stone-gray",children:(0,d.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",className:"mx-auto",children:[(0,d.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,d.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,d.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,d.jsx)("p",{className:"mb-2 font-zen-body text-sm text-stone-gray font-light",children:"暂无提供商"}),(0,d.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:"点击下方按钮添加"})]}):a.map((a,e)=>(0,d.jsx)("div",{style:{animation:`slideInUp 0.5s ease-out ${.05*e}s backwards`},children:(0,d.jsx)(j,{provider:a,isActive:b===a.id,onSelect:()=>c(a.id),onToggle:()=>h(a.id),onDelete:()=>i(a.id)})},a.id))}),(0,d.jsx)("div",{className:"border-t border-parchment/10 p-5",children:(0,d.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:()=>n(!0),children:[(0,d.jsx)(g.c1,{}),"添加提供商"]})})]}),(0,d.jsx)(k,{open:m,onClose:()=>n(!1),onAdd:a=>l(a)})]})}},846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},1025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},1098:(a,b,c)=>{"use strict";c.d(b,{GQ:()=>f,PX:()=>k,RY:()=>r,Sr:()=>p,Td:()=>s,US:()=>q,WI:()=>n,aR:()=>v,bM:()=>u,bN:()=>i,c1:()=>l,fN:()=>o,hp:()=>e,mo:()=>j,qY:()=>t,uc:()=>m,v1:()=>g,yo:()=>h});var d=c(8249);function e(){return(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.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,d.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,d.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 f(){return(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,d.jsx)("path",{d:"M9 9h6v6H9z"}),(0,d.jsx)("path",{d:"M9 1v3"}),(0,d.jsx)("path",{d:"M15 1v3"}),(0,d.jsx)("path",{d:"M9 20v3"}),(0,d.jsx)("path",{d:"M15 20v3"}),(0,d.jsx)("path",{d:"M20 9h3"}),(0,d.jsx)("path",{d:"M20 15h3"}),(0,d.jsx)("path",{d:"M1 9h3"}),(0,d.jsx)("path",{d:"M1 15h3"})]})}function g(){return(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("circle",{cx:"13.5",cy:"6.5",r:"0.5",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"17.5",cy:"10.5",r:"0.5",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"8.5",cy:"7.5",r:"0.5",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"6.5",cy:"12.5",r:"0.5",fill:"currentColor"}),(0,d.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 h(){return(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),(0,d.jsx)("path",{d:"M8 21h8"}),(0,d.jsx)("path",{d:"M12 17v4"})]})}function i(){return(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),(0,d.jsx)("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),(0,d.jsx)("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function j(){return(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,d.jsx)("path",{d:"M12 16v-4"}),(0,d.jsx)("path",{d:"M12 8h.01"})]})}function k(){return(0,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.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 l(){return(0,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M12 5v14M5 12h14"})})}function m(){return(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.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 n(){return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,d.jsx)("path",{d:"m21 21-4.35-4.35"})]})}function o(){return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,d.jsx)("path",{d:"M3 3v5h5"}),(0,d.jsx)("path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"}),(0,d.jsx)("path",{d:"M16 16h5v5"})]})}function p(){return(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M20 6 9 17l-5-5"})})}function q(){return(0,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M18 6 6 18M6 6l12 12"})})}function r(){return(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.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 s(){return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),(0,d.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 t(){return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.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,d.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 u(){return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}function v(){return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}),(0,d.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,d.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,d.jsx)("line",{x1:"2",x2:"22",y1:"2",y2:"22"})]})}},1190:(a,b,c)=>{"use strict";c.d(b,{SettingsPage:()=>e});var d=c(7943);let e=(0,d.registerClientReference)(function(){throw Error("Attempted to call SettingsPage() from the server but SettingsPage is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/SettingsPage.tsx","SettingsPage");(0,d.registerClientReference)(function(){throw Error("Attempted to call the default export of \"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/SettingsPage.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/SettingsPage.tsx","default")},1279:(a,b,c)=>{Promise.resolve().then(c.bind(c,3154)),Promise.resolve().then(c.bind(c,6325)),Promise.resolve().then(c.bind(c,7287)),Promise.resolve().then(c.bind(c,1190)),Promise.resolve().then(c.bind(c,2479))},1479:(a,b,c)=>{"use strict";c.d(b,{SettingsPage:()=>G});var d=c(8249),e=c(2116),f=c.n(e),g=c(7484),h=c(9157),i=c(813),j=c(5032),k=c(1569),l=c(100),m=c(2815),n=c(518),o=c(318),p=c(7440),q=c(5951),r=c(8655),s=c(6684),t=c(1879),u=c(7872),v=c(1098);function w(a){return"object"==typeof a&&null!==a}function x({title:a,description:b,action:c,children:e}){return(0,d.jsxs)("div",{className:"flex h-full flex-1 flex-col bg-shoji-white",children:[(0,d.jsx)("div",{className:"border-b border-parchment/10 px-8 py-8",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h2",{className:"font-zen-display text-2xl font-light text-ink-black tracking-wide",children:a}),b&&(0,d.jsx)("p",{className:"mt-2 max-w-xl font-zen-body text-sm text-stone-gray font-light",children:b})]}),c]})}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,d.jsx)("div",{className:"max-w-3xl px-8 py-8",children:e})})]})}function y({title:a,description:b}){return(0,d.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,d.jsx)("div",{className:"mb-4 rounded-xl bg-shoji-white p-4 text-stone-gray",children:(0,d.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,d.jsx)("path",{d:"M12 16v-4"}),(0,d.jsx)("path",{d:"M12 8h.01"})]})}),(0,d.jsx)("p",{className:"mb-2 font-zen-body text-sm text-stone-gray font-light",children:a}),(0,d.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:b})]})}function z(){let a=(0,h.CU)(a=>a.providers),b=(0,h.CU)(a=>a.compressionModel),c=(0,h.CU)(a=>a.summaryModel),e=(0,h.CU)(a=>a.setLLMSettings),f=(0,h.CU)(a=>a.selectedModels),i=(0,h.CU)(a=>a.setSelectedModels),[j,k]=(0,g.useState)("idle"),[l,m]=(0,g.useState)(null),[n,o]=(0,g.useState)(null),p=(0,g.useMemo)(()=>(0,r.n)(a),[a]),q=(0,g.useMemo)(()=>new Set(f.map(r.R)),[f]),t=(0,g.useMemo)(()=>{let a=new Map;for(let b of p)a.has(b.providerId)||a.set(b.providerId,{providerId:b.providerId,providerName:b.providerName,models:[]}),a.get(b.providerId).models.push(b);return Array.from(a.values()).sort((a,b)=>a.providerName.localeCompare(b.providerName))},[p]),w=a=>({providerId:a.providerId,modelId:a.modelId}),z=async()=>{let b=f[0];if(!b){k("error"),m("请先选择模型");return}let c=a.find(a=>a.id===b.providerId)??null;if(!c){k("error"),m("模型服务商不存在");return}let d=(0,u.aA)(c);if(!d){k("error"),m("请先配置 API 密钥");return}k("running"),m(null),o(null);let e=await (0,s.DT)(d.value,c.baseUrl,b.modelId,{headers:c.headers,timeout:c.timeout,prompt:"ping"});if(o(e.responseTime??null),"healthy"===e.status){k("success"),m(e.content||"连接成功");return}k("error"),m(e.error||"测试失败")},A=b?(0,r.R)(b):"",B=c?(0,r.R)(c):"";return(0,d.jsx)(x,{title:"模型设置",description:"选择对话分支模型,并配置压缩与标题总结模型。",children:(0,d.jsxs)("div",{className:"space-y-8",children:[(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"已启用模型"}),(0,d.jsx)("p",{className:"mt-2 font-zen-body text-sm text-stone-gray font-light",children:"选择多个模型后,发送消息将并行生成多个分支回复。"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.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:()=>{i(p.map(a=>w(a)))},disabled:0===p.length,children:"全选"}),(0,d.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:()=>{i([])},disabled:0===f.length,children:"清空"})]})]}),0===p.length?(0,d.jsx)("div",{className:"mt-6",children:(0,d.jsx)(y,{title:"暂无启用模型",description:"请先在模型服务中启用模型。"})}):(0,d.jsx)("div",{className:"mt-6 space-y-6",children:t.map(a=>(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"mb-3 font-zen-body text-xs text-stone-gray font-light",children:a.providerName}),(0,d.jsx)("div",{className:"space-y-2",children:a.models.map(a=>{let b=q.has((0,r.R)(a));return(0,d.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 ${b?"border-matcha-green/40 bg-matcha-green/10":"border-parchment/20 bg-shoji-white hover:border-matcha-green/30"}`,onClick:()=>{let b;return b=(0,r.R)(a),void i(q.has(b)?f.filter(a=>(0,r.R)(a)!==b):[...f,w(a)])},children:[(0,d.jsx)("span",{className:`flex h-5 w-5 items-center justify-center rounded border text-[0.7rem] ${b?"border-matcha-green bg-matcha-green text-shoji-white":"border-parchment bg-transparent text-transparent"}`,children:"✓"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("div",{className:"font-mono text-sm text-ink-black",children:a.modelId}),(0,d.jsx)("div",{className:"text-xs text-stone-gray font-light",children:a.label})]})]},a.modelId)})})]},a.providerId))})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsx)("div",{className:"mb-3 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"压缩模型"}),(0,d.jsxs)("select",{value:A,onChange:a=>{var b;let c;return b=a.target.value,void e({compressionModel:(c=p.find(a=>(0,r.R)(a)===b))?w(c):null,...c?{model:c.modelId}:{}})},disabled:0===p.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,d.jsx)("option",{value:"",children:"请选择压缩模型"}),p.map(a=>(0,d.jsx)("option",{value:(0,r.R)(a),children:a.label},`${a.providerId}-${a.modelId}`))]}),(0,d.jsx)("p",{className:"mt-3 font-zen-body text-xs text-stone-gray font-light",children:"用于生成压缩节点的摘要与元指令建议。"})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsx)("div",{className:"mb-3 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"总结模型"}),(0,d.jsxs)("select",{value:B,onChange:a=>{var b;let c;return b=a.target.value,void e({summaryModel:(c=p.find(a=>(0,r.R)(a)===b))?w(c):null})},disabled:0===p.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,d.jsx)("option",{value:"",children:"请选择总结模型"}),p.map(a=>(0,d.jsx)("option",{value:(0,r.R)(a),children:a.label},`${a.providerId}-${a.modelId}`))]}),(0,d.jsx)("p",{className:"mt-3 font-zen-body text-xs text-stone-gray font-light",children:"用于首条消息后生成不超过 6 个字的对话标题。"})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"模型测试"}),null!==n&&(0,d.jsxs)("div",{className:"mt-2 font-mono text-xs text-stone-gray",children:["响应时间 ",n,"ms"]})]}),(0,d.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"===j?"bg-washi-cream text-stone-gray cursor-wait":"bg-matcha-green/10 text-matcha-green hover:bg-matcha-green/20 font-light"}`,onClick:z,disabled:"running"===j||0===f.length,children:"running"===j?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(v.fN,{}),"测试中..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(v.Sr,{}),"测试模型"]})})]}),l&&(0,d.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"}[j]}`,children:l})]})]})})}function A(){let a=(0,h.CU)(a=>a.temperature),b=(0,h.CU)(a=>a.maxTokens),c=(0,h.CU)(a=>a.setLLMSettings),[e,f]=(0,g.useState)(""),[i,j]=(0,g.useState)(p.rd),[k,l]=(0,g.useState)(a.toString()),[m,n]=(0,g.useState)(b.toString()),[q,r]=(0,g.useState)(!1),[s,t]=(0,g.useState)(null);return(0,d.jsx)(x,{title:"常规设置",description:"管理默认 API 连接和基础生成参数。",children:(0,d.jsxs)("div",{className:"space-y-8",children:[(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsx)("div",{className:"mb-4 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"API 连接"}),(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"mb-2 block font-zen-body text-xs text-stone-gray font-light",children:"API Key"}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{type:q?"text":"password",value:e,onChange:a=>f(a.target.value),placeholder:"sk-...",className:"w-full rounded-xl border border-parchment/20 bg-shoji-white px-5 py-4 pr-10 font-mono text-sm text-ink-black outline-none transition-all duration-300 focus:border-matcha-green/50"}),(0,d.jsx)("button",{type:"button",className:"absolute right-4 top-1/2 -translate-y-1/2 text-stone-gray transition-colors hover:text-ink-black",onClick:()=>r(a=>!a),children:q?(0,d.jsx)(v.aR,{}):(0,d.jsx)(v.bM,{})})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"mb-2 block font-zen-body text-xs text-stone-gray font-light",children:"Base URL"}),(0,d.jsx)("input",{type:"text",value:i,onChange:a=>j(a.target.value),placeholder:p.rd,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"})]})]})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsx)("div",{className:"mb-4 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"生成参数"}),(0,d.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"mb-2 block font-zen-body text-xs text-stone-gray font-light",children:"Temperature"}),(0,d.jsx)("input",{type:"number",min:"0",max:"2",step:"0.1",value:k,onChange:a=>l(a.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,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"mb-2 block font-zen-body text-xs text-stone-gray font-light",children:"Max Tokens"}),(0,d.jsx)("input",{type:"number",min:"1",value:m,onChange:a=>n(a.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,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:s??"修改将保存到本地浏览器"}),(0,d.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 d=Number.parseFloat(k),f=Number.parseInt(m,10),g={temperature:Number.isFinite(d)?d:a,maxTokens:Number.isFinite(f)?f:b};(0,o.YA)(e),(0,p.$t)(i),c(g),t("设置已保存"),setTimeout(()=>t(null),2e3)},children:"保存设置"})]})]})})}function B(){let a=(0,h.CU)(a=>a.theme),b=(0,h.CU)(a=>a.setTheme);return(0,d.jsx)(x,{title:"显示设置",description:"切换应用整体主题。",children:(0,d.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:[{id:"light",label:"浅色",description:"适合白天或自然光环境"},{id:"dark",label:"深色",description:"适合夜间或弱光环境"}].map(c=>(0,d.jsxs)("button",{type:"button",className:`rounded-2xl border px-6 py-5 text-left transition-all duration-300 ${a===c.id?"border-matcha-green/40 bg-matcha-green/10":"border-parchment/20 bg-washi-cream/50 hover:border-matcha-green/40"}`,onClick:()=>b(c.id),children:[(0,d.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:c.label}),(0,d.jsx)("div",{className:"mt-2 font-zen-body text-xs text-stone-gray font-light",children:c.description})]},c.id))})})}function C(){let a=(0,h.CU)(a=>a.setLLMSettings),b=(0,h.CU)(a=>a.setTheme),[c,e]=(0,g.useState)(!1),[f,i]=(0,g.useState)(!1),[j,k]=(0,g.useState)(!1),[l,m]=(0,g.useState)(!1),[r,s]=(0,g.useState)(null),u=async()=>{e(!0),s(null);try{await (0,n.MR)(),s("对话数据已清除,正在刷新..."),setTimeout(()=>window.location.reload(),800)}catch(a){s(a instanceof Error?a.message:"清除失败"),e(!1)}},v=async()=>{i(!0),s(null);try{(0,o.YA)(""),(0,p.$t)(""),(0,t.Ny)(),(0,t.k8)(),a(q.ES),b("light"),s("设置已重置,正在刷新..."),setTimeout(()=>window.location.reload(),800)}catch(a){s(a instanceof Error?a.message:"重置失败"),i(!1)}};return(0,d.jsx)(x,{title:"数据设置",description:"管理本地存储的对话数据与设置。",children:(0,d.jsxs)("div",{className:"space-y-6",children:[(0,d.jsx)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:"清除对话数据"}),(0,d.jsx)("p",{className:"mt-2 font-zen-body text-xs text-stone-gray font-light",children:"删除 IndexedDB 中保存的全部对话记录。"})]}),j?(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("button",{type:"button",className:"rounded-lg bg-red-500 px-4 py-2 text-sm text-white",onClick:u,disabled:c,children:c?"清除中...":"确认清除"}),(0,d.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/30 px-4 py-2 text-sm text-stone-gray",onClick:()=>k(!1),children:"取消"})]}):(0,d.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:()=>k(!0),children:"清除数据"})]})}),(0,d.jsx)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:"重置设置"}),(0,d.jsx)("p",{className:"mt-2 font-zen-body text-xs text-stone-gray font-light",children:"清空提供商配置、API Key 与主题设置。"})]}),l?(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("button",{type:"button",className:"rounded-lg bg-matcha-green px-4 py-2 text-sm text-shoji-white",onClick:v,disabled:f,children:f?"重置中...":"确认重置"}),(0,d.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/30 px-4 py-2 text-sm text-stone-gray",onClick:()=>m(!1),children:"取消"})]}):(0,d.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:()=>m(!0),children:"重置设置"})]})}),r&&(0,d.jsx)("p",{className:"font-zen-body text-xs text-stone-gray font-light",children:r})]})})}function D(){return(0,d.jsx)(x,{title:"关于",description:"了解 Cortex 的技术与版本信息。",children:(0,d.jsx)("div",{className:"space-y-4",children:[{label:"版本",value:"Cortex v1.0.0"},{label:"框架",value:"Next.js 14 + React 18"},{label:"数据存储",value:"IndexedDB + LocalStorage"},{label:"界面风格",value:"Zen Serenity"}].map(a=>(0,d.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,d.jsx)("span",{className:"font-zen-body text-sm text-stone-gray font-light",children:a.label}),(0,d.jsx)("span",{className:"font-zen-display text-lg font-light text-ink-black",children:a.value})]},a.label))})})}function E(){let a=(0,h.CU)(a=>a.toolSettings),b=(0,h.CU)(a=>a.setToolSettings),c=(0,h.CU)(a=>a.upsertMcpServer),e=(0,h.CU)(a=>a.deleteMcpServer),[f,i]=(0,g.useState)(!1),[j,k]=(0,g.useState)(!1),[l,n]=(0,g.useState)({status:"idle"}),o=async()=>{let b=a.search.provider,c="exa"===b?a.search.exaApiKey:a.search.tavilyApiKey;if(!c.trim())return void n({status:"error",message:`请先配置 ${"exa"===b?"Exa":"Tavily"} API Key`});n({status:"running",message:void 0,latencyMs:void 0});let d=Date.now();try{let e=await fetch("/api/tools/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:b,apiKey:c,query:"OpenAI",maxResults:1,searchDepth:a.search.searchDepth})}),f=Math.max(0,Date.now()-d),g=await e.json().catch(()=>null);if(!e.ok){let a=w(g)&&"error"in g?String(g.error??""):"";throw Error(a||`请求失败 (${e.status})`)}let h=w(g)&&Array.isArray(g.results)&&g.results[0]&&w(g.results[0])&&"string"==typeof g.results[0].title?g.results[0].title:"";n({status:"success",latencyMs:f,message:h?`连接成功 \xb7 ${h}`:"连接成功"})}catch(a){n({status:"error",message:a instanceof Error?a.message:"连接测试失败"})}},p={idle:"text-stone-gray",running:"text-kintsugi-gold",success:"text-matcha-green",error:"text-red-500"}[l.status],[q,r]=(0,g.useState)({}),[s,t]=(0,g.useState)({}),[u,z]=(0,g.useState)({}),A=(a,b)=>{let c=b.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g,"").replace(/\r/g,"").split("\n").map(a=>a.trimEnd()).filter(Boolean);0!==c.length&&r(b=>{let d=b[a],e=[...d?.logs??[],...c],f=e.slice(Math.max(0,e.length-200));return{...b,[a]:{...d??{status:"running"},logs:f}}})},B=async b=>{let c=a.mcp.servers.find(a=>a.id===b)??null;if(!c)return void r(a=>({...a,[b]:{status:"error",message:"MCP Server 不存在或已删除。"}}));r(a=>({...a,[b]:{status:"running",message:void 0,tools:void 0,logs:[]}})),z(a=>({...a,[b]:!0}));let d=Date.now();try{let a=await fetch("/api/tools/mcp/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({server:c})});if(!a.ok){let b=await a.json().catch(()=>null),c="object"==typeof b&&null!==b&&"error"in b?String(b.error??""):"";throw Error(c||`请求失败 (${a.status})`)}let e=a.headers.get("content-type")??"";if(!a.body||!e.includes("text/event-stream"))throw Error("Invalid MCP test response (expected SSE).");let f=a.body.getReader(),g=new TextDecoder("utf-8"),h="",i=!1,j=!1;for(;!i;){let a=await f.read();if(a.done)break;let c=(h+=g.decode(a.value,{stream:!0})).split(/\r?\n\r?\n/);for(let a of(h=c.pop()??"",c)){for(let c of a.split(/\r?\n/)){if(!c.startsWith("data:"))continue;let a=c.replace(/^data:\s*/,"");if(a){if("[DONE]"===a){i=!0;break}try{let c=JSON.parse(a);if("log"===c.type)A(b,c.text);else if("status"===c.type)r(a=>({...a,[b]:{...a[b]??{status:"running"},message:c.phase}}));else if("result"===c.type)j=!0,r(a=>({...a,[b]:{...a[b]??{status:"success"},status:"success",message:`连接成功 \xb7 ${c.tools.length} tools`,latencyMs:c.latencyMs??Math.max(0,Date.now()-d),tools:c.tools,testedAt:Date.now()}})),t(a=>({...a,[b]:!0}));else if("error"===c.type)throw Error(c.message)}catch(c){let a=c instanceof Error?c.message:"测试连接失败";A(b,a)}}}if(i)break}}if(!j)throw Error("MCP test finished without result.")}catch(e){let a=Math.max(0,Date.now()-d),c=e instanceof Error?e.message:"连接测试失败";r(d=>({...d,[b]:{...d[b]??{status:"error"},status:"error",message:c,latencyMs:a,tools:d[b]?.tools??[],testedAt:Date.now()}}))}},[C,D]=(0,g.useState)(!1),[E,F]=(0,g.useState)(null),[G,H]=(0,g.useState)(null),I=()=>{H(null),F({id:`mcp_${Date.now().toString(36)}`,name:"New MCP Server",transport:"http",token:"",configJson:JSON.stringify({url:"http://localhost:3000/mcp",protocolVersion:"2024-11-05"},null,2)}),D(!0)};return(0,d.jsxs)(x,{title:"工具设置",description:"配置 Web 搜索(Exa/Tavily)、MCP 服务器、以及 Python 代码执行参数。",action:(0,d.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:I,children:"添加 MCP"}),children:[(0,d.jsxs)("div",{className:"space-y-10",children:[(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsx)("div",{className:"mb-5 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"Web Search"}),(0,d.jsxs)("div",{className:"grid gap-5 md:grid-cols-2",children:[(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:"Default Provider"}),(0,d.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:a.search.provider,onChange:c=>b({...a,search:{...a.search,provider:"exa"===c.target.value?"exa":"tavily"}}),children:[(0,d.jsx)("option",{value:"tavily",children:"Tavily"}),(0,d.jsx)("option",{value:"exa",children:"Exa"})]})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:"Search Depth"}),(0,d.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:a.search.searchDepth,onChange:c=>b({...a,search:{...a.search,searchDepth:"advanced"===c.target.value?"advanced":"basic"}}),children:[(0,d.jsx)("option",{value:"basic",children:"basic"}),(0,d.jsx)("option",{value:"advanced",children:"advanced"})]})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:"Max Results"}),(0,d.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:a.search.maxResults,onChange:c=>b({...a,search:{...a.search,maxResults:Math.max(1,Math.min(20,Number(c.target.value||0)))}})})]})]}),(0,d.jsxs)("div",{className:"mt-6 grid gap-5 md:grid-cols-2",children:[(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:"Tavily API Key"}),(0,d.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:()=>i(a=>!a),children:[f?(0,d.jsx)(v.aR,{}):(0,d.jsx)(v.bM,{}),f?"隐藏":"显示"]})]}),(0,d.jsx)("input",{type:f?"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:a.search.tavilyApiKey,onChange:c=>b({...a,search:{...a.search,tavilyApiKey:c.target.value}}),placeholder:"tvly-..."})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:"Exa API Key"}),(0,d.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:()=>k(a=>!a),children:[j?(0,d.jsx)(v.aR,{}):(0,d.jsx)(v.bM,{}),j?"隐藏":"显示"]})]}),(0,d.jsx)("input",{type:j?"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:a.search.exaApiKey,onChange:c=>b({...a,search:{...a.search,exaApiKey:c.target.value}}),placeholder:"exa_..."})]})]}),(0,d.jsxs)("div",{className:"mt-6 flex flex-wrap items-center justify-between gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"连接测试"}),void 0!==l.latencyMs?(0,d.jsxs)("div",{className:"mt-2 font-mono text-xs text-stone-gray",children:["响应时间 ",l.latencyMs,"ms"]}):null]}),(0,d.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"===l.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 o(),disabled:"running"===l.status,children:"running"===l.status?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(v.fN,{}),"测试中..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(v.Sr,{}),"测试连接"]})})]}),l.message?(0,d.jsx)("p",{className:`mt-3 font-zen-body text-xs font-light ${p}`,children:l.message}):null]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsxs)("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"MCP Servers"}),(0,d.jsx)("p",{className:"mt-2 font-zen-body text-sm text-stone-gray font-light",children:"使用 JSON 配置 MCP 连接(Streamable HTTP / Legacy SSE / stdio),并为每个 server 设置 token。"})]}),(0,d.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:I,children:"新增"})]}),0===a.mcp.servers.length?(0,d.jsx)(y,{title:"暂无 MCP Server",description:"点击上方新增按钮,粘贴你的 MCP 配置 JSON。"}):(0,d.jsx)("div",{className:"space-y-3",children:a.mcp.servers.map(b=>{let c,f,g,h;return(0,d.jsx)("div",{className:"rounded-2xl border border-parchment/20 bg-shoji-white px-6 py-4",children:(c=q[b.id]??{status:"idle"},f=s[b.id]??!1,g=u[b.id]??!1,h="success"===c.status?"text-matcha-green":"error"===c.status?"text-red-500":"running"===c.status?"text-kintsugi-gold":"text-stone-gray",(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:b.name}),(0,d.jsxs)("div",{className:"mt-1 font-mono text-[0.7rem] text-stone-gray",children:[b.id," \xb7 ",b.transport.toUpperCase()]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.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 B(b.id),disabled:"running"===c.status,children:"running"===c.status?"测试中...":"测试连接"}),(0,d.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 c;let d;return c=b.id,void((d=a.mcp.servers.find(a=>a.id===c))&&(H(null),F({id:d.id,name:d.name,transport:d.transport,token:d.token,configJson:d.configJson}),D(!0)))},children:"编辑"}),(0,d.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:()=>e(b.id),children:"删除"})]})]}),"idle"!==c.status?(0,d.jsxs)("div",{className:"mt-3",children:[(0,d.jsxs)("div",{className:`font-mono text-[0.75rem] ${h}`,children:[c.message??("running"===c.status?"测试中...":""),"number"==typeof c.latencyMs?(0,d.jsxs)("span",{className:"ml-2 text-stone-gray",children:[c.latencyMs,"ms"]}):null]}),c.logs&&c.logs.length>0?(0,d.jsxs)("div",{className:"mt-2 rounded-xl border border-parchment/20 bg-washi-cream/60 px-4 py-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsx)("div",{className:"font-mono text-[0.65rem] uppercase tracking-[0.12em] text-stone-gray",children:"日志"}),(0,d.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:()=>z(a=>({...a,[b.id]:!g})),children:[g?"收起":"展开"," (",c.logs.length,")"]})]}),g?(0,d.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:c.logs.join("\n")}):null]}):null,"success"===c.status&&c.tools&&(0,d.jsxs)("div",{className:"mt-2 rounded-xl border border-parchment/20 bg-washi-cream/60 px-4 py-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsx)("div",{className:"font-mono text-[0.65rem] uppercase tracking-[0.12em] text-stone-gray",children:"可用工具"}),(0,d.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:()=>t(a=>({...a,[b.id]:!f})),children:[f?"收起":"展开"," (",c.tools.length,")"]})]}),f?(0,d.jsx)("div",{className:"mt-3 max-h-[260px] space-y-2 overflow-auto pr-1",children:0===c.tools.length?(0,d.jsx)("div",{className:"rounded-lg bg-shoji-white px-3 py-2 text-xs text-stone-gray",children:"未返回工具列表(tools = 0)"}):c.tools.map(a=>(0,d.jsxs)("div",{className:"rounded-lg bg-shoji-white px-3 py-2",children:[(0,d.jsx)("div",{className:"font-mono text-[0.75rem] text-ink-black",children:a.name}),a.description?(0,d.jsx)("div",{className:"mt-1 text-xs text-stone-gray",children:a.description}):null]},a.name))}):null]})]}):null]}))},b.id)})})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsx)("div",{className:"mb-5 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"Python Execution"}),(0,d.jsxs)("div",{className:"grid gap-5 md:grid-cols-2",children:[(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:"Timeout (seconds)"}),(0,d.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(a.python.timeoutMs/1e3),onChange:c=>{let d=Math.max(1,Math.min(120,Number(c.target.value||0)));b({...a,python:{...a.python,timeoutMs:1e3*d}})}})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:"Max Output (chars)"}),(0,d.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:a.python.maxOutputChars,onChange:c=>{let d=Math.max(1e3,Math.min(2e5,Number(c.target.value||0)));b({...a,python:{...a.python,maxOutputChars:d}})}})]}),(0,d.jsxs)("label",{className:"space-y-2 md:col-span-2",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:"Python Command"}),(0,d.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:a.python.pythonCommand,onChange:c=>b({...a,python:{...a.python,pythonCommand:c.target.value}}),placeholder:"python3"}),(0,d.jsxs)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:["本地运行建议保持为 ",(0,d.jsx)("code",{className:"font-mono",children:"python3"}),"。"]})]})]})]})]}),(0,d.jsx)(m.a,{open:C,title:E?`MCP Server \xb7 ${E.name}`:"MCP Server",onClose:()=>D(!1),children:E?(0,d.jsxs)("div",{className:"space-y-4",children:[G?(0,d.jsx)("div",{className:"rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:G}):null,(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"text-xs text-sand",children:"Server ID"}),(0,d.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:E.id,onChange:a=>F({...E,id:a.target.value})})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"text-xs text-sand",children:"Name"}),(0,d.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:E.name,onChange:a=>F({...E,name:a.target.value})})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"text-xs text-sand",children:"Transport"}),(0,d.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:E.transport,onChange:a=>{let b="stdio"===a.target.value?"stdio":"sse"===a.target.value?"sse":"http",c="http"===b?JSON.stringify({url:"http://localhost:3000/mcp",protocolVersion:"2024-11-05"},null,2):"sse"===b?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);F({...E,transport:b,configJson:E.configJson.trim()?E.configJson:c})},children:[(0,d.jsx)("option",{value:"http",children:"streamable http"}),(0,d.jsx)("option",{value:"sse",children:"legacy sse"}),(0,d.jsx)("option",{value:"stdio",children:"stdio"})]})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"text-xs text-sand",children:"Token"}),(0,d.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:E.token,onChange:a=>F({...E,token:a.target.value}),placeholder:"Bearer token (optional)"})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"text-xs text-sand",children:"Config JSON"}),(0,d.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:E.configJson,onChange:a=>F({...E,configJson:a.target.value}),spellCheck:!1}),(0,d.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:"该 JSON 不做校验,运行时直接解析。"})]}),(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/30 bg-shoji-white px-4 py-2 text-sm text-stone-gray",onClick:()=>D(!1),children:"取消"}),(0,d.jsx)("button",{type:"button",className:"rounded-lg bg-matcha-green px-4 py-2 text-sm text-shoji-white",onClick:()=>{if(!E)return;let a=E.id.trim(),b=E.name.trim();a?b?(c({id:a,name:b,transport:E.transport,token:E.token,configJson:E.configJson}),D(!1)):H("Server name is required."):H("Server ID is required.")},children:"保存"})]})]}):null})]})}function F(){return(0,d.jsxs)(f(),{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,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),"返回主页"]})}function G(){(0,h.CU)(a=>a.providers),(0,h.CU)(a=>a.selectedProviderId),(0,h.CU)(a=>a.loadProviders);let a=(0,g.useRef)(null),[b,c]=(0,g.useState)("providers"),e=()=>"providers"===b?(0,d.jsx)(j.ProviderConfig,{}):"models"===b?(0,d.jsx)(z,{}):"general"===b?(0,d.jsx)(A,{}):"display"===b?(0,d.jsx)(B,{}):"tools"===b?(0,d.jsx)(E,{}):"data"===b?(0,d.jsx)(C,{}):"about"===b?(0,d.jsx)(D,{}):(0,d.jsx)(j.ProviderConfig,{}),f="providers"===b||"models"===b;return(0,d.jsxs)("div",{ref:a,className:"fixed inset-0 z-[100] flex bg-shoji-white",style:{height:"100vh",maxHeight:"100vh"},children:[(0,d.jsx)(k.SettingsSidebar,{activeId:b,onSelect:c}),f?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i.ProviderList,{}),e(),(0,d.jsx)(l.ConnectedModelSelector,{})]}):e(),(0,d.jsx)(F,{})]})}},1561:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>f});var d=c(5735),e=c(1190);function f(){return(0,d.jsx)(e.SettingsPage,{})}c(2479),c(7287),c(6325),c(3154)},1569:(a,b,c)=>{"use strict";c.d(b,{SettingsSidebar:()=>h});var d=c(8249),e=c(1098);let f=[{id:"providers",label:"模型服务",labelEn:"Configuration",icon:(0,d.jsx)(e.hp,{})},{id:"models",label:"默认模型",labelEn:"Default Model",icon:(0,d.jsx)(e.GQ,{})},{id:"tools",label:"工具设置",labelEn:"Tools",icon:(0,d.jsx)(e.PX,{})},{id:"general",label:"常规设置",labelEn:"General",icon:(0,d.jsx)(e.yo,{})},{id:"display",label:"显示设置",labelEn:"Display",icon:(0,d.jsx)(e.v1,{})}],g=[{id:"data",label:"数据设置",labelEn:"Data",icon:(0,d.jsx)(e.bN,{})},{id:"about",label:"关于",labelEn:"About",icon:(0,d.jsx)(e.mo,{})}];function h({activeId:a,onSelect:b}){return(0,d.jsxs)("nav",{className:"flex h-full w-[240px] flex-shrink-0 flex-col border-r border-parchment/10 bg-shoji-white",children:[(0,d.jsxs)("div",{className:"border-b border-parchment/10 px-8 py-12",children:[(0,d.jsx)("div",{className:"font-zen-display text-2xl font-light tracking-[0.15em] text-ink-black",children:"設定"}),(0,d.jsx)("div",{className:"mt-1 font-zen-body text-[0.6rem] tracking-[0.2em] text-stone-gray font-light uppercase",children:"Settings"})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-8",children:[{label:"Configuration",items:f},{label:"Data",items:g}].map((c,e)=>(0,d.jsxs)("div",{className:0===e?"mb-8":"",children:[(0,d.jsx)("div",{className:"mb-5 px-3 font-zen-body text-[0.65rem] tracking-[0.25em] text-stone-gray uppercase font-light",children:c.label}),(0,d.jsx)("div",{className:"space-y-1",children:c.items.map((c,e)=>(0,d.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 ${a===c.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*e}s backwards`},onClick:()=>b(c.id),children:[(0,d.jsx)("div",{className:`absolute left-0 top-0 h-full w-0.5 bg-matcha-green transition-transform duration-300 ${a===c.id?"scale-y-100":"scale-y-0"}`}),(0,d.jsx)("span",{className:"flex-shrink-0 text-base opacity-70 group-hover:opacity-100 transition-opacity",children:c.icon}),(0,d.jsx)("span",{className:"font-light tracking-wide",children:c.label})]},c.id))})]},c.label))}),(0,d.jsx)("div",{className:"border-t border-parchment/10 px-8 py-7",children:(0,d.jsx)("div",{className:"font-zen-display text-sm text-stone-gray font-light tracking-[0.1em]",children:"Cortex v1.0.0"})})]})}},2479:(a,b,c)=>{"use strict";c.d(b,{SettingsSidebar:()=>d});let d=(0,c(7943).registerClientReference)(function(){throw Error("Attempted to call SettingsSidebar() from the server but SettingsSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/SettingsSidebar.tsx","SettingsSidebar")},3033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},3154:(a,b,c)=>{"use strict";c.d(b,{ConnectedModelSelector:()=>e});var d=c(7943);(0,d.registerClientReference)(function(){throw Error("Attempted to call ModelSelector() from the server but ModelSelector is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/ModelSelector.tsx","ModelSelector");let e=(0,d.registerClientReference)(function(){throw Error("Attempted to call ConnectedModelSelector() from the server but ConnectedModelSelector is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/ModelSelector.tsx","ConnectedModelSelector")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3873:a=>{"use strict";a.exports=require("path")},3954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},5032:(a,b,c)=>{"use strict";c.d(b,{ProviderConfig:()=>m});var d=c(8249),e=c(7484),f=c(9157),g=c(6684),h=c(1098);function i({apiKey:a,onUpdate:b,onDelete:c,onSetPrimary:f,isPrimary:g}){let[i,j]=(0,e.useState)(!1),k=async()=>{try{await navigator.clipboard.writeText(a.value)}catch{}},l={healthy:"text-matcha-green",error:"text-red-500",checking:"text-kintsugi-gold",unknown:"text-stone-gray"}[a.healthStatus||"unknown"];return(0,d.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,d.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{type:"text",value:a.name||"",onChange:a=>b({name:a.target.value}),placeholder:"API 密钥",className:"w-32 bg-transparent font-zen-body text-sm font-normal text-ink-black outline-none placeholder:text-stone-gray/50"}),g&&(0,d.jsx)("span",{className:"rounded-lg bg-kintsugi-gold/10 px-2 py-1 font-zen-body text-xs text-kintsugi-gold font-light",children:"主密钥"})]}),(0,d.jsx)("div",{className:"flex items-center gap-1",children:(0,d.jsx)("span",{className:`flex-shrink-0 ${l}`,children:"healthy"===a.healthStatus?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10"})}):"error"===a.healthStatus?(0,d.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,d.jsx)("path",{d:"m15 9-6 6m0-6 6 6"})]}):(0,d.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,d.jsx)("path",{d:"M12 6v6l4 2"})]})})})]}),(0,d.jsx)("div",{className:"flex items-center gap-2",children:(0,d.jsxs)("div",{className:"relative flex-1",children:[(0,d.jsx)("input",{type:i?"text":"password",value:a.value,onChange:a=>b({value:a.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,d.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:()=>j(!i),children:i?(0,d.jsx)(h.aR,{}):(0,d.jsx)(h.bM,{})})]})}),(0,d.jsxs)("div",{className:"mt-3 flex items-center justify-between",children:[(0,d.jsx)("div",{className:"flex items-center gap-1",children:!g&&(0,d.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:f,children:"设为主密钥"})}),(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)("button",{type:"button",className:"rounded-lg p-2 text-stone-gray transition-colors hover:text-ink-black",onClick:k,title:"复制",children:(0,d.jsx)(h.Td,{})}),(0,d.jsx)("button",{type:"button",className:"rounded-lg p-2 text-stone-gray transition-colors hover:text-red-500",onClick:c,title:"删除",children:(0,d.jsx)(h.uc,{})})]})]})]})}function j({model:a,onRemove:b,onToggleEnabled:c,onToggleStreaming:e}){let f=a.supportsStreaming??!1;return(0,d.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,d.jsx)("button",{type:"button",className:`flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-lg border transition-all duration-300 ${a.enabled?"border-matcha-green bg-matcha-green text-shoji-white":"border-stone-gray/30 bg-transparent text-transparent hover:border-stone-gray/50"}`,onClick:c,children:(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:(0,d.jsx)("path",{d:"M5 12l6 6 8-8"})})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"font-mono text-sm text-ink-black truncate font-light",children:a.id}),a.name!==a.id&&(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray truncate font-light",children:a.name})]}),(0,d.jsxs)("button",{type:"button",className:`flex items-center gap-1.5 rounded-full border px-3 py-1 text-[0.65rem] transition-all ${f?"border-copper/50 bg-copper/10 text-copper":"border-parchment/40 text-sand hover:border-copper/40 hover:text-ink"}`,onClick:e,children:[(0,d.jsx)("span",{className:`h-2 w-2 rounded-full border ${f?"border-copper bg-copper":"border-parchment/60 bg-transparent"}`}),"流式"]}),(0,d.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:b,children:(0,d.jsx)(h.uc,{})})]})}function k({icon:a,title:b,description:c}){return(0,d.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,d.jsx)("div",{className:"mb-4 rounded-xl bg-shoji-white p-4 text-stone-gray",children:(0,d.jsx)(a,{className:"h-8 w-8"})}),(0,d.jsx)("p",{className:"mb-2 font-zen-body text-sm text-stone-gray font-light",children:b}),(0,d.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:c})]})}function l({open:a,onClose:b,onAdd:c}){let[f,g]=(0,e.useState)(""),[h,i]=(0,e.useState)("");return a?(0,d.jsx)("div",{className:"fixed inset-0 z-[220] flex items-center justify-center bg-ink-black/20 backdrop-blur-sm",children:(0,d.jsxs)("div",{className:"w-full max-w-md rounded-2xl bg-shoji-white p-8 shadow-lg border border-parchment/10",children:[(0,d.jsx)("h3",{className:"mb-6 font-zen-display text-2xl font-light text-ink-black tracking-wide",children:"添加 API 密钥"}),(0,d.jsxs)("form",{onSubmit:a=>{a.preventDefault();let d=h.trim(),e=f.trim();d&&(c(d,e||void 0),b())},children:[(0,d.jsxs)("div",{className:"mb-5",children:[(0,d.jsx)("label",{className:"mb-2 block font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"Key Name"}),(0,d.jsx)("input",{type:"text",value:f,onChange:a=>g(a.target.value),placeholder:"主密钥 / 备用密钥",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,d.jsxs)("div",{className:"mb-6",children:[(0,d.jsx)("label",{className:"mb-2 block font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"API Key"}),(0,d.jsx)("input",{type:"password",value:h,onChange:a=>i(a.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,d.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,d.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:b,children:"取消"}),(0,d.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:"添加"})]})]})]})}):null}function m(){let a=(0,f.CU)(a=>a.providers),b=(0,f.CU)(a=>a.selectedProviderId),c=(0,f.CU)(a=>a.updateProvider),m=(0,f.CU)(a=>a.updateModel),n=(0,f.CU)(a=>a.addApiKey),o=(0,f.CU)(a=>a.updateApiKey),p=(0,f.CU)(a=>a.deleteApiKey),q=(0,f.CU)(a=>a.setPrimaryApiKey),r=(0,f.CU)(a=>a.removeModel),s=(0,f.CU)(a=>a.toggleModelEnabled),t=(0,f.CU)(a=>a.checkProviderHealth),u=(0,f.CU)(a=>a.openModelSelector),[v,w]=(0,e.useState)(""),[x,y]=(0,e.useState)(""),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(!1),[D,E]=(0,e.useState)(null),F=a.find(a=>a.id===b)||null,G=async()=>{if(F){A(!0),E(null);try{await t(F.id)}catch(a){E(a instanceof Error?a.message:"连接失败")}finally{A(!1)}}},H=F?.models.filter(a=>a.enabled)??[],I=F?.models.filter(a=>!a.enabled)??[];return F?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex h-full flex-1 flex-col bg-shoji-white",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between border-b border-parchment/10 px-8 py-8",children:[(0,d.jsxs)("div",{className:"flex items-center gap-4",children:[(0,d.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:F.name.charAt(0).toUpperCase()}),(0,d.jsx)("input",{type:"text",value:v,onChange:a=>{var b;w(b=a.target.value),F&&c(F.id,{name:b})},className:"bg-transparent font-zen-display text-2xl font-light text-ink-black outline-none tracking-wide"})]}),(0,d.jsxs)("div",{className:"flex flex-col items-end gap-2",children:[(0,d.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 ${z?"bg-washi-cream text-stone-gray cursor-wait":"bg-matcha-green/10 text-matcha-green hover:bg-matcha-green/20 font-light"}`,onClick:G,disabled:z,children:z?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(h.fN,{}),"检测中..."]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(h.fN,{}),"检测连接"]})}),D&&(0,d.jsx)("p",{className:"font-zen-body text-xs text-red-500 font-light",children:D})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,d.jsxs)("div",{className:"max-w-3xl px-8 py-8",children:[(0,d.jsxs)("section",{className:"mb-10",children:[(0,d.jsxs)("div",{className:"mb-5 flex items-center gap-3",children:[(0,d.jsx)("div",{className:"rounded-lg bg-washi-cream p-2.5 text-stone-gray",children:(0,d.jsx)(h.RY,{})}),(0,d.jsx)("h3",{className:"font-zen-display text-xl font-light text-ink-black tracking-wide",children:"API 密钥"})]}),(0,d.jsx)("div",{className:"space-y-3",children:F.apiKeys.map(a=>(0,d.jsx)(i,{apiKey:a,onUpdate:b=>o(F.id,a.id,b),onDelete:()=>p(F.id,a.id),onSetPrimary:()=>q(F.id,a.id),isPrimary:a.isPrimary||1===F.apiKeys.length},a.id))}),(0,d.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:()=>{F&&C(!0)},children:[(0,d.jsx)(h.c1,{}),"添加密钥"]})]}),(0,d.jsxs)("section",{className:"mb-10",children:[(0,d.jsxs)("div",{className:"mb-5 flex items-center gap-3",children:[(0,d.jsx)("div",{className:"rounded-lg bg-washi-cream p-2.5 text-stone-gray",children:(0,d.jsx)(h.qY,{})}),(0,d.jsx)("h3",{className:"font-zen-display text-xl font-light text-ink-black tracking-wide",children:"API 地址"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("input",{type:"text",value:x,onChange:a=>{var b;y(b=a.target.value),F&&c(F.id,{baseUrl:(0,g.qT)(b)})},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,d.jsxs)("p",{className:"mt-3 font-zen-body text-xs text-stone-gray font-light",children:["预览: ",(0,g.qT)(x),"/chat/completions"]})]})]}),(0,d.jsxs)("section",{children:[(0,d.jsxs)("div",{className:"mb-5 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"rounded-lg bg-washi-cream p-2.5 text-stone-gray",children:(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,d.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,d.jsx)("path",{d:"M9 9h6v6H9z"})]})}),(0,d.jsx)("h3",{className:"font-zen-display text-xl font-light text-ink-black tracking-wide",children:"模型"}),(0,d.jsx)("span",{className:"rounded-full bg-washi-cream px-3 py-1 font-mono text-xs text-stone-gray font-light",children:F.models.length})]}),(0,d.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:()=>u(F.id),children:[(0,d.jsx)(h.WI,{}),"选择模型"]})]}),0===F.models.length?(0,d.jsx)(k,{icon:a=>(0,d.jsxs)("svg",{...a,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,d.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,d.jsx)("path",{d:"M9 9h6v6H9z"})]}),title:"暂无模型",description:"点击「选择模型」添加"}):(0,d.jsxs)("div",{className:"space-y-6",children:[H.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"mb-3 font-mono text-xs text-stone-gray font-light",children:["已启用 (",H.length,")"]}),(0,d.jsx)("div",{className:"space-y-2",children:H.map(a=>(0,d.jsx)(j,{model:a,onRemove:()=>r(F.id,a.id),onToggleEnabled:()=>s(F.id,a.id),onToggleStreaming:()=>m(F.id,a.id,{supportsStreaming:!a.supportsStreaming})},a.id))})]}),I.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"mb-3 font-mono text-xs text-stone-gray font-light",children:["未启用 (",I.length,")"]}),(0,d.jsx)("div",{className:"space-y-2",children:I.map(a=>(0,d.jsx)(j,{model:a,onRemove:()=>r(F.id,a.id),onToggleEnabled:()=>s(F.id,a.id),onToggleStreaming:()=>m(F.id,a.id,{supportsStreaming:!a.supportsStreaming})},a.id))})]})]})]})]})})]}),(0,d.jsx)(l,{open:B,onClose:()=>C(!1),onAdd:(a,b)=>{F&&n(F.id,a,b)}})]}):(0,d.jsx)("div",{className:"flex h-full flex-1 items-center justify-center bg-shoji-white",children:(0,d.jsx)(k,{icon:a=>(0,d.jsxs)("svg",{...a,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,d.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,d.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,d.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:"请选择或添加一个提供商",description:"从中间列表选择一个提供商来配置"})})}},6325:(a,b,c)=>{"use strict";c.d(b,{ProviderConfig:()=>d});let d=(0,c(7943).registerClientReference)(function(){throw Error("Attempted to call ProviderConfig() from the server but ProviderConfig is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/ProviderConfig.tsx","ProviderConfig")},6439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},6713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},7287:(a,b,c)=>{"use strict";c.d(b,{ProviderList:()=>d});let d=(0,c(7943).registerClientReference)(function(){throw Error("Attempted to call ProviderList() from the server but ProviderList is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/ProviderList.tsx","ProviderList")},7598:a=>{"use strict";a.exports=require("node:crypto")},8231:(a,b,c)=>{Promise.resolve().then(c.bind(c,100)),Promise.resolve().then(c.bind(c,5032)),Promise.resolve().then(c.bind(c,813)),Promise.resolve().then(c.bind(c,1479)),Promise.resolve().then(c.bind(c,1569))},8354:a=>{"use strict";a.exports=require("util")},9121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},9294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")}};var b=require("../../webpack-runtime.js");b.C(a);var c=b.X(0,[445,471,918,368,852],()=>b(b.s=729));module.exports=c})();
1
+ (()=>{var a={};a.id=662,a.ids=[662],a.modules={100:(a,b,c)=>{"use strict";c.d(b,{ConnectedModelSelector:()=>l});var d=c(8249),e=c(7484),f=c(3006),g=c(4995),h=c(2115),i=c(1098);function j({category:a,models:b,selectedIds:c,onToggle:f,onAddSelected:h}){let j=(0,g.k)(),[k,l]=(0,e.useState)(!0);if(0===b.length)return null;let m=b.filter(a=>c.has(a.id)),n=j("chat"===a?"modelCategory.chat":"reasoning"===a?"modelCategory.reasoning":"vision"===a?"modelCategory.vision":"embedding"===a?"modelCategory.embedding":"tool"===a?"modelCategory.tool":"modelCategory.other");return(0,d.jsxs)("div",{className:"mb-3 rounded-xl border border-parchment bg-cream overflow-hidden",children:[(0,d.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:()=>l(!k),children:[(0,d.jsx)("span",{className:`transition-transform duration-200 ${k?"rotate-0":"-rotate-90"}`,children:(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,d.jsx)("path",{d:"m6 9 6 6 6-6"})})}),(0,d.jsx)("span",{className:"flex-1 font-body text-[0.9rem] font-medium text-ink",children:n}),(0,d.jsx)("span",{className:"rounded-full bg-parchment px-2 py-0.5 font-mono text-[0.7rem] text-clay",children:b.length}),m.length>0&&(0,d.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:a=>{a.stopPropagation(),h()},children:j("modelSelector.addCount",{count:m.length})})]}),k&&(0,d.jsx)("div",{className:"border-t border-parchment px-4 pb-3",children:(0,d.jsx)("div",{className:"space-y-1 pt-2",children:b.map(a=>{let b=c.has(a.id);return(0,d.jsxs)("div",{className:`group flex items-center gap-3 rounded-lg px-3 py-2.5 transition-all ${b?"bg-copper/10":"hover:bg-paper/50"}`,children:[(0,d.jsx)("button",{type:"button",className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded border transition-all ${b?"border-copper bg-copper text-white":"border-parchment bg-transparent hover:border-sand"}`,onClick:()=>f(a.id),children:b&&(0,d.jsx)(i.Sr,{})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"font-mono text-[0.85rem] text-ink truncate",children:a.id}),a.name!==a.id&&(0,d.jsx)("div",{className:"font-body text-[0.75rem] text-sand truncate",children:a.name})]})]},a.id)})})})]})}function k({open:a,onClose:b}){let c=(0,g.k)(),k=(0,f.CU)(a=>a.providers),l=(0,f.CU)(a=>a.modelSelector);(0,f.CU)(a=>a.closeModelSelector);let m=(0,f.CU)(a=>a.setModelSelectorSearch),n=(0,f.CU)(a=>a.setModelSelectorTab),o=(0,f.CU)(a=>a.fetchModelsForSelector),p=(0,f.CU)(a=>a.addFetchedModels),[q,r]=(0,e.useState)(new Set),s=k.find(a=>a.id===l.providerId),t=new Set(s?.models.map(a=>a.id)||[]),u=l.fetchedModels.filter(a=>!t.has(a.id)).filter(a=>{let b=!l.searchQuery||a.id.toLowerCase().includes(l.searchQuery.toLowerCase())||a.name.toLowerCase().includes(l.searchQuery.toLowerCase()),c="all"===l.activeTab||a.category===l.activeTab;return b&&c}),v={};for(let a of u){let b=a.category||"chat";v[b]||(v[b]=[]),v[b].push(a)}let w=a=>{r(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})};return a?(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-ink/20 backdrop-blur-sm",onClick:b}),(0,d.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,d.jsxs)("div",{className:"flex items-center justify-between border-b border-parchment px-6 py-4",children:[(0,d.jsxs)("h3",{className:"font-display text-xl text-ink",children:[s?.name||c("modelSelector.providerFallback")," - ",c("modelSelector.models")]}),(0,d.jsx)("button",{type:"button",className:"rounded-lg p-2 text-clay transition-colors hover:text-ink",onClick:b,children:(0,d.jsx)(i.US,{})})]}),(0,d.jsx)("div",{className:"border-b border-parchment px-6 py-4",children:(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsxs)("div",{className:"flex-1 relative",children:[(0,d.jsx)(i.WI,{}),(0,d.jsx)("input",{type:"text",value:l.searchQuery,onChange:a=>m(a.target.value),placeholder:c("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,d.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 ${l.isLoading?"animate-spin":""}`,onClick:()=>{s&&o(s.id)},disabled:l.isLoading,children:(0,d.jsx)(i.fN,{})})]})}),(0,d.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(a=>(0,d.jsx)("button",{type:"button",className:`whitespace-nowrap rounded-lg px-3 py-1.5 font-body text-[0.8rem] transition-all ${l.activeTab===a?"bg-copper text-white":"text-clay hover:bg-cream hover:text-ink"}`,onClick:()=>n(a),children:(a=>{switch(a){case"all":return c("modelCategory.all");case"chat":return c("modelCategory.chat");case"reasoning":return c("modelCategory.reasoning");case"vision":return c("modelCategory.vision");case"embedding":return c("modelCategory.embedding");case"tool":return c("modelCategory.tool");default:return c("modelCategory.other")}})(a)},a))}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:l.isLoading?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,d.jsx)("div",{className:"mb-4 h-8 w-8 animate-spin rounded-full border-2 border-copper border-t-transparent"}),(0,d.jsx)("p",{className:"font-body text-[0.9rem] text-sand",children:c("modelSelector.fetching")})]}):l.error?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,d.jsx)("div",{className:"mb-4 text-red-400",children:(0,d.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,d.jsx)("path",{d:"m15 9-6 6m0-6 6 6"})]})}),(0,d.jsx)("p",{className:"mb-1 font-body text-[0.9rem] text-clay",children:c("modelSelector.fetchFailed")}),(0,d.jsx)("p",{className:"font-body text-[0.8rem] text-sand",children:(0,h.d)(l.error)?c(l.error):l.error})]}):0===u.length?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,d.jsx)("div",{className:"mb-4 text-sand",children:(0,d.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,d.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,d.jsx)("path",{d:"M9 9h6v6H9z"})]})}),(0,d.jsx)("p",{className:"mb-1 font-body text-[0.9rem] text-clay",children:l.searchQuery?c("modelSelector.noMatches"):c("modelSelector.noModels")}),(0,d.jsx)("p",{className:"font-body text-[0.8rem] text-sand",children:l.searchQuery?c("modelSelector.tryOtherQuery"):c("modelSelector.configureApiKey")})]}):(0,d.jsx)("div",{children:Object.entries(v).map(([a,b])=>(0,d.jsx)(j,{category:a,models:b,selectedIds:q,onToggle:w,onAddSelected:()=>{let a=b.filter(a=>q.has(a.id)).map(a=>a.id);a.length>0&&(p(a),a.forEach(a=>q.delete(a)),r(new Set(q)))}},a))})}),q.size>0&&(0,d.jsxs)("div",{className:"flex items-center justify-between border-t border-parchment px-6 py-4",children:[(0,d.jsx)("span",{className:"font-body text-[0.85rem] text-sand",children:c("modelSelector.selectedCount",{count:q.size})}),(0,d.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:()=>{q.size>0&&(p(Array.from(q)),r(new Set))},children:[(0,d.jsx)(i.c1,{}),c("modelSelector.addSelected")]})]})]})]}):null}function l(){let a=(0,f.CU)(a=>a.modelSelector),b=(0,f.CU)(a=>a.closeModelSelector);return(0,d.jsx)(k,{open:a.open,onClose:b})}},261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},729:(a,b,c)=>{"use strict";c.r(b),c.d(b,{GlobalError:()=>C.a,__next_app__:()=>K,handler:()=>M,routeModule:()=>L});var d=c(7553),e=c(4006),f=c(7798),g=c(4775),h=c(9373),i=c(3461),j=c(1020),k=c(6349),l=c(4365),m=c(6023),n=c(3747),o=c(4235),p=c(3938),q=c(261),r=c(6758),s=c(7243),t=c(6713),u=c(7527),v=c(2820),w=c(8216),x=c(7929),y=c(9551),z=c(9125),A=c(6439),B=c(5547),C=c.n(B),D=c(1287),E=c(1494),F=c(722),G=c(753),H=c(3954),I={};for(let a in D)0>["default","GlobalError","__next_app__","routeModule","handler"].indexOf(a)&&(I[a]=()=>D[a]);c.d(b,I);let J={children:["",{children:["settings",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,1561)),"/Users/yxp/Documents/new-chat/ai-chat-client/src/app/settings/page.tsx"]}]},{metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(c.bind(c,6537)),"/Users/yxp/Documents/new-chat/ai-chat-client/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.t.bind(c,5547,23)),"next/dist/client/components/builtin/global-error.js"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,5091,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,5270,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,8193,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]}.children,K={require:c,loadChunk:()=>Promise.resolve()},L=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/settings/page",pathname:"/settings",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:J},distDir:".next",relativeProjectDir:""});async function M(a,b,d){var B;L.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let I=!!(0,h.getRequestMeta)(a,"minimalMode"),N="/settings/page";"/index"===N&&(N="/");let O=await L.prepare(a,b,{srcPage:N,multiZoneDraftMode:!1});if(!O)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:P,query:Q,params:R,pageIsDynamic:S,buildManifest:T,nextFontManifest:U,reactLoadableManifest:V,serverActionsManifest:W,clientReferenceManifest:X,subresourceIntegrityManifest:Y,prerenderManifest:Z,isDraftMode:$,resolvedPathname:_,revalidateOnlyGenerated:aa,routerServerContext:ab,nextConfig:ac,parsedUrl:ad,interceptionRoutePatterns:ae,deploymentId:af}=O,ag=(0,q.normalizeAppPath)(N),{isOnDemandRevalidate:ah}=O,ai=ac.experimental.ppr&&!ac.cacheComponents&&(0,H.isInterceptionRouteAppPath)(_)?null:L.match(_,Z),aj=!!Z.routes[_],ak=a.headers["user-agent"]||"",al=(0,t.getBotType)(ak),am=(0,p.isHtmlBotRequest)(a),an=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[s.NEXT_ROUTER_PREFETCH_HEADER],ao=(0,h.getRequestMeta)(a,"isRSCRequest")??!!a.headers[s.RSC_HEADER],ap=(0,r.getIsPossibleServerAction)(a),aq=(0,m.checkIsAppPPREnabled)(ac.experimental.ppr);if(!(0,h.getRequestMeta)(a,"postponed")&&aq&&"1"===a.headers[x.NEXT_RESUME_HEADER]&&"POST"===a.method){let b=[];for await(let c of a)b.push(c);let c=Buffer.concat(b).toString("utf8");(0,h.addRequestMeta)(a,"postponed",c)}let ar=aq&&(null==(B=Z.routes[ag]??Z.dynamicRoutes[ag])?void 0:B.renderingMode)==="PARTIALLY_STATIC",as=!1,at=!1,au=ar?(0,h.getRequestMeta)(a,"postponed"):void 0,av=ar&&ao&&!an;I&&(av=av&&!!au);let aw=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),ax=(!am||!ar)&&(!ak||(0,p.shouldServeStreamingMetadata)(ak,ac.htmlLimitedBots)),ay=!!((ai||aj||Z.routes[ag])&&!(am&&ar)),az=ar&&!0===ac.cacheComponents,aA=!0===L.isDev||!ay||"string"==typeof au||(az&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?av&&!I:av),aB=am&&ar,aC=null;$||!ay||aA||ap||au||av||(aC=_);let aD=aC;!aD&&L.isDev&&(aD=_),L.isDev||$||!ay||!ao||av||(0,k.d)(a.headers);let aE={...D,tree:J,GlobalError:C(),handler:M,routeModule:L,__next_app__:K};W&&X&&(0,o.setManifestsSingleton)({page:N,clientReferenceManifest:X,serverActionsManifest:W});let aF=a.method||"GET",aG=(0,g.getTracer)(),aH=aG.getActiveScopeSpan(),aI=async()=>((null==ab?void 0:ab.render404)?await ab.render404(a,b,ad,!1):b.end("This page could not be found"),null);try{let f=L.getVaryHeader(_,ae);b.setHeader("Vary",f);let k=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return L.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aG.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aF} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a)}else c.updateName(`${aF} ${N}`)})},m=(0,h.getRequestMeta)(a,"incrementalCache"),o=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let l={query:Q,params:R,page:ag,sharedContext:{buildId:P},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aE,Component:(0,j.T)(aE),params:R,routeModule:L,page:N,postponed:f,shouldWaitOnAllReady:aB,serveStreamingMetadata:ax,supportsDynamicResponse:"string"==typeof f||aA,buildManifest:T,nextFontManifest:U,reactLoadableManifest:V,subresourceIntegrityManifest:Y,setCacheStatus:null==ab?void 0:ab.setCacheStatus,setIsrStatus:null==ab?void 0:ab.setIsrStatus,setReactDebugChannel:null==ab?void 0:ab.setReactDebugChannel,sendErrorsToBrowser:null==ab?void 0:ab.sendErrorsToBrowser,dir:c(3873).join(process.cwd(),L.relativeProjectDir),isDraftMode:$,botType:al,isOnDemandRevalidate:ah,isPossibleServerAction:ap,assetPrefix:ac.assetPrefix,nextConfigOutput:ac.output,crossOrigin:ac.crossOrigin,trailingSlash:ac.trailingSlash,images:ac.images,previewProps:Z.preview,deploymentId:af,enableTainting:ac.experimental.taint,htmlLimitedBots:ac.htmlLimitedBots,reactMaxHeadersLength:ac.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:m,cacheLifeProfiles:ac.cacheLife,basePath:ac.basePath,serverActions:ac.experimental.serverActions,...as||at?{nextExport:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:as}:{},cacheComponents:!!ac.cacheComponents,experimental:{isRoutePPREnabled:ar,expireTime:ac.expireTime,staleTimes:ac.experimental.staleTimes,dynamicOnHover:!!ac.experimental.dynamicOnHover,inlineCss:!!ac.experimental.inlineCss,authInterrupts:!!ac.experimental.authInterrupts,clientTraceMetadata:ac.experimental.clientTraceMetadata||[],clientParamParsingOrigins:ac.experimental.clientParamParsingOrigins},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>L.onRequestError(a,b,d,e,ab),err:(0,h.getRequestMeta)(a,"invokeError"),dev:L.isDev}};as&&(l.renderOpts.nextExport=!0,l.renderOpts.supportsDynamicResponse=!1,l.renderOpts.isDebugDynamicAccesses=as),i&&(l.renderOpts.supportsDynamicResponse=!1);let n=await k(e,l),{metadata:o}=n,{cacheControl:p,headers:q={},fetchTags:r,fetchMetrics:s}=o;if(r&&(q[x.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,ay&&(null==p?void 0:p.revalidate)===0&&!L.isDev&&!ar){let a=o.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${_}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
2
+ see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:u.CachedRouteKind.APP_PAGE,html:n,headers:q,rscData:o.flightData,postponed:o.postponed,status:o.statusCode,segmentData:o.segmentData},cacheControl:p}},p=async({hasResolved:c,previousCacheEntry:f,isRevalidating:g,span:i,forceStaticRender:j=!1})=>{let k,l=!1===L.isDev,q=c||b.writableEnded;if(ah&&aa&&!f&&!I)return(null==ab?void 0:ab.render404)?await ab.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(ai&&(k=(0,v.parseFallbackField)(ai.fallback)),k===v.FallbackMode.PRERENDER&&(0,t.isBot)(ak)&&(!ar||am)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),(null==f?void 0:f.isStale)===-1&&(ah=!0),ah&&(k!==v.FallbackMode.NOT_FOUND||f)&&(k=v.FallbackMode.BLOCKING_STATIC_RENDER),!I&&k!==v.FallbackMode.BLOCKING_STATIC_RENDER&&aD&&!q&&!$&&S&&(l||!aj)){if((l||ai)&&k===v.FallbackMode.NOT_FOUND){if(ac.experimental.adapterPath)return await aI();throw new A.NoFallbackError}if(ar&&(ac.cacheComponents?!av:!ao)){let b=l&&"string"==typeof(null==ai?void 0:ai.fallback)?ai.fallback:ag,c=l&&(null==ai?void 0:ai.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ai.fallbackRouteParams):at?(0,n.getFallbackRouteParams)(ag,L):null,f=await L.handleResponse({cacheKey:b,req:a,nextConfig:ac,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:Z,isRoutePPREnabled:ar,responseGenerator:async()=>o({span:i,postponed:void 0,fallbackRouteParams:c,forceStaticRender:!1}),waitUntil:d.waitUntil,isMinimalMode:I});if(null===f)return null;if(f)return delete f.cacheControl,f}}let r=ah||g||!au?void 0:au;if(az&&!I&&m&&av&&!j){let b=await m.get(_,{kind:u.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===u.CachedRouteKind.APP_PAGE&&(r=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,G.scheduleOnNextTick)(async()=>{let b=L.getResponseCache(a);try{await b.revalidate(_,m,ar,!1,a=>p({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if(as&&void 0!==r)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:u.CachedRouteKind.PAGES,html:w.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let s=l&&(null==ai?void 0:ai.fallbackRouteParams)&&(0,h.getRequestMeta)(a,"renderFallbackShell")?(0,n.createOpaqueFallbackRouteParams)(ai.fallbackRouteParams):at?(0,n.getFallbackRouteParams)(ag,L):null;return o({span:i,postponed:r,fallbackRouteParams:s,forceStaticRender:j})},q=async c=>{var f,g,i,j,k;let l,m=await L.handleResponse({cacheKey:aC,responseGenerator:a=>p({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ah,isRoutePPREnabled:ar,req:a,nextConfig:ac,prerenderManifest:Z,waitUntil:d.waitUntil,isMinimalMode:I});if($&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),L.isDev&&b.setHeader("Cache-Control","no-store, must-revalidate"),!m){if(aC)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=m.value)?void 0:f.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=m.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let n="string"==typeof m.value.postponed;ay&&!av&&(!n||an)&&(I||b.setHeader("x-nextjs-cache",ah?"REVALIDATED":m.isMiss?"MISS":m.isStale?"STALE":"HIT"),b.setHeader(s.NEXT_IS_PRERENDER_HEADER,"1"));let{value:q}=m;if(au)l={revalidate:0,expire:void 0};else if(av)l={revalidate:0,expire:void 0};else if(!L.isDev)if($)l={revalidate:0,expire:void 0};else if(ay){if(m.cacheControl)if("number"==typeof m.cacheControl.revalidate){if(m.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${m.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:m.cacheControl.revalidate,expire:(null==(j=m.cacheControl)?void 0:j.expire)??ac.expireTime}}else l={revalidate:x.CACHE_ONE_YEAR,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(m.cacheControl=l,"string"==typeof aw&&(null==q?void 0:q.kind)===u.CachedRouteKind.APP_PAGE&&q.segmentData){b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=q.headers)?void 0:k[x.NEXT_CACHE_TAGS_HEADER];I&&ay&&c&&"string"==typeof c&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,c);let d=q.segmentData.get(aw);return void 0!==d?(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:w.default.fromStatic(d,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl}):(b.statusCode=204,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl}))}let r=az?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(r&&await r(m,{url:(0,h.getRequestMeta)(a,"initURL")??a.url}))return null;if(q.headers){let a={...q.headers};for(let[c,d]of(I&&ay||delete a[x.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let t=null==(g=q.headers)?void 0:g[x.NEXT_CACHE_TAGS_HEADER];if(I&&ay&&t&&"string"==typeof t&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,t),!q.status||ao&&ar||(b.statusCode=q.status),!I&&q.status&&E.RedirectStatusCode[q.status]&&ao&&(b.statusCode=200),n&&!av&&b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"1"),ao&&!$){if(void 0===q.rscData){if(q.html.contentType!==s.RSC_CONTENT_TYPE_HEADER)if(ac.cacheComponents)return b.statusCode=404,(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl});else throw Object.defineProperty(new F.InvariantError(`Expected RSC response, got ${q.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:q.html,cacheControl:m.cacheControl})}return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:w.default.fromStatic(q.rscData,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl})}let v=q.html;if(!n||I||ao)return(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:v,cacheControl:m.cacheControl});if(as)return v.push(new ReadableStream({start(a){a.enqueue(y.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}});let A=new TransformStream;return v.push(A.readable),o({span:c,postponed:q.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(A.writable)}).catch(a=>{A.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,z.sendRenderResult)({req:a,res:b,generateEtags:ac.generateEtags,poweredByHeader:ac.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})};if(!aH)return await aG.withPropagatedContext(a.headers,()=>aG.trace(i.BaseServerSpan.handleRequest,{spanName:`${aF} ${N}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aF,"http.target":a.url}},q));await q(aH)}catch(b){throw b instanceof A.NoFallbackError||await L.onRequestError(a,b,{routerKind:"App Router",routePath:N,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:ay,isOnDemandRevalidate:ah})},!1,ab),b}}},813:(a,b,c)=>{"use strict";c.d(b,{ProviderList:()=>m});var d=c(8249),e=c(7484),f=c(3006),g=c(4995),h=c(1098);function i({name:a}){let b=a.trim().charAt(0).toUpperCase(),c=["bg-matcha-green","bg-kintsugi-gold","bg-stone-gray"],e=a.charCodeAt(0)%c.length,f=c[e];return(0,d.jsx)("div",{className:`flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg ${f} text-shoji-white text-lg font-medium shadow-sm`,children:b})}function j({enabled:a,onToggle:b}){return(0,d.jsx)("button",{type:"button",className:`relative flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-all duration-300 ${a?"bg-matcha-green":"bg-stone-gray/30"}`,onClick:a=>{a.stopPropagation(),b()},"aria-pressed":a,children:(0,d.jsx)("span",{className:`block h-4.5 w-4.5 transform rounded-full bg-white shadow-sm transition-all duration-300 ${a?"translate-x-6":"translate-x-0.5"}`})})}function k({provider:a,isActive:b,onSelect:c,onToggle:e,onDelete:f}){let k=(0,g.k)();return(0,d.jsx)("div",{className:`group relative mb-2 cursor-pointer rounded-xl p-4 transition-all duration-300 ${b?"bg-washi-cream/70 border border-matcha-green/20 shadow-sm":"hover:bg-washi-cream/30 border border-transparent"}`,onClick:c,role:"button",tabIndex:0,onKeyDown:a=>"Enter"===a.key&&c(),children:(0,d.jsxs)("div",{className:"flex w-full items-center gap-4 text-left",children:[(0,d.jsx)(i,{name:a.name}),(0,d.jsx)("span",{className:"flex-1 truncate font-zen-body text-sm font-normal text-ink-black",children:a.name}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(j,{enabled:a.enabled,onToggle:e}),(0,d.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:a=>{a.stopPropagation(),f()},"aria-label":k("providers.deleteAria"),children:(0,d.jsx)(h.uc,{})})]})]})})}function l({open:a,onClose:b,onAdd:c}){let f=(0,g.k)(),[h,i]=(0,e.useState)("");return a?(0,d.jsx)("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-ink-black/20 backdrop-blur-sm",children:(0,d.jsxs)("div",{className:"w-full max-w-md rounded-2xl bg-shoji-white p-8 shadow-lg border border-parchment/10",children:[(0,d.jsx)("h3",{className:"mb-6 font-zen-display text-2xl font-light text-ink-black tracking-wide",children:f("providers.dialog.title")}),(0,d.jsxs)("form",{onSubmit:a=>{a.preventDefault();let d=h.trim();d&&(c(d),i(""),b())},children:[(0,d.jsxs)("div",{className:"mb-6",children:[(0,d.jsx)("label",{className:"mb-3 block font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:f("providers.dialog.nameLabel")}),(0,d.jsx)("input",{type:"text",value:h,onChange:a=>i(a.target.value),placeholder:f("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,d.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,d.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:b,children:f("common.cancel")}),(0,d.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:f("common.add")})]})]})]})}):null}function m(){let a=(0,g.k)(),b=(0,f.CU)(a=>a.providers),c=(0,f.CU)(a=>a.selectedProviderId),i=(0,f.CU)(a=>a.selectProvider),j=(0,f.CU)(a=>a.toggleProviderEnabled),m=(0,f.CU)(a=>a.deleteProvider),n=(0,f.CU)(a=>a.addProvider),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(!1);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex h-full w-[320px] flex-shrink-0 flex-col border-r border-parchment/10 bg-washi-cream/50",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between border-b border-parchment/10 px-6 py-6",children:[(0,d.jsx)("div",{className:"font-zen-display text-xl font-normal text-ink-black tracking-wide",children:a("providers.title")}),(0,d.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:q?b.length:"-"})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-6",children:0===b.length?(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,d.jsx)("div",{className:"mb-4 rounded-2xl bg-washi-cream/50 p-6 text-stone-gray",children:(0,d.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",className:"mx-auto",children:[(0,d.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,d.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,d.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,d.jsx)("p",{className:"mb-2 font-zen-body text-sm text-stone-gray font-light",children:a("providers.empty.title")}),(0,d.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:a("providers.empty.description")})]}):b.map((a,b)=>(0,d.jsx)("div",{style:{animation:`slideInUp 0.5s ease-out ${.05*b}s backwards`},children:(0,d.jsx)(k,{provider:a,isActive:c===a.id,onSelect:()=>i(a.id),onToggle:()=>j(a.id),onDelete:()=>m(a.id)})},a.id))}),(0,d.jsx)("div",{className:"border-t border-parchment/10 p-5",children:(0,d.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:()=>p(!0),children:[(0,d.jsx)(h.c1,{}),a("providers.add")]})})]}),(0,d.jsx)(l,{open:o,onClose:()=>p(!1),onAdd:a=>n(a)})]})}},846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},1025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},1098:(a,b,c)=>{"use strict";c.d(b,{GQ:()=>f,PX:()=>k,RY:()=>r,Sr:()=>p,Td:()=>s,US:()=>q,WI:()=>n,aR:()=>v,bM:()=>u,bN:()=>i,c1:()=>l,fN:()=>o,hp:()=>e,mo:()=>j,qY:()=>t,uc:()=>m,v1:()=>g,yo:()=>h});var d=c(8249);function e(){return(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.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,d.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,d.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 f(){return(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,d.jsx)("path",{d:"M9 9h6v6H9z"}),(0,d.jsx)("path",{d:"M9 1v3"}),(0,d.jsx)("path",{d:"M15 1v3"}),(0,d.jsx)("path",{d:"M9 20v3"}),(0,d.jsx)("path",{d:"M15 20v3"}),(0,d.jsx)("path",{d:"M20 9h3"}),(0,d.jsx)("path",{d:"M20 15h3"}),(0,d.jsx)("path",{d:"M1 9h3"}),(0,d.jsx)("path",{d:"M1 15h3"})]})}function g(){return(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("circle",{cx:"13.5",cy:"6.5",r:"0.5",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"17.5",cy:"10.5",r:"0.5",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"8.5",cy:"7.5",r:"0.5",fill:"currentColor"}),(0,d.jsx)("circle",{cx:"6.5",cy:"12.5",r:"0.5",fill:"currentColor"}),(0,d.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 h(){return(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),(0,d.jsx)("path",{d:"M8 21h8"}),(0,d.jsx)("path",{d:"M12 17v4"})]})}function i(){return(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),(0,d.jsx)("path",{d:"M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"}),(0,d.jsx)("path",{d:"M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"})]})}function j(){return(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,d.jsx)("path",{d:"M12 16v-4"}),(0,d.jsx)("path",{d:"M12 8h.01"})]})}function k(){return(0,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.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 l(){return(0,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M12 5v14M5 12h14"})})}function m(){return(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.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 n(){return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,d.jsx)("path",{d:"m21 21-4.35-4.35"})]})}function o(){return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,d.jsx)("path",{d:"M3 3v5h5"}),(0,d.jsx)("path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"}),(0,d.jsx)("path",{d:"M16 16h5v5"})]})}function p(){return(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M20 6 9 17l-5-5"})})}function q(){return(0,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M18 6 6 18M6 6l12 12"})})}function r(){return(0,d.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.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 s(){return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),(0,d.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 t(){return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.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,d.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 u(){return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),(0,d.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}function v(){return(0,d.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,d.jsx)("path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}),(0,d.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,d.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,d.jsx)("line",{x1:"2",x2:"22",y1:"2",y2:"22"})]})}},1190:(a,b,c)=>{"use strict";c.d(b,{SettingsPage:()=>e});var d=c(7943);let e=(0,d.registerClientReference)(function(){throw Error("Attempted to call SettingsPage() from the server but SettingsPage is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/SettingsPage.tsx","SettingsPage");(0,d.registerClientReference)(function(){throw Error("Attempted to call the default export of \"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/SettingsPage.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/SettingsPage.tsx","default")},1279:(a,b,c)=>{Promise.resolve().then(c.bind(c,3154)),Promise.resolve().then(c.bind(c,6325)),Promise.resolve().then(c.bind(c,7287)),Promise.resolve().then(c.bind(c,1190)),Promise.resolve().then(c.bind(c,2479))},1479:(a,b,c)=>{"use strict";c.d(b,{SettingsPage:()=>H});var d=c(8249),e=c(2116),f=c.n(e),g=c(7484),h=c(3006),i=c(4995),j=c(813),k=c(5032),l=c(1569),m=c(100),n=c(2815),o=c(518),p=c(318),q=c(7440),r=c(5951),s=c(8655),t=c(6684),u=c(1879),v=c(7872),w=c(1098);function x(a){return"object"==typeof a&&null!==a}function y({title:a,description:b,action:c,children:e}){return(0,d.jsxs)("div",{className:"flex h-full flex-1 flex-col bg-shoji-white",children:[(0,d.jsx)("div",{className:"border-b border-parchment/10 px-8 py-8",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h2",{className:"font-zen-display text-2xl font-light text-ink-black tracking-wide",children:a}),b&&(0,d.jsx)("p",{className:"mt-2 max-w-xl font-zen-body text-sm text-stone-gray font-light",children:b})]}),c]})}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,d.jsx)("div",{className:"max-w-3xl px-8 py-8",children:e})})]})}function z({title:a,description:b}){return(0,d.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,d.jsx)("div",{className:"mb-4 rounded-xl bg-shoji-white p-4 text-stone-gray",children:(0,d.jsxs)("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,d.jsx)("path",{d:"M12 16v-4"}),(0,d.jsx)("path",{d:"M12 8h.01"})]})}),(0,d.jsx)("p",{className:"mb-2 font-zen-body text-sm text-stone-gray font-light",children:a}),(0,d.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:b})]})}function A(){let a=(0,i.k)(),b=(0,h.CU)(a=>a.providers),c=(0,h.CU)(a=>a.compressionModel),e=(0,h.CU)(a=>a.summaryModel),f=(0,h.CU)(a=>a.setLLMSettings),j=(0,h.CU)(a=>a.selectedModels),k=(0,h.CU)(a=>a.setSelectedModels),[l,m]=(0,g.useState)("idle"),[n,o]=(0,g.useState)(null),[p,q]=(0,g.useState)(null),r=(0,g.useMemo)(()=>(0,s.n)(b),[b]),u=(0,g.useMemo)(()=>new Set(j.map(s.R)),[j]),x=(0,g.useMemo)(()=>{let a=new Map;for(let b of r)a.has(b.providerId)||a.set(b.providerId,{providerId:b.providerId,providerName:b.providerName,models:[]}),a.get(b.providerId).models.push(b);return Array.from(a.values()).sort((a,b)=>a.providerName.localeCompare(b.providerName))},[r]),A=a=>({providerId:a.providerId,modelId:a.modelId}),B=async()=>{let c=j[0];if(!c){m("error"),o(a("settings.defaultModel.test.selectModelFirst"));return}let d=b.find(a=>a.id===c.providerId)??null;if(!d){m("error"),o(a("settings.defaultModel.test.providerMissing"));return}let e=(0,v.aA)(d);if(!e){m("error"),o(a("errors.missingApiKey"));return}m("running"),o(null),q(null);let f=await (0,t.DT)(e.value,d.baseUrl,c.modelId,{headers:d.headers,timeout:d.timeout,prompt:"ping"});if(q(f.responseTime??null),"healthy"===f.status){m("success"),o(f.content||a("settings.defaultModel.test.success"));return}m("error"),o(f.error||a("settings.defaultModel.test.failed"))},C=c?(0,s.R)(c):"",D=e?(0,s.R)(e):"";return(0,d.jsx)(y,{title:a("settings.defaultModel.title"),description:a("settings.defaultModel.description"),children:(0,d.jsxs)("div",{className:"space-y-8",children:[(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:a("settings.defaultModel.enabledModels.title")}),(0,d.jsx)("p",{className:"mt-2 font-zen-body text-sm text-stone-gray font-light",children:a("settings.defaultModel.enabledModels.description")})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.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:()=>{k(r.map(a=>A(a)))},disabled:0===r.length,children:a("common.selectAll")}),(0,d.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:()=>{k([])},disabled:0===j.length,children:a("common.clear")})]})]}),0===r.length?(0,d.jsx)("div",{className:"mt-6",children:(0,d.jsx)(z,{title:a("settings.defaultModel.enabledModels.emptyTitle"),description:a("settings.defaultModel.enabledModels.emptyDescription")})}):(0,d.jsx)("div",{className:"mt-6 space-y-6",children:x.map(a=>(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"mb-3 font-zen-body text-xs text-stone-gray font-light",children:a.providerName}),(0,d.jsx)("div",{className:"space-y-2",children:a.models.map(a=>{let b=u.has((0,s.R)(a));return(0,d.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 ${b?"border-matcha-green/40 bg-matcha-green/10":"border-parchment/20 bg-shoji-white hover:border-matcha-green/30"}`,onClick:()=>{let b;return b=(0,s.R)(a),void k(u.has(b)?j.filter(a=>(0,s.R)(a)!==b):[...j,A(a)])},children:[(0,d.jsx)("span",{className:`flex h-5 w-5 items-center justify-center rounded border text-[0.7rem] ${b?"border-matcha-green bg-matcha-green text-shoji-white":"border-parchment bg-transparent text-transparent"}`,children:"✓"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("div",{className:"font-mono text-sm text-ink-black",children:a.modelId}),(0,d.jsx)("div",{className:"text-xs text-stone-gray font-light",children:a.label})]})]},a.modelId)})})]},a.providerId))})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsx)("div",{className:"mb-3 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:a("settings.defaultModel.compressionModel.title")}),(0,d.jsxs)("select",{value:C,onChange:a=>{var b;let c;return b=a.target.value,void f({compressionModel:(c=r.find(a=>(0,s.R)(a)===b))?A(c):null,...c?{model:c.modelId}:{}})},disabled:0===r.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,d.jsx)("option",{value:"",children:a("settings.defaultModel.compressionModel.placeholder")}),r.map(a=>(0,d.jsx)("option",{value:(0,s.R)(a),children:a.label},`${a.providerId}-${a.modelId}`))]}),(0,d.jsx)("p",{className:"mt-3 font-zen-body text-xs text-stone-gray font-light",children:a("settings.defaultModel.compressionModel.description")})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsx)("div",{className:"mb-3 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:a("settings.defaultModel.summaryModel.title")}),(0,d.jsxs)("select",{value:D,onChange:a=>{var b;let c;return b=a.target.value,void f({summaryModel:(c=r.find(a=>(0,s.R)(a)===b))?A(c):null})},disabled:0===r.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,d.jsx)("option",{value:"",children:a("settings.defaultModel.summaryModel.placeholder")}),r.map(a=>(0,d.jsx)("option",{value:(0,s.R)(a),children:a.label},`${a.providerId}-${a.modelId}`))]}),(0,d.jsx)("p",{className:"mt-3 font-zen-body text-xs text-stone-gray font-light",children:a("settings.defaultModel.summaryModel.description")})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:a("settings.defaultModel.test.title")}),null!==p&&(0,d.jsx)("div",{className:"mt-2 font-mono text-xs text-stone-gray",children:a("settings.defaultModel.test.latency",{ms:p})})]}),(0,d.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"===l?"bg-washi-cream text-stone-gray cursor-wait":"bg-matcha-green/10 text-matcha-green hover:bg-matcha-green/20 font-light"}`,onClick:B,disabled:"running"===l||0===j.length,children:"running"===l?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(w.fN,{}),a("settings.defaultModel.test.running")]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(w.Sr,{}),a("settings.defaultModel.test.button")]})})]}),n&&(0,d.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"}[l]}`,children:n})]})]})})}function B(){let a=(0,i.k)(),b=(0,h.CU)(a=>a.temperature),c=(0,h.CU)(a=>a.maxTokens),e=(0,h.CU)(a=>a.setLLMSettings),[f,j]=(0,g.useState)(""),[k,l]=(0,g.useState)(q.rd),[m,n]=(0,g.useState)(b.toString()),[o,r]=(0,g.useState)(c.toString()),[s,t]=(0,g.useState)(!1),[u,v]=(0,g.useState)(null);return(0,d.jsx)(y,{title:a("settings.general.title"),description:a("settings.general.description"),children:(0,d.jsxs)("div",{className:"space-y-8",children:[(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsx)("div",{className:"mb-4 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:a("settings.general.api.title")}),(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"mb-2 block font-zen-body text-xs text-stone-gray font-light",children:a("settings.general.api.apiKeyLabel")}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("input",{type:s?"text":"password",value:f,onChange:a=>j(a.target.value),placeholder:"sk-...",className:"w-full rounded-xl border border-parchment/20 bg-shoji-white px-5 py-4 pr-10 font-mono text-sm text-ink-black outline-none transition-all duration-300 focus:border-matcha-green/50"}),(0,d.jsx)("button",{type:"button",className:"absolute right-4 top-1/2 -translate-y-1/2 text-stone-gray transition-colors hover:text-ink-black",onClick:()=>t(a=>!a),children:s?(0,d.jsx)(w.aR,{}):(0,d.jsx)(w.bM,{})})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"mb-2 block font-zen-body text-xs text-stone-gray font-light",children:a("settings.general.api.baseUrlLabel")}),(0,d.jsx)("input",{type:"text",value:k,onChange:a=>l(a.target.value),placeholder:q.rd,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"})]})]})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsx)("div",{className:"mb-4 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:a("settings.general.generation.title")}),(0,d.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"mb-2 block font-zen-body text-xs text-stone-gray font-light",children:a("settings.general.generation.temperature")}),(0,d.jsx)("input",{type:"number",min:"0",max:"2",step:"0.1",value:m,onChange:a=>n(a.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,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"mb-2 block font-zen-body text-xs text-stone-gray font-light",children:a("settings.general.generation.maxTokens")}),(0,d.jsx)("input",{type:"number",min:"1",value:o,onChange:a=>r(a.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,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:u??a("settings.general.saveHint")}),(0,d.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 d=Number.parseFloat(m),g=Number.parseInt(o,10),h={temperature:Number.isFinite(d)?d:b,maxTokens:Number.isFinite(g)?g:c};(0,p.YA)(f),(0,q.$t)(k),e(h),v(a("settings.general.saved")),setTimeout(()=>v(null),2e3)},children:a("settings.general.saveButton")})]})]})})}function C(){let a=(0,i.k)(),b=(0,h.CU)(a=>a.theme),c=(0,h.CU)(a=>a.setTheme),e=(0,h.CU)(a=>a.locale),f=(0,h.CU)(a=>a.setLocale),g=[{id:"light",label:a("settings.display.theme.light"),description:a("settings.display.theme.lightDesc")},{id:"dark",label:a("settings.display.theme.dark"),description:a("settings.display.theme.darkDesc")}],j=[{id:"en",label:a("settings.display.language.en"),description:a("settings.display.language.enDesc")},{id:"zh-CN",label:a("settings.display.language.zhCN"),description:a("settings.display.language.zhCNDesc")}];return(0,d.jsx)(y,{title:a("settings.display.title"),description:a("settings.display.description"),children:(0,d.jsxs)("div",{className:"space-y-8",children:[(0,d.jsxs)("section",{children:[(0,d.jsx)("div",{className:"mb-4 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:a("settings.display.theme")}),(0,d.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:g.map(a=>(0,d.jsxs)("button",{type:"button",className:`rounded-2xl border px-6 py-5 text-left transition-all duration-300 ${b===a.id?"border-matcha-green/40 bg-matcha-green/10":"border-parchment/20 bg-washi-cream/50 hover:border-matcha-green/40"}`,onClick:()=>c(a.id),children:[(0,d.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:a.label}),(0,d.jsx)("div",{className:"mt-2 font-zen-body text-xs text-stone-gray font-light",children:a.description})]},a.id))})]}),(0,d.jsxs)("section",{children:[(0,d.jsx)("div",{className:"mb-4 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:a("settings.display.language")}),(0,d.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:j.map(a=>(0,d.jsxs)("button",{type:"button",className:`rounded-2xl border px-6 py-5 text-left transition-all duration-300 ${e===a.id?"border-matcha-green/40 bg-matcha-green/10":"border-parchment/20 bg-washi-cream/50 hover:border-matcha-green/40"}`,onClick:()=>f(a.id),children:[(0,d.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:a.label}),(0,d.jsx)("div",{className:"mt-2 font-zen-body text-xs text-stone-gray font-light",children:a.description})]},a.id))})]})]})})}function D(){let a=(0,i.k)(),b=(0,h.CU)(a=>a.setLLMSettings),c=(0,h.CU)(a=>a.setTheme),[e,f]=(0,g.useState)(!1),[j,k]=(0,g.useState)(!1),[l,m]=(0,g.useState)(!1),[n,s]=(0,g.useState)(!1),[t,v]=(0,g.useState)(null),w=async()=>{f(!0),v(null);try{await (0,o.MR)(),v(a("settings.data.clear.success")),setTimeout(()=>window.location.reload(),800)}catch(b){v(b instanceof Error?b.message:a("settings.data.clear.failed")),f(!1)}},x=async()=>{k(!0),v(null);try{(0,p.YA)(""),(0,q.$t)(""),(0,u.Ny)(),(0,u.k8)(),b(r.ES),c("light"),v(a("settings.data.reset.success")),setTimeout(()=>window.location.reload(),800)}catch(b){v(b instanceof Error?b.message:a("settings.data.reset.failed")),k(!1)}};return(0,d.jsx)(y,{title:a("settings.data.title"),description:a("settings.data.description"),children:(0,d.jsxs)("div",{className:"space-y-6",children:[(0,d.jsx)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:a("settings.data.clear.title")}),(0,d.jsx)("p",{className:"mt-2 font-zen-body text-xs text-stone-gray font-light",children:a("settings.data.clear.description")})]}),l?(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("button",{type:"button",className:"rounded-lg bg-red-500 px-4 py-2 text-sm text-white",onClick:w,disabled:e,children:e?a("settings.data.clear.running"):a("settings.data.clear.confirm")}),(0,d.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/30 px-4 py-2 text-sm text-stone-gray",onClick:()=>m(!1),children:a("common.cancel")})]}):(0,d.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:()=>m(!0),children:a("settings.data.clear.button")})]})}),(0,d.jsx)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:a("settings.data.reset.title")}),(0,d.jsx)("p",{className:"mt-2 font-zen-body text-xs text-stone-gray font-light",children:a("settings.data.reset.description")})]}),n?(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("button",{type:"button",className:"rounded-lg bg-matcha-green px-4 py-2 text-sm text-shoji-white",onClick:x,disabled:j,children:j?a("settings.data.reset.running"):a("settings.data.reset.confirm")}),(0,d.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/30 px-4 py-2 text-sm text-stone-gray",onClick:()=>s(!1),children:a("common.cancel")})]}):(0,d.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:()=>s(!0),children:a("settings.data.reset.button")})]})}),t&&(0,d.jsx)("p",{className:"font-zen-body text-xs text-stone-gray font-light",children:t})]})})}function E(){let a=(0,i.k)(),b=[{label:a("settings.about.version.label"),value:a("settings.about.version.value")},{label:a("settings.about.framework.label"),value:a("settings.about.framework.value")},{label:a("settings.about.storage.label"),value:a("settings.about.storage.value")},{label:a("settings.about.ui.label"),value:a("settings.about.ui.value")}];return(0,d.jsx)(y,{title:a("settings.about.title"),description:a("settings.about.description"),children:(0,d.jsx)("div",{className:"space-y-4",children:b.map(a=>(0,d.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,d.jsx)("span",{className:"font-zen-body text-sm text-stone-gray font-light",children:a.label}),(0,d.jsx)("span",{className:"font-zen-display text-lg font-light text-ink-black",children:a.value})]},a.label))})})}function F(){let a=(0,i.k)(),b=(0,h.CU)(a=>a.toolSettings),c=(0,h.CU)(a=>a.setToolSettings),e=(0,h.CU)(a=>a.upsertMcpServer),f=(0,h.CU)(a=>a.deleteMcpServer),[j,k]=(0,g.useState)(!1),[l,m]=(0,g.useState)(!1),[o,p]=(0,g.useState)({status:"idle"}),q=async()=>{let c=b.search.provider,d="exa"===c?b.search.exaApiKey:b.search.tavilyApiKey;if(!d.trim())return void p({status:"error",message:a("settings.tools.search.missingApiKey",{provider:"exa"===c?"Exa":"Tavily"})});p({status:"running",message:void 0,latencyMs:void 0});let e=Date.now();try{let f=await fetch("/api/tools/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:c,apiKey:d,query:"OpenAI",maxResults:1,searchDepth:b.search.searchDepth})}),g=Math.max(0,Date.now()-e),h=await f.json().catch(()=>null);if(!f.ok){let b=x(h)&&"error"in h?String(h.error??""):"";throw Error(b||a("errors.requestFailedWithStatus",{status:f.status}))}let i=x(h)&&Array.isArray(h.results)&&h.results[0]&&x(h.results[0])&&"string"==typeof h.results[0].title?h.results[0].title:"";p({status:"success",latencyMs:g,message:i?a("settings.tools.search.test.successWithTitle",{title:i}):a("settings.tools.search.test.success")})}catch(b){p({status:"error",message:b instanceof Error?b.message:a("settings.tools.search.test.failed")})}},r={idle:"text-stone-gray",running:"text-kintsugi-gold",success:"text-matcha-green",error:"text-red-500"}[o.status],[s,t]=(0,g.useState)({}),[u,v]=(0,g.useState)({}),[A,B]=(0,g.useState)({}),C=(a,b)=>{let c=b.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g,"").replace(/\r/g,"").split("\n").map(a=>a.trimEnd()).filter(Boolean);0!==c.length&&t(b=>{let d=b[a],e=[...d?.logs??[],...c],f=e.slice(Math.max(0,e.length-200));return{...b,[a]:{...d??{status:"running"},logs:f}}})},D=async c=>{let d=b.mcp.servers.find(a=>a.id===c)??null;if(!d)return void t(b=>({...b,[c]:{status:"error",message:a("settings.tools.mcp.serverNotFound")}}));t(a=>({...a,[c]:{status:"running",message:void 0,tools:void 0,logs:[]}})),B(a=>({...a,[c]:!0}));let e=Date.now();try{let b=await fetch("/api/tools/mcp/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({server:d})});if(!b.ok){let c=await b.json().catch(()=>null),d="object"==typeof c&&null!==c&&"error"in c?String(c.error??""):"";throw Error(d||a("errors.requestFailedWithStatus",{status:b.status}))}let f=b.headers.get("content-type")??"";if(!b.body||!f.includes("text/event-stream"))throw Error(a("settings.tools.mcp.invalidTestResponse"));let g=b.body.getReader(),h=new TextDecoder("utf-8"),i="",j=!1,k=!1;for(;!j;){let b=await g.read();if(b.done)break;let d=(i+=h.decode(b.value,{stream:!0})).split(/\r?\n\r?\n/);for(let b of(i=d.pop()??"",d)){for(let d of b.split(/\r?\n/)){if(!d.startsWith("data:"))continue;let b=d.replace(/^data:\s*/,"");if(b){if("[DONE]"===b){j=!0;break}try{let d=JSON.parse(b);if("log"===d.type)C(c,d.text);else if("status"===d.type)t(a=>({...a,[c]:{...a[c]??{status:"running"},message:d.phase}}));else if("result"===d.type)k=!0,t(b=>({...b,[c]:{...b[c]??{status:"success"},status:"success",message:a("settings.tools.mcp.test.success",{count:d.tools.length}),latencyMs:d.latencyMs??Math.max(0,Date.now()-e),tools:d.tools,testedAt:Date.now()}})),v(a=>({...a,[c]:!0}));else if("error"===d.type)throw Error(d.message)}catch(d){let b=d instanceof Error?d.message:a("settings.tools.mcp.test.failed");C(c,b)}}}if(j)break}}if(!k)throw Error(a("settings.tools.mcp.test.noResult"))}catch(f){let b=Math.max(0,Date.now()-e),d=f instanceof Error?f.message:a("settings.tools.mcp.test.failed");t(a=>({...a,[c]:{...a[c]??{status:"error"},status:"error",message:d,latencyMs:b,tools:a[c]?.tools??[],testedAt:Date.now()}}))}},[E,F]=(0,g.useState)(!1),[G,H]=(0,g.useState)(null),[I,J]=(0,g.useState)(null),K=()=>{J(null),H({id:`mcp_${Date.now().toString(36)}`,name:a("settings.tools.mcp.newServerName"),transport:"http",token:"",configJson:JSON.stringify({url:"http://localhost:3000/mcp",protocolVersion:"2024-11-05"},null,2)}),F(!0)};return(0,d.jsxs)(y,{title:a("settings.tools.title"),description:a("settings.tools.description"),action:(0,d.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:K,children:a("settings.tools.mcp.add")}),children:[(0,d.jsxs)("div",{className:"space-y-10",children:[(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsx)("div",{className:"mb-5 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:a("settings.tools.search.title")}),(0,d.jsxs)("div",{className:"grid gap-5 md:grid-cols-2",children:[(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:a("settings.tools.search.defaultProvider")}),(0,d.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:b.search.provider,onChange:a=>c({...b,search:{...b.search,provider:"exa"===a.target.value?"exa":"tavily"}}),children:[(0,d.jsx)("option",{value:"tavily",children:"Tavily"}),(0,d.jsx)("option",{value:"exa",children:"Exa"})]})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:a("settings.tools.search.searchDepth")}),(0,d.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:b.search.searchDepth,onChange:a=>c({...b,search:{...b.search,searchDepth:"advanced"===a.target.value?"advanced":"basic"}}),children:[(0,d.jsx)("option",{value:"basic",children:a("settings.tools.search.depth.basic")}),(0,d.jsx)("option",{value:"advanced",children:a("settings.tools.search.depth.advanced")})]})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:a("settings.tools.search.maxResults")}),(0,d.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:b.search.maxResults,onChange:a=>c({...b,search:{...b.search,maxResults:Math.max(1,Math.min(20,Number(a.target.value||0)))}})})]})]}),(0,d.jsxs)("div",{className:"mt-6 grid gap-5 md:grid-cols-2",children:[(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:"Tavily API Key"}),(0,d.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:()=>k(a=>!a),children:[j?(0,d.jsx)(w.aR,{}):(0,d.jsx)(w.bM,{}),j?a("common.hide"):a("common.show")]})]}),(0,d.jsx)("input",{type:j?"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:b.search.tavilyApiKey,onChange:a=>c({...b,search:{...b.search,tavilyApiKey:a.target.value}}),placeholder:"tvly-..."})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:"Exa API Key"}),(0,d.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:()=>m(a=>!a),children:[l?(0,d.jsx)(w.aR,{}):(0,d.jsx)(w.bM,{}),l?a("common.hide"):a("common.show")]})]}),(0,d.jsx)("input",{type:l?"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:b.search.exaApiKey,onChange:a=>c({...b,search:{...b.search,exaApiKey:a.target.value}}),placeholder:"exa_..."})]})]}),(0,d.jsxs)("div",{className:"mt-6 flex flex-wrap items-center justify-between gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:a("settings.tools.search.test.title")}),void 0!==o.latencyMs?(0,d.jsx)("div",{className:"mt-2 font-mono text-xs text-stone-gray",children:a("settings.tools.search.test.latency",{ms:o.latencyMs})}):null]}),(0,d.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"===o.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 q(),disabled:"running"===o.status,children:"running"===o.status?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(w.fN,{}),a("settings.tools.search.test.running")]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(w.Sr,{}),a("settings.tools.search.test.button")]})})]}),o.message?(0,d.jsx)("p",{className:`mt-3 font-zen-body text-xs font-light ${r}`,children:o.message}):null]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsxs)("div",{className:"mb-5 flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:"MCP Servers"}),(0,d.jsx)("p",{className:"mt-2 font-zen-body text-sm text-stone-gray font-light",children:a("settings.tools.mcp.description")})]}),(0,d.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:K,children:a("common.new")})]}),0===b.mcp.servers.length?(0,d.jsx)(z,{title:a("settings.tools.mcp.empty.title"),description:a("settings.tools.mcp.empty.description")}):(0,d.jsx)("div",{className:"space-y-3",children:b.mcp.servers.map(c=>{let e,g,h,i;return(0,d.jsx)("div",{className:"rounded-2xl border border-parchment/20 bg-shoji-white px-6 py-4",children:(e=s[c.id]??{status:"idle"},g=u[c.id]??!1,h=A[c.id]??!1,i="success"===e.status?"text-matcha-green":"error"===e.status?"text-red-500":"running"===e.status?"text-kintsugi-gold":"text-stone-gray",(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-zen-display text-lg font-light text-ink-black",children:c.name}),(0,d.jsxs)("div",{className:"mt-1 font-mono text-[0.7rem] text-stone-gray",children:[c.id," \xb7 ",c.transport.toUpperCase()]})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.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 D(c.id),disabled:"running"===e.status,children:"running"===e.status?a("settings.tools.mcp.test.running"):a("settings.tools.mcp.test.button")}),(0,d.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 a;let d;return a=c.id,void((d=b.mcp.servers.find(b=>b.id===a))&&(J(null),H({id:d.id,name:d.name,transport:d.transport,token:d.token,configJson:d.configJson}),F(!0)))},children:a("common.edit")}),(0,d.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:()=>f(c.id),children:a("common.delete")})]})]}),"idle"!==e.status?(0,d.jsxs)("div",{className:"mt-3",children:[(0,d.jsxs)("div",{className:`font-mono text-[0.75rem] ${i}`,children:[e.message??("running"===e.status?a("settings.tools.mcp.test.running"):""),"number"==typeof e.latencyMs?(0,d.jsxs)("span",{className:"ml-2 text-stone-gray",children:[e.latencyMs,"ms"]}):null]}),e.logs&&e.logs.length>0?(0,d.jsxs)("div",{className:"mt-2 rounded-xl border border-parchment/20 bg-washi-cream/60 px-4 py-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsx)("div",{className:"font-mono text-[0.65rem] uppercase tracking-[0.12em] text-stone-gray",children:a("settings.tools.mcp.logs")}),(0,d.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:()=>B(a=>({...a,[c.id]:!h})),children:[h?a("settings.tools.mcp.collapse"):a("settings.tools.mcp.expand")," (",e.logs.length,")"]})]}),h?(0,d.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:e.logs.join("\n")}):null]}):null,"success"===e.status&&e.tools&&(0,d.jsxs)("div",{className:"mt-2 rounded-xl border border-parchment/20 bg-washi-cream/60 px-4 py-3",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,d.jsx)("div",{className:"font-mono text-[0.65rem] uppercase tracking-[0.12em] text-stone-gray",children:a("settings.tools.mcp.tools")}),(0,d.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(a=>({...a,[c.id]:!g})),children:[g?a("settings.tools.mcp.collapse"):a("settings.tools.mcp.expand")," (",e.tools.length,")"]})]}),g?(0,d.jsx)("div",{className:"mt-3 max-h-[260px] space-y-2 overflow-auto pr-1",children:0===e.tools.length?(0,d.jsx)("div",{className:"rounded-lg bg-shoji-white px-3 py-2 text-xs text-stone-gray",children:a("settings.tools.mcp.noTools")}):e.tools.map(a=>(0,d.jsxs)("div",{className:"rounded-lg bg-shoji-white px-3 py-2",children:[(0,d.jsx)("div",{className:"font-mono text-[0.75rem] text-ink-black",children:a.name}),a.description?(0,d.jsx)("div",{className:"mt-1 text-xs text-stone-gray",children:a.description}):null]},a.name))}):null]})]}):null]}))},c.id)})})]}),(0,d.jsxs)("section",{className:"rounded-2xl border border-parchment/20 bg-washi-cream/50 p-6",children:[(0,d.jsx)("div",{className:"mb-5 font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:a("settings.tools.python.title")}),(0,d.jsxs)("div",{className:"grid gap-5 md:grid-cols-2",children:[(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:a("settings.tools.python.timeoutSeconds")}),(0,d.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(b.python.timeoutMs/1e3),onChange:a=>{let d=Math.max(1,Math.min(120,Number(a.target.value||0)));c({...b,python:{...b.python,timeoutMs:1e3*d}})}})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:a("settings.tools.python.maxOutputChars")}),(0,d.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:b.python.maxOutputChars,onChange:a=>{let d=Math.max(1e3,Math.min(2e5,Number(a.target.value||0)));c({...b,python:{...b.python,maxOutputChars:d}})}})]}),(0,d.jsxs)("label",{className:"space-y-2 md:col-span-2",children:[(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray font-light",children:a("settings.tools.python.command")}),(0,d.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:b.python.pythonCommand,onChange:a=>c({...b,python:{...b.python,pythonCommand:a.target.value}}),placeholder:"python3"}),(0,d.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:a("settings.tools.python.note")})]})]})]})]}),(0,d.jsx)(n.a,{open:E,title:G?a("settings.tools.mcp.modal.titleWithName",{name:G.name}):a("settings.tools.mcp.modal.title"),onClose:()=>F(!1),children:G?(0,d.jsxs)("div",{className:"space-y-4",children:[I?(0,d.jsx)("div",{className:"rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:I}):null,(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"text-xs text-sand",children:a("settings.tools.mcp.editor.serverId")}),(0,d.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:G.id,onChange:a=>H({...G,id:a.target.value})})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"text-xs text-sand",children:a("settings.tools.mcp.editor.name")}),(0,d.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:G.name,onChange:a=>H({...G,name:a.target.value})})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"text-xs text-sand",children:a("settings.tools.mcp.editor.transport")}),(0,d.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:G.transport,onChange:a=>{let b="stdio"===a.target.value?"stdio":"sse"===a.target.value?"sse":"http",c="http"===b?JSON.stringify({url:"http://localhost:3000/mcp",protocolVersion:"2024-11-05"},null,2):"sse"===b?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);H({...G,transport:b,configJson:G.configJson.trim()?G.configJson:c})},children:[(0,d.jsx)("option",{value:"http",children:"streamable http"}),(0,d.jsx)("option",{value:"sse",children:"legacy sse"}),(0,d.jsx)("option",{value:"stdio",children:"stdio"})]})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"text-xs text-sand",children:a("settings.tools.mcp.editor.token")}),(0,d.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:G.token,onChange:a=>H({...G,token:a.target.value}),placeholder:a("settings.tools.mcp.editor.tokenPlaceholder")})]}),(0,d.jsxs)("label",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"text-xs text-sand",children:a("settings.tools.mcp.editor.configJson")}),(0,d.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:G.configJson,onChange:a=>H({...G,configJson:a.target.value}),spellCheck:!1}),(0,d.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:a("settings.tools.mcp.editor.configNote")})]}),(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)("button",{type:"button",className:"rounded-lg border border-parchment/30 bg-shoji-white px-4 py-2 text-sm text-stone-gray",onClick:()=>F(!1),children:a("common.cancel")}),(0,d.jsx)("button",{type:"button",className:"rounded-lg bg-matcha-green px-4 py-2 text-sm text-shoji-white",onClick:()=>{if(!G)return;let b=G.id.trim(),c=G.name.trim();b?c?(e({id:b,name:c,transport:G.transport,token:G.token,configJson:G.configJson}),F(!1)):J(a("settings.tools.mcp.editor.nameRequired")):J(a("settings.tools.mcp.editor.idRequired"))},children:a("common.save")})]})]}):null})]})}function G(){let a=(0,i.k)();return(0,d.jsxs)(f(),{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,d.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.jsx)("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),a("settings.backToHome")]})}function H(){(0,h.CU)(a=>a.providers),(0,h.CU)(a=>a.selectedProviderId),(0,h.CU)(a=>a.loadProviders);let a=(0,g.useRef)(null),[b,c]=(0,g.useState)("providers"),e=()=>"providers"===b?(0,d.jsx)(k.ProviderConfig,{}):"models"===b?(0,d.jsx)(A,{}):"general"===b?(0,d.jsx)(B,{}):"display"===b?(0,d.jsx)(C,{}):"tools"===b?(0,d.jsx)(F,{}):"data"===b?(0,d.jsx)(D,{}):"about"===b?(0,d.jsx)(E,{}):(0,d.jsx)(k.ProviderConfig,{}),f="providers"===b||"models"===b;return(0,d.jsxs)("div",{ref:a,className:"fixed inset-0 z-[100] flex bg-shoji-white",style:{height:"100vh",maxHeight:"100vh"},children:[(0,d.jsx)(l.SettingsSidebar,{activeId:b,onSelect:c}),f?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(j.ProviderList,{}),e(),(0,d.jsx)(m.ConnectedModelSelector,{})]}):e(),(0,d.jsx)(G,{})]})}},1561:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>f});var d=c(5735),e=c(1190);function f(){return(0,d.jsx)(e.SettingsPage,{})}c(2479),c(7287),c(6325),c(3154)},1569:(a,b,c)=>{"use strict";c.d(b,{SettingsSidebar:()=>i});var d=c(8249),e=c(4995),f=c(1098);let g=[{id:"providers",labelKey:"settings.nav.providers",icon:(0,d.jsx)(f.hp,{})},{id:"models",labelKey:"settings.nav.defaultModel",icon:(0,d.jsx)(f.GQ,{})},{id:"tools",labelKey:"settings.nav.tools",icon:(0,d.jsx)(f.PX,{})},{id:"general",labelKey:"settings.nav.general",icon:(0,d.jsx)(f.yo,{})},{id:"display",labelKey:"settings.nav.display",icon:(0,d.jsx)(f.v1,{})}],h=[{id:"data",labelKey:"settings.nav.data",icon:(0,d.jsx)(f.bN,{})},{id:"about",labelKey:"settings.nav.about",icon:(0,d.jsx)(f.mo,{})}];function i({activeId:a,onSelect:b}){let c=(0,e.k)(),f=[{label:c("settings.nav.configuration"),items:g},{label:c("settings.nav.data"),items:h}];return(0,d.jsxs)("nav",{className:"flex h-full w-[240px] flex-shrink-0 flex-col border-r border-parchment/10 bg-shoji-white",children:[(0,d.jsxs)("div",{className:"border-b border-parchment/10 px-8 py-12",children:[(0,d.jsx)("div",{className:"font-zen-display text-2xl font-light tracking-[0.15em] text-ink-black",children:c("common.settings")}),(0,d.jsx)("div",{className:"mt-1 font-zen-body text-[0.6rem] tracking-[0.2em] text-stone-gray font-light uppercase",children:c("common.appName")})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-8",children:f.map((e,f)=>(0,d.jsxs)("div",{className:0===f?"mb-8":"",children:[(0,d.jsx)("div",{className:"mb-5 px-3 font-zen-body text-[0.65rem] tracking-[0.25em] text-stone-gray uppercase font-light",children:e.label}),(0,d.jsx)("div",{className:"space-y-1",children:e.items.map((e,f)=>(0,d.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 ${a===e.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*f}s backwards`},onClick:()=>b(e.id),children:[(0,d.jsx)("div",{className:`absolute left-0 top-0 h-full w-0.5 bg-matcha-green transition-transform duration-300 ${a===e.id?"scale-y-100":"scale-y-0"}`}),(0,d.jsx)("span",{className:"flex-shrink-0 text-base opacity-70 group-hover:opacity-100 transition-opacity",children:e.icon}),(0,d.jsx)("span",{className:"font-light tracking-wide",children:c(e.labelKey)})]},e.id))})]},e.label))}),(0,d.jsx)("div",{className:"border-t border-parchment/10 px-8 py-7",children:(0,d.jsxs)("div",{className:"font-zen-display text-sm text-stone-gray font-light tracking-[0.1em]",children:[c("common.appName")," v1.0.0"]})})]})}},2479:(a,b,c)=>{"use strict";c.d(b,{SettingsSidebar:()=>d});let d=(0,c(7943).registerClientReference)(function(){throw Error("Attempted to call SettingsSidebar() from the server but SettingsSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/SettingsSidebar.tsx","SettingsSidebar")},3033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},3154:(a,b,c)=>{"use strict";c.d(b,{ConnectedModelSelector:()=>e});var d=c(7943);(0,d.registerClientReference)(function(){throw Error("Attempted to call ModelSelector() from the server but ModelSelector is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/ModelSelector.tsx","ModelSelector");let e=(0,d.registerClientReference)(function(){throw Error("Attempted to call ConnectedModelSelector() from the server but ConnectedModelSelector is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/ModelSelector.tsx","ConnectedModelSelector")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3873:a=>{"use strict";a.exports=require("path")},3954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},5032:(a,b,c)=>{"use strict";c.d(b,{ProviderConfig:()=>n});var d=c(8249),e=c(7484),f=c(3006),g=c(4995),h=c(6684),i=c(1098);function j({apiKey:a,onUpdate:b,onDelete:c,onSetPrimary:f,isPrimary:h}){let j=(0,g.k)(),[k,l]=(0,e.useState)(!1),m=async()=>{try{await navigator.clipboard.writeText(a.value)}catch{}},n={healthy:"text-matcha-green",error:"text-red-500",checking:"text-kintsugi-gold",unknown:"text-stone-gray"}[a.healthStatus||"unknown"];return(0,d.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,d.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{type:"text",value:a.name||"",onChange:a=>b({name:a.target.value}),placeholder:j("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"}),h&&(0,d.jsx)("span",{className:"rounded-lg bg-kintsugi-gold/10 px-2 py-1 font-zen-body text-xs text-kintsugi-gold font-light",children:j("providerConfig.apiKeys.primary")})]}),(0,d.jsx)("div",{className:"flex items-center gap-1",children:(0,d.jsx)("span",{className:`flex-shrink-0 ${n}`,children:"healthy"===a.healthStatus?(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",children:(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10"})}):"error"===a.healthStatus?(0,d.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,d.jsx)("path",{d:"m15 9-6 6m0-6 6 6"})]}):(0,d.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,d.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,d.jsx)("path",{d:"M12 6v6l4 2"})]})})})]}),(0,d.jsx)("div",{className:"flex items-center gap-2",children:(0,d.jsxs)("div",{className:"relative flex-1",children:[(0,d.jsx)("input",{type:k?"text":"password",value:a.value,onChange:a=>b({value:a.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,d.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:()=>l(!k),children:k?(0,d.jsx)(i.aR,{}):(0,d.jsx)(i.bM,{})})]})}),(0,d.jsxs)("div",{className:"mt-3 flex items-center justify-between",children:[(0,d.jsx)("div",{className:"flex items-center gap-1",children:!h&&(0,d.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:f,children:j("providerConfig.apiKeys.setPrimary")})}),(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)("button",{type:"button",className:"rounded-lg p-2 text-stone-gray transition-colors hover:text-ink-black",onClick:m,title:j("common.copy"),children:(0,d.jsx)(i.Td,{})}),(0,d.jsx)("button",{type:"button",className:"rounded-lg p-2 text-stone-gray transition-colors hover:text-red-500",onClick:c,title:j("common.delete"),children:(0,d.jsx)(i.uc,{})})]})]})]})}function k({model:a,onRemove:b,onToggleEnabled:c,onToggleStreaming:e}){let f=(0,g.k)(),h=a.supportsStreaming??!1;return(0,d.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,d.jsx)("button",{type:"button",className:`flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-lg border transition-all duration-300 ${a.enabled?"border-matcha-green bg-matcha-green text-shoji-white":"border-stone-gray/30 bg-transparent text-transparent hover:border-stone-gray/50"}`,onClick:c,children:(0,d.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:(0,d.jsx)("path",{d:"M5 12l6 6 8-8"})})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"font-mono text-sm text-ink-black truncate font-light",children:a.id}),a.name!==a.id&&(0,d.jsx)("div",{className:"font-zen-body text-xs text-stone-gray truncate font-light",children:a.name})]}),(0,d.jsxs)("button",{type:"button",className:`flex items-center gap-1.5 rounded-full border px-3 py-1 text-[0.65rem] transition-all ${h?"border-copper/50 bg-copper/10 text-copper":"border-parchment/40 text-sand hover:border-copper/40 hover:text-ink"}`,onClick:e,children:[(0,d.jsx)("span",{className:`h-2 w-2 rounded-full border ${h?"border-copper bg-copper":"border-parchment/60 bg-transparent"}`}),f("providerConfig.models.streaming")]}),(0,d.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:b,children:(0,d.jsx)(i.uc,{})})]})}function l({icon:a,title:b,description:c}){return(0,d.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,d.jsx)("div",{className:"mb-4 rounded-xl bg-shoji-white p-4 text-stone-gray",children:(0,d.jsx)(a,{className:"h-8 w-8"})}),(0,d.jsx)("p",{className:"mb-2 font-zen-body text-sm text-stone-gray font-light",children:b}),(0,d.jsx)("p",{className:"font-zen-body text-xs text-stone-gray/70 font-light",children:c})]})}function m({open:a,onClose:b,onAdd:c}){let f=(0,g.k)(),[h,i]=(0,e.useState)(""),[j,k]=(0,e.useState)("");return a?(0,d.jsx)("div",{className:"fixed inset-0 z-[220] flex items-center justify-center bg-ink-black/20 backdrop-blur-sm",children:(0,d.jsxs)("div",{className:"w-full max-w-md rounded-2xl bg-shoji-white p-8 shadow-lg border border-parchment/10",children:[(0,d.jsx)("h3",{className:"mb-6 font-zen-display text-2xl font-light text-ink-black tracking-wide",children:f("providerConfig.addKey.title")}),(0,d.jsxs)("form",{onSubmit:a=>{a.preventDefault();let d=j.trim(),e=h.trim();d&&(c(d,e||void 0),b())},children:[(0,d.jsxs)("div",{className:"mb-5",children:[(0,d.jsx)("label",{className:"mb-2 block font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:f("providerConfig.addKey.nameLabel")}),(0,d.jsx)("input",{type:"text",value:h,onChange:a=>i(a.target.value),placeholder:f("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,d.jsxs)("div",{className:"mb-6",children:[(0,d.jsx)("label",{className:"mb-2 block font-zen-body text-[0.7rem] uppercase tracking-[0.15em] text-stone-gray font-light",children:f("providerConfig.addKey.valueLabel")}),(0,d.jsx)("input",{type:"password",value:j,onChange:a=>k(a.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,d.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,d.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:b,children:f("common.cancel")}),(0,d.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:f("common.add")})]})]})]})}):null}function n(){let a=(0,g.k)(),b=(0,f.CU)(a=>a.providers),c=(0,f.CU)(a=>a.selectedProviderId),n=(0,f.CU)(a=>a.updateProvider),o=(0,f.CU)(a=>a.updateModel),p=(0,f.CU)(a=>a.addApiKey),q=(0,f.CU)(a=>a.updateApiKey),r=(0,f.CU)(a=>a.deleteApiKey),s=(0,f.CU)(a=>a.setPrimaryApiKey),t=(0,f.CU)(a=>a.removeModel),u=(0,f.CU)(a=>a.toggleModelEnabled),v=(0,f.CU)(a=>a.checkProviderHealth),w=(0,f.CU)(a=>a.openModelSelector),[x,y]=(0,e.useState)(""),[z,A]=(0,e.useState)(""),[B,C]=(0,e.useState)(!1),[D,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)(null),H=b.find(a=>a.id===c)||null,I=async()=>{if(H){C(!0),G(null);try{await v(H.id)}catch(b){G(b instanceof Error?b.message:a("errors.connectionFailed"))}finally{C(!1)}}},J=H?.models.filter(a=>a.enabled)??[],K=H?.models.filter(a=>!a.enabled)??[];return H?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex h-full flex-1 flex-col bg-shoji-white",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between border-b border-parchment/10 px-8 py-8",children:[(0,d.jsxs)("div",{className:"flex items-center gap-4",children:[(0,d.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:H.name.charAt(0).toUpperCase()}),(0,d.jsx)("input",{type:"text",value:x,onChange:a=>{var b;y(b=a.target.value),H&&n(H.id,{name:b})},className:"bg-transparent font-zen-display text-2xl font-light text-ink-black outline-none tracking-wide"})]}),(0,d.jsxs)("div",{className:"flex flex-col items-end gap-2",children:[(0,d.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 ${B?"bg-washi-cream text-stone-gray cursor-wait":"bg-matcha-green/10 text-matcha-green hover:bg-matcha-green/20 font-light"}`,onClick:I,disabled:B,children:B?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i.fN,{}),a("providerConfig.check.running")]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i.fN,{}),a("providerConfig.check.button")]})}),F&&(0,d.jsx)("p",{className:"font-zen-body text-xs text-red-500 font-light",children:F})]})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,d.jsxs)("div",{className:"max-w-3xl px-8 py-8",children:[(0,d.jsxs)("section",{className:"mb-10",children:[(0,d.jsxs)("div",{className:"mb-5 flex items-center gap-3",children:[(0,d.jsx)("div",{className:"rounded-lg bg-washi-cream p-2.5 text-stone-gray",children:(0,d.jsx)(i.RY,{})}),(0,d.jsx)("h3",{className:"font-zen-display text-xl font-light text-ink-black tracking-wide",children:a("providerConfig.apiKeys.title")})]}),(0,d.jsx)("div",{className:"space-y-3",children:H.apiKeys.map(a=>(0,d.jsx)(j,{apiKey:a,onUpdate:b=>q(H.id,a.id,b),onDelete:()=>r(H.id,a.id),onSetPrimary:()=>s(H.id,a.id),isPrimary:a.isPrimary||1===H.apiKeys.length},a.id))}),(0,d.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:()=>{H&&E(!0)},children:[(0,d.jsx)(i.c1,{}),a("providerConfig.apiKeys.add")]})]}),(0,d.jsxs)("section",{className:"mb-10",children:[(0,d.jsxs)("div",{className:"mb-5 flex items-center gap-3",children:[(0,d.jsx)("div",{className:"rounded-lg bg-washi-cream p-2.5 text-stone-gray",children:(0,d.jsx)(i.qY,{})}),(0,d.jsx)("h3",{className:"font-zen-display text-xl font-light text-ink-black tracking-wide",children:a("providerConfig.baseUrl.title")})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("input",{type:"text",value:z,onChange:a=>{var b;A(b=a.target.value),H&&n(H.id,{baseUrl:(0,h.qT)(b)})},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,d.jsx)("p",{className:"mt-3 font-zen-body text-xs text-stone-gray font-light",children:a("providerConfig.baseUrl.preview",{url:`${(0,h.qT)(z)}/chat/completions`})})]})]}),(0,d.jsxs)("section",{children:[(0,d.jsxs)("div",{className:"mb-5 flex items-center justify-between",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"rounded-lg bg-washi-cream p-2.5 text-stone-gray",children:(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,d.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,d.jsx)("path",{d:"M9 9h6v6H9z"})]})}),(0,d.jsx)("h3",{className:"font-zen-display text-xl font-light text-ink-black tracking-wide",children:a("providerConfig.models.title")}),(0,d.jsx)("span",{className:"rounded-full bg-washi-cream px-3 py-1 font-mono text-xs text-stone-gray font-light",children:H.models.length})]}),(0,d.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:()=>w(H.id),children:[(0,d.jsx)(i.WI,{}),a("providerConfig.models.select")]})]}),0===H.models.length?(0,d.jsx)(l,{icon:a=>(0,d.jsxs)("svg",{...a,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,d.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),(0,d.jsx)("path",{d:"M9 9h6v6H9z"})]}),title:a("providerConfig.models.empty.title"),description:a("providerConfig.models.empty.description")}):(0,d.jsxs)("div",{className:"space-y-6",children:[J.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"mb-3 font-mono text-xs text-stone-gray font-light",children:a("providerConfig.models.enabled",{count:J.length})}),(0,d.jsx)("div",{className:"space-y-2",children:J.map(a=>(0,d.jsx)(k,{model:a,onRemove:()=>t(H.id,a.id),onToggleEnabled:()=>u(H.id,a.id),onToggleStreaming:()=>o(H.id,a.id,{supportsStreaming:!a.supportsStreaming})},a.id))})]}),K.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"mb-3 font-mono text-xs text-stone-gray font-light",children:a("providerConfig.models.disabled",{count:K.length})}),(0,d.jsx)("div",{className:"space-y-2",children:K.map(a=>(0,d.jsx)(k,{model:a,onRemove:()=>t(H.id,a.id),onToggleEnabled:()=>u(H.id,a.id),onToggleStreaming:()=>o(H.id,a.id,{supportsStreaming:!a.supportsStreaming})},a.id))})]})]})]})]})})]}),(0,d.jsx)(m,{open:D,onClose:()=>E(!1),onAdd:(a,b)=>{H&&p(H.id,a,b)}})]}):(0,d.jsx)("div",{className:"flex h-full flex-1 items-center justify-center bg-shoji-white",children:(0,d.jsx)(l,{icon:a=>(0,d.jsxs)("svg",{...a,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,d.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,d.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,d.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:a("providerConfig.empty.title"),description:a("providerConfig.empty.description")})})}},6325:(a,b,c)=>{"use strict";c.d(b,{ProviderConfig:()=>d});let d=(0,c(7943).registerClientReference)(function(){throw Error("Attempted to call ProviderConfig() from the server but ProviderConfig is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/ProviderConfig.tsx","ProviderConfig")},6439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},6713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},7287:(a,b,c)=>{"use strict";c.d(b,{ProviderList:()=>d});let d=(0,c(7943).registerClientReference)(function(){throw Error("Attempted to call ProviderList() from the server but ProviderList is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/yxp/Documents/new-chat/ai-chat-client/src/components/settings/ProviderList.tsx","ProviderList")},7598:a=>{"use strict";a.exports=require("node:crypto")},8231:(a,b,c)=>{Promise.resolve().then(c.bind(c,100)),Promise.resolve().then(c.bind(c,5032)),Promise.resolve().then(c.bind(c,813)),Promise.resolve().then(c.bind(c,1479)),Promise.resolve().then(c.bind(c,1569))},8354:a=>{"use strict";a.exports=require("util")},9121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},9294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")}};var b=require("../../webpack-runtime.js");b.C(a);var c=b.X(0,[445,471,734,116,732,689],()=>b(b.s=729));module.exports=c})();