@nextclaw/ui 0.27.1 → 0.27.3

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 (95) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/.vite/manifest.json +419 -419
  3. package/dist/assets/{account-panel-BVNV8XqM.js → account-panel-DiKpSvqS.js} +1 -1
  4. package/dist/assets/{agents-CfpN8PQc.js → agents-lT-bDFex.js} +1 -1
  5. package/dist/assets/agents-nyTxTl89.js +1 -0
  6. package/dist/assets/{api-CI6_8Qt1.js → api-BaML_txv.js} +1 -1
  7. package/dist/assets/{app-presenter-provider-2DwHRRle.js → app-presenter-provider-DSlY9Lz6.js} +6 -6
  8. package/dist/assets/{appearance-settings-page-Cn9w3F-K.js → appearance-settings-page-BNIxFwEY.js} +1 -1
  9. package/dist/assets/apps-D7Se5AXs.js +1 -0
  10. package/dist/assets/{book-open-i_BjUBqL.js → book-open-oG0GrLyy.js} +1 -1
  11. package/dist/assets/{card-DokH7OBp.js → card-DxCOCY_7.js} +1 -1
  12. package/dist/assets/{channels-list-page-B7G9lHUm.js → channels-list-page-UQ1xjKw9.js} +1 -1
  13. package/dist/assets/{circle-dashed-Cx8CIEbg.js → circle-dashed-pgOOTUik.js} +1 -1
  14. package/dist/assets/{client-CUJUci3r.js → client-C1Z8ITVa.js} +1 -1
  15. package/dist/assets/{config-split-page-hY1xug28.js → config-split-page-Cfozkh5B.js} +1 -1
  16. package/dist/assets/{confirm-dialog-B-ejV666.js → confirm-dialog-BdEQiFoD.js} +1 -1
  17. package/dist/assets/{context-menu-dGVv8klA.js → context-menu-DVgLoPqH.js} +1 -1
  18. package/dist/assets/{createLucideIcon-reFMl-W-.js → createLucideIcon-D-7Sxfw7.js} +1 -1
  19. package/dist/assets/cron-wSJKKm6g.js +1 -0
  20. package/dist/assets/{desktop-capabilities-page-CYJTQ3nC.js → desktop-capabilities-page-gakZ5UKX.js} +1 -1
  21. package/dist/assets/{desktop-update-config-guKAozXO.js → desktop-update-config-CVUwJyV-.js} +1 -1
  22. package/dist/assets/{dialog-DLOwdjT1.js → dialog-InO6RVpm.js} +1 -1
  23. package/dist/assets/{dist-ZaFFmAGl.js → dist-BxOjfeaD.js} +1 -1
  24. package/dist/assets/doc-browser-Cuedjp9j.js +1 -0
  25. package/dist/assets/{doc-browser-context-CTmOmuqa.js → doc-browser-context-Bs122rxO.js} +1 -1
  26. package/dist/assets/{download-DovI3Yvf.js → download-BN4aCzSx.js} +1 -1
  27. package/dist/assets/{extensions-BZ3qrM8M.js → extensions-hxS830nS.js} +1 -1
  28. package/dist/assets/{external-link-DUD3AbsF.js → external-link-NwtWKzE2.js} +1 -1
  29. package/dist/assets/{form-actions-B8VniHts.js → form-actions-XP38NiPw.js} +1 -1
  30. package/dist/assets/{i18n-IGQbjBqS.js → i18n-Bzo4IocH.js} +2 -2
  31. package/dist/assets/inbox-CnpKPeFb.js +1 -0
  32. package/dist/assets/{inbox-ClAG7SI_.js → inbox-DofXi7Xv.js} +1 -1
  33. package/dist/assets/{keyboard-shortcuts-settings-page-BqfbbKir.js → keyboard-shortcuts-settings-page-Cn3zyBq_.js} +1 -1
  34. package/dist/assets/login-page-3Yv6FU7k.js +1 -0
  35. package/dist/assets/{login-page-DYaozpzz.js → login-page-CkfjjXD2.js} +1 -1
  36. package/dist/assets/{main-CWYF9QU_.js → main-BI7BtvLx.js} +2 -2
  37. package/dist/assets/main-i18n-catalog.config-ykBbOfNP.js +1 -0
  38. package/dist/assets/marketplace-BkdTZexc.js +1 -0
  39. package/dist/assets/mcp-marketplace-page-BqFum360.js +1 -0
  40. package/dist/assets/{model-config-page-Cduyz2Hy.js → model-config-page-BCGCP2Wc.js} +1 -1
  41. package/dist/assets/{navigation-link-D-JSWFxj.js → navigation-link-tawg3qi2.js} +1 -1
  42. package/dist/assets/panel-app-i18n-catalog.config-DEFg3R5S.js +1 -0
  43. package/dist/assets/panel-apps-CRjFqZZD.js +1 -0
  44. package/dist/assets/{panelStandalone-oHxbXvYt.js → panelStandalone-smtUeY2k.js} +2 -2
  45. package/dist/assets/plus-v29lPO18.js +1 -0
  46. package/dist/assets/{privacy-settings-page-DG9E8N-F.js → privacy-settings-page-D4TI_vdw.js} +1 -1
  47. package/dist/assets/{projects-CzBaTOTL.js → projects-Rm2oKUPt.js} +1 -1
  48. package/dist/assets/{provider-models-COzjYl29.js → provider-models-CWtoV3BJ.js} +1 -1
  49. package/dist/assets/{provider-scoped-model-input-Cvy74uj8.js → provider-scoped-model-input-DJzdGBE8.js} +1 -1
  50. package/dist/assets/{providers-config-page-7rCwVnhh.js → providers-config-page-gzLkTzMP.js} +1 -1
  51. package/dist/assets/{puzzle-C5Wfpjk_.js → puzzle-CXL_z0vz.js} +1 -1
  52. package/dist/assets/{pwa-CAg_9zFs.js → pwa-Blsqtn1m.js} +1 -1
  53. package/dist/assets/{refresh-cw-OhwaPDn1.js → refresh-cw-CqsHJPqR.js} +1 -1
  54. package/dist/assets/remote-DTe4pS7P.js +1 -0
  55. package/dist/assets/{rotate-cw-aBponvp7.js → rotate-cw-DS-Gca0a.js} +1 -1
  56. package/dist/assets/{runtime-config-page-BF1wxvzR.js → runtime-config-page-B5CCnrei.js} +1 -1
  57. package/dist/assets/{save-394QCMXn.js → save-CwxRo7hc.js} +1 -1
  58. package/dist/assets/{search-BG2qAlNZ.js → search-Drx-sMCE.js} +1 -1
  59. package/dist/assets/{search-config-page-D4LeiB9y.js → search-config-page-BjVONAIH.js} +1 -1
  60. package/dist/assets/{secrets-config-page-BzGcr5Vw.js → secrets-config-page-BB32noHT.js} +1 -1
  61. package/dist/assets/security-config--ilpaAEr.js +1 -0
  62. package/dist/assets/{select-xUXYV0Gr.js → select-DHYR109w.js} +1 -1
  63. package/dist/assets/{service-apps-panel-D3wwPRzV.js → service-apps-panel-DOKGtwsR.js} +1 -1
  64. package/dist/assets/{settings-2-CWOGRRaA.js → settings-2-DAPjKYtK.js} +1 -1
  65. package/dist/assets/{status-dot-CYifnSnt.js → status-dot-xxVxbdQr.js} +1 -1
  66. package/dist/assets/{tag-chip-CjM6lyeh.js → tag-chip-0lQj9HFa.js} +1 -1
  67. package/dist/assets/{theme-provider-BToFZGZG.js → theme-provider-DDJOlUxn.js} +1 -1
  68. package/dist/assets/{trash-2-DvJ6duOW.js → trash-2-B8mbrtCx.js} +1 -1
  69. package/dist/assets/{use-config-COusaY5p.js → use-config-BpKXDcM_.js} +1 -1
  70. package/dist/assets/{use-desktop-capabilities-B-u6ojjW.js → use-desktop-capabilities-C1bXk7fx.js} +1 -1
  71. package/dist/assets/{use-viewport-layout-IKKGpjzF.js → use-viewport-layout-D6seoW0Z.js} +1 -1
  72. package/dist/assets/{x-E9VB4HQx.js → x-DLvS4xvV.js} +1 -1
  73. package/dist/index.html +36 -36
  74. package/dist/panel-standalone.html +14 -14
  75. package/package.json +2 -2
  76. package/src/features/chat/features/conversation/components/__tests__/session-conversation-input-top-slot.test.tsx +71 -0
  77. package/src/features/chat/features/conversation/components/session-conversation-input-top-slot.tsx +6 -7
  78. package/src/features/chat/features/conversation/hooks/__tests__/use-session-conversation-controller.test.tsx +41 -0
  79. package/src/features/chat/features/conversation/hooks/use-session-conversation-controller.ts +4 -1
  80. package/src/shared/lib/i18n/locales/en-US/chat.json +0 -1
  81. package/src/shared/lib/i18n/locales/zh-CN/chat.json +0 -1
  82. package/dist/assets/agents-E4nu-17c.js +0 -1
  83. package/dist/assets/apps-YFlJirpx.js +0 -1
  84. package/dist/assets/cron-CH5c55CR.js +0 -1
  85. package/dist/assets/doc-browser-ClDUWo9V.js +0 -1
  86. package/dist/assets/inbox-BjBZIbgx.js +0 -1
  87. package/dist/assets/login-page-BxSMwUsc.js +0 -1
  88. package/dist/assets/main-i18n-catalog.config-itg3Gvzp.js +0 -1
  89. package/dist/assets/marketplace-CnQ5USfr.js +0 -1
  90. package/dist/assets/mcp-marketplace-page-Dor6H9IC.js +0 -1
  91. package/dist/assets/panel-app-i18n-catalog.config-BfLHr1tc.js +0 -1
  92. package/dist/assets/panel-apps-C-izvtu9.js +0 -1
  93. package/dist/assets/plus-DUdl68Eo.js +0 -1
  94. package/dist/assets/remote-DvCdHjzA.js +0 -1
  95. package/dist/assets/security-config-vD_V0BQF.js +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./chunk-DF37yw5_.js";import{Gt as t,Ut as n,Wt as r,Xn as i,Yt as a,Zt as o,_n as s,hn as c,lr as l,ur as u,xr as d}from"./api-CI6_8Qt1.js";import{t as f}from"./createLucideIcon-reFMl-W-.js";import{g as p,h as m,lt as h,mt as g,pt as _,q as v}from"./context-menu-dGVv8klA.js";import{t as y}from"./search-BG2qAlNZ.js";import{z as b}from"./dist-ZaFFmAGl.js";import{n as x}from"./inbox-ClAG7SI_.js";import{i as S,t as C}from"./x-E9VB4HQx.js";import{i as w,t as T}from"./use-viewport-layout-IKKGpjzF.js";import{t as E}from"./plus-DUdl68Eo.js";import{t as D}from"./refresh-cw-OhwaPDn1.js";import{t as O}from"./settings-2-CWOGRRaA.js";import{t as k}from"./trash-2-DvJ6duOW.js";import{l as A,s as j}from"./i18n-IGQbjBqS.js";import{a as M,c as N,g as P,h as F,l as I,o as L,p as R,t as z}from"./provider-models-COzjYl29.js";import{n as B,t as V}from"./status-dot-CYifnSnt.js";import{t as H}from"./confirm-dialog-B-ejV666.js";import{t as ee}from"./host-capabilities-B107nwS3.js";import{a as U,i as W,n as G,r as K,t as q}from"./select-xUXYV0Gr.js";import{a as J,c as te,d as ne,f as re,h as ie,i as ae,l as oe,m as se,o as ce,p as le,r as ue,y as de}from"./use-config-COusaY5p.js";import{t as fe}from"./form-actions-B8VniHts.js";import{t as pe}from"./config-hints-CaB3I7KP.js";import{a as me,c as he,i as ge,l as _e,n as ve,o as ye,r as be,s as xe}from"./config-split-page-hY1xug28.js";var Se=f(`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`}]]),Ce=f(`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`}]]),Y=e(d(),1),we={providerId:``,providerType:null,isBuiltInType:!1,isCustom:!0,enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelConfig:{}};function X(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 Te(e,t){let n=X(e),r=X(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 Z(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 Ee(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 Q(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=Ee(n,t))}return n.trim()}function De(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Oe(e,t){return Z(t)}function ke(e,t){return Z(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Ae(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={},a=N(i.thinking?.supported);if(a.length>0){let t=I(i.thinking?.default);e.thinking=t&&a.includes(t)?{supported:a,default:t}:{supported:a}}i.vision===!0&&(e.vision=!0),(e.thinking||e.vision===!0)&&(r[t]=e)}return r}function je(e,t,n){return{...L(e,n),...L(t,n)}}function Me(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||!De([...o.thinking?.supported??[]].sort(),[...s.thinking?.supported??[]].sort())||(o.thinking?.default??null)!==(s.thinking?.default??null)||(o.vision??!1)!==(s.vision??!1))return!1}return!0}function Ne(e){return e.providerName?e.apiKey.trim().length>0||e.apiBase.trim()!==e.currentApiBase.trim()||!Te(e.extraHeaders,e.currentHeaders)||e.supportsWireApi&&e.wireApi!==e.currentWireApi||!De(e.models,e.currentEditableModels)||!Me(e.modelConfig,e.currentModelConfig)||e.providerDisplayName.trim()!==e.effectiveDisplayName:!1}function Pe(e){let t={},n=e.apiKey.trim(),r=e.apiBase.trim(),i=X(e.extraHeaders),a=e.providerDisplayName.trim();return a!==e.effectiveDisplayName&&(t.displayName=a.length>0?a:null),n.length>0&&(t.apiKey=n),r!==e.currentApiBase.trim()&&(t.apiBase=r.length>0&&r!==e.defaultApiBase?r:null),Te(i,e.currentHeaders)||(t.extraHeaders=i),e.supportsWireApi&&e.wireApi!==e.currentWireApi&&(t.wireApi=e.wireApi),De(e.models,e.currentEditableModels)||(t.models=ke(e.models,e.providerName??``)),Me(e.modelConfig,e.currentModelConfig)||(t.modelConfig=Ae(e.modelConfig,e.models)),t}function Fe(e){let t=Q(e.models.find(e=>e.trim().length>0)??``,e.providerModelAliases),n={...Ie(e),model:t||null};return e.supportsWireApi&&(n.wireApi=e.wireApi),n}function Ie(e){let t={apiBase:e.apiBase.trim(),extraHeaders:X(e.extraHeaders)};return e.apiKey.trim().length>0&&(t.apiKey=e.apiKey.trim()),t}function Le(e){return j(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Re(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 ze(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Be(e,t,n){let r=Q(t,n);return r?e.includes(r)?{models:e,draft:``}:{models:[...e,r],draft:``}:{models:e,draft:t}}function Ve(e,t,n){let r=[...e],i=new Set(e);for(let e of t){let t=Q(e,n);t&&!i.has(t)&&(i.add(t),r.push(t))}return{models:r,addedCount:r.length-e.length}}function He(e,t,n){return Ve(e,t,n).models.slice(e.length)}function Ue(e,t,n){let r={...t};return delete r[n],{models:e.filter(e=>e!==n),modelConfig:r}}function We(e,t,n){let r=e[t],i=r?.thinking?.supported??[],a=i.includes(n)?i.filter(e=>e!==n):z.filter(e=>e===n||i.includes(e)),o=r?.thinking?.default&&a.includes(r.thinking.default)?r.thinking.default:void 0,s={...r,thinking:a.length>0?o?{supported:a,default:o}:{supported:a}:void 0},c={...e};return s.thinking||s.vision===!0?c[t]=s:delete c[t],c}function Ge(e,t,n){let r=e[t],i=r?.thinking;return!i||i.supported.length===0||n&&!i.supported.includes(n)?e:{...e,[t]:{...r,thinking:n?{supported:i.supported,default:n}:{supported:i.supported}}}}function Ke(e,t,n){let r={...e[t],vision:n?!0:void 0},i={...e};return r.thinking||r.vision===!0?i[t]=r:delete i[t],i}function qe(e){let{providerName:t,providerSpec:n,language:r}=e,i=n?.auth,a=i?.methods??[];return{providerAuth:i,providerAuthMethodOptions:a.map(e=>({value:e.id,label:e.label?.[r]||e.label?.en||e.id})),providerAuthMethods:a,preferredAuthMethodId:Re({providerName:n?.providerType??t,methods:a,defaultMethodId:i?.defaultMethodId,language:r}),shouldUseAuthMethodPills:ze({required:i?.kind===`device_code`,hasDefault:!!i?.defaultMethodId?.trim(),optionCount:a.length})}}function Je(e,t){let n=!!e?.supportsWireApi||t,r=(e?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:j(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)}));return{shouldUseWireApiPills:ze({required:n,hasDefault:typeof e?.defaultWireApi==`string`&&e.defaultWireApi.length>0,optionCount:r.length}),supportsWireApi:n,wireApiSelectOptions:r}}function Ye(e){let{providerName:t,providersView:n,templatesView:r,schema:i,language:a}=e,o=t?n?.providers[t]:null,s=r?.providerTemplates.find(e=>e.providerType===o?.providerType),c=o??we,l=i?.uiHints,u=!!o?.isCustom,d=t?pe(`providers.${t}.apiKey`,l):void 0,f=t?pe(`providers.${t}.apiBase`,l):void 0,p=t?pe(`providers.${t}.extraHeaders`,l):void 0,m=t?pe(`providers.${t}.wireApi`,l):void 0,h=s?.displayName||o?.displayName||t||``,g=(c.displayName||``).trim()||h,_=c.enabled!==!1,v=u||s?.supportsModelDiscovery===!0,y=Z([s?.modelPrefix||s?.providerType||``,t||``]),b=s?.defaultApiBase||``,x=c.apiBase||b,S=X(c.extraHeaders||null),C=c.wireApi||s?.defaultWireApi||`auto`,w=Oe(Z((s?.defaultModels??[]).map(e=>Q(e,y))),Z((c.models??[]).map(e=>Q(e,y)))),T=Ae(je(s?.modelConfig,c.modelConfig,y),w),E=s?.apiBaseHelp?.[a]||s?.apiBaseHelp?.en||f?.help||j(`providerApiBaseHelp`),D=qe({providerName:t,providerSpec:s,language:a}),O=Je(s,u);return{apiBaseHelpText:E,apiBaseHint:f,apiKeyHint:d,currentApiBase:x,currentEditableModels:w,currentEnabled:_,currentHeaders:S,currentModelConfig:T,currentWireApi:C,defaultApiBase:b,defaultDisplayName:h,effectiveDisplayName:g,extraHeadersHint:p,...D,providerConfig:o,providerModelAliases:y,resolvedProviderConfig:c,supportsModelDiscovery:v,wireApiHint:m,...O}}function Xe(e){let{providerName:t,providerAuth:n,resolvedAuthMethodId:r}=e,a=l(),o=se(),s=oe(),c=te(),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(``),g=(0,Y.useRef)(null),_=(0,Y.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),v=(0,Y.useCallback)((e,n)=>{_(),g.current=window.setTimeout(()=>{(async()=>{if(t)try{let r=await s.mutateAsync({provider:t,data:{sessionId:e}});if(r.status===`pending`){h(j(`providerAuthWaitingBrowser`)),v(e,r.nextPollMs??n);return}if(r.status===`authorized`){p(null),_(),h(j(`providerAuthCompleted`)),i.success(j(`providerAuthCompleted`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]});return}p(null),_(),h(r.message||`Authorization ${r.status}.`),i.error(r.message||`Authorization ${r.status}.`)}catch(e){p(null),_();let t=e instanceof Error?e.message:String(e);h(t),i.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,n))},[_,s,t,a]),y=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),h(``);let e=await o.mutateAsync({provider:t,data:r?{methodId:r}:{}});if(!e.sessionId||!e.verificationUri)throw Error(j(`providerAuthStartFailed`));p(e.sessionId),h(`${j(`providerAuthOpenPrompt`)}${e.userCode}${j(`providerAuthOpenPromptSuffix`)}`),await ee.openExternalUrl(e.verificationUri),v(e.sessionId,e.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);p(null),_(),h(t),i.error(`${j(`providerAuthStartFailed`)}: ${t}`)}},[_,n?.kind,t,r,v,o]),b=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),_(),p(null);let e=await c.mutateAsync({provider:t});h(`${j(`providerAuthImportStatusPrefix`)}${e.expiresAt?` (expires: ${e.expiresAt})`:``}`),i.success(j(`providerAuthImportSuccess`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);h(t),i.error(`${j(`providerAuthImportFailed`)}: ${t}`)}},[_,c,n?.kind,t,a]);return(0,Y.useEffect)(()=>{_()},[_,t]),(0,Y.useEffect)(()=>()=>_(),[_]),{authSessionId:u===t?f:null,authStatusMessage:u===t?m:``,importAuthFromCli:b,importPending:c.isPending,startAuth:y,startPending:o.isPending}}function Ze(e){let{providerName:t,apiKey:n,apiKeyRequired:r,apiKeySet:a,apiBase:o,extraHeaders:s,supportsWireApi:l,wireApi:u,models:d,providerModelAliases:f}=e,p=ie(),m=ce(),h=(0,Y.useMemo)(()=>JSON.stringify({providerName:t,apiKey:n,apiBase:o,extraHeaders:s}),[o,n,s,t]),[g,_]=(0,Y.useState)(null),v=(0,Y.useCallback)(async()=>{if(t)try{let e=await p.mutateAsync({provider:t,data:Fe({apiKey:n,apiBase:o,extraHeaders:s,supportsWireApi:l,wireApi:u,models:d,providerModelAliases:f})});if(e.success){i.success(`${j(`providerTestConnectionSuccess`)} (${e.latencyMs}ms)`);return}let r=[`provider=${e.provider}`,`latency=${e.latencyMs}ms`];e.model&&r.push(`model=${e.model}`),i.error(`${j(`providerTestConnectionFailed`)}: ${e.message} | ${r.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);i.error(`${j(`providerTestConnectionFailed`)}: ${t}`)}},[o,n,s,d,f,t,l,p,u]);return{discoverModels:(0,Y.useCallback)(async()=>{if(!t)return null;if(r&&!n.trim()&&!a)return i.error(j(`providerModelsApiKeyRequired`)),null;try{let e=await m.mutateAsync({provider:t,data:Ie({apiKey:n,apiBase:o,extraHeaders:s})});return _({key:h,models:e.models}),i.success(j(`providerModelsFetchSuccess`)),e.models}catch(e){if(e instanceof c&&(e.details?.upstreamStatus===401||e.details?.upstreamStatus===403))return i.error(j(`providerModelsAuthorizationFailed`)),null;let t=e instanceof Error?e.message:String(e);return i.error(`${j(`providerModelsFetchFailed`)}: ${t}`),null}},[o,n,r,a,m,h,s,t]),fetchedModels:g?.key===h?g.models:[],isDiscoveringModels:m.isPending,isTestPending:p.isPending,testConnection:v}}var $=u();function Qe({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,$.jsxs)(`div`,{className:s(`space-y-2`,r),children:[i.map(([e,n],r)=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(t,{type:`text`,value:e,onChange:e=>o(r,e.target.value,n),placeholder:j(`headerName`),className:`flex-1`}),(0,$.jsx)(t,{type:`text`,value:n,onChange:t=>o(r,e,t.target.value),placeholder:j(`headerValue`),className:`flex-1`}),(0,$.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(r),children:(0,$.jsx)(k,{className:`h-4 w-4 text-red-500`})})]},r)),(0,$.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,$.jsx)(E,{className:`h-4 w-4 mr-2`}),j(`add`)]})]})}function $e(e){let{value:t,onChange:n,options:r}=e;return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,$.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-[var(--interaction-selection-border)] bg-[var(--interaction-selection)] text-foreground`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-[var(--interaction-hover)] hover:text-foreground`}`,children:e.label},e.value)})})}function et(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:l,extraHeadersLabel:u,extraHeaders:d,onExtraHeadersChange:f}=e;return(0,$.jsxs)(`div`,{className:`border-t border-border/70 pt-4`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between text-sm text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(O,{className:`h-3.5 w-3.5`}),j(`providerAdvancedSettings`)]}),(0,$.jsx)(b,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,$.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`wireApi`,className:`text-sm font-medium text-foreground`,children:a}),c?(0,$.jsx)($e,{value:o,onChange:e=>s(e),options:l}):(0,$.jsxs)(q,{value:o,onValueChange:e=>s(e),children:[(0,$.jsx)(W,{className:`rounded-xl`,children:(0,$.jsx)(U,{})}),(0,$.jsx)(G,{children:l.map(e=>(0,$.jsx)(K,{value:e.value,children:e.label},e.value))})]})]}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{className:`text-sm font-medium text-foreground`,children:u}),(0,$.jsx)(Qe,{value:d,onChange:f}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerExtraHeadersHelpShort`)})]})]}):null]})}function tt({isSet:e,className:n,value:r,onChange:i,placeholder:o,...c}){let[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),p=typeof r==`string`&&r.length>0;return(0,$.jsxs)(`div`,{className:`relative`,children:[e&&!p&&!d?(0,$.jsx)(`div`,{onClick:()=>f(!0),className:s(`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`,n),children:`••••••••••••`}):(0,$.jsx)(t,{type:l?`text`:`password`,className:s(`pr-12`,n),value:r,onChange:i,onBlur:()=>{p||f(!1)},placeholder:o,autoFocus:d,...c}),(0,$.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||p)&&(0,$.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>u(!l),children:l?(0,$.jsx)(Ce,{className:`h-4 w-4`}):(0,$.jsx)(x,{className:`h-4 w-4`})})})]})}function nt(e){let{apiKey:t,apiKeyRequired:n,apiKeySet:i,apiKeyPlaceholder:o,providerAuth:s,providerAuthNote:c,providerAuthMethodOptions:l,providerAuthMethodsCount:u,selectedAuthMethodHint:d,shouldUseAuthMethodPills:f,resolvedAuthMethodId:p,onAuthMethodChange:m,onStartProviderAuth:h,onImportProviderAuthFromCli:g,startPending:_,importPending:v,authSessionId:y,authStatusMessage:b,onApiKeyChange:x}=e,S=n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`apiKey`,className:`text-sm font-medium text-foreground`,children:j(`apiKey`)}),(0,$.jsx)(tt,{id:`apiKey`,value:t,isSet:i,onChange:e=>x(e.target.value),placeholder:o,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`leaveBlankToKeepUnchanged`)})]}):null;return s?.kind===`device_code`?(0,$.jsxs)($.Fragment,{children:[S,(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-muted/45 p-3`,children:[(0,$.jsx)(r,{className:`text-sm font-medium text-foreground`,children:s.displayName||j(`providerAuthSectionTitle`)}),c?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c}):null,u>1?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{className:`text-xs font-medium text-foreground`,children:j(`providerAuthMethodLabel`)}),f?(0,$.jsx)($e,{value:p,onChange:m,options:l}):(0,$.jsxs)(q,{value:p,onValueChange:m,children:[(0,$.jsx)(W,{className:`h-8 rounded-lg`,children:(0,$.jsx)(U,{placeholder:j(`providerAuthMethodPlaceholder`)})}),(0,$.jsx)(G,{children:l.map(e=>(0,$.jsx)(K,{value:e.value,children:e.label},e.value))})]}),d?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d}):null]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:h,disabled:_||!!y,children:j(_?`providerAuthStarting`:y?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),s.supportsCliImport?(0,$.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:g,disabled:v,children:j(v?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,y?(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[j(`providerAuthSessionLabel`),`: `,y.slice(0,8),`…`]}):null]}),b?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b}):null]})]}):S}function rt(e){let{providerName:t,models:n,aliases:r,fetchedModels:i=[],onModelsChange:a}=e,o=ne({pollWhileRefreshing:!0,refreshOnMount:!0}),s=t?o.data?.providers[t]:void 0,c=i.length>0?`fetched`:`background`,l=(0,Y.useMemo)(()=>He(n,c===`fetched`?i:s?.models??[],r),[r,s?.models,i,n,c]);return{addSuggestedModels:(0,Y.useCallback)(e=>{let t=Ve(n,e,r);t.addedCount>0&&a(t.models)},[r,n,a]),hasSuggestionError:!!(s?.lastError&&!s.fetchedAt),isCheckingSuggestions:!!(t&&(o.isLoading||o.data?.refreshing&&!s)),suggestedModels:l,suggestionSource:c}}function it(e){let{models:t,modelConfig:i,onModelsChange:a,onRemoveModel:o,onToggleModelThinkingLevel:s,onSetModelThinkingDefault:c,onSetModelVision:l,thinkingLevels:u,formatThinkingLevelLabel:d}=e,[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(()=>new Set),g=(0,Y.useMemo)(()=>t.filter(e=>m.has(e)),[t,m]),_=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=()=>{p(!1),h(new Set)};return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`flex min-h-7 flex-wrap items-center justify-end gap-2`,children:f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:j(`providerModelsSuggestionsSelected`).replace(`{count}`,String(g.length))}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-primary hover:text-primary/80`,onClick:()=>h(g.length===t.length?new Set:new Set(t)),children:j(g.length===t.length?`providerModelsClearSelection`:`providerModelsSelectAll`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:v,children:j(`cancel`)}),(0,$.jsxs)(`button`,{type:`button`,disabled:g.length===0,className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/15 disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>{g.length!==0&&(a(t.filter(e=>!m.has(e))),v())},children:[(0,$.jsx)(k,{className:`h-3 w-3`}),j(`providerModelsRemoveSelected`)]})]}):(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:()=>p(!0),children:[(0,$.jsx)(k,{className:`h-3 w-3`}),j(`providerModelsBulkRemove`)]})}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{if(f)return(0,$.jsxs)(`label`,{className:`inline-flex max-w-full cursor-pointer items-center gap-2 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5 hover:bg-[var(--interaction-hover)]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:m.has(e),onChange:()=>_(e),"aria-label":j(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e})]},e);let t=i[e],a=t?.thinking,p=a?.supported??[],h=a?.default??null,g=t?.vision===!0;return(0,$.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e}),(0,$.jsxs)(R,{children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-[var(--interaction-hover)] hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":j(`providerModelThinkingTitle`),title:j(`providerModelThinkingTitle`),children:(0,$.jsx)(O,{className:`h-3 w-3`})})}),(0,$.jsxs)(F,{className:`w-80 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-muted/50 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:j(`providerModelVisionTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelVisionHint`)})]}),(0,$.jsx)(n,{checked:g,onCheckedChange:t=>l(e,t)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:j(`providerModelThinkingTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelThinkingHint`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.map(t=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${p.includes(t)?`border-[var(--interaction-selection-border)] bg-[var(--interaction-selection)] text-foreground`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-[var(--interaction-hover)] hover:text-foreground`}`,children:d(t)},t))}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(r,{className:`text-xs font-medium text-foreground`,children:j(`providerModelThinkingDefault`)}),(0,$.jsxs)(q,{value:h??`__none__`,onValueChange:t=>c(e,t===`__none__`?null:t),disabled:p.length===0,children:[(0,$.jsx)(W,{className:`h-8 rounded-lg text-xs`,children:(0,$.jsx)(U,{})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{value:`__none__`,children:j(`providerModelThinkingDefaultNone`)}),p.map(e=>(0,$.jsx)(K,{value:e,children:d(e)},e))]})]}),p.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-[var(--interaction-hover)] hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":j(`remove`),children:(0,$.jsx)(C,{className:`h-3 w-3`})})]},e)})}),f?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelsRemoveSaveHint`)}):null]})}var at=20,ot=50,st=50;function ct(e){let{expanded:n,fetchedTotal:r,models:i,source:a,onExpandedChange:o,onAddModels:s}=e,[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(()=>new Set),f=(0,Y.useMemo)(()=>{let e=c.trim().toLowerCase();return e?i.filter(t=>t.toLowerCase().includes(e)):i},[i,c]),p=f.slice(0,st),m=(0,Y.useMemo)(()=>i.filter(e=>u.has(e)),[i,u]),h=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=e=>{e.length!==0&&(s(e),l(``),d(new Set))},b=a===`fetched`?`providerModelsFetchedSuggestionsSummary`:`providerModelsSuggestionsSummary`;return a===`fetched`&&i.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,role:`status`,children:[(0,$.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{children:j(`providerModelsFetchedAllConfigured`).replace(`{count}`,String(r))})]}):(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":n,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-lg px-2 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-[var(--interaction-hover)] hover:text-foreground`,onClick:()=>o(!n),children:[(0,$.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:j(b).replace(`{count}`,String(i.length))}),(0,$.jsx)(g,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${n?`rotate-90`:``}`})]}),i.length<=ot?(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg px-2 py-1.5 text-xs font-medium text-primary transition-colors hover:bg-[var(--interaction-hover)]`,onClick:()=>_(i),children:j(`providerModelsSuggestionsAddAll`)}):null]}),n?(0,$.jsxs)(`div`,{className:`px-1 pb-1`,children:[i.length>at?(0,$.jsxs)(`div`,{className:`relative px-2 pb-1 pt-1.5`,children:[(0,$.jsx)(y,{className:`pointer-events-none absolute left-4 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(t,{value:c,onChange:e=>l(e.target.value),placeholder:j(`providerModelsSuggestionsSearchPlaceholder`),className:`h-8 rounded-lg pl-8 text-xs`})]}):null,(0,$.jsxs)(`div`,{className:`custom-scrollbar max-h-44 overflow-y-auto`,children:[p.map(e=>(0,$.jsxs)(`label`,{className:`grid min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-[var(--interaction-hover)]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:u.has(e),onChange:()=>h(e),"aria-label":j(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`block min-w-0 truncate text-xs text-foreground`,title:e,children:e})]},e)),f.length===0?(0,$.jsx)(`p`,{className:`px-2 py-4 text-center text-xs text-muted-foreground`,children:j(`providerModelsSuggestionsSearchEmpty`)}):null]}),f.length>p.length?(0,$.jsx)(`p`,{className:`px-2 pt-1 text-[11px] text-muted-foreground`,children:j(`providerModelsSuggestionsShowing`).replace(`{visible}`,String(p.length)).replace(`{count}`,String(f.length))}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pt-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:j(`providerModelsSuggestionsSelected`).replace(`{count}`,String(m.length))}),(0,$.jsx)(`button`,{type:`button`,disabled:m.length===0,className:`shrink-0 rounded-md bg-primary/10 px-2 py-1 text-[11px] font-medium text-primary transition-colors hover:bg-[var(--interaction-hover)] disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>_(m),children:j(`providerModelsSuggestionsAddSelected`)})]}),(0,$.jsx)(`p`,{className:`px-2 pb-1 pt-1 text-[11px] text-muted-foreground`,children:j(`providerModelsSuggestionsSaveHint`)})]}):null]})}function lt({hasFetchedCatalog:e,hasSuggestionError:t,supportsModelDiscovery:n}){return!n||!t||e?null:(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,$.jsx)(_,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),j(`providerModelsSuggestionsFailed`)]})}function ut(e){let{providerName:n,providerModelAliases:i,models:o,modelConfig:s,modelDraft:c,showModelInput:l,onModelDraftChange:u,onShowModelInputChange:d,onAddModel:f,onModelsChange:p,supportsModelDiscovery:m,onDiscoverModels:h,isDiscoveringModels:g,fetchedModels:_,onRemoveModel:v,onToggleModelThinkingLevel:y,onSetModelThinkingDefault:b,onSetModelVision:x,thinkingLevels:w,formatThinkingLevelLabel:T}=e,[O,k]=(0,Y.useState)(!1),A=(0,Y.useRef)(null),{addSuggestedModels:M,hasSuggestionError:N,isCheckingSuggestions:P,suggestedModels:F,suggestionSource:I}=rt({providerName:n,models:o,aliases:i,fetchedModels:_,onModelsChange:p}),L=async()=>{await h()&&(k(!0),window.requestAnimationFrame(()=>{let e=A.current;e?.scrollIntoView?.({behavior:`smooth`,block:`center`}),e?.focus({preventScroll:!0})}))},R=_.length>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(r,{className:`text-sm font-medium text-foreground`,children:j(`providerModelsTitle`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[m?(0,$.jsxs)(`button`,{type:`button`,onClick:L,disabled:g,className:`flex items-center gap-1 text-xs font-medium text-primary transition-colors hover:text-primary/80 disabled:cursor-wait disabled:opacity-60`,children:[(0,$.jsx)(D,{className:`h-3 w-3 ${g?`animate-spin`:``}`}),j(g?`providerModelsFetching`:`providerModelsFetch`)]}):null,l?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,$.jsx)(E,{className:`h-3 w-3`}),j(`providerAddModel`)]})]})]}),l?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(t,{value:c,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f()),e.key===`Escape`&&(d(!1),u(``))},placeholder:j(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,$.jsx)(a,{type:`button`,size:`sm`,onClick:f,disabled:c.trim().length===0,children:j(`add`)}),(0,$.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{d(!1),u(``)},children:(0,$.jsx)(C,{className:`h-4 w-4`})})]}):null,(0,$.jsx)(lt,{hasFetchedCatalog:R,hasSuggestionError:N,supportsModelDiscovery:m}),m&&P&&!R?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(S,{className:`h-3.5 w-3.5 animate-spin`}),j(`providerModelsSuggestionsChecking`)]}):m&&(F.length>0||R)?(0,$.jsx)(`div`,{ref:A,tabIndex:-1,"aria-live":`polite`,className:`scroll-m-4 outline-none`,children:(0,$.jsx)(ct,{expanded:O,fetchedTotal:_.length,models:F,source:I,onExpandedChange:k,onAddModels:M})}):null,o.length===0?(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 px-4 py-6 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:j(`providerModelsEmptyShort`)}),l?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>d(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:j(`providerAddFirstModel`)})]}):(0,$.jsx)(it,{models:o,modelConfig:s,onModelsChange:p,onRemoveModel:v,onToggleModelThinkingLevel:y,onSetModelThinkingDefault:b,onSetModelVision:x,thinkingLevels:w,formatThinkingLevelLabel:T})]})}function dt({apiKeyRequired:e=!0,apiKeySet:t,className:n,enabled:r}){if(!r)return(0,$.jsx)(V,{status:`inactive`,label:j(`disabled`),className:n});let i=!e||t;return(0,$.jsx)(V,{status:i?`ready`:`setup`,label:j(i?`statusReady`:`statusSetup`),className:n})}function ft(e){let{context:n,language:i,providerTitle:o,providerDisplayName:s,apiKey:c,apiBase:l,extraHeaders:u,wireApi:d,models:f,modelConfig:p,modelDraft:m,showAdvanced:h,showModelInput:g,resolvedAuthMethodId:_,authSessionId:v,authStatusMessage:y,hasChanges:b,isDeletePending:x,isUpdatePending:S,connectivity:C,startPending:w,importPending:T,onProviderDisplayNameChange:E,onApiKeyChange:D,onApiBaseChange:O,onAuthMethodChange:A,onStartProviderAuth:M,onImportProviderAuthFromCli:N,onModelDraftChange:P,onShowModelInputChange:F,onAddModel:I,onModelsChange:L,onRemoveModel:R,onToggleModelThinkingLevel:B,onSetModelThinkingDefault:V,onSetModelVision:H,onShowAdvancedChange:ee,onWireApiChange:U,onExtraHeadersChange:W,onDeleteProvider:G,onSubmit:K,onTestConnection:q}=e,J=n.providerAuthMethods.find(e=>e.id===_);return(0,$.jsxs)(ve,{children:[(0,$.jsx)(he,{className:`px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`truncate text-lg font-semibold text-foreground`,children:o}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:G,disabled:x,className:`text-muted-foreground/70 transition-colors hover:text-red-500`,title:j(`providerDelete`),children:(0,$.jsx)(k,{className:`h-4 w-4`})}),(0,$.jsx)(dt,{enabled:n.currentEnabled,apiKeyRequired:n.resolvedProviderConfig.apiKeyRequired,apiKeySet:n.resolvedProviderConfig.apiKeySet})]})]})}),(0,$.jsxs)(`form`,{onSubmit:K,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(ye,{className:`space-y-4 px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-foreground`,children:j(`providerDisplayName`)}),(0,$.jsx)(t,{id:`providerDisplayName`,type:`text`,value:s,onChange:e=>E(e.target.value),placeholder:n.defaultDisplayName||j(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerDisplayNameHelpShort`)})]}),(0,$.jsx)(nt,{apiKey:c,apiKeyRequired:n.resolvedProviderConfig.apiKeyRequired!==!1,apiKeySet:n.resolvedProviderConfig.apiKeySet,apiKeyPlaceholder:n.apiKeyHint?.placeholder??j(`enterApiKey`),providerAuth:n.providerAuth,providerAuthNote:n.providerAuth?.note?.[i]||n.providerAuth?.note?.en||n.providerAuth?.displayName||``,providerAuthMethodOptions:n.providerAuthMethodOptions,providerAuthMethodsCount:n.providerAuthMethods.length,selectedAuthMethodHint:J?.hint?.[i]||J?.hint?.en||``,shouldUseAuthMethodPills:n.shouldUseAuthMethodPills,resolvedAuthMethodId:_,onAuthMethodChange:A,onStartProviderAuth:M,onImportProviderAuthFromCli:N,startPending:w,importPending:T,authSessionId:v,authStatusMessage:y,onApiKeyChange:D}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`apiBase`,className:`text-sm font-medium text-foreground`,children:j(`apiBase`)}),(0,$.jsx)(t,{id:`apiBase`,type:`text`,value:l,onChange:e=>O(e.target.value),placeholder:n.defaultApiBase||n.apiBaseHint?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.apiBaseHelpText})]}),(0,$.jsx)(ut,{providerName:n.providerConfig?.providerId??``,providerModelAliases:n.providerModelAliases,models:f,modelConfig:p,modelDraft:m,showModelInput:g,onModelDraftChange:P,onShowModelInputChange:F,onAddModel:I,onModelsChange:L,supportsModelDiscovery:n.supportsModelDiscovery,onDiscoverModels:C.discoverModels,isDiscoveringModels:C.isDiscoveringModels,fetchedModels:C.fetchedModels,onRemoveModel:R,onToggleModelThinkingLevel:B,onSetModelThinkingDefault:V,onSetModelVision:H,thinkingLevels:z,formatThinkingLevelLabel:Le},n.providerConfig?.providerId),(0,$.jsx)(et,{showAdvanced:h,onShowAdvancedChange:ee,supportsWireApi:n.supportsWireApi,wireApiLabel:j(`wireApi`),wireApi:d,onWireApiChange:U,shouldUseWireApiPills:n.shouldUseWireApiPills,wireApiSelectOptions:n.wireApiSelectOptions,extraHeadersLabel:j(`extraHeaders`),extraHeaders:u,onExtraHeadersChange:W})]}),(0,$.jsx)(xe,{children:(0,$.jsxs)(fe,{align:`between`,children:[(0,$.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:q,disabled:C.isTestPending,children:[(0,$.jsx)(Se,{className:`mr-1.5 h-3.5 w-3.5`}),C.isTestPending?j(`providerTestingConnection`):j(`providerTestConnection`)]}),(0,$.jsx)(a,{type:`submit`,size:`sm`,disabled:S||!b,children:j(S?`saving`:b?`save`:`unchanged`)})]})})]})]})}function pt({providerName:e,onProviderDeleted:t}){let{data:n}=le(),{data:r}=re(),{data:i}=ue(),a=A(),o=(0,Y.useMemo)(()=>Ye({providerName:e,providersView:n,templatesView:r,schema:i,language:a}),[a,e,n,i,r]);if(!e||!o.providerConfig)return(0,$.jsx)(be,{children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:j(`providersSelectTitle`)}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:j(`providersSelectDescription`)})]})});let s=JSON.stringify({providerConfig:o.providerConfig,currentApiBase:o.currentApiBase,currentEditableModels:o.currentEditableModels,currentModelConfig:o.currentModelConfig,currentWireApi:o.currentWireApi,effectiveDisplayName:o.effectiveDisplayName,preferredAuthMethodId:o.preferredAuthMethodId});return(0,$.jsx)(mt,{providerName:e,onProviderDeleted:t,context:o,language:a},s)}function mt({providerName:e,onProviderDeleted:t,context:n,language:r}){let i=de(),a=J(),{currentApiBase:o,currentEditableModels:s,currentHeaders:c,currentModelConfig:l,currentWireApi:u,defaultApiBase:d,effectiveDisplayName:f,providerAuth:p,providerAuthMethods:m,providerModelAliases:h,resolvedProviderConfig:g,preferredAuthMethodId:_,supportsWireApi:v}=n,[y,b]=(0,Y.useState)(``),[x,S]=(0,Y.useState)(o),[C,w]=(0,Y.useState)(g.extraHeaders||null),[T,E]=(0,Y.useState)(u),[D,O]=(0,Y.useState)(s),[k,A]=(0,Y.useState)(l),[M,N]=(0,Y.useState)(``),[P,F]=(0,Y.useState)(f),[I,L]=(0,Y.useState)(!1),[R,z]=(0,Y.useState)(!1),[B,V]=(0,Y.useState)(_),H=Ze({providerName:e,apiKey:y,apiKeyRequired:g.apiKeyRequired!==!1,apiKeySet:g.apiKeySet,apiBase:x,extraHeaders:C,supportsWireApi:v,wireApi:T,models:D,providerModelAliases:h}),ee=P.trim()||f||e||j(`providersSelectPlaceholder`),U=(0,Y.useMemo)(()=>{if(!m.length)return``;let e=B.trim();return e&&m.some(t=>t.id===e)?e:_||m[0]?.id||``},[B,_,m]),{authSessionId:W,authStatusMessage:G,importAuthFromCli:K,importPending:q,startAuth:te,startPending:ne}=Xe({providerName:e,providerAuth:p,resolvedAuthMethodId:U}),re=(0,Y.useMemo)(()=>Ne({providerName:e,apiKey:y,apiBase:x,currentApiBase:o,extraHeaders:C,currentHeaders:c,supportsWireApi:v,wireApi:T,currentWireApi:u,models:D,currentEditableModels:s,modelConfig:k,currentModelConfig:l,providerDisplayName:P,effectiveDisplayName:f}),[e,y,x,o,C,c,v,T,u,D,s,k,l,P,f]),ie=e=>{O(e),A(t=>Ae(t,e))};return(0,$.jsx)(ft,{context:n,language:r,providerTitle:ee,providerDisplayName:P,apiKey:y,apiBase:x,extraHeaders:C,wireApi:T,models:D,modelConfig:k,modelDraft:M,showAdvanced:I,showModelInput:R,resolvedAuthMethodId:U,authSessionId:W,authStatusMessage:G,hasChanges:re,isDeletePending:a.isPending,isUpdatePending:i.isPending,connectivity:H,startPending:ne,importPending:q,onProviderDisplayNameChange:F,onApiKeyChange:b,onApiBaseChange:S,onAuthMethodChange:V,onStartProviderAuth:te,onImportProviderAuthFromCli:K,onModelDraftChange:N,onShowModelInputChange:z,onAddModel:()=>{let e=Be(D,M,h);ie(e.models),N(e.draft)},onModelsChange:ie,onRemoveModel:e=>{let t=Ue(D,k,e);O(t.models),A(t.modelConfig)},onToggleModelThinkingLevel:(e,t)=>{A(n=>We(n,e,t))},onSetModelThinkingDefault:(e,t)=>{A(n=>Ge(n,e,t))},onSetModelVision:(e,t)=>{A(n=>Ke(n,e,t))},onShowAdvancedChange:L,onWireApiChange:E,onExtraHeadersChange:w,onDeleteProvider:async()=>{if(e&&window.confirm(j(`providerDeleteConfirm`)))try{await a.mutateAsync({provider:e}),t?.(e)}catch{}},onSubmit:t=>{t.preventDefault(),e&&i.mutate({provider:e,data:Pe({providerName:e,apiKey:y,apiBase:x,currentApiBase:o,defaultApiBase:d,extraHeaders:C,currentHeaders:c,supportsWireApi:v,wireApi:T,currentWireApi:u,models:D,currentEditableModels:s,modelConfig:k,currentModelConfig:l,providerDisplayName:P,effectiveDisplayName:f})})},onTestConnection:H.testConnection})}function ht(e){if(!e)return null;try{let t=new URL(e);return`${t.host}${t.pathname&&t.pathname!==`/`?t.pathname:``}`}catch{return e.replace(/^https?:\/\//,``)}}function gt(e,t=[]){let n=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let r=n.get(e.provider.providerId),i=n.get(t.provider.providerId);if(r!==void 0||i!==void 0)return(r??2**53-1)-(i??2**53-1);let a=e.provider.providerType===`nextclaw`?1:0,o=t.provider.providerType===`nextclaw`?1:0;return a===o?e.index-t.index:a-o}).map(({provider:e})=>e)}function _t(e){let t=e.findIndex(e=>e.providerType===`zhipu`),n=e.findIndex(e=>e.providerType===`dashscope-coding-plan`);return e.map((e,t)=>({template:e,index:t})).sort((e,r)=>{let i=({template:e,index:r})=>e.providerType===`nextclaw`?2**53-1:e.providerType===`deepseek`&&n>=0?n-.5:e.providerType===`mimo`&&t>=0?t+.5:r;return i(e)-i(r)}).map(({template:e})=>e)}function vt(){let{isMobile:e}=T(),{data:r}=le(),{data:i}=re(),c=ae(),l=J(),u=de(),[d,f]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),[v,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)([]),[C,D]=(0,Y.useState)(``),O=(0,Y.useMemo)(()=>gt(Object.values(r?.providers??{}),x),[r?.providers,x]),A=(0,Y.useMemo)(()=>i?.providerTemplates??[],[i?.providerTemplates]),N=(0,Y.useMemo)(()=>_t(A),[A]),I=(0,Y.useMemo)(()=>new Map(A.map(e=>[e.providerType,e])),[A]),L=(0,Y.useMemo)(()=>{let e=C.trim().toLowerCase();return O.filter(t=>{if(!e)return!0;let n=t.providerType?I.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[O,C,I]),z=(0,Y.useMemo)(()=>d&&L.some(e=>e.providerId===d)?d:e?null:L[0]?.providerId??null,[L,e,d]);return!r||!i?(0,$.jsx)(o,{title:j(`providersPageTitle`),description:j(`providersPageDescription`),layout:`split`,children:(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:j(`providersLoading`)})}):(0,$.jsxs)(o,{title:j(`providersPageTitle`),description:j(`providersPageDescription`),layout:`split`,children:[(0,$.jsxs)(me,{className:`md:min-h-0`,compactView:d?`detail`:`list`,onMobileBack:()=>f(null),mobileListLabel:j(`providersPageTitle`),children:[(0,$.jsxs)(_e,{children:[(0,$.jsx)(he,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,$.jsxs)(R,{open:v,onOpenChange:b,children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsxs)(a,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:c.isPending,children:[(0,$.jsx)(E,{className:`mr-2 h-4 w-4`}),c.isPending?j(`saving`):j(`providerAdd`)]})}),(0,$.jsxs)(F,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,$.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-muted-foreground`,children:j(`providerTemplatePickerTitle`)}),(0,$.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-left transition-colors hover:border-border hover:bg-[var(--interaction-hover)]`,onClick:async()=>{try{let e=await c.mutateAsync({data:{providerType:null}});D(``),f(e.providerId),S(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),b(!1)}catch{}},children:[(0,$.jsx)(B,{name:`custom`,className:`h-8 w-8 rounded-lg border border-border/60 bg-muted/50`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:j(`providerAddCustom`)})]}),N.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-border/55 bg-muted/15 px-3 py-2 text-left transition-colors hover:border-border/80 hover:bg-[var(--interaction-hover)]`,onClick:async()=>{try{let t=await c.mutateAsync({data:{providerType:e.providerType}});D(``),f(t.providerId),S(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),b(!1)}catch{}},children:[(0,$.jsx)(B,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-border/55 bg-background`,imgClassName:`h-4 w-4 object-contain`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:e.displayName||e.providerType})]},e.providerType))]})]})]})}),(0,$.jsx)(`div`,{className:`border-b border-border/70 px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(y,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/70`}),(0,$.jsx)(t,{value:C,onChange:e=>D(e.target.value),placeholder:j(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,$.jsxs)(ye,{className:`space-y-2 p-3`,children:[L.map(e=>{let t=e.providerType?I.get(e.providerType):null,r=e.enabled!==!1,i=M(e),a=e.displayName?.trim()||t?.displayName||e.providerId,o=ht(e.apiBase||t?.defaultApiBase||``)||j(`providersDefaultDescription`);return(0,$.jsx)(`div`,{onClick:()=>f(e.providerId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),f(e.providerId))},role:`button`,tabIndex:0,className:s(`group w-full rounded-xl p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,z===e.providerId?`bg-[var(--interaction-selection)] text-foreground`:`bg-transparent text-muted-foreground hover:bg-[var(--interaction-hover)] hover:text-foreground`),children:(0,$.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,$.jsx)(B,{name:e.providerType??e.providerId,src:t?.logo?`/logos/${t.logo}`:null,className:`h-10 w-10 rounded-lg bg-background/80`,imgClassName:`h-5 w-5 object-contain`,fallback:(0,$.jsx)(`span`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:e.providerId[0]})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:a}),(0,$.jsx)(`p`,{className:`truncate font-mono text-[10px] text-muted-foreground/65`,children:e.providerId}),(0,$.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-muted-foreground`,children:[o,` · `,e.models?.length??0]})]})]}),(0,$.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5 opacity-70 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(n,{checked:r,disabled:u.isPending,title:j(r?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:t=>{u.mutateAsync({provider:e.providerId,data:{enabled:t},silentSuccess:!0})}})}),(0,$.jsxs)(R,{children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/70 hover:bg-[var(--interaction-hover)] hover:text-foreground`,onClick:e=>e.stopPropagation(),title:j(`more`),children:(0,$.jsx)(h,{className:`h-4 w-4`})})}),(0,$.jsx)(F,{variant:`menu`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(`button`,{type:`button`,className:`${p} ${m.destructive}`,onClick:()=>_(e.providerId),children:[(0,$.jsx)(k,{className:`h-4 w-4`}),j(`providerDelete`)]})})]})]}),(0,$.jsx)(V,{status:r?i?`ready`:`setup`:`inactive`,label:j(r?i?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},e.providerId)}),L.length===0?(0,$.jsx)(ge,{icon:w,title:j(`providersNoMatch`)}):null]})]}),(0,$.jsx)(pt,{providerName:z??void 0,onProviderDeleted:e=>{S(t=>t.filter(t=>t!==e)),e===z&&f(null)}})]}),(0,$.jsx)(H,{open:!!g,onOpenChange:e=>{e||_(null)},title:j(`providerDelete`),description:g??void 0,confirmLabel:j(`delete`),variant:`destructive`,onCancel:()=>_(null),onConfirm:()=>{g&&l.mutateAsync({provider:g}).then(()=>{S(e=>e.filter(e=>e!==g)),g===z&&f(null),_(null)})}})]})}export{vt as ProvidersConfigPage};
1
+ import{i as e}from"./chunk-DF37yw5_.js";import{Gt as t,Ut as n,Wt as r,Xn as i,Yt as a,Zt as o,_n as s,hn as c,lr as l,ur as u,xr as d}from"./api-BaML_txv.js";import{t as f}from"./createLucideIcon-D-7Sxfw7.js";import{g as p,h as m,lt as h,mt as g,pt as _,q as v}from"./context-menu-DVgLoPqH.js";import{t as y}from"./search-Drx-sMCE.js";import{z as b}from"./dist-BxOjfeaD.js";import{n as x}from"./inbox-DofXi7Xv.js";import{i as S,t as C}from"./x-DLvS4xvV.js";import{i as w,t as T}from"./use-viewport-layout-D6seoW0Z.js";import{t as E}from"./plus-v29lPO18.js";import{t as D}from"./refresh-cw-CqsHJPqR.js";import{t as O}from"./settings-2-DAPjKYtK.js";import{t as k}from"./trash-2-B8mbrtCx.js";import{l as A,s as j}from"./i18n-Bzo4IocH.js";import{a as M,c as N,g as P,h as F,l as I,o as L,p as R,t as z}from"./provider-models-CWtoV3BJ.js";import{n as B,t as V}from"./status-dot-xxVxbdQr.js";import{t as H}from"./confirm-dialog-BdEQiFoD.js";import{t as ee}from"./host-capabilities-B107nwS3.js";import{a as U,i as W,n as G,r as K,t as q}from"./select-DHYR109w.js";import{a as J,c as te,d as ne,f as re,h as ie,i as ae,l as oe,m as se,o as ce,p as le,r as ue,y as de}from"./use-config-BpKXDcM_.js";import{t as fe}from"./form-actions-XP38NiPw.js";import{t as pe}from"./config-hints-CaB3I7KP.js";import{a as me,c as he,i as ge,l as _e,n as ve,o as ye,r as be,s as xe}from"./config-split-page-Cfozkh5B.js";var Se=f(`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`}]]),Ce=f(`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`}]]),Y=e(d(),1),we={providerId:``,providerType:null,isBuiltInType:!1,isCustom:!0,enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelConfig:{}};function X(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 Te(e,t){let n=X(e),r=X(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 Z(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 Ee(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 Q(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=Ee(n,t))}return n.trim()}function De(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Oe(e,t){return Z(t)}function ke(e,t){return Z(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Ae(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={},a=N(i.thinking?.supported);if(a.length>0){let t=I(i.thinking?.default);e.thinking=t&&a.includes(t)?{supported:a,default:t}:{supported:a}}i.vision===!0&&(e.vision=!0),(e.thinking||e.vision===!0)&&(r[t]=e)}return r}function je(e,t,n){return{...L(e,n),...L(t,n)}}function Me(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||!De([...o.thinking?.supported??[]].sort(),[...s.thinking?.supported??[]].sort())||(o.thinking?.default??null)!==(s.thinking?.default??null)||(o.vision??!1)!==(s.vision??!1))return!1}return!0}function Ne(e){return e.providerName?e.apiKey.trim().length>0||e.apiBase.trim()!==e.currentApiBase.trim()||!Te(e.extraHeaders,e.currentHeaders)||e.supportsWireApi&&e.wireApi!==e.currentWireApi||!De(e.models,e.currentEditableModels)||!Me(e.modelConfig,e.currentModelConfig)||e.providerDisplayName.trim()!==e.effectiveDisplayName:!1}function Pe(e){let t={},n=e.apiKey.trim(),r=e.apiBase.trim(),i=X(e.extraHeaders),a=e.providerDisplayName.trim();return a!==e.effectiveDisplayName&&(t.displayName=a.length>0?a:null),n.length>0&&(t.apiKey=n),r!==e.currentApiBase.trim()&&(t.apiBase=r.length>0&&r!==e.defaultApiBase?r:null),Te(i,e.currentHeaders)||(t.extraHeaders=i),e.supportsWireApi&&e.wireApi!==e.currentWireApi&&(t.wireApi=e.wireApi),De(e.models,e.currentEditableModels)||(t.models=ke(e.models,e.providerName??``)),Me(e.modelConfig,e.currentModelConfig)||(t.modelConfig=Ae(e.modelConfig,e.models)),t}function Fe(e){let t=Q(e.models.find(e=>e.trim().length>0)??``,e.providerModelAliases),n={...Ie(e),model:t||null};return e.supportsWireApi&&(n.wireApi=e.wireApi),n}function Ie(e){let t={apiBase:e.apiBase.trim(),extraHeaders:X(e.extraHeaders)};return e.apiKey.trim().length>0&&(t.apiKey=e.apiKey.trim()),t}function Le(e){return j(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Re(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 ze(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Be(e,t,n){let r=Q(t,n);return r?e.includes(r)?{models:e,draft:``}:{models:[...e,r],draft:``}:{models:e,draft:t}}function Ve(e,t,n){let r=[...e],i=new Set(e);for(let e of t){let t=Q(e,n);t&&!i.has(t)&&(i.add(t),r.push(t))}return{models:r,addedCount:r.length-e.length}}function He(e,t,n){return Ve(e,t,n).models.slice(e.length)}function Ue(e,t,n){let r={...t};return delete r[n],{models:e.filter(e=>e!==n),modelConfig:r}}function We(e,t,n){let r=e[t],i=r?.thinking?.supported??[],a=i.includes(n)?i.filter(e=>e!==n):z.filter(e=>e===n||i.includes(e)),o=r?.thinking?.default&&a.includes(r.thinking.default)?r.thinking.default:void 0,s={...r,thinking:a.length>0?o?{supported:a,default:o}:{supported:a}:void 0},c={...e};return s.thinking||s.vision===!0?c[t]=s:delete c[t],c}function Ge(e,t,n){let r=e[t],i=r?.thinking;return!i||i.supported.length===0||n&&!i.supported.includes(n)?e:{...e,[t]:{...r,thinking:n?{supported:i.supported,default:n}:{supported:i.supported}}}}function Ke(e,t,n){let r={...e[t],vision:n?!0:void 0},i={...e};return r.thinking||r.vision===!0?i[t]=r:delete i[t],i}function qe(e){let{providerName:t,providerSpec:n,language:r}=e,i=n?.auth,a=i?.methods??[];return{providerAuth:i,providerAuthMethodOptions:a.map(e=>({value:e.id,label:e.label?.[r]||e.label?.en||e.id})),providerAuthMethods:a,preferredAuthMethodId:Re({providerName:n?.providerType??t,methods:a,defaultMethodId:i?.defaultMethodId,language:r}),shouldUseAuthMethodPills:ze({required:i?.kind===`device_code`,hasDefault:!!i?.defaultMethodId?.trim(),optionCount:a.length})}}function Je(e,t){let n=!!e?.supportsWireApi||t,r=(e?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:j(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)}));return{shouldUseWireApiPills:ze({required:n,hasDefault:typeof e?.defaultWireApi==`string`&&e.defaultWireApi.length>0,optionCount:r.length}),supportsWireApi:n,wireApiSelectOptions:r}}function Ye(e){let{providerName:t,providersView:n,templatesView:r,schema:i,language:a}=e,o=t?n?.providers[t]:null,s=r?.providerTemplates.find(e=>e.providerType===o?.providerType),c=o??we,l=i?.uiHints,u=!!o?.isCustom,d=t?pe(`providers.${t}.apiKey`,l):void 0,f=t?pe(`providers.${t}.apiBase`,l):void 0,p=t?pe(`providers.${t}.extraHeaders`,l):void 0,m=t?pe(`providers.${t}.wireApi`,l):void 0,h=s?.displayName||o?.displayName||t||``,g=(c.displayName||``).trim()||h,_=c.enabled!==!1,v=u||s?.supportsModelDiscovery===!0,y=Z([s?.modelPrefix||s?.providerType||``,t||``]),b=s?.defaultApiBase||``,x=c.apiBase||b,S=X(c.extraHeaders||null),C=c.wireApi||s?.defaultWireApi||`auto`,w=Oe(Z((s?.defaultModels??[]).map(e=>Q(e,y))),Z((c.models??[]).map(e=>Q(e,y)))),T=Ae(je(s?.modelConfig,c.modelConfig,y),w),E=s?.apiBaseHelp?.[a]||s?.apiBaseHelp?.en||f?.help||j(`providerApiBaseHelp`),D=qe({providerName:t,providerSpec:s,language:a}),O=Je(s,u);return{apiBaseHelpText:E,apiBaseHint:f,apiKeyHint:d,currentApiBase:x,currentEditableModels:w,currentEnabled:_,currentHeaders:S,currentModelConfig:T,currentWireApi:C,defaultApiBase:b,defaultDisplayName:h,effectiveDisplayName:g,extraHeadersHint:p,...D,providerConfig:o,providerModelAliases:y,resolvedProviderConfig:c,supportsModelDiscovery:v,wireApiHint:m,...O}}function Xe(e){let{providerName:t,providerAuth:n,resolvedAuthMethodId:r}=e,a=l(),o=se(),s=oe(),c=te(),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(``),g=(0,Y.useRef)(null),_=(0,Y.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),v=(0,Y.useCallback)((e,n)=>{_(),g.current=window.setTimeout(()=>{(async()=>{if(t)try{let r=await s.mutateAsync({provider:t,data:{sessionId:e}});if(r.status===`pending`){h(j(`providerAuthWaitingBrowser`)),v(e,r.nextPollMs??n);return}if(r.status===`authorized`){p(null),_(),h(j(`providerAuthCompleted`)),i.success(j(`providerAuthCompleted`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]});return}p(null),_(),h(r.message||`Authorization ${r.status}.`),i.error(r.message||`Authorization ${r.status}.`)}catch(e){p(null),_();let t=e instanceof Error?e.message:String(e);h(t),i.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,n))},[_,s,t,a]),y=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),h(``);let e=await o.mutateAsync({provider:t,data:r?{methodId:r}:{}});if(!e.sessionId||!e.verificationUri)throw Error(j(`providerAuthStartFailed`));p(e.sessionId),h(`${j(`providerAuthOpenPrompt`)}${e.userCode}${j(`providerAuthOpenPromptSuffix`)}`),await ee.openExternalUrl(e.verificationUri),v(e.sessionId,e.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);p(null),_(),h(t),i.error(`${j(`providerAuthStartFailed`)}: ${t}`)}},[_,n?.kind,t,r,v,o]),b=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),_(),p(null);let e=await c.mutateAsync({provider:t});h(`${j(`providerAuthImportStatusPrefix`)}${e.expiresAt?` (expires: ${e.expiresAt})`:``}`),i.success(j(`providerAuthImportSuccess`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);h(t),i.error(`${j(`providerAuthImportFailed`)}: ${t}`)}},[_,c,n?.kind,t,a]);return(0,Y.useEffect)(()=>{_()},[_,t]),(0,Y.useEffect)(()=>()=>_(),[_]),{authSessionId:u===t?f:null,authStatusMessage:u===t?m:``,importAuthFromCli:b,importPending:c.isPending,startAuth:y,startPending:o.isPending}}function Ze(e){let{providerName:t,apiKey:n,apiKeyRequired:r,apiKeySet:a,apiBase:o,extraHeaders:s,supportsWireApi:l,wireApi:u,models:d,providerModelAliases:f}=e,p=ie(),m=ce(),h=(0,Y.useMemo)(()=>JSON.stringify({providerName:t,apiKey:n,apiBase:o,extraHeaders:s}),[o,n,s,t]),[g,_]=(0,Y.useState)(null),v=(0,Y.useCallback)(async()=>{if(t)try{let e=await p.mutateAsync({provider:t,data:Fe({apiKey:n,apiBase:o,extraHeaders:s,supportsWireApi:l,wireApi:u,models:d,providerModelAliases:f})});if(e.success){i.success(`${j(`providerTestConnectionSuccess`)} (${e.latencyMs}ms)`);return}let r=[`provider=${e.provider}`,`latency=${e.latencyMs}ms`];e.model&&r.push(`model=${e.model}`),i.error(`${j(`providerTestConnectionFailed`)}: ${e.message} | ${r.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);i.error(`${j(`providerTestConnectionFailed`)}: ${t}`)}},[o,n,s,d,f,t,l,p,u]);return{discoverModels:(0,Y.useCallback)(async()=>{if(!t)return null;if(r&&!n.trim()&&!a)return i.error(j(`providerModelsApiKeyRequired`)),null;try{let e=await m.mutateAsync({provider:t,data:Ie({apiKey:n,apiBase:o,extraHeaders:s})});return _({key:h,models:e.models}),i.success(j(`providerModelsFetchSuccess`)),e.models}catch(e){if(e instanceof c&&(e.details?.upstreamStatus===401||e.details?.upstreamStatus===403))return i.error(j(`providerModelsAuthorizationFailed`)),null;let t=e instanceof Error?e.message:String(e);return i.error(`${j(`providerModelsFetchFailed`)}: ${t}`),null}},[o,n,r,a,m,h,s,t]),fetchedModels:g?.key===h?g.models:[],isDiscoveringModels:m.isPending,isTestPending:p.isPending,testConnection:v}}var $=u();function Qe({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,$.jsxs)(`div`,{className:s(`space-y-2`,r),children:[i.map(([e,n],r)=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(t,{type:`text`,value:e,onChange:e=>o(r,e.target.value,n),placeholder:j(`headerName`),className:`flex-1`}),(0,$.jsx)(t,{type:`text`,value:n,onChange:t=>o(r,e,t.target.value),placeholder:j(`headerValue`),className:`flex-1`}),(0,$.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(r),children:(0,$.jsx)(k,{className:`h-4 w-4 text-red-500`})})]},r)),(0,$.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,$.jsx)(E,{className:`h-4 w-4 mr-2`}),j(`add`)]})]})}function $e(e){let{value:t,onChange:n,options:r}=e;return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,$.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-[var(--interaction-selection-border)] bg-[var(--interaction-selection)] text-foreground`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-[var(--interaction-hover)] hover:text-foreground`}`,children:e.label},e.value)})})}function et(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:l,extraHeadersLabel:u,extraHeaders:d,onExtraHeadersChange:f}=e;return(0,$.jsxs)(`div`,{className:`border-t border-border/70 pt-4`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between text-sm text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(O,{className:`h-3.5 w-3.5`}),j(`providerAdvancedSettings`)]}),(0,$.jsx)(b,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,$.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`wireApi`,className:`text-sm font-medium text-foreground`,children:a}),c?(0,$.jsx)($e,{value:o,onChange:e=>s(e),options:l}):(0,$.jsxs)(q,{value:o,onValueChange:e=>s(e),children:[(0,$.jsx)(W,{className:`rounded-xl`,children:(0,$.jsx)(U,{})}),(0,$.jsx)(G,{children:l.map(e=>(0,$.jsx)(K,{value:e.value,children:e.label},e.value))})]})]}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{className:`text-sm font-medium text-foreground`,children:u}),(0,$.jsx)(Qe,{value:d,onChange:f}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerExtraHeadersHelpShort`)})]})]}):null]})}function tt({isSet:e,className:n,value:r,onChange:i,placeholder:o,...c}){let[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),p=typeof r==`string`&&r.length>0;return(0,$.jsxs)(`div`,{className:`relative`,children:[e&&!p&&!d?(0,$.jsx)(`div`,{onClick:()=>f(!0),className:s(`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`,n),children:`••••••••••••`}):(0,$.jsx)(t,{type:l?`text`:`password`,className:s(`pr-12`,n),value:r,onChange:i,onBlur:()=>{p||f(!1)},placeholder:o,autoFocus:d,...c}),(0,$.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||p)&&(0,$.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>u(!l),children:l?(0,$.jsx)(Ce,{className:`h-4 w-4`}):(0,$.jsx)(x,{className:`h-4 w-4`})})})]})}function nt(e){let{apiKey:t,apiKeyRequired:n,apiKeySet:i,apiKeyPlaceholder:o,providerAuth:s,providerAuthNote:c,providerAuthMethodOptions:l,providerAuthMethodsCount:u,selectedAuthMethodHint:d,shouldUseAuthMethodPills:f,resolvedAuthMethodId:p,onAuthMethodChange:m,onStartProviderAuth:h,onImportProviderAuthFromCli:g,startPending:_,importPending:v,authSessionId:y,authStatusMessage:b,onApiKeyChange:x}=e,S=n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`apiKey`,className:`text-sm font-medium text-foreground`,children:j(`apiKey`)}),(0,$.jsx)(tt,{id:`apiKey`,value:t,isSet:i,onChange:e=>x(e.target.value),placeholder:o,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`leaveBlankToKeepUnchanged`)})]}):null;return s?.kind===`device_code`?(0,$.jsxs)($.Fragment,{children:[S,(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-muted/45 p-3`,children:[(0,$.jsx)(r,{className:`text-sm font-medium text-foreground`,children:s.displayName||j(`providerAuthSectionTitle`)}),c?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c}):null,u>1?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{className:`text-xs font-medium text-foreground`,children:j(`providerAuthMethodLabel`)}),f?(0,$.jsx)($e,{value:p,onChange:m,options:l}):(0,$.jsxs)(q,{value:p,onValueChange:m,children:[(0,$.jsx)(W,{className:`h-8 rounded-lg`,children:(0,$.jsx)(U,{placeholder:j(`providerAuthMethodPlaceholder`)})}),(0,$.jsx)(G,{children:l.map(e=>(0,$.jsx)(K,{value:e.value,children:e.label},e.value))})]}),d?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d}):null]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:h,disabled:_||!!y,children:j(_?`providerAuthStarting`:y?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),s.supportsCliImport?(0,$.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:g,disabled:v,children:j(v?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,y?(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[j(`providerAuthSessionLabel`),`: `,y.slice(0,8),`…`]}):null]}),b?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b}):null]})]}):S}function rt(e){let{providerName:t,models:n,aliases:r,fetchedModels:i=[],onModelsChange:a}=e,o=ne({pollWhileRefreshing:!0,refreshOnMount:!0}),s=t?o.data?.providers[t]:void 0,c=i.length>0?`fetched`:`background`,l=(0,Y.useMemo)(()=>He(n,c===`fetched`?i:s?.models??[],r),[r,s?.models,i,n,c]);return{addSuggestedModels:(0,Y.useCallback)(e=>{let t=Ve(n,e,r);t.addedCount>0&&a(t.models)},[r,n,a]),hasSuggestionError:!!(s?.lastError&&!s.fetchedAt),isCheckingSuggestions:!!(t&&(o.isLoading||o.data?.refreshing&&!s)),suggestedModels:l,suggestionSource:c}}function it(e){let{models:t,modelConfig:i,onModelsChange:a,onRemoveModel:o,onToggleModelThinkingLevel:s,onSetModelThinkingDefault:c,onSetModelVision:l,thinkingLevels:u,formatThinkingLevelLabel:d}=e,[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(()=>new Set),g=(0,Y.useMemo)(()=>t.filter(e=>m.has(e)),[t,m]),_=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=()=>{p(!1),h(new Set)};return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`flex min-h-7 flex-wrap items-center justify-end gap-2`,children:f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:j(`providerModelsSuggestionsSelected`).replace(`{count}`,String(g.length))}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-primary hover:text-primary/80`,onClick:()=>h(g.length===t.length?new Set:new Set(t)),children:j(g.length===t.length?`providerModelsClearSelection`:`providerModelsSelectAll`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:v,children:j(`cancel`)}),(0,$.jsxs)(`button`,{type:`button`,disabled:g.length===0,className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/15 disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>{g.length!==0&&(a(t.filter(e=>!m.has(e))),v())},children:[(0,$.jsx)(k,{className:`h-3 w-3`}),j(`providerModelsRemoveSelected`)]})]}):(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:()=>p(!0),children:[(0,$.jsx)(k,{className:`h-3 w-3`}),j(`providerModelsBulkRemove`)]})}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{if(f)return(0,$.jsxs)(`label`,{className:`inline-flex max-w-full cursor-pointer items-center gap-2 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5 hover:bg-[var(--interaction-hover)]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:m.has(e),onChange:()=>_(e),"aria-label":j(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e})]},e);let t=i[e],a=t?.thinking,p=a?.supported??[],h=a?.default??null,g=t?.vision===!0;return(0,$.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e}),(0,$.jsxs)(R,{children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-[var(--interaction-hover)] hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":j(`providerModelThinkingTitle`),title:j(`providerModelThinkingTitle`),children:(0,$.jsx)(O,{className:`h-3 w-3`})})}),(0,$.jsxs)(F,{className:`w-80 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-muted/50 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:j(`providerModelVisionTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelVisionHint`)})]}),(0,$.jsx)(n,{checked:g,onCheckedChange:t=>l(e,t)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:j(`providerModelThinkingTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelThinkingHint`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.map(t=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${p.includes(t)?`border-[var(--interaction-selection-border)] bg-[var(--interaction-selection)] text-foreground`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-[var(--interaction-hover)] hover:text-foreground`}`,children:d(t)},t))}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(r,{className:`text-xs font-medium text-foreground`,children:j(`providerModelThinkingDefault`)}),(0,$.jsxs)(q,{value:h??`__none__`,onValueChange:t=>c(e,t===`__none__`?null:t),disabled:p.length===0,children:[(0,$.jsx)(W,{className:`h-8 rounded-lg text-xs`,children:(0,$.jsx)(U,{})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{value:`__none__`,children:j(`providerModelThinkingDefaultNone`)}),p.map(e=>(0,$.jsx)(K,{value:e,children:d(e)},e))]})]}),p.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-[var(--interaction-hover)] hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":j(`remove`),children:(0,$.jsx)(C,{className:`h-3 w-3`})})]},e)})}),f?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelsRemoveSaveHint`)}):null]})}var at=20,ot=50,st=50;function ct(e){let{expanded:n,fetchedTotal:r,models:i,source:a,onExpandedChange:o,onAddModels:s}=e,[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(()=>new Set),f=(0,Y.useMemo)(()=>{let e=c.trim().toLowerCase();return e?i.filter(t=>t.toLowerCase().includes(e)):i},[i,c]),p=f.slice(0,st),m=(0,Y.useMemo)(()=>i.filter(e=>u.has(e)),[i,u]),h=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=e=>{e.length!==0&&(s(e),l(``),d(new Set))},b=a===`fetched`?`providerModelsFetchedSuggestionsSummary`:`providerModelsSuggestionsSummary`;return a===`fetched`&&i.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,role:`status`,children:[(0,$.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{children:j(`providerModelsFetchedAllConfigured`).replace(`{count}`,String(r))})]}):(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":n,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-lg px-2 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-[var(--interaction-hover)] hover:text-foreground`,onClick:()=>o(!n),children:[(0,$.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:j(b).replace(`{count}`,String(i.length))}),(0,$.jsx)(g,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${n?`rotate-90`:``}`})]}),i.length<=ot?(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg px-2 py-1.5 text-xs font-medium text-primary transition-colors hover:bg-[var(--interaction-hover)]`,onClick:()=>_(i),children:j(`providerModelsSuggestionsAddAll`)}):null]}),n?(0,$.jsxs)(`div`,{className:`px-1 pb-1`,children:[i.length>at?(0,$.jsxs)(`div`,{className:`relative px-2 pb-1 pt-1.5`,children:[(0,$.jsx)(y,{className:`pointer-events-none absolute left-4 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(t,{value:c,onChange:e=>l(e.target.value),placeholder:j(`providerModelsSuggestionsSearchPlaceholder`),className:`h-8 rounded-lg pl-8 text-xs`})]}):null,(0,$.jsxs)(`div`,{className:`custom-scrollbar max-h-44 overflow-y-auto`,children:[p.map(e=>(0,$.jsxs)(`label`,{className:`grid min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-[var(--interaction-hover)]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:u.has(e),onChange:()=>h(e),"aria-label":j(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`block min-w-0 truncate text-xs text-foreground`,title:e,children:e})]},e)),f.length===0?(0,$.jsx)(`p`,{className:`px-2 py-4 text-center text-xs text-muted-foreground`,children:j(`providerModelsSuggestionsSearchEmpty`)}):null]}),f.length>p.length?(0,$.jsx)(`p`,{className:`px-2 pt-1 text-[11px] text-muted-foreground`,children:j(`providerModelsSuggestionsShowing`).replace(`{visible}`,String(p.length)).replace(`{count}`,String(f.length))}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pt-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:j(`providerModelsSuggestionsSelected`).replace(`{count}`,String(m.length))}),(0,$.jsx)(`button`,{type:`button`,disabled:m.length===0,className:`shrink-0 rounded-md bg-primary/10 px-2 py-1 text-[11px] font-medium text-primary transition-colors hover:bg-[var(--interaction-hover)] disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>_(m),children:j(`providerModelsSuggestionsAddSelected`)})]}),(0,$.jsx)(`p`,{className:`px-2 pb-1 pt-1 text-[11px] text-muted-foreground`,children:j(`providerModelsSuggestionsSaveHint`)})]}):null]})}function lt({hasFetchedCatalog:e,hasSuggestionError:t,supportsModelDiscovery:n}){return!n||!t||e?null:(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,$.jsx)(_,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),j(`providerModelsSuggestionsFailed`)]})}function ut(e){let{providerName:n,providerModelAliases:i,models:o,modelConfig:s,modelDraft:c,showModelInput:l,onModelDraftChange:u,onShowModelInputChange:d,onAddModel:f,onModelsChange:p,supportsModelDiscovery:m,onDiscoverModels:h,isDiscoveringModels:g,fetchedModels:_,onRemoveModel:v,onToggleModelThinkingLevel:y,onSetModelThinkingDefault:b,onSetModelVision:x,thinkingLevels:w,formatThinkingLevelLabel:T}=e,[O,k]=(0,Y.useState)(!1),A=(0,Y.useRef)(null),{addSuggestedModels:M,hasSuggestionError:N,isCheckingSuggestions:P,suggestedModels:F,suggestionSource:I}=rt({providerName:n,models:o,aliases:i,fetchedModels:_,onModelsChange:p}),L=async()=>{await h()&&(k(!0),window.requestAnimationFrame(()=>{let e=A.current;e?.scrollIntoView?.({behavior:`smooth`,block:`center`}),e?.focus({preventScroll:!0})}))},R=_.length>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(r,{className:`text-sm font-medium text-foreground`,children:j(`providerModelsTitle`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[m?(0,$.jsxs)(`button`,{type:`button`,onClick:L,disabled:g,className:`flex items-center gap-1 text-xs font-medium text-primary transition-colors hover:text-primary/80 disabled:cursor-wait disabled:opacity-60`,children:[(0,$.jsx)(D,{className:`h-3 w-3 ${g?`animate-spin`:``}`}),j(g?`providerModelsFetching`:`providerModelsFetch`)]}):null,l?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,$.jsx)(E,{className:`h-3 w-3`}),j(`providerAddModel`)]})]})]}),l?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(t,{value:c,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f()),e.key===`Escape`&&(d(!1),u(``))},placeholder:j(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,$.jsx)(a,{type:`button`,size:`sm`,onClick:f,disabled:c.trim().length===0,children:j(`add`)}),(0,$.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{d(!1),u(``)},children:(0,$.jsx)(C,{className:`h-4 w-4`})})]}):null,(0,$.jsx)(lt,{hasFetchedCatalog:R,hasSuggestionError:N,supportsModelDiscovery:m}),m&&P&&!R?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(S,{className:`h-3.5 w-3.5 animate-spin`}),j(`providerModelsSuggestionsChecking`)]}):m&&(F.length>0||R)?(0,$.jsx)(`div`,{ref:A,tabIndex:-1,"aria-live":`polite`,className:`scroll-m-4 outline-none`,children:(0,$.jsx)(ct,{expanded:O,fetchedTotal:_.length,models:F,source:I,onExpandedChange:k,onAddModels:M})}):null,o.length===0?(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 px-4 py-6 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:j(`providerModelsEmptyShort`)}),l?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>d(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:j(`providerAddFirstModel`)})]}):(0,$.jsx)(it,{models:o,modelConfig:s,onModelsChange:p,onRemoveModel:v,onToggleModelThinkingLevel:y,onSetModelThinkingDefault:b,onSetModelVision:x,thinkingLevels:w,formatThinkingLevelLabel:T})]})}function dt({apiKeyRequired:e=!0,apiKeySet:t,className:n,enabled:r}){if(!r)return(0,$.jsx)(V,{status:`inactive`,label:j(`disabled`),className:n});let i=!e||t;return(0,$.jsx)(V,{status:i?`ready`:`setup`,label:j(i?`statusReady`:`statusSetup`),className:n})}function ft(e){let{context:n,language:i,providerTitle:o,providerDisplayName:s,apiKey:c,apiBase:l,extraHeaders:u,wireApi:d,models:f,modelConfig:p,modelDraft:m,showAdvanced:h,showModelInput:g,resolvedAuthMethodId:_,authSessionId:v,authStatusMessage:y,hasChanges:b,isDeletePending:x,isUpdatePending:S,connectivity:C,startPending:w,importPending:T,onProviderDisplayNameChange:E,onApiKeyChange:D,onApiBaseChange:O,onAuthMethodChange:A,onStartProviderAuth:M,onImportProviderAuthFromCli:N,onModelDraftChange:P,onShowModelInputChange:F,onAddModel:I,onModelsChange:L,onRemoveModel:R,onToggleModelThinkingLevel:B,onSetModelThinkingDefault:V,onSetModelVision:H,onShowAdvancedChange:ee,onWireApiChange:U,onExtraHeadersChange:W,onDeleteProvider:G,onSubmit:K,onTestConnection:q}=e,J=n.providerAuthMethods.find(e=>e.id===_);return(0,$.jsxs)(ve,{children:[(0,$.jsx)(he,{className:`px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`truncate text-lg font-semibold text-foreground`,children:o}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:G,disabled:x,className:`text-muted-foreground/70 transition-colors hover:text-red-500`,title:j(`providerDelete`),children:(0,$.jsx)(k,{className:`h-4 w-4`})}),(0,$.jsx)(dt,{enabled:n.currentEnabled,apiKeyRequired:n.resolvedProviderConfig.apiKeyRequired,apiKeySet:n.resolvedProviderConfig.apiKeySet})]})]})}),(0,$.jsxs)(`form`,{onSubmit:K,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(ye,{className:`space-y-4 px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-foreground`,children:j(`providerDisplayName`)}),(0,$.jsx)(t,{id:`providerDisplayName`,type:`text`,value:s,onChange:e=>E(e.target.value),placeholder:n.defaultDisplayName||j(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerDisplayNameHelpShort`)})]}),(0,$.jsx)(nt,{apiKey:c,apiKeyRequired:n.resolvedProviderConfig.apiKeyRequired!==!1,apiKeySet:n.resolvedProviderConfig.apiKeySet,apiKeyPlaceholder:n.apiKeyHint?.placeholder??j(`enterApiKey`),providerAuth:n.providerAuth,providerAuthNote:n.providerAuth?.note?.[i]||n.providerAuth?.note?.en||n.providerAuth?.displayName||``,providerAuthMethodOptions:n.providerAuthMethodOptions,providerAuthMethodsCount:n.providerAuthMethods.length,selectedAuthMethodHint:J?.hint?.[i]||J?.hint?.en||``,shouldUseAuthMethodPills:n.shouldUseAuthMethodPills,resolvedAuthMethodId:_,onAuthMethodChange:A,onStartProviderAuth:M,onImportProviderAuthFromCli:N,startPending:w,importPending:T,authSessionId:v,authStatusMessage:y,onApiKeyChange:D}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`apiBase`,className:`text-sm font-medium text-foreground`,children:j(`apiBase`)}),(0,$.jsx)(t,{id:`apiBase`,type:`text`,value:l,onChange:e=>O(e.target.value),placeholder:n.defaultApiBase||n.apiBaseHint?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.apiBaseHelpText})]}),(0,$.jsx)(ut,{providerName:n.providerConfig?.providerId??``,providerModelAliases:n.providerModelAliases,models:f,modelConfig:p,modelDraft:m,showModelInput:g,onModelDraftChange:P,onShowModelInputChange:F,onAddModel:I,onModelsChange:L,supportsModelDiscovery:n.supportsModelDiscovery,onDiscoverModels:C.discoverModels,isDiscoveringModels:C.isDiscoveringModels,fetchedModels:C.fetchedModels,onRemoveModel:R,onToggleModelThinkingLevel:B,onSetModelThinkingDefault:V,onSetModelVision:H,thinkingLevels:z,formatThinkingLevelLabel:Le},n.providerConfig?.providerId),(0,$.jsx)(et,{showAdvanced:h,onShowAdvancedChange:ee,supportsWireApi:n.supportsWireApi,wireApiLabel:j(`wireApi`),wireApi:d,onWireApiChange:U,shouldUseWireApiPills:n.shouldUseWireApiPills,wireApiSelectOptions:n.wireApiSelectOptions,extraHeadersLabel:j(`extraHeaders`),extraHeaders:u,onExtraHeadersChange:W})]}),(0,$.jsx)(xe,{children:(0,$.jsxs)(fe,{align:`between`,children:[(0,$.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:q,disabled:C.isTestPending,children:[(0,$.jsx)(Se,{className:`mr-1.5 h-3.5 w-3.5`}),C.isTestPending?j(`providerTestingConnection`):j(`providerTestConnection`)]}),(0,$.jsx)(a,{type:`submit`,size:`sm`,disabled:S||!b,children:j(S?`saving`:b?`save`:`unchanged`)})]})})]})]})}function pt({providerName:e,onProviderDeleted:t}){let{data:n}=le(),{data:r}=re(),{data:i}=ue(),a=A(),o=(0,Y.useMemo)(()=>Ye({providerName:e,providersView:n,templatesView:r,schema:i,language:a}),[a,e,n,i,r]);if(!e||!o.providerConfig)return(0,$.jsx)(be,{children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:j(`providersSelectTitle`)}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:j(`providersSelectDescription`)})]})});let s=JSON.stringify({providerConfig:o.providerConfig,currentApiBase:o.currentApiBase,currentEditableModels:o.currentEditableModels,currentModelConfig:o.currentModelConfig,currentWireApi:o.currentWireApi,effectiveDisplayName:o.effectiveDisplayName,preferredAuthMethodId:o.preferredAuthMethodId});return(0,$.jsx)(mt,{providerName:e,onProviderDeleted:t,context:o,language:a},s)}function mt({providerName:e,onProviderDeleted:t,context:n,language:r}){let i=de(),a=J(),{currentApiBase:o,currentEditableModels:s,currentHeaders:c,currentModelConfig:l,currentWireApi:u,defaultApiBase:d,effectiveDisplayName:f,providerAuth:p,providerAuthMethods:m,providerModelAliases:h,resolvedProviderConfig:g,preferredAuthMethodId:_,supportsWireApi:v}=n,[y,b]=(0,Y.useState)(``),[x,S]=(0,Y.useState)(o),[C,w]=(0,Y.useState)(g.extraHeaders||null),[T,E]=(0,Y.useState)(u),[D,O]=(0,Y.useState)(s),[k,A]=(0,Y.useState)(l),[M,N]=(0,Y.useState)(``),[P,F]=(0,Y.useState)(f),[I,L]=(0,Y.useState)(!1),[R,z]=(0,Y.useState)(!1),[B,V]=(0,Y.useState)(_),H=Ze({providerName:e,apiKey:y,apiKeyRequired:g.apiKeyRequired!==!1,apiKeySet:g.apiKeySet,apiBase:x,extraHeaders:C,supportsWireApi:v,wireApi:T,models:D,providerModelAliases:h}),ee=P.trim()||f||e||j(`providersSelectPlaceholder`),U=(0,Y.useMemo)(()=>{if(!m.length)return``;let e=B.trim();return e&&m.some(t=>t.id===e)?e:_||m[0]?.id||``},[B,_,m]),{authSessionId:W,authStatusMessage:G,importAuthFromCli:K,importPending:q,startAuth:te,startPending:ne}=Xe({providerName:e,providerAuth:p,resolvedAuthMethodId:U}),re=(0,Y.useMemo)(()=>Ne({providerName:e,apiKey:y,apiBase:x,currentApiBase:o,extraHeaders:C,currentHeaders:c,supportsWireApi:v,wireApi:T,currentWireApi:u,models:D,currentEditableModels:s,modelConfig:k,currentModelConfig:l,providerDisplayName:P,effectiveDisplayName:f}),[e,y,x,o,C,c,v,T,u,D,s,k,l,P,f]),ie=e=>{O(e),A(t=>Ae(t,e))};return(0,$.jsx)(ft,{context:n,language:r,providerTitle:ee,providerDisplayName:P,apiKey:y,apiBase:x,extraHeaders:C,wireApi:T,models:D,modelConfig:k,modelDraft:M,showAdvanced:I,showModelInput:R,resolvedAuthMethodId:U,authSessionId:W,authStatusMessage:G,hasChanges:re,isDeletePending:a.isPending,isUpdatePending:i.isPending,connectivity:H,startPending:ne,importPending:q,onProviderDisplayNameChange:F,onApiKeyChange:b,onApiBaseChange:S,onAuthMethodChange:V,onStartProviderAuth:te,onImportProviderAuthFromCli:K,onModelDraftChange:N,onShowModelInputChange:z,onAddModel:()=>{let e=Be(D,M,h);ie(e.models),N(e.draft)},onModelsChange:ie,onRemoveModel:e=>{let t=Ue(D,k,e);O(t.models),A(t.modelConfig)},onToggleModelThinkingLevel:(e,t)=>{A(n=>We(n,e,t))},onSetModelThinkingDefault:(e,t)=>{A(n=>Ge(n,e,t))},onSetModelVision:(e,t)=>{A(n=>Ke(n,e,t))},onShowAdvancedChange:L,onWireApiChange:E,onExtraHeadersChange:w,onDeleteProvider:async()=>{if(e&&window.confirm(j(`providerDeleteConfirm`)))try{await a.mutateAsync({provider:e}),t?.(e)}catch{}},onSubmit:t=>{t.preventDefault(),e&&i.mutate({provider:e,data:Pe({providerName:e,apiKey:y,apiBase:x,currentApiBase:o,defaultApiBase:d,extraHeaders:C,currentHeaders:c,supportsWireApi:v,wireApi:T,currentWireApi:u,models:D,currentEditableModels:s,modelConfig:k,currentModelConfig:l,providerDisplayName:P,effectiveDisplayName:f})})},onTestConnection:H.testConnection})}function ht(e){if(!e)return null;try{let t=new URL(e);return`${t.host}${t.pathname&&t.pathname!==`/`?t.pathname:``}`}catch{return e.replace(/^https?:\/\//,``)}}function gt(e,t=[]){let n=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let r=n.get(e.provider.providerId),i=n.get(t.provider.providerId);if(r!==void 0||i!==void 0)return(r??2**53-1)-(i??2**53-1);let a=e.provider.providerType===`nextclaw`?1:0,o=t.provider.providerType===`nextclaw`?1:0;return a===o?e.index-t.index:a-o}).map(({provider:e})=>e)}function _t(e){let t=e.findIndex(e=>e.providerType===`zhipu`),n=e.findIndex(e=>e.providerType===`dashscope-coding-plan`);return e.map((e,t)=>({template:e,index:t})).sort((e,r)=>{let i=({template:e,index:r})=>e.providerType===`nextclaw`?2**53-1:e.providerType===`deepseek`&&n>=0?n-.5:e.providerType===`mimo`&&t>=0?t+.5:r;return i(e)-i(r)}).map(({template:e})=>e)}function vt(){let{isMobile:e}=T(),{data:r}=le(),{data:i}=re(),c=ae(),l=J(),u=de(),[d,f]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),[v,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)([]),[C,D]=(0,Y.useState)(``),O=(0,Y.useMemo)(()=>gt(Object.values(r?.providers??{}),x),[r?.providers,x]),A=(0,Y.useMemo)(()=>i?.providerTemplates??[],[i?.providerTemplates]),N=(0,Y.useMemo)(()=>_t(A),[A]),I=(0,Y.useMemo)(()=>new Map(A.map(e=>[e.providerType,e])),[A]),L=(0,Y.useMemo)(()=>{let e=C.trim().toLowerCase();return O.filter(t=>{if(!e)return!0;let n=t.providerType?I.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[O,C,I]),z=(0,Y.useMemo)(()=>d&&L.some(e=>e.providerId===d)?d:e?null:L[0]?.providerId??null,[L,e,d]);return!r||!i?(0,$.jsx)(o,{title:j(`providersPageTitle`),description:j(`providersPageDescription`),layout:`split`,children:(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:j(`providersLoading`)})}):(0,$.jsxs)(o,{title:j(`providersPageTitle`),description:j(`providersPageDescription`),layout:`split`,children:[(0,$.jsxs)(me,{className:`md:min-h-0`,compactView:d?`detail`:`list`,onMobileBack:()=>f(null),mobileListLabel:j(`providersPageTitle`),children:[(0,$.jsxs)(_e,{children:[(0,$.jsx)(he,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,$.jsxs)(R,{open:v,onOpenChange:b,children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsxs)(a,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:c.isPending,children:[(0,$.jsx)(E,{className:`mr-2 h-4 w-4`}),c.isPending?j(`saving`):j(`providerAdd`)]})}),(0,$.jsxs)(F,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,$.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-muted-foreground`,children:j(`providerTemplatePickerTitle`)}),(0,$.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-left transition-colors hover:border-border hover:bg-[var(--interaction-hover)]`,onClick:async()=>{try{let e=await c.mutateAsync({data:{providerType:null}});D(``),f(e.providerId),S(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),b(!1)}catch{}},children:[(0,$.jsx)(B,{name:`custom`,className:`h-8 w-8 rounded-lg border border-border/60 bg-muted/50`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:j(`providerAddCustom`)})]}),N.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-border/55 bg-muted/15 px-3 py-2 text-left transition-colors hover:border-border/80 hover:bg-[var(--interaction-hover)]`,onClick:async()=>{try{let t=await c.mutateAsync({data:{providerType:e.providerType}});D(``),f(t.providerId),S(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),b(!1)}catch{}},children:[(0,$.jsx)(B,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-border/55 bg-background`,imgClassName:`h-4 w-4 object-contain`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:e.displayName||e.providerType})]},e.providerType))]})]})]})}),(0,$.jsx)(`div`,{className:`border-b border-border/70 px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(y,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/70`}),(0,$.jsx)(t,{value:C,onChange:e=>D(e.target.value),placeholder:j(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,$.jsxs)(ye,{className:`space-y-2 p-3`,children:[L.map(e=>{let t=e.providerType?I.get(e.providerType):null,r=e.enabled!==!1,i=M(e),a=e.displayName?.trim()||t?.displayName||e.providerId,o=ht(e.apiBase||t?.defaultApiBase||``)||j(`providersDefaultDescription`);return(0,$.jsx)(`div`,{onClick:()=>f(e.providerId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),f(e.providerId))},role:`button`,tabIndex:0,className:s(`group w-full rounded-xl p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,z===e.providerId?`bg-[var(--interaction-selection)] text-foreground`:`bg-transparent text-muted-foreground hover:bg-[var(--interaction-hover)] hover:text-foreground`),children:(0,$.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,$.jsx)(B,{name:e.providerType??e.providerId,src:t?.logo?`/logos/${t.logo}`:null,className:`h-10 w-10 rounded-lg bg-background/80`,imgClassName:`h-5 w-5 object-contain`,fallback:(0,$.jsx)(`span`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:e.providerId[0]})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:a}),(0,$.jsx)(`p`,{className:`truncate font-mono text-[10px] text-muted-foreground/65`,children:e.providerId}),(0,$.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-muted-foreground`,children:[o,` · `,e.models?.length??0]})]})]}),(0,$.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5 opacity-70 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(n,{checked:r,disabled:u.isPending,title:j(r?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:t=>{u.mutateAsync({provider:e.providerId,data:{enabled:t},silentSuccess:!0})}})}),(0,$.jsxs)(R,{children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/70 hover:bg-[var(--interaction-hover)] hover:text-foreground`,onClick:e=>e.stopPropagation(),title:j(`more`),children:(0,$.jsx)(h,{className:`h-4 w-4`})})}),(0,$.jsx)(F,{variant:`menu`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(`button`,{type:`button`,className:`${p} ${m.destructive}`,onClick:()=>_(e.providerId),children:[(0,$.jsx)(k,{className:`h-4 w-4`}),j(`providerDelete`)]})})]})]}),(0,$.jsx)(V,{status:r?i?`ready`:`setup`:`inactive`,label:j(r?i?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},e.providerId)}),L.length===0?(0,$.jsx)(ge,{icon:w,title:j(`providersNoMatch`)}):null]})]}),(0,$.jsx)(pt,{providerName:z??void 0,onProviderDeleted:e=>{S(t=>t.filter(t=>t!==e)),e===z&&f(null)}})]}),(0,$.jsx)(H,{open:!!g,onOpenChange:e=>{e||_(null)},title:j(`providerDelete`),description:g??void 0,confirmLabel:j(`delete`),variant:`destructive`,onCancel:()=>_(null),onConfirm:()=>{g&&l.mutateAsync({provider:g}).then(()=>{S(e=>e.filter(e=>e!==g)),g===z&&f(null),_(null)})}})]})}export{vt as ProvidersConfigPage};
@@ -1 +1 @@
1
- import{t as e}from"./createLucideIcon-reFMl-W-.js";var t=e(`Activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),n=e(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]);export{t as n,n as t};
1
+ import{t as e}from"./createLucideIcon-D-7Sxfw7.js";var t=e(`Activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),n=e(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]);export{t as n,n as t};
@@ -1 +1 @@
1
- import{D as e,O as t,T as n}from"./theme-provider-BToFZGZG.js";import{Jt as r,Xn as i,Yt as a,_n as o,fn as s,qt as c,ur as l}from"./api-CI6_8Qt1.js";import{t as u}from"./createLucideIcon-reFMl-W-.js";import{t as d}from"./download-DovI3Yvf.js";import{t as f}from"./x-E9VB4HQx.js";import{s as p}from"./i18n-IGQbjBqS.js";var m={"paper-ink":`#FAF8F4`,"plain-paper":`#FAF8F4`,natural:`#FAF9F7`,work:`#FFFFFF`,minimal:`#FFFFFF`,warm:`#FAF8F4`,cool:`#F8FAFC`,dawn:`#FAF7F4`,graphite:`#F8F8F7`,night:`#101318`,charcoal:`#1C1C1C`,island:`#FBF8ED`,probe:`#FEFCF6`},h=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let r=m[t(e)];this.updateThemeMeta(r),this.updateSurfaceBackgrounds(r);let i=n(e);document.documentElement.style.colorScheme=i,document.querySelector(`meta[name="color-scheme"]`)?.setAttribute(`content`,i)},this.syncCurrentTheme=()=>{if(typeof document>`u`)return;let t=document.documentElement.getAttribute(`data-theme`);this.syncTheme(e(t)??`default`)},this.updateThemeMeta=e=>{let t=document.querySelector(`meta[name="theme-color"]`);t instanceof HTMLMetaElement&&(t.content=e)},this.updateSurfaceBackgrounds=e=>{document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e;let t=document.getElementById(`root`);t&&(t.style.backgroundColor=e)}}},g=u(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),_=`nextclaw-pwa-install-banner-dismissed`,v=`nextclaw-pwa-install-banner-dismissed-until`;function y(){let e=S();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:C(e):!1}function b(){let e=S();e?.setItem(_,`1`),e?.removeItem(v)}function x(){let e=S();e?.removeItem(_),e?.removeItem(v)}function S(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function C(e){let t=e.getItem(v);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(v),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(_,`1`),!0)}function w(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:y()}}var T=s(()=>w()),E=new class{constructor(){this.started=!1,this.deferredPrompt=null,this.displayModeMediaQuery=null,this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.addEventListener(`appinstalled`,this.handleAppInstalled),typeof window.matchMedia==`function`&&(this.displayModeMediaQuery=window.matchMedia(`(display-mode: standalone)`),this.bindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged)),this.refreshState())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.removeEventListener(`appinstalled`,this.handleAppInstalled),this.displayModeMediaQuery&&=(this.unbindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged),null),this.deferredPrompt=null,this.started=!1)},this.resetForTests=()=>{this.stop(),T.setState(w())},this.refreshState=()=>{let e=this.resolveInstallability();T.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:y()}))},this.dismissInstallPrompt=()=>{b(),T.setState({dismissedInstallPrompt:!0})},this.promptInstall=async()=>{let e=this.resolveInstallability();if(e.installability!==`available`)return`unavailable`;if(e.installMethod===`manual`||!this.deferredPrompt)return`manual`;this.deferredPrompt.prompt();let t=await this.deferredPrompt.userChoice;return this.deferredPrompt=null,t.outcome===`accepted`?(x(),this.refreshState(),i.success(p(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,x(),T.setState({dismissedInstallPrompt:!0}),i.success(p(`pwaInstalledToast`)),this.refreshState()},this.handleDisplayModeChanged=()=>{this.refreshState()},this.resolveInstallability=()=>this.isDevelopmentServer()?{installability:`unsupported`,installMethod:`none`,blockedReason:`dev-server`}:this.hasDesktopHost()?{installability:`suppressed`,installMethod:`none`,blockedReason:`desktop-host`}:this.isStandalone()?{installability:`installed`,installMethod:`none`,blockedReason:null}:this.hasInstallSurfaceSupport()?this.isEligibleInstallContext()?{installability:`available`,installMethod:this.deferredPrompt?`prompt`:`manual`,blockedReason:null}:{installability:`unsupported`,installMethod:`none`,blockedReason:`insecure-context`}:{installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`},this.hasDesktopHost=()=>typeof window<`u`&&!!window.nextclawDesktop,this.hasInstallSurfaceSupport=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&`serviceWorker`in navigator,this.isEligibleInstallContext=()=>typeof window>`u`?!1:window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>typeof window<`u`&&!1,this.isStandalone=()=>{if(typeof window>`u`)return!1;let e=window.navigator;return typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||e.standalone===!0},this.bindDisplayModeListener=(e,t)=>{if(`addEventListener`in e){e.addEventListener(`change`,t);return}e.addListener?.(t)},this.unbindDisplayModeListener=(e,t)=>{if(`removeEventListener`in e){e.removeEventListener(`change`,t);return}e.removeListener?.(t)}}},D=l();function O(){let e=T(e=>e.installability);return(0,D.jsx)(`span`,{className:o(`inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium`,e===`installed`?`bg-emerald-50 text-emerald-700 border-emerald-200`:e===`available`?`bg-amber-50 text-amber-700 border-amber-200`:`bg-gray-100 text-gray-600 border-gray-200`),children:k(e)})}function k(e){return p(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function A(e,t,n){return p(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&t===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:n===`insecure-context`?`pwaInstallCardInsecureContext`:n===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function j(){let e=T(e=>e.installability),t=T(e=>e.installMethod),n=T(e=>e.blockedReason);return(0,D.jsx)(r,{title:p(`pwaInstallTitle`),description:p(`pwaInstallDescription`),actions:(0,D.jsx)(O,{}),children:(0,D.jsx)(c,{children:(0,D.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,D.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:A(e,t,n)}),e===`available`&&t===`prompt`?(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,D.jsxs)(a,{type:`button`,className:`gap-2`,onClick:()=>void E.promptInstall(),children:[(0,D.jsx)(d,{className:`h-4 w-4`}),p(`pwaInstallAction`)]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p(`pwaInstallPromptHint`)})]}):null,e===`available`&&t===`manual`?(0,D.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-background/65 p-4`,children:[(0,D.jsx)(g,{className:`mt-0.5 h-4 w-4 text-muted-foreground`}),(0,D.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:p(`pwaInstallManualHint`)})]}):null]})})})}function M(){let e=T(e=>e.installability),t=T(e=>e.installMethod),n=T(e=>e.dismissedInstallPrompt);return e!==`available`||t!==`prompt`||n?null:(0,D.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:p(`pwaInstallBannerTitle`)}),(0,D.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:p(`pwaInstallBannerDescription`)})]}),(0,D.jsx)(`button`,{type:`button`,"aria-label":p(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-[var(--interaction-hover)] hover:text-gray-600`,onClick:()=>{E.dismissInstallPrompt()},children:(0,D.jsx)(f,{className:`h-4 w-4`})})]}),(0,D.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,D.jsxs)(a,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{E.promptInstall()},children:[(0,D.jsx)(d,{className:`h-4 w-4`}),p(`pwaInstallAction`)]}),(0,D.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{E.dismissInstallPrompt()},children:p(`pwaInstallDismiss`)})]})]})}var N=new class{constructor(){this.started=!1,this.registration=null,this.start=async()=>{if(!(this.started||typeof window>`u`)&&(this.started=!0,!(!(`serviceWorker`in navigator)||!this.isEligibleInstallContext()))){if(this.isDevelopmentServer()){await this.cleanupDevelopmentRegistrations();return}try{this.registration=await navigator.serviceWorker.register(`/sw.js`)}catch{return}}},this.stop=()=>{!this.started||typeof window>`u`||!(`serviceWorker`in navigator)||(this.started=!1,this.registration=null)},this.isEligibleInstallContext=()=>window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>!1,this.cleanupDevelopmentRegistrations=async()=>{if(typeof navigator.serviceWorker.getRegistrations!=`function`)return;let e=(await navigator.serviceWorker.getRegistrations()).filter(e=>[e.active?.scriptURL,e.installing?.scriptURL,e.waiting?.scriptURL].filter(e=>!!e).some(e=>e.endsWith(`/sw.js`)));await Promise.all(e.map(async e=>await e.unregister())),e.length>0&&await this.clearNextClawCaches()},this.clearNextClawCaches=async()=>{if(typeof window>`u`||!(`caches`in window)||typeof caches.keys!=`function`)return;let e=await caches.keys();await Promise.all(e.filter(e=>e.startsWith(`nextclaw-ui-`)).map(async e=>await caches.delete(e)))}}},P=!1;function F(){P||typeof window>`u`||(P=!0,E.start(),N.start())}export{h as i,M as n,j as r,F as t};
1
+ import{D as e,O as t,T as n}from"./theme-provider-DDJOlUxn.js";import{Jt as r,Xn as i,Yt as a,_n as o,fn as s,qt as c,ur as l}from"./api-BaML_txv.js";import{t as u}from"./createLucideIcon-D-7Sxfw7.js";import{t as d}from"./download-BN4aCzSx.js";import{t as f}from"./x-DLvS4xvV.js";import{s as p}from"./i18n-Bzo4IocH.js";var m={"paper-ink":`#FAF8F4`,"plain-paper":`#FAF8F4`,natural:`#FAF9F7`,work:`#FFFFFF`,minimal:`#FFFFFF`,warm:`#FAF8F4`,cool:`#F8FAFC`,dawn:`#FAF7F4`,graphite:`#F8F8F7`,night:`#101318`,charcoal:`#1C1C1C`,island:`#FBF8ED`,probe:`#FEFCF6`},h=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let r=m[t(e)];this.updateThemeMeta(r),this.updateSurfaceBackgrounds(r);let i=n(e);document.documentElement.style.colorScheme=i,document.querySelector(`meta[name="color-scheme"]`)?.setAttribute(`content`,i)},this.syncCurrentTheme=()=>{if(typeof document>`u`)return;let t=document.documentElement.getAttribute(`data-theme`);this.syncTheme(e(t)??`default`)},this.updateThemeMeta=e=>{let t=document.querySelector(`meta[name="theme-color"]`);t instanceof HTMLMetaElement&&(t.content=e)},this.updateSurfaceBackgrounds=e=>{document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e;let t=document.getElementById(`root`);t&&(t.style.backgroundColor=e)}}},g=u(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),_=`nextclaw-pwa-install-banner-dismissed`,v=`nextclaw-pwa-install-banner-dismissed-until`;function y(){let e=S();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:C(e):!1}function b(){let e=S();e?.setItem(_,`1`),e?.removeItem(v)}function x(){let e=S();e?.removeItem(_),e?.removeItem(v)}function S(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function C(e){let t=e.getItem(v);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(v),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(_,`1`),!0)}function w(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:y()}}var T=s(()=>w()),E=new class{constructor(){this.started=!1,this.deferredPrompt=null,this.displayModeMediaQuery=null,this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.addEventListener(`appinstalled`,this.handleAppInstalled),typeof window.matchMedia==`function`&&(this.displayModeMediaQuery=window.matchMedia(`(display-mode: standalone)`),this.bindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged)),this.refreshState())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.removeEventListener(`appinstalled`,this.handleAppInstalled),this.displayModeMediaQuery&&=(this.unbindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged),null),this.deferredPrompt=null,this.started=!1)},this.resetForTests=()=>{this.stop(),T.setState(w())},this.refreshState=()=>{let e=this.resolveInstallability();T.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:y()}))},this.dismissInstallPrompt=()=>{b(),T.setState({dismissedInstallPrompt:!0})},this.promptInstall=async()=>{let e=this.resolveInstallability();if(e.installability!==`available`)return`unavailable`;if(e.installMethod===`manual`||!this.deferredPrompt)return`manual`;this.deferredPrompt.prompt();let t=await this.deferredPrompt.userChoice;return this.deferredPrompt=null,t.outcome===`accepted`?(x(),this.refreshState(),i.success(p(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,x(),T.setState({dismissedInstallPrompt:!0}),i.success(p(`pwaInstalledToast`)),this.refreshState()},this.handleDisplayModeChanged=()=>{this.refreshState()},this.resolveInstallability=()=>this.isDevelopmentServer()?{installability:`unsupported`,installMethod:`none`,blockedReason:`dev-server`}:this.hasDesktopHost()?{installability:`suppressed`,installMethod:`none`,blockedReason:`desktop-host`}:this.isStandalone()?{installability:`installed`,installMethod:`none`,blockedReason:null}:this.hasInstallSurfaceSupport()?this.isEligibleInstallContext()?{installability:`available`,installMethod:this.deferredPrompt?`prompt`:`manual`,blockedReason:null}:{installability:`unsupported`,installMethod:`none`,blockedReason:`insecure-context`}:{installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`},this.hasDesktopHost=()=>typeof window<`u`&&!!window.nextclawDesktop,this.hasInstallSurfaceSupport=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&`serviceWorker`in navigator,this.isEligibleInstallContext=()=>typeof window>`u`?!1:window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>typeof window<`u`&&!1,this.isStandalone=()=>{if(typeof window>`u`)return!1;let e=window.navigator;return typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||e.standalone===!0},this.bindDisplayModeListener=(e,t)=>{if(`addEventListener`in e){e.addEventListener(`change`,t);return}e.addListener?.(t)},this.unbindDisplayModeListener=(e,t)=>{if(`removeEventListener`in e){e.removeEventListener(`change`,t);return}e.removeListener?.(t)}}},D=l();function O(){let e=T(e=>e.installability);return(0,D.jsx)(`span`,{className:o(`inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium`,e===`installed`?`bg-emerald-50 text-emerald-700 border-emerald-200`:e===`available`?`bg-amber-50 text-amber-700 border-amber-200`:`bg-gray-100 text-gray-600 border-gray-200`),children:k(e)})}function k(e){return p(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function A(e,t,n){return p(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&t===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:n===`insecure-context`?`pwaInstallCardInsecureContext`:n===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function j(){let e=T(e=>e.installability),t=T(e=>e.installMethod),n=T(e=>e.blockedReason);return(0,D.jsx)(r,{title:p(`pwaInstallTitle`),description:p(`pwaInstallDescription`),actions:(0,D.jsx)(O,{}),children:(0,D.jsx)(c,{children:(0,D.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,D.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:A(e,t,n)}),e===`available`&&t===`prompt`?(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,D.jsxs)(a,{type:`button`,className:`gap-2`,onClick:()=>void E.promptInstall(),children:[(0,D.jsx)(d,{className:`h-4 w-4`}),p(`pwaInstallAction`)]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p(`pwaInstallPromptHint`)})]}):null,e===`available`&&t===`manual`?(0,D.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-background/65 p-4`,children:[(0,D.jsx)(g,{className:`mt-0.5 h-4 w-4 text-muted-foreground`}),(0,D.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:p(`pwaInstallManualHint`)})]}):null]})})})}function M(){let e=T(e=>e.installability),t=T(e=>e.installMethod),n=T(e=>e.dismissedInstallPrompt);return e!==`available`||t!==`prompt`||n?null:(0,D.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:p(`pwaInstallBannerTitle`)}),(0,D.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:p(`pwaInstallBannerDescription`)})]}),(0,D.jsx)(`button`,{type:`button`,"aria-label":p(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-[var(--interaction-hover)] hover:text-gray-600`,onClick:()=>{E.dismissInstallPrompt()},children:(0,D.jsx)(f,{className:`h-4 w-4`})})]}),(0,D.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,D.jsxs)(a,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{E.promptInstall()},children:[(0,D.jsx)(d,{className:`h-4 w-4`}),p(`pwaInstallAction`)]}),(0,D.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{E.dismissInstallPrompt()},children:p(`pwaInstallDismiss`)})]})]})}var N=new class{constructor(){this.started=!1,this.registration=null,this.start=async()=>{if(!(this.started||typeof window>`u`)&&(this.started=!0,!(!(`serviceWorker`in navigator)||!this.isEligibleInstallContext()))){if(this.isDevelopmentServer()){await this.cleanupDevelopmentRegistrations();return}try{this.registration=await navigator.serviceWorker.register(`/sw.js`)}catch{return}}},this.stop=()=>{!this.started||typeof window>`u`||!(`serviceWorker`in navigator)||(this.started=!1,this.registration=null)},this.isEligibleInstallContext=()=>window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>!1,this.cleanupDevelopmentRegistrations=async()=>{if(typeof navigator.serviceWorker.getRegistrations!=`function`)return;let e=(await navigator.serviceWorker.getRegistrations()).filter(e=>[e.active?.scriptURL,e.installing?.scriptURL,e.waiting?.scriptURL].filter(e=>!!e).some(e=>e.endsWith(`/sw.js`)));await Promise.all(e.map(async e=>await e.unregister())),e.length>0&&await this.clearNextClawCaches()},this.clearNextClawCaches=async()=>{if(typeof window>`u`||!(`caches`in window)||typeof caches.keys!=`function`)return;let e=await caches.keys();await Promise.all(e.filter(e=>e.startsWith(`nextclaw-ui-`)).map(async e=>await caches.delete(e)))}}},P=!1;function F(){P||typeof window>`u`||(P=!0,E.start(),N.start())}export{h as i,M as n,j as r,F as t};
@@ -1 +1 @@
1
- import{t as e}from"./createLucideIcon-reFMl-W-.js";var t=e(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]);export{t};
1
+ import{t as e}from"./createLucideIcon-D-7Sxfw7.js";var t=e(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{F as e}from"./app-presenter-provider-DSlY9Lz6.js";export{e as RemoteAccessPage};
@@ -1 +1 @@
1
- import{t as e}from"./createLucideIcon-reFMl-W-.js";var t=e(`RotateCw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]);export{t};
1
+ import{t as e}from"./createLucideIcon-D-7Sxfw7.js";var t=e(`RotateCw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]);export{t};
@@ -1 +1 @@
1
- import{i as e}from"./chunk-DF37yw5_.js";import{r as t}from"./pwa-CAg_9zFs.js";import{Gt as n,Jt as r,Kt as i,Ut as a,Xn as o,Yt as s,Zt as c,dn as l,ln as u,pn as d,qt as f,sn as p,ur as m,xr as h}from"./api-CI6_8Qt1.js";import{L as g,R as _,Zt as v,pt as y}from"./app-presenter-provider-2DwHRRle.js";import{X as b}from"./context-menu-dGVv8klA.js";import{i as x}from"./x-E9VB4HQx.js";import{t as S}from"./plus-DUdl68Eo.js";import{t as C}from"./rotate-cw-aBponvp7.js";import{t as w}from"./save-394QCMXn.js";import{t as T}from"./trash-2-DvJ6duOW.js";import{s as E}from"./i18n-IGQbjBqS.js";import{a as D,i as O,n as k,r as A,t as j}from"./select-xUXYV0Gr.js";import{b as M,t as ee}from"./use-config-COusaY5p.js";import{t as te}from"./form-actions-B8VniHts.js";var N=e(h(),1),P=m(),F={healthy:`runtimeControlHealthy`,"starting-service":`runtimeControlStartingService`,"restarting-service":`runtimeControlRestartingService`,"stopping-service":`runtimeControlStoppingService`,"restarting-app":`runtimeControlRestartingApp`,recovering:`runtimeControlRecovering`,failed:`runtimeControlFailed`},I={running:`runtimeControlServiceRunning`,stopped:`runtimeControlServiceStopped`,starting:`runtimeControlServiceStarting`,stopping:`runtimeControlServiceStopping`,restarting:`runtimeControlServiceRestarting`},L={"desktop-embedded":`runtimeControlEnvironmentDesktop`,"managed-local-service":`runtimeControlEnvironmentManagedService`,"self-hosted-web":`runtimeControlEnvironmentSelfHosted`,"shared-web":`runtimeControlEnvironmentSharedWeb`};function R(e){return E(F[e]??`runtimeControlUnavailable`)}function z(e){return E(I[e]??`runtimeControlServiceUnknown`)}function B(e){return E(L[e.environment])}function V(e,t){return t===`start-service`?e?.canStartService:t===`stop-service`?e?.canStopService:e?.canRestartService}function H(e){return e?[{action:`start-service`,capability:e.canStartService,label:E(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:E(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:E(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:E(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function U(e){let{busy:t,icon:n}=e;return t?(0,P.jsx)(x,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,P.jsx)(b,{className:`mr-2 h-4 w-4`}):n===`square`?(0,P.jsx)(v,{className:`mr-2 h-4 w-4`}):(0,P.jsx)(C,{className:`mr-2 h-4 w-4`})}function W(){let{busy:e,busyAction:t,controlView:n,errorMessage:i,pendingRestart:a,visibleLifecycle:c,visibleMessage:u,visibleServiceState:m}=p(),h=H(n??void 0),g=async e=>{let t=V(n,e);if(!t?.available){o.error(d(t?.reasonIfUnavailable)??E(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(E(`runtimeControlStopServiceConfirm`))))try{let t=await l.runRuntimeControlAction(e);o.success(d(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:E(`runtimeControlActionFailed`);o.error(`${E(`runtimeControlActionFailed`)}: ${t}`)}},_=async()=>{if(!n?.canRestartApp.available){o.error(d(n?.canRestartApp.reasonIfUnavailable)??E(`runtimeRestartAppUnavailable`));return}if(window.confirm(E(`runtimeControlRestartAppConfirm`)))try{let e=await l.runRuntimeControlAction(`restart-app`);o.success(d(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:E(`runtimeControlActionFailed`);o.error(`${E(`runtimeControlActionFailed`)}: ${t}`)}};return(0,P.jsx)(r,{title:E(`runtimeControlTitle`),description:E(`runtimeControlDescription`),children:(0,P.jsxs)(f,{children:[(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:z(m)}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n?B(n):E(`runtimeControlLoading`)})]}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:R(c)}),n?.managementHint?(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d(n.managementHint)}):null,i&&!e?(0,P.jsx)(`p`,{className:`text-sm text-amber-700`,children:i}):null]}),a?(0,P.jsxs)(`div`,{className:`space-y-3 bg-amber-50/75 p-4 dark:bg-amber-950/20`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:E(`runtimeControlPendingRestartTitle`)}),(0,P.jsx)(`p`,{className:`text-sm text-amber-800`,children:E(`runtimeControlPendingRestartDescription`)}),a.changedPaths.length>0?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:E(`runtimeControlPendingRestartPaths`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.changedPaths.map(e=>(0,P.jsx)(`span`,{className:`rounded-full bg-background/80 px-2.5 py-1 text-xs text-amber-800 dark:text-amber-300`,children:e},e))})]}):null]}):null,(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:h.map(n=>(0,P.jsxs)(s,{type:`button`,variant:n.variant??`default`,onClick:()=>{if(n.action===`restart-app`){_();return}g(n.action)},disabled:!n.capability.available||e,children:[(0,P.jsx)(U,{icon:n.icon,busy:t===n.action}),n.label]},n.action))}),h.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d(e.capability.reasonIfUnavailable)},`${e.action}-reason`))]})]})})}function G(e){let{description:t,title:n}=e;return(0,P.jsx)(y,{tone:`neutral`,title:n,description:t})}function K(e){let{children:t}=e;return(0,P.jsx)(r,{title:E(`runtimePresenceTitle`),description:E(`runtimePresenceDescription`),children:(0,P.jsx)(f,{children:t})})}function q(){let e=u().runtimeControlView?.environment,t=_(e=>e.supported),n=_(e=>e.initialized),r=_(e=>e.busyAction),o=_(e=>e.snapshot);return(0,N.useEffect)(()=>{if(e===`desktop-embedded`){g.start();return}g.markUnsupported()},[e]),e===`desktop-embedded`?(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(y,{tone:`neutral`,title:E(`runtimePresenceBehaviorLabel`),description:o?.closeToBackground?E(`runtimePresenceBehaviorBackground`):E(`runtimePresenceBehaviorQuit`),className:`rounded-xl`})}),!n||t&&!o?(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:E(`runtimePresenceLoading`)}):null,o?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(i,{title:E(`runtimePresenceCloseToBackground`),description:E(`runtimePresenceCloseToBackgroundHelp`),control:(0,P.jsx)(a,{id:`runtime-presence-close-background`,"aria-label":E(`runtimePresenceCloseToBackground`),checked:o.closeToBackground,disabled:r===`saving-preferences`,onCheckedChange:e=>{g.updatePreferences({closeToBackground:e})}})}),(0,P.jsx)(i,{title:E(`runtimePresenceLaunchAtLogin`),description:o.supportsLaunchAtLogin?E(`runtimePresenceLaunchAtLoginHelp`):o.launchAtLoginReason??E(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,P.jsx)(a,{id:`runtime-presence-launch-login`,"aria-label":E(`runtimePresenceLaunchAtLogin`),checked:o.launchAtLogin,disabled:!o.supportsLaunchAtLogin||r===`saving-preferences`,onCheckedChange:e=>{g.updatePreferences({launchAtLogin:e})}})})]}):null]}):e===`managed-local-service`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:E(`runtimePresenceManagedLocalTitle`),description:E(`runtimePresenceManagedLocalDescription`)})})}):e===`self-hosted-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:E(`runtimePresenceSelfHostedTitle`),description:E(`runtimePresenceSelfHostedDescription`)})})}):e===`shared-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:E(`runtimePresenceSharedTitle`),description:E(`runtimePresenceSharedDescription`)})})}):(0,P.jsx)(K,{children:(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:E(`runtimePresenceLoading`)})})}function J(){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(W,{}),(0,P.jsx)(q,{}),(0,P.jsx)(t,{})]})}var Y={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function X(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0}}function Z(){return{agentId:``,match:{channel:``,accountId:``}}}function Q(){return{id:``,enabled:!0,label:``,type:`narp-stdio`,config:Y,configText:JSON.stringify(Y,null,2)}}function ne(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}}function re(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 ie(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ae(e){return{companionEnabled:e.companion?.enabled===!0,agents:(e.agents.list??[]).map(ne),bindings:(e.bindings??[]).map(re),runtimeEntries: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)})),dmScope:e.session?.dmScope??`per-channel-peer`,defaultContextTokens:e.agents.defaults.contextTokens??2e5,defaultEngine:e.agents.defaults.engine??`native`}}function oe(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)),t}function $(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(E(`agentIdRequiredError`).replace(`{index}`,String(t)));return oe(e)}),n=t.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0)throw Error(`${E(`duplicateAgentId`)}: ${n[0]}`);let r=e.bindings.map((t,n)=>{let r=t.agentId.trim(),i=t.match.channel.trim(),a=t.match.accountId?.trim()??``,o=t.match.peer?.kind,s=t.match.peer?.id?.trim()??``;if(!r)throw Error(E(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!e.knownAgentIds.has(r))throw Error(`${E(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${r}`);if(!i)throw Error(E(`bindingChannelRequired`).replace(`{index}`,String(n)));let c={agentId:r,match:{channel:i}};if(a&&(c.match.accountId=a),o){if(!s)throw Error(E(`bindingPeerIdRequired`).replace(`{index}`,String(n)));c.match.peer={kind:o,id:s}}return c}),i=e.runtimeEntries.reduce((e,t,n)=>{let r=t.id.trim(),i=t.type.trim();if(!r)throw Error(E(`runtimeEntryIdRequired`).replace(`{index}`,String(n)));if(!i)throw Error(E(`runtimeEntryTypeRequired`).replace(`{id}`,r));if(e[r])throw Error(`${E(`runtimeEntryDuplicate`)}: ${r}`);let a=t.configText.trim()?JSON.parse(t.configText):{};if(a&&(typeof a!=`object`||Array.isArray(a)))throw Error(E(`runtimeEntryConfigObjectRequired`).replace(`{id}`,r));return e[r]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:i,config:a??{}},e},{});return{companion:{enabled:e.companionEnabled},agents:{defaults:{contextTokens:Math.max(1e3,e.defaultContextTokens),engine:e.defaultEngine.trim()||`native`},list:t,runtimes:{entries:i}},bindings:r,session:{dmScope:e.dmScope}}}function se({agents:e,onAddAgent:t,onRemoveAgent:i,onSetDefaultAgent:o,onUpdateAgent:c}){return(0,P.jsx)(r,{title:E(`agentList`),description:E(`agentListHelp`),actions:(0,P.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(S,{className:`mr-2 h-4 w-4`}),E(`addAgent`)]}),children:(0,P.jsx)(f,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(n,{value:e.id,onChange:e=>c(t,{id:e.target.value}),placeholder:E(`agentIdPlaceholder`)}),(0,P.jsx)(n,{value:e.workspace??``,onChange:e=>c(t,{workspace:e.target.value}),placeholder:E(`workspaceOverridePlaceholder`)}),(0,P.jsx)(n,{value:e.model??``,onChange:e=>c(t,{model:e.target.value}),placeholder:E(`modelOverridePlaceholder`)}),(0,P.jsx)(n,{value:e.runtime??e.engine??``,onChange:e=>c(t,{runtime:e.target.value}),placeholder:E(`engineOverridePlaceholder`)}),(0,P.jsx)(n,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>c(t,{contextTokens:ie(e.target.value)}),placeholder:E(`contextTokensPlaceholder`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(a,{checked:!!e.default,onCheckedChange:e=>o(t,e)}),(0,P.jsx)(`span`,{children:E(`defaultAgent`)})]}),(0,P.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(t),children:[(0,P.jsx)(T,{className:`h-4 w-4 mr-1`}),E(`remove`)]})]})]},`${t}-${e.id}`))})})}function ce({bindings:e,onAddBinding:t,onRemoveBinding:i,onUpdateBinding:a}){return(0,P.jsx)(r,{title:E(`bindings`),description:E(`bindingsHelp`),actions:(0,P.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(S,{className:`mr-2 h-4 w-4`}),E(`addBinding`)]}),children:(0,P.jsx)(f,{children:e.map((e,t)=>{let r=e.match.peer?.kind??``;return(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,P.jsx)(n,{value:e.agentId,onChange:n=>a(t,{...e,agentId:n.target.value}),placeholder:E(`targetAgentIdPlaceholder`)}),(0,P.jsx)(n,{value:e.match.channel,onChange:n=>a(t,{...e,match:{...e.match,channel:n.target.value}}),placeholder:E(`channelPlaceholder`)}),(0,P.jsx)(n,{value:e.match.accountId??``,onChange:n=>a(t,{...e,match:{...e.match,accountId:n.target.value}}),placeholder:E(`accountIdOptionalPlaceholder`)}),(0,P.jsxs)(j,{value:r||`__none__`,onValueChange:n=>{let r=n===`__none__`?``:n;a(t,r?{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}}:{...e,match:{...e.match,peer:void 0}})},children:[(0,P.jsx)(O,{children:(0,P.jsx)(D,{})}),(0,P.jsxs)(k,{children:[(0,P.jsx)(A,{value:`__none__`,children:E(`peerKindOptional`)}),(0,P.jsx)(A,{value:`direct`,children:E(`peerKindDirect`)}),(0,P.jsx)(A,{value:`group`,children:E(`peerKindGroup`)}),(0,P.jsx)(A,{value:`channel`,children:E(`peerKindChannel`)})]})]}),(0,P.jsx)(n,{value:e.match.peer?.id??``,onChange:n=>a(t,{...e,match:{...e.match,peer:r?{kind:r,id:n.target.value}:void 0}}),placeholder:E(`peerIdPlaceholder`)})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(t),children:[(0,P.jsx)(T,{className:`h-4 w-4 mr-1`}),E(`remove`)]})})]},`${t}-${e.agentId}`)})})})}function le({entries:e,onAddEntry:t,onRemoveEntry:i,onUpdateEntry:o}){return(0,P.jsx)(r,{title:E(`runtimeEntries`),description:E(`runtimeEntriesHelp`),actions:(0,P.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(S,{className:`mr-2 h-4 w-4`}),E(`addRuntimeEntry`)]}),children:(0,P.jsx)(f,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(n,{value:e.id,onChange:e=>o(t,{id:e.target.value}),placeholder:E(`runtimeEntryIdPlaceholder`)}),(0,P.jsx)(n,{value:e.label??``,onChange:e=>o(t,{label:e.target.value}),placeholder:E(`runtimeEntryLabelPlaceholder`)}),(0,P.jsx)(n,{value:e.type,onChange:e=>o(t,{type:e.target.value}),placeholder:E(`runtimeEntryTypePlaceholder`)}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg bg-background/65 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:E(`enabled`)}),(0,P.jsx)(a,{checked:e.enabled!==!1,onCheckedChange:e=>o(t,{enabled:e})})]})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-foreground`,children:E(`runtimeEntryConfigJson`)}),(0,P.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm`,value:e.configText,onChange:e=>o(t,{configText:e.target.value}),spellCheck:!1})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(s,{type:`button`,variant:`outline`,onClick:()=>i(t),children:[(0,P.jsx)(T,{className:`mr-2 h-4 w-4`}),E(`delete`)]})})]},`${t}-${e.id||`runtime-entry`}`))})})}var ue=[{value:`main`,labelKey:`dmScopeMain`},{value:`per-peer`,labelKey:`dmScopePerPeer`},{value:`per-channel-peer`,labelKey:`dmScopePerChannelPeer`},{value:`per-account-channel-peer`,labelKey:`dmScopePerAccountChannelPeer`}];function de({companionEnabled:e,defaultContextTokens:t,defaultEngine:o,dmScope:s,onCompanionEnabledChange:c,onDefaultContextTokensChange:l,onDefaultEngineChange:u,onDmScopeChange:d}){return(0,P.jsx)(r,{title:E(`dmScope`),description:E(`dmScopeHelp`),children:(0,P.jsxs)(f,{children:[(0,P.jsx)(i,{title:E(`runtimeCompanionEnabled`),description:E(`runtimeCompanionEnabledHelp`),control:(0,P.jsx)(a,{checked:e,onCheckedChange:c})}),(0,P.jsx)(i,{title:E(`defaultContextTokens`),description:E(`defaultContextTokensHelp`),control:(0,P.jsx)(n,{type:`number`,min:1e3,step:1e3,value:t,onChange:e=>l(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3)),className:`w-36`})}),(0,P.jsx)(i,{title:E(`defaultEngine`),description:E(`defaultEngineHelp`),control:(0,P.jsx)(n,{value:o,onChange:e=>u(e.target.value),placeholder:E(`defaultEnginePlaceholder`),className:`w-56`})}),(0,P.jsx)(i,{title:E(`dmScope`),control:(0,P.jsxs)(j,{value:s,onValueChange:e=>d(e),children:[(0,P.jsx)(O,{className:`w-56`,children:(0,P.jsx)(D,{})}),(0,P.jsx)(k,{children:ue.map(e=>(0,P.jsx)(A,{value:e.value,children:E(e.labelKey)},e.value))})]})})]})})}function fe({config:e,updateRuntime:t}){let n=(0,N.useMemo)(()=>ae(e),[e]),[r,i]=(0,N.useState)(n.agents),[a,l]=(0,N.useState)(n.bindings),[u,d]=(0,N.useState)(n.runtimeEntries),[f,p]=(0,N.useState)(n.dmScope),[m,h]=(0,N.useState)(n.companionEnabled),[g,_]=(0,N.useState)(n.defaultContextTokens),[v,y]=(0,N.useState)(n.defaultEngine),b=(0,N.useMemo)(()=>{let e=new Set([`main`]);return r.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[r]);return(0,P.jsxs)(c,{title:E(`runtimePageTitle`),description:E(`runtimePageDescription`),children:[(0,P.jsx)(J,{}),(0,P.jsx)(de,{companionEnabled:m,dmScope:f,defaultContextTokens:g,defaultEngine:v,onCompanionEnabledChange:h,onDmScopeChange:p,onDefaultContextTokensChange:_,onDefaultEngineChange:y}),(0,P.jsx)(le,{entries:u,onUpdateEntry:(e,t)=>d(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>d(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>d(e=>[...e,Q()])}),(0,P.jsx)(se,{agents:r,onUpdateAgent:(e,t)=>{i(n=>n.map((n,r)=>r===e?{...n,...t}:n))},onRemoveAgent:e=>i(t=>t.filter((t,n)=>n!==e)),onAddAgent:()=>i(e=>[...e,X()]),onSetDefaultAgent:(e,t)=>i(n=>t?n.map((t,n)=>({...t,default:n===e})):n.map((t,n)=>n===e?{...t,default:!1}:t))}),(0,P.jsx)(ce,{bindings:a,onUpdateBinding:(e,t)=>{l(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>l(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>l(e=>[...e,Z()])}),(0,P.jsx)(te,{children:(0,P.jsxs)(s,{type:`button`,size:`sm`,onClick:()=>{try{let e=$({companionEnabled:m,agents:r,bindings:a,runtimeEntries:u,dmScope:f,defaultContextTokens:g,defaultEngine:v,knownAgentIds:b});t.mutate({data:e})}catch(e){o.error(e instanceof Error?e.message:String(e))}},disabled:t.isPending,children:[(0,P.jsx)(w,{className:`mr-1.5 h-3.5 w-3.5`}),t.isPending?E(`saving`):E(`saveRuntimeSettings`)]})})]})}function pe(){let{data:e,isLoading:t}=ee(),n=M();return t||!e?(0,P.jsx)(c,{title:E(`runtimePageTitle`),description:E(`runtimePageDescription`),children:(0,P.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:E(`runtimeLoading`)})}):(0,P.jsx)(fe,{config:e,updateRuntime:n})}export{pe as RuntimeConfig};
1
+ import{i as e}from"./chunk-DF37yw5_.js";import{r as t}from"./pwa-Blsqtn1m.js";import{Gt as n,Jt as r,Kt as i,Ut as a,Xn as o,Yt as s,Zt as c,dn as l,ln as u,pn as d,qt as f,sn as p,ur as m,xr as h}from"./api-BaML_txv.js";import{L as g,R as _,Zt as v,pt as y}from"./app-presenter-provider-DSlY9Lz6.js";import{X as b}from"./context-menu-DVgLoPqH.js";import{i as x}from"./x-DLvS4xvV.js";import{t as S}from"./plus-v29lPO18.js";import{t as C}from"./rotate-cw-DS-Gca0a.js";import{t as w}from"./save-CwxRo7hc.js";import{t as T}from"./trash-2-B8mbrtCx.js";import{s as E}from"./i18n-Bzo4IocH.js";import{a as D,i as O,n as k,r as A,t as j}from"./select-DHYR109w.js";import{b as M,t as ee}from"./use-config-BpKXDcM_.js";import{t as te}from"./form-actions-XP38NiPw.js";var N=e(h(),1),P=m(),F={healthy:`runtimeControlHealthy`,"starting-service":`runtimeControlStartingService`,"restarting-service":`runtimeControlRestartingService`,"stopping-service":`runtimeControlStoppingService`,"restarting-app":`runtimeControlRestartingApp`,recovering:`runtimeControlRecovering`,failed:`runtimeControlFailed`},I={running:`runtimeControlServiceRunning`,stopped:`runtimeControlServiceStopped`,starting:`runtimeControlServiceStarting`,stopping:`runtimeControlServiceStopping`,restarting:`runtimeControlServiceRestarting`},L={"desktop-embedded":`runtimeControlEnvironmentDesktop`,"managed-local-service":`runtimeControlEnvironmentManagedService`,"self-hosted-web":`runtimeControlEnvironmentSelfHosted`,"shared-web":`runtimeControlEnvironmentSharedWeb`};function R(e){return E(F[e]??`runtimeControlUnavailable`)}function z(e){return E(I[e]??`runtimeControlServiceUnknown`)}function B(e){return E(L[e.environment])}function V(e,t){return t===`start-service`?e?.canStartService:t===`stop-service`?e?.canStopService:e?.canRestartService}function H(e){return e?[{action:`start-service`,capability:e.canStartService,label:E(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:E(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:E(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:E(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function U(e){let{busy:t,icon:n}=e;return t?(0,P.jsx)(x,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,P.jsx)(b,{className:`mr-2 h-4 w-4`}):n===`square`?(0,P.jsx)(v,{className:`mr-2 h-4 w-4`}):(0,P.jsx)(C,{className:`mr-2 h-4 w-4`})}function W(){let{busy:e,busyAction:t,controlView:n,errorMessage:i,pendingRestart:a,visibleLifecycle:c,visibleMessage:u,visibleServiceState:m}=p(),h=H(n??void 0),g=async e=>{let t=V(n,e);if(!t?.available){o.error(d(t?.reasonIfUnavailable)??E(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(E(`runtimeControlStopServiceConfirm`))))try{let t=await l.runRuntimeControlAction(e);o.success(d(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:E(`runtimeControlActionFailed`);o.error(`${E(`runtimeControlActionFailed`)}: ${t}`)}},_=async()=>{if(!n?.canRestartApp.available){o.error(d(n?.canRestartApp.reasonIfUnavailable)??E(`runtimeRestartAppUnavailable`));return}if(window.confirm(E(`runtimeControlRestartAppConfirm`)))try{let e=await l.runRuntimeControlAction(`restart-app`);o.success(d(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:E(`runtimeControlActionFailed`);o.error(`${E(`runtimeControlActionFailed`)}: ${t}`)}};return(0,P.jsx)(r,{title:E(`runtimeControlTitle`),description:E(`runtimeControlDescription`),children:(0,P.jsxs)(f,{children:[(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:z(m)}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n?B(n):E(`runtimeControlLoading`)})]}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:R(c)}),n?.managementHint?(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d(n.managementHint)}):null,i&&!e?(0,P.jsx)(`p`,{className:`text-sm text-amber-700`,children:i}):null]}),a?(0,P.jsxs)(`div`,{className:`space-y-3 bg-amber-50/75 p-4 dark:bg-amber-950/20`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:E(`runtimeControlPendingRestartTitle`)}),(0,P.jsx)(`p`,{className:`text-sm text-amber-800`,children:E(`runtimeControlPendingRestartDescription`)}),a.changedPaths.length>0?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:E(`runtimeControlPendingRestartPaths`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.changedPaths.map(e=>(0,P.jsx)(`span`,{className:`rounded-full bg-background/80 px-2.5 py-1 text-xs text-amber-800 dark:text-amber-300`,children:e},e))})]}):null]}):null,(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:h.map(n=>(0,P.jsxs)(s,{type:`button`,variant:n.variant??`default`,onClick:()=>{if(n.action===`restart-app`){_();return}g(n.action)},disabled:!n.capability.available||e,children:[(0,P.jsx)(U,{icon:n.icon,busy:t===n.action}),n.label]},n.action))}),h.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d(e.capability.reasonIfUnavailable)},`${e.action}-reason`))]})]})})}function G(e){let{description:t,title:n}=e;return(0,P.jsx)(y,{tone:`neutral`,title:n,description:t})}function K(e){let{children:t}=e;return(0,P.jsx)(r,{title:E(`runtimePresenceTitle`),description:E(`runtimePresenceDescription`),children:(0,P.jsx)(f,{children:t})})}function q(){let e=u().runtimeControlView?.environment,t=_(e=>e.supported),n=_(e=>e.initialized),r=_(e=>e.busyAction),o=_(e=>e.snapshot);return(0,N.useEffect)(()=>{if(e===`desktop-embedded`){g.start();return}g.markUnsupported()},[e]),e===`desktop-embedded`?(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(y,{tone:`neutral`,title:E(`runtimePresenceBehaviorLabel`),description:o?.closeToBackground?E(`runtimePresenceBehaviorBackground`):E(`runtimePresenceBehaviorQuit`),className:`rounded-xl`})}),!n||t&&!o?(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:E(`runtimePresenceLoading`)}):null,o?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(i,{title:E(`runtimePresenceCloseToBackground`),description:E(`runtimePresenceCloseToBackgroundHelp`),control:(0,P.jsx)(a,{id:`runtime-presence-close-background`,"aria-label":E(`runtimePresenceCloseToBackground`),checked:o.closeToBackground,disabled:r===`saving-preferences`,onCheckedChange:e=>{g.updatePreferences({closeToBackground:e})}})}),(0,P.jsx)(i,{title:E(`runtimePresenceLaunchAtLogin`),description:o.supportsLaunchAtLogin?E(`runtimePresenceLaunchAtLoginHelp`):o.launchAtLoginReason??E(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,P.jsx)(a,{id:`runtime-presence-launch-login`,"aria-label":E(`runtimePresenceLaunchAtLogin`),checked:o.launchAtLogin,disabled:!o.supportsLaunchAtLogin||r===`saving-preferences`,onCheckedChange:e=>{g.updatePreferences({launchAtLogin:e})}})})]}):null]}):e===`managed-local-service`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:E(`runtimePresenceManagedLocalTitle`),description:E(`runtimePresenceManagedLocalDescription`)})})}):e===`self-hosted-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:E(`runtimePresenceSelfHostedTitle`),description:E(`runtimePresenceSelfHostedDescription`)})})}):e===`shared-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:E(`runtimePresenceSharedTitle`),description:E(`runtimePresenceSharedDescription`)})})}):(0,P.jsx)(K,{children:(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:E(`runtimePresenceLoading`)})})}function J(){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(W,{}),(0,P.jsx)(q,{}),(0,P.jsx)(t,{})]})}var Y={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function X(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0}}function Z(){return{agentId:``,match:{channel:``,accountId:``}}}function Q(){return{id:``,enabled:!0,label:``,type:`narp-stdio`,config:Y,configText:JSON.stringify(Y,null,2)}}function ne(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}}function re(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 ie(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ae(e){return{companionEnabled:e.companion?.enabled===!0,agents:(e.agents.list??[]).map(ne),bindings:(e.bindings??[]).map(re),runtimeEntries: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)})),dmScope:e.session?.dmScope??`per-channel-peer`,defaultContextTokens:e.agents.defaults.contextTokens??2e5,defaultEngine:e.agents.defaults.engine??`native`}}function oe(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)),t}function $(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(E(`agentIdRequiredError`).replace(`{index}`,String(t)));return oe(e)}),n=t.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0)throw Error(`${E(`duplicateAgentId`)}: ${n[0]}`);let r=e.bindings.map((t,n)=>{let r=t.agentId.trim(),i=t.match.channel.trim(),a=t.match.accountId?.trim()??``,o=t.match.peer?.kind,s=t.match.peer?.id?.trim()??``;if(!r)throw Error(E(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!e.knownAgentIds.has(r))throw Error(`${E(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${r}`);if(!i)throw Error(E(`bindingChannelRequired`).replace(`{index}`,String(n)));let c={agentId:r,match:{channel:i}};if(a&&(c.match.accountId=a),o){if(!s)throw Error(E(`bindingPeerIdRequired`).replace(`{index}`,String(n)));c.match.peer={kind:o,id:s}}return c}),i=e.runtimeEntries.reduce((e,t,n)=>{let r=t.id.trim(),i=t.type.trim();if(!r)throw Error(E(`runtimeEntryIdRequired`).replace(`{index}`,String(n)));if(!i)throw Error(E(`runtimeEntryTypeRequired`).replace(`{id}`,r));if(e[r])throw Error(`${E(`runtimeEntryDuplicate`)}: ${r}`);let a=t.configText.trim()?JSON.parse(t.configText):{};if(a&&(typeof a!=`object`||Array.isArray(a)))throw Error(E(`runtimeEntryConfigObjectRequired`).replace(`{id}`,r));return e[r]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:i,config:a??{}},e},{});return{companion:{enabled:e.companionEnabled},agents:{defaults:{contextTokens:Math.max(1e3,e.defaultContextTokens),engine:e.defaultEngine.trim()||`native`},list:t,runtimes:{entries:i}},bindings:r,session:{dmScope:e.dmScope}}}function se({agents:e,onAddAgent:t,onRemoveAgent:i,onSetDefaultAgent:o,onUpdateAgent:c}){return(0,P.jsx)(r,{title:E(`agentList`),description:E(`agentListHelp`),actions:(0,P.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(S,{className:`mr-2 h-4 w-4`}),E(`addAgent`)]}),children:(0,P.jsx)(f,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(n,{value:e.id,onChange:e=>c(t,{id:e.target.value}),placeholder:E(`agentIdPlaceholder`)}),(0,P.jsx)(n,{value:e.workspace??``,onChange:e=>c(t,{workspace:e.target.value}),placeholder:E(`workspaceOverridePlaceholder`)}),(0,P.jsx)(n,{value:e.model??``,onChange:e=>c(t,{model:e.target.value}),placeholder:E(`modelOverridePlaceholder`)}),(0,P.jsx)(n,{value:e.runtime??e.engine??``,onChange:e=>c(t,{runtime:e.target.value}),placeholder:E(`engineOverridePlaceholder`)}),(0,P.jsx)(n,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>c(t,{contextTokens:ie(e.target.value)}),placeholder:E(`contextTokensPlaceholder`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(a,{checked:!!e.default,onCheckedChange:e=>o(t,e)}),(0,P.jsx)(`span`,{children:E(`defaultAgent`)})]}),(0,P.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(t),children:[(0,P.jsx)(T,{className:`h-4 w-4 mr-1`}),E(`remove`)]})]})]},`${t}-${e.id}`))})})}function ce({bindings:e,onAddBinding:t,onRemoveBinding:i,onUpdateBinding:a}){return(0,P.jsx)(r,{title:E(`bindings`),description:E(`bindingsHelp`),actions:(0,P.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(S,{className:`mr-2 h-4 w-4`}),E(`addBinding`)]}),children:(0,P.jsx)(f,{children:e.map((e,t)=>{let r=e.match.peer?.kind??``;return(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,P.jsx)(n,{value:e.agentId,onChange:n=>a(t,{...e,agentId:n.target.value}),placeholder:E(`targetAgentIdPlaceholder`)}),(0,P.jsx)(n,{value:e.match.channel,onChange:n=>a(t,{...e,match:{...e.match,channel:n.target.value}}),placeholder:E(`channelPlaceholder`)}),(0,P.jsx)(n,{value:e.match.accountId??``,onChange:n=>a(t,{...e,match:{...e.match,accountId:n.target.value}}),placeholder:E(`accountIdOptionalPlaceholder`)}),(0,P.jsxs)(j,{value:r||`__none__`,onValueChange:n=>{let r=n===`__none__`?``:n;a(t,r?{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}}:{...e,match:{...e.match,peer:void 0}})},children:[(0,P.jsx)(O,{children:(0,P.jsx)(D,{})}),(0,P.jsxs)(k,{children:[(0,P.jsx)(A,{value:`__none__`,children:E(`peerKindOptional`)}),(0,P.jsx)(A,{value:`direct`,children:E(`peerKindDirect`)}),(0,P.jsx)(A,{value:`group`,children:E(`peerKindGroup`)}),(0,P.jsx)(A,{value:`channel`,children:E(`peerKindChannel`)})]})]}),(0,P.jsx)(n,{value:e.match.peer?.id??``,onChange:n=>a(t,{...e,match:{...e.match,peer:r?{kind:r,id:n.target.value}:void 0}}),placeholder:E(`peerIdPlaceholder`)})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(t),children:[(0,P.jsx)(T,{className:`h-4 w-4 mr-1`}),E(`remove`)]})})]},`${t}-${e.agentId}`)})})})}function le({entries:e,onAddEntry:t,onRemoveEntry:i,onUpdateEntry:o}){return(0,P.jsx)(r,{title:E(`runtimeEntries`),description:E(`runtimeEntriesHelp`),actions:(0,P.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(S,{className:`mr-2 h-4 w-4`}),E(`addRuntimeEntry`)]}),children:(0,P.jsx)(f,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(n,{value:e.id,onChange:e=>o(t,{id:e.target.value}),placeholder:E(`runtimeEntryIdPlaceholder`)}),(0,P.jsx)(n,{value:e.label??``,onChange:e=>o(t,{label:e.target.value}),placeholder:E(`runtimeEntryLabelPlaceholder`)}),(0,P.jsx)(n,{value:e.type,onChange:e=>o(t,{type:e.target.value}),placeholder:E(`runtimeEntryTypePlaceholder`)}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg bg-background/65 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:E(`enabled`)}),(0,P.jsx)(a,{checked:e.enabled!==!1,onCheckedChange:e=>o(t,{enabled:e})})]})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-foreground`,children:E(`runtimeEntryConfigJson`)}),(0,P.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm`,value:e.configText,onChange:e=>o(t,{configText:e.target.value}),spellCheck:!1})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(s,{type:`button`,variant:`outline`,onClick:()=>i(t),children:[(0,P.jsx)(T,{className:`mr-2 h-4 w-4`}),E(`delete`)]})})]},`${t}-${e.id||`runtime-entry`}`))})})}var ue=[{value:`main`,labelKey:`dmScopeMain`},{value:`per-peer`,labelKey:`dmScopePerPeer`},{value:`per-channel-peer`,labelKey:`dmScopePerChannelPeer`},{value:`per-account-channel-peer`,labelKey:`dmScopePerAccountChannelPeer`}];function de({companionEnabled:e,defaultContextTokens:t,defaultEngine:o,dmScope:s,onCompanionEnabledChange:c,onDefaultContextTokensChange:l,onDefaultEngineChange:u,onDmScopeChange:d}){return(0,P.jsx)(r,{title:E(`dmScope`),description:E(`dmScopeHelp`),children:(0,P.jsxs)(f,{children:[(0,P.jsx)(i,{title:E(`runtimeCompanionEnabled`),description:E(`runtimeCompanionEnabledHelp`),control:(0,P.jsx)(a,{checked:e,onCheckedChange:c})}),(0,P.jsx)(i,{title:E(`defaultContextTokens`),description:E(`defaultContextTokensHelp`),control:(0,P.jsx)(n,{type:`number`,min:1e3,step:1e3,value:t,onChange:e=>l(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3)),className:`w-36`})}),(0,P.jsx)(i,{title:E(`defaultEngine`),description:E(`defaultEngineHelp`),control:(0,P.jsx)(n,{value:o,onChange:e=>u(e.target.value),placeholder:E(`defaultEnginePlaceholder`),className:`w-56`})}),(0,P.jsx)(i,{title:E(`dmScope`),control:(0,P.jsxs)(j,{value:s,onValueChange:e=>d(e),children:[(0,P.jsx)(O,{className:`w-56`,children:(0,P.jsx)(D,{})}),(0,P.jsx)(k,{children:ue.map(e=>(0,P.jsx)(A,{value:e.value,children:E(e.labelKey)},e.value))})]})})]})})}function fe({config:e,updateRuntime:t}){let n=(0,N.useMemo)(()=>ae(e),[e]),[r,i]=(0,N.useState)(n.agents),[a,l]=(0,N.useState)(n.bindings),[u,d]=(0,N.useState)(n.runtimeEntries),[f,p]=(0,N.useState)(n.dmScope),[m,h]=(0,N.useState)(n.companionEnabled),[g,_]=(0,N.useState)(n.defaultContextTokens),[v,y]=(0,N.useState)(n.defaultEngine),b=(0,N.useMemo)(()=>{let e=new Set([`main`]);return r.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[r]);return(0,P.jsxs)(c,{title:E(`runtimePageTitle`),description:E(`runtimePageDescription`),children:[(0,P.jsx)(J,{}),(0,P.jsx)(de,{companionEnabled:m,dmScope:f,defaultContextTokens:g,defaultEngine:v,onCompanionEnabledChange:h,onDmScopeChange:p,onDefaultContextTokensChange:_,onDefaultEngineChange:y}),(0,P.jsx)(le,{entries:u,onUpdateEntry:(e,t)=>d(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>d(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>d(e=>[...e,Q()])}),(0,P.jsx)(se,{agents:r,onUpdateAgent:(e,t)=>{i(n=>n.map((n,r)=>r===e?{...n,...t}:n))},onRemoveAgent:e=>i(t=>t.filter((t,n)=>n!==e)),onAddAgent:()=>i(e=>[...e,X()]),onSetDefaultAgent:(e,t)=>i(n=>t?n.map((t,n)=>({...t,default:n===e})):n.map((t,n)=>n===e?{...t,default:!1}:t))}),(0,P.jsx)(ce,{bindings:a,onUpdateBinding:(e,t)=>{l(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>l(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>l(e=>[...e,Z()])}),(0,P.jsx)(te,{children:(0,P.jsxs)(s,{type:`button`,size:`sm`,onClick:()=>{try{let e=$({companionEnabled:m,agents:r,bindings:a,runtimeEntries:u,dmScope:f,defaultContextTokens:g,defaultEngine:v,knownAgentIds:b});t.mutate({data:e})}catch(e){o.error(e instanceof Error?e.message:String(e))}},disabled:t.isPending,children:[(0,P.jsx)(w,{className:`mr-1.5 h-3.5 w-3.5`}),t.isPending?E(`saving`):E(`saveRuntimeSettings`)]})})]})}function pe(){let{data:e,isLoading:t}=ee(),n=M();return t||!e?(0,P.jsx)(c,{title:E(`runtimePageTitle`),description:E(`runtimePageDescription`),children:(0,P.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:E(`runtimeLoading`)})}):(0,P.jsx)(fe,{config:e,updateRuntime:n})}export{pe as RuntimeConfig};
@@ -1 +1 @@
1
- import{t as e}from"./createLucideIcon-reFMl-W-.js";var t=e(`Save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]);export{t};
1
+ import{t as e}from"./createLucideIcon-D-7Sxfw7.js";var t=e(`Save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]);export{t};
@@ -1 +1 @@
1
- import{t as e}from"./createLucideIcon-reFMl-W-.js";var t=e(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),n=e(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]);export{t as n,n as t};
1
+ import{t as e}from"./createLucideIcon-D-7Sxfw7.js";var t=e(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),n=e(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]);export{t as n,n as t};
@@ -1 +1 @@
1
- import{i as e}from"./chunk-DF37yw5_.js";import{Gt as t,Wt as n,Yt as r,Zt as i,ur as a,xr as o}from"./api-CI6_8Qt1.js";import{t as s}from"./navigation-link-D-JSWFxj.js";import{t as c}from"./search-BG2qAlNZ.js";import{i as l,t as u}from"./use-viewport-layout-IKKGpjzF.js";import{s as d}from"./i18n-IGQbjBqS.js";import{a as f,i as p,n as m,r as h,t as g}from"./select-xUXYV0Gr.js";import{n as _,t as v,x as y}from"./use-config-COusaY5p.js";import{t as b}from"./form-actions-B8VniHts.js";import{a as x,c as S,l as C,n as w,o as T,r as E,s as D,t as O}from"./config-split-page-hY1xug28.js";var k=e(o(),1),A=a(),j=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],M=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],N=[{value:`true`,label:`enabled`},{value:`false`,label:`disabled`}],P={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`,exa:`searchProviderExaDescription`};function F(e){return{activeProvider:e.provider,enabledProviders:e.enabledProviders,maxResults:String(e.defaults.maxResults),providers:{bocha:{apiKey:``,baseUrl:e.providers.bocha.baseUrl,summary:!!e.providers.bocha.summary,freshness:e.providers.bocha.freshness??`noLimit`},tavily:{apiKey:``,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth??`basic`,includeAnswer:!!e.providers.tavily.includeAnswer},brave:{apiKey:``,baseUrl:e.providers.brave.baseUrl},exa:{apiKey:``,baseUrl:e.providers.exa.baseUrl}}}}function I(e){return{provider:e.activeProvider,enabledProviders:e.enabledProviders,defaults:{maxResults:Number(e.maxResults)||10},providers:{bocha:{apiKey:e.providers.bocha.apiKey||void 0,baseUrl:e.providers.bocha.baseUrl,summary:e.providers.bocha.summary,freshness:e.providers.bocha.freshness},tavily:{apiKey:e.providers.tavily.apiKey||void 0,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth,includeAnswer:e.providers.tavily.includeAnswer},brave:{apiKey:e.providers.brave.apiKey||void 0,baseUrl:e.providers.brave.baseUrl},exa:{apiKey:e.providers.exa.apiKey||void 0,baseUrl:e.providers.exa.baseUrl}}}}function L(e){let{label:r,value:i,onChange:a,placeholder:o,type:s=`text`,inputMode:c}=e;return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(n,{children:r}),(0,A.jsx)(t,{type:s,value:i,onChange:e=>a(e.target.value),placeholder:o,inputMode:c,className:`rounded-xl`})]})}function R(e){let{label:t,value:r,options:i,onChange:a}=e;return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(n,{children:t}),(0,A.jsxs)(g,{value:r,onValueChange:a,children:[(0,A.jsx)(p,{className:`rounded-xl`,children:(0,A.jsx)(f,{})}),(0,A.jsx)(m,{children:i.map(e=>(0,A.jsx)(h,{value:e.value,children:d(e.label)},e.value))})]})]})}function z({docsUrl:e}){return e?(0,A.jsx)(s,{href:e,external:!0,children:d(`searchProviderOpenDocs`)}):null}function B(e){let{draft:t,provider:n,search:r,selectedDocsUrl:i,updateProviderDraft:a}=e;if(n===`bocha`){let{bocha:e}=t.providers;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:d(`apiKey`),value:e.apiKey,onChange:e=>a(`bocha`,{apiKey:e}),placeholder:r.providers.bocha.apiKeyMasked||d(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:d(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>a(`bocha`,{baseUrl:e})}),(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:d(`searchProviderSummary`),value:e.summary?`true`:`false`,options:N,onChange:e=>a(`bocha`,{summary:e===`true`})}),(0,A.jsx)(R,{label:d(`searchProviderFreshness`),value:e.freshness,options:j,onChange:e=>a(`bocha`,{freshness:e})})]}),(0,A.jsx)(z,{docsUrl:i??`https://open.bocha.cn`})]})}if(n===`tavily`){let{tavily:e}=t.providers;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:d(`apiKey`),value:e.apiKey,onChange:e=>a(`tavily`,{apiKey:e}),placeholder:r.providers.tavily.apiKeyMasked||d(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:d(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>a(`tavily`,{baseUrl:e})}),(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:d(`searchProviderSearchDepth`),value:e.searchDepth,options:M,onChange:e=>a(`tavily`,{searchDepth:e})}),(0,A.jsx)(R,{label:d(`searchProviderIncludeAnswer`),value:e.includeAnswer?`true`:`false`,options:N,onChange:e=>a(`tavily`,{includeAnswer:e===`true`})})]}),(0,A.jsx)(z,{docsUrl:i})]})}let o=t.providers[n],s=r.providers[n];return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:d(`apiKey`),value:o.apiKey,onChange:e=>a(n,{apiKey:e}),placeholder:s.apiKeyMasked||d(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:d(`searchProviderBaseUrl`),value:o.baseUrl,onChange:e=>a(n,{baseUrl:e})}),(0,A.jsx)(z,{docsUrl:i})]})}function V(e){let{draft:t,providers:n,search:r,selectedProvider:i,onSelect:a}=e;return(0,A.jsxs)(C,{children:[(0,A.jsx)(S,{className:`px-4 py-4`,children:(0,A.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:d(`searchChannels`)})}),(0,A.jsx)(T,{className:`space-y-2 p-3`,children:n.map(e=>{let n=r.providers[e.name],o=t.enabledProviders.includes(e.name);return(0,A.jsx)(O,{onClick:()=>a(e.name),active:i===e.name,className:`p-3`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:e.displayName}),(0,A.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-muted-foreground`,children:d(P[e.name])})]}),(0,A.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,A.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground`,children:n.apiKeySet?d(`searchStatusConfigured`):d(`searchStatusNeedsSetup`)}),o?(0,A.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:d(`searchProviderActivated`)}):null]})]})},e.name)})})]})}function H(e){let{initialDraft:t,providers:n,search:i,onSubmit:a,isPending:o}=e,{isMobile:s}=u(),[f,p]=(0,k.useState)(null),[m,h]=(0,k.useState)(t),g=f&&n.some(e=>e.name===f)?f:s?null:i.provider,_=n.find(e=>e.name===g)??null,v=g?i.providers[g]:null,y=g?m.enabledProviders.includes(g):!1,C=v?.docsUrl??_?.docsUrl;return(0,A.jsxs)(x,{className:`md:min-h-0`,compactView:f?`detail`:`list`,onMobileBack:()=>p(null),mobileListLabel:d(`searchPageTitle`),children:[(0,A.jsx)(V,{draft:m,providers:n,search:i,selectedProvider:g??i.provider,onSelect:p}),_?(0,A.jsx)(w,{children:(0,A.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a(m)},className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsx)(S,{className:`px-5 py-4`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-primary-foreground`,children:(0,A.jsx)(c,{className:`h-5 w-5`})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:_.displayName}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:d(P[_.name])})]})]}),(0,A.jsx)(r,{type:`button`,variant:y?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=y?m.enabledProviders.filter(e=>e!==g):g?[...m.enabledProviders,g]:m.enabledProviders,t={...m,enabledProviders:e};h(t),a(t)},children:d(y?`searchProviderDeactivate`:`searchProviderActivate`)})]})}),(0,A.jsxs)(T,{className:`space-y-5 px-5 py-4`,children:[(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:d(`searchActiveProvider`),value:m.activeProvider,options:n.map(e=>({value:e.name,label:e.displayName})),onChange:e=>h({...m,activeProvider:e})}),(0,A.jsx)(L,{label:d(`searchDefaultMaxResults`),value:m.maxResults,onChange:e=>h({...m,maxResults:e}),inputMode:`numeric`})]}),(0,A.jsx)(B,{draft:m,provider:g,search:i,selectedDocsUrl:C,updateProviderDraft:(e,t)=>{h(n=>({...n,providers:{...n.providers,[e]:{...n.providers[e],...t}}}))}})]}),(0,A.jsx)(D,{children:(0,A.jsx)(b,{children:(0,A.jsxs)(r,{type:`submit`,size:`sm`,disabled:o,children:[(0,A.jsx)(l,{className:`mr-1.5 h-3.5 w-3.5`}),d(o?`saving`:`saveChanges`)]})})})]})}):(0,A.jsx)(E,{children:(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:d(`searchNoProviderSelected`)})})]})}function U(){let{data:e}=v(),{data:t}=_(),n=y(),r=t?.search??[],a=e?.search;return!a||r.length===0?(0,A.jsx)(i,{title:d(`searchPageTitle`),description:d(`searchPageDescription`),layout:`split`,children:(0,A.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:d(`loading`)})}):(0,A.jsx)(i,{title:d(`searchPageTitle`),description:d(`searchPageDescription`),layout:`split`,children:(0,A.jsx)(H,{initialDraft:F(a),providers:r,search:a,onSubmit:e=>n.mutate({data:I(e)}),isPending:n.isPending},JSON.stringify(a))})}export{U as SearchConfigPage};
1
+ import{i as e}from"./chunk-DF37yw5_.js";import{Gt as t,Wt as n,Yt as r,Zt as i,ur as a,xr as o}from"./api-BaML_txv.js";import{t as s}from"./navigation-link-tawg3qi2.js";import{t as c}from"./search-Drx-sMCE.js";import{i as l,t as u}from"./use-viewport-layout-D6seoW0Z.js";import{s as d}from"./i18n-Bzo4IocH.js";import{a as f,i as p,n as m,r as h,t as g}from"./select-DHYR109w.js";import{n as _,t as v,x as y}from"./use-config-BpKXDcM_.js";import{t as b}from"./form-actions-XP38NiPw.js";import{a as x,c as S,l as C,n as w,o as T,r as E,s as D,t as O}from"./config-split-page-Cfozkh5B.js";var k=e(o(),1),A=a(),j=[{value:`noLimit`,label:`searchFreshnessNoLimit`},{value:`oneDay`,label:`searchFreshnessOneDay`},{value:`oneWeek`,label:`searchFreshnessOneWeek`},{value:`oneMonth`,label:`searchFreshnessOneMonth`},{value:`oneYear`,label:`searchFreshnessOneYear`}],M=[{value:`basic`,label:`searchDepthBasic`},{value:`advanced`,label:`searchDepthAdvanced`}],N=[{value:`true`,label:`enabled`},{value:`false`,label:`disabled`}],P={bocha:`searchProviderBochaDescription`,tavily:`searchProviderTavilyDescription`,brave:`searchProviderBraveDescription`,exa:`searchProviderExaDescription`};function F(e){return{activeProvider:e.provider,enabledProviders:e.enabledProviders,maxResults:String(e.defaults.maxResults),providers:{bocha:{apiKey:``,baseUrl:e.providers.bocha.baseUrl,summary:!!e.providers.bocha.summary,freshness:e.providers.bocha.freshness??`noLimit`},tavily:{apiKey:``,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth??`basic`,includeAnswer:!!e.providers.tavily.includeAnswer},brave:{apiKey:``,baseUrl:e.providers.brave.baseUrl},exa:{apiKey:``,baseUrl:e.providers.exa.baseUrl}}}}function I(e){return{provider:e.activeProvider,enabledProviders:e.enabledProviders,defaults:{maxResults:Number(e.maxResults)||10},providers:{bocha:{apiKey:e.providers.bocha.apiKey||void 0,baseUrl:e.providers.bocha.baseUrl,summary:e.providers.bocha.summary,freshness:e.providers.bocha.freshness},tavily:{apiKey:e.providers.tavily.apiKey||void 0,baseUrl:e.providers.tavily.baseUrl,searchDepth:e.providers.tavily.searchDepth,includeAnswer:e.providers.tavily.includeAnswer},brave:{apiKey:e.providers.brave.apiKey||void 0,baseUrl:e.providers.brave.baseUrl},exa:{apiKey:e.providers.exa.apiKey||void 0,baseUrl:e.providers.exa.baseUrl}}}}function L(e){let{label:r,value:i,onChange:a,placeholder:o,type:s=`text`,inputMode:c}=e;return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(n,{children:r}),(0,A.jsx)(t,{type:s,value:i,onChange:e=>a(e.target.value),placeholder:o,inputMode:c,className:`rounded-xl`})]})}function R(e){let{label:t,value:r,options:i,onChange:a}=e;return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(n,{children:t}),(0,A.jsxs)(g,{value:r,onValueChange:a,children:[(0,A.jsx)(p,{className:`rounded-xl`,children:(0,A.jsx)(f,{})}),(0,A.jsx)(m,{children:i.map(e=>(0,A.jsx)(h,{value:e.value,children:d(e.label)},e.value))})]})]})}function z({docsUrl:e}){return e?(0,A.jsx)(s,{href:e,external:!0,children:d(`searchProviderOpenDocs`)}):null}function B(e){let{draft:t,provider:n,search:r,selectedDocsUrl:i,updateProviderDraft:a}=e;if(n===`bocha`){let{bocha:e}=t.providers;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:d(`apiKey`),value:e.apiKey,onChange:e=>a(`bocha`,{apiKey:e}),placeholder:r.providers.bocha.apiKeyMasked||d(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:d(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>a(`bocha`,{baseUrl:e})}),(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:d(`searchProviderSummary`),value:e.summary?`true`:`false`,options:N,onChange:e=>a(`bocha`,{summary:e===`true`})}),(0,A.jsx)(R,{label:d(`searchProviderFreshness`),value:e.freshness,options:j,onChange:e=>a(`bocha`,{freshness:e})})]}),(0,A.jsx)(z,{docsUrl:i??`https://open.bocha.cn`})]})}if(n===`tavily`){let{tavily:e}=t.providers;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:d(`apiKey`),value:e.apiKey,onChange:e=>a(`tavily`,{apiKey:e}),placeholder:r.providers.tavily.apiKeyMasked||d(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:d(`searchProviderBaseUrl`),value:e.baseUrl,onChange:e=>a(`tavily`,{baseUrl:e})}),(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:d(`searchProviderSearchDepth`),value:e.searchDepth,options:M,onChange:e=>a(`tavily`,{searchDepth:e})}),(0,A.jsx)(R,{label:d(`searchProviderIncludeAnswer`),value:e.includeAnswer?`true`:`false`,options:N,onChange:e=>a(`tavily`,{includeAnswer:e===`true`})})]}),(0,A.jsx)(z,{docsUrl:i})]})}let o=t.providers[n],s=r.providers[n];return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(L,{label:d(`apiKey`),value:o.apiKey,onChange:e=>a(n,{apiKey:e}),placeholder:s.apiKeyMasked||d(`enterApiKey`),type:`password`}),(0,A.jsx)(L,{label:d(`searchProviderBaseUrl`),value:o.baseUrl,onChange:e=>a(n,{baseUrl:e})}),(0,A.jsx)(z,{docsUrl:i})]})}function V(e){let{draft:t,providers:n,search:r,selectedProvider:i,onSelect:a}=e;return(0,A.jsxs)(C,{children:[(0,A.jsx)(S,{className:`px-4 py-4`,children:(0,A.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground`,children:d(`searchChannels`)})}),(0,A.jsx)(T,{className:`space-y-2 p-3`,children:n.map(e=>{let n=r.providers[e.name],o=t.enabledProviders.includes(e.name);return(0,A.jsx)(O,{onClick:()=>a(e.name),active:i===e.name,className:`p-3`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:e.displayName}),(0,A.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-muted-foreground`,children:d(P[e.name])})]}),(0,A.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,A.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground`,children:n.apiKeySet?d(`searchStatusConfigured`):d(`searchStatusNeedsSetup`)}),o?(0,A.jsx)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700`,children:d(`searchProviderActivated`)}):null]})]})},e.name)})})]})}function H(e){let{initialDraft:t,providers:n,search:i,onSubmit:a,isPending:o}=e,{isMobile:s}=u(),[f,p]=(0,k.useState)(null),[m,h]=(0,k.useState)(t),g=f&&n.some(e=>e.name===f)?f:s?null:i.provider,_=n.find(e=>e.name===g)??null,v=g?i.providers[g]:null,y=g?m.enabledProviders.includes(g):!1,C=v?.docsUrl??_?.docsUrl;return(0,A.jsxs)(x,{className:`md:min-h-0`,compactView:f?`detail`:`list`,onMobileBack:()=>p(null),mobileListLabel:d(`searchPageTitle`),children:[(0,A.jsx)(V,{draft:m,providers:n,search:i,selectedProvider:g??i.provider,onSelect:p}),_?(0,A.jsx)(w,{children:(0,A.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a(m)},className:`flex min-h-0 flex-1 flex-col`,children:[(0,A.jsx)(S,{className:`px-5 py-4`,children:(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-primary-foreground`,children:(0,A.jsx)(c,{className:`h-5 w-5`})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:_.displayName}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:d(P[_.name])})]})]}),(0,A.jsx)(r,{type:`button`,variant:y?`secondary`:`outline`,className:`rounded-xl`,onClick:()=>{let e=y?m.enabledProviders.filter(e=>e!==g):g?[...m.enabledProviders,g]:m.enabledProviders,t={...m,enabledProviders:e};h(t),a(t)},children:d(y?`searchProviderDeactivate`:`searchProviderActivate`)})]})}),(0,A.jsxs)(T,{className:`space-y-5 px-5 py-4`,children:[(0,A.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,A.jsx)(R,{label:d(`searchActiveProvider`),value:m.activeProvider,options:n.map(e=>({value:e.name,label:e.displayName})),onChange:e=>h({...m,activeProvider:e})}),(0,A.jsx)(L,{label:d(`searchDefaultMaxResults`),value:m.maxResults,onChange:e=>h({...m,maxResults:e}),inputMode:`numeric`})]}),(0,A.jsx)(B,{draft:m,provider:g,search:i,selectedDocsUrl:C,updateProviderDraft:(e,t)=>{h(n=>({...n,providers:{...n.providers,[e]:{...n.providers[e],...t}}}))}})]}),(0,A.jsx)(D,{children:(0,A.jsx)(b,{children:(0,A.jsxs)(r,{type:`submit`,size:`sm`,disabled:o,children:[(0,A.jsx)(l,{className:`mr-1.5 h-3.5 w-3.5`}),d(o?`saving`:`saveChanges`)]})})})]})}):(0,A.jsx)(E,{children:(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:d(`searchNoProviderSelected`)})})]})}function U(){let{data:e}=v(),{data:t}=_(),n=y(),r=t?.search??[],a=e?.search;return!a||r.length===0?(0,A.jsx)(i,{title:d(`searchPageTitle`),description:d(`searchPageDescription`),layout:`split`,children:(0,A.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:d(`loading`)})}):(0,A.jsx)(i,{title:d(`searchPageTitle`),description:d(`searchPageDescription`),layout:`split`,children:(0,A.jsx)(H,{initialDraft:F(a),providers:r,search:a,onSubmit:e=>n.mutate({data:I(e)}),isPending:n.isPending},JSON.stringify(a))})}export{U as SearchConfigPage};
@@ -1,3 +1,3 @@
1
- import{i as e}from"./chunk-DF37yw5_.js";import{Gt as t,Jt as n,Kt as r,Ut as i,Xn as a,Yt as o,Zt as s,qt as c,ur as l,xr as u}from"./api-CI6_8Qt1.js";import{t as d}from"./plus-DUdl68Eo.js";import{t as f}from"./save-394QCMXn.js";import{t as p}from"./trash-2-DvJ6duOW.js";import{s as m}from"./i18n-IGQbjBqS.js";import{a as h,i as g,n as _,r as v,t as y}from"./select-xUXYV0Gr.js";import{S as b,t as x}from"./use-config-COusaY5p.js";import{t as S}from"./form-actions-B8VniHts.js";var C=e(u(),1),w=[`env`,`file`,`exec`];function T(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function E(){return{path:``,source:`env`,provider:``,id:``}}function D(e,t){return t.source===`env`?{...T(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...T(e),source:`file`,path:t.path}:{...T(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
1
+ import{i as e}from"./chunk-DF37yw5_.js";import{Gt as t,Jt as n,Kt as r,Ut as i,Xn as a,Yt as o,Zt as s,qt as c,ur as l,xr as u}from"./api-BaML_txv.js";import{t as d}from"./plus-v29lPO18.js";import{t as f}from"./save-CwxRo7hc.js";import{t as p}from"./trash-2-B8mbrtCx.js";import{s as m}from"./i18n-Bzo4IocH.js";import{a as h,i as g,n as _,r as v,t as y}from"./select-DHYR109w.js";import{S as b,t as x}from"./use-config-BpKXDcM_.js";import{t as S}from"./form-actions-XP38NiPw.js";var C=e(u(),1),w=[`env`,`file`,`exec`];function T(e=``){return{alias:e,source:`env`,prefix:``,path:``,command:``,argsText:``,cwd:``,timeoutMs:5e3}}function E(){return{path:``,source:`env`,provider:``,id:``}}function D(e,t){return t.source===`env`?{...T(e),source:`env`,prefix:t.prefix??``}:t.source===`file`?{...T(e),source:`file`,path:t.path}:{...T(e),source:`exec`,command:t.command,argsText:(t.args??[]).join(`
2
2
  `),cwd:t.cwd??``,timeoutMs:t.timeoutMs??5e3}}function O(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
3
  `).map(e=>e.trim()).filter(Boolean),...e.cwd.trim()?{cwd:e.cwd.trim()}:{},timeoutMs:Math.max(1,Math.trunc(e.timeoutMs||5e3))}}function k(e){return e?{enabled:!!e.enabled,defaultEnv:e.defaults.env??``,defaultFile:e.defaults.file??``,defaultExec:e.defaults.exec??``,providers:Object.entries(e.providers).map(([e,t])=>D(e,t)),refs:Object.entries(e.refs).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}))}:{enabled:!0,defaultEnv:``,defaultFile:``,defaultExec:``,providers:[],refs:[]}}function A(e){let t={};for(let[n,r]of e.providers.entries()){let e=r.alias.trim();if(!e)throw Error(`${m(`providerAlias`)} #${n+1} ${m(`isRequired`)}`);if(t[e])throw Error(`${m(`providerAlias`)}: ${e} (${m(`duplicate`)})`);if(r.source===`file`&&!r.path.trim())throw Error(`${m(`secretFilePath`)} #${n+1} ${m(`isRequired`)}`);if(r.source===`exec`&&!r.command.trim())throw Error(`${m(`secretExecCommand`)} #${n+1} ${m(`isRequired`)}`);t[e]=O(r)}let n={};for(let[r,i]of e.refs.entries()){let e=i.path.trim(),a=i.id.trim();if(!e)throw Error(`${m(`secretConfigPath`)} #${r+1} ${m(`isRequired`)}`);if(!a)throw Error(`${m(`secretId`)} #${r+1} ${m(`isRequired`)}`);let o=i.provider.trim();if(o&&!t[o])throw Error(`${m(`secretProviderAlias`)}: ${o} ${m(`notFound`)}`);n[e]={source:i.source,...o?{provider:o}:{},id:a}}return{enabled:e.enabled,defaultEnv:e.defaultEnv.trim(),defaultFile:e.defaultFile.trim(),defaultExec:e.defaultExec.trim(),providers:Object.entries(t).map(([e,t])=>D(e,t)),refs:Object.entries(n).map(([e,t])=>({path:e,source:t.source,provider:t.provider??``,id:t.id}))}}function j(e){return{enabled:e.enabled,defaults:{env:e.defaultEnv||null,file:e.defaultFile||null,exec:e.defaultExec||null},providers:Object.fromEntries(e.providers.map(e=>[e.alias.trim(),O(e)]).filter(([e])=>e)),refs:Object.fromEntries(e.refs.map(e=>[e.path.trim(),{source:e.source,...e.provider.trim()?{provider:e.provider.trim()}:{},id:e.id.trim()}]).filter(([e,t])=>e&&t.id))}}var M=l();function N(e){let{defaultEnv:t,defaultFile:n,defaultExec:i,providerAliases:a,onChange:o}=e;return(0,M.jsx)(M.Fragment,{children:[{label:m(`defaultEnvProvider`),value:t,key:`defaultEnv`},{label:m(`defaultFileProvider`),value:n,key:`defaultFile`},{label:m(`defaultExecProvider`),value:i,key:`defaultExec`}].map(e=>(0,M.jsx)(r,{title:e.label,control:(0,M.jsxs)(y,{value:e.value||`__none__`,onValueChange:t=>o(e.key,t===`__none__`?``:t),children:[(0,M.jsx)(g,{className:`w-56`,children:(0,M.jsx)(h,{placeholder:m(`noneOption`)})}),(0,M.jsxs)(_,{children:[(0,M.jsx)(v,{value:`__none__`,children:m(`noneOption`)}),a.map(e=>(0,M.jsx)(v,{value:e,children:e},e))]})]})},e.key))})}function P(e){let{providers:r,onUpdate:i,onRemove:a,onAdd:s}=e;return(0,M.jsx)(n,{title:m(`secretProvidersTitle`),description:m(`secretProvidersDescription`),actions:(0,M.jsxs)(o,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,children:[(0,M.jsx)(d,{className:`mr-2 h-4 w-4`}),m(`addSecretProvider`)]}),children:(0,M.jsx)(c,{children:r.map((e,n)=>(0,M.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,M.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-3`,children:[(0,M.jsx)(t,{value:e.alias,onChange:e=>i(n,{alias:e.target.value}),placeholder:m(`providerAlias`)}),(0,M.jsxs)(y,{value:e.source,onValueChange:e=>i(n,{source:e}),children:[(0,M.jsx)(g,{children:(0,M.jsx)(h,{})}),(0,M.jsx)(_,{children:w.map(e=>(0,M.jsx)(v,{value:e,children:e},e))})]}),(0,M.jsxs)(o,{type:`button`,variant:`outline`,onClick:()=>a(n),children:[(0,M.jsx)(p,{className:`mr-2 h-4 w-4`}),m(`removeProvider`)]})]}),e.source===`env`?(0,M.jsx)(t,{value:e.prefix,onChange:e=>i(n,{prefix:e.target.value}),placeholder:m(`envPrefix`)}):null,e.source===`file`?(0,M.jsx)(t,{value:e.path,onChange:e=>i(n,{path:e.target.value}),placeholder:m(`secretFilePath`)}):null,e.source===`exec`?(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(t,{value:e.command,onChange:e=>i(n,{command:e.target.value}),placeholder:m(`secretExecCommand`)}),(0,M.jsx)(`textarea`,{className:`min-h-[84px] w-full rounded-lg border border-input bg-background px-3 py-2 font-mono text-xs`,value:e.argsText,onChange:e=>i(n,{argsText:e.target.value}),placeholder:m(`secretExecArgs`)}),(0,M.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 md:grid-cols-2`,children:[(0,M.jsx)(t,{value:e.cwd,onChange:e=>i(n,{cwd:e.target.value}),placeholder:m(`secretExecCwd`)}),(0,M.jsx)(t,{type:`number`,min:1,value:e.timeoutMs,onChange:e=>i(n,{timeoutMs:Number.parseInt(e.target.value,10)||5e3}),placeholder:m(`secretExecTimeoutMs`)})]})]}):null]},`provider-${n}`))})})}function F(e){let{refs:r,providerAliases:i,onUpdate:a,onRemove:s,onAdd:l}=e;return(0,M.jsx)(n,{title:m(`secretRefsTitle`),description:m(`secretRefsDescription`),actions:(0,M.jsxs)(o,{type:`button`,variant:`ghost`,size:`sm`,onClick:l,children:[(0,M.jsx)(d,{className:`mr-2 h-4 w-4`}),m(`addSecretRef`)]}),children:(0,M.jsx)(c,{children:r.map((e,n)=>(0,M.jsx)(`div`,{className:`space-y-3 p-4`,children:(0,M.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,M.jsx)(t,{value:e.path,onChange:e=>a(n,{path:e.target.value}),placeholder:m(`secretConfigPath`)}),(0,M.jsx)(t,{value:e.id,onChange:e=>a(n,{id:e.target.value}),placeholder:m(`secretId`)}),(0,M.jsxs)(y,{value:e.source,onValueChange:e=>a(n,{source:e}),children:[(0,M.jsx)(g,{children:(0,M.jsx)(h,{})}),(0,M.jsx)(_,{children:w.map(e=>(0,M.jsx)(v,{value:e,children:e},e))})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,M.jsxs)(y,{value:e.provider||`__none__`,onValueChange:e=>a(n,{provider:e===`__none__`?``:e}),children:[(0,M.jsx)(g,{children:(0,M.jsx)(h,{placeholder:m(`secretProviderAlias`)})}),(0,M.jsxs)(_,{children:[(0,M.jsx)(v,{value:`__none__`,children:m(`noneOption`)}),i.map(e=>(0,M.jsx)(v,{value:e,children:e},e))]})]}),(0,M.jsx)(o,{type:`button`,variant:`outline`,onClick:()=>s(n),children:(0,M.jsx)(p,{className:`h-4 w-4`})})]})]})},`ref-${n}`))})})}function I(e){let{initialState:t,isPending:l,onSubmit:u}=e,[d,p]=(0,C.useState)(t),h=(0,C.useMemo)(()=>{let e=d.providers.map(e=>e.alias.trim()).filter(Boolean);return Array.from(new Set(e))},[d.providers]);return(0,M.jsxs)(s,{title:m(`secretsPageTitle`),description:m(`secretsPageDescription`),children:[(0,M.jsx)(n,{title:m(`secrets`),description:m(`secretsEnabledHelp`),children:(0,M.jsxs)(c,{children:[(0,M.jsx)(r,{title:m(`enabled`),description:m(`secretsEnabledHelp`),control:(0,M.jsx)(i,{checked:d.enabled,onCheckedChange:e=>p(t=>({...t,enabled:e}))})}),(0,M.jsx)(N,{defaultEnv:d.defaultEnv,defaultFile:d.defaultFile,defaultExec:d.defaultExec,providerAliases:h,onChange:(e,t)=>p(n=>({...n,[e]:t}))})]})}),(0,M.jsx)(P,{providers:d.providers,onUpdate:(e,t)=>{p(n=>({...n,providers:n.providers.map((n,r)=>r===e?{...n,...t}:n)}))},onRemove:e=>p(t=>({...t,providers:t.providers.filter((t,n)=>n!==e)})),onAdd:()=>p(e=>({...e,providers:[...e.providers,T()]}))}),(0,M.jsx)(F,{refs:d.refs,providerAliases:h,onUpdate:(e,t)=>{p(n=>({...n,refs:n.refs.map((n,r)=>r===e?{...n,...t}:n)}))},onRemove:e=>p(t=>({...t,refs:t.refs.filter((t,n)=>n!==e)})),onAdd:()=>p(e=>({...e,refs:[...e.refs,E()]}))}),(0,M.jsx)(S,{children:(0,M.jsxs)(o,{type:`button`,size:`sm`,onClick:()=>{try{u(A(d))}catch(e){a.error(e instanceof Error?e.message:String(e))}},disabled:l,children:[(0,M.jsx)(f,{className:`mr-1.5 h-3.5 w-3.5`}),m(l?`saving`:`save`)]})})]})}function L(){let{data:e,isLoading:t}=x(),n=b();return t?(0,M.jsx)(s,{title:m(`secretsPageTitle`),description:m(`secretsPageDescription`),children:(0,M.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:m(`loading`)})}):(0,M.jsx)(I,{initialState:k(e?.secrets),isPending:n.isPending,onSubmit:e=>n.mutate({data:j(e)})},JSON.stringify(e?.secrets??null))}export{L as SecretsConfigPage};
