nextclaw 0.17.11 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/cli/index.js +1684 -347
  2. package/package.json +15 -12
  3. package/resources/USAGE.md +2 -1
  4. package/ui-dist/assets/ChannelsList-Ita2Zm1_.js +8 -0
  5. package/ui-dist/assets/{DocBrowser-BMxf9CIK.js → DocBrowser-6ReNjvzF.js} +1 -1
  6. package/ui-dist/assets/DocBrowser-BNwbPHf4.js +1 -0
  7. package/ui-dist/assets/{DocBrowserContext-Ce28gRXt.js → DocBrowserContext-B6SpA7Qs.js} +1 -1
  8. package/ui-dist/assets/{LogoBadge-o92MOA2L.js → LogoBadge-ByNLYg65.js} +1 -1
  9. package/ui-dist/assets/MarketplacePage-CjX2MWww.js +1 -0
  10. package/ui-dist/assets/{MarketplacePage-BySqkYDh.js → MarketplacePage-D0sDlYX4.js} +1 -1
  11. package/ui-dist/assets/McpMarketplacePage-BGKJm1sJ.js +40 -0
  12. package/ui-dist/assets/{ModelConfig-IrmzoslW.js → ModelConfig-BzZenCH-.js} +1 -1
  13. package/ui-dist/assets/{ProviderScopedModelInput-CmTIzgI7.js → ProviderScopedModelInput-Da7khnBA.js} +1 -1
  14. package/ui-dist/assets/{ProvidersList-8_Kalfwl.js → ProvidersList-BbVzRxjY.js} +1 -1
  15. package/ui-dist/assets/RemoteAccessPage-BaDH_X1Q.js +1 -0
  16. package/ui-dist/assets/RuntimeConfig-F_XKGgLm.js +1 -0
  17. package/ui-dist/assets/{SearchConfig-DNBR-UbE.js → SearchConfig-BGkzXQP-.js} +1 -1
  18. package/ui-dist/assets/{SecretsConfig-Ba1RPJaG.js → SecretsConfig-D281Rotl.js} +2 -2
  19. package/ui-dist/assets/{SessionsConfig-Doqp5ghH.js → SessionsConfig-ChHQ7M5c.js} +2 -2
  20. package/ui-dist/assets/{app-query-client-DniXoIN5.js → app-query-client-VnFElj4E.js} +1 -1
  21. package/ui-dist/assets/{book-open-DocgeQtR.js → book-open-BdcxxoQu.js} +1 -1
  22. package/ui-dist/assets/chat-page-Doe0yTtB.js +58 -0
  23. package/ui-dist/assets/chat-session-display-cw78aiI_.js +1 -0
  24. package/ui-dist/assets/{chunk-JZWAC4HX-BvKvh1R8.js → chunk-JZWAC4HX-DK5HPmIK.js} +1 -1
  25. package/ui-dist/assets/{client-CVqPF5ie.js → client-_i4MU2bB.js} +1 -1
  26. package/ui-dist/assets/{config-Bop2oB18.js → config-DtIQwrHF.js} +1 -1
  27. package/ui-dist/assets/{createLucideIcon-DVv8taGY.js → createLucideIcon-BSeTgkZW.js} +1 -1
  28. package/ui-dist/assets/desktop-update-config-Dpcf4BKG.js +1 -0
  29. package/ui-dist/assets/{dist-Da5Gm_pO.js → dist-6TrrnPCR.js} +1 -1
  30. package/ui-dist/assets/{dist-DmAlInRu.js → dist-ccBFUi-o.js} +1 -1
  31. package/ui-dist/assets/download-BhDxnyvU.js +1 -0
  32. package/ui-dist/assets/{external-link-DFjw3x1B.js → external-link-BgErLCNT.js} +1 -1
  33. package/ui-dist/assets/{hash-DJtaCejM.js → hash-Bl7dr_UG.js} +1 -1
  34. package/ui-dist/assets/i18n-eDHeDY0n.js +1 -0
  35. package/ui-dist/assets/index-CF9xve0E.js +6 -0
  36. package/ui-dist/assets/index-FgA52VBt.css +1 -0
  37. package/ui-dist/assets/{infiniteQueryBehavior-DHSEQ3OH.js → infiniteQueryBehavior-ZDS92Qpp.js} +1 -1
  38. package/ui-dist/assets/loader-circle-ACM1s51e.js +1 -0
  39. package/ui-dist/assets/{logos-DEFUIR12.js → logos-x89HbrZ4.js} +1 -1
  40. package/ui-dist/assets/{page-layout-Da3i3r6G.js → page-layout-vZnghcFy.js} +1 -1
  41. package/ui-dist/assets/play-CFUwCA2E.js +1 -0
  42. package/ui-dist/assets/plus-rYsv72JG.js +1 -0
  43. package/ui-dist/assets/{popover-C_mWOFzI.js → popover-Bg1VoTZ6.js} +1 -1
  44. package/ui-dist/assets/{refresh-ccw-D6HkNtfz.js → refresh-ccw-DT98i__E.js} +1 -1
  45. package/ui-dist/assets/{refresh-cw-DRcvRrnc.js → refresh-cw-C47QSEwg.js} +1 -1
  46. package/ui-dist/assets/{rotate-cw-BmDKfXtH.js → rotate-cw-JtFzpNn6.js} +1 -1
  47. package/ui-dist/assets/{save-DHGmi2e9.js → save-3S6-H3Xw.js} +1 -1
  48. package/ui-dist/assets/search-3kFR_zh9.js +1 -0
  49. package/ui-dist/assets/{security-config-CbXfPZzr.js → security-config-BWaiARNk.js} +1 -1
  50. package/ui-dist/assets/{select-Caud8QvU.js → select-DJ2MUjBB.js} +1 -1
  51. package/ui-dist/assets/skeleton-ByQepn0M.js +1 -0
  52. package/ui-dist/assets/{status-dot-DurKKSwA.js → status-dot-vbanNPFU.js} +1 -1
  53. package/ui-dist/assets/{switch-0rmPBRKI.js → switch-BsLtHOH-.js} +1 -1
  54. package/ui-dist/assets/{tabs-custom-5JLVL6v8.js → tabs-custom-D3HYMt6k.js} +1 -1
  55. package/ui-dist/assets/{trash-2-C6caKPoz.js → trash-2-G48scll7.js} +1 -1
  56. package/ui-dist/assets/{use-infinite-scroll-loader-dwnaa_qi.js → use-infinite-scroll-loader-DkNhD-42.js} +1 -1
  57. package/ui-dist/assets/{useConfirmDialog-mMeWD_yo.js → useConfirmDialog-BkvTN-vd.js} +1 -1
  58. package/ui-dist/assets/{useMutation-BmxxvCNf.js → useMutation-CBWjE2uj.js} +1 -1
  59. package/ui-dist/assets/x-ByDbItbq.js +1 -0
  60. package/ui-dist/index.html +95 -21
  61. package/ui-dist/manifest.webmanifest +30 -0
  62. package/ui-dist/offline.html +102 -0
  63. package/ui-dist/pwa-192.png +0 -0
  64. package/ui-dist/pwa-512.png +0 -0
  65. package/ui-dist/sw.js +80 -0
  66. package/ui-dist/assets/ChannelsList-KIQIxluX.js +0 -8
  67. package/ui-dist/assets/DocBrowser-CyDgAtO9.js +0 -1
  68. package/ui-dist/assets/MarketplacePage-C0olZaek.js +0 -1
  69. package/ui-dist/assets/McpMarketplacePage-DqKaiXO9.js +0 -40
  70. package/ui-dist/assets/RemoteAccessPage-CyQlSjPf.js +0 -1
  71. package/ui-dist/assets/RuntimeConfig-Bk0uYBhf.js +0 -1
  72. package/ui-dist/assets/chat-page-Bph8M5zo.js +0 -58
  73. package/ui-dist/assets/chat-session-display-CoN3Wmn-.js +0 -1
  74. package/ui-dist/assets/desktop-update-config-1KBrqLBC.js +0 -1
  75. package/ui-dist/assets/i18n-CwHZ-9vt.js +0 -1
  76. package/ui-dist/assets/index-DafCdM4F.css +0 -1
  77. package/ui-dist/assets/index-DdksE6U3.js +0 -6
  78. package/ui-dist/assets/loader-circle-PsSP0H9n.js +0 -1
  79. package/ui-dist/assets/play-DBQbBxTA.js +0 -1
  80. package/ui-dist/assets/plus-DUOVbsyQ.js +0 -1
  81. package/ui-dist/assets/search-MChQRYR1.js +0 -1
  82. package/ui-dist/assets/skeleton-B-4vRq_Z.js +0 -1
  83. package/ui-dist/assets/x-DuMhMATD.js +0 -1
  84. /package/ui-dist/assets/{config-hints-BZoDjXye.js → config-hints-BhTmc9P1.js} +0 -0
  85. /package/ui-dist/assets/{config-layout-DmlGaay2.js → config-layout-CHs0mAaR.js} +0 -0
