@yxp934/prompt-tree 0.2.0 → 0.3.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 (70) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +4 -4
  3. package/.next/standalone/.next/build-manifest.json +2 -2
  4. package/.next/standalone/.next/server/app/_global-error/page.js +1 -1
  5. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next/standalone/.next/server/app/_global-error.html +2 -2
  7. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_not-found/page.js +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 +2 -2
  18. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  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 +2 -2
  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 +1 -1
  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_client-reference-manifest.js +1 -1
  27. package/.next/standalone/.next/server/app/api/providers/models/route_client-reference-manifest.js +1 -1
  28. package/.next/standalone/.next/server/app/api/providers/test/route_client-reference-manifest.js +1 -1
  29. package/.next/standalone/.next/server/app/api/tools/mcp/call-tool/route_client-reference-manifest.js +1 -1
  30. package/.next/standalone/.next/server/app/api/tools/mcp/list-tools/route_client-reference-manifest.js +1 -1
  31. package/.next/standalone/.next/server/app/api/tools/mcp/test/route_client-reference-manifest.js +1 -1
  32. package/.next/standalone/.next/server/app/api/tools/python/route_client-reference-manifest.js +1 -1
  33. package/.next/standalone/.next/server/app/api/tools/search/route_client-reference-manifest.js +1 -1
  34. package/.next/standalone/.next/server/app/index.html +2 -2
  35. package/.next/standalone/.next/server/app/index.rsc +3 -3
  36. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  37. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
  38. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  39. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
  40. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  41. package/.next/standalone/.next/server/app/page.js +1 -1
  42. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  43. package/.next/standalone/.next/server/app/settings/page.js +2 -2
  44. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  45. package/.next/standalone/.next/server/app/settings.html +1 -1
  46. package/.next/standalone/.next/server/app/settings.rsc +3 -3
  47. package/.next/standalone/.next/server/app/settings.segments/_full.segment.rsc +3 -3
  48. package/.next/standalone/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  49. package/.next/standalone/.next/server/app/settings.segments/_index.segment.rsc +2 -2
  50. package/.next/standalone/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
  51. package/.next/standalone/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
  52. package/.next/standalone/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  53. package/.next/standalone/.next/server/app-paths-manifest.json +4 -4
  54. package/.next/standalone/.next/server/chunks/471.js +4 -4
  55. package/.next/standalone/.next/server/chunks/689.js +1 -1
  56. package/.next/standalone/.next/server/chunks/732.js +3 -3
  57. package/.next/standalone/.next/server/chunks/734.js +1 -1
  58. package/.next/standalone/.next/server/pages/404.html +1 -1
  59. package/.next/standalone/.next/server/pages/500.html +2 -2
  60. package/.next/standalone/.next/static/chunks/{394-1e8c9367852fd6d7.js → 394-dc41566095beafcf.js} +1 -1
  61. package/.next/standalone/.next/static/chunks/787-12058ee9986bdbfc.js +1 -0
  62. package/.next/standalone/.next/static/chunks/app/settings/page-76e3d482410f0adc.js +1 -0
  63. package/.next/standalone/package.json +1 -1
  64. package/README.md +134 -120
  65. package/README.zh-CN.md +200 -0
  66. package/package.json +1 -1
  67. package/.next/standalone/.next/static/chunks/787-56a48f915165efd3.js +0 -1
  68. package/.next/standalone/.next/static/chunks/app/settings/page-0fc8a4cbf639025c.js +0 -1
  69. /package/.next/standalone/.next/static/{wYfac0R-RsurEa801s_qH → i6P3teUAVQJ-hEG3Y6KV0}/_buildManifest.js +0 -0
  70. /package/.next/standalone/.next/static/{wYfac0R-RsurEa801s_qH → i6P3teUAVQJ-hEG3Y6KV0}/_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:()=>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})();
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,8059))).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,8059))).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)(b.toString()),[k,l]=(0,g.useState)(c.toString()),[m,n]=(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.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:f,onChange:a=>j(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: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",{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:m??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(f),g=Number.parseInt(k,10);e({temperature:Number.isFinite(d)?d:b,maxTokens:Number.isFinite(g)?g:c}),n(a("settings.general.saved")),setTimeout(()=>n(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.contact.email"),value:"yxp934@outlook.com"},{label:a("settings.about.contact.wechat"),value:"WanguA8"}];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")," v0.3.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})();