@@ -0,0 +1 @@
1
+ import{zt as e}from"./api-BaML_txv.js";export{e as SecurityConfig};
@@ -1 +1 @@
1
- import{i as e}from"./chunk-DF37yw5_.js";import{_n as t,ur as n,xr as r}from"./api-CI6_8Qt1.js";import{B as i,R as a,a as o,c as s,d as c,f as l,h as u,i as d,l as f,m as p,o as m,p as h,r as g,s as _,t as v,u as y,z as b}from"./dist-ZaFFmAGl.js";var x=e(r(),1),S=n(),C=f,w=p,T=`2rem`;function E(e){return`min(${e}, max(0px, calc(var(--radix-select-content-available-height, 100vh) - ${T})))`}var D=E(`24rem`),O=x.forwardRef(({className:e,children:n,indicator:r,...i},a)=>(0,S.jsxs)(h,{ref:a,className:t(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-border/75 bg-card px-3 py-2 text-sm text-foreground ring-offset-background placeholder:text-muted-foreground transition-colors focus:outline-none focus:ring-0 focus:border-border disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,`max-md:min-h-[var(--control-touch-size)]`,e),...i,children:[n,(0,S.jsx)(g,{asChild:!0,children:r??(0,S.jsx)(b,{className:`h-4 w-4 opacity-50`})})]}));O.displayName=h.displayName;var k=x.forwardRef(({className:e,...n},r)=>(0,S.jsx)(c,{ref:r,className:t(`flex cursor-default items-center justify-center py-1`,e),...n,children:(0,S.jsx)(a,{className:`h-4 w-4`})}));k.displayName=c.displayName;var A=x.forwardRef(({className:e,...n},r)=>(0,S.jsx)(y,{ref:r,className:t(`flex cursor-default items-center justify-center py-1`,e),...n,children:(0,S.jsx)(b,{className:`h-4 w-4`})}));A.displayName=y.displayName;var j=x.forwardRef(({className:e,children:n,collisionPadding:r=12,position:i=`popper`,style:a,viewportClassName:o,...c},l)=>(0,S.jsx)(s,{children:(0,S.jsxs)(v,{ref:l,"data-theme-overlay":`select`,className:t(`relative z-[var(--z-popover,10100)] flex max-h-96 min-w-[8rem] flex-col overflow-hidden rounded-xl border border-border/40 bg-popover text-popover-foreground shadow-floating data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),collisionPadding:r,position:i,style:{maxHeight:D,...a},...c,children:[(0,S.jsx)(k,{}),(0,S.jsx)(u,{className:t(`min-h-0 flex-1 overflow-y-auto overscroll-contain p-1`,i===`popper`&&`w-full min-w-[var(--radix-select-trigger-width)]`,o),children:n}),(0,S.jsx)(A,{})]})}));j.displayName=v.displayName;var M=x.forwardRef(({className:e,...n},r)=>(0,S.jsx)(_,{ref:r,className:t(`px-2 py-1.5 text-sm font-semibold`,e),...n}));M.displayName=_.displayName;var N=x.forwardRef(({className:e,children:n,...r},a)=>(0,S.jsxs)(d,{ref:a,className:t(`relative flex max-md:min-h-[var(--control-touch-size)] w-full cursor-default select-none items-center rounded-lg py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-[var(--interaction-hover)] focus:text-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-[var(--interaction-hover)]`,e),...r,children:[(0,S.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(o,{children:(0,S.jsx)(i,{className:`h-4 w-4`})})}),(0,S.jsx)(m,{children:n})]}));N.displayName=d.displayName;var P=x.forwardRef(({className:e,...n},r)=>(0,S.jsx)(l,{ref:r,className:t(`-mx-1 my-1 h-px bg-muted`,e),...n}));P.displayName=l.displayName;export{w as a,O as i,j as n,E as o,N as r,C as t};
1
+ import{i as e}from"./chunk-DF37yw5_.js";import{_n as t,ur as n,xr as r}from"./api-BaML_txv.js";import{B as i,R as a,a as o,c as s,d as c,f as l,h as u,i as d,l as f,m as p,o as m,p as h,r as g,s as _,t as v,u as y,z as b}from"./dist-BxOjfeaD.js";var x=e(r(),1),S=n(),C=f,w=p,T=`2rem`;function E(e){return`min(${e}, max(0px, calc(var(--radix-select-content-available-height, 100vh) - ${T})))`}var D=E(`24rem`),O=x.forwardRef(({className:e,children:n,indicator:r,...i},a)=>(0,S.jsxs)(h,{ref:a,className:t(`flex h-9 w-full items-center justify-between whitespace-nowrap rounded-xl border border-border/75 bg-card px-3 py-2 text-sm text-foreground ring-offset-background placeholder:text-muted-foreground transition-colors focus:outline-none focus:ring-0 focus:border-border disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,`max-md:min-h-[var(--control-touch-size)]`,e),...i,children:[n,(0,S.jsx)(g,{asChild:!0,children:r??(0,S.jsx)(b,{className:`h-4 w-4 opacity-50`})})]}));O.displayName=h.displayName;var k=x.forwardRef(({className:e,...n},r)=>(0,S.jsx)(c,{ref:r,className:t(`flex cursor-default items-center justify-center py-1`,e),...n,children:(0,S.jsx)(a,{className:`h-4 w-4`})}));k.displayName=c.displayName;var A=x.forwardRef(({className:e,...n},r)=>(0,S.jsx)(y,{ref:r,className:t(`flex cursor-default items-center justify-center py-1`,e),...n,children:(0,S.jsx)(b,{className:`h-4 w-4`})}));A.displayName=y.displayName;var j=x.forwardRef(({className:e,children:n,collisionPadding:r=12,position:i=`popper`,style:a,viewportClassName:o,...c},l)=>(0,S.jsx)(s,{children:(0,S.jsxs)(v,{ref:l,"data-theme-overlay":`select`,className:t(`relative z-[var(--z-popover,10100)] flex max-h-96 min-w-[8rem] flex-col overflow-hidden rounded-xl border border-border/40 bg-popover text-popover-foreground shadow-floating data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),collisionPadding:r,position:i,style:{maxHeight:D,...a},...c,children:[(0,S.jsx)(k,{}),(0,S.jsx)(u,{className:t(`min-h-0 flex-1 overflow-y-auto overscroll-contain p-1`,i===`popper`&&`w-full min-w-[var(--radix-select-trigger-width)]`,o),children:n}),(0,S.jsx)(A,{})]})}));j.displayName=v.displayName;var M=x.forwardRef(({className:e,...n},r)=>(0,S.jsx)(_,{ref:r,className:t(`px-2 py-1.5 text-sm font-semibold`,e),...n}));M.displayName=_.displayName;var N=x.forwardRef(({className:e,children:n,...r},a)=>(0,S.jsxs)(d,{ref:a,className:t(`relative flex max-md:min-h-[var(--control-touch-size)] w-full cursor-default select-none items-center rounded-lg py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-[var(--interaction-hover)] focus:text-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-[var(--interaction-hover)]`,e),...r,children:[(0,S.jsx)(`span`,{className:`absolute right-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(o,{children:(0,S.jsx)(i,{className:`h-4 w-4`})})}),(0,S.jsx)(m,{children:n})]}));N.displayName=d.displayName;var P=x.forwardRef(({className:e,...n},r)=>(0,S.jsx)(l,{ref:r,className:t(`-mx-1 my-1 h-px bg-muted`,e),...n}));P.displayName=l.displayName;export{w as a,O as i,j as n,E as o,N as r,C as t};