@@ -1 +1 @@
1
- import{_ as e,i as t,m as n,o as r,p as i,u as a}from"./i18n-CwHZ-9vt.js";import{n as o,r as s}from"./dist-DmAlInRu.js";import{s as c}from"./client-CVqPF5ie.js";import{O as l,a as u,i as d,n as f,r as p,t as m}from"./select-Caud8QvU.js";import{t as h}from"./createLucideIcon-DVv8taGY.js";import{t as g}from"./plus-DUOVbsyQ.js";import{t as _}from"./search-MChQRYR1.js";import{t as v}from"./trash-2-C6caKPoz.js";import{t as y}from"./x-DuMhMATD.js";import{C as b,_ as x,c as ee,d as te,et as S,gt as ne,h as re,k as ie,l as ae,tt as C,u as oe,w as se,x as ce}from"./index-DdksE6U3.js";import{n as w,r as le,t as T}from"./popover-C_mWOFzI.js";import{t as ue}from"./LogoBadge-o92MOA2L.js";import{n as E,t as de}from"./page-layout-Da3i3r6G.js";import{t as D}from"./tabs-custom-5JLVL6v8.js";import{t as O}from"./status-dot-DurKKSwA.js";import{t as k}from"./config-hints-BZoDjXye.js";import{i as A,n as fe,r as j,t as pe}from"./config-layout-DmlGaay2.js";import{t as me}from"./switch-0rmPBRKI.js";var he=h(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),M=h(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),N=h(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ge=h(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),P=e(n(),1),F=i();function _e({isSet:e,className:t,value:n,onChange:r,placeholder:i,...o}){let[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(!1),f=typeof n==`string`&&n.length>0;return(0,F.jsxs)(`div`,{className:`relative`,children:[e&&!f&&!u?(0,F.jsx)(`div`,{onClick:()=>d(!0),className:a(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,t),children:`••••••••••••`}):(0,F.jsx)(C,{type:c?`text`:`password`,className:a(`pr-12`,t),value:n,onChange:r,onBlur:()=>{f||d(!1)},placeholder:i,autoFocus:u,...o}),(0,F.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||f)&&(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>l(!c),children:c?(0,F.jsx)(M,{className:`h-4 w-4`}):(0,F.jsx)(N,{className:`h-4 w-4`})})})]})}function ve({value:e,onChange:n,className:r}){let i=e?Object.entries(e):[],o=(e,t,r)=>{let a=[...i];a[e]=[t,r],n(Object.fromEntries(a))},c=()=>{n({...e,"":``})},l=e=>{let t=i.filter((t,n)=>n!==e);n(Object.fromEntries(t))};return(0,F.jsxs)(`div`,{className:a(`space-y-2`,r),children:[i.map(([e,n],r)=>(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(C,{type:`text`,value:e,onChange:e=>o(r,e.target.value,n),placeholder:t(`headerName`),className:`flex-1`}),(0,F.jsx)(C,{type:`text`,value:n,onChange:t=>o(r,e,t.target.value),placeholder:t(`headerValue`),className:`flex-1`}),(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(r),children:(0,F.jsx)(v,{className:`h-4 w-4 text-red-500`})})]},r)),(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,F.jsx)(g,{className:`h-4 w-4 mr-2`}),t(`add`)]})]})}function ye(e){let{value:t,onChange:n,options:r}=e;return(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,F.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-primary bg-primary text-white shadow-sm`:`border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary`}`,children:e.label},e.value)})})}function be(e){let{showAdvanced:n,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:h,extraHeadersLabel:g,extraHeaders:_,onExtraHeadersChange:v}=e;return(0,F.jsxs)(`div`,{className:`border-t border-gray-100 pt-4`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:`flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(ge,{className:`h-3.5 w-3.5`}),t(`providerAdvancedSettings`)]}),(0,F.jsx)(l,{className:`h-4 w-4 transition-transform ${n?`rotate-180`:``}`})]}),n?(0,F.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`wireApi`,className:`text-sm font-medium text-gray-900`,children:a}),c?(0,F.jsx)(ye,{value:o,onChange:e=>s(e),options:h}):(0,F.jsxs)(m,{value:o,onValueChange:e=>s(e),children:[(0,F.jsx)(d,{className:`rounded-xl`,children:(0,F.jsx)(u,{})}),(0,F.jsx)(f,{children:h.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]})]}):null,(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{className:`text-sm font-medium text-gray-900`,children:g}),(0,F.jsx)(ve,{value:_,onChange:v}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerExtraHeadersHelpShort`)})]})]}):null]})}function xe(e){let{providerAuth:n,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:a,selectedAuthMethodHint:o,shouldUseAuthMethodPills:c,resolvedAuthMethodId:l,onAuthMethodChange:h,onStartProviderAuth:g,onImportProviderAuthFromCli:_,startPending:v,importPending:y,authSessionId:b,authStatusMessage:x}=e;return n?.kind===`device_code`?(0,F.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,F.jsx)(S,{className:`text-sm font-medium text-gray-900`,children:n.displayName||t(`providerAuthSectionTitle`)}),r?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:r}):null,a>1?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{className:`text-xs font-medium text-gray-700`,children:t(`providerAuthMethodLabel`)}),c?(0,F.jsx)(ye,{value:l,onChange:h,options:i}):(0,F.jsxs)(m,{value:l,onValueChange:h,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white`,children:(0,F.jsx)(u,{placeholder:t(`providerAuthMethodPlaceholder`)})}),(0,F.jsx)(f,{children:i.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]}),o?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:o}):null]}):null,(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:g,disabled:v||!!b,children:t(v?`providerAuthStarting`:b?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),n.supportsCliImport?(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:_,disabled:y,children:t(y?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,b?(0,F.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[t(`providerAuthSessionLabel`),`: `,b.slice(0,8),`…`]}):null]}),x?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:x}):null]}):null}function Se(e){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,F.jsx)(S,{className:`text-sm font-medium text-gray-900`,children:t(`enabled`)}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.enabled?t(`enabled`):t(`disabled`)}),(0,F.jsx)(me,{checked:e.enabled,onCheckedChange:e.onChange})]})]})}var Ce={enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},we=[`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`],Te=new Set(we);function Ee(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function De(e,t){let n=Ee(e),r=Ee(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function Oe(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function ke(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function I(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=ke(n,t))}return n.trim()}function Ae(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function je(e,t){let n=[...e];for(let e of t)n.includes(e)||n.push(e);return n}function Me(e,t){return t.length===0?e:t.every(t=>!e.includes(t))?je(e,t):t}function Ne(e,t){return Ae(e,t)?[]:e}function Pe(e,t,n){t!==n&&(e.enabled=t)}function L(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&Te.has(t)?t:null}function Fe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=L(n);!e||t.includes(e)||t.push(e)}return t}function Ie(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=I(r,t);if(!e)continue;let a=Fe(i?.supported);if(a.length===0)continue;let o=L(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function Le(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e=Fe(i.supported);if(e.length===0)continue;let a=L(i.default);r[t]=a&&e.includes(a)?{supported:e,default:a}:{supported:e}}return r}function Re(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!Ae([...o.supported].sort(),[...s.supported].sort())||(o.default??null)!==(s.default??null))return!1}return!0}function ze(e){return t(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Be(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function Ve(e){return e.required&&e.hasDefault&&e.optionCount>1&&e.optionCount<=3}function He(e){let{models:n,modelThinking:r,modelDraft:i,showModelInput:a,onModelDraftChange:o,onShowModelInputChange:c,onAddModel:l,onRemoveModel:h,onToggleModelThinkingLevel:_,onSetModelThinkingDefault:v,thinkingLevels:b,formatThinkingLevelLabel:x}=e;return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(S,{className:`text-sm font-medium text-gray-900`,children:t(`providerModelsTitle`)}),a?null:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,F.jsx)(g,{className:`h-3 w-3`}),t(`providerAddModel`)]})]}),a?(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(C,{value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(c(!1),o(``))},placeholder:t(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,F.jsx)(s,{type:`button`,size:`sm`,onClick:l,disabled:i.trim().length===0,children:t(`add`)}),(0,F.jsx)(s,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{c(!1),o(``)},children:(0,F.jsx)(y,{className:`h-4 w-4`})})]}):null,n.length===0?(0,F.jsxs)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center`,children:[(0,F.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`providerModelsEmptyShort`)}),a?null:(0,F.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:t(`providerAddFirstModel`)})]}):(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map(e=>{let n=r[e],i=n?.supported??[],a=n?.default??null;return(0,F.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5`,children:[(0,F.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]`,children:e}),(0,F.jsxs)(T,{children:[(0,F.jsx)(le,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":t(`providerModelThinkingTitle`),title:t(`providerModelThinkingTitle`),children:(0,F.jsx)(ge,{className:`h-3 w-3`})})}),(0,F.jsxs)(w,{className:`w-80 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:t(`providerModelThinkingTitle`)}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerModelThinkingHint`)})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:b.map(t=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>_(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${i.includes(t)?`border-primary bg-primary text-white`:`border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary`}`,children:x(t)},t))}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(S,{className:`text-xs font-medium text-gray-700`,children:t(`providerModelThinkingDefault`)}),(0,F.jsxs)(m,{value:a??`__none__`,onValueChange:t=>v(e,t===`__none__`?null:t),disabled:i.length===0,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white text-xs`,children:(0,F.jsx)(u,{})}),(0,F.jsxs)(f,{children:[(0,F.jsx)(p,{value:`__none__`,children:t(`providerModelThinkingDefaultNone`)}),i.map(e=>(0,F.jsx)(p,{value:e,children:x(e)},e))]})]}),i.length===0?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":t(`remove`),children:(0,F.jsx)(y,{className:`h-3 w-3`})})]},e)})})]})}function Ue(e){return e.enabled?(0,F.jsx)(O,{status:e.apiKeySet?`ready`:`setup`,label:e.apiKeySet?t(`statusReady`):t(`statusSetup`),className:e.className}):(0,F.jsx)(O,{status:`inactive`,label:t(`disabled`),className:e.className})}function R({providerName:e,onProviderDeleted:n}){let i=c(),{data:a}=ee(),{data:l}=ae(),{data:u}=oe(),d=ie(),f=re(),p=se(),m=b(),h=ce(),g=x(),[_,y]=(0,P.useState)(``),[te,ne]=(0,P.useState)(!0),[w,le]=(0,P.useState)(``),[T,ue]=(0,P.useState)(null),[E,de]=(0,P.useState)(`auto`),[D,O]=(0,P.useState)([]),[A,j]=(0,P.useState)({}),[me,M]=(0,P.useState)(``),[N,ge]=(0,P.useState)(``),[ve,ye]=(0,P.useState)(!1),[Te,ke]=(0,P.useState)(!1),[je,L]=(0,P.useState)(null),[Fe,R]=(0,P.useState)(``),[We,Ge]=(0,P.useState)(``),z=(0,P.useRef)(null),B=l?.providers.find(t=>t.name===e),V=(e?a?.providers[e]:null)??Ce,Ke=u?.uiHints,H=!!B?.isCustom,qe=e?k(`providers.${e}.apiKey`,Ke):void 0,Je=e?k(`providers.${e}.apiBase`,Ke):void 0,Ye=e?k(`providers.${e}.extraHeaders`,Ke):void 0,Xe=e?k(`providers.${e}.wireApi`,Ke):void 0,Ze=B?.displayName||e||``,U=(V.displayName||``).trim()||Ze,W=V.enabled!==!1,Qe=N.trim()||U||e||t(`providersSelectPlaceholder`),$e=B?.modelPrefix||e||``,G=(0,P.useMemo)(()=>Oe([$e,e||``]),[$e,e]),et=B?.defaultApiBase||``,K=V.apiBase||et,tt=Ee(V.extraHeaders||null),q=V.wireApi||B?.defaultWireApi||`auto`,nt=(0,P.useMemo)(()=>Oe((B?.defaultModels??[]).map(e=>I(e,G))),[B?.defaultModels,G]),rt=(0,P.useMemo)(()=>Oe((V.models??[]).map(e=>I(e,G))),[V.models,G]),J=(0,P.useMemo)(()=>Me(nt,rt),[nt,rt]),it=(0,P.useMemo)(()=>Le(Ie(V.modelThinking,G),J),[J,G,V.modelThinking]),Y=r(),at=B?.apiBaseHelp?.[Y]||B?.apiBaseHelp?.en||Je?.help||t(`providerApiBaseHelp`),X=B?.auth,Z=(0,P.useMemo)(()=>X?.methods??[],[X?.methods]),Q=!!B?.supportsWireApi||H,ot=(0,P.useMemo)(()=>Z.map(e=>({value:e.id,label:e.label?.[Y]||e.label?.en||e.id})),[Z,Y]),st=(0,P.useMemo)(()=>Be({providerName:e,methods:Z,defaultMethodId:X?.defaultMethodId,language:Y}),[e,X?.defaultMethodId,Z,Y]),ct=(0,P.useMemo)(()=>{if(!Z.length)return``;let e=We.trim();return e&&Z.some(t=>t.id===e)?e:st||Z[0]?.id||``},[We,st,Z]),lt=(0,P.useMemo)(()=>Z.find(e=>e.id===ct),[Z,ct]),ut=Ve({required:X?.kind===`device_code`,hasDefault:!!X?.defaultMethodId?.trim(),optionCount:Z.length}),dt=(B?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:t(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)})),ft=Ve({required:Q,hasDefault:typeof B?.defaultWireApi==`string`&&B.defaultWireApi.length>0,optionCount:dt.length}),$=(0,P.useCallback)(()=>{z.current!==null&&(window.clearTimeout(z.current),z.current=null)},[]),pt=(0,P.useCallback)((n,r)=>{$(),z.current=window.setTimeout(()=>{(async()=>{if(e)try{let a=await h.mutateAsync({provider:e,data:{sessionId:n}});if(a.status===`pending`){R(t(`providerAuthWaitingBrowser`)),pt(n,a.nextPollMs??r);return}if(a.status===`authorized`){L(null),$(),R(t(`providerAuthCompleted`)),o.success(t(`providerAuthCompleted`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]});return}L(null),$(),R(a.message||`Authorization ${a.status}.`),o.error(a.message||`Authorization ${a.status}.`)}catch(e){L(null),$();let t=e instanceof Error?e.message:String(e);R(t),o.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,r))},[$,h,e,i]);(0,P.useEffect)(()=>{if(!e){y(``),ne(!0),le(``),ue(null),de(`auto`),O([]),j({}),M(``),ge(``),L(null),R(``),Ge(``),$();return}y(``),ne(W),le(K),ue(V.extraHeaders||null),de(q),O(J),j(it),M(``),ge(U),L(null),R(``),Ge(st),$()},[e,K,W,V.extraHeaders,q,J,it,U,st,$]),(0,P.useEffect)(()=>()=>$(),[$]),(0,P.useEffect)(()=>{j(e=>Le(e,D))},[D]);let mt=(0,P.useMemo)(()=>{if(!e)return!1;let t=_.trim().length>0,n=w.trim()!==K.trim(),r=!De(T,tt),i=Q?E!==q:!1,a=!Ae(D,J),o=!Re(A,it),s=H?N.trim()!==U:!1;return t||te!==W||n||r||i||a||o||s},[e,H,N,U,_,te,W,w,K,T,tt,Q,E,q,D,J,A,it]);return!e||!B?(0,F.jsx)(`div`,{className:fe,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:t(`providersSelectTitle`)}),(0,F.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:t(`providersSelectDescription`)})]})}):(0,F.jsxs)(`div`,{className:pe,children:[(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-6 py-4`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900`,children:Qe}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[H&&(0,F.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(!e||!H)&&window.confirm(t(`providerDeleteConfirm`)))try{await f.mutateAsync({provider:e}),n?.(e)}catch{}},disabled:f.isPending,className:`text-gray-400 hover:text-red-500 transition-colors`,title:t(`providerDelete`),children:(0,F.jsx)(v,{className:`h-4 w-4`})}),(0,F.jsx)(Ue,{enabled:W,apiKeySet:V.apiKeySet})]})]})}),(0,F.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),!e)return;let n={},r=_.trim(),i=w.trim(),a=Ee(T),o=N.trim();H&&o!==U&&(n.displayName=o.length>0?o:null),r.length>0&&(n.apiKey=r),Pe(n,te,W),i!==K.trim()&&(n.apiBase=i.length>0&&i!==et?i:null),De(a,tt)||(n.extraHeaders=a),Q&&E!==q&&(n.wireApi=E),Ae(D,J)||(n.models=Ne(D,nt)),Re(A,it)||(n.modelThinking=Le(A,D)),d.mutate({provider:e,data:n})},className:`flex min-h-0 flex-1 flex-col`,children:[(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5`,children:[(0,F.jsx)(Se,{enabled:te,onChange:ne}),H&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-gray-900`,children:t(`providerDisplayName`)}),(0,F.jsx)(C,{id:`providerDisplayName`,type:`text`,value:N,onChange:e=>ge(e.target.value),placeholder:Ze||t(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerDisplayNameHelpShort`)})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`apiKey`,className:`text-sm font-medium text-gray-900`,children:qe?.label??t(`apiKey`)}),(0,F.jsx)(_e,{id:`apiKey`,value:_,isSet:V.apiKeySet,onChange:e=>y(e.target.value),placeholder:qe?.placeholder??t(`enterApiKey`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`leaveBlankToKeepUnchanged`)})]}),(0,F.jsx)(xe,{providerAuth:X,providerAuthNote:X?.note?.[Y]||X?.note?.en||X?.displayName||``,providerAuthMethodOptions:ot,providerAuthMethodsCount:Z.length,selectedAuthMethodHint:lt?.hint?.[Y]||lt?.hint?.en||``,shouldUseAuthMethodPills:ut,resolvedAuthMethodId:ct,onAuthMethodChange:Ge,onStartProviderAuth:async()=>{if(!(!e||X?.kind!==`device_code`))try{R(``);let n=await m.mutateAsync({provider:e,data:ct?{methodId:ct}:{}});if(!n.sessionId||!n.verificationUri)throw Error(t(`providerAuthStartFailed`));L(n.sessionId),R(`${t(`providerAuthOpenPrompt`)}${n.userCode}${t(`providerAuthOpenPromptSuffix`)}`),window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),pt(n.sessionId,n.intervalMs)}catch(e){let n=e instanceof Error?e.message:String(e);L(null),$(),R(n),o.error(`${t(`providerAuthStartFailed`)}: ${n}`)}},onImportProviderAuthFromCli:async()=>{if(!(!e||X?.kind!==`device_code`))try{$(),L(null);let n=await g.mutateAsync({provider:e}),r=n.expiresAt?` (expires: ${n.expiresAt})`:``;R(`${t(`providerAuthImportStatusPrefix`)}${r}`),o.success(t(`providerAuthImportSuccess`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]})}catch(e){let n=e instanceof Error?e.message:String(e);R(n),o.error(`${t(`providerAuthImportFailed`)}: ${n}`)}},startPending:m.isPending,importPending:g.isPending,authSessionId:je,authStatusMessage:Fe}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`apiBase`,className:`text-sm font-medium text-gray-900`,children:Je?.label??t(`apiBase`)}),(0,F.jsx)(C,{id:`apiBase`,type:`text`,value:w,onChange:e=>le(e.target.value),placeholder:et||Je?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:at})]}),(0,F.jsx)(He,{models:D,modelThinking:A,modelDraft:me,showModelInput:Te,onModelDraftChange:M,onShowModelInputChange:ke,onAddModel:()=>{let e=I(me,G);if(e){if(D.includes(e)){M(``);return}O(t=>[...t,e]),M(``)}},onRemoveModel:e=>{O(t=>t.filter(t=>t!==e)),j(t=>{let n={...t};return delete n[e],n})},onToggleModelThinkingLevel:(e,t)=>{j(n=>{let r=n[e],i=r?.supported??[],a=i.includes(t)?i.filter(e=>e!==t):we.filter(e=>e===t||i.includes(e));if(a.length===0){let t={...n};return delete t[e],t}let o=r?.default&&a.includes(r.default)?r.default:void 0;return{...n,[e]:o?{supported:a,default:o}:{supported:a}}})},onSetModelThinkingDefault:(e,t)=>{j(n=>{let r=n[e];return!r||r.supported.length===0||t&&!r.supported.includes(t)?n:{...n,[e]:t?{supported:r.supported,default:t}:{supported:r.supported}}})},thinkingLevels:we,formatThinkingLevelLabel:ze}),(0,F.jsx)(be,{showAdvanced:ve,onShowAdvancedChange:ye,supportsWireApi:Q,wireApiLabel:Xe?.label??t(`wireApi`),wireApi:E,onWireApiChange:de,shouldUseWireApiPills:ft,wireApiSelectOptions:dt,extraHeadersLabel:Ye?.label??t(`extraHeaders`),extraHeaders:T,onExtraHeadersChange:ue})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 px-6 py-4`,children:[(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(!e)return;let n=I(D.find(e=>e.trim().length>0)??``,G),r={apiBase:w.trim(),extraHeaders:Ee(T),model:n||null};_.trim().length>0&&(r.apiKey=_.trim()),Q&&(r.wireApi=E);try{let n=await p.mutateAsync({provider:e,data:r});if(n.success){o.success(`${t(`providerTestConnectionSuccess`)} (${n.latencyMs}ms)`);return}let i=[`provider=${n.provider}`,`latency=${n.latencyMs}ms`];n.model&&i.push(`model=${n.model}`),o.error(`${t(`providerTestConnectionFailed`)}: ${n.message} | ${i.join(` | `)}`)}catch(e){let n=e instanceof Error?e.message:String(e);o.error(`${t(`providerTestConnectionFailed`)}: ${n}`)}},disabled:p.isPending,children:[(0,F.jsx)(he,{className:`mr-1.5 h-4 w-4`}),p.isPending?t(`providerTestingConnection`):t(`providerTestConnection`)]}),(0,F.jsx)(s,{type:`submit`,disabled:d.isPending||!mt,children:d.isPending?t(`saving`):t(mt?`save`:`unchanged`)})]})]})]})}function We(e){if(!e)return null;try{let t=new URL(e),n=t.pathname&&t.pathname!==`/`?t.pathname:``;return`${t.host}${n}`}catch{return e.replace(/^https?:\/\//,``)}}function Ge(e){return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let n=e.provider.name===`nextclaw`?1:0,r=t.provider.name===`nextclaw`?1:0;return n===r?e.index-t.index:n-r}).map(({provider:e})=>e)}function z(){let{data:e}=ee(),{data:n}=ae(),{data:r}=oe(),i=te(),[o,c]=(0,P.useState)(`installed`),[l,u]=(0,P.useState)(),[d,f]=(0,P.useState)(``),p=r?.uiHints,m=(0,P.useMemo)(()=>Ge(n?.providers??[]),[n?.providers]),h=e?.providers??{},v=m.filter(e=>{let t=h[e.name];return t?.enabled!==!1&&t?.apiKeySet}).length,y=[{id:`installed`,label:t(`providersTabConfigured`),count:v},{id:`all`,label:t(`providersTabAll`),count:m.length}],b=(0,P.useMemo)(()=>{let t=m,n=e?.providers??{},r=d.trim().toLowerCase();return t.filter(e=>{if(o===`installed`){let t=n[e.name];return!!(t?.enabled!==!1&&t?.apiKeySet)}return!0}).filter(e=>r?(n[e.name]?.displayName?.trim()||e.displayName||e.name).toLowerCase().includes(r)||e.name.toLowerCase().includes(r):!0)},[m,e,o,d]);(0,P.useEffect)(()=>{if(b.length===0){u(void 0);return}b.some(e=>e.name===l)||u(b[0].name)},[b,l]);let x=l;return!e||!n?(0,F.jsx)(`div`,{className:`p-8`,children:t(`providersLoading`)}):(0,F.jsxs)(E,{children:[(0,F.jsx)(de,{title:t(`providersPageTitle`),description:t(`providersPageDescription`)}),(0,F.jsxs)(`div`,{className:A,children:[(0,F.jsxs)(`section`,{className:j,children:[(0,F.jsxs)(`div`,{className:`border-b border-gray-100 px-4 pt-4 pb-3 space-y-3`,children:[(0,F.jsx)(D,{tabs:y,activeTab:o,onChange:c,className:`mb-0`}),(0,F.jsxs)(s,{type:`button`,variant:`outline`,className:`w-full justify-center`,onClick:async()=>{try{let e=await i.mutateAsync({data:{}});c(`all`),f(``),u(e.name)}catch{}},disabled:i.isPending,children:[(0,F.jsx)(g,{className:`mr-2 h-4 w-4`}),i.isPending?t(`saving`):t(`providerAddCustom`)]})]}),(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,F.jsx)(C,{value:d,onChange:e=>f(e.target.value),placeholder:t(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:[b.map(n=>{let r=e.providers[n.name],i=r?.enabled!==!1,o=!!(i&&r?.apiKeySet),s=x===n.name,c=r?.displayName?.trim()||n.displayName||n.name,l=k(`providers.${n.name}`,p),d=We(r?.apiBase||n.defaultApiBase||``)||l?.help||t(`providersDefaultDescription`);return(0,F.jsx)(`button`,{type:`button`,onClick:()=>u(n.name),className:a(`w-full rounded-xl border p-2.5 text-left transition-all`,s?`border-primary/30 bg-primary-50/40 shadow-sm`:`border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70`),children:(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,F.jsx)(ue,{name:n.name,src:n.logo?`/logos/${n.logo}`:null,className:a(`h-10 w-10 rounded-lg border`,o?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,F.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:n.name[0]})}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:c}),(0,F.jsx)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:d})]})]}),(0,F.jsx)(O,{status:i?o?`ready`:`setup`:`inactive`,label:t(i?o?`statusReady`:`statusSetup`:`disabled`),className:`min-w-[56px] justify-center`})]})},n.name)}),b.length===0&&(0,F.jsxs)(`div`,{className:`flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center`,children:[(0,F.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white`,children:(0,F.jsx)(ne,{className:`h-5 w-5 text-gray-300`})}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-gray-700`,children:t(`providersNoMatch`)})]})]})]}),(0,F.jsx)(R,{providerName:x,onProviderDeleted:e=>{e===l&&u(void 0)}})]})]})}export{z as ProvidersList};
1
+ import{_ as e,i as t,m as n,o as r,p as i,u as a}from"./i18n-eDHeDY0n.js";import{n as o,r as s}from"./dist-ccBFUi-o.js";import{s as c}from"./client-_i4MU2bB.js";import{O as l,a as u,i as d,n as f,r as p,t as m}from"./select-DJ2MUjBB.js";import{t as h}from"./createLucideIcon-BSeTgkZW.js";import{t as g}from"./plus-rYsv72JG.js";import{t as _}from"./search-3kFR_zh9.js";import{t as v}from"./trash-2-G48scll7.js";import{t as y}from"./x-ByDbItbq.js";import{A as b,S as x,T as ee,_t as te,d as ne,f as re,g as ie,l as ae,nt as S,tt as C,u as oe,v as se,w as ce}from"./index-CF9xve0E.js";import{n as w,r as le,t as T}from"./popover-Bg1VoTZ6.js";import{t as ue}from"./LogoBadge-ByNLYg65.js";import{n as E,t as de}from"./page-layout-vZnghcFy.js";import{t as D}from"./tabs-custom-D3HYMt6k.js";import{t as O}from"./status-dot-vbanNPFU.js";import{t as k}from"./config-hints-BhTmc9P1.js";import{i as A,n as fe,r as j,t as pe}from"./config-layout-CHs0mAaR.js";import{t as me}from"./switch-BsLtHOH-.js";var he=h(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),M=h(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),N=h(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ge=h(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),P=e(n(),1),F=i();function _e({isSet:e,className:t,value:n,onChange:r,placeholder:i,...o}){let[c,l]=(0,P.useState)(!1),[u,d]=(0,P.useState)(!1),f=typeof n==`string`&&n.length>0;return(0,F.jsxs)(`div`,{className:`relative`,children:[e&&!f&&!u?(0,F.jsx)(`div`,{onClick:()=>d(!0),className:a(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,t),children:`••••••••••••`}):(0,F.jsx)(S,{type:c?`text`:`password`,className:a(`pr-12`,t),value:n,onChange:r,onBlur:()=>{f||d(!1)},placeholder:i,autoFocus:u,...o}),(0,F.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||f)&&(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>l(!c),children:c?(0,F.jsx)(M,{className:`h-4 w-4`}):(0,F.jsx)(N,{className:`h-4 w-4`})})})]})}function ve({value:e,onChange:n,className:r}){let i=e?Object.entries(e):[],o=(e,t,r)=>{let a=[...i];a[e]=[t,r],n(Object.fromEntries(a))},c=()=>{n({...e,"":``})},l=e=>{let t=i.filter((t,n)=>n!==e);n(Object.fromEntries(t))};return(0,F.jsxs)(`div`,{className:a(`space-y-2`,r),children:[i.map(([e,n],r)=>(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(S,{type:`text`,value:e,onChange:e=>o(r,e.target.value,n),placeholder:t(`headerName`),className:`flex-1`}),(0,F.jsx)(S,{type:`text`,value:n,onChange:t=>o(r,e,t.target.value),placeholder:t(`headerValue`),className:`flex-1`}),(0,F.jsx)(s,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(r),children:(0,F.jsx)(v,{className:`h-4 w-4 text-red-500`})})]},r)),(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,F.jsx)(g,{className:`h-4 w-4 mr-2`}),t(`add`)]})]})}function ye(e){let{value:t,onChange:n,options:r}=e;return(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,F.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-primary bg-primary text-white shadow-sm`:`border-gray-200 bg-white text-gray-700 hover:border-primary/40 hover:text-primary`}`,children:e.label},e.value)})})}function be(e){let{showAdvanced:n,onShowAdvancedChange:r,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:h,extraHeadersLabel:g,extraHeaders:_,onExtraHeadersChange:v}=e;return(0,F.jsxs)(`div`,{className:`border-t border-gray-100 pt-4`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:`flex w-full items-center justify-between text-sm text-gray-600 transition-colors hover:text-gray-900`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(ge,{className:`h-3.5 w-3.5`}),t(`providerAdvancedSettings`)]}),(0,F.jsx)(l,{className:`h-4 w-4 transition-transform ${n?`rotate-180`:``}`})]}),n?(0,F.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(C,{htmlFor:`wireApi`,className:`text-sm font-medium text-gray-900`,children:a}),c?(0,F.jsx)(ye,{value:o,onChange:e=>s(e),options:h}):(0,F.jsxs)(m,{value:o,onValueChange:e=>s(e),children:[(0,F.jsx)(d,{className:`rounded-xl`,children:(0,F.jsx)(u,{})}),(0,F.jsx)(f,{children:h.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]})]}):null,(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(C,{className:`text-sm font-medium text-gray-900`,children:g}),(0,F.jsx)(ve,{value:_,onChange:v}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerExtraHeadersHelpShort`)})]})]}):null]})}function xe(e){let{providerAuth:n,providerAuthNote:r,providerAuthMethodOptions:i,providerAuthMethodsCount:a,selectedAuthMethodHint:o,shouldUseAuthMethodPills:c,resolvedAuthMethodId:l,onAuthMethodChange:h,onStartProviderAuth:g,onImportProviderAuthFromCli:_,startPending:v,importPending:y,authSessionId:b,authStatusMessage:x}=e;return n?.kind===`device_code`?(0,F.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-primary/20 bg-primary-50/50 p-3`,children:[(0,F.jsx)(C,{className:`text-sm font-medium text-gray-900`,children:n.displayName||t(`providerAuthSectionTitle`)}),r?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:r}):null,a>1?(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(C,{className:`text-xs font-medium text-gray-700`,children:t(`providerAuthMethodLabel`)}),c?(0,F.jsx)(ye,{value:l,onChange:h,options:i}):(0,F.jsxs)(m,{value:l,onValueChange:h,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white`,children:(0,F.jsx)(u,{placeholder:t(`providerAuthMethodPlaceholder`)})}),(0,F.jsx)(f,{children:i.map(e=>(0,F.jsx)(p,{value:e.value,children:e.label},e.value))})]}),o?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:o}):null]}):null,(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:g,disabled:v||!!b,children:t(v?`providerAuthStarting`:b?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),n.supportsCliImport?(0,F.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:_,disabled:y,children:t(y?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,b?(0,F.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[t(`providerAuthSessionLabel`),`: `,b.slice(0,8),`…`]}):null]}),x?(0,F.jsx)(`p`,{className:`text-xs text-gray-600`,children:x}):null]}):null}function Se(e){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,F.jsx)(C,{className:`text-sm font-medium text-gray-900`,children:t(`enabled`)}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`text-xs text-gray-500`,children:e.enabled?t(`enabled`):t(`disabled`)}),(0,F.jsx)(me,{checked:e.enabled,onCheckedChange:e.onChange})]})]})}var Ce={enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelThinking:{}},we=[`off`,`minimal`,`low`,`medium`,`high`,`adaptive`,`xhigh`],Te=new Set(we);function Ee(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function De(e,t){let n=Ee(e),r=Ee(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function Oe(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function ke(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function I(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=ke(n,t))}return n.trim()}function Ae(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function je(e,t){let n=[...e];for(let e of t)n.includes(e)||n.push(e);return n}function Me(e,t){return t.length===0?e:t.every(t=>!e.includes(t))?je(e,t):t}function Ne(e,t){return Ae(e,t)?[]:e}function Pe(e,t,n){t!==n&&(e.enabled=t)}function L(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t&&Te.has(t)?t:null}function Fe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=L(n);!e||t.includes(e)||t.push(e)}return t}function Ie(e,t){if(!e)return{};let n={};for(let[r,i]of Object.entries(e)){let e=I(r,t);if(!e)continue;let a=Fe(i?.supported);if(a.length===0)continue;let o=L(i?.default);n[e]=o&&a.includes(o)?{supported:a,default:o}:{supported:a}}return n}function Le(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e=Fe(i.supported);if(e.length===0)continue;let a=L(i.default);r[t]=a&&e.includes(a)?{supported:e,default:a}:{supported:e}}return r}function Re(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!Ae([...o.supported].sort(),[...s.supported].sort())||(o.default??null)!==(s.default??null))return!1}return!0}function ze(e){return t(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Be(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function Ve(e){return e.required&&e.hasDefault&&e.optionCount>1&&e.optionCount<=3}function He(e){let{models:n,modelThinking:r,modelDraft:i,showModelInput:a,onModelDraftChange:o,onShowModelInputChange:c,onAddModel:l,onRemoveModel:h,onToggleModelThinkingLevel:_,onSetModelThinkingDefault:v,thinkingLevels:b,formatThinkingLevelLabel:x}=e;return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(C,{className:`text-sm font-medium text-gray-900`,children:t(`providerModelsTitle`)}),a?null:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,F.jsx)(g,{className:`h-3 w-3`}),t(`providerAddModel`)]})]}),a?(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(S,{value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(c(!1),o(``))},placeholder:t(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,F.jsx)(s,{type:`button`,size:`sm`,onClick:l,disabled:i.trim().length===0,children:t(`add`)}),(0,F.jsx)(s,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{c(!1),o(``)},children:(0,F.jsx)(y,{className:`h-4 w-4`})})]}):null,n.length===0?(0,F.jsxs)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-6 text-center`,children:[(0,F.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`providerModelsEmptyShort`)}),a?null:(0,F.jsx)(`button`,{type:`button`,onClick:()=>c(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:t(`providerAddFirstModel`)})]}):(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map(e=>{let n=r[e],i=n?.supported??[],a=n?.default??null;return(0,F.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-gray-200 bg-white px-3 py-1.5`,children:[(0,F.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-gray-800 sm:max-w-[220px]`,children:e}),(0,F.jsxs)(T,{children:[(0,F.jsx)(le,{asChild:!0,children:(0,F.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":t(`providerModelThinkingTitle`),title:t(`providerModelThinkingTitle`),children:(0,F.jsx)(ge,{className:`h-3 w-3`})})}),(0,F.jsxs)(w,{className:`w-80 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold text-gray-800`,children:t(`providerModelThinkingTitle`)}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerModelThinkingHint`)})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:b.map(t=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>_(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${i.includes(t)?`border-primary bg-primary text-white`:`border-gray-200 bg-white text-gray-600 hover:border-primary/40 hover:text-primary`}`,children:x(t)},t))}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(C,{className:`text-xs font-medium text-gray-700`,children:t(`providerModelThinkingDefault`)}),(0,F.jsxs)(m,{value:a??`__none__`,onValueChange:t=>v(e,t===`__none__`?null:t),disabled:i.length===0,children:[(0,F.jsx)(d,{className:`h-8 rounded-lg bg-white text-xs`,children:(0,F.jsx)(u,{})}),(0,F.jsxs)(f,{children:[(0,F.jsx)(p,{value:`__none__`,children:t(`providerModelThinkingDefaultNone`)}),i.map(e=>(0,F.jsx)(p,{value:e,children:x(e)},e))]})]}),i.length===0?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 opacity-100 transition-opacity hover:bg-gray-100 hover:text-gray-600 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":t(`remove`),children:(0,F.jsx)(y,{className:`h-3 w-3`})})]},e)})})]})}function Ue(e){return e.enabled?(0,F.jsx)(O,{status:e.apiKeySet?`ready`:`setup`,label:e.apiKeySet?t(`statusReady`):t(`statusSetup`),className:e.className}):(0,F.jsx)(O,{status:`inactive`,label:t(`disabled`),className:e.className})}function R({providerName:e,onProviderDeleted:n}){let i=c(),{data:a}=ae(),{data:l}=oe(),{data:u}=ne(),d=b(),f=ie(),p=ee(),m=ce(),h=x(),g=se(),[_,y]=(0,P.useState)(``),[te,re]=(0,P.useState)(!0),[w,le]=(0,P.useState)(``),[T,ue]=(0,P.useState)(null),[E,de]=(0,P.useState)(`auto`),[D,O]=(0,P.useState)([]),[A,j]=(0,P.useState)({}),[me,M]=(0,P.useState)(``),[N,ge]=(0,P.useState)(``),[ve,ye]=(0,P.useState)(!1),[Te,ke]=(0,P.useState)(!1),[je,L]=(0,P.useState)(null),[Fe,R]=(0,P.useState)(``),[We,Ge]=(0,P.useState)(``),z=(0,P.useRef)(null),B=l?.providers.find(t=>t.name===e),V=(e?a?.providers[e]:null)??Ce,Ke=u?.uiHints,H=!!B?.isCustom,qe=e?k(`providers.${e}.apiKey`,Ke):void 0,Je=e?k(`providers.${e}.apiBase`,Ke):void 0,Ye=e?k(`providers.${e}.extraHeaders`,Ke):void 0,Xe=e?k(`providers.${e}.wireApi`,Ke):void 0,Ze=B?.displayName||e||``,U=(V.displayName||``).trim()||Ze,W=V.enabled!==!1,Qe=N.trim()||U||e||t(`providersSelectPlaceholder`),$e=B?.modelPrefix||e||``,G=(0,P.useMemo)(()=>Oe([$e,e||``]),[$e,e]),et=B?.defaultApiBase||``,K=V.apiBase||et,tt=Ee(V.extraHeaders||null),q=V.wireApi||B?.defaultWireApi||`auto`,nt=(0,P.useMemo)(()=>Oe((B?.defaultModels??[]).map(e=>I(e,G))),[B?.defaultModels,G]),rt=(0,P.useMemo)(()=>Oe((V.models??[]).map(e=>I(e,G))),[V.models,G]),J=(0,P.useMemo)(()=>Me(nt,rt),[nt,rt]),it=(0,P.useMemo)(()=>Le(Ie(V.modelThinking,G),J),[J,G,V.modelThinking]),Y=r(),at=B?.apiBaseHelp?.[Y]||B?.apiBaseHelp?.en||Je?.help||t(`providerApiBaseHelp`),X=B?.auth,Z=(0,P.useMemo)(()=>X?.methods??[],[X?.methods]),Q=!!B?.supportsWireApi||H,ot=(0,P.useMemo)(()=>Z.map(e=>({value:e.id,label:e.label?.[Y]||e.label?.en||e.id})),[Z,Y]),st=(0,P.useMemo)(()=>Be({providerName:e,methods:Z,defaultMethodId:X?.defaultMethodId,language:Y}),[e,X?.defaultMethodId,Z,Y]),ct=(0,P.useMemo)(()=>{if(!Z.length)return``;let e=We.trim();return e&&Z.some(t=>t.id===e)?e:st||Z[0]?.id||``},[We,st,Z]),lt=(0,P.useMemo)(()=>Z.find(e=>e.id===ct),[Z,ct]),ut=Ve({required:X?.kind===`device_code`,hasDefault:!!X?.defaultMethodId?.trim(),optionCount:Z.length}),dt=(B?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:t(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)})),ft=Ve({required:Q,hasDefault:typeof B?.defaultWireApi==`string`&&B.defaultWireApi.length>0,optionCount:dt.length}),$=(0,P.useCallback)(()=>{z.current!==null&&(window.clearTimeout(z.current),z.current=null)},[]),pt=(0,P.useCallback)((n,r)=>{$(),z.current=window.setTimeout(()=>{(async()=>{if(e)try{let a=await h.mutateAsync({provider:e,data:{sessionId:n}});if(a.status===`pending`){R(t(`providerAuthWaitingBrowser`)),pt(n,a.nextPollMs??r);return}if(a.status===`authorized`){L(null),$(),R(t(`providerAuthCompleted`)),o.success(t(`providerAuthCompleted`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]});return}L(null),$(),R(a.message||`Authorization ${a.status}.`),o.error(a.message||`Authorization ${a.status}.`)}catch(e){L(null),$();let t=e instanceof Error?e.message:String(e);R(t),o.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,r))},[$,h,e,i]);(0,P.useEffect)(()=>{if(!e){y(``),re(!0),le(``),ue(null),de(`auto`),O([]),j({}),M(``),ge(``),L(null),R(``),Ge(``),$();return}y(``),re(W),le(K),ue(V.extraHeaders||null),de(q),O(J),j(it),M(``),ge(U),L(null),R(``),Ge(st),$()},[e,K,W,V.extraHeaders,q,J,it,U,st,$]),(0,P.useEffect)(()=>()=>$(),[$]),(0,P.useEffect)(()=>{j(e=>Le(e,D))},[D]);let mt=(0,P.useMemo)(()=>{if(!e)return!1;let t=_.trim().length>0,n=w.trim()!==K.trim(),r=!De(T,tt),i=Q?E!==q:!1,a=!Ae(D,J),o=!Re(A,it),s=H?N.trim()!==U:!1;return t||te!==W||n||r||i||a||o||s},[e,H,N,U,_,te,W,w,K,T,tt,Q,E,q,D,J,A,it]);return!e||!B?(0,F.jsx)(`div`,{className:fe,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:t(`providersSelectTitle`)}),(0,F.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:t(`providersSelectDescription`)})]})}):(0,F.jsxs)(`div`,{className:pe,children:[(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-6 py-4`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900`,children:Qe}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[H&&(0,F.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(!e||!H)&&window.confirm(t(`providerDeleteConfirm`)))try{await f.mutateAsync({provider:e}),n?.(e)}catch{}},disabled:f.isPending,className:`text-gray-400 hover:text-red-500 transition-colors`,title:t(`providerDelete`),children:(0,F.jsx)(v,{className:`h-4 w-4`})}),(0,F.jsx)(Ue,{enabled:W,apiKeySet:V.apiKeySet})]})]})}),(0,F.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),!e)return;let n={},r=_.trim(),i=w.trim(),a=Ee(T),o=N.trim();H&&o!==U&&(n.displayName=o.length>0?o:null),r.length>0&&(n.apiKey=r),Pe(n,te,W),i!==K.trim()&&(n.apiBase=i.length>0&&i!==et?i:null),De(a,tt)||(n.extraHeaders=a),Q&&E!==q&&(n.wireApi=E),Ae(D,J)||(n.models=Ne(D,nt)),Re(A,it)||(n.modelThinking=Le(A,D)),d.mutate({provider:e,data:n})},className:`flex min-h-0 flex-1 flex-col`,children:[(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5`,children:[(0,F.jsx)(Se,{enabled:te,onChange:re}),H&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(C,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-gray-900`,children:t(`providerDisplayName`)}),(0,F.jsx)(S,{id:`providerDisplayName`,type:`text`,value:N,onChange:e=>ge(e.target.value),placeholder:Ze||t(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`providerDisplayNameHelpShort`)})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(C,{htmlFor:`apiKey`,className:`text-sm font-medium text-gray-900`,children:qe?.label??t(`apiKey`)}),(0,F.jsx)(_e,{id:`apiKey`,value:_,isSet:V.apiKeySet,onChange:e=>y(e.target.value),placeholder:qe?.placeholder??t(`enterApiKey`),className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`leaveBlankToKeepUnchanged`)})]}),(0,F.jsx)(xe,{providerAuth:X,providerAuthNote:X?.note?.[Y]||X?.note?.en||X?.displayName||``,providerAuthMethodOptions:ot,providerAuthMethodsCount:Z.length,selectedAuthMethodHint:lt?.hint?.[Y]||lt?.hint?.en||``,shouldUseAuthMethodPills:ut,resolvedAuthMethodId:ct,onAuthMethodChange:Ge,onStartProviderAuth:async()=>{if(!(!e||X?.kind!==`device_code`))try{R(``);let n=await m.mutateAsync({provider:e,data:ct?{methodId:ct}:{}});if(!n.sessionId||!n.verificationUri)throw Error(t(`providerAuthStartFailed`));L(n.sessionId),R(`${t(`providerAuthOpenPrompt`)}${n.userCode}${t(`providerAuthOpenPromptSuffix`)}`),window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),pt(n.sessionId,n.intervalMs)}catch(e){let n=e instanceof Error?e.message:String(e);L(null),$(),R(n),o.error(`${t(`providerAuthStartFailed`)}: ${n}`)}},onImportProviderAuthFromCli:async()=>{if(!(!e||X?.kind!==`device_code`))try{$(),L(null);let n=await g.mutateAsync({provider:e}),r=n.expiresAt?` (expires: ${n.expiresAt})`:``;R(`${t(`providerAuthImportStatusPrefix`)}${r}`),o.success(t(`providerAuthImportSuccess`)),i.invalidateQueries({queryKey:[`config`]}),i.invalidateQueries({queryKey:[`config-meta`]})}catch(e){let n=e instanceof Error?e.message:String(e);R(n),o.error(`${t(`providerAuthImportFailed`)}: ${n}`)}},startPending:m.isPending,importPending:g.isPending,authSessionId:je,authStatusMessage:Fe}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(C,{htmlFor:`apiBase`,className:`text-sm font-medium text-gray-900`,children:Je?.label??t(`apiBase`)}),(0,F.jsx)(S,{id:`apiBase`,type:`text`,value:w,onChange:e=>le(e.target.value),placeholder:et||Je?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:at})]}),(0,F.jsx)(He,{models:D,modelThinking:A,modelDraft:me,showModelInput:Te,onModelDraftChange:M,onShowModelInputChange:ke,onAddModel:()=>{let e=I(me,G);if(e){if(D.includes(e)){M(``);return}O(t=>[...t,e]),M(``)}},onRemoveModel:e=>{O(t=>t.filter(t=>t!==e)),j(t=>{let n={...t};return delete n[e],n})},onToggleModelThinkingLevel:(e,t)=>{j(n=>{let r=n[e],i=r?.supported??[],a=i.includes(t)?i.filter(e=>e!==t):we.filter(e=>e===t||i.includes(e));if(a.length===0){let t={...n};return delete t[e],t}let o=r?.default&&a.includes(r.default)?r.default:void 0;return{...n,[e]:o?{supported:a,default:o}:{supported:a}}})},onSetModelThinkingDefault:(e,t)=>{j(n=>{let r=n[e];return!r||r.supported.length===0||t&&!r.supported.includes(t)?n:{...n,[e]:t?{supported:r.supported,default:t}:{supported:r.supported}}})},thinkingLevels:we,formatThinkingLevelLabel:ze}),(0,F.jsx)(be,{showAdvanced:ve,onShowAdvancedChange:ye,supportsWireApi:Q,wireApiLabel:Xe?.label??t(`wireApi`),wireApi:E,onWireApiChange:de,shouldUseWireApiPills:ft,wireApiSelectOptions:dt,extraHeadersLabel:Ye?.label??t(`extraHeaders`),extraHeaders:T,onExtraHeadersChange:ue})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-100 px-6 py-4`,children:[(0,F.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(!e)return;let n=I(D.find(e=>e.trim().length>0)??``,G),r={apiBase:w.trim(),extraHeaders:Ee(T),model:n||null};_.trim().length>0&&(r.apiKey=_.trim()),Q&&(r.wireApi=E);try{let n=await p.mutateAsync({provider:e,data:r});if(n.success){o.success(`${t(`providerTestConnectionSuccess`)} (${n.latencyMs}ms)`);return}let i=[`provider=${n.provider}`,`latency=${n.latencyMs}ms`];n.model&&i.push(`model=${n.model}`),o.error(`${t(`providerTestConnectionFailed`)}: ${n.message} | ${i.join(` | `)}`)}catch(e){let n=e instanceof Error?e.message:String(e);o.error(`${t(`providerTestConnectionFailed`)}: ${n}`)}},disabled:p.isPending,children:[(0,F.jsx)(he,{className:`mr-1.5 h-4 w-4`}),p.isPending?t(`providerTestingConnection`):t(`providerTestConnection`)]}),(0,F.jsx)(s,{type:`submit`,disabled:d.isPending||!mt,children:d.isPending?t(`saving`):t(mt?`save`:`unchanged`)})]})]})]})}function We(e){if(!e)return null;try{let t=new URL(e),n=t.pathname&&t.pathname!==`/`?t.pathname:``;return`${t.host}${n}`}catch{return e.replace(/^https?:\/\//,``)}}function Ge(e){return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let n=e.provider.name===`nextclaw`?1:0,r=t.provider.name===`nextclaw`?1:0;return n===r?e.index-t.index:n-r}).map(({provider:e})=>e)}function z(){let{data:e}=ae(),{data:n}=oe(),{data:r}=ne(),i=re(),[o,c]=(0,P.useState)(`installed`),[l,u]=(0,P.useState)(),[d,f]=(0,P.useState)(``),p=r?.uiHints,m=(0,P.useMemo)(()=>Ge(n?.providers??[]),[n?.providers]),h=e?.providers??{},v=m.filter(e=>{let t=h[e.name];return t?.enabled!==!1&&t?.apiKeySet}).length,y=[{id:`installed`,label:t(`providersTabConfigured`),count:v},{id:`all`,label:t(`providersTabAll`),count:m.length}],b=(0,P.useMemo)(()=>{let t=m,n=e?.providers??{},r=d.trim().toLowerCase();return t.filter(e=>{if(o===`installed`){let t=n[e.name];return!!(t?.enabled!==!1&&t?.apiKeySet)}return!0}).filter(e=>r?(n[e.name]?.displayName?.trim()||e.displayName||e.name).toLowerCase().includes(r)||e.name.toLowerCase().includes(r):!0)},[m,e,o,d]);(0,P.useEffect)(()=>{if(b.length===0){u(void 0);return}b.some(e=>e.name===l)||u(b[0].name)},[b,l]);let x=l;return!e||!n?(0,F.jsx)(`div`,{className:`p-8`,children:t(`providersLoading`)}):(0,F.jsxs)(E,{children:[(0,F.jsx)(de,{title:t(`providersPageTitle`),description:t(`providersPageDescription`)}),(0,F.jsxs)(`div`,{className:A,children:[(0,F.jsxs)(`section`,{className:j,children:[(0,F.jsxs)(`div`,{className:`border-b border-gray-100 px-4 pt-4 pb-3 space-y-3`,children:[(0,F.jsx)(D,{tabs:y,activeTab:o,onChange:c,className:`mb-0`}),(0,F.jsxs)(s,{type:`button`,variant:`outline`,className:`w-full justify-center`,onClick:async()=>{try{let e=await i.mutateAsync({data:{}});c(`all`),f(``),u(e.name)}catch{}},disabled:i.isPending,children:[(0,F.jsx)(g,{className:`mr-2 h-4 w-4`}),i.isPending?t(`saving`):t(`providerAddCustom`)]})]}),(0,F.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,F.jsx)(S,{value:d,onChange:e=>f(e.target.value),placeholder:t(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:[b.map(n=>{let r=e.providers[n.name],i=r?.enabled!==!1,o=!!(i&&r?.apiKeySet),s=x===n.name,c=r?.displayName?.trim()||n.displayName||n.name,l=k(`providers.${n.name}`,p),d=We(r?.apiBase||n.defaultApiBase||``)||l?.help||t(`providersDefaultDescription`);return(0,F.jsx)(`button`,{type:`button`,onClick:()=>u(n.name),className:a(`w-full rounded-xl border p-2.5 text-left transition-all`,s?`border-primary/30 bg-primary-50/40 shadow-sm`:`border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70`),children:(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,F.jsx)(ue,{name:n.name,src:n.logo?`/logos/${n.logo}`:null,className:a(`h-10 w-10 rounded-lg border`,o?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,F.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:n.name[0]})}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:c}),(0,F.jsx)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:d})]})]}),(0,F.jsx)(O,{status:i?o?`ready`:`setup`:`inactive`,label:t(i?o?`statusReady`:`statusSetup`:`disabled`),className:`min-w-[56px] justify-center`})]})},n.name)}),b.length===0&&(0,F.jsxs)(`div`,{className:`flex h-full min-h-[220px] flex-col items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50/70 py-10 text-center`,children:[(0,F.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white`,children:(0,F.jsx)(te,{className:`h-5 w-5 text-gray-300`})}),(0,F.jsx)(`p`,{className:`text-sm font-medium text-gray-700`,children:t(`providersNoMatch`)})]})]})]}),(0,F.jsx)(R,{providerName:x,onProviderDeleted:e=>{e===l&&u(void 0)}})]})]})}export{z as ProvidersList};
@@ -0,0 +1 @@
1
+ import{_ as e,i as t,m as n,n as r,p as i}from"./i18n-eDHeDY0n.js";import{r as a}from"./dist-ccBFUi-o.js";import{t as o}from"./createLucideIcon-BSeTgkZW.js";import{t as s}from"./refresh-ccw-DT98i__E.js";import{$ as c,G as l,J as u,K as d,X as f,Y as p,Z as m,et as h,q as g,ut as _}from"./index-CF9xve0E.js";import{n as v,t as y}from"./page-layout-vZnghcFy.js";import{t as b}from"./status-dot-vbanNPFU.js";var x=o(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),S=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function C(e){return e?.runtime?.lastError?.trim()||``}function w(e){let n=t(`remoteStatusIssueDetailGeneric`),r=C(e);return r?`${n} (${r})`:n}function T(e){if(!e?.settings.enabled)return!1;let t=C(e);return S.some(e=>e.test(t))}function E(e){return T(e)?{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteStateReauthorizationRequired`),title:t(`remoteStatusReauthorizationTitle`),description:t(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:t(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:t(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:t(`statusReady`),title:t(`remoteStatusReadyTitle`),description:t(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:t(`connecting`),title:t(`remoteStatusConnectingTitle`),description:t(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteStateDisconnected`),title:t(`remoteStatusIssueTitle`),description:t(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:w(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteServiceStopped`),title:t(`remoteStatusNeedsServiceTitle`),description:t(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:t(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:t(`statusInactive`),title:t(`remoteStatusNeedsEnable`),description:t(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:t(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:t(`statusSetup`),title:t(`remoteStatusNeedsSignIn`),description:t(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:t(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var D=e(n(),1),O=i();function k(e){let{label:t,muted:n,value:r}=e;return(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,O.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,O.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function A(){let e=f(),n=c(),i=n.data,o=m(e=>e.actionLabel),S=(0,D.useMemo)(()=>E(i),[i]),C=!!o,w=i?.runtime?.deviceName?.trim()||i?.settings.deviceName?.trim()||t(`remoteDeviceNameAuto`),T=!!(i?.account.loggedIn&&h(i)),{hero:A,issueHint:j}=S;return(0,D.useEffect)(()=>{e.remoteAccessManager.syncStatus(i)},[e,i]),n.isLoading&&!i?(0,O.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`remoteLoading`)}):(0,O.jsxs)(v,{className:`space-y-6`,children:[(0,O.jsx)(y,{title:t(`remotePageTitle`),description:t(`remotePageDescription`)}),(0,O.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,O.jsxs)(l,{children:[(0,O.jsxs)(u,{className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,O.jsx)(p,{children:A.title}),(0,O.jsx)(b,{status:A.badgeStatus,label:A.badgeLabel})]}),(0,O.jsx)(g,{children:A.description})]}),(0,O.jsxs)(d,{className:`space-y-5`,children:[(0,O.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,O.jsx)(k,{label:t(`remoteSignedInAccount`),value:i?.account.email}),(0,O.jsx)(k,{label:t(`remoteDeviceName`),value:w}),(0,O.jsx)(k,{label:t(`remoteConnectionStatus`),value:A.badgeLabel}),(0,O.jsx)(k,{label:t(`remoteLastConnectedAt`),value:i?.runtime?.lastConnectedAt?r(i.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[S.primaryAction?(0,O.jsxs)(a,{onClick:()=>{if(S.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(i);return}if(S.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(i);return}e.remoteAccessManager.enableRemoteAccess(i)},disabled:C,children:[S.primaryAction.showRefreshIcon?(0,O.jsx)(s,{className:`mr-2 h-4 w-4`}):null,o||S.primaryAction.label]}):null,(0,O.jsxs)(a,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:C||!T,children:[(0,O.jsx)(_,{className:`mr-2 h-4 w-4`}),t(`remoteOpenDeviceList`)]}),i?.settings.enabled?(0,O.jsx)(a,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(i),disabled:C,children:t(`remoteDisable`)}):null]}),S.shouldShowIssueHint&&j?(0,O.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-amber-900`,children:j.title}),(0,O.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-amber-800`,children:j.body})]}):null,(0,O.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`remoteOpenWebHint`)})]})]}),(0,O.jsxs)(l,{children:[(0,O.jsxs)(u,{children:[(0,O.jsxs)(p,{className:`flex items-center gap-2`,children:[(0,O.jsx)(x,{className:`h-4 w-4 text-primary`}),t(`remoteDeviceSectionTitle`)]}),(0,O.jsx)(g,{children:t(`remoteDeviceSectionDescription`)})]}),(0,O.jsxs)(d,{className:`space-y-5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,O.jsx)(b,{status:i?.account.loggedIn?`ready`:`inactive`,label:i?.account.loggedIn?t(`remoteAccountConnected`):t(`remoteAccountNotConnected`)}),(0,O.jsx)(b,{status:i?.settings.enabled?`active`:`inactive`,label:i?.settings.enabled?t(`remoteEnabled`):t(`remoteStateDisabled`)}),(0,O.jsx)(b,{status:i?.service.running?`active`:`inactive`,label:i?.service.running?t(`remoteServiceRunning`):t(`remoteServiceStopped`)})]}),(0,O.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 bg-gray-50 px-4 py-3`,children:[(0,O.jsx)(k,{label:t(`remoteDeviceName`),value:w}),(0,O.jsx)(k,{label:t(`remoteConnectionStatus`),value:A.badgeLabel}),(0,O.jsx)(k,{label:t(`remoteLastConnectedAt`),value:i?.runtime?.lastConnectedAt?r(i.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,O.jsx)(`div`,{className:`rounded-2xl border border-dashed border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600`,children:i?.account.loggedIn?t(`remoteOpenWebHint`):t(`remoteStatusNeedsSignInDescription`)})]})]})]})]})}export{A as RemoteAccessPage};
@@ -0,0 +1 @@
1
+ import{_ as e,i as t,m as n,p as r}from"./i18n-eDHeDY0n.js";import{n as i,r as a}from"./dist-ccBFUi-o.js";import{i as o,s,t as c}from"./client-_i4MU2bB.js";import{t as l}from"./useMutation-CBWjE2uj.js";import{a as u,i as d,n as f,r as p,t as m}from"./select-DJ2MUjBB.js";import{t as h}from"./createLucideIcon-BSeTgkZW.js";import{t as g}from"./loader-circle-ACM1s51e.js";import{t as _}from"./play-CFUwCA2E.js";import{t as v}from"./plus-rYsv72JG.js";import{t as y}from"./rotate-cw-JtFzpNn6.js";import{t as b}from"./save-3S6-H3Xw.js";import{t as x}from"./trash-2-G48scll7.js";import{G as S,J as C,K as w,Q as T,Y as E,d as D,j as ee,l as te,nt as O,q as k,t as A,tt as j}from"./index-CF9xve0E.js";import{n as ne,t as M}from"./page-layout-vZnghcFy.js";import{t as N}from"./config-hints-BhTmc9P1.js";import{t as P}from"./switch-BsLtHOH-.js";var F=h(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),I=e(n(),1);async function L(){let e=await c.get(`/api/runtime/control`);if(!e.ok)throw Error(e.error.message);return e.data}async function R(){let e=await c.post(`/api/runtime/control/start-service`,{});if(!e.ok)throw Error(e.error.message);return e.data}async function z(){let e=await c.post(`/api/runtime/control/restart-service`,{});if(!e.ok)throw Error(e.error.message);return e.data}async function B(){let e=await c.post(`/api/runtime/control/stop-service`,{});if(!e.ok)throw Error(e.error.message);return e.data}var V=new class{constructor(){this.getControl=async()=>this.decorateForCurrentEnvironment(await L()),this.controlService=async e=>{let t=this.getDesktopBridge();if(e===`restart-service`&&t&&typeof t.restartService==`function`){let e=await t.restartService();return{accepted:e.accepted,action:`restart-service`,lifecycle:e.lifecycle,message:e.message}}return e===`start-service`?await R():e===`stop-service`?await B():await z()},this.restartApp=async()=>{let e=this.getDesktopBridge();if(!e||typeof e.restartApp!=`function`)throw Error(t(`runtimeRestartAppUnavailable`));let n=await e.restartApp();return{accepted:n.accepted,action:`restart-app`,lifecycle:n.lifecycle,message:n.message}},this.waitForRecovery=async(e={})=>{let n=e.timeoutMs??25e3,r=e.pollIntervalMs??1500,i=Date.now()+n,a=null;for(;Date.now()<i;)try{return await this.getControl()}catch(e){a=e,await this.sleep(r)}throw a instanceof Error?a:Error(t(`runtimeRecoveryTimedOut`))},this.decorateForCurrentEnvironment=e=>{let n=this.getDesktopBridge();return!n||typeof n.restartApp!=`function`?e:{...e,environment:`desktop-embedded`,serviceState:`running`,canStartService:{available:!1,requiresConfirmation:!1,impact:`none`},canStopService:{available:!1,requiresConfirmation:!0,impact:`brief-ui-disconnect`},canRestartApp:{available:!0,requiresConfirmation:!0,impact:`full-app-relaunch`},ownerLabel:t(`runtimeControlEnvironmentDesktop`),managementHint:t(`runtimeControlDesktopServiceHint`)}},this.getDesktopBridge=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.sleep=async e=>{await new Promise(t=>{window.setTimeout(t,e)})}}};function H(){return o({queryKey:[`runtime-control`],queryFn:async()=>await V.getControl(),staleTime:5e3,refetchOnWindowFocus:!0})}function U(){let e=s();return l({mutationFn:async e=>await V.controlService(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:[`runtime-control`]})}})}var W=r();function G(e){return t(e===`healthy`?`runtimeControlHealthy`:e===`starting-service`?`runtimeControlStartingService`:e===`restarting-service`?`runtimeControlRestartingService`:e===`stopping-service`?`runtimeControlStoppingService`:e===`restarting-app`?`runtimeControlRestartingApp`:e===`recovering`?`runtimeControlRecovering`:e===`failed`?`runtimeControlFailed`:`runtimeControlUnavailable`)}function K(e){return t(e===`running`?`runtimeControlServiceRunning`:e===`stopped`?`runtimeControlServiceStopped`:e===`starting`?`runtimeControlServiceStarting`:e===`stopping`?`runtimeControlServiceStopping`:e===`restarting`?`runtimeControlServiceRestarting`:`runtimeControlServiceUnknown`)}function q(e){return e.environment===`desktop-embedded`?t(`runtimeControlEnvironmentDesktop`):e.environment===`managed-local-service`?t(`runtimeControlEnvironmentManagedService`):e.environment===`self-hosted-web`?t(`runtimeControlEnvironmentSelfHosted`):t(`runtimeControlEnvironmentSharedWeb`)}function J(e){return e?[{action:`start-service`,capability:e.canStartService,label:t(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:t(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:t(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:t(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function Y(e){return t(e===`start-service`?`runtimeControlStartingServiceHelp`:e===`restart-service`?`runtimeControlRestartingServiceHelp`:e===`stop-service`?`runtimeControlStoppingServiceHelp`:`runtimeControlRestartingAppHelp`)}function X(e){let{busy:t,icon:n}=e;return t?(0,W.jsx)(g,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,W.jsx)(_,{className:`mr-2 h-4 w-4`}):n===`square`?(0,W.jsx)(F,{className:`mr-2 h-4 w-4`}):(0,W.jsx)(y,{className:`mr-2 h-4 w-4`})}function re(){let e=s(),n=H(),r=U(),[o,c]=(0,I.useState)(null),[l,u]=(0,I.useState)(null),[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(null),h=n.data,g=o??h?.lifecycle??`healthy`,_=l??h?.serviceState??`unknown`,v=d??h?.message??t(`runtimeControlDescription`),y=r.isPending||p!==null||g===`recovering`,b=J(h),x=()=>{c(null),u(null),f(null),m(null)},T=async n=>{let a=n===`start-service`?h?.canStartService:n===`stop-service`?h?.canStopService:h?.canRestartService;if(!a?.available){i.error(a?.reasonIfUnavailable??t(`runtimeControlLoadFailed`));return}if(!(n===`stop-service`&&a.requiresConfirmation&&!window.confirm(t(`runtimeControlStopServiceConfirm`)))){m(n),c(n===`start-service`?`starting-service`:n===`stop-service`?`stopping-service`:`restarting-service`),u(n===`start-service`?`starting`:n===`stop-service`?`stopping`:`restarting`),f(Y(n));try{let a=await r.mutateAsync(n);if(i.success(a.message),n===`stop-service`)return;c(`recovering`),f(t(`runtimeControlRecoveringHelp`));let o=await V.waitForRecovery();e.setQueryData([`runtime-control`],o),await e.invalidateQueries({queryKey:[`runtime-control`]}),x(),i.success(t(`runtimeControlRecovered`))}catch(e){let r=e instanceof Error?e.message:t(`runtimeControlActionFailed`);c(`failed`),u(n===`stop-service`?`running`:`unknown`),f(r),m(null),i.error(`${t(`runtimeControlActionFailed`)}: ${r}`)}}},D=async()=>{if(!h?.canRestartApp.available){i.error(h?.canRestartApp.reasonIfUnavailable??t(`runtimeRestartAppUnavailable`));return}if(window.confirm(t(`runtimeControlRestartAppConfirm`))){m(`restart-app`),c(`restarting-app`),f(t(`runtimeControlRestartingAppHelp`));try{let e=await V.restartApp();i.success(e.message)}catch(e){let n=e instanceof Error?e.message:t(`runtimeControlActionFailed`);c(`failed`),f(n),m(null),i.error(`${t(`runtimeControlActionFailed`)}: ${n}`)}}};return(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:t(`runtimeControlTitle`)}),(0,W.jsx)(k,{children:t(`runtimeControlDescription`)})]}),(0,W.jsxs)(w,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`rounded-xl border border-gray-200 bg-gray-50 p-4 space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:K(_)}),(0,W.jsx)(`div`,{className:`text-xs text-gray-500`,children:h?q(h):t(`runtimeControlLoading`)})]}),(0,W.jsx)(`p`,{className:`text-sm text-gray-600`,children:v}),(0,W.jsx)(`div`,{className:`text-xs text-gray-500`,children:G(g)}),h?.managementHint?(0,W.jsx)(`p`,{className:`text-xs text-gray-500`,children:h.managementHint}):null,n.isError&&!y?(0,W.jsx)(`p`,{className:`text-sm text-amber-700`,children:n.error instanceof Error?n.error.message:t(`runtimeControlLoadFailed`)}):null]}),(0,W.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:b.map(e=>{let t=p===e.action,n=!e.capability.available||y;return(0,W.jsxs)(a,{type:`button`,variant:e.variant??`default`,onClick:()=>{if(e.action===`restart-app`){D();return}T(e.action)},disabled:n,children:[(0,W.jsx)(X,{icon:e.icon,busy:t}),e.label]},e.action)})}),b.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,W.jsx)(`p`,{className:`text-xs text-gray-500`,children:e.capability.reasonIfUnavailable},`${e.action}-reason`))]})]})}var Z=T(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),Q=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}Z.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();Z.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){Z.setState({supported:!0,initialized:!0,busyAction:null}),i.error(`${t(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{Z.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let n=this.getDesktopApi();if(!n)throw Error(t(`runtimePresenceLaunchAtLoginUnavailable`));Z.setState({busyAction:`saving-preferences`});try{let r=await n.updatePresencePreferences(e);return Z.setState({supported:!0,initialized:!0,snapshot:r}),i.success(t(`runtimePresenceSaved`)),r}catch(e){throw i.error(`${t(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{Z.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:t(`error`)}};function $(e){let{description:t,title:n}=e;return(0,W.jsxs)(`div`,{className:`rounded-xl border border-gray-200 bg-gray-50 p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:n}),(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-gray-600`,children:t})]})}function ie(){let e=H().data?.environment,n=Z(e=>e.supported),r=Z(e=>e.initialized),i=Z(e=>e.busyAction),a=Z(e=>e.snapshot);return(0,I.useEffect)(()=>{if(e===`desktop-embedded`){Q.start();return}Q.markUnsupported()},[e]),e===`desktop-embedded`?(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:t(`runtimePresenceTitle`)}),(0,W.jsx)(k,{children:t(`runtimePresenceDescription`)})]}),(0,W.jsxs)(w,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`rounded-xl border border-gray-200 bg-gray-50 p-4`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-gray-500`,children:t(`runtimePresenceBehaviorLabel`)}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-medium text-gray-900`,children:a?.closeToBackground?t(`runtimePresenceBehaviorBackground`):t(`runtimePresenceBehaviorQuit`)})]}),!r||n&&!a?(0,W.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`runtimePresenceLoading`)}):null,a?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4 rounded-xl border border-gray-200 p-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(j,{htmlFor:`runtime-presence-close-background`,children:t(`runtimePresenceCloseToBackground`)}),(0,W.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`runtimePresenceCloseToBackgroundHelp`)})]}),(0,W.jsx)(P,{id:`runtime-presence-close-background`,"aria-label":t(`runtimePresenceCloseToBackground`),checked:a.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{Q.updatePreferences({closeToBackground:e})}})]}),(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4 rounded-xl border border-gray-200 p-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(j,{htmlFor:`runtime-presence-launch-login`,children:t(`runtimePresenceLaunchAtLogin`)}),(0,W.jsx)(`p`,{className:`text-sm text-gray-500`,children:a.supportsLaunchAtLogin?t(`runtimePresenceLaunchAtLoginHelp`):a.launchAtLoginReason??t(`runtimePresenceLaunchAtLoginUnavailable`)})]}),(0,W.jsx)(P,{id:`runtime-presence-launch-login`,"aria-label":t(`runtimePresenceLaunchAtLogin`),checked:a.launchAtLogin,disabled:!a.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{Q.updatePreferences({launchAtLogin:e})}})]})]}):null]})]}):e===`managed-local-service`?(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:t(`runtimePresenceTitle`)}),(0,W.jsx)(k,{children:t(`runtimePresenceDescription`)})]}),(0,W.jsx)(w,{children:(0,W.jsx)($,{title:t(`runtimePresenceManagedLocalTitle`),description:t(`runtimePresenceManagedLocalDescription`)})})]}):e===`self-hosted-web`?(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:t(`runtimePresenceTitle`)}),(0,W.jsx)(k,{children:t(`runtimePresenceDescription`)})]}),(0,W.jsx)(w,{children:(0,W.jsx)($,{title:t(`runtimePresenceSelfHostedTitle`),description:t(`runtimePresenceSelfHostedDescription`)})})]}):e===`shared-web`?(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:t(`runtimePresenceTitle`)}),(0,W.jsx)(k,{children:t(`runtimePresenceDescription`)})]}),(0,W.jsx)(w,{children:(0,W.jsx)($,{title:t(`runtimePresenceSharedTitle`),description:t(`runtimePresenceSharedDescription`)})})]}):(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:t(`runtimePresenceTitle`)}),(0,W.jsx)(k,{children:t(`runtimePresenceDescription`)})]}),(0,W.jsx)(w,{children:(0,W.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`runtimePresenceLoading`)})})]})}function ae(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0,maxToolIterations:void 0}}function oe(){return{agentId:``,match:{channel:``,accountId:``}}}function se(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens,maxToolIterations:e.maxToolIterations}}function ce(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function le(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ue(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),typeof e.maxToolIterations==`number`&&(t.maxToolIterations=e.maxToolIterations),t}var de=[{value:`main`,label:`main`},{value:`per-peer`,label:`per-peer`},{value:`per-channel-peer`,label:`per-channel-peer`},{value:`per-account-channel-peer`,label:`per-account-channel-peer`}],fe={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function pe(){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(M,{title:t(`runtimePageTitle`),description:t(`runtimePageDescription`)}),(0,W.jsx)(re,{}),(0,W.jsx)(ie,{}),(0,W.jsx)(A,{})]})}function me(){let{data:e,isLoading:n}=te(),{data:r}=D(),o=ee(),[s,c]=(0,I.useState)([]),[l,h]=(0,I.useState)([]),[g,_]=(0,I.useState)([]),[y,T]=(0,I.useState)(`per-channel-peer`),[A,j]=(0,I.useState)(2e5),[M,F]=(0,I.useState)(`native`);(0,I.useEffect)(()=>{e&&(c((e.agents.list??[]).map(se)),h((e.bindings??[]).map(ce)),_(Object.entries(e.agents.runtimes?.entries??{}).map(([e,t])=>({id:e,enabled:t.enabled!==!1,label:t.label??``,type:t.type,config:t.config??{},configText:JSON.stringify(t.config??{},null,2)}))),T(e.session?.dmScope??`per-channel-peer`),j(e.agents.defaults.contextTokens??2e5),F(e.agents.defaults.engine??`native`))},[e]);let L=r?.uiHints,R=N(`session.dmScope`,L),z=N(`agents.defaults.contextTokens`,L),B=N(`agents.defaults.engine`,L),V=N(`agents.list.*.contextTokens`,L),H=N(`agents.list.*.engine`,L),U=N(`agents.list`,L),G=N(`bindings`,L),K=N(`agents.runtimes.entries`,L),q=(0,I.useMemo)(()=>{let e=new Set([`main`]);return s.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[s]),J=(e,t)=>{c(n=>n.map((n,r)=>r===e?{...n,...t}:n))},Y=(e,t)=>{h(n=>n.map((n,r)=>r===e?t:n))},X=(e,t)=>{_(n=>n.map((n,r)=>r===e?{...n,...t}:n))},re=e=>{_(t=>t.filter((t,n)=>n!==e))};return n||!e?(0,W.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`runtimeLoading`)}):(0,W.jsxs)(ne,{className:`space-y-6`,children:[(0,W.jsx)(pe,{}),(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:R?.label??t(`dmScope`)}),(0,W.jsx)(k,{children:R?.help??t(`dmScopeHelp`)})]}),(0,W.jsxs)(w,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:z?.label??t(`defaultContextTokens`)}),(0,W.jsx)(O,{type:`number`,min:1e3,step:1e3,value:A,onChange:e=>j(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3))}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500`,children:z?.help??t(`defaultContextTokensHelp`)})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:B?.label??t(`defaultEngine`)}),(0,W.jsx)(O,{value:M,onChange:e=>F(e.target.value),placeholder:t(`defaultEnginePlaceholder`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500`,children:B?.help??t(`defaultEngineHelp`)})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:R?.label??t(`dmScope`)}),(0,W.jsxs)(m,{value:y,onValueChange:e=>T(e),children:[(0,W.jsx)(d,{children:(0,W.jsx)(u,{})}),(0,W.jsx)(f,{children:de.map(e=>(0,W.jsx)(p,{value:e.value,children:e.label},e.value))})]})]})]})]}),(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:K?.label??`Runtime Entries`}),(0,W.jsx)(k,{children:K?.help??`统一管理可见的 runtime entry 与其配置。`})]}),(0,W.jsxs)(w,{className:`space-y-3`,children:[g.map((e,n)=>(0,W.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,W.jsx)(O,{value:e.id,onChange:e=>X(n,{id:e.target.value}),placeholder:`entry id,例如 hermes`}),(0,W.jsx)(O,{value:e.label??``,onChange:e=>X(n,{label:e.target.value}),placeholder:`展示名称,例如 Hermes`}),(0,W.jsx)(O,{value:e.type,onChange:e=>X(n,{type:e.target.value}),placeholder:`runtime type,例如 narp-stdio`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-200 px-3 py-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-gray-700`,children:`Enabled`}),(0,W.jsx)(P,{checked:e.enabled!==!1,onCheckedChange:e=>X(n,{enabled:e})})]})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:`Config JSON`}),(0,W.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-gray-200 px-3 py-2 text-sm font-mono`,value:e.configText,onChange:e=>X(n,{configText:e.target.value}),spellCheck:!1})]}),(0,W.jsx)(`div`,{className:`flex justify-end`,children:(0,W.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>re(n),children:[(0,W.jsx)(x,{className:`mr-2 h-4 w-4`}),t(`deleteButton`)]})})]},`${n}-${e.id||`runtime-entry`}`)),(0,W.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>{_(e=>[...e,{id:``,enabled:!0,label:``,type:`narp-stdio`,config:fe,configText:JSON.stringify(fe,null,2)}])},children:[(0,W.jsx)(v,{className:`mr-2 h-4 w-4`}),`Add Runtime Entry`]})]})]}),(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:U?.label??t(`agentList`)}),(0,W.jsx)(k,{children:U?.help??t(`agentListHelp`)})]}),(0,W.jsxs)(w,{className:`space-y-3`,children:[s.map((e,n)=>(0,W.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,W.jsx)(O,{value:e.id,onChange:e=>J(n,{id:e.target.value}),placeholder:t(`agentIdPlaceholder`)}),(0,W.jsx)(O,{value:e.workspace??``,onChange:e=>J(n,{workspace:e.target.value}),placeholder:t(`workspaceOverridePlaceholder`)}),(0,W.jsx)(O,{value:e.model??``,onChange:e=>J(n,{model:e.target.value}),placeholder:t(`modelOverridePlaceholder`)}),(0,W.jsx)(O,{value:e.runtime??e.engine??``,onChange:e=>J(n,{runtime:e.target.value}),placeholder:H?.label??t(`engineOverridePlaceholder`)}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,W.jsx)(O,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>J(n,{contextTokens:le(e.target.value)}),placeholder:V?.label??t(`contextTokensPlaceholder`)}),(0,W.jsx)(O,{type:`number`,min:1,value:e.maxToolIterations??``,onChange:e=>J(n,{maxToolIterations:le(e.target.value)}),placeholder:t(`maxToolsPlaceholder`)})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600`,children:[(0,W.jsx)(P,{checked:!!e.default,onCheckedChange:e=>{if(!e){J(n,{default:!1});return}c(e=>e.map((e,t)=>({...e,default:t===n})))}}),(0,W.jsx)(`span`,{children:t(`defaultAgent`)})]}),(0,W.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>c(e=>e.filter((e,t)=>t!==n)),children:[(0,W.jsx)(x,{className:`h-4 w-4 mr-1`}),t(`remove`)]})]})]},`${n}-${e.id}`)),(0,W.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>c(e=>[...e,ae()]),children:[(0,W.jsx)(v,{className:`h-4 w-4 mr-2`}),t(`addAgent`)]})]})]}),(0,W.jsxs)(S,{children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(E,{children:G?.label??t(`bindings`)}),(0,W.jsx)(k,{children:G?.help??t(`bindingsHelp`)})]}),(0,W.jsxs)(w,{className:`space-y-3`,children:[l.map((e,n)=>{let r=e.match.peer?.kind??``;return(0,W.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,W.jsx)(O,{value:e.agentId,onChange:t=>Y(n,{...e,agentId:t.target.value}),placeholder:t(`targetAgentIdPlaceholder`)}),(0,W.jsx)(O,{value:e.match.channel,onChange:t=>Y(n,{...e,match:{...e.match,channel:t.target.value}}),placeholder:t(`channelPlaceholder`)}),(0,W.jsx)(O,{value:e.match.accountId??``,onChange:t=>Y(n,{...e,match:{...e.match,accountId:t.target.value}}),placeholder:t(`accountIdOptionalPlaceholder`)}),(0,W.jsxs)(m,{value:r||`__none__`,onValueChange:t=>{let r=t===`__none__`?``:t;if(!r){Y(n,{...e,match:{...e.match,peer:void 0}});return}Y(n,{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}})},children:[(0,W.jsx)(d,{children:(0,W.jsx)(u,{})}),(0,W.jsxs)(f,{children:[(0,W.jsx)(p,{value:`__none__`,children:t(`peerKindOptional`)}),(0,W.jsx)(p,{value:`direct`,children:`direct`}),(0,W.jsx)(p,{value:`group`,children:`group`}),(0,W.jsx)(p,{value:`channel`,children:`channel`})]})]}),(0,W.jsx)(O,{value:e.match.peer?.id??``,onChange:t=>Y(n,{...e,match:{...e.match,peer:r?{kind:r,id:t.target.value}:void 0}}),placeholder:t(`peerIdPlaceholder`)})]}),(0,W.jsx)(`div`,{className:`flex justify-end`,children:(0,W.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>h(e=>e.filter((e,t)=>t!==n)),children:[(0,W.jsx)(x,{className:`h-4 w-4 mr-1`}),t(`remove`)]})})]},`${n}-${e.agentId}`)}),(0,W.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>h(e=>[...e,oe()]),children:[(0,W.jsx)(v,{className:`h-4 w-4 mr-2`}),t(`addBinding`)]})]})]}),(0,W.jsx)(`div`,{className:`flex justify-end`,children:(0,W.jsxs)(a,{type:`button`,onClick:()=>{try{let e=s.map((e,n)=>{if(!e.id.trim())throw Error(t(`agentIdRequiredError`).replace(`{index}`,String(n)));return ue(e)}),n=e.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0){i.error(`${t(`duplicateAgentId`)}: ${n[0]}`);return}let r=l.map((e,n)=>{let r=e.agentId.trim(),i=e.match.channel.trim(),a=e.match.accountId?.trim()??``,o=e.match.peer?.kind,s=e.match.peer?.id?.trim()??``;if(!r)throw Error(t(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!q.has(r))throw Error(`${t(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${r}`);if(!i)throw Error(t(`bindingChannelRequired`).replace(`{index}`,String(n)));let c={agentId:r,match:{channel:i}};if(a&&(c.match.accountId=a),o){if(!s)throw Error(t(`bindingPeerIdRequired`).replace(`{index}`,String(n)));c.match.peer={kind:o,id:s}}return c}),a=g.reduce((e,t,n)=>{let r=t.id.trim(),i=t.type.trim();if(!r)throw Error(`Runtime entry id is required at index ${n}.`);if(!i)throw Error(`Runtime entry type is required for "${r}".`);if(e[r])throw Error(`Duplicate runtime entry id: ${r}`);let a=t.configText.trim()?JSON.parse(t.configText):{};if(a&&(typeof a!=`object`||Array.isArray(a)))throw Error(`Runtime entry config for "${r}" must be a JSON object.`);return e[r]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:i,config:a??{}},e},{});o.mutate({data:{agents:{defaults:{contextTokens:Math.max(1e3,A),engine:M.trim()||`native`},list:e,runtimes:{entries:a}},bindings:r,session:{dmScope:y}}})}catch(e){let t=e instanceof Error?e.message:String(e);i.error(t)}},disabled:o.isPending,children:[(0,W.jsx)(b,{className:`h-4 w-4 mr-2`}),o.isPending?t(`saving`):t(`saveRuntimeSettings`)]})})]})}export{me as RuntimeConfig};
@@ -1 +1 @@
1
- import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-CwHZ-9vt.js";import{r as a}from"./dist-DmAlInRu.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-Caud8QvU.js";import{t as d}from"./external-link-DFjw3x1B.js";import{t as f}from"./search-MChQRYR1.js";import{c as p,et as m,gt as h,j as g,l as _,tt as v}from"./index-DdksE6U3.js";import{n as y,t as ee}from"./page-layout-Da3i3r6G.js";import{i as te,r as ne,t as re}from"./config-layout-DmlGaay2.js";var b=e(n(),1),x=r(),S=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],C=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],ie={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`};function ae({apiKey:e,apiKeyMasked:n,baseUrl:r,summary:i,freshness:f,docsUrl:p,onApiKeyChange:h,onBaseUrlChange:g,onSummaryChange:_,onFreshnessChange:y}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(m,{children:t(`apiKey`)}),(0,x.jsx)(v,{type:`password`,value:e,onChange:e=>h(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(m,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(v,{value:r,onChange:e=>g(e.target.value),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(m,{children:t(`searchProviderSummary`)}),(0,x.jsxs)(u,{value:i?`true`:`false`,onValueChange:e=>_(e===`true`),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsxs)(c,{children:[(0,x.jsx)(l,{value:`true`,children:t(`enabled`)}),(0,x.jsx)(l,{value:`false`,children:t(`disabled`)})]})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(m,{children:t(`searchProviderFreshness`)}),(0,x.jsxs)(u,{value:f,onValueChange:y,children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:S.map(e=>(0,x.jsx)(l,{value:e.value,children:t(e.label)},e.value))})]})]})]}),(0,x.jsx)(`div`,{className:`space-y-2`,children:(0,x.jsx)(`a`,{href:p??`https://open.bocha.cn`,target:`_blank`,rel:`noreferrer`,children:(0,x.jsxs)(a,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,x.jsx)(d,{className:`mr-2 h-4 w-4`}),t(`searchProviderOpenDocs`)]})})})]})}function w({apiKey:e,apiKeyMasked:n,baseUrl:r,searchDepth:i,includeAnswer:f,docsUrl:p,onApiKeyChange:h,onBaseUrlChange:g,onSearchDepthChange:_,onIncludeAnswerChange:y}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(m,{children:t(`apiKey`)}),(0,x.jsx)(v,{type:`password`,value:e,onChange:e=>h(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(m,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(v,{value:r,onChange:e=>g(e.target.value),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(m,{children:t(`searchProviderSearchDepth`)}),(0,x.jsxs)(u,{value:i,onValueChange:e=>_(e),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:C.map(e=>(0,x.jsx)(l,{value:e.value,children:t(e.label)},e.value))})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(m,{children:t(`searchProviderIncludeAnswer`)}),(0,x.jsxs)(u,{value:f?`true`:`false`,onValueChange:e=>y(e===`true`),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsxs)(c,{children:[(0,x.jsx)(l,{value:`true`,children:t(`enabled`)}),(0,x.jsx)(l,{value:`false`,children:t(`disabled`)})]})]})]})]}),p?(0,x.jsx)(`div`,{className:`space-y-2`,children:(0,x.jsx)(`a`,{href:p,target:`_blank`,rel:`noreferrer`,children:(0,x.jsxs)(a,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,x.jsx)(d,{className:`mr-2 h-4 w-4`}),t(`searchProviderOpenDocs`)]})})}):null]})}function oe({apiKey:e,apiKeyMasked:n,baseUrl:r,onApiKeyChange:i,onBaseUrlChange:a}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(m,{children:t(`apiKey`)}),(0,x.jsx)(v,{type:`password`,value:e,onChange:e=>i(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(m,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(v,{value:r,onChange:e=>a(e.target.value),className:`rounded-xl`})]})]})}function T(){let{data:e}=p(),{data:n}=_(),r=g(),d=(0,b.useMemo)(()=>n?.search??[],[n]),S=e?.search,[C,T]=(0,b.useState)(`bocha`),[E,D]=(0,b.useState)(`bocha`),[O,k]=(0,b.useState)([`bocha`]),[A,j]=(0,b.useState)(`10`),[M,se]=(0,b.useState)(``),[N,P]=(0,b.useState)(`https://api.bocha.cn/v1/web-search`),[F,I]=(0,b.useState)(!0),[L,R]=(0,b.useState)(`noLimit`),[z,ce]=(0,b.useState)(``),[B,V]=(0,b.useState)(`https://api.tavily.com/search`),[H,U]=(0,b.useState)(`basic`),[W,G]=(0,b.useState)(!1),[K,le]=(0,b.useState)(``),[q,J]=(0,b.useState)(`https://api.search.brave.com/res/v1/web/search`);(0,b.useEffect)(()=>{S&&(T(S.provider),D(S.provider),k(S.enabledProviders),j(String(S.defaults.maxResults)),P(S.providers.bocha.baseUrl),I(!!S.providers.bocha.summary),R(S.providers.bocha.freshness??`noLimit`),V(S.providers.tavily.baseUrl),U(S.providers.tavily.searchDepth??`basic`),G(!!S.providers.tavily.includeAnswer),J(S.providers.brave.baseUrl))},[S]);let Y=(0,b.useMemo)(()=>d.find(e=>e.name===C),[d,C]),X=S?.providers[C],Z=O.includes(C),Q=X?.docsUrl??Y?.docsUrl,ue=t(Z?`searchProviderDeactivate`:`searchProviderActivate`),$=(e=O,t=E)=>({provider:t,enabledProviders:e,defaults:{maxResults:Number(A)||10},providers:{bocha:{apiKey:M||void 0,baseUrl:N,summary:F,freshness:L},tavily:{apiKey:z||void 0,baseUrl:B,searchDepth:H,includeAnswer:W},brave:{apiKey:K||void 0,baseUrl:q}}});return!S||d.length===0?(0,x.jsx)(`div`,{className:`p-8`,children:t(`loading`)}):(0,x.jsxs)(y,{children:[(0,x.jsx)(ee,{title:t(`searchPageTitle`),description:t(`searchPageDescription`)}),(0,x.jsxs)(`div`,{className:te,children:[(0,x.jsxs)(`section`,{className:ne,children:[(0,x.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-4`,children:(0,x.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-gray-500`,children:t(`searchChannels`)})}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:d.map(e=>{let n=S.providers[e.name],r=O.includes(e.name);return(0,x.jsx)(`button`,{type:`button`,onClick:()=>T(e.name),className:i(`w-full rounded-xl border p-3 text-left transition-all`,C===e.name?`border-primary/30 bg-primary-50/40 shadow-sm`:`border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70`),children:(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.displayName}),(0,x.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-gray-500`,children:t(ie[e.name])})]}),(0,x.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,x.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:n.apiKeySet?t(`searchStatusConfigured`):t(`searchStatusNeedsSetup`)}),r?(0,x.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:t(`searchProviderActivated`)}):null]})]})},e.name)})})]}),(0,x.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),r.mutate({data:$()})},className:i(re,`p-6`),children:!Y||!X?(0,x.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:t(`searchNoProviderSelected`)}):(0,x.jsxs)(`div`,{className:`space-y-6 overflow-y-auto`,children:[(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,x.jsx)(f,{className:`h-5 w-5`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:Y.displayName}),(0,x.jsx)(`p`,{className:`text-sm text-gray-500`,children:Y.description})]})]}),(0,x.jsx)(a,{type:`button`,variant:Z?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=Z?O.filter(e=>e!==C):[...O,C];k(e),r.mutate({data:$(e)})},children:ue})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(m,{children:t(`searchActiveProvider`)}),(0,x.jsxs)(u,{value:E,onValueChange:e=>{D(e)},children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:d.map(e=>(0,x.jsx)(l,{value:e.name,children:e.displayName},e.name))})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(m,{children:t(`searchDefaultMaxResults`)}),(0,x.jsx)(v,{value:A,onChange:e=>j(e.target.value),inputMode:`numeric`,className:`rounded-xl`})]})]}),C===`bocha`?(0,x.jsx)(ae,{apiKey:M,apiKeyMasked:S.providers.bocha.apiKeyMasked,baseUrl:N,summary:F,freshness:L,docsUrl:Q,onApiKeyChange:se,onBaseUrlChange:P,onSummaryChange:I,onFreshnessChange:R}):C===`tavily`?(0,x.jsx)(w,{apiKey:z,apiKeyMasked:S.providers.tavily.apiKeyMasked,baseUrl:B,searchDepth:H,includeAnswer:W,docsUrl:Q,onApiKeyChange:ce,onBaseUrlChange:V,onSearchDepthChange:U,onIncludeAnswerChange:G}):(0,x.jsx)(oe,{apiKey:K,apiKeyMasked:S.providers.brave.apiKeyMasked,baseUrl:q,onApiKeyChange:le,onBaseUrlChange:J}),(0,x.jsx)(`div`,{className:`flex justify-end`,children:(0,x.jsxs)(a,{type:`submit`,disabled:r.isPending,children:[(0,x.jsx)(h,{className:`mr-2 h-4 w-4`}),r.isPending?t(`saving`):t(`saveChanges`)]})})]})})]})]})}export{T as SearchConfig};
1
+ import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-eDHeDY0n.js";import{r as a}from"./dist-ccBFUi-o.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DJ2MUjBB.js";import{t as d}from"./external-link-BgErLCNT.js";import{t as f}from"./search-3kFR_zh9.js";import{M as p,_t as m,l as h,nt as g,tt as _,u as v}from"./index-CF9xve0E.js";import{n as y,t as ee}from"./page-layout-vZnghcFy.js";import{i as te,r as ne,t as re}from"./config-layout-CHs0mAaR.js";var b=e(n(),1),x=r(),S=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],C=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],ie={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`};function ae({apiKey:e,apiKeyMasked:n,baseUrl:r,summary:i,freshness:f,docsUrl:p,onApiKeyChange:m,onBaseUrlChange:h,onSummaryChange:v,onFreshnessChange:y}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`apiKey`)}),(0,x.jsx)(g,{type:`password`,value:e,onChange:e=>m(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(g,{value:r,onChange:e=>h(e.target.value),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderSummary`)}),(0,x.jsxs)(u,{value:i?`true`:`false`,onValueChange:e=>v(e===`true`),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsxs)(c,{children:[(0,x.jsx)(l,{value:`true`,children:t(`enabled`)}),(0,x.jsx)(l,{value:`false`,children:t(`disabled`)})]})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderFreshness`)}),(0,x.jsxs)(u,{value:f,onValueChange:y,children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:S.map(e=>(0,x.jsx)(l,{value:e.value,children:t(e.label)},e.value))})]})]})]}),(0,x.jsx)(`div`,{className:`space-y-2`,children:(0,x.jsx)(`a`,{href:p??`https://open.bocha.cn`,target:`_blank`,rel:`noreferrer`,children:(0,x.jsxs)(a,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,x.jsx)(d,{className:`mr-2 h-4 w-4`}),t(`searchProviderOpenDocs`)]})})})]})}function w({apiKey:e,apiKeyMasked:n,baseUrl:r,searchDepth:i,includeAnswer:f,docsUrl:p,onApiKeyChange:m,onBaseUrlChange:h,onSearchDepthChange:v,onIncludeAnswerChange:y}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`apiKey`)}),(0,x.jsx)(g,{type:`password`,value:e,onChange:e=>m(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(g,{value:r,onChange:e=>h(e.target.value),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderSearchDepth`)}),(0,x.jsxs)(u,{value:i,onValueChange:e=>v(e),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:C.map(e=>(0,x.jsx)(l,{value:e.value,children:t(e.label)},e.value))})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderIncludeAnswer`)}),(0,x.jsxs)(u,{value:f?`true`:`false`,onValueChange:e=>y(e===`true`),children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsxs)(c,{children:[(0,x.jsx)(l,{value:`true`,children:t(`enabled`)}),(0,x.jsx)(l,{value:`false`,children:t(`disabled`)})]})]})]})]}),p?(0,x.jsx)(`div`,{className:`space-y-2`,children:(0,x.jsx)(`a`,{href:p,target:`_blank`,rel:`noreferrer`,children:(0,x.jsxs)(a,{type:`button`,variant:`outline`,className:`rounded-xl`,children:[(0,x.jsx)(d,{className:`mr-2 h-4 w-4`}),t(`searchProviderOpenDocs`)]})})}):null]})}function oe({apiKey:e,apiKeyMasked:n,baseUrl:r,onApiKeyChange:i,onBaseUrlChange:a}){return(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`apiKey`)}),(0,x.jsx)(g,{type:`password`,value:e,onChange:e=>i(e.target.value),placeholder:n||t(`enterApiKey`),className:`rounded-xl`})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchProviderBaseUrl`)}),(0,x.jsx)(g,{value:r,onChange:e=>a(e.target.value),className:`rounded-xl`})]})]})}function T(){let{data:e}=h(),{data:n}=v(),r=p(),d=(0,b.useMemo)(()=>n?.search??[],[n]),S=e?.search,[C,T]=(0,b.useState)(`bocha`),[E,D]=(0,b.useState)(`bocha`),[O,k]=(0,b.useState)([`bocha`]),[A,j]=(0,b.useState)(`10`),[M,se]=(0,b.useState)(``),[N,P]=(0,b.useState)(`https://api.bocha.cn/v1/web-search`),[F,I]=(0,b.useState)(!0),[L,R]=(0,b.useState)(`noLimit`),[z,ce]=(0,b.useState)(``),[B,V]=(0,b.useState)(`https://api.tavily.com/search`),[H,U]=(0,b.useState)(`basic`),[W,G]=(0,b.useState)(!1),[K,le]=(0,b.useState)(``),[q,J]=(0,b.useState)(`https://api.search.brave.com/res/v1/web/search`);(0,b.useEffect)(()=>{S&&(T(S.provider),D(S.provider),k(S.enabledProviders),j(String(S.defaults.maxResults)),P(S.providers.bocha.baseUrl),I(!!S.providers.bocha.summary),R(S.providers.bocha.freshness??`noLimit`),V(S.providers.tavily.baseUrl),U(S.providers.tavily.searchDepth??`basic`),G(!!S.providers.tavily.includeAnswer),J(S.providers.brave.baseUrl))},[S]);let Y=(0,b.useMemo)(()=>d.find(e=>e.name===C),[d,C]),X=S?.providers[C],Z=O.includes(C),Q=X?.docsUrl??Y?.docsUrl,ue=t(Z?`searchProviderDeactivate`:`searchProviderActivate`),$=(e=O,t=E)=>({provider:t,enabledProviders:e,defaults:{maxResults:Number(A)||10},providers:{bocha:{apiKey:M||void 0,baseUrl:N,summary:F,freshness:L},tavily:{apiKey:z||void 0,baseUrl:B,searchDepth:H,includeAnswer:W},brave:{apiKey:K||void 0,baseUrl:q}}});return!S||d.length===0?(0,x.jsx)(`div`,{className:`p-8`,children:t(`loading`)}):(0,x.jsxs)(y,{children:[(0,x.jsx)(ee,{title:t(`searchPageTitle`),description:t(`searchPageDescription`)}),(0,x.jsxs)(`div`,{className:te,children:[(0,x.jsxs)(`section`,{className:ne,children:[(0,x.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-4`,children:(0,x.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-gray-500`,children:t(`searchChannels`)})}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-3`,children:d.map(e=>{let n=S.providers[e.name],r=O.includes(e.name);return(0,x.jsx)(`button`,{type:`button`,onClick:()=>T(e.name),className:i(`w-full rounded-xl border p-3 text-left transition-all`,C===e.name?`border-primary/30 bg-primary-50/40 shadow-sm`:`border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70`),children:(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.displayName}),(0,x.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-gray-500`,children:t(ie[e.name])})]}),(0,x.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,x.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600`,children:n.apiKeySet?t(`searchStatusConfigured`):t(`searchStatusNeedsSetup`)}),r?(0,x.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:t(`searchProviderActivated`)}):null]})]})},e.name)})})]}),(0,x.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),r.mutate({data:$()})},className:i(re,`p-6`),children:!Y||!X?(0,x.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-gray-500`,children:t(`searchNoProviderSelected`)}):(0,x.jsxs)(`div`,{className:`space-y-6 overflow-y-auto`,children:[(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white`,children:(0,x.jsx)(f,{className:`h-5 w-5`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:Y.displayName}),(0,x.jsx)(`p`,{className:`text-sm text-gray-500`,children:Y.description})]})]}),(0,x.jsx)(a,{type:`button`,variant:Z?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=Z?O.filter(e=>e!==C):[...O,C];k(e),r.mutate({data:$(e)})},children:ue})]}),(0,x.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchActiveProvider`)}),(0,x.jsxs)(u,{value:E,onValueChange:e=>{D(e)},children:[(0,x.jsx)(s,{className:`rounded-xl`,children:(0,x.jsx)(o,{})}),(0,x.jsx)(c,{children:d.map(e=>(0,x.jsx)(l,{value:e.name,children:e.displayName},e.name))})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(_,{children:t(`searchDefaultMaxResults`)}),(0,x.jsx)(g,{value:A,onChange:e=>j(e.target.value),inputMode:`numeric`,className:`rounded-xl`})]})]}),C===`bocha`?(0,x.jsx)(ae,{apiKey:M,apiKeyMasked:S.providers.bocha.apiKeyMasked,baseUrl:N,summary:F,freshness:L,docsUrl:Q,onApiKeyChange:se,onBaseUrlChange:P,onSummaryChange:I,onFreshnessChange:R}):C===`tavily`?(0,x.jsx)(w,{apiKey:z,apiKeyMasked:S.providers.tavily.apiKeyMasked,baseUrl:B,searchDepth:H,includeAnswer:W,docsUrl:Q,onApiKeyChange:ce,onBaseUrlChange:V,onSearchDepthChange:U,onIncludeAnswerChange:G}):(0,x.jsx)(oe,{apiKey:K,apiKeyMasked:S.providers.brave.apiKeyMasked,baseUrl:q,onApiKeyChange:le,onBaseUrlChange:J}),(0,x.jsx)(`div`,{className:`flex justify-end`,children:(0,x.jsxs)(a,{type:`submit`,disabled:r.isPending,children:[(0,x.jsx)(m,{className:`mr-2 h-4 w-4`}),r.isPending?t(`saving`):t(`saveChanges`)]})})]})})]})]})}export{T as SearchConfig};
@@ -1,3 +1,3 @@
1
- import{_ as e,i as t,m as n,p as r}from"./i18n-CwHZ-9vt.js";import{n as i,r as a}from"./dist-DmAlInRu.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-Caud8QvU.js";import{t as d}from"./plus-DUOVbsyQ.js";import{t as f}from"./save-DHGmi2e9.js";import{t as p}from"./trash-2-C6caKPoz.js";import{G as m,J as h,K as g,M as _,W as v,c as y,et as b,q as x,tt as S}from"./index-DdksE6U3.js";import{n as C,t as w}from"./page-layout-Da3i3r6G.js";import{t as T}from"./switch-0rmPBRKI.js";var E=e(n(),1),D=r(),O=[`env`,`file`,`exec`];function k(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function A(){return{path:``,source:`env`,provider:``,id:``}}function j(e,t){return t.source===`env`?{...k(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...k(e),source:`file`,path:t.path}:{...k(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
1
+ import{_ as e,i as t,m as n,p as r}from"./i18n-eDHeDY0n.js";import{n as i,r as a}from"./dist-ccBFUi-o.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-DJ2MUjBB.js";import{t as d}from"./plus-rYsv72JG.js";import{t as f}from"./save-3S6-H3Xw.js";import{t as p}from"./trash-2-G48scll7.js";import{G as m,J as h,K as g,N as _,Y as v,l as y,nt as b,q as x,tt as S}from"./index-CF9xve0E.js";import{n as C,t as w}from"./page-layout-vZnghcFy.js";import{t as T}from"./switch-BsLtHOH-.js";var E=e(n(),1),D=r(),O=[`env`,`file`,`exec`];function k(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function A(){return{path:``,source:`env`,provider:``,id:``}}function j(e,t){return t.source===`env`?{...k(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...k(e),source:`file`,path:t.path}:{...k(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
2
2
  `),cwd:t.cwd??``,timeoutMs:t.timeoutMs??5e3}}function M(e){return e.source===`env`?{source:`env`,...e.prefix.trim()?{prefix:e.prefix.trim()}:{}}:e.source===`file`?{source:`file`,path:e.path.trim(),format:`json`}:{source:`exec`,command:e.command.trim(),args:e.argsText.split(`
3
- `).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(e.timeoutMs||5e3))}}function N(){let{data:e,isLoading:n}=y(),r=_(),[N,P]=(0,E.useState)(!0),[F,I]=(0,E.useState)(``),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(``),[V,H]=(0,E.useState)([]),[U,W]=(0,E.useState)([]);(0,E.useEffect)(()=>{let t=e?.secrets;if(!t){P(!0),I(``),R(``),B(``),H([]),W([]);return}P(!!t.enabled),I(t.defaults.env??``),R(t.defaults.file??``),B(t.defaults.exec??``);let n=Object.entries(t.providers).map(([e,t])=>j(e,t)),r=Object.entries(t.refs).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}));H(n),W(r)},[e?.secrets]);let G=(0,E.useMemo)(()=>{let e=V.map(e=>e.alias.trim()).filter(Boolean);return Array.from(new Set(e))},[V]),K=(e,t)=>{H(n=>n.map((n,r)=>r===e?{...n,...t}:n))},q=(e,t)=>{W(n=>n.map((n,r)=>r===e?{...n,...t}:n))};return n?(0,D.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`loading`)}):(0,D.jsxs)(C,{className:`space-y-6`,children:[(0,D.jsx)(w,{title:t(`secretsPageTitle`),description:t(`secretsPageDescription`)}),(0,D.jsxs)(v,{children:[(0,D.jsxs)(x,{children:[(0,D.jsx)(h,{children:t(`secrets`)}),(0,D.jsx)(g,{children:t(`secretsEnabledHelp`)})]}),(0,D.jsxs)(m,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 p-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-gray-800`,children:t(`enabled`)}),(0,D.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`secretsEnabledHelp`)})]}),(0,D.jsx)(T,{checked:N,onCheckedChange:P})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(b,{children:t(`defaultEnvProvider`)}),(0,D.jsxs)(u,{value:F||`__none__`,onValueChange:e=>I(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(b,{children:t(`defaultFileProvider`)}),(0,D.jsxs)(u,{value:L||`__none__`,onValueChange:e=>R(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(b,{children:t(`defaultExecProvider`)}),(0,D.jsxs)(u,{value:z||`__none__`,onValueChange:e=>B(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]})]})]})]}),(0,D.jsxs)(v,{children:[(0,D.jsxs)(x,{children:[(0,D.jsx)(h,{children:t(`secretProvidersTitle`)}),(0,D.jsx)(g,{children:t(`secretProvidersDescription`)})]}),(0,D.jsxs)(m,{className:`space-y-3`,children:[V.map((e,n)=>(0,D.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsx)(S,{value:e.alias,onChange:e=>K(n,{alias:e.target.value}),placeholder:t(`providerAlias`)}),(0,D.jsxs)(u,{value:e.source,onValueChange:e=>K(n,{source:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{})}),(0,D.jsx)(c,{children:O.map(e=>(0,D.jsx)(l,{value:e,children:e},e))})]}),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>H(e=>e.filter((e,t)=>t!==n)),children:[(0,D.jsx)(p,{className:`h-4 w-4 mr-2`}),t(`removeProvider`)]})]}),e.source===`env`&&(0,D.jsx)(S,{value:e.prefix,onChange:e=>K(n,{prefix:e.target.value}),placeholder:t(`envPrefix`)}),e.source===`file`&&(0,D.jsx)(S,{value:e.path,onChange:e=>K(n,{path:e.target.value}),placeholder:t(`secretFilePath`)}),e.source===`exec`&&(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(S,{value:e.command,onChange:e=>K(n,{command:e.target.value}),placeholder:t(`secretExecCommand`)}),(0,D.jsx)(`textarea`,{className:`min-h-[84px] w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono`,value:e.argsText,onChange:e=>K(n,{argsText:e.target.value}),placeholder:t(`secretExecArgs`)}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,D.jsx)(S,{value:e.cwd,onChange:e=>K(n,{cwd:e.target.value}),placeholder:t(`secretExecCwd`)}),(0,D.jsx)(S,{type:`number`,min:1,value:e.timeoutMs,onChange:e=>K(n,{timeoutMs:Number.parseInt(e.target.value,10)||5e3}),placeholder:t(`secretExecTimeoutMs`)})]})]})]},`provider-${n}`)),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>H(e=>[...e,k()]),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addSecretProvider`)]})]})]}),(0,D.jsxs)(v,{children:[(0,D.jsxs)(x,{children:[(0,D.jsx)(h,{children:t(`secretRefsTitle`)}),(0,D.jsx)(g,{children:t(`secretRefsDescription`)})]}),(0,D.jsxs)(m,{className:`space-y-3`,children:[U.map((e,n)=>(0,D.jsx)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,D.jsx)(S,{value:e.path,onChange:e=>q(n,{path:e.target.value}),placeholder:t(`secretConfigPath`)}),(0,D.jsx)(S,{value:e.id,onChange:e=>q(n,{id:e.target.value}),placeholder:t(`secretId`)}),(0,D.jsxs)(u,{value:e.source,onValueChange:e=>q(n,{source:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{})}),(0,D.jsx)(c,{children:O.map(e=>(0,D.jsx)(l,{value:e,children:e},e))})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,D.jsxs)(u,{value:e.provider||`__none__`,onValueChange:e=>q(n,{provider:e===`__none__`?``:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`secretProviderAlias`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]}),(0,D.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>W(e=>e.filter((e,t)=>t!==n)),children:(0,D.jsx)(p,{className:`h-4 w-4`})})]})]})},`ref-${n}`)),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>W(e=>[...e,A()]),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addSecretRef`)]})]})]}),(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(a,{type:`button`,onClick:()=>{try{let e={};for(let[n,r]of V.entries()){let i=r.alias.trim();if(!i)throw Error(`${t(`providerAlias`)} #${n+1} ${t(`isRequired`)}`);if(e[i])throw Error(`${t(`providerAlias`)}: ${i} (${t(`duplicate`)})`);if(r.source===`file`&&!r.path.trim())throw Error(`${t(`secretFilePath`)} #${n+1} ${t(`isRequired`)}`);if(r.source===`exec`&&!r.command.trim())throw Error(`${t(`secretExecCommand`)} #${n+1} ${t(`isRequired`)}`);e[i]=M(r)}let n={};for(let[r,i]of U.entries()){let a=i.path.trim(),o=i.id.trim();if(!a)throw Error(`${t(`secretConfigPath`)} #${r+1} ${t(`isRequired`)}`);if(!o)throw Error(`${t(`secretId`)} #${r+1} ${t(`isRequired`)}`);let s=i.provider.trim();if(s&&!e[s])throw Error(`${t(`secretProviderAlias`)}: ${s} ${t(`notFound`)}`);n[a]={source:i.source,...s?{provider:s}:{},id:o}}r.mutate({data:{enabled:N,defaults:{env:F.trim()||null,file:L.trim()||null,exec:z.trim()||null},providers:e,refs:n}})}catch(e){let t=e instanceof Error?e.message:String(e);i.error(t)}},disabled:r.isPending,children:[(0,D.jsx)(f,{className:`h-4 w-4 mr-2`}),r.isPending?t(`saving`):t(`save`)]})})]})}export{N as SecretsConfig};
3
+ `).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(e.timeoutMs||5e3))}}function N(){let{data:e,isLoading:n}=y(),r=_(),[N,P]=(0,E.useState)(!0),[F,I]=(0,E.useState)(``),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(``),[V,H]=(0,E.useState)([]),[U,W]=(0,E.useState)([]);(0,E.useEffect)(()=>{let t=e?.secrets;if(!t){P(!0),I(``),R(``),B(``),H([]),W([]);return}P(!!t.enabled),I(t.defaults.env??``),R(t.defaults.file??``),B(t.defaults.exec??``);let n=Object.entries(t.providers).map(([e,t])=>j(e,t)),r=Object.entries(t.refs).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}));H(n),W(r)},[e?.secrets]);let G=(0,E.useMemo)(()=>{let e=V.map(e=>e.alias.trim()).filter(Boolean);return Array.from(new Set(e))},[V]),K=(e,t)=>{H(n=>n.map((n,r)=>r===e?{...n,...t}:n))},q=(e,t)=>{W(n=>n.map((n,r)=>r===e?{...n,...t}:n))};return n?(0,D.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`loading`)}):(0,D.jsxs)(C,{className:`space-y-6`,children:[(0,D.jsx)(w,{title:t(`secretsPageTitle`),description:t(`secretsPageDescription`)}),(0,D.jsxs)(m,{children:[(0,D.jsxs)(h,{children:[(0,D.jsx)(v,{children:t(`secrets`)}),(0,D.jsx)(x,{children:t(`secretsEnabledHelp`)})]}),(0,D.jsxs)(g,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 p-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-gray-800`,children:t(`enabled`)}),(0,D.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`secretsEnabledHelp`)})]}),(0,D.jsx)(T,{checked:N,onCheckedChange:P})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(S,{children:t(`defaultEnvProvider`)}),(0,D.jsxs)(u,{value:F||`__none__`,onValueChange:e=>I(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(S,{children:t(`defaultFileProvider`)}),(0,D.jsxs)(u,{value:L||`__none__`,onValueChange:e=>R(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(S,{children:t(`defaultExecProvider`)}),(0,D.jsxs)(u,{value:z||`__none__`,onValueChange:e=>B(e===`__none__`?``:e),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`noneOption`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]})]})]})]})]}),(0,D.jsxs)(m,{children:[(0,D.jsxs)(h,{children:[(0,D.jsx)(v,{children:t(`secretProvidersTitle`)}),(0,D.jsx)(x,{children:t(`secretProvidersDescription`)})]}),(0,D.jsxs)(g,{className:`space-y-3`,children:[V.map((e,n)=>(0,D.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,D.jsx)(b,{value:e.alias,onChange:e=>K(n,{alias:e.target.value}),placeholder:t(`providerAlias`)}),(0,D.jsxs)(u,{value:e.source,onValueChange:e=>K(n,{source:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{})}),(0,D.jsx)(c,{children:O.map(e=>(0,D.jsx)(l,{value:e,children:e},e))})]}),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>H(e=>e.filter((e,t)=>t!==n)),children:[(0,D.jsx)(p,{className:`h-4 w-4 mr-2`}),t(`removeProvider`)]})]}),e.source===`env`&&(0,D.jsx)(b,{value:e.prefix,onChange:e=>K(n,{prefix:e.target.value}),placeholder:t(`envPrefix`)}),e.source===`file`&&(0,D.jsx)(b,{value:e.path,onChange:e=>K(n,{path:e.target.value}),placeholder:t(`secretFilePath`)}),e.source===`exec`&&(0,D.jsxs)(`div`,{className:`space-y-2`,children:[(0,D.jsx)(b,{value:e.command,onChange:e=>K(n,{command:e.target.value}),placeholder:t(`secretExecCommand`)}),(0,D.jsx)(`textarea`,{className:`min-h-[84px] w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono`,value:e.argsText,onChange:e=>K(n,{argsText:e.target.value}),placeholder:t(`secretExecArgs`)}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,D.jsx)(b,{value:e.cwd,onChange:e=>K(n,{cwd:e.target.value}),placeholder:t(`secretExecCwd`)}),(0,D.jsx)(b,{type:`number`,min:1,value:e.timeoutMs,onChange:e=>K(n,{timeoutMs:Number.parseInt(e.target.value,10)||5e3}),placeholder:t(`secretExecTimeoutMs`)})]})]})]},`provider-${n}`)),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>H(e=>[...e,k()]),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addSecretProvider`)]})]})]}),(0,D.jsxs)(m,{children:[(0,D.jsxs)(h,{children:[(0,D.jsx)(v,{children:t(`secretRefsTitle`)}),(0,D.jsx)(x,{children:t(`secretRefsDescription`)})]}),(0,D.jsxs)(g,{className:`space-y-3`,children:[U.map((e,n)=>(0,D.jsx)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,D.jsx)(b,{value:e.path,onChange:e=>q(n,{path:e.target.value}),placeholder:t(`secretConfigPath`)}),(0,D.jsx)(b,{value:e.id,onChange:e=>q(n,{id:e.target.value}),placeholder:t(`secretId`)}),(0,D.jsxs)(u,{value:e.source,onValueChange:e=>q(n,{source:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{})}),(0,D.jsx)(c,{children:O.map(e=>(0,D.jsx)(l,{value:e,children:e},e))})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,D.jsxs)(u,{value:e.provider||`__none__`,onValueChange:e=>q(n,{provider:e===`__none__`?``:e}),children:[(0,D.jsx)(s,{children:(0,D.jsx)(o,{placeholder:t(`secretProviderAlias`)})}),(0,D.jsxs)(c,{children:[(0,D.jsx)(l,{value:`__none__`,children:t(`noneOption`)}),G.map(e=>(0,D.jsx)(l,{value:e,children:e},e))]})]}),(0,D.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>W(e=>e.filter((e,t)=>t!==n)),children:(0,D.jsx)(p,{className:`h-4 w-4`})})]})]})},`ref-${n}`)),(0,D.jsxs)(a,{type:`button`,variant:`outline`,onClick:()=>W(e=>[...e,A()]),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-2`}),t(`addSecretRef`)]})]})]}),(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(a,{type:`button`,onClick:()=>{try{let e={};for(let[n,r]of V.entries()){let i=r.alias.trim();if(!i)throw Error(`${t(`providerAlias`)} #${n+1} ${t(`isRequired`)}`);if(e[i])throw Error(`${t(`providerAlias`)}: ${i} (${t(`duplicate`)})`);if(r.source===`file`&&!r.path.trim())throw Error(`${t(`secretFilePath`)} #${n+1} ${t(`isRequired`)}`);if(r.source===`exec`&&!r.command.trim())throw Error(`${t(`secretExecCommand`)} #${n+1} ${t(`isRequired`)}`);e[i]=M(r)}let n={};for(let[r,i]of U.entries()){let a=i.path.trim(),o=i.id.trim();if(!a)throw Error(`${t(`secretConfigPath`)} #${r+1} ${t(`isRequired`)}`);if(!o)throw Error(`${t(`secretId`)} #${r+1} ${t(`isRequired`)}`);let s=i.provider.trim();if(s&&!e[s])throw Error(`${t(`secretProviderAlias`)}: ${s} ${t(`notFound`)}`);n[a]={source:i.source,...s?{provider:s}:{},id:o}}r.mutate({data:{enabled:N,defaults:{env:F.trim()||null,file:L.trim()||null,exec:z.trim()||null},providers:e,refs:n}})}catch(e){let t=e instanceof Error?e.message:String(e);i.error(t)}},disabled:r.isPending,children:[(0,D.jsx)(f,{className:`h-4 w-4 mr-2`}),r.isPending?t(`saving`):t(`save`)]})})]})}export{N as SecretsConfig};
@@ -1,2 +1,2 @@
1
- import{_ as e,i as t,m as n,n as r,p as i,t as a,u as o}from"./i18n-CwHZ-9vt.js";import{r as s}from"./dist-DmAlInRu.js";import{a as c,i as ee,n as l,r as u,t as d}from"./select-Caud8QvU.js";import{t as f}from"./createLucideIcon-DVv8taGY.js";import{t as p}from"./hash-DJtaCejM.js";import{t as m}from"./refresh-cw-DRcvRrnc.js";import{t as h}from"./search-MChQRYR1.js";import{i as g,l as _,n as v,t as y,u as b}from"./chat-session-display-CoN3Wmn-.js";import{O as x,b as S,dt as C,m as te,mt as w,tt as T,v as ne,yt as E}from"./index-DdksE6U3.js";import{n as D,t as O}from"./page-layout-Da3i3r6G.js";import{t as k}from"./useConfirmDialog-mMeWD_yo.js";var A=f(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),j=f(`Inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),M=e(n(),1),N=i(),P=`__unknown_channel__`;function F(e){return r(e)}function I(e){let t=e.indexOf(`:`);return t<=0?P:e.slice(0,t).trim()||P}function L(e){return e===P?t(`sessionsUnknownChannel`):e}function R(e){return e===`service`?`system`:e===`tool`?`tool`:e}function z(e){let t=[];for(let n of e.parts){if(n.type===`text`||n.type===`rich-text`||n.type===`reasoning`){t.push(n.text);continue}if(n.type===`tool-invocation`){let e=n.toolName?.trim()?`[${n.toolName.trim()}]`:`[tool]`;if(n.state===`result`&&typeof n.result==`string`&&n.result.trim()){t.push(`${e} ${n.result.trim()}`);continue}t.push(e)}}return t.join(`
2
- `).trim()}function B({session:e,summary:t,channel:n,isSelected:r,onSelect:i}){let s=L(n),c=y(e);return(0,N.jsxs)(`button`,{onClick:i,className:o(`w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group`,r?`bg-brand-50 border border-brand-100/50`:`bg-transparent border border-transparent hover:bg-gray-50/80`),children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between mb-1.5`,children:[(0,N.jsx)(`div`,{className:o(`font-semibold truncate pr-2 flex-1 text-sm`,r?`text-brand-800`:`text-gray-900`),children:c}),(0,N.jsx)(`div`,{className:o(`text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize`,r?`bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]`:`bg-gray-100 text-gray-500`),children:s})]}),(0,N.jsxs)(`div`,{className:o(`flex items-center text-xs justify-between mt-2 font-medium`,r?`text-brand-600/80`:`text-gray-400`),children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:t.status===`running`?(0,N.jsx)(_,{status:`running`}):null}),(0,N.jsx)(A,{className:`w-3.5 h-3.5 opacity-70`}),(0,N.jsx)(`span`,{className:`truncate max-w-[100px]`,children:a(t.updatedAt)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(w,{className:`w-3.5 h-3.5 opacity-70`}),(0,N.jsx)(`span`,{children:t.messageCount})]})]})]})}function V({message:e}){let t=R(e.role),n=t===`user`,r=z(e);return(0,N.jsx)(`div`,{className:o(`flex w-full mb-6`,n?`justify-end`:`justify-start`),children:(0,N.jsxs)(`div`,{className:o(`max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm`,n?`bg-primary text-white rounded-tr-sm`:`bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50`),children:[(0,N.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:n?(0,N.jsx)(b,{className:`w-4 h-4 text-primary-100`}):(0,N.jsx)(E,{className:`w-4 h-4 text-gray-400`})}),(0,N.jsxs)(`div`,{className:`flex-1 space-y-1 overflow-x-hidden`,children:[(0,N.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 mb-2`,children:[(0,N.jsx)(`span`,{className:o(`font-semibold text-xs capitalize`,n?`text-primary-50`:`text-gray-900`),children:t}),(0,N.jsx)(`span`,{className:o(`text-[10px]`,n?`text-primary-200`:`text-gray-400`),children:F(e.timestamp)})]}),(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-relaxed text-[15px]`,children:r||`-`})]})]})})}function H(){let[e,n]=(0,M.useState)(``),[r]=(0,M.useState)(100),[i,a]=(0,M.useState)(null),[f,b]=(0,M.useState)(`all`),[E,A]=(0,M.useState)(``),[F,R]=(0,M.useState)(``),[z,H]=(0,M.useState)(!1),U=S({limit:r}),W=ne(i,300),G=x(),K=te(),{confirm:q,ConfirmDialog:re}=k(),J=(0,M.useMemo)(()=>U.data?.sessions??[],[U.data?.sessions]),Y=(0,M.useMemo)(()=>g(J),[J]),X=(0,M.useMemo)(()=>new Map(J.map(e=>[e.sessionId,e])),[J]),Z=(0,M.useMemo)(()=>Y.filter(t=>f!==`all`&&I(t.key)!==f?!1:v(t,e)),[e,f,Y]),Q=(0,M.useMemo)(()=>Y.find(e=>e.key===i)??null,[i,Y]),$=(0,M.useMemo)(()=>i?X.get(i)??null:null,[i,X]),ie=(0,M.useMemo)(()=>{let e=new Set;for(let t of Y)e.add(I(t.key));return Array.from(e).sort((e,t)=>e===P?1:t===P?-1:e.localeCompare(t))},[Y]);return(0,M.useEffect)(()=>{i&&!X.has(i)&&a(null)},[i,X]),(0,M.useEffect)(()=>{Q?(A(Q.label||``),R(Q.preferredModel||``)):(A(``),R(``)),H(!1)},[Q]),(0,N.jsxs)(D,{fullHeight:!0,children:[(0,N.jsx)(O,{title:t(`sessionsPageTitle`),description:t(`sessionsPageDescription`)}),(0,N.jsxs)(`div`,{className:`flex-1 flex gap-6 min-h-0 relative`,children:[(0,N.jsxs)(`div`,{className:`w-[320px] flex flex-col shrink-0 bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-4 border-b border-gray-100 bg-white z-10 shrink-0 space-y-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`span`,{className:`text-[11px] font-semibold text-gray-400 uppercase tracking-wider`,children:[Y.length,` `,t(`sessionsListTitle`)]}),(0,N.jsx)(s,{variant:`ghost`,size:`icon`,className:`h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>U.refetch(),children:(0,N.jsx)(m,{className:o(`h-3.5 w-3.5`,U.isFetching&&`animate-spin`)})})]}),(0,N.jsxs)(d,{value:f,onValueChange:b,children:[(0,N.jsx)(ee,{className:`w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700`,children:(0,N.jsx)(c,{placeholder:t(`sessionsAllChannels`)})}),(0,N.jsxs)(l,{className:`rounded-xl shadow-lg border-gray-100 max-w-[280px]`,children:[(0,N.jsx)(u,{value:`all`,className:`rounded-lg text-xs`,children:t(`sessionsAllChannels`)}),ie.map(e=>(0,N.jsx)(u,{value:e,className:`rounded-lg text-xs truncate pr-6`,children:L(e)},e))]})]}),(0,N.jsxs)(`div`,{className:`relative w-full`,children:[(0,N.jsx)(h,{className:`h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400`}),(0,N.jsx)(T,{value:e,onChange:e=>n(e.target.value),placeholder:t(`sessionsSearchPlaceholder`),className:`pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs`})]})]}),(0,N.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3 space-y-1 pb-10 custom-scrollbar relative`,children:U.isLoading?(0,N.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:t(`sessionsLoading`)}):Z.length===0?(0,N.jsxs)(`div`,{className:`text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4`,children:[(0,N.jsx)(j,{className:`w-8 h-8 mx-auto mb-2 text-gray-300`}),t(`sessionsEmpty`)]}):Z.map(e=>{let t=X.get(e.key);return t?(0,N.jsx)(B,{session:e,summary:t,channel:I(e.key),isSelected:i===e.key,onSelect:()=>a(e.key)},e.key):null})})]}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col overflow-hidden relative bg-white rounded-2xl shadow-sm border border-gray-200`,children:[(G.isPending||K.isPending)&&(0,N.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20`,children:(0,N.jsx)(`div`,{className:`h-full bg-primary animate-pulse w-1/3 rounded-r-full`})}),i&&Q&&$?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,N.jsx)(`div`,{className:`h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0`,children:(0,N.jsx)(p,{className:`h-6 w-6`})}),(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2.5 mb-1.5`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 tracking-tight`,children:y(Q)}),(0,N.jsx)(`span`,{className:`text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest`,children:L(I(Q.key))}),$.status===`running`?(0,N.jsx)(_,{status:`running`,className:`h-4 w-4`}):null]}),(0,N.jsx)(`div`,{className:`text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70`,title:i,children:i})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,N.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>H(!z),className:o(`h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold`,z?`bg-gray-100 text-gray-900`:`hover:bg-gray-50 hover:text-gray-900`),children:[(0,N.jsx)(C,{className:`w-3.5 h-3.5 mr-1.5`}),t(`sessionsMetadata`)]}),(0,N.jsx)(s,{variant:`outline`,size:`sm`,onClick:async()=>{i&&await q({title:t(`sessionsDeleteConfirm`)+`?`,variant:`destructive`,confirmLabel:t(`sessionsDeleteConfirm`)})&&K.mutate({sessionId:i},{onSuccess:()=>a(null)})},className:`h-8.5 rounded-lg shadow-none hover:bg-red-50 hover:text-red-600 hover:border-red-200 border-gray-200 text-xs font-semibold text-red-500`,children:t(`delete`)})]})]}),z&&(0,N.jsxs)(`div`,{className:`flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in`,children:[(0,N.jsx)(T,{placeholder:t(`sessionsLabelPlaceholder`),value:E,onChange:e=>A(e.target.value),className:`h-8 text-sm bg-white`}),(0,N.jsx)(T,{placeholder:t(`sessionsModelPlaceholder`),value:F,onChange:e=>R(e.target.value),className:`h-8 text-sm bg-white`}),(0,N.jsx)(s,{size:`sm`,onClick:()=>{i&&(G.mutate({sessionId:i,data:{label:E.trim()||null,preferredModel:F.trim()||null}}),H(!1))},className:`h-8 px-4 shrink-0 shadow-none`,disabled:G.isPending,children:t(`sessionsSaveMeta`)})]})]}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 relative [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full`,children:[W.isLoading&&(0,N.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-3 animate-pulse`,children:[(0,N.jsx)(m,{className:`w-6 h-6 text-primary animate-spin`}),(0,N.jsx)(`span`,{className:`text-sm font-medium text-gray-500`,children:t(`sessionsHistoryLoading`)})]})}),W.error&&(0,N.jsx)(`div`,{className:`text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm`,children:W.error.message}),!W.isLoading&&W.data?.messages.length===0&&(0,N.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-gray-400`,children:[(0,N.jsx)(w,{className:`w-12 h-12 mb-3 text-gray-300`}),(0,N.jsx)(`p`,{className:`text-sm`,children:t(`sessionsEmpty`)})]}),(0,N.jsx)(`div`,{className:`max-w-3xl mx-auto`,children:(W.data?.messages??[]).map(e=>(0,N.jsx)(V,{message:e},e.id))})]})]}):(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white`,children:[(0,N.jsx)(`div`,{className:`w-20 h-20 bg-gray-50 rounded-3xl flex items-center justify-center mb-6 border border-gray-100 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.02)] rotate-3`,children:(0,N.jsx)(j,{className:`h-8 w-8 text-gray-300 -rotate-3`})}),(0,N.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 mb-2`,children:t(`sessionsNoSelectionTitle`)}),(0,N.jsx)(`p`,{className:`text-sm text-center max-w-sm leading-relaxed`,children:t(`sessionsNoSelectionDescription`)})]})]})]}),(0,N.jsx)(re,{})]})}export{H as SessionsConfig};
1
+ import{_ as e,i as t,m as n,n as r,p as i,t as a,u as o}from"./i18n-eDHeDY0n.js";import{r as s}from"./dist-ccBFUi-o.js";import{a as c,i as l,n as ee,r as u,t as d}from"./select-DJ2MUjBB.js";import{t as f}from"./createLucideIcon-BSeTgkZW.js";import{t as p}from"./hash-Bl7dr_UG.js";import{t as m}from"./refresh-cw-C47QSEwg.js";import{t as h}from"./search-3kFR_zh9.js";import{i as g,l as _,n as v,t as y,u as b}from"./chat-session-display-cw78aiI_.js";import{bt as x,ft as S,h as C,ht as w,k as te,nt as T,x as ne,y as E}from"./index-CF9xve0E.js";import{n as D,t as O}from"./page-layout-vZnghcFy.js";import{t as k}from"./useConfirmDialog-BkvTN-vd.js";var A=f(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),j=f(`Inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),M=e(n(),1),N=i(),P=`__unknown_channel__`;function F(e){return r(e)}function I(e){let t=e.indexOf(`:`);return t<=0?P:e.slice(0,t).trim()||P}function L(e){return e===P?t(`sessionsUnknownChannel`):e}function R(e){return e===`service`?`system`:e===`tool`?`tool`:e}function z(e){let t=[];for(let n of e.parts){if(n.type===`text`||n.type===`rich-text`||n.type===`reasoning`){t.push(n.text);continue}if(n.type===`tool-invocation`){let e=n.toolName?.trim()?`[${n.toolName.trim()}]`:`[tool]`;if(n.state===`result`&&typeof n.result==`string`&&n.result.trim()){t.push(`${e} ${n.result.trim()}`);continue}t.push(e)}}return t.join(`
2
+ `).trim()}function B({session:e,summary:t,channel:n,isSelected:r,onSelect:i}){let s=L(n),c=y(e);return(0,N.jsxs)(`button`,{onClick:i,className:o(`w-full text-left p-3.5 rounded-xl transition-all duration-200 outline-none focus:outline-none focus:ring-0 group`,r?`bg-brand-50 border border-brand-100/50`:`bg-transparent border border-transparent hover:bg-gray-50/80`),children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between mb-1.5`,children:[(0,N.jsx)(`div`,{className:o(`font-semibold truncate pr-2 flex-1 text-sm`,r?`text-brand-800`:`text-gray-900`),children:c}),(0,N.jsx)(`div`,{className:o(`text-[10px] font-bold px-2 py-0.5 rounded-full shrink-0 capitalize`,r?`bg-white text-brand-600 shadow-[0_1px_2px_rgba(0,0,0,0.02)]`:`bg-gray-100 text-gray-500`),children:s})]}),(0,N.jsxs)(`div`,{className:o(`flex items-center text-xs justify-between mt-2 font-medium`,r?`text-brand-600/80`:`text-gray-400`),children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,children:t.status===`running`?(0,N.jsx)(_,{status:`running`}):null}),(0,N.jsx)(A,{className:`w-3.5 h-3.5 opacity-70`}),(0,N.jsx)(`span`,{className:`truncate max-w-[100px]`,children:a(t.updatedAt)})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(w,{className:`w-3.5 h-3.5 opacity-70`}),(0,N.jsx)(`span`,{children:t.messageCount})]})]})]})}function V({message:e}){let t=R(e.role),n=t===`user`,r=z(e);return(0,N.jsx)(`div`,{className:o(`flex w-full mb-6`,n?`justify-end`:`justify-start`),children:(0,N.jsxs)(`div`,{className:o(`max-w-[85%] rounded-[1.25rem] p-5 flex gap-3 text-sm`,n?`bg-primary text-white rounded-tr-sm`:`bg-gray-50 text-gray-800 rounded-tl-sm border border-gray-100/50`),children:[(0,N.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:n?(0,N.jsx)(b,{className:`w-4 h-4 text-primary-100`}):(0,N.jsx)(x,{className:`w-4 h-4 text-gray-400`})}),(0,N.jsxs)(`div`,{className:`flex-1 space-y-1 overflow-x-hidden`,children:[(0,N.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 mb-2`,children:[(0,N.jsx)(`span`,{className:o(`font-semibold text-xs capitalize`,n?`text-primary-50`:`text-gray-900`),children:t}),(0,N.jsx)(`span`,{className:o(`text-[10px]`,n?`text-primary-200`:`text-gray-400`),children:F(e.timestamp)})]}),(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words leading-relaxed text-[15px]`,children:r||`-`})]})]})})}function H(){let[e,n]=(0,M.useState)(``),[r]=(0,M.useState)(100),[i,a]=(0,M.useState)(null),[f,b]=(0,M.useState)(`all`),[x,A]=(0,M.useState)(``),[F,R]=(0,M.useState)(``),[z,H]=(0,M.useState)(!1),U=ne({limit:r}),W=E(i,300),G=te(),K=C(),{confirm:q,ConfirmDialog:re}=k(),J=(0,M.useMemo)(()=>U.data?.sessions??[],[U.data?.sessions]),Y=(0,M.useMemo)(()=>g(J),[J]),X=(0,M.useMemo)(()=>new Map(J.map(e=>[e.sessionId,e])),[J]),Z=(0,M.useMemo)(()=>Y.filter(t=>f!==`all`&&I(t.key)!==f?!1:v(t,e)),[e,f,Y]),Q=(0,M.useMemo)(()=>Y.find(e=>e.key===i)??null,[i,Y]),$=(0,M.useMemo)(()=>i?X.get(i)??null:null,[i,X]),ie=(0,M.useMemo)(()=>{let e=new Set;for(let t of Y)e.add(I(t.key));return Array.from(e).sort((e,t)=>e===P?1:t===P?-1:e.localeCompare(t))},[Y]);return(0,M.useEffect)(()=>{i&&!X.has(i)&&a(null)},[i,X]),(0,M.useEffect)(()=>{Q?(A(Q.label||``),R(Q.preferredModel||``)):(A(``),R(``)),H(!1)},[Q]),(0,N.jsxs)(D,{fullHeight:!0,children:[(0,N.jsx)(O,{title:t(`sessionsPageTitle`),description:t(`sessionsPageDescription`)}),(0,N.jsxs)(`div`,{className:`flex-1 flex gap-6 min-h-0 relative`,children:[(0,N.jsxs)(`div`,{className:`w-[320px] flex flex-col shrink-0 bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden`,children:[(0,N.jsxs)(`div`,{className:`px-4 py-4 border-b border-gray-100 bg-white z-10 shrink-0 space-y-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`span`,{className:`text-[11px] font-semibold text-gray-400 uppercase tracking-wider`,children:[Y.length,` `,t(`sessionsListTitle`)]}),(0,N.jsx)(s,{variant:`ghost`,size:`icon`,className:`h-7 w-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>U.refetch(),children:(0,N.jsx)(m,{className:o(`h-3.5 w-3.5`,U.isFetching&&`animate-spin`)})})]}),(0,N.jsxs)(d,{value:f,onValueChange:b,children:[(0,N.jsx)(l,{className:`w-full h-8.5 rounded-lg bg-gray-50/50 hover:bg-gray-100 border-gray-200 focus:ring-0 shadow-none text-xs font-medium text-gray-700`,children:(0,N.jsx)(c,{placeholder:t(`sessionsAllChannels`)})}),(0,N.jsxs)(ee,{className:`rounded-xl shadow-lg border-gray-100 max-w-[280px]`,children:[(0,N.jsx)(u,{value:`all`,className:`rounded-lg text-xs`,children:t(`sessionsAllChannels`)}),ie.map(e=>(0,N.jsx)(u,{value:e,className:`rounded-lg text-xs truncate pr-6`,children:L(e)},e))]})]}),(0,N.jsxs)(`div`,{className:`relative w-full`,children:[(0,N.jsx)(h,{className:`h-3.5 w-3.5 absolute left-3 top-2.5 text-gray-400`}),(0,N.jsx)(T,{value:e,onChange:e=>n(e.target.value),placeholder:t(`sessionsSearchPlaceholder`),className:`pl-8 h-8.5 rounded-lg bg-gray-50/50 border-gray-200 focus-visible:bg-white text-xs`})]})]}),(0,N.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3 space-y-1 pb-10 custom-scrollbar relative`,children:U.isLoading?(0,N.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:t(`sessionsLoading`)}):Z.length===0?(0,N.jsxs)(`div`,{className:`text-sm text-gray-400 p-4 text-center border-2 border-dashed border-gray-100 rounded-xl mt-4`,children:[(0,N.jsx)(j,{className:`w-8 h-8 mx-auto mb-2 text-gray-300`}),t(`sessionsEmpty`)]}):Z.map(e=>{let t=X.get(e.key);return t?(0,N.jsx)(B,{session:e,summary:t,channel:I(e.key),isSelected:i===e.key,onSelect:()=>a(e.key)},e.key):null})})]}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col overflow-hidden relative bg-white rounded-2xl shadow-sm border border-gray-200`,children:[(G.isPending||K.isPending)&&(0,N.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-primary/20 overflow-hidden z-20`,children:(0,N.jsx)(`div`,{className:`h-full bg-primary animate-pulse w-1/3 rounded-r-full`})}),i&&Q&&$?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`shrink-0 border-b border-gray-100 bg-white px-8 py-5 z-10 space-y-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,N.jsx)(`div`,{className:`h-12 w-12 rounded-[14px] bg-gray-50 border border-gray-100 flex items-center justify-center text-gray-400 shrink-0`,children:(0,N.jsx)(p,{className:`h-6 w-6`})}),(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2.5 mb-1.5`,children:[(0,N.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 tracking-tight`,children:y(Q)}),(0,N.jsx)(`span`,{className:`text-[10px] font-bold px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 uppercase tracking-widest`,children:L(I(Q.key))}),$.status===`running`?(0,N.jsx)(_,{status:`running`,className:`h-4 w-4`}):null]}),(0,N.jsx)(`div`,{className:`text-xs text-gray-500 font-mono break-all line-clamp-1 opacity-70`,title:i,children:i})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,N.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>H(!z),className:o(`h-8.5 rounded-lg shadow-none border-gray-200 transition-all text-xs font-semibold`,z?`bg-gray-100 text-gray-900`:`hover:bg-gray-50 hover:text-gray-900`),children:[(0,N.jsx)(S,{className:`w-3.5 h-3.5 mr-1.5`}),t(`sessionsMetadata`)]}),(0,N.jsx)(s,{variant:`outline`,size:`sm`,onClick:async()=>{i&&await q({title:t(`sessionsDeleteConfirm`)+`?`,variant:`destructive`,confirmLabel:t(`sessionsDeleteConfirm`)})&&K.mutate({sessionId:i},{onSuccess:()=>a(null)})},className:`h-8.5 rounded-lg shadow-none hover:bg-red-50 hover:text-red-600 hover:border-red-200 border-gray-200 text-xs font-semibold text-red-500`,children:t(`delete`)})]})]}),z&&(0,N.jsxs)(`div`,{className:`flex items-center gap-3 bg-gray-50/50 p-3 rounded-lg border border-gray-100 animate-slide-in`,children:[(0,N.jsx)(T,{placeholder:t(`sessionsLabelPlaceholder`),value:x,onChange:e=>A(e.target.value),className:`h-8 text-sm bg-white`}),(0,N.jsx)(T,{placeholder:t(`sessionsModelPlaceholder`),value:F,onChange:e=>R(e.target.value),className:`h-8 text-sm bg-white`}),(0,N.jsx)(s,{size:`sm`,onClick:()=>{i&&(G.mutate({sessionId:i,data:{label:x.trim()||null,preferredModel:F.trim()||null}}),H(!1))},className:`h-8 px-4 shrink-0 shadow-none`,disabled:G.isPending,children:t(`sessionsSaveMeta`)})]})]}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 relative [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-gray-300/80 [&::-webkit-scrollbar-thumb]:rounded-full`,children:[W.isLoading&&(0,N.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-gray-50/50 backdrop-blur-sm z-10`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-3 animate-pulse`,children:[(0,N.jsx)(m,{className:`w-6 h-6 text-primary animate-spin`}),(0,N.jsx)(`span`,{className:`text-sm font-medium text-gray-500`,children:t(`sessionsHistoryLoading`)})]})}),W.error&&(0,N.jsx)(`div`,{className:`text-center p-6 bg-red-50 rounded-xl text-red-600 border border-red-100 text-sm`,children:W.error.message}),!W.isLoading&&W.data?.messages.length===0&&(0,N.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-gray-400`,children:[(0,N.jsx)(w,{className:`w-12 h-12 mb-3 text-gray-300`}),(0,N.jsx)(`p`,{className:`text-sm`,children:t(`sessionsEmpty`)})]}),(0,N.jsx)(`div`,{className:`max-w-3xl mx-auto`,children:(W.data?.messages??[]).map(e=>(0,N.jsx)(V,{message:e},e.id))})]})]}):(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-gray-400 p-8 h-full bg-white`,children:[(0,N.jsx)(`div`,{className:`w-20 h-20 bg-gray-50 rounded-3xl flex items-center justify-center mb-6 border border-gray-100 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.02)] rotate-3`,children:(0,N.jsx)(j,{className:`h-8 w-8 text-gray-300 -rotate-3`})}),(0,N.jsx)(`h3`,{className:`text-lg font-bold text-gray-900 mb-2`,children:t(`sessionsNoSelectionTitle`)}),(0,N.jsx)(`p`,{className:`text-sm text-center max-w-sm leading-relaxed`,children:t(`sessionsNoSelectionDescription`)})]})]})]}),(0,N.jsx)(re,{})]})}export{H as SessionsConfig};
@@ -1 +1 @@
1
- import{A as e,C as t,E as n,S as r,T as i,b as a,c as o,d as s,f as c,k as l,m as u,p as d,w as f,x as p,y as m}from"./client-CVqPF5ie.js";import{r as h}from"./infiniteQueryBehavior-DHSEQ3OH.js";var g=class extends e{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new o({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=_(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=_(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=_(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=_(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){d.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>r(t,e))}findAll(e={}){return this.getAll().filter(t=>r(e,t))}notify(e){d.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return d.batch(()=>Promise.all(e.map(e=>e.continue().catch(f))))}};function _(e){return e.options.scope?.id}var v=class extends e{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??p(r,t),a=this.get(i);return a||(a=new s({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){d.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let n={exact:!0,...e};return this.getAll().find(e=>t(n,e))}findAll(e={}){let n=this.getAll();return Object.keys(e).length>0?n.filter(n=>t(e,n)):n}notify(e){d.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){d.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){d.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},y=new class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new v,this.#t=e.mutationCache||new g,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=u.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=c.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),i=r.state.data;return i===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(n(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(i))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=m(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return d.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;d.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return d.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=d.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(f).catch(f)}invalidateQueries(e,t={}){return d.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=d.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(f)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(f)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(n(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(f).catch(f)}fetchInfiniteQuery(e){return e.behavior=h(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(f).catch(f)}ensureInfiniteQueryData(e){return e.behavior=h(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return c.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(a(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{i(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(a(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{i(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=p(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===l&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}}({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!0}}});export{y as t};
1
+ import{A as e,C as t,E as n,S as r,T as i,b as a,c as o,d as s,f as c,k as l,m as u,p as d,w as f,x as p,y as m}from"./client-_i4MU2bB.js";import{r as h}from"./infiniteQueryBehavior-ZDS92Qpp.js";var g=class extends e{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new o({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=_(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=_(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=_(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=_(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){d.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>r(t,e))}findAll(e={}){return this.getAll().filter(t=>r(e,t))}notify(e){d.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return d.batch(()=>Promise.all(e.map(e=>e.continue().catch(f))))}};function _(e){return e.options.scope?.id}var v=class extends e{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??p(r,t),a=this.get(i);return a||(a=new s({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){d.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let n={exact:!0,...e};return this.getAll().find(e=>t(n,e))}findAll(e={}){let n=this.getAll();return Object.keys(e).length>0?n.filter(n=>t(e,n)):n}notify(e){d.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){d.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){d.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},y=new class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new v,this.#t=e.mutationCache||new g,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=u.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=c.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#e.build(this,t),i=r.state.data;return i===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(n(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(i))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=m(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return d.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;d.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return d.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=d.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(f).catch(f)}invalidateQueries(e,t={}){return d.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=d.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(f)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(f)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let r=this.#e.build(this,t);return r.isStaleByTime(n(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(f).catch(f)}fetchInfiniteQuery(e){return e.behavior=h(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(f).catch(f)}ensureInfiniteQueryData(e){return e.behavior=h(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return c.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(a(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{i(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(a(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{i(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=p(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===l&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}}({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!0}}});export{y as t};
@@ -1 +1 @@
1
- import{t as e}from"./createLucideIcon-DVv8taGY.js";var t=e(`BookOpen`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]);export{t};
1
+ import{t as e}from"./createLucideIcon-BSeTgkZW.js";var t=e(`BookOpen`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]);export{t};