@xopcai/xopc 0.0.128 → 0.0.129

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 (75) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Dx3HQkOk.js → agent-avatar-dicebear-DHzfg5D-.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agents-Ceb_WmSZ.js → agents-CMxKKFQD.js} +1 -1
  5. package/dist/gateway/static/root/assets/{app-management-settings-panel-DGtoXVvI.js → app-management-settings-panel-ptk9c5BN.js} +1 -1
  6. package/dist/gateway/static/root/assets/{appearance-settings-BQQf_iLu.js → appearance-settings-bYeEj3IW.js} +1 -1
  7. package/dist/gateway/static/root/assets/{apps-page-D05daQF8.js → apps-page-DdZvDf5B.js} +1 -1
  8. package/dist/gateway/static/root/assets/{archive-plugin-HuCFa2UL.js → archive-plugin-Dy6lsTHw.js} +1 -1
  9. package/dist/gateway/static/root/assets/{attachment-load-N3csiRso.js → attachment-load-qOtBYR6Y.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automation-suggestion-card-DeYEW2YQ.js → automation-suggestion-card-BFH-RfaV.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-page-Dxn5-hGx.js → automations-page-B8JTjkCr.js} +1 -1
  12. package/dist/gateway/static/root/assets/{binary-plugins-DnJO0VG7.js → binary-plugins-DJvi_thc.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-DOAZkqfs.js → block-editor-DlMnizlt.js} +1 -1
  14. package/dist/gateway/static/root/assets/{browser-settings-page-DSB-ZKIX.js → browser-settings-page-slHLiZgi.js} +1 -1
  15. package/dist/gateway/static/root/assets/{capability-presets-api-DRCu-s6d.js → capability-presets-api-D4q7vHVJ.js} +1 -1
  16. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-M7jOJxZX.js → capability-presets-settings-panel-Dng8Grpv.js} +1 -1
  17. package/dist/gateway/static/root/assets/{channels-settings-C1iggCG3.js → channels-settings-KIsISXw0.js} +1 -1
  18. package/dist/gateway/static/root/assets/{connectors-page-Df0TJNgv.js → connectors-page-C5fx4Qs9.js} +1 -1
  19. package/dist/gateway/static/root/assets/{desktop-pet-MnqKnEgd.js → desktop-pet-Jmdn6q47.js} +1 -1
  20. package/dist/gateway/static/root/assets/{desktop-pet-settings-PRnTI9no.js → desktop-pet-settings-B-u63N4e.js} +1 -1
  21. package/dist/gateway/static/root/assets/{directory-picker-path-field-DJNFtSWq.js → directory-picker-path-field-8p1ehIHn.js} +1 -1
  22. package/dist/gateway/static/root/assets/{dreaming-settings-D0_2JavX.js → dreaming-settings-CCkKP-I4.js} +1 -1
  23. package/dist/gateway/static/root/assets/{extension-debug-page-C4sQuETO.js → extension-debug-page-DJ1ABK95.js} +1 -1
  24. package/dist/gateway/static/root/assets/{extension-page-DhnpWAUJ.js → extension-page-CP9P2lGM.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-settings-page-D7JDxFGh.js → extension-settings-page-DnhU-tx0.js} +1 -1
  26. package/dist/gateway/static/root/assets/{gateway-config-api-B_VyPdKh.js → gateway-config-api-CjxDn46s.js} +1 -1
  27. package/dist/gateway/static/root/assets/{gateway-settings-C0TutwM5.js → gateway-settings-TING7224.js} +1 -1
  28. package/dist/gateway/static/root/assets/{goal-create-dialog-DrDGK2L5.js → goal-create-dialog-2lPbGfp3.js} +1 -1
  29. package/dist/gateway/static/root/assets/{goal-detail-page-aaIMRRor.js → goal-detail-page-DHWVRafk.js} +1 -1
  30. package/dist/gateway/static/root/assets/{goals-config-api-CzTu01a1.js → goals-config-api-BqhuxG8P.js} +1 -1
  31. package/dist/gateway/static/root/assets/{goals-page-CBfCPiNK.js → goals-page-CMk-9ZYN.js} +1 -1
  32. package/dist/gateway/static/root/assets/{goals-settings-4rKUC3EH.js → goals-settings-BHzOAU_l.js} +1 -1
  33. package/dist/gateway/static/root/assets/{heartbeat-settings-DqJBKlza.js → heartbeat-settings-BQIm0P3V.js} +1 -1
  34. package/dist/gateway/static/root/assets/{index-38TSE7ng.js → index-C4k6QSXw.js} +6 -6
  35. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-ClVhEihC.js → keyboard-shortcuts-settings-BrENZzM7.js} +1 -1
  36. package/dist/gateway/static/root/assets/{logs-page-J8fw1O8x.js → logs-page-BiL302Ve.js} +1 -1
  37. package/dist/gateway/static/root/assets/{markdown-split-DQYDAL4r.js → markdown-split-BYF4ReGM.js} +1 -1
  38. package/dist/gateway/static/root/assets/{media-plugins-o5fchHfb.js → media-plugins-CpQDz-QJ.js} +1 -1
  39. package/dist/gateway/static/root/assets/{models-hub-panel-D9csuY5T.js → models-hub-panel-CFPpl3Cq.js} +1 -1
  40. package/dist/gateway/static/root/assets/{notes-page-CeWoUGI-.js → notes-page-BurgcdVZ.js} +1 -1
  41. package/dist/gateway/static/root/assets/{notes-workbench-D_oaF0Pq.js → notes-workbench-BAELRM_O.js} +2 -2
  42. package/dist/gateway/static/root/assets/{page-tabs-u0u41Gxz.js → page-tabs-RnYYOIWO.js} +1 -1
  43. package/dist/gateway/static/root/assets/{preview-open-alternatives-BaYRX55y.js → preview-open-alternatives-CTRt06Ri.js} +1 -1
  44. package/dist/gateway/static/root/assets/{project-detail-page-dkHzwhDL.js → project-detail-page-iXX1Ceo2.js} +1 -1
  45. package/dist/gateway/static/root/assets/{projects-page-DBp2WExF.js → projects-page-GDVTFAY7.js} +1 -1
  46. package/dist/gateway/static/root/assets/{remote-access-hub-Cgzg4pNN.js → remote-access-hub-BUrbUnwv.js} +1 -1
  47. package/dist/gateway/static/root/assets/{save-bar-controls-8ebg7PIX.js → save-bar-controls-c4pZeikq.js} +1 -1
  48. package/dist/gateway/static/root/assets/{schedule-field-Cd7FPvsJ.js → schedule-field-Cb6R7iuP.js} +1 -1
  49. package/dist/gateway/static/root/assets/{schema-form-Bq9iqPeA.js → schema-form-BqET_hEP.js} +1 -1
  50. package/dist/gateway/static/root/assets/{sessions-page-vkORZvUB.js → sessions-page-CiOreA2k.js} +1 -1
  51. package/dist/gateway/static/root/assets/settings-advanced-gate-C-qvptlu.js +1 -0
  52. package/dist/gateway/static/root/assets/{settings-collapsible-section-DaVKl6I7.js → settings-collapsible-section-DuOvqNsI.js} +1 -1
  53. package/dist/gateway/static/root/assets/{settings-form-section-C92Shabe.js → settings-form-section-DptSsbWd.js} +1 -1
  54. package/dist/gateway/static/root/assets/{settings-loading-skeleton-EJwzElLr.js → settings-loading-skeleton-BlVfBCb9.js} +1 -1
  55. package/dist/gateway/static/root/assets/{settings-page-layout-dTbdUfAB.js → settings-page-layout-DVt69dJJ.js} +1 -1
  56. package/dist/gateway/static/root/assets/{settings-page-BLY6onMK.js → settings-page-xQx2Pkg5.js} +1 -1
  57. package/dist/gateway/static/root/assets/{setup-status-panel-BU0JUWIA.js → setup-status-panel-DWB8VdLK.js} +1 -1
  58. package/dist/gateway/static/root/assets/{share-preview-page-SgKIyNQ7.js → share-preview-page-8m_ACH0z.js} +1 -1
  59. package/dist/gateway/static/root/assets/{shares-settings-aiY_QGsl.js → shares-settings-CgxfhNxI.js} +1 -1
  60. package/dist/gateway/static/root/assets/{skill-reload-api-C44tGvK7.js → skill-reload-api-BBFUOxmf.js} +1 -1
  61. package/dist/gateway/static/root/assets/{skills-page-C1re61FQ.js → skills-page-bo695odu.js} +1 -1
  62. package/dist/gateway/static/root/assets/{system-settings-panel-CntJCZEg.js → system-settings-panel-CW22OkZ4.js} +1 -1
  63. package/dist/gateway/static/root/assets/{typed-models-lib-CjULd6SF.js → typed-models-lib-BqpGAKxV.js} +1 -1
  64. package/dist/gateway/static/root/assets/{user-profile-settings-panel-DBgcbZfp.js → user-profile-settings-panel-CERVLuaW.js} +1 -1
  65. package/dist/gateway/static/root/assets/{utils-icmWvHl6.js → utils-BnmysurA.js} +1 -1
  66. package/dist/gateway/static/root/assets/{voice-api-key-field-BfvNUIWI.js → voice-api-key-field-Jr3jvPcB.js} +1 -1
  67. package/dist/gateway/static/root/assets/{work-item-detail-page-BYvZjBuJ.js → work-item-detail-page-B-8rex4u.js} +1 -1
  68. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DMXd1znx.js → workflow-run-setup-panel-Ci9GSPnS.js} +1 -1
  69. package/dist/gateway/static/root/assets/{workflow-start-dialog-Dff4IHzz.js → workflow-start-dialog-BhDj8pqH.js} +1 -1
  70. package/dist/gateway/static/root/assets/{workflows-page-0-640fQi.js → workflows-page-Brb3UGvs.js} +1 -1
  71. package/dist/gateway/static/root/index.html +1 -1
  72. package/dist/package.js +1 -1
  73. package/dist/src/mcp/channel-bridge.js +1 -1
  74. package/package.json +1 -1
  75. package/dist/gateway/static/root/assets/settings-advanced-gate-BFJsnSvx.js +0 -1
@@ -1,2 +1,2 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s,n as c,t as l}from"./fetch-BMjlW0g1.js";import{r as u}from"./toast-z0toXu32.js";import{t as d}from"./url-DFGNSBNT.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{$t as p,Ba as m,C as h,Cl as g,Cs as _,Do as v,Dt as y,Eo as b,Et as x,Ga as S,Gs as C,Gt as w,Jt as T,Ka as E,Kt as D,No as O,Ol as k,Os as A,Qc as j,Qt as M,Ss as N,To as P,Tt as F,Ua as I,Us as L,Ut as R,Va as z,Vo as B,Wa as V,Wt as H,Xt as U,Yt as W,Za as ee,Zo as te,Zt as ne,_a as G,_n as re,an as ie,ba as K,bo as ae,cc as oe,cn as se,cs as ce,dn as le,en as ue,fn as de,ga as fe,gc as pe,gn as me,go as he,ha as ge,hn as _e,in as ve,io as q,kc as ye,ko as be,ln as xe,ml as Se,mn as Ce,mo as we,nn as Te,no as J,on as Ee,oo as De,pn as Oe,po as ke,qt as Ae,rn as je,sn as Me,so as Ne,ss as Pe,tl as Fe,tn as Ie,to as Le,us as Re,vn as ze,wo as Be,ws as Ve,xo as Y,yn as He,zs as Ue}from"./index-38TSE7ng.js";import{n as We,t as Ge}from"./settings-page-layout-dTbdUfAB.js";import{r as Ke}from"./settings-loading-skeleton-EJwzElLr.js";import{a as qe,c as Je,d as Ye,f as Xe,l as Ze,n as Qe,o as $e,r as et,s as tt,t as nt,u as rt}from"./voice-api-key-field-BfvNUIWI.js";import{t as it}from"./settings-advanced-gate-BFJsnSvx.js";import{t as at}from"./settings-collapsible-section-DaVKl6I7.js";import{n as ot,t as st}from"./settings-form-section-C92Shabe.js";import{t as ct}from"./page-tabs-u0u41Gxz.js";import{n as lt,t as ut}from"./save-bar-controls-8ebg7PIX.js";var X=n(),Z=e(t(),1),Q=r(),dt=()=>d(Xe),ft=()=>d(`/api/image/capabilities`),pt=()=>d(`/api/global-defaults`),mt={imageModel:``,imageModelFallbacks:[],imageGenerationModel:``,imageGenerationModelFallbacks:[],imageGenerationModelTimeoutMs:``,imageGenerationModelAutoProviderFallback:!1};async function ht(){let e=await c(ft());if(!e.payload)throw Error(`Invalid image capabilities response`);return e.payload}function gt(e){return{imageModel:e?.imageModel?.primary??``,imageModelFallbacks:e?.imageModel?.fallbacks??[],imageGenerationModel:e?.imageGenerationModel?.primary??``,imageGenerationModelFallbacks:e?.imageGenerationModel?.fallbacks??[],imageGenerationModelTimeoutMs:e?.imageGenerationModel?.timeoutMs?String(e.imageGenerationModel.timeoutMs):``,imageGenerationModelAutoProviderFallback:e?.imageGenerationModel?.autoProviderFallback===!0}}function _t(e){return e.map(e=>e.trim()).filter(Boolean)}function vt(e,t){let n={...e,roles:{...e.roles}},r=t.imageModel.trim();if(r){let e=_t(t.imageModelFallbacks);n.imageModel={primary:r,...e.length>0?{fallbacks:e}:{}}}else delete n.imageModel;let i=t.imageGenerationModel.trim();if(i){let e=_t(t.imageGenerationModelFallbacks),r=t.imageGenerationModelTimeoutMs.trim(),a=r?Number(r):void 0;n.imageGenerationModel={primary:i,...e.length>0?{fallbacks:e}:{},...Number.isFinite(a)&&a&&a>0?{timeoutMs:Math.floor(a)}:{},...t.imageGenerationModelAutoProviderFallback?{autoProviderFallback:!0}:{}}}else delete n.imageGenerationModel;return n}function yt(e){return e.filter(e=>e.configured).flatMap(e=>e.models.map(t=>({value:t.ref,label:`${t.name||t.id} · ${t.ref}`,configured:e.configured}))).sort((e,t)=>Number(t.configured)-Number(e.configured)||e.value.localeCompare(t.value))}function bt(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}var xt={saving:!1,savedFlash:!1,error:void 0};function St(e){let t=(0,X.c)(63),{title:n,description:r,primaryLabel:i,fallbackLabel:a,fallbackPlaceholder:o,value:s,fallbackValues:c,options:l,emptyLabel:u,onValueChange:d,onFallbackValuesChange:f}=e,p;t[0]!==c||t[1]!==s?(p=new Set([s,...c].filter(Boolean)),t[0]=c,t[1]=s,t[2]=p):p=t[2];let m=p,h;t[3]!==l||t[4]!==m||t[5]!==s?(h=s?l.find(e=>!m.has(e.value))?.value??``:``,t[3]=l,t[4]=m,t[5]=s,t[6]=h):h=t[6];let g=h,_;t[7]!==c||t[8]!==g||t[9]!==f?(_=()=>{g&&f([...c,g])},t[7]=c,t[8]=g,t[9]=f,t[10]=_):_=t[10];let v=_,y;t[11]!==c||t[12]!==f?(y=(e,t)=>{let n=[...c];n[e]=t,f(n)},t[11]=c,t[12]=f,t[13]=y):y=t[13];let b=y,x;t[14]!==c||t[15]!==f?(x=e=>{f(c.filter((t,n)=>n!==e))},t[14]=c,t[15]=f,t[16]=x):x=t[16];let S=x,C;t[17]===n?C=t[18]:(C=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[17]=n,t[18]=C);let w;t[19]===r?w=t[20]:(w=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[19]=r,t[20]=w);let T;t[21]!==C||t[22]!==w?(T=(0,Q.jsxs)(`div`,{className:`mb-3`,children:[C,w]}),t[21]=C,t[22]=w,t[23]=T):T=t[23];let E;t[24]===c?E=t[25]:(E=new Set(c),t[24]=c,t[25]=E);let D;t[26]!==u||t[27]!==d||t[28]!==l||t[29]!==E||t[30]!==s?(D=(0,Q.jsx)(Le,{value:s,options:l,placeholder:u,emptyLabel:u,disabledValues:E,onChange:d}),t[26]=u,t[27]=d,t[28]=l,t[29]=E,t[30]=s,t[31]=D):D=t[31];let O;t[32]!==i||t[33]!==D?(O=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[i,D]}),t[32]=i,t[33]=D,t[34]=O):O=t[34];let k;t[35]===a?k=t[36]:(k=(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:a}),t[35]=a,t[36]=k);let A;t[37]!==u||t[38]!==a||t[39]!==o||t[40]!==c||t[41]!==l||t[42]!==S||t[43]!==m||t[44]!==b?(A=c.length===0?(0,Q.jsx)(`div`,{className:`flex min-h-10 items-center rounded-lg bg-surface-subtle px-3 text-sm font-normal text-fg-subtle shadow-surface`,children:o}):c.map((e,t)=>(0,Q.jsxs)(`div`,{className:`grid h-10 grid-cols-[minmax(0,1fr)_2.5rem] gap-2`,children:[(0,Q.jsx)(Le,{value:e,options:l,placeholder:u,emptyLabel:u,allowEmpty:!1,disabledValues:m,onChange:e=>b(t,e)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(t),className:`box-border inline-flex size-10 shrink-0 items-center justify-center rounded-lg border border-edge bg-surface-subtle text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:border-edge-strong`,"aria-label":a,children:(0,Q.jsx)(B,{className:`size-4`,"aria-hidden":`true`})})]},`${t}:${e}`)),t[37]=u,t[38]=a,t[39]=o,t[40]=c,t[41]=l,t[42]=S,t[43]=m,t[44]=b,t[45]=A):A=t[45];let j=!g,M;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(N,{className:`size-4`,"aria-hidden":`true`}),t[46]=M):M=t[46];let P;t[47]!==v||t[48]!==a||t[49]!==j?(P=(0,Q.jsxs)(`button`,{type:`button`,onClick:v,disabled:j,className:`box-border inline-flex h-9 w-fit min-w-[7.5rem] items-center justify-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:border-edge-strong`,children:[M,a]}),t[47]=v,t[48]=a,t[49]=j,t[50]=P):P=t[50];let F;t[51]!==A||t[52]!==P?(F=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[A,P]}),t[51]=A,t[52]=P,t[53]=F):F=t[53];let I;t[54]!==k||t[55]!==F?(I=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[k,F]}),t[54]=k,t[55]=F,t[56]=I):I=t[56];let L;t[57]!==O||t[58]!==I?(L=(0,Q.jsxs)(`div`,{className:`grid gap-3`,children:[O,I]}),t[57]=O,t[58]=I,t[59]=L):L=t[59];let R;return t[60]!==L||t[61]!==T?(R=(0,Q.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[T,L]}),t[60]=L,t[61]=T,t[62]=R):R=t[62],R}function Ct(){let e=(0,X.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Array.from({length:2}).map(wt),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(G,{className:`h-4 w-36`}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[t,(0,Q.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[n,(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2`,children:[(0,Q.jsx)(G,{className:`h-10 rounded-lg`}),(0,Q.jsx)(G,{className:`h-16 rounded-lg`})]})]})]}),e[2]=r):r=e[2],r}function wt(e,t){return(0,Q.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,Q.jsx)(G,{className:`h-4 w-40`}),(0,Q.jsx)(G,{className:`mt-2 h-3 w-72 max-w-full`}),(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3`,children:[(0,Q.jsx)(G,{className:`h-10 rounded-lg`}),(0,Q.jsx)(G,{className:`h-10 rounded-lg`}),(0,Q.jsx)(G,{className:`h-9 w-36 rounded-lg`})]})]},t)}function Tt(){let e=o(e=>e.language),t=a(e),n=t.imageModelsSettings,r=!!s(e=>e.token),[i,c]=(0,Z.useReducer)(y,xt),{saving:l,error:d}=i,p=K(),m=(0,Z.useMemo)(()=>new Set(p.map(e=>e.id)),[p]),{data:h=[],isLoading:g}=f(r?dt():null,Ye,{revalidateOnFocus:!1}),{data:_,isLoading:v,mutate:b}=f(r?ft():null,ht,{revalidateOnFocus:!1}),{data:x,isLoading:S,mutate:C}=f(r?pt():null,R,{revalidateOnFocus:!1}),w=h.some(e=>e.configured),T=Ze(h),[E,D]=(0,Z.useState)(mt),[O,k]=(0,Z.useState)(mt);(0,Z.useEffect)(()=>{if(!x?.models)return;let e=gt(x.models);D(e),k(e)},[x?.models]);let A=JSON.stringify(E)!==JSON.stringify(O),j=T.credDirty||A;(0,Z.useEffect)(()=>{if(!j)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[j]),lt({id:`image-models`,dirty:j,saving:l,save:(0,Z.useCallback)(async()=>{c({type:`patch`,patch:{saving:!0,error:void 0}});try{if(A){if(!x?.models)throw Error(n.loadError);let e=await H(vt(x.models,E));await C(e,!1),await b();let t=gt(e.models);D(t),k(t)}T.credDirty&&(await T.saveCredentials(n.credentialsSaveError),await b()),c({type:`patch`,patch:{savedFlash:!0}}),u({type:`success`,title:n.saved})}catch(e){c({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{saving:!1}})}},[T,x?.models,A,E,C,b,n.credentialsSaveError,n.loadError,n.saved]),discard:(0,Z.useCallback)(()=>{T.credDirty&&T.onDiscardCredentials(),A&&D(O),c({type:`patch`,patch:{error:void 0,savedFlash:!1}})},[T,O,A])});let M=(0,Z.useMemo)(()=>bt(n),[n]),N=(0,Z.useMemo)(()=>yt(_?.imageUnderstanding.providers??[]),[_?.imageUnderstanding.providers]),P=(0,Z.useMemo)(()=>yt(_?.imageGeneration.providers??[]),[_?.imageGeneration.providers]),F=(0,Z.useMemo)(()=>({getApiKey:t.providersSettings.getApiKey,getApiKeyIntl:t.providersSettings.getApiKeyIntl,getApiKeyCn:t.providersSettings.getApiKeyCn}),[t.providersSettings]);return r?g||v||S?(0,Q.jsx)(Ct,{}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d?(0,Q.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:d}):null,(0,Q.jsx)(St,{title:n.understandingTitle,description:n.understandingDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:E.imageModel,fallbackValues:E.imageModelFallbacks,options:N,emptyLabel:n.noModelSelected,onValueChange:e=>D(t=>({...t,imageModel:e,imageModelFallbacks:e?t.imageModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>D(t=>({...t,imageModelFallbacks:e}))}),(0,Q.jsx)(St,{title:n.generationTitle,description:n.generationDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:E.imageGenerationModel,fallbackValues:E.imageGenerationModelFallbacks,options:P,emptyLabel:n.noModelSelected,onValueChange:e=>D(t=>({...t,imageGenerationModel:e,imageGenerationModelFallbacks:e?t.imageGenerationModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>D(t=>({...t,imageGenerationModelFallbacks:e}))}),(0,Q.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.runtimeTuningTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.runtimeTuningHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,220px)_minmax(0,1fr)]`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[n.timeoutLabel,(0,Q.jsx)(`input`,{type:`number`,min:1,value:E.imageGenerationModelTimeoutMs,onChange:e=>D(t=>({...t,imageGenerationModelTimeoutMs:e.target.value})),placeholder:`120000`,className:`h-10 rounded-lg border border-edge bg-surface-subtle px-3 text-sm font-normal text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),(0,Q.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5 text-sm text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:E.imageGenerationModelAutoProviderFallback,onChange:e=>D(t=>({...t,imageGenerationModelAutoProviderFallback:e.target.checked})),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:n.autoFallbackLabel}),(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-fg-muted`,children:n.autoFallbackHint})]})]})]})]}),(0,Q.jsx)(at,{icon:ce,showLabel:n.providersTitle,hideLabel:n.providersTitle,defaultOpen:w,children:h.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.providersEmpty}):(0,Q.jsx)(rt,{summaries:h,credDraft:T.credDraft,credBaseline:T.credBaseline,credDirty:T.credDirty,credSaving:T.credSaving,credError:T.credError,credSavedFlash:T.credSavedFlash,credNoopFlash:T.credNoopFlash,updateCredRow:T.updateCredRow,onDiscardCredentials:T.onDiscardCredentials,onSaveCredentials:()=>void T.saveCredentials(n.credentialsSaveError),extensionIds:m,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:e,apiKeyLinkLabels:F,messages:M})})]}):(0,Q.jsx)(`div`,{className:`w-full text-sm text-fg-muted`,children:e===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var Et=Be;function Dt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function Ot(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function kt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function At(){return i(P,Be)}function jt(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Mt(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}var Nt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],Pt=[{id:`whisper-1`,name:`Whisper-1`}],Ft=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],It=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],Lt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Rt=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],zt=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],Bt=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],Vt=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],Ht=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],Ut=[{id:`piper`,command:`piper --model /path/to/voice.onnx --output_file "{{OutputPath}}"`,outputFormat:`wav`},{id:`sherpa-onnx`,command:`sherpa-onnx-offline-tts --text "{{Text}}" --output-filename "{{OutputPath}}"`,outputFormat:`wav`},{id:`mlx-audio`,command:`python -m mlx_audio.tts.generate --text "{{Text}}" --file_prefix "{{OutputBase}}"`,outputFormat:`wav`}];function Wt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Gt(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function Kt(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function qt(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function Jt(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Yt(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function Xt(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Zt(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function Qt(){let e=a(o(e=>e.language)).voiceSettings,t=!!s(e=>e.token),[n,r]=(0,Z.useReducer)(Zt,{form:null,baseline:null}),i=n.form,c=n.baseline,[l,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),y=(0,Z.useRef)(!1),b=(0,Z.useRef)({parsed:null,models:void 0}),{data:x,error:S,isLoading:C,mutate:w}=fe(t),{data:T,error:E,isLoading:D,mutate:O}=f(t?d(`/api/voice/models`):null,Qe,{revalidateOnFocus:!1}),{data:k,error:A,isLoading:j}=f(t?d(`/api/voice/providers`):null,et,{revalidateOnFocus:!1}),{data:M,error:N,isLoading:P}=f(t?d(`/api/voice/stt-providers`):null,qe,{revalidateOnFocus:!1}),F=(0,Z.useMemo)(()=>k?.providers??[],[k]),I=(0,Z.useMemo)(()=>M?.providers??[],[M]),L=(0,Z.useMemo)(()=>x?.payload?.config===void 0?null:$e(x.payload.config),[x]),R=(0,Z.useMemo)(()=>!i||!c?!1:JSON.stringify(i)!==JSON.stringify(c),[i,c]);t?L!==null&&T!==void 0&&!y.current&&(b.current.parsed!==L||b.current.models!==T)&&(b.current={parsed:L,models:T},r({type:`sync`,value:L}),p(T)):(b.current.parsed!==null||b.current.models!==void 0)&&(b.current={parsed:null,models:void 0},r({type:`reset`}),p(null),y.current=!1);let z=!!(t&&(L===null||T===void 0||k===void 0||M===void 0)&&(C||D||j||P)),B=S instanceof Error?S.message:S?String(S):E instanceof Error?E.message:E?String(E):A instanceof Error?A.message:A?String(A):N instanceof Error?N.message:N?String(N):null,V=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),H=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),U=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),W=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!0,order:[`alibaba`,`openai`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ee=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),te=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),ne=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),G=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),re=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),ie=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]);if(lt({id:`voice`,dirty:R,saving:m,save:(0,Z.useCallback)(async()=>{if(!(!i||m)){h(!0),_(null);try{await tt(i),r({type:`saved`,value:i}),y.current=!1,u({type:`success`,title:e.saved})}catch(t){_(t instanceof Error?t.message:e.saveError)}finally{h(!1)}}},[i,m,e.saveError]),discard:(0,Z.useCallback)(()=>{c&&(y.current=!1,r({type:`discard`}),_(null))},[c])}),!t)return(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.needToken})});if(z)return(0,Q.jsx)(Ke,{rows:4});if(!i||l===null)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g??B??e.loadError}),(0,Q.jsx)(v,{type:`button`,variant:`secondary`,onClick:()=>{w(),O()},children:e.retry})]});let K=i.stt,ae=i.tts,oe=Jt(e);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g}):null,(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)($t,{v:e,stt:K,tts:ae}),(0,Q.jsx)(tn,{v:e,apiKeyLabels:oe,stt:K,models:l,sttProviders:I,updateStt:V,updateSttAlibaba:H,updateSttOpenai:U,updateSttFallback:W}),(0,Q.jsx)(sn,{v:e,apiKeyLabels:oe,tts:ae,models:l,ttsProviders:F,updateTts:ee,updateTtsAlibaba:te,updateTtsOpenai:ne,updateTtsEdge:G,updateTtsMinimax:re,updateTtsLocalCli:ie})]}),(0,Q.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,Q.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,Q.jsx)(`strong`,{className:`text-accent`,children:e.notes.title}),` `,e.notes.duration]}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:e.notes.envVars})]})]})}function $t(e){let t=(0,X.c)(39),{v:n,stt:r,tts:i}=e,a=i.provider===`openai`?i.openai?.voice:i.provider===`alibaba`?i.alibaba?.voice:i.provider===`minimax`?i.minimax?.voice:i.provider===`edge`?i.edge?.voice:void 0,o;t[0]===n.overview.title?o=t[1]:(o=(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=o);let s;t[2]===n.overview.description?s=t[3]:(s=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(l=r.enabled?`${n.overview.ready} · ${Wt(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=l):l=t[10];let u;t[11]!==r.enabled||t[12]!==l||t[13]!==n.overview.input?(u=(0,Q.jsx)(en,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?Kt(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=d):d=t[18];let f=i.enabled&&i.trigger!==`off`,p;t[19]!==d||t[20]!==f||t[21]!==n.overview.replies?(p=(0,Q.jsx)(en,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${Gt(i.provider,n)}${a?` · ${a}`:``}`:n.overview.off,t[23]=a,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=m):m=t[27];let h;t[28]!==m||t[29]!==i.enabled||t[30]!==n.overview.voice?(h=(0,Q.jsx)(en,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,Q.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,p,h]}),t[32]=h,t[33]=u,t[34]=p,t[35]=g):g=t[35];let _;return t[36]!==g||t[37]!==c?(_=(0,Q.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[c,g]}),t[36]=g,t[37]=c,t[38]=_):_=t[38],_}function en(e){let t=(0,X.c)(10),{label:n,value:r,ready:a}=e,o;t[0]===n?o=t[1]:(o=(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=o);let s=a?`text-fg`:`text-fg-muted`,c;t[2]===s?c=t[3]:(c=i(`mt-1 text-sm font-medium`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,Q.jsx)(`div`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function tn(e){let t=(0,X.c)(46),{v:n,apiKeyLabels:r,stt:a,models:o,sttProviders:s,updateStt:c,updateSttAlibaba:l,updateSttOpenai:u,updateSttFallback:d}=e,f=o?.stt?.alibaba?.length?o.stt.alibaba:Nt,p=o?.stt?.openai?.length?o.stt.openai:Pt,m;if(t[0]!==s){let e=new Set;m=[];for(let t of s)e.has(t.id)||(e.add(t.id),m.push(t));t[0]=s,t[1]=m}else m=t[1];let h=m,g,_,v,y,b;if(t[2]!==f||t[3]!==r||t[4]!==p||t[5]!==h||t[6]!==a||t[7]!==c||t[8]!==l||t[9]!==d||t[10]!==u||t[11]!==n){let e=h.find(e=>e.id===a.provider),o=a.providers?.[a.provider],s=typeof o?.apiKey==`string`?o.apiKey:``,m=typeof o?.model==`string`?o.model:``,x={...a.provider===`alibaba`?a.alibaba??{}:{},...a.provider===`openai`?a.openai??{}:{},...o??{}},S=(e?.fields??[]).filter(on),C;t[17]!==a.provider||t[18]!==a.providers||t[19]!==c?(C=e=>{c({providers:{...a.providers??{},[a.provider]:{...a.providers?.[a.provider]??{},...e}}})},t[17]=a.provider,t[18]=a.providers,t[19]=c,t[20]=C):C=t[20];let w=C;y=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(Ue,{className:`size-4 text-accent`,strokeWidth:1.75}),t[21]=T):T=t[21];let E;t[22]===n.stt.title?E=t[23]:(E=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[22]=n.stt.title,t[23]=E);let D;t[24]===n.stt.description?D=t[25]:(D=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[24]=n.stt.description,t[25]=D),t[26]!==E||t[27]!==D?(b=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[26]=E,t[27]=D,t[28]=b):b=t[28],g=`space-y-4`;let O;t[29]===c?O=t[30]:(O=e=>c({enabled:e}),t[29]=c,t[30]=O),t[31]!==a.enabled||t[32]!==O||t[33]!==n.overview.off||t[34]!==n.overview.ready||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(_=(0,Q.jsx)(cn,{checked:a.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:O}),t[31]=a.enabled,t[32]=O,t[33]=n.overview.off,t[34]=n.overview.ready,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=_):_=t[37],v=a.enabled?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:n.stt.provider}),(0,Q.jsx)(J,{className:At(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,Q.jsxs)(q,{value:e.id,children:[Wt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:n.stt.model}),a.provider===`alibaba`?(0,Q.jsx)(J,{className:At(),value:a.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(an)}):a.provider===`openai`?(0,Q.jsx)(J,{className:At(),value:a.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map(rn)}):a.provider===`groq`?(0,Q.jsx)(J,{className:At(),value:m||Ft[0].id,onChange:e=>w({model:e.target.value}),children:Ft.map(nn)}):(0,Q.jsx)(`input`,{className:kt(),value:m,onChange:e=>w({model:e.target.value}),placeholder:a.provider})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:n.stt.apiKey}),(0,Q.jsx)(nt,{kind:`stt`,providerId:a.provider,fieldId:`voice-stt-${a.provider}-api-key`,value:a.provider===`alibaba`?a.alibaba?.apiKey??``:a.provider===`openai`?a.openai?.apiKey??``:s,onChange:e=>{a.provider===`alibaba`?l({apiKey:e}):a.provider===`openai`?u({apiKey:e}):w({apiKey:e})},labels:r,placeholder:a.provider===`groq`?`gsk_...`:`sk-...`}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Dt(a.provider)?` ${Dt(a.provider)}`:``]})]})]}),S.length>0?(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,Q.jsx)(ln,{field:e,value:Yt(x,e),onChange:t=>w({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Et},e.key))}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a.fallback?.enabled??!0,onChange:e=>d({enabled:e.target.checked})})]})]}):null,t[2]=f,t[3]=r,t[4]=p,t[5]=h,t[6]=a,t[7]=c,t[8]=l,t[9]=d,t[10]=u,t[11]=n,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b}else g=t[12],_=t[13],v=t[14],y=t[15],b=t[16];let x;t[38]!==g||t[39]!==_||t[40]!==v?(x=(0,Q.jsxs)(`div`,{className:g,children:[_,v]}),t[38]=g,t[39]=_,t[40]=v,t[41]=x):x=t[41];let S;return t[42]!==y||t[43]!==b||t[44]!==x?(S=(0,Q.jsxs)(`section`,{className:y,children:[b,x]}),t[42]=y,t[43]=b,t[44]=x,t[45]=S):S=t[45],S}function nn(e){return(0,Q.jsx)(q,{value:e.id,children:e.name},e.id)}function rn(e){return(0,Q.jsx)(q,{value:e.id,children:e.name},e.id)}function an(e){return(0,Q.jsx)(q,{value:e.id,children:e.name},e.id)}function on(e){return e.key!==`apiKey`&&e.key!==`model`}function sn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:a,updateTts:o,updateTtsAlibaba:s,updateTtsOpenai:c,updateTtsEdge:l,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:It,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:Lt,m=r?.tts?.alibaba?.length?r.tts.alibaba:Rt,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:zt,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:Bt,_=r?.tts?.minimax?.length?r.tts.minimax:Vt,y=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:Ht,[b,x]=(0,Z.useState)(e.tts.test.sampleText),[S,w]=(0,Z.useState)({status:`idle`}),T=(0,Z.useRef)(null),E=(0,Z.useRef)(null),D=(0,Z.useCallback)(()=>{T.current?.pause(),T.current=null,E.current&&=(URL.revokeObjectURL(E.current),null)},[]),k=(0,Z.useMemo)(()=>{let e=new Set,t=[];for(let n of a)e.has(n.id)||(e.add(n.id),t.push(n));return t},[a]),A=k.find(e=>e.id===n.provider),j=n.providers?.[n.provider],M={...n.provider===`openai`?n.openai??{}:{},...n.provider===`alibaba`?n.alibaba??{}:{},...n.provider===`edge`?n.edge??{}:{},...n.provider===`minimax`?n.minimax??{}:{},...n.provider===`tts-local-cli`?n[`tts-local-cli`]??{}:{},...j??{}},N=(A?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),P=!!A?.diagnostics.requiresApiKey,F=!!A?.configured||!P,I=n.enabled?F?`ready`:`action`:`muted`,L=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,R=n.provider===`openai`?n.openai?.voice:n.provider===`alibaba`?n.alibaba?.voice:n.provider===`minimax`?n.minimax?.voice:n.provider===`edge`?n.edge?.voice:void 0;(0,Z.useEffect)(()=>()=>D(),[D]);let z=(0,Z.useCallback)(e=>{o({provider:e}),w({status:`idle`})},[o]),B=(0,Z.useCallback)(async()=>{let t=b.trim();if(!t){w({status:`error`,message:e.tts.test.emptyText});return}D(),w({status:`loading`});try{let r=await Je({text:t,provider:n.provider,providerConfig:M,...L?{model:L}:{},...R?{voice:R}:{}}),i=Mt(r.audio,r.mimeType);E.current=i;let a=new Audio(i);T.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,jt(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>w({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>w({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),w({status:`playing`,summary:o})}catch(e){D(),w({status:`error`,message:e instanceof Error?e.message:String(e)})}},[L,R,M,D,b,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),V=(0,Z.useCallback)(e=>{o({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,o]),H=(0,Z.useCallback)((e,t)=>{let r={[e.key]:t};V(r),n.provider===`openai`&&e.key===`baseUrl`?c(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&l(r)},[n.provider,V,l,u,c]);return(0,Q.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,Q.jsxs)(`div`,{className:`mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(O,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(cn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>o({enabled:e})}),(0,Q.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2.5 text-sm`,I===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:I===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,Q.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?F?`${e.tts.statusReady} ${Gt(n.provider,e)}${R?` · ${R}`:``}`:`${e.tts.statusNeedsSetup} ${Gt(n.provider,e)} · ${A?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:e.tts.trigger}),(0,Q.jsxs)(J,{className:At(),value:n.trigger,onChange:e=>o({trigger:e.target.value}),children:[(0,Q.jsx)(q,{value:`off`,children:e.tts.triggerOff}),(0,Q.jsx)(q,{value:`inbound`,children:e.tts.triggerInbound}),(0,Q.jsx)(q,{value:`tagged`,children:e.tts.triggerTagged}),(0,Q.jsx)(q,{value:`always`,children:e.tts.triggerAlways})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:e.tts.provider}),(0,Q.jsx)(J,{className:At(),value:n.provider,onChange:e=>z(e.target.value),children:k.map(t=>(0,Q.jsx)(q,{value:t.id,children:Gt(t.id,e)},t.id))}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[A?.configured?e.tts.configured:A?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${A.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,A?.description??qt(n.provider,e)]})]})]}),(0,Q.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!F||n.provider===`tts-local-cli`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,Q.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:e.stt.apiKey}),(0,Q.jsx)(nt,{kind:`tts`,providerId:n.provider,fieldId:`voice-tts-${n.provider}-api-key`,value:n.provider===`openai`?n.openai?.apiKey??``:n.provider===`alibaba`?n.alibaba?.apiKey??``:n.minimax?.apiKey??``,onChange:e=>{n.provider===`openai`?c({apiKey:e}):n.provider===`alibaba`?s({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,Ot(n.provider)?` ${Ot(n.provider)}`:``]})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:e.stt.model}),(0,Q.jsx)(J,{className:At(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?c({model:e.target.value}):n.provider===`alibaba`?s({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:_).map(e=>(0,Q.jsx)(q,{value:e.id,children:e.name},e.id))})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:e.tts.voice}),(0,Q.jsx)(J,{className:At(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?c({voice:e.target.value}):n.provider===`alibaba`?s({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:y).map(e=>(0,Q.jsx)(q,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:e.tts.voice}),(0,Q.jsx)(J,{className:At(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:g.map(e=>(0,Q.jsx)(q,{value:e.id,children:e.name},e.id))}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Q.jsx)($,{children:e.tts.localCli.preset}),(0,Q.jsxs)(J,{className:At(),value:``,onChange:e=>{let t=Ut.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,Q.jsx)(q,{value:``,children:e.tts.localCli.presetPlaceholder}),Ut.map(e=>(0,Q.jsx)(q,{value:e.id,children:e.id},e.id))]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Q.jsx)($,{children:e.tts.localCli.command}),(0,Q.jsx)(`input`,{className:i(kt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.command??``,onChange:e=>d({command:e.target.value}),placeholder:e.tts.localCli.commandPlaceholder}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)($,{children:e.tts.localCli.cwd}),(0,Q.jsx)(`input`,{className:i(kt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.cwd??``,onChange:e=>d({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)($,{children:e.tts.localCli.outputFormat}),(0,Q.jsxs)(J,{className:At(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,Q.jsx)(q,{value:`wav`,children:`wav`}),(0,Q.jsx)(q,{value:`mp3`,children:`mp3`}),(0,Q.jsx)(q,{value:`opus`,children:`opus`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Q.jsx)($,{children:e.tts.localCli.timeoutMs}),(0,Q.jsx)(`input`,{className:kt(),type:`number`,min:0,step:1e3,value:typeof n[`tts-local-cli`]?.timeoutMs==`number`?String(n[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){d({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&d({timeoutMs:n})},placeholder:`30000`}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,N.length>0?(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:N.map(e=>(0,Q.jsx)(ln,{field:e,value:Yt(M,e),onChange:t=>H(e,t),className:e.type===`textarea`?`sm:col-span-2`:Et},e.key))}):null]})]}),(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsxs)(v,{type:`button`,variant:`primary`,onClick:()=>void B(),disabled:S.status===`loading`,className:`h-9`,children:[S.status===`loading`?(0,Q.jsx)(C,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ve,{className:`size-4`}),S.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,Q.jsxs)(v,{type:`button`,variant:`secondary`,onClick:()=>{D(),w(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:S.status!==`playing`,className:`h-9`,children:[(0,Q.jsx)(te,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,Q.jsx)(`textarea`,{className:i(kt(),`mt-3 min-h-20 resize-y`),value:b,onChange:e=>x(e.target.value),maxLength:1e3}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,Q.jsxs)(`span`,{className:`text-fg-subtle`,children:[b.length,`/1000`]}),S.status===`playing`||S.status===`done`?(0,Q.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[S.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,S.summary]}):null,S.status===`error`?(0,Q.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:S.message}):null]})]})]}):null]})]})}function cn(e){let t=(0,X.c)(33),{checked:n,title:r,description:a,onLabel:o,offLabel:s,onChange:c}=e,l;t[0]!==n||t[1]!==c?(l=()=>c(!n),t[0]=n,t[1]=c,t[2]=l):l=t[2];let u=n?`bg-accent/10 text-fg ring-1 ring-accent/45 dark:bg-accent/15`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=i(`group flex w-full items-center justify-between gap-4 rounded-2xl px-4 py-3 text-left shadow-surface transition-colors`,b,u),t[3]=u,t[4]=d);let f=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,p;t[5]===f?p=t[6]:(p=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?o:s,h;t[7]!==p||t[8]!==m?(h=(0,Q.jsx)(`span`,{className:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==h||t[11]!==r?(g=(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,h]}),t[10]=h,t[11]=r,t[12]=g):g=t[12];let _;t[13]===a?_=t[14]:(_=(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:a}),t[13]=a,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,x;t[18]===y?x=t[19]:(x=i(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=x);let S=n?`translate-x-5`:`translate-x-0.5`,C;t[20]===S?C=t[21]:(C=i(`size-5 rounded-full bg-white shadow-surface transition-transform`,S),t[20]=S,t[21]=C);let w;t[22]===C?w=t[23]:(w=(0,Q.jsx)(`span`,{className:C}),t[22]=C,t[23]=w);let T;t[24]!==x||t[25]!==w?(T=(0,Q.jsx)(`span`,{className:x,"aria-hidden":!0,children:w}),t[24]=x,t[25]=w,t[26]=T):T=t[26];let E;return t[27]!==n||t[28]!==l||t[29]!==v||t[30]!==T||t[31]!==d?(E=(0,Q.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:l,className:d,children:[v,T]}),t[27]=n,t[28]=l,t[29]=v,t[30]=T,t[31]=d,t[32]=E):E=t[32],E}function ln(e){let t=(0,X.c)(36),{field:n,value:r,onChange:a,className:o}=e,s=`voice-schema-field-${n.key}`,c=n.description;if(n.type===`boolean`){let e;t[0]===o?e=t[1]:(e=i(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let s;t[2]===n.label?s=t[3]:(s=(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=s);let l;t[4]===c?l=t[5]:(l=c?(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,Q.jsxs)(`span`,{children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==a?(f=e=>a(Xt(n,e.target.checked)),t[9]=n,t[10]=a,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:f}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==e||t[16]!==u||t[17]!==p?(m=(0,Q.jsxs)(`label`,{className:e,children:[u,p]}),t[15]=e,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}let l=typeof r==`boolean`?``:String(r),u;t[19]===o?u=t[20]:(u=i(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,Q.jsx)($,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==o||t[24]!==n||t[25]!==l||t[26]!==s||t[27]!==a?(f=n.type===`select`?(0,Q.jsx)(J,{id:s,className:At(),value:l,required:n.required,onChange:e=>a(Xt(n,e.target.value)),children:(n.options??[]).map(un)}):n.type===`textarea`?(0,Q.jsx)(`textarea`,{id:s,className:i(kt(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Xt(n,e.target.value))}):n.type===`password`?(0,Q.jsx)(he,{id:s,className:o,value:l,onChange:e=>a(Xt(n,e)),placeholder:n.placeholder,labels:ke}):(0,Q.jsx)(`input`,{id:s,className:kt(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Xt(n,e.target.value))}),t[23]=o,t[24]=n,t[25]=l,t[26]=s,t[27]=a,t[28]=f):f=t[28];let p;t[29]===c?p=t[30]:(p=c?(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[29]=c,t[30]=p);let m;return t[31]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,Q.jsxs)(`div`,{className:u,children:[d,f,p]}),t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function un(e){return(0,Q.jsx)(q,{value:e.id,children:e.name},e.id)}function $(e){let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function dn(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function fn(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await c(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),ge()}async function pn(e){let t=await c(d(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function mn(e){let t=(0,X.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function hn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function gn(){return i(P,Be)}var _n=[`brave`,`tavily`,`bing`,`searxng`];function vn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var yn=F();function bn(){let e=a(o(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!s(e=>e.token),[c,l]=(0,Z.useReducer)(yn,{form:null,baseline:null}),d=c.form,f=c.baseline,[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),_=(0,Z.useRef)(!1),y=(0,Z.useRef)(null),{data:b,error:S,isLoading:C,mutate:w}=fe(r);x({enabled:r,parsed:(0,Z.useMemo)(()=>b?.payload?.config===void 0?null:dn(b.payload.config),[b]),dirty:_.current,trackedParsedRef:y,dispatch:l,onResetDirty:()=>{_.current=!1}});let T=!!(r&&C&&b===void 0&&!S),E=S instanceof Error?S.message:S?String(S):null,D=(0,Z.useMemo)(()=>!d||!f?!1:JSON.stringify(d)!==JSON.stringify(f),[d,f]),O=(0,Z.useCallback)(e=>{_.current=!0,l({type:`patch`,patch:e})},[]);return lt({id:`search`,dirty:D,saving:p,save:(0,Z.useCallback)(async()=>{if(!(!d||p)){m(!0),g(null);try{await fn(d),_.current=!1,l({type:`saved`,value:d}),u({type:`success`,title:t.saved})}catch(e){g(e instanceof Error?e.message:t.saveError)}finally{m(!1)}}},[d,p,t.saveError]),discard:(0,Z.useCallback)(()=>{f&&(_.current=!1,l({type:`discard`}),g(null))},[f])}),r?T?(0,Q.jsx)(Ke,{rows:3}):d?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,Q.jsxs)(st,{children:[(0,Q.jsx)(ot,{icon:Re,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,Q.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,Q.jsx)(mn,{label:t.regionLabel,description:t.regionDesc,children:(0,Q.jsxs)(J,{className:gn(),value:d.regionMode,onChange:e=>O({regionMode:e.target.value}),children:[(0,Q.jsx)(q,{value:`auto`,children:t.regionAuto}),(0,Q.jsx)(q,{value:`cn`,children:t.regionCn}),(0,Q.jsx)(q,{value:`global`,children:t.regionGlobal})]})})})]}),(0,Q.jsx)(it,{children:(0,Q.jsxs)(st,{children:[(0,Q.jsx)(ot,{icon:Se,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,Q.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:d.blocklistEnabled,onChange:e=>O({blocklistEnabled:e.target.checked})}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),(0,Q.jsx)(mn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,Q.jsx)(`textarea`,{className:i(hn(),`min-h-[6rem] font-mono text-xs`),value:d.blocklistDomains.join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s,n as c,t as l}from"./fetch-BMjlW0g1.js";import{r as u}from"./toast-z0toXu32.js";import{t as d}from"./url-DFGNSBNT.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{$t as p,Ba as m,C as h,Cl as g,Cs as _,Do as v,Dt as y,Eo as b,Et as x,Ga as S,Gs as C,Gt as w,Jt as T,Ka as E,Kt as D,No as O,Ol as k,Os as A,Qc as j,Qt as M,Ss as N,To as P,Tt as F,Ua as I,Us as L,Ut as R,Va as z,Vo as B,Wa as V,Wt as H,Xt as U,Yt as W,Za as ee,Zo as te,Zt as ne,_a as G,_n as re,an as ie,ba as K,bo as ae,cc as oe,cn as se,cs as ce,dn as le,en as ue,fn as de,ga as fe,gc as pe,gn as me,go as he,ha as ge,hn as _e,in as ve,io as q,kc as ye,ko as be,ln as xe,ml as Se,mn as Ce,mo as we,nn as Te,no as J,on as Ee,oo as De,pn as Oe,po as ke,qt as Ae,rn as je,sn as Me,so as Ne,ss as Pe,tl as Fe,tn as Ie,to as Le,us as Re,vn as ze,wo as Be,ws as Ve,xo as Y,yn as He,zs as Ue}from"./index-C4k6QSXw.js";import{n as We,t as Ge}from"./settings-page-layout-DVt69dJJ.js";import{r as Ke}from"./settings-loading-skeleton-BlVfBCb9.js";import{a as qe,c as Je,d as Ye,f as Xe,l as Ze,n as Qe,o as $e,r as et,s as tt,t as nt,u as rt}from"./voice-api-key-field-Jr3jvPcB.js";import{t as it}from"./settings-advanced-gate-C-qvptlu.js";import{t as at}from"./settings-collapsible-section-DuOvqNsI.js";import{n as ot,t as st}from"./settings-form-section-DptSsbWd.js";import{t as ct}from"./page-tabs-RnYYOIWO.js";import{n as lt,t as ut}from"./save-bar-controls-c4pZeikq.js";var X=n(),Z=e(t(),1),Q=r(),dt=()=>d(Xe),ft=()=>d(`/api/image/capabilities`),pt=()=>d(`/api/global-defaults`),mt={imageModel:``,imageModelFallbacks:[],imageGenerationModel:``,imageGenerationModelFallbacks:[],imageGenerationModelTimeoutMs:``,imageGenerationModelAutoProviderFallback:!1};async function ht(){let e=await c(ft());if(!e.payload)throw Error(`Invalid image capabilities response`);return e.payload}function gt(e){return{imageModel:e?.imageModel?.primary??``,imageModelFallbacks:e?.imageModel?.fallbacks??[],imageGenerationModel:e?.imageGenerationModel?.primary??``,imageGenerationModelFallbacks:e?.imageGenerationModel?.fallbacks??[],imageGenerationModelTimeoutMs:e?.imageGenerationModel?.timeoutMs?String(e.imageGenerationModel.timeoutMs):``,imageGenerationModelAutoProviderFallback:e?.imageGenerationModel?.autoProviderFallback===!0}}function _t(e){return e.map(e=>e.trim()).filter(Boolean)}function vt(e,t){let n={...e,roles:{...e.roles}},r=t.imageModel.trim();if(r){let e=_t(t.imageModelFallbacks);n.imageModel={primary:r,...e.length>0?{fallbacks:e}:{}}}else delete n.imageModel;let i=t.imageGenerationModel.trim();if(i){let e=_t(t.imageGenerationModelFallbacks),r=t.imageGenerationModelTimeoutMs.trim(),a=r?Number(r):void 0;n.imageGenerationModel={primary:i,...e.length>0?{fallbacks:e}:{},...Number.isFinite(a)&&a&&a>0?{timeoutMs:Math.floor(a)}:{},...t.imageGenerationModelAutoProviderFallback?{autoProviderFallback:!0}:{}}}else delete n.imageGenerationModel;return n}function yt(e){return e.filter(e=>e.configured).flatMap(e=>e.models.map(t=>({value:t.ref,label:`${t.name||t.id} · ${t.ref}`,configured:e.configured}))).sort((e,t)=>Number(t.configured)-Number(e.configured)||e.value.localeCompare(t.value))}function bt(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}var xt={saving:!1,savedFlash:!1,error:void 0};function St(e){let t=(0,X.c)(63),{title:n,description:r,primaryLabel:i,fallbackLabel:a,fallbackPlaceholder:o,value:s,fallbackValues:c,options:l,emptyLabel:u,onValueChange:d,onFallbackValuesChange:f}=e,p;t[0]!==c||t[1]!==s?(p=new Set([s,...c].filter(Boolean)),t[0]=c,t[1]=s,t[2]=p):p=t[2];let m=p,h;t[3]!==l||t[4]!==m||t[5]!==s?(h=s?l.find(e=>!m.has(e.value))?.value??``:``,t[3]=l,t[4]=m,t[5]=s,t[6]=h):h=t[6];let g=h,_;t[7]!==c||t[8]!==g||t[9]!==f?(_=()=>{g&&f([...c,g])},t[7]=c,t[8]=g,t[9]=f,t[10]=_):_=t[10];let v=_,y;t[11]!==c||t[12]!==f?(y=(e,t)=>{let n=[...c];n[e]=t,f(n)},t[11]=c,t[12]=f,t[13]=y):y=t[13];let b=y,x;t[14]!==c||t[15]!==f?(x=e=>{f(c.filter((t,n)=>n!==e))},t[14]=c,t[15]=f,t[16]=x):x=t[16];let S=x,C;t[17]===n?C=t[18]:(C=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[17]=n,t[18]=C);let w;t[19]===r?w=t[20]:(w=(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[19]=r,t[20]=w);let T;t[21]!==C||t[22]!==w?(T=(0,Q.jsxs)(`div`,{className:`mb-3`,children:[C,w]}),t[21]=C,t[22]=w,t[23]=T):T=t[23];let E;t[24]===c?E=t[25]:(E=new Set(c),t[24]=c,t[25]=E);let D;t[26]!==u||t[27]!==d||t[28]!==l||t[29]!==E||t[30]!==s?(D=(0,Q.jsx)(Le,{value:s,options:l,placeholder:u,emptyLabel:u,disabledValues:E,onChange:d}),t[26]=u,t[27]=d,t[28]=l,t[29]=E,t[30]=s,t[31]=D):D=t[31];let O;t[32]!==i||t[33]!==D?(O=(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[i,D]}),t[32]=i,t[33]=D,t[34]=O):O=t[34];let k;t[35]===a?k=t[36]:(k=(0,Q.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:a}),t[35]=a,t[36]=k);let A;t[37]!==u||t[38]!==a||t[39]!==o||t[40]!==c||t[41]!==l||t[42]!==S||t[43]!==m||t[44]!==b?(A=c.length===0?(0,Q.jsx)(`div`,{className:`flex min-h-10 items-center rounded-lg bg-surface-subtle px-3 text-sm font-normal text-fg-subtle shadow-surface`,children:o}):c.map((e,t)=>(0,Q.jsxs)(`div`,{className:`grid h-10 grid-cols-[minmax(0,1fr)_2.5rem] gap-2`,children:[(0,Q.jsx)(Le,{value:e,options:l,placeholder:u,emptyLabel:u,allowEmpty:!1,disabledValues:m,onChange:e=>b(t,e)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>S(t),className:`box-border inline-flex size-10 shrink-0 items-center justify-center rounded-lg border border-edge bg-surface-subtle text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:border-edge-strong`,"aria-label":a,children:(0,Q.jsx)(B,{className:`size-4`,"aria-hidden":`true`})})]},`${t}:${e}`)),t[37]=u,t[38]=a,t[39]=o,t[40]=c,t[41]=l,t[42]=S,t[43]=m,t[44]=b,t[45]=A):A=t[45];let j=!g,M;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Q.jsx)(N,{className:`size-4`,"aria-hidden":`true`}),t[46]=M):M=t[46];let P;t[47]!==v||t[48]!==a||t[49]!==j?(P=(0,Q.jsxs)(`button`,{type:`button`,onClick:v,disabled:j,className:`box-border inline-flex h-9 w-fit min-w-[7.5rem] items-center justify-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:border-edge-strong`,children:[M,a]}),t[47]=v,t[48]=a,t[49]=j,t[50]=P):P=t[50];let F;t[51]!==A||t[52]!==P?(F=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[A,P]}),t[51]=A,t[52]=P,t[53]=F):F=t[53];let I;t[54]!==k||t[55]!==F?(I=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[k,F]}),t[54]=k,t[55]=F,t[56]=I):I=t[56];let L;t[57]!==O||t[58]!==I?(L=(0,Q.jsxs)(`div`,{className:`grid gap-3`,children:[O,I]}),t[57]=O,t[58]=I,t[59]=L):L=t[59];let R;return t[60]!==L||t[61]!==T?(R=(0,Q.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[T,L]}),t[60]=L,t[61]=T,t[62]=R):R=t[62],R}function Ct(){let e=(0,X.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Array.from({length:2}).map(wt),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(G,{className:`h-4 w-36`}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,"aria-hidden":`true`,children:[t,(0,Q.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[n,(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2`,children:[(0,Q.jsx)(G,{className:`h-10 rounded-lg`}),(0,Q.jsx)(G,{className:`h-16 rounded-lg`})]})]})]}),e[2]=r):r=e[2],r}function wt(e,t){return(0,Q.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,Q.jsx)(G,{className:`h-4 w-40`}),(0,Q.jsx)(G,{className:`mt-2 h-3 w-72 max-w-full`}),(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3`,children:[(0,Q.jsx)(G,{className:`h-10 rounded-lg`}),(0,Q.jsx)(G,{className:`h-10 rounded-lg`}),(0,Q.jsx)(G,{className:`h-9 w-36 rounded-lg`})]})]},t)}function Tt(){let e=o(e=>e.language),t=a(e),n=t.imageModelsSettings,r=!!s(e=>e.token),[i,c]=(0,Z.useReducer)(y,xt),{saving:l,error:d}=i,p=K(),m=(0,Z.useMemo)(()=>new Set(p.map(e=>e.id)),[p]),{data:h=[],isLoading:g}=f(r?dt():null,Ye,{revalidateOnFocus:!1}),{data:_,isLoading:v,mutate:b}=f(r?ft():null,ht,{revalidateOnFocus:!1}),{data:x,isLoading:S,mutate:C}=f(r?pt():null,R,{revalidateOnFocus:!1}),w=h.some(e=>e.configured),T=Ze(h),[E,D]=(0,Z.useState)(mt),[O,k]=(0,Z.useState)(mt);(0,Z.useEffect)(()=>{if(!x?.models)return;let e=gt(x.models);D(e),k(e)},[x?.models]);let A=JSON.stringify(E)!==JSON.stringify(O),j=T.credDirty||A;(0,Z.useEffect)(()=>{if(!j)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[j]),lt({id:`image-models`,dirty:j,saving:l,save:(0,Z.useCallback)(async()=>{c({type:`patch`,patch:{saving:!0,error:void 0}});try{if(A){if(!x?.models)throw Error(n.loadError);let e=await H(vt(x.models,E));await C(e,!1),await b();let t=gt(e.models);D(t),k(t)}T.credDirty&&(await T.saveCredentials(n.credentialsSaveError),await b()),c({type:`patch`,patch:{savedFlash:!0}}),u({type:`success`,title:n.saved})}catch(e){c({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{c({type:`patch`,patch:{saving:!1}})}},[T,x?.models,A,E,C,b,n.credentialsSaveError,n.loadError,n.saved]),discard:(0,Z.useCallback)(()=>{T.credDirty&&T.onDiscardCredentials(),A&&D(O),c({type:`patch`,patch:{error:void 0,savedFlash:!1}})},[T,O,A])});let M=(0,Z.useMemo)(()=>bt(n),[n]),N=(0,Z.useMemo)(()=>yt(_?.imageUnderstanding.providers??[]),[_?.imageUnderstanding.providers]),P=(0,Z.useMemo)(()=>yt(_?.imageGeneration.providers??[]),[_?.imageGeneration.providers]),F=(0,Z.useMemo)(()=>({getApiKey:t.providersSettings.getApiKey,getApiKeyIntl:t.providersSettings.getApiKeyIntl,getApiKeyCn:t.providersSettings.getApiKeyCn}),[t.providersSettings]);return r?g||v||S?(0,Q.jsx)(Ct,{}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d?(0,Q.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:d}):null,(0,Q.jsx)(St,{title:n.understandingTitle,description:n.understandingDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:E.imageModel,fallbackValues:E.imageModelFallbacks,options:N,emptyLabel:n.noModelSelected,onValueChange:e=>D(t=>({...t,imageModel:e,imageModelFallbacks:e?t.imageModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>D(t=>({...t,imageModelFallbacks:e}))}),(0,Q.jsx)(St,{title:n.generationTitle,description:n.generationDescription,primaryLabel:n.primaryModelLabel,fallbackLabel:n.fallbackModelsLabel,fallbackPlaceholder:n.fallbackModelsPlaceholder,value:E.imageGenerationModel,fallbackValues:E.imageGenerationModelFallbacks,options:P,emptyLabel:n.noModelSelected,onValueChange:e=>D(t=>({...t,imageGenerationModel:e,imageGenerationModelFallbacks:e?t.imageGenerationModelFallbacks.filter(t=>t!==e):[]})),onFallbackValuesChange:e=>D(t=>({...t,imageGenerationModelFallbacks:e}))}),(0,Q.jsxs)(`section`,{className:`rounded-lg bg-surface-base p-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.runtimeTuningTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.runtimeTuningHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,220px)_minmax(0,1fr)]`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs font-medium text-fg-muted`,children:[n.timeoutLabel,(0,Q.jsx)(`input`,{type:`number`,min:1,value:E.imageGenerationModelTimeoutMs,onChange:e=>D(t=>({...t,imageGenerationModelTimeoutMs:e.target.value})),placeholder:`120000`,className:`h-10 rounded-lg border border-edge bg-surface-subtle px-3 text-sm font-normal text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`})]}),(0,Q.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-subtle px-3 py-2.5 text-sm text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:E.imageGenerationModelAutoProviderFallback,onChange:e=>D(t=>({...t,imageGenerationModelAutoProviderFallback:e.target.checked})),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:n.autoFallbackLabel}),(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs leading-relaxed text-fg-muted`,children:n.autoFallbackHint})]})]})]})]}),(0,Q.jsx)(at,{icon:ce,showLabel:n.providersTitle,hideLabel:n.providersTitle,defaultOpen:w,children:h.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.providersEmpty}):(0,Q.jsx)(rt,{summaries:h,credDraft:T.credDraft,credBaseline:T.credBaseline,credDirty:T.credDirty,credSaving:T.credSaving,credError:T.credError,credSavedFlash:T.credSavedFlash,credNoopFlash:T.credNoopFlash,updateCredRow:T.updateCredRow,onDiscardCredentials:T.onDiscardCredentials,onSaveCredentials:()=>void T.saveCredentials(n.credentialsSaveError),extensionIds:m,showExtensionLinks:!0,showImageModelsLink:!1,hideActions:!0,language:e,apiKeyLinkLabels:F,messages:M})})]}):(0,Q.jsx)(`div`,{className:`w-full text-sm text-fg-muted`,children:e===`zh`?`请先登录网关。`:`Connect to a gateway to continue.`})}var Et=Be;function Dt(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`groq`:return`(GROQ_API_KEY)`;default:return``}}function Ot(e){switch(e){case`alibaba`:return`(DASHSCOPE_API_KEY)`;case`openai`:return`(OPENAI_API_KEY)`;case`minimax`:return`(MINIMAX_API_KEY)`;default:return``}}function kt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function At(){return i(P,Be)}function jt(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Mt(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}var Nt=[{id:`paraformer-v2`,name:`Paraformer v2`},{id:`paraformer-v1`,name:`Paraformer v1`}],Pt=[{id:`whisper-1`,name:`Whisper-1`}],Ft=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}],It=[{id:`tts-1`,name:`TTS-1`},{id:`tts-1-hd`,name:`TTS-1 HD`}],Lt=[{id:`alloy`,name:`Alloy`},{id:`echo`,name:`Echo`}],Rt=[{id:`qwen-tts`,name:`Qwen TTS`},{id:`qwen3-tts-flash`,name:`Qwen3 TTS Flash`}],zt=[{id:`Cherry`,name:`Cherry`},{id:`longxiaochun`,name:`Long Xiao Chun`}],Bt=[{id:`en-US-MichelleNeural`,name:`Michelle (US English)`},{id:`zh-CN-XiaoxiaoNeural`,name:`Xiaoxiao (Chinese)`}],Vt=[{id:`speech-2.8-hd`,name:`Speech 2.8 HD (Recommended)`},{id:`speech-2.8-turbo`,name:`Speech 2.8 Turbo (Fast)`}],Ht=[{id:`male-qn-qingse`,name:`Male Qingse (青涩男声)`},{id:`female-shaonv`,name:`Female Shaonv (少女音)`}],Ut=[{id:`piper`,command:`piper --model /path/to/voice.onnx --output_file "{{OutputPath}}"`,outputFormat:`wav`},{id:`sherpa-onnx`,command:`sherpa-onnx-offline-tts --text "{{Text}}" --output-filename "{{OutputPath}}"`,outputFormat:`wav`},{id:`mlx-audio`,command:`python -m mlx_audio.tts.generate --text "{{Text}}" --file_prefix "{{OutputBase}}"`,outputFormat:`wav`}];function Wt(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Gt(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function Kt(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function qt(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function Jt(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Yt(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function Xt(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Zt(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function Qt(){let e=a(o(e=>e.language)).voiceSettings,t=!!s(e=>e.token),[n,r]=(0,Z.useReducer)(Zt,{form:null,baseline:null}),i=n.form,c=n.baseline,[l,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),y=(0,Z.useRef)(!1),b=(0,Z.useRef)({parsed:null,models:void 0}),{data:x,error:S,isLoading:C,mutate:w}=fe(t),{data:T,error:E,isLoading:D,mutate:O}=f(t?d(`/api/voice/models`):null,Qe,{revalidateOnFocus:!1}),{data:k,error:A,isLoading:j}=f(t?d(`/api/voice/providers`):null,et,{revalidateOnFocus:!1}),{data:M,error:N,isLoading:P}=f(t?d(`/api/voice/stt-providers`):null,qe,{revalidateOnFocus:!1}),F=(0,Z.useMemo)(()=>k?.providers??[],[k]),I=(0,Z.useMemo)(()=>M?.providers??[],[M]),L=(0,Z.useMemo)(()=>x?.payload?.config===void 0?null:$e(x.payload.config),[x]),R=(0,Z.useMemo)(()=>!i||!c?!1:JSON.stringify(i)!==JSON.stringify(c),[i,c]);t?L!==null&&T!==void 0&&!y.current&&(b.current.parsed!==L||b.current.models!==T)&&(b.current={parsed:L,models:T},r({type:`sync`,value:L}),p(T)):(b.current.parsed!==null||b.current.models!==void 0)&&(b.current={parsed:null,models:void 0},r({type:`reset`}),p(null),y.current=!1);let z=!!(t&&(L===null||T===void 0||k===void 0||M===void 0)&&(C||D||j||P)),B=S instanceof Error?S.message:S?String(S):E instanceof Error?E.message:E?String(E):A instanceof Error?A.message:A?String(A):N instanceof Error?N.message:N?String(N):null,V=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),H=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,alibaba:{...t.stt.alibaba,...e}}}:null})},[]),U=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,stt:{...t.stt,openai:{...t.stt.openai,...e}}}:null})},[]),W=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!0,order:[`alibaba`,`openai`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ee=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),te=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,alibaba:{...t.tts.alibaba,...e}}}:null})},[]),ne=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,openai:{...t.tts.openai,...e}}}:null})},[]),G=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,edge:{...t.tts.edge,...e}}}:null})},[]),re=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,minimax:{...t.tts.minimax,...e}}}:null})},[]),ie=(0,Z.useCallback)(e=>{y.current=!0,r({type:`update`,updater:t=>t?{...t,tts:{...t.tts,"tts-local-cli":{...t.tts[`tts-local-cli`],...e}}}:null})},[]);if(lt({id:`voice`,dirty:R,saving:m,save:(0,Z.useCallback)(async()=>{if(!(!i||m)){h(!0),_(null);try{await tt(i),r({type:`saved`,value:i}),y.current=!1,u({type:`success`,title:e.saved})}catch(t){_(t instanceof Error?t.message:e.saveError)}finally{h(!1)}}},[i,m,e.saveError]),discard:(0,Z.useCallback)(()=>{c&&(y.current=!1,r({type:`discard`}),_(null))},[c])}),!t)return(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e.needToken})});if(z)return(0,Q.jsx)(Ke,{rows:4});if(!i||l===null)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g??B??e.loadError}),(0,Q.jsx)(v,{type:`button`,variant:`secondary`,onClick:()=>{w(),O()},children:e.retry})]});let K=i.stt,ae=i.tts,oe=Jt(e);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g}):null,(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)($t,{v:e,stt:K,tts:ae}),(0,Q.jsx)(tn,{v:e,apiKeyLabels:oe,stt:K,models:l,sttProviders:I,updateStt:V,updateSttAlibaba:H,updateSttOpenai:U,updateSttFallback:W}),(0,Q.jsx)(sn,{v:e,apiKeyLabels:oe,tts:ae,models:l,ttsProviders:F,updateTts:ee,updateTtsAlibaba:te,updateTtsOpenai:ne,updateTtsEdge:G,updateTtsMinimax:re,updateTtsLocalCli:ie})]}),(0,Q.jsxs)(`div`,{className:`rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10`,children:[(0,Q.jsxs)(`p`,{className:`text-sm text-fg`,children:[(0,Q.jsx)(`strong`,{className:`text-accent`,children:e.notes.title}),` `,e.notes.duration]}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:e.notes.envVars})]})]})}function $t(e){let t=(0,X.c)(39),{v:n,stt:r,tts:i}=e,a=i.provider===`openai`?i.openai?.voice:i.provider===`alibaba`?i.alibaba?.voice:i.provider===`minimax`?i.minimax?.voice:i.provider===`edge`?i.edge?.voice:void 0,o;t[0]===n.overview.title?o=t[1]:(o=(0,Q.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.overview.title}),t[0]=n.overview.title,t[1]=o);let s;t[2]===n.overview.description?s=t[3]:(s=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.overview.description}),t[2]=n.overview.description,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]!==r.enabled||t[8]!==r.provider||t[9]!==n?(l=r.enabled?`${n.overview.ready} · ${Wt(r.provider,n)}`:n.overview.off,t[7]=r.enabled,t[8]=r.provider,t[9]=n,t[10]=l):l=t[10];let u;t[11]!==r.enabled||t[12]!==l||t[13]!==n.overview.input?(u=(0,Q.jsx)(en,{label:n.overview.input,value:l,ready:r.enabled}),t[11]=r.enabled,t[12]=l,t[13]=n.overview.input,t[14]=u):u=t[14];let d;t[15]!==i.enabled||t[16]!==i.trigger||t[17]!==n?(d=i.enabled?Kt(i.trigger,n):n.overview.off,t[15]=i.enabled,t[16]=i.trigger,t[17]=n,t[18]=d):d=t[18];let f=i.enabled&&i.trigger!==`off`,p;t[19]!==d||t[20]!==f||t[21]!==n.overview.replies?(p=(0,Q.jsx)(en,{label:n.overview.replies,value:d,ready:f}),t[19]=d,t[20]=f,t[21]=n.overview.replies,t[22]=p):p=t[22];let m;t[23]!==a||t[24]!==i.enabled||t[25]!==i.provider||t[26]!==n?(m=i.enabled?`${Gt(i.provider,n)}${a?` · ${a}`:``}`:n.overview.off,t[23]=a,t[24]=i.enabled,t[25]=i.provider,t[26]=n,t[27]=m):m=t[27];let h;t[28]!==m||t[29]!==i.enabled||t[30]!==n.overview.voice?(h=(0,Q.jsx)(en,{label:n.overview.voice,value:m,ready:i.enabled}),t[28]=m,t[29]=i.enabled,t[30]=n.overview.voice,t[31]=h):h=t[31];let g;t[32]!==h||t[33]!==u||t[34]!==p?(g=(0,Q.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,p,h]}),t[32]=h,t[33]=u,t[34]=p,t[35]=g):g=t[35];let _;return t[36]!==g||t[37]!==c?(_=(0,Q.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[c,g]}),t[36]=g,t[37]=c,t[38]=_):_=t[38],_}function en(e){let t=(0,X.c)(10),{label:n,value:r,ready:a}=e,o;t[0]===n?o=t[1]:(o=(0,Q.jsx)(`div`,{className:`text-xs text-fg-muted`,children:n}),t[0]=n,t[1]=o);let s=a?`text-fg`:`text-fg-muted`,c;t[2]===s?c=t[3]:(c=i(`mt-1 text-sm font-medium`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,Q.jsx)(`div`,{className:c,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function tn(e){let t=(0,X.c)(46),{v:n,apiKeyLabels:r,stt:a,models:o,sttProviders:s,updateStt:c,updateSttAlibaba:l,updateSttOpenai:u,updateSttFallback:d}=e,f=o?.stt?.alibaba?.length?o.stt.alibaba:Nt,p=o?.stt?.openai?.length?o.stt.openai:Pt,m;if(t[0]!==s){let e=new Set;m=[];for(let t of s)e.has(t.id)||(e.add(t.id),m.push(t));t[0]=s,t[1]=m}else m=t[1];let h=m,g,_,v,y,b;if(t[2]!==f||t[3]!==r||t[4]!==p||t[5]!==h||t[6]!==a||t[7]!==c||t[8]!==l||t[9]!==d||t[10]!==u||t[11]!==n){let e=h.find(e=>e.id===a.provider),o=a.providers?.[a.provider],s=typeof o?.apiKey==`string`?o.apiKey:``,m=typeof o?.model==`string`?o.model:``,x={...a.provider===`alibaba`?a.alibaba??{}:{},...a.provider===`openai`?a.openai??{}:{},...o??{}},S=(e?.fields??[]).filter(on),C;t[17]!==a.provider||t[18]!==a.providers||t[19]!==c?(C=e=>{c({providers:{...a.providers??{},[a.provider]:{...a.providers?.[a.provider]??{},...e}}})},t[17]=a.provider,t[18]=a.providers,t[19]=c,t[20]=C):C=t[20];let w=C;y=`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`;let T;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(Ue,{className:`size-4 text-accent`,strokeWidth:1.75}),t[21]=T):T=t[21];let E;t[22]===n.stt.title?E=t[23]:(E=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[22]=n.stt.title,t[23]=E);let D;t[24]===n.stt.description?D=t[25]:(D=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[24]=n.stt.description,t[25]=D),t[26]!==E||t[27]!==D?(b=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[26]=E,t[27]=D,t[28]=b):b=t[28],g=`space-y-4`;let O;t[29]===c?O=t[30]:(O=e=>c({enabled:e}),t[29]=c,t[30]=O),t[31]!==a.enabled||t[32]!==O||t[33]!==n.overview.off||t[34]!==n.overview.ready||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(_=(0,Q.jsx)(cn,{checked:a.enabled,title:n.stt.enable,description:n.stt.enableDesc,onLabel:n.overview.ready,offLabel:n.overview.off,onChange:O}),t[31]=a.enabled,t[32]=O,t[33]=n.overview.off,t[34]=n.overview.ready,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=_):_=t[37],v=a.enabled?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:n.stt.provider}),(0,Q.jsx)(J,{className:At(),value:a.provider,onChange:e=>c({provider:e.target.value}),children:h.map(e=>(0,Q.jsxs)(q,{value:e.id,children:[Wt(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:n.stt.model}),a.provider===`alibaba`?(0,Q.jsx)(J,{className:At(),value:a.alibaba?.model??``,onChange:e=>l({model:e.target.value}),children:f.map(an)}):a.provider===`openai`?(0,Q.jsx)(J,{className:At(),value:a.openai?.model??``,onChange:e=>u({model:e.target.value}),children:p.map(rn)}):a.provider===`groq`?(0,Q.jsx)(J,{className:At(),value:m||Ft[0].id,onChange:e=>w({model:e.target.value}),children:Ft.map(nn)}):(0,Q.jsx)(`input`,{className:kt(),value:m,onChange:e=>w({model:e.target.value}),placeholder:a.provider})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:n.stt.apiKey}),(0,Q.jsx)(nt,{kind:`stt`,providerId:a.provider,fieldId:`voice-stt-${a.provider}-api-key`,value:a.provider===`alibaba`?a.alibaba?.apiKey??``:a.provider===`openai`?a.openai?.apiKey??``:s,onChange:e=>{a.provider===`alibaba`?l({apiKey:e}):a.provider===`openai`?u({apiKey:e}):w({apiKey:e})},labels:r,placeholder:a.provider===`groq`?`gsk_...`:`sk-...`}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.stt.apiKeyDesc,Dt(a.provider)?` ${Dt(a.provider)}`:``]})]})]}),S.length>0?(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:S.map(e=>(0,Q.jsx)(ln,{field:e,value:Yt(x,e),onChange:t=>w({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Et},e.key))}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a.fallback?.enabled??!0,onChange:e=>d({enabled:e.target.checked})})]})]}):null,t[2]=f,t[3]=r,t[4]=p,t[5]=h,t[6]=a,t[7]=c,t[8]=l,t[9]=d,t[10]=u,t[11]=n,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b}else g=t[12],_=t[13],v=t[14],y=t[15],b=t[16];let x;t[38]!==g||t[39]!==_||t[40]!==v?(x=(0,Q.jsxs)(`div`,{className:g,children:[_,v]}),t[38]=g,t[39]=_,t[40]=v,t[41]=x):x=t[41];let S;return t[42]!==y||t[43]!==b||t[44]!==x?(S=(0,Q.jsxs)(`section`,{className:y,children:[b,x]}),t[42]=y,t[43]=b,t[44]=x,t[45]=S):S=t[45],S}function nn(e){return(0,Q.jsx)(q,{value:e.id,children:e.name},e.id)}function rn(e){return(0,Q.jsx)(q,{value:e.id,children:e.name},e.id)}function an(e){return(0,Q.jsx)(q,{value:e.id,children:e.name},e.id)}function on(e){return e.key!==`apiKey`&&e.key!==`model`}function sn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:a,updateTts:o,updateTtsAlibaba:s,updateTtsOpenai:c,updateTtsEdge:l,updateTtsMinimax:u,updateTtsLocalCli:d}){let f=r?.tts?.openai?.length?r.tts.openai:It,p=r?.ttsVoices?.openai?.length?r.ttsVoices.openai:Lt,m=r?.tts?.alibaba?.length?r.tts.alibaba:Rt,h=r?.ttsVoices?.alibaba?.length?r.ttsVoices.alibaba:zt,g=r?.ttsVoices?.edge?.length?r.ttsVoices.edge:Bt,_=r?.tts?.minimax?.length?r.tts.minimax:Vt,y=r?.ttsVoices?.minimax?.length?r.ttsVoices.minimax:Ht,[b,x]=(0,Z.useState)(e.tts.test.sampleText),[S,w]=(0,Z.useState)({status:`idle`}),T=(0,Z.useRef)(null),E=(0,Z.useRef)(null),D=(0,Z.useCallback)(()=>{T.current?.pause(),T.current=null,E.current&&=(URL.revokeObjectURL(E.current),null)},[]),k=(0,Z.useMemo)(()=>{let e=new Set,t=[];for(let n of a)e.has(n.id)||(e.add(n.id),t.push(n));return t},[a]),A=k.find(e=>e.id===n.provider),j=n.providers?.[n.provider],M={...n.provider===`openai`?n.openai??{}:{},...n.provider===`alibaba`?n.alibaba??{}:{},...n.provider===`edge`?n.edge??{}:{},...n.provider===`minimax`?n.minimax??{}:{},...n.provider===`tts-local-cli`?n[`tts-local-cli`]??{}:{},...j??{}},N=(A?.fields??[]).filter(e=>![`apiKey`,`model`,`voice`].includes(e.key)),P=!!A?.diagnostics.requiresApiKey,F=!!A?.configured||!P,I=n.enabled?F?`ready`:`action`:`muted`,L=n.provider===`openai`?n.openai?.model:n.provider===`alibaba`?n.alibaba?.model:n.provider===`minimax`?n.minimax?.model:void 0,R=n.provider===`openai`?n.openai?.voice:n.provider===`alibaba`?n.alibaba?.voice:n.provider===`minimax`?n.minimax?.voice:n.provider===`edge`?n.edge?.voice:void 0;(0,Z.useEffect)(()=>()=>D(),[D]);let z=(0,Z.useCallback)(e=>{o({provider:e}),w({status:`idle`})},[o]),B=(0,Z.useCallback)(async()=>{let t=b.trim();if(!t){w({status:`error`,message:e.tts.test.emptyText});return}D(),w({status:`loading`});try{let r=await Je({text:t,provider:n.provider,providerConfig:M,...L?{model:L}:{},...R?{voice:R}:{}}),i=Mt(r.audio,r.mimeType);E.current=i;let a=new Audio(i);T.current=a;let o=[r.provider,r.format,r.latencyMs===void 0?void 0:`${r.latencyMs}ms`,jt(r.audioSize)].filter(Boolean).join(` · `);a.addEventListener(`ended`,()=>w({status:`done`,summary:o}),{once:!0}),a.addEventListener(`error`,()=>w({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await a.play(),w({status:`playing`,summary:o})}catch(e){D(),w({status:`error`,message:e instanceof Error?e.message:String(e)})}},[L,R,M,D,b,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]),V=(0,Z.useCallback)(e=>{o({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,o]),H=(0,Z.useCallback)((e,t)=>{let r={[e.key]:t};V(r),n.provider===`openai`&&e.key===`baseUrl`?c(r):n.provider===`minimax`&&(e.key===`baseUrl`||e.key===`groupId`)?u(r):n.provider===`edge`&&e.key===`lang`&&l(r)},[n.provider,V,l,u,c]);return(0,Q.jsxs)(`section`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:[(0,Q.jsxs)(`div`,{className:`mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(O,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(cn,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onLabel:e.overview.ready,offLabel:e.overview.off,onChange:e=>o({enabled:e})}),(0,Q.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2.5 text-sm`,I===`ready`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-800 dark:text-emerald-100`:I===`action`?`border-amber-300/50 bg-amber-50 text-amber-900 dark:border-amber-300/30 dark:bg-amber-400/10 dark:text-amber-100`:`border-edge bg-surface-panel text-fg-muted`),children:[(0,Q.jsx)(`div`,{className:`font-medium text-fg`,children:e.tts.statusTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:n.enabled?F?`${e.tts.statusReady} ${Gt(n.provider,e)}${R?` · ${R}`:``}`:`${e.tts.statusNeedsSetup} ${Gt(n.provider,e)} · ${A?.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.statusOff})]}),n.enabled?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:e.tts.trigger}),(0,Q.jsxs)(J,{className:At(),value:n.trigger,onChange:e=>o({trigger:e.target.value}),children:[(0,Q.jsx)(q,{value:`off`,children:e.tts.triggerOff}),(0,Q.jsx)(q,{value:`inbound`,children:e.tts.triggerInbound}),(0,Q.jsx)(q,{value:`tagged`,children:e.tts.triggerTagged}),(0,Q.jsx)(q,{value:`always`,children:e.tts.triggerAlways})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:e.tts.provider}),(0,Q.jsx)(J,{className:At(),value:n.provider,onChange:e=>z(e.target.value),children:k.map(t=>(0,Q.jsx)(q,{value:t.id,children:Gt(t.id,e)},t.id))}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[A?.configured?e.tts.configured:A?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${A.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,A?.description??qt(n.provider,e)]})]})]}),(0,Q.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!F||n.provider===`tts-local-cli`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,Q.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,Q.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.provider===`openai`||n.provider===`alibaba`||n.provider===`minimax`?(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:e.stt.apiKey}),(0,Q.jsx)(nt,{kind:`tts`,providerId:n.provider,fieldId:`voice-tts-${n.provider}-api-key`,value:n.provider===`openai`?n.openai?.apiKey??``:n.provider===`alibaba`?n.alibaba?.apiKey??``:n.minimax?.apiKey??``,onChange:e=>{n.provider===`openai`?c({apiKey:e}):n.provider===`alibaba`?s({apiKey:e}):u({apiKey:e})},labels:t,placeholder:n.provider===`minimax`?`eyJ...`:`sk-...`}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.stt.apiKeyDesc,Ot(n.provider)?` ${Ot(n.provider)}`:``]})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:e.stt.model}),(0,Q.jsx)(J,{className:At(),value:n.provider===`openai`?n.openai?.model??``:n.provider===`alibaba`?n.alibaba?.model??``:n.minimax?.model??``,onChange:e=>{n.provider===`openai`?c({model:e.target.value}):n.provider===`alibaba`?s({model:e.target.value}):u({model:e.target.value})},children:(n.provider===`openai`?f:n.provider===`alibaba`?m:_).map(e=>(0,Q.jsx)(q,{value:e.id,children:e.name},e.id))})]}),(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:e.tts.voice}),(0,Q.jsx)(J,{className:At(),value:n.provider===`openai`?n.openai?.voice??``:n.provider===`alibaba`?n.alibaba?.voice??``:n.minimax?.voice??``,onChange:e=>{n.provider===`openai`?c({voice:e.target.value}):n.provider===`alibaba`?s({voice:e.target.value}):u({voice:e.target.value})},children:(n.provider===`openai`?p:n.provider===`alibaba`?h:y).map(e=>(0,Q.jsx)(q,{value:e.id,children:e.name},e.id))})]})]}):null,n.provider===`edge`?(0,Q.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,Et),children:[(0,Q.jsx)($,{children:e.tts.voice}),(0,Q.jsx)(J,{className:At(),value:n.edge?.voice??``,onChange:e=>l({voice:e.target.value}),children:g.map(e=>(0,Q.jsx)(q,{value:e.id,children:e.name},e.id))}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.edgeHint})]}):null,n.provider===`tts-local-cli`?(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Q.jsx)($,{children:e.tts.localCli.preset}),(0,Q.jsxs)(J,{className:At(),value:``,onChange:e=>{let t=Ut.find(t=>t.id===e.target.value);t&&d({command:t.command,outputFormat:t.outputFormat})},children:[(0,Q.jsx)(q,{value:``,children:e.tts.localCli.presetPlaceholder}),Ut.map(e=>(0,Q.jsx)(q,{value:e.id,children:e.id},e.id))]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.presetDesc})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Q.jsx)($,{children:e.tts.localCli.command}),(0,Q.jsx)(`input`,{className:i(kt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.command??``,onChange:e=>d({command:e.target.value}),placeholder:e.tts.localCli.commandPlaceholder}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.commandDesc})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)($,{children:e.tts.localCli.cwd}),(0,Q.jsx)(`input`,{className:i(kt(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,value:n[`tts-local-cli`]?.cwd??``,onChange:e=>d({cwd:e.target.value}),placeholder:`/path/to/cwd`}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.cwdDesc})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)($,{children:e.tts.localCli.outputFormat}),(0,Q.jsxs)(J,{className:At(),value:n[`tts-local-cli`]?.outputFormat??`wav`,onChange:e=>d({outputFormat:e.target.value}),children:[(0,Q.jsx)(q,{value:`wav`,children:`wav`}),(0,Q.jsx)(q,{value:`mp3`,children:`mp3`}),(0,Q.jsx)(q,{value:`opus`,children:`opus`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.outputFormatDesc})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,Q.jsx)($,{children:e.tts.localCli.timeoutMs}),(0,Q.jsx)(`input`,{className:kt(),type:`number`,min:0,step:1e3,value:typeof n[`tts-local-cli`]?.timeoutMs==`number`?String(n[`tts-local-cli`].timeoutMs):``,onChange:e=>{let t=e.target.value.trim();if(t===``){d({timeoutMs:void 0});return}let n=Number(t);Number.isFinite(n)&&n>=0&&d({timeoutMs:n})},placeholder:`30000`}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.localCli.timeoutMsDesc})]}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:e.tts.localCli.hint})]}):null,N.length>0?(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:N.map(e=>(0,Q.jsx)(ln,{field:e,value:Yt(M,e),onChange:t=>H(e,t),className:e.type===`textarea`?`sm:col-span-2`:Et},e.key))}):null]})]}),(0,Q.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsxs)(v,{type:`button`,variant:`primary`,onClick:()=>void B(),disabled:S.status===`loading`,className:`h-9`,children:[S.status===`loading`?(0,Q.jsx)(C,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ve,{className:`size-4`}),S.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,Q.jsxs)(v,{type:`button`,variant:`secondary`,onClick:()=>{D(),w(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:S.status!==`playing`,className:`h-9`,children:[(0,Q.jsx)(te,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,Q.jsx)(`textarea`,{className:i(kt(),`mt-3 min-h-20 resize-y`),value:b,onChange:e=>x(e.target.value),maxLength:1e3}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,Q.jsxs)(`span`,{className:`text-fg-subtle`,children:[b.length,`/1000`]}),S.status===`playing`||S.status===`done`?(0,Q.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[S.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,S.summary]}):null,S.status===`error`?(0,Q.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:S.message}):null]})]})]}):null]})]})}function cn(e){let t=(0,X.c)(33),{checked:n,title:r,description:a,onLabel:o,offLabel:s,onChange:c}=e,l;t[0]!==n||t[1]!==c?(l=()=>c(!n),t[0]=n,t[1]=c,t[2]=l):l=t[2];let u=n?`bg-accent/10 text-fg ring-1 ring-accent/45 dark:bg-accent/15`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,d;t[3]===u?d=t[4]:(d=i(`group flex w-full items-center justify-between gap-4 rounded-2xl px-4 py-3 text-left shadow-surface transition-colors`,b,u),t[3]=u,t[4]=d);let f=n?`bg-accent text-white`:`bg-surface-hover text-fg-muted`,p;t[5]===f?p=t[6]:(p=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,f),t[5]=f,t[6]=p);let m=n?o:s,h;t[7]!==p||t[8]!==m?(h=(0,Q.jsx)(`span`,{className:p,children:m}),t[7]=p,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==h||t[11]!==r?(g=(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:[r,h]}),t[10]=h,t[11]=r,t[12]=g):g=t[12];let _;t[13]===a?_=t[14]:(_=(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:a}),t[13]=a,t[14]=_);let v;t[15]!==g||t[16]!==_?(v=(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[g,_]}),t[15]=g,t[16]=_,t[17]=v):v=t[17];let y=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,x;t[18]===y?x=t[19]:(x=i(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,y),t[18]=y,t[19]=x);let S=n?`translate-x-5`:`translate-x-0.5`,C;t[20]===S?C=t[21]:(C=i(`size-5 rounded-full bg-white shadow-surface transition-transform`,S),t[20]=S,t[21]=C);let w;t[22]===C?w=t[23]:(w=(0,Q.jsx)(`span`,{className:C}),t[22]=C,t[23]=w);let T;t[24]!==x||t[25]!==w?(T=(0,Q.jsx)(`span`,{className:x,"aria-hidden":!0,children:w}),t[24]=x,t[25]=w,t[26]=T):T=t[26];let E;return t[27]!==n||t[28]!==l||t[29]!==v||t[30]!==T||t[31]!==d?(E=(0,Q.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:l,className:d,children:[v,T]}),t[27]=n,t[28]=l,t[29]=v,t[30]=T,t[31]=d,t[32]=E):E=t[32],E}function ln(e){let t=(0,X.c)(36),{field:n,value:r,onChange:a,className:o}=e,s=`voice-schema-field-${n.key}`,c=n.description;if(n.type===`boolean`){let e;t[0]===o?e=t[1]:(e=i(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let s;t[2]===n.label?s=t[3]:(s=(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=s);let l;t[4]===c?l=t[5]:(l=c?(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,Q.jsxs)(`span`,{children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d=!!r,f;t[9]!==n||t[10]!==a?(f=e=>a(Xt(n,e.target.checked)),t[9]=n,t[10]=a,t[11]=f):f=t[11];let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:f}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==e||t[16]!==u||t[17]!==p?(m=(0,Q.jsxs)(`label`,{className:e,children:[u,p]}),t[15]=e,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}let l=typeof r==`boolean`?``:String(r),u;t[19]===o?u=t[20]:(u=i(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let d;t[21]===n.label?d=t[22]:(d=(0,Q.jsx)($,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==o||t[24]!==n||t[25]!==l||t[26]!==s||t[27]!==a?(f=n.type===`select`?(0,Q.jsx)(J,{id:s,className:At(),value:l,required:n.required,onChange:e=>a(Xt(n,e.target.value)),children:(n.options??[]).map(un)}):n.type===`textarea`?(0,Q.jsx)(`textarea`,{id:s,className:i(kt(),`min-h-24 resize-y`),value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Xt(n,e.target.value))}):n.type===`password`?(0,Q.jsx)(he,{id:s,className:o,value:l,onChange:e=>a(Xt(n,e)),placeholder:n.placeholder,labels:ke}):(0,Q.jsx)(`input`,{id:s,className:kt(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:l,required:n.required,placeholder:n.placeholder,onChange:e=>a(Xt(n,e.target.value))}),t[23]=o,t[24]=n,t[25]=l,t[26]=s,t[27]=a,t[28]=f):f=t[28];let p;t[29]===c?p=t[30]:(p=c?(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[29]=c,t[30]=p);let m;return t[31]!==u||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,Q.jsxs)(`div`,{className:u,children:[d,f,p]}),t[31]=u,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function un(e){return(0,Q.jsx)(q,{value:e.id,children:e.name},e.id)}function $(e){let t=(0,X.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function dn(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function fn(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await c(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),ge()}async function pn(e){let t=await c(d(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function mn(e){let t=(0,X.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function hn(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function gn(){return i(P,Be)}var _n=[`brave`,`tavily`,`bing`,`searxng`];function vn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var yn=F();function bn(){let e=a(o(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!s(e=>e.token),[c,l]=(0,Z.useReducer)(yn,{form:null,baseline:null}),d=c.form,f=c.baseline,[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),_=(0,Z.useRef)(!1),y=(0,Z.useRef)(null),{data:b,error:S,isLoading:C,mutate:w}=fe(r);x({enabled:r,parsed:(0,Z.useMemo)(()=>b?.payload?.config===void 0?null:dn(b.payload.config),[b]),dirty:_.current,trackedParsedRef:y,dispatch:l,onResetDirty:()=>{_.current=!1}});let T=!!(r&&C&&b===void 0&&!S),E=S instanceof Error?S.message:S?String(S):null,D=(0,Z.useMemo)(()=>!d||!f?!1:JSON.stringify(d)!==JSON.stringify(f),[d,f]),O=(0,Z.useCallback)(e=>{_.current=!0,l({type:`patch`,patch:e})},[]);return lt({id:`search`,dirty:D,saving:p,save:(0,Z.useCallback)(async()=>{if(!(!d||p)){m(!0),g(null);try{await fn(d),_.current=!1,l({type:`saved`,value:d}),u({type:`success`,title:t.saved})}catch(e){g(e instanceof Error?e.message:t.saveError)}finally{m(!1)}}},[d,p,t.saveError]),discard:(0,Z.useCallback)(()=>{f&&(_.current=!1,l({type:`discard`}),g(null))},[f])}),r?T?(0,Q.jsx)(Ke,{rows:3}):d?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h}):null,(0,Q.jsxs)(st,{children:[(0,Q.jsx)(ot,{icon:Re,title:t.sectionRegion,subtitle:t.sectionRegionHint}),(0,Q.jsx)(`div`,{className:`flex max-w-md flex-col gap-4`,children:(0,Q.jsx)(mn,{label:t.regionLabel,description:t.regionDesc,children:(0,Q.jsxs)(J,{className:gn(),value:d.regionMode,onChange:e=>O({regionMode:e.target.value}),children:[(0,Q.jsx)(q,{value:`auto`,children:t.regionAuto}),(0,Q.jsx)(q,{value:`cn`,children:t.regionCn}),(0,Q.jsx)(q,{value:`global`,children:t.regionGlobal})]})})})]}),(0,Q.jsx)(it,{children:(0,Q.jsxs)(st,{children:[(0,Q.jsx)(ot,{icon:Se,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,Q.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-4`,children:[(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:d.blocklistEnabled,onChange:e=>O({blocklistEnabled:e.target.checked})}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),(0,Q.jsx)(mn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,Q.jsx)(`textarea`,{className:i(hn(),`min-h-[6rem] font-mono text-xs`),value:d.blocklistDomains.join(`
2
2
  `),placeholder:t.blocklistDomainsPlaceholder,disabled:!d.blocklistEnabled,onChange:e=>{O({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})})]})]})}),(0,Q.jsxs)(st,{children:[(0,Q.jsx)(ot,{icon:Re,title:t.sectionSearch,subtitle:t.sectionSearchHint}),(0,Q.jsxs)(`div`,{className:`flex max-w-xl flex-col gap-6`,children:[(0,Q.jsx)(mn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:50,className:hn(),value:d.maxResults,onChange:e=>O({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.providersTitle}),d.providers.map((n,r)=>(0,Q.jsx)(xn,{row:n,providerIndex:r,labels:t,secretLabels:we(e.providersSettings),onChange:e=>{let t=[...d.providers];t[r]=e,O({providers:t})},onRemove:()=>{O({providers:d.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,Q.jsxs)(v,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>O({providers:[...d.providers,vn()]}),children:[(0,Q.jsx)(N,{className:`size-4`}),t.addProvider]})]})]})]}),(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:t.footerHint})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h??E??t.loadError}),(0,Q.jsx)(v,{type:`button`,variant:`secondary`,onClick:()=>void w(),children:n.refresh})]}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})})}function xn(e){let t=(0,X.c)(54),{row:n,providerIndex:r,labels:a,secretLabels:o,onChange:s,onRemove:c}=e,l;t[0]===r?l=t[1]:(l=()=>pn(r).then(Sn),t[0]=r,t[1]=l);let u=l,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(gn(),`min-w-[8rem]`),t[2]=d):d=t[2];let f=n.type,p;t[3]!==s||t[4]!==n?(p=e=>s({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=s,t[4]=n,t[5]=p):p=t[5];let m;t[6]===a.providerTypes?m=t[7]:(m=_n.map(e=>(0,Q.jsx)(q,{value:e,children:a.providerTypes[e]},e)),t[6]=a.providerTypes,t[7]=m);let h;t[8]!==n.type||t[9]!==p||t[10]!==m?(h=(0,Q.jsx)(J,{className:d,value:f,onChange:p,children:m}),t[8]=n.type,t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==s||t[13]!==n?(g=e=>s({...n,disabled:e.target.checked}),t[12]=s,t[13]=n,t[14]=g):g=t[14];let _;t[15]!==n.disabled||t[16]!==g?(_=(0,Q.jsx)(`input`,{type:`checkbox`,className:`size-3.5 rounded border-edge`,checked:n.disabled,onChange:g}),t[15]=n.disabled,t[16]=g,t[17]=_):_=t[17];let y;t[18]!==a.disabled||t[19]!==_?(y=(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[_,a.disabled]}),t[18]=a.disabled,t[19]=_,t[20]=y):y=t[20];let b;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(B,{className:`size-4`}),t[21]=b):b=t[21];let x;t[22]===c?x=t[23]:(x=(0,Q.jsx)(v,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:c,children:b}),t[22]=c,t[23]=x);let S;t[24]!==x||t[25]!==y?(S=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y,x]}),t[24]=x,t[25]=y,t[26]=S):S=t[26];let C;t[27]!==S||t[28]!==h?(C=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[h,S]}),t[27]=S,t[28]=h,t[29]=C):C=t[29];let w;t[30]!==a.urlDesc||t[31]!==a.urlLabel||t[32]!==s||t[33]!==n?(w=n.type===`searxng`?(0,Q.jsx)(mn,{label:a.urlLabel,description:a.urlDesc,children:(0,Q.jsx)(`input`,{type:`url`,className:hn(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>s({...n,url:e.target.value})})}):null,t[30]=a.urlDesc,t[31]=a.urlLabel,t[32]=s,t[33]=n,t[34]=w):w=t[34];let T;t[35]!==s||t[36]!==n?(T=e=>s({...n,apiKey:e}),t[35]=s,t[36]=n,t[37]=T):T=t[37];let E;t[38]!==a.keyPlaceholder||t[39]!==a.keyPlaceholderMasked||t[40]!==a.saveError||t[41]!==u||t[42]!==n.apiKey||t[43]!==o||t[44]!==T?(E=(0,Q.jsx)(he,{value:n.apiKey,onChange:T,placeholder:a.keyPlaceholder,labels:o,reveal:u,loadFailedLabel:a.saveError,notInConfigFile:a.keyPlaceholderMasked}),t[38]=a.keyPlaceholder,t[39]=a.keyPlaceholderMasked,t[40]=a.saveError,t[41]=u,t[42]=n.apiKey,t[43]=o,t[44]=T,t[45]=E):E=t[45];let D;t[46]!==a.apiKeyDesc||t[47]!==a.apiKeyLabel||t[48]!==E?(D=(0,Q.jsx)(mn,{label:a.apiKeyLabel,description:a.apiKeyDesc,children:E}),t[46]=a.apiKeyDesc,t[47]=a.apiKeyLabel,t[48]=E,t[49]=D):D=t[49];let O;return t[50]!==C||t[51]!==w||t[52]!==D?(O=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/70 p-4 shadow-surface`,children:[C,w,D]}),t[50]=C,t[51]=w,t[52]=D,t[53]=O):O=t[53],O}function Sn(e){return e.apiKey??null}function Cn(){let e=(0,X.c)(31),t=s(On),n=!!t,{data:r,isLoading:i}=fe(n),a;e[0]===n?a=e[1]:(a=n?d(`/api/providers/meta`):null,e[0]=n,e[1]=a);let o;e[2]===t?o=e[3]:(o=async e=>{let{payload:n}=await(await fetch(e,{headers:{Authorization:`Bearer ${t}`}})).json();return n?.providers??[]},e[2]=t,e[3]=o);let c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c={revalidateOnFocus:!1},e[4]=c):c=e[4];let{data:l,isLoading:u}=f(a,o,c),p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},e[5]=p):p=e[5];let{data:m,isLoading:h}=f(n?ze:null,Dn,p),g;e[6]===m?g=e[7]:(g=m===void 0?[]:m,e[6]=m,e[7]=g);let _=g,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[8]=v):v=e[8];let{data:y}=f(n?me:null,En,v),b;bb0:{if(!l||r===void 0){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[9]=t):t=e[9],b=t;break bb0}let t;e[10]!==r?.payload?.config||e[11]!==l||e[12]!==_?(t=de(l,Ce(r?.payload?.config),_),e[10]=r?.payload?.config,e[11]=l,e[12]=_,e[13]=t):t=e[13],b=t}let x=b,S;bb1:{if(!y){S=null;break bb1}let t;e[14]===y.config?t=e[15]:(t=Me(y.config),e[14]=y.config,e[15]=t),S=t}let C=S,w;if(e[16]!==x||e[17]!==C||e[18]!==l||e[19]!==_){w=[];let t=new Set((l??[]).filter(Tn).map(wn)),n;e[21]===C?n=e[22]:(n=new Set(C?Object.keys(C.providers):[]),e[21]=C,e[22]=n);let r=n;for(let e of x){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?C.providers[e.id]?.models?.length??0:_.filter(t=>t.provider===e.id).length;w.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(C){let t;e[23]===C.providers?t=e[24]:(t=Object.entries(C.providers),e[23]=C.providers,e[24]=t);for(let[e,n]of t)w.some(t=>t.id===e)||w.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[16]=x,e[17]=C,e[18]=l,e[19]=_,e[20]=w}else w=e[20];let T=w,E=i||u||h,D;return e[25]!==x||e[26]!==T||e[27]!==C||e[28]!==E||e[29]!==_?(D={cards:T,loading:E,builtinRows:x,customConfig:C,allModels:_},e[25]=x,e[26]=T,e[27]=C,e[28]=E,e[29]=_,e[30]=D):D=e[30],D}function wn(e){return e.id}function Tn(e){return e.configured}function En(){return Ee()}function Dn(){return He()}function On(e){return e.token}function kn(e){let t=(0,X.c)(16),{labels:n,onAdd:r,onManage:i}=e,{cards:a,loading:o}=Cn();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(G,{className:`h-6 w-48 max-w-full`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[e,(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3].map(jn)})]}),t[1]=n):n=t[1],n}let s;if(t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==i){let e=a.filter(An),o=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,c;t[7]===o?c=t[8]:(c=(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o}),t[7]=o,t[8]=c);let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(N,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=l):l=t[9];let u;t[10]!==n.addProvider||t[11]!==r?(u=(0,Q.jsxs)(v,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:r,children:[l,n.addProvider]}),t[10]=n.addProvider,t[11]=r,t[12]=u):u=t[12];let d;t[13]!==c||t[14]!==u?(d=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[c,u]}),t[13]=c,t[14]=u,t[15]=d):d=t[15],s=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,e.length===0?(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel/60 px-6 py-10 text-center shadow-surface`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,Q.jsxs)(v,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:r,children:[(0,Q.jsx)(N,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,Q.jsx)(Mn,{card:e,labels:n,onManage:()=>i(e.id,e.isCustom)},e.id))})]}),t[2]=a,t[3]=n,t[4]=r,t[5]=i,t[6]=s}else s=t[6];return s}function An(e){return e.configured}function jn(e){return(0,Q.jsx)(G,{className:`h-32 rounded-2xl`},e)}function Mn(e){let t=(0,X.c)(28),{card:n,labels:r,onManage:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=i(`group relative flex flex-col justify-between rounded-2xl bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Y.pressCard),t[0]=o):o=t[0];let s;t[1]===n.name?s=t[2]:(s=(0,Q.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[1]=n.name,t[2]=s);let c;t[3]!==n.isCustom||t[4]!==r.custom?(c=n.isCustom?(0,Q.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:r.custom}):null,t[3]=n.isCustom,t[4]=r.custom,t[5]=c):c=t[5];let l;t[6]!==s||t[7]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(j,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[9]=u):u=t[9];let d;t[10]===l?d=t[11]:(d=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,u]}),t[10]=l,t[11]=d);let f;t[12]!==n.modelCount||t[13]!==r.modelsCount||t[14]!==r.noModels?(f=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[12]=n.modelCount,t[13]=r.modelsCount,t[14]=r.noModels,t[15]=f):f=t[15];let p;t[16]===f?p=t[17]:(p=(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:f}),t[16]=f,t[17]=p);let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(Pe,{className:`size-3`,"aria-hidden":!0}),t[18]=m):m=t[18];let h;t[19]===r.manage?h=t[20]:(h=(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg opacity-0 transition-opacity group-hover:opacity-100`,children:[m,r.manage]}),t[19]=r.manage,t[20]=h);let g;t[21]!==h||t[22]!==p?(g=(0,Q.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between`,children:[p,h]}),t[21]=h,t[22]=p,t[23]=g):g=t[23];let _;return t[24]!==a||t[25]!==g||t[26]!==d?(_=(0,Q.jsxs)(`button`,{type:`button`,onClick:a,className:o,children:[d,g]}),t[24]=a,t[25]=g,t[26]=d,t[27]=_):_=t[27],_}async function Nn(e){let t=await l(d(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${t.status}`)}return(await t.json()).payload}async function Pn(e){let t=await l(d(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function Fn(e,t){let n=await l(d(`/api/auth/oauth-async/${encodeURIComponent(e)}/code`),{method:`POST`,body:JSON.stringify({code:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${n.status}`)}}async function In(e){let t=await l(d(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function Ln(e){let t=await l(d(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function Rn(e){let t=await l(d(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}var zn=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function Bn(e){let t=new Map;for(let e of zn)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}function Vn(e){let t=(0,X.c)(22),{open:n,onOpenChange:r,builtinRows:a,customConfig:o,labels:s,language:c,onSaved:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={type:`pick`},t[0]=u):u=t[0];let[d,f]=(0,Z.useState)(u),[m,h]=(0,Z.useState)(``),g;t[1]===r?g=t[2]:(g=e=>{e||window.setTimeout(()=>{f({type:`pick`}),h(``)},200),r(e)},t[1]=r,t[2]=g);let _=g,v;t[3]!==_||t[4]!==l?(v=()=>{l(),_(!1)},t[3]=_,t[4]=l,t[5]=v):v=t[5];let y=v,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(I,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Ne)}),t[6]=b):b=t[6];let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x=i(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,De),t[7]=x):x=t[7];let C;t[8]!==a||t[9]!==o||t[10]!==y||t[11]!==s||t[12]!==c||t[13]!==m||t[14]!==d.presetKey||t[15]!==d.providerId||t[16]!==d.type?(C=(0,Q.jsxs)(V,{children:[b,(0,Q.jsx)(z,{className:x,children:d.type===`pick`?(0,Q.jsx)(Un,{builtinRows:a,searchQuery:m,onSearchChange:h,labels:s,onPickBuiltin:e=>{let t=p(e);f(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>f({type:`custom`})}):d.type===`builtin`?(0,Q.jsx)(Wn,{providerId:d.providerId,builtinRows:a,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:y}):(0,Q.jsx)(qn,{initialPresetKey:d.presetKey,customConfig:o,labels:s,language:c,onBack:()=>f({type:`pick`}),onSaved:y})})]}),t[8]=a,t[9]=o,t[10]=y,t[11]=s,t[12]=c,t[13]=m,t[14]=d.presetKey,t[15]=d.providerId,t[16]=d.type,t[17]=C):C=t[17];let w;return t[18]!==_||t[19]!==n||t[20]!==C?(w=(0,Q.jsx)(S,{open:n,onOpenChange:_,children:C}),t[18]=_,t[19]=n,t[20]=C,t[21]=w):w=t[21],w}function Hn(e){let t=(0,X.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Y.press),t[0]=r):r=t[0];let a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(be,{className:`size-4`,"aria-hidden":!0}),t[1]=a):a=t[1];let o;return t[2]===n?o=t[3]:(o=(0,Q.jsx)(m,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:a})}),t[2]=n,t[3]=o),o}function Un(e){let t=(0,X.c)(42),{builtinRows:n,searchQuery:r,onSearchChange:a,labels:o,onPickBuiltin:s,onPickCustom:c}=e,l;t[0]===r?l=t[1]:(l=r.trim().toLowerCase(),t[0]=r,t[1]=l);let u=l,d;bb0:{if(!u){d=n;break bb0}let e;if(t[2]!==n||t[3]!==u){let r;t[5]===u?r=t[6]:(r=e=>{let t=w[e.id]?.aliases??[];return e.id.toLowerCase().includes(u)||e.name.toLowerCase().includes(u)||t.some(e=>e.toLowerCase().includes(u))},t[5]=u,t[6]=r),e=n.filter(r),t[2]=n,t[3]=u,t[4]=e}else e=t[4];d=e}let f=d,p;t[7]===f?p=t[8]:(p=Bn(f),t[7]=f,t[8]=p);let m=p,h;t[9]===o.step1Title?h=t[10]:(h=(0,Q.jsx)(E,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o.step1Title}),t[9]=o.step1Title,t[10]=h);let g;t[11]===o.close?g=t[12]:(g=(0,Q.jsx)(Hn,{label:o.close}),t[11]=o.close,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-edge-subtle px-5 py-4`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(Re,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]===a?y=t[18]:(y=e=>a(e.target.value),t[17]=a,t[18]=y);let x=o.searchPlaceholder,S;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,b),t[19]=S):S=t[19];let C;t[20]!==o.searchPlaceholder||t[21]!==r||t[22]!==y?(C=(0,Q.jsx)(`div`,{className:`px-5 pt-3`,children:(0,Q.jsxs)(`div`,{className:`relative`,children:[v,(0,Q.jsx)(`input`,{type:`search`,value:r,onChange:y,placeholder:x,autoComplete:`off`,autoFocus:!0,className:S})]})}),t[20]=o.searchPlaceholder,t[21]=r,t[22]=y,t[23]=C):C=t[23];let T;t[24]!==o.addCustom||t[25]!==o.customDescription||t[26]!==c||t[27]!==u?(T=u?null:(0,Q.jsxs)(`button`,{type:`button`,onClick:c,className:i(`mb-3 flex w-full items-center gap-3 rounded-xl border border-dashed border-edge-subtle bg-surface-panel/40 px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Y.press),children:[(0,Q.jsx)(pe,{className:`size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.addCustom}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:o.customDescription})]}),(0,Q.jsx)(Fe,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),t[24]=o.addCustom,t[25]=o.customDescription,t[26]=c,t[27]=u,t[28]=T):T=t[28];let D;t[29]!==f.length||t[30]!==m||t[31]!==o.categories||t[32]!==o.noResults||t[33]!==s?(D=f.length===0?(0,Q.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:o.noResults}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:zn.map(e=>{let t=m.get(e)??[];return t.length===0?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-1 px-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:o.categories[e]??e}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:t.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:i(`flex w-full items-center justify-between gap-2 rounded-lg px-3 py-2.5 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Y.press),children:[(0,Q.jsx)(`span`,{className:`truncate text-sm text-fg`,children:e.name}),e.configured?(0,Q.jsx)(j,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):null]},e.id))})]},e)})}),t[29]=f.length,t[30]=m,t[31]=o.categories,t[32]=o.noResults,t[33]=s,t[34]=D):D=t[34];let O;t[35]!==T||t[36]!==D?(O=(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-3`,children:[T,D]}),t[35]=T,t[36]=D,t[37]=O):O=t[37];let k;return t[38]!==C||t[39]!==O||t[40]!==_?(k=(0,Q.jsxs)(Q.Fragment,{children:[_,C,O]}),t[38]=C,t[39]=O,t[40]=_,t[41]=k):k=t[41],k}function Wn({providerId:e,builtinRows:t,labels:n,language:r,onBack:o,onSaved:s}){let c=t.find(t=>t.id===e),l=w[e],[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),y=(0,Z.useRef)(null),x=a(r).providersSettings,S=we(x),T=(0,Z.useMemo)(()=>D(e,r),[e,r]),O=c?.supportsApiKey!==!1,k=c?.supportsOAuth===!0,[A,M]=(0,Z.useState)(null),[N,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(`idle`),[L,R]=(0,Z.useState)(null),[z,B]=(0,Z.useState)(null),[V,H]=(0,Z.useState)(``),U=F===`waiting`||F===`waiting_code`;(0,Z.useEffect)(()=>{if(!A||!U)return;let e=window.setInterval(()=>{(async()=>{try{let t=await Pn(A);t.status===`waiting_auth`||t.status===`waiting_code`?(I(t.status===`waiting_code`?`waiting_code`:`waiting`),P(t.message??null),R(t.authUrl??null),B(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),I(`success`),P(t.message??x.saved),window.setTimeout(s,600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),I(`error`),P(t.error??t.message??x.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[A,U,s,x.revokeFailed,x.saved]),(0,Z.useEffect)(()=>()=>{A&&Ln(A).catch(()=>{})},[A]);let W=async()=>{I(`waiting`),P(x.oauthStarting),h(null);try{M((await Nn(e)).sessionId)}catch(e){I(`error`),P(e instanceof Error?e.message:x.revokeFailed)}},ee=async()=>{if(A){try{await In(A)}catch{}I(`idle`),P(null),M(null),R(null),B(null)}},te=async()=>{if(!(!A||!V.trim()))try{await Fn(A,V.trim()),H(``),P(x.oauthProcessingCode)}catch(e){I(`error`),P(e instanceof Error?e.message:x.revokeFailed)}},ne=async()=>{let t=u.trim();if(!(!t||!O)){p(!0),h(null);try{await Oe({[e]:t}),_(!0),window.setTimeout(s,600)}catch(e){h(e instanceof Error?e.message:n.saveError)}finally{p(!1)}}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Y.press),"aria-label":n.back,children:(0,Q.jsx)(Fe,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Q.jsx)(E,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:c?.name??e}),(0,Q.jsx)(Hn,{label:n.close})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 px-5 py-4`,children:[l?.description?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.description}):null,O?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,Q.jsx)(he,{id:`builtin-api-key`,value:u,onChange:d,placeholder:n.apiKeyPlaceholder,labels:S,inputRef:y,onKeyDown:e=>{e.key===`Enter`&&ne()}})]}):null,k?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:x.oauth}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:x.oauthHint})]}),(0,Q.jsxs)(v,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:U,onClick:()=>void W(),children:[U?(0,Q.jsx)(C,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,x.oauth]})]}),N?(0,Q.jsx)(`p`,{className:i(`text-xs`,F===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:N}):null,F===`waiting`||F===`waiting_code`?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[L?(0,Q.jsxs)(`a`,{href:L,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[x.openAuthPage,(0,Q.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,Q.jsx)(v,{type:`button`,variant:`secondary`,onClick:()=>void ee(),children:x.cancelOAuth})]}):null,z?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:z}):null,F===`waiting_code`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Q.jsx)(`input`,{type:`text`,value:V,onChange:e=>H(e.target.value),onKeyDown:e=>e.key===`Enter`&&void te(),placeholder:x.pasteRedirectUrl,className:i(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)}),(0,Q.jsx)(v,{type:`button`,variant:`primary`,onClick:()=>void te(),children:x.submitCode})]}):null]}):null,T.length>0&&O?(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:T.map(({kind:e,href:t})=>(0,Q.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[Ae(e,n),(0,Q.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,m?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Q.jsx)(v,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),O?(0,Q.jsx)(v,{type:`button`,variant:`primary`,disabled:!u.trim()||f||g,onClick:()=>void ne(),children:g?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):f?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(C,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})]})}function Gn(e=`custom`){if(e!==`custom`&&W[e]){let t=W[e].config;return{preset:e,providerId:Ie(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:t.models?.map(e=>e.id)??[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function Kn(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:W[t.key]?Gn(t.key):e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`setModelIds`:return{...e,modelIds:t.values.length>0?t.values:[``]};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function qn({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:o,onSaved:s}){let[c,l]=(0,Z.useReducer)(Kn,void 0,()=>Gn(e)),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m=we(a(r).providersSettings),{preset:h,providerId:g,baseUrl:_,api:y,apiKey:x,modelIds:S,error:w}=c,T=async()=>{let e=g.trim(),r=_.trim();if(!e){l({type:`setError`,value:n.providerIdRequired});return}if(!r){l({type:`setError`,value:n.baseUrlRequired});return}let i=S.map(e=>e.trim()).filter(Boolean);d(!0),l({type:`setError`,value:null});try{let n=t?.providers??{},a=h===`custom`?void 0:W[h]?.config,o={...a??{},baseUrl:r,api:y,apiKey:x.trim()||void 0,models:i.map(e=>a?.models?.find(t=>t.id===e)??{id:e})};await se({providers:{...n,[e]:o}}),s()}catch(e){l({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{d(!1)}},D=async()=>{let e=g.trim()||Ie(h)||`custom`,t=_.trim();if(!t){l({type:`setError`,value:n.baseUrlRequired});return}p(!0),l({type:`setError`,value:null});try{let r=h===`custom`?void 0:W[h]?.config,i=(await ie({providerId:e,baseUrl:t,apiKey:x.trim()||void 0,api:y,headers:r?.headers})).map(e=>e.id).filter(e=>e&&!e.includes(`/`));l({type:`setModelIds`,values:i}),i.length===0&&l({type:`setError`,value:n.discoverModelsHint})}catch(e){l({type:`setError`,value:e instanceof Error?e.message:n.discoverModelsHint})}finally{p(!1)}},O=g.trim()&&_.trim(),k=(y===`openai-completions`||y===`openai-responses`)&&_.trim();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge-subtle px-5 py-4`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:o,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Y.press),"aria-label":n.back,children:(0,Q.jsx)(Fe,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,Q.jsx)(E,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,Q.jsx)(Hn,{label:n.close})]}),(0,Q.jsxs)(`div`,{className:`flex max-h-[60vh] flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.customDescription}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:n.presetLabel}),(0,Q.jsxs)(J,{id:`custom-preset`,value:h,onChange:e=>l({type:`applyPreset`,key:e.target.value}),className:Te(),children:[(0,Q.jsx)(q,{value:`custom`,children:n.presetCustom}),U.map(e=>(0,Q.jsx)(q,{value:e.key,children:e.label},e.key))]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:n.providerIdLabel}),(0,Q.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,autoFocus:!0,value:g,onChange:e=>l({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,Q.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:_,onChange:e=>l({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:n.apiTypeLabel}),(0,Q.jsx)(J,{id:`custom-api-type`,value:y,onChange:e=>l({type:`setApi`,value:e.target.value}),className:Te(),children:je.map(e=>(0,Q.jsx)(q,{value:e.value,children:e.label},e.value))})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,Q.jsx)(he,{id:`custom-api-key`,value:x,onChange:e=>l({type:`setApiKey`,value:e}),placeholder:n.apiKeyPlaceholder,labels:m})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.modelIdLabel}),(0,Q.jsxs)(v,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!k||f,onClick:()=>void D(),children:[f?(0,Q.jsx)(C,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Q.jsx)(Re,{className:`size-3.5`,"aria-hidden":!0}),f?n.discoveringModels:n.discoverModels]})]}),S.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>l({type:`updateModelId`,index:t,value:e.target.value}),placeholder:n.modelIdPlaceholder,className:i(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)}),S.length>1?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>l({type:`removeModelSlot`,index:t}),className:i(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,Y.press),children:(0,Q.jsx)(be,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,Q.jsxs)(v,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>l({type:`addModelSlot`}),children:[(0,Q.jsx)(N,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),w?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-edge-subtle px-5 py-3`,children:[(0,Q.jsx)(v,{type:`button`,variant:`secondary`,onClick:o,children:n.cancel}),(0,Q.jsx)(v,{type:`button`,variant:`primary`,disabled:!O||u,onClick:()=>void T(),children:u?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(C,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function Jn(e){let t=(0,X.c)(156),{model:n,isNew:r,providerId:a,onSave:o,onClose:s,m:c}=e,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:ve(``),t[0]=n,t[1]=l);let[u,d]=(0,Z.useState)(l),[f,p]=(0,Z.useState)(Yn),h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{d(n=>({...n,[e]:t})),p(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=h):h=t[2];let g=h,_;t[3]!==u.contextWindow||t[4]!==u.id||t[5]!==u.maxTokens||t[6]!==c.modelIdRequired||t[7]!==c.mustBePositive?(_=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,c.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,c.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,c.mustBePositive),p(e),e.size===0},t[3]=u.contextWindow,t[4]=u.id,t[5]=u.maxTokens,t[6]=c.modelIdRequired,t[7]=c.mustBePositive,t[8]=_):_=t[8];let y=_,b;t[9]!==u||t[10]!==s||t[11]!==o||t[12]!==y?(b=()=>{if(!y())return;let e=(u.id||``).trim();o({...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}}),s()},t[9]=u,t[10]=s,t[11]=o,t[12]=y,t[13]=b):b=t[13];let x=b,S=u,C;t[14]===S?C=t[15]:(C=ue(S),t[14]=S,t[15]=C);let w=C,D=r?c.addModelTitle:c.editModelTitle,O;t[16]===D?O=t[17]:(O=(0,Q.jsx)(E,{className:`text-base font-semibold text-fg`,children:D}),t[16]=D,t[17]=O);let k;t[18]!==c.modelProviderLabel||t[19]!==a?(k=a?(0,Q.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[c.modelProviderLabel,`: `,a]}):null,t[18]=c.modelProviderLabel,t[19]=a,t[20]=k):k=t[20];let A;t[21]!==O||t[22]!==k?(A=(0,Q.jsxs)(`div`,{children:[O,k]}),t[21]=O,t[22]=k,t[23]=A):A=t[23];let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=i(ae,`p-1.5 hover:bg-surface-base`),t[24]=j):j=t[24];let N;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Q.jsx)(be,{className:`size-4`}),t[25]=N):N=t[25];let P;t[26]===c.close?P=t[27]:(P=(0,Q.jsx)(m,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:j,"aria-label":c.close,children:N})}),t[26]=c.close,t[27]=P);let F;t[28]!==A||t[29]!==P?(F=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[A,P]}),t[28]=A,t[29]=P,t[30]=F):F=t[30];let I;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Q.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[31]=I):I=t[31];let L;t[32]===c.modelId?L=t[33]:(L=(0,Q.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[c.modelId,I]}),t[32]=c.modelId,t[33]=L);let R;t[34]===f?R=t[35]:(R=i(ne(),f.has(`id`)&&`border-red-500`),t[34]=f,t[35]=R);let z=u.id||``,B;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>g(`id`,e.target.value),t[36]=B):B=t[36];let V=!r,H;t[37]!==R||t[38]!==z||t[39]!==V?(H=(0,Q.jsx)(`input`,{className:R,value:z,onChange:B,placeholder:`e.g. llama3.1:8b`,disabled:V}),t[37]=R,t[38]=z,t[39]=V,t[40]=H):H=t[40];let U;t[41]===f?U=t[42]:(U=f.has(`id`)?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[41]=f,t[42]=U);let W;t[43]!==L||t[44]!==H||t[45]!==U?(W=(0,Q.jsxs)(`div`,{children:[L,H,U]}),t[43]=L,t[44]=H,t[45]=U,t[46]=W):W=t[46];let ee;t[47]===c.displayName?ee=t[48]:(ee=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.displayName}),t[47]=c.displayName,t[48]=ee);let te;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(te=ne(),t[49]=te):te=t[49];let G=u.name||``,re;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>g(`name`,e.target.value),t[50]=re):re=t[50];let ie;t[51]===G?ie=t[52]:(ie=(0,Q.jsx)(`input`,{className:te,value:G,onChange:re}),t[51]=G,t[52]=ie);let K;t[53]!==ee||t[54]!==ie?(K=(0,Q.jsxs)(`div`,{children:[ee,ie]}),t[53]=ee,t[54]=ie,t[55]=K):K=t[55];let oe;t[56]===c.inputTypes?oe=t[57]:(oe=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.inputTypes}),t[56]=c.inputTypes,t[57]=oe);let se;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(se=Te(),t[58]=se):se=t[58];let ce;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>g(`input`,M(e.target.value)),t[59]=ce):ce=t[59];let le;t[60]===c?le=t[61]:(le=T.map(e=>(0,Q.jsx)(q,{value:e.value,children:c[e.labelKey]},e.value)),t[60]=c,t[61]=le);let de;t[62]!==w||t[63]!==le?(de=(0,Q.jsx)(J,{className:se,value:w,onChange:ce,children:le}),t[62]=w,t[63]=le,t[64]=de):de=t[64];let fe;t[65]!==oe||t[66]!==de?(fe=(0,Q.jsxs)(`div`,{children:[oe,de]}),t[65]=oe,t[66]=de,t[67]=fe):fe=t[67];let pe=u.reasoning||!1,me;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(me=e=>g(`reasoning`,e.target.checked),t[68]=me):me=t[68];let he;t[69]===pe?he=t[70]:(he=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:pe,onChange:me}),t[69]=pe,t[70]=he);let ge;t[71]!==c.reasoning||t[72]!==he?(ge=(0,Q.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[he,c.reasoning]}),t[71]=c.reasoning,t[72]=he,t[73]=ge):ge=t[73];let _e;t[74]!==fe||t[75]!==ge?(_e=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[fe,ge]}),t[74]=fe,t[75]=ge,t[76]=_e):_e=t[76];let ye;t[77]===c.contextWindow?ye=t[78]:(ye=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.contextWindow}),t[77]=c.contextWindow,t[78]=ye);let xe;t[79]===f?xe=t[80]:(xe=i(ne(),f.has(`contextWindow`)&&`border-red-500`),t[79]=f,t[80]=xe);let Se=u.contextWindow??128e3,Ce;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=e=>g(`contextWindow`,parseInt(e.target.value,10)||0),t[81]=Ce):Ce=t[81];let we;t[82]!==xe||t[83]!==Se?(we=(0,Q.jsx)(`input`,{type:`number`,min:1,className:xe,value:Se,onChange:Ce}),t[82]=xe,t[83]=Se,t[84]=we):we=t[84];let Ee;t[85]===f?Ee=t[86]:(Ee=f.has(`contextWindow`)?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[85]=f,t[86]=Ee);let De;t[87]!==ye||t[88]!==we||t[89]!==Ee?(De=(0,Q.jsxs)(`div`,{children:[ye,we,Ee]}),t[87]=ye,t[88]=we,t[89]=Ee,t[90]=De):De=t[90];let Oe;t[91]===c.maxOutputTokens?Oe=t[92]:(Oe=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:c.maxOutputTokens}),t[91]=c.maxOutputTokens,t[92]=Oe);let ke;t[93]===f?ke=t[94]:(ke=i(ne(),f.has(`maxTokens`)&&`border-red-500`),t[93]=f,t[94]=ke);let Ae=u.maxTokens??16384,je;t[95]===Symbol.for(`react.memo_cache_sentinel`)?(je=e=>g(`maxTokens`,parseInt(e.target.value,10)||0),t[95]=je):je=t[95];let Me;t[96]!==ke||t[97]!==Ae?(Me=(0,Q.jsx)(`input`,{type:`number`,min:1,className:ke,value:Ae,onChange:je}),t[96]=ke,t[97]=Ae,t[98]=Me):Me=t[98];let Ne;t[99]===f?Ne=t[100]:(Ne=f.has(`maxTokens`)?(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[99]=f,t[100]=Ne);let Pe;t[101]!==Oe||t[102]!==Me||t[103]!==Ne?(Pe=(0,Q.jsxs)(`div`,{children:[Oe,Me,Ne]}),t[101]=Oe,t[102]=Me,t[103]=Ne,t[104]=Pe):Pe=t[104];let Fe;t[105]!==De||t[106]!==Pe?(Fe=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[De,Pe]}),t[105]=De,t[106]=Pe,t[107]=Fe):Fe=t[107];let Ie;t[108]===c.costSection?Ie=t[109]:(Ie=(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:c.costSection}),t[108]=c.costSection,t[109]=Ie);let Le;t[110]===c.costInput?Le=t[111]:(Le=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costInput}),t[110]=c.costInput,t[111]=Le);let Re;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Re=ne(),t[112]=Re):Re=t[112];let ze=u.cost?.input??0,Be;t[113]===u.cost?Be=t[114]:(Be=e=>g(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[113]=u.cost,t[114]=Be);let Ve;t[115]!==ze||t[116]!==Be?(Ve=(0,Q.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Re,value:ze,onChange:Be}),t[115]=ze,t[116]=Be,t[117]=Ve):Ve=t[117];let Y;t[118]!==Le||t[119]!==Ve?(Y=(0,Q.jsxs)(`div`,{children:[Le,Ve]}),t[118]=Le,t[119]=Ve,t[120]=Y):Y=t[120];let He;t[121]===c.costOutput?He=t[122]:(He=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:c.costOutput}),t[121]=c.costOutput,t[122]=He);let Ue;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=ne(),t[123]=Ue):Ue=t[123];let We=u.cost?.output??0,Ge;t[124]===u.cost?Ge=t[125]:(Ge=e=>g(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[124]=u.cost,t[125]=Ge);let Ke;t[126]!==We||t[127]!==Ge?(Ke=(0,Q.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Ue,value:We,onChange:Ge}),t[126]=We,t[127]=Ge,t[128]=Ke):Ke=t[128];let qe;t[129]!==He||t[130]!==Ke?(qe=(0,Q.jsxs)(`div`,{children:[He,Ke]}),t[129]=He,t[130]=Ke,t[131]=qe):qe=t[131];let Je;t[132]!==Y||t[133]!==qe?(Je=(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Y,qe]}),t[132]=Y,t[133]=qe,t[134]=Je):Je=t[134];let Ye;t[135]!==Ie||t[136]!==Je?(Ye=(0,Q.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Ie,Je]}),t[135]=Ie,t[136]=Je,t[137]=Ye):Ye=t[137];let Xe;t[138]!==W||t[139]!==K||t[140]!==_e||t[141]!==Fe||t[142]!==Ye?(Xe=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[W,K,_e,Fe,Ye]}),t[138]=W,t[139]=K,t[140]=_e,t[141]=Fe,t[142]=Ye,t[143]=Xe):Xe=t[143];let Ze;t[144]===c.cancel?Ze=t[145]:(Ze=(0,Q.jsx)(m,{asChild:!0,children:(0,Q.jsx)(v,{type:`button`,variant:`secondary`,children:c.cancel})}),t[144]=c.cancel,t[145]=Ze);let Qe=r?c.addModelConfirm:c.saveModelConfirm,$e;t[146]!==x||t[147]!==Qe?($e=(0,Q.jsx)(v,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,onClick:x,children:Qe}),t[146]=x,t[147]=Qe,t[148]=$e):$e=t[148];let et;t[149]!==Ze||t[150]!==$e?(et=(0,Q.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Ze,$e]}),t[149]=Ze,t[150]=$e,t[151]=et):et=t[151];let tt;return t[152]!==F||t[153]!==Xe||t[154]!==et?(tt=(0,Q.jsxs)(Q.Fragment,{children:[F,Xe,et]}),t[152]=F,t[153]=Xe,t[154]=et,t[155]=tt):tt=t[155],tt}function Yn(){return new Map}function Xn(e){let t=(0,X.c)(16),{open:n,onOpenChange:r,providerId:a,model:o,isNew:s,onSave:c,m:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(I,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Ne)}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(`xopc-dialog-content fixed left-1/2 top-1/2 max-h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,De,`overflow-y-auto rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`),t[1]=d):d=t[1];let f;t[2]!==s||t[3]!==l||t[4]!==o||t[5]!==r||t[6]!==c||t[7]!==n||t[8]!==a?(f=n?(0,Q.jsx)(Jn,{model:o,isNew:s,providerId:a,onSave:c,onClose:()=>r(!1),m:l},`${a??`none`}-${o?.id??`new`}`):null,t[2]=s,t[3]=l,t[4]=o,t[5]=r,t[6]=c,t[7]=n,t[8]=a,t[9]=f):f=t[9];let p;t[10]===f?p=t[11]:(p=(0,Q.jsxs)(V,{children:[u,(0,Q.jsx)(z,{className:d,onOpenAutoFocus:Zn,children:f})]}),t[10]=f,t[11]=p);let m;return t[12]!==r||t[13]!==n||t[14]!==p?(m=(0,Q.jsx)(S,{open:n,onOpenChange:r,children:p}),t[12]=r,t[13]=n,t[14]=p,t[15]=m):m=t[15],m}function Zn(e){return e.preventDefault()}function Qn(e){let t=(0,X.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>_e(n).then($n),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,Q.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,Q.jsx)(he,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function $n(e){return e.apiKey??null}function er(e){let t=(0,X.c)(16),{open:n,onOpenChange:r,providerId:a,isCustom:o,builtinRows:s,customConfig:c,allModels:l,labels:u,language:d,onSaved:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(I,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Ne)}),t[0]=p):p=t[0];let m;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`fixed left-1/2 top-1/2 flex max-h-[85vh] w-full max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-xl`,De),t[1]=m):m=t[1];let h;t[2]!==l||t[3]!==s||t[4]!==c||t[5]!==o||t[6]!==u||t[7]!==d||t[8]!==r||t[9]!==f||t[10]!==a?(h=(0,Q.jsxs)(V,{children:[p,(0,Q.jsx)(z,{className:m,children:o?(0,Q.jsx)(nr,{providerId:a,customConfig:c,labels:u,language:d,onClose:()=>r(!1),onSaved:f}):(0,Q.jsx)(tr,{providerId:a,builtinRows:s,allModels:l,labels:u,language:d,onClose:()=>r(!1),onSaved:f})})]}),t[2]=l,t[3]=s,t[4]=c,t[5]=o,t[6]=u,t[7]=d,t[8]=r,t[9]=f,t[10]=a,t[11]=h):h=t[11];let g;return t[12]!==r||t[13]!==n||t[14]!==h?(g=(0,Q.jsx)(S,{open:n,onOpenChange:r,children:h}),t[12]=r,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function tr({providerId:e,builtinRows:t,allModels:n,labels:r,language:o,onClose:s,onSaved:c}){let l=t.find(t=>t.id===e),u=w[e],d=n.filter(t=>t.provider===e),[f,p]=(0,Z.useState)(l?.apiKey??``),[_,y]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[T,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(!1),M=a(o).providersSettings,N=l?.supportsApiKey!==!1,P=l?.supportsOAuth===!0,F=l?.authMode===`oauth`&&l.authStatus===`connected`,I=l?.configured===!0&&l.activeKeySource!==`env`&&l.activeKeySource!==`extension`&&l.activeKeySource!==`models_json`,[R,z]=(0,Z.useState)(null),[V,H]=(0,Z.useState)(null),[U,W]=(0,Z.useState)(`idle`),[ee,te]=(0,Z.useState)(null),[ne,G]=(0,Z.useState)(null),[re,ie]=(0,Z.useState)(``),K=U===`waiting`||U===`waiting_code`,ae=(0,Z.useMemo)(()=>D(e,o),[e,o]),oe=f!==(l?.apiKey??``),se=async()=>{let t=f.trim();if(!(!t||!N||le(t))){y(!0),O(null);try{await Oe({[e]:t}),S(!0),window.setTimeout(()=>{c(),s()},600)}catch(e){O(e instanceof Error?e.message:r.saveError)}finally{y(!1)}}};(0,Z.useEffect)(()=>{if(!R||!K)return;let e=window.setInterval(()=>{(async()=>{try{let t=await Pn(R);t.status===`waiting_auth`||t.status===`waiting_code`?(W(t.status===`waiting_code`?`waiting_code`:`waiting`),H(t.message??null),te(t.authUrl??null),G(t.instructions??null)):t.status===`completed`?(window.clearInterval(e),W(`success`),H(t.message??M.saved),window.setTimeout(()=>{c(),s()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),W(`error`),H(t.error??t.message??M.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[R,K,s,c,M.revokeFailed,M.saved]),(0,Z.useEffect)(()=>()=>{R&&Ln(R).catch(()=>{})},[R]);let ce=async()=>{try{await xe(e),c(),s()}catch{}},ue=async()=>{W(`waiting`),H(M.oauthStarting),O(null);try{z((await Nn(e)).sessionId)}catch(e){W(`error`),H(e instanceof Error?e.message:M.revokeFailed)}},de=async()=>{if(R){try{await In(R)}catch{}W(`idle`),H(null),z(null),te(null),G(null)}},fe=async()=>{if(!(!R||!re.trim()))try{await Fn(R,re.trim()),ie(``),H(M.oauthProcessingCode)}catch(e){W(`error`),H(e instanceof Error?e.message:M.revokeFailed)}},pe=async()=>{try{await Rn(e),c(),s()}catch(e){O(e instanceof Error?e.message:M.revokeFailed)}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Q.jsx)(E,{className:`text-base font-semibold text-fg`,children:l?.name??e}),(0,Q.jsx)(m,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Y.press),children:(0,Q.jsx)(be,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[u?.description?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,l?.baseUrl?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,Q.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:l.baseUrl})]}):l?.category===`extension`?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,N?(0,Q.jsx)(Qn,{providerId:e,inputId:`manage-api-key`,value:f,onChange:e=>{p(e),S(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):l?.category===`extension`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:r.extensionKeyHint}),l?.extensionId?(0,Q.jsxs)(g,{to:`/settings/ext/${encodeURIComponent(l.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:s,children:[r.openExtensionSettings,(0,Q.jsx)(ye,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,P?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:M.oauth}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:F?M.sourceOauth:M.oauthHint})]}),F?(0,Q.jsx)(v,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void pe(),children:M.revoke}):(0,Q.jsxs)(v,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:K,onClick:()=>void ue(),children:[K?(0,Q.jsx)(C,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Q.jsx)(L,{className:`size-3.5`,"aria-hidden":!0}),M.oauth]})]}),V?(0,Q.jsx)(`p`,{className:i(`text-xs`,U===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:V}):null,U===`waiting`||U===`waiting_code`?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ee?(0,Q.jsxs)(`a`,{href:ee,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-white hover:bg-accent-hover`,children:[(0,Q.jsx)(ye,{className:`size-4`,"aria-hidden":!0}),M.openAuthPage]}):null,(0,Q.jsx)(v,{type:`button`,variant:`secondary`,onClick:()=>void de(),children:M.cancelOAuth})]}):null,ne?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ne}):null,U===`waiting_code`?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,Q.jsx)(`input`,{type:`text`,value:re,onChange:e=>ie(e.target.value),onKeyDown:e=>e.key===`Enter`&&void fe(),placeholder:M.pasteRedirectUrl,className:i(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)}),(0,Q.jsx)(v,{type:`button`,variant:`primary`,onClick:()=>void fe(),children:M.submitCode})]}):null]}):null,ae.length>0&&N?(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ae.map(({kind:e,href:t})=>(0,Q.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[Ae(e,r),(0,Q.jsx)(ye,{className:`size-3`,"aria-hidden":!0})]},e))}):null,d.length>0?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,d.length,`)`]}),(0,Q.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.map(e=>(0,Q.jsx)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:e.id.includes(`/`)?e.id.split(`/`).pop():e.id},e.id))})})]}):(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),T?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:T}):null]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[I?(0,Q.jsxs)(v,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>A(!0),children:[(0,Q.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,Q.jsx)(`span`,{}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:N&&oe&&!le(f.trim())?(0,Q.jsx)(v,{type:`button`,variant:`primary`,disabled:!f.trim()||_||x,onClick:()=>void se(),children:x?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):_?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(C,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,Q.jsx)(h,{open:k,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,l?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void ce(),onCancel:()=>A(!1)})]})}function nr({providerId:e,customConfig:t,labels:n,language:r,onClose:o,onSaved:s}){let c=a(r).modelsSettings,l=t?.providers[e],[u,d]=(0,Z.useState)(l?.baseUrl??``),[f,p]=(0,Z.useState)(l?.apiKey??``),[g,_]=(0,Z.useState)(l?.models??[]),[y,x]=(0,Z.useState)(!1),[S,w]=(0,Z.useState)(null),[T,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(null),I=n=>{if(!t)return null;let r=f.trim(),i={...l,baseUrl:u.trim()||void 0,apiKey:le(r)?l?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},L=async()=>{let e=I({models:g});if(e){x(!0),w(null);try{await se(e),s(),o()}catch(e){w(e instanceof Error?e.message:n.saveError)}finally{x(!1)}}},R=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await se({providers:r}),s(),o()}catch{}},z=(e,t)=>{F({model:e,isNew:t}),M(!0)},V=async e=>{if(!P)return;let t=P.isNew?[...g,e]:g.map(t=>t.id===e.id?e:t);_(t);let r=I({models:t});if(r)try{await se(r),s()}catch(e){w(e instanceof Error?e.message:n.saveError)}},H=async e=>{let t=g.filter(t=>t.id!==e);_(t),k(null);let r=I({models:t});if(r)try{await se(r),s()}catch(e){w(e instanceof Error?e.message:n.saveError)}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(E,{className:`text-base font-semibold text-fg`,children:e}),(0,Q.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,Q.jsx)(m,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Y.press),children:(0,Q.jsx)(be,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,Q.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:u,onChange:e=>d(e.target.value),className:i(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,b)})]}),(0,Q.jsx)(Qn,{providerId:e,inputId:`manage-custom-api-key`,value:f,onChange:p,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,Q.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[c.modelsSection,g.length>0?` (${g.length})`:``]}),(0,Q.jsxs)(v,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>z(null,!0),children:[(0,Q.jsx)(N,{className:`size-3.5`,"aria-hidden":!0}),c.addModel]})]}),g.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.modelsEmpty}):(0,Q.jsx)(`ul`,{className:`space-y-2`,children:g.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.name&&e.name!==e.id?(0,Q.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Y.press),onClick:()=>z(e,!1),"aria-label":c.editModel,children:(0,Q.jsx)(A,{className:`size-3.5`,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,Y.press),onClick:()=>k(e.id),"aria-label":c.removeModel,children:(0,Q.jsx)(B,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),S?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S}):null]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,Q.jsxs)(v,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>D(!0),children:[(0,Q.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)(v,{type:`button`,variant:`primary`,disabled:y,onClick:()=>void L(),children:y?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(C,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,Q.jsx)(h,{open:T,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void R(),onCancel:()=>D(!1)}),(0,Q.jsx)(h,{open:O!==null,title:c.removeModel,description:c.removeModelConfirm.replace(`{{id}}`,O??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{O&&H(O)},onCancel:()=>k(null)}),(0,Q.jsx)(Xn,{open:j,onOpenChange:e=>{M(e),e||F(null)},providerId:e,model:P?.model??null,isNew:P?.isNew??!1,onSave:e=>void V(e),m:c})]})}var rr=[`services`,`image-models`,`voice`,`search`];function ir(e){let t=(e??``).trim();return t===`providers`||t===`catalog`?`services`:rr.includes(t)?t:`services`}function ar(){let e=(0,X.c)(59),t=o(sr),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.modelsHub,[s,c]=k(),l;e[2]===s?l=e[3]:(l=ir(s.get(`tab`)),e[2]=s,e[3]=l);let u=l,[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),h=Cn(),g;e[4]!==i.servicesHint||e[5]!==i.tabs.services?(g={id:`services`,icon:_,label:i.tabs.services,hint:i.servicesHint},e[4]=i.servicesHint,e[5]=i.tabs.services,e[6]=g):g=e[6];let v;e[7]!==i.imageModelsHint||e[8]!==i.tabs.imageModels?(v={id:`image-models`,icon:oe,label:i.tabs.imageModels,hint:i.imageModelsHint},e[7]=i.imageModelsHint,e[8]=i.tabs.imageModels,e[9]=v):v=e[9];let y;e[10]!==i.tabs.voice||e[11]!==i.voiceHint?(y={id:`voice`,icon:Ue,label:i.tabs.voice,hint:i.voiceHint},e[10]=i.tabs.voice,e[11]=i.voiceHint,e[12]=y):y=e[12];let b;e[13]!==i.searchHint||e[14]!==i.tabs.search?(b={id:`search`,icon:Re,label:i.tabs.search,hint:i.searchHint},e[13]=i.searchHint,e[14]=i.tabs.search,e[15]=b):b=e[15];let x;e[16]!==g||e[17]!==v||e[18]!==y||e[19]!==b?(x=[g,v,y,b],e[16]=g,e[17]=v,e[18]=y,e[19]=b,e[20]=x):x=e[20];let S=x,C;e[21]===c?C=e[22]:(C=e=>{c(t=>{let n=new URLSearchParams(t);return e===`services`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[21]=c,e[22]=C);let w=C,T=or,E=r.settingsSections.credentials,D=i.subtitle,O;e[23]===t?O=e[24]:(O=ee(t,`configuration`),e[23]=t,e[24]=O);let A;e[25]!==i.docsLink||e[26]!==i.subtitle||e[27]!==r.settingsSections.credentials||e[28]!==O?(A=(0,Q.jsx)(We,{title:E,subtitle:D,docsLink:O,docsLabel:i.docsLink}),e[25]=i.docsLink,e[26]=i.subtitle,e[27]=r.settingsSections.credentials,e[28]=O,e[29]=A):A=e[29];let j;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(ut,{}),e[30]=j):j=e[30];let M;e[31]!==u||e[32]!==i.tabsAria||e[33]!==w||e[34]!==S?(M=(0,Q.jsx)(ct,{items:S,activeTab:u,onChange:w,ariaLabel:i.tabsAria,tabIdPrefix:`hub-tab`,panelIdPrefix:`hub-panel`}),e[31]=u,e[32]=i.tabsAria,e[33]=w,e[34]=S,e[35]=M):M=e[35];let N;e[36]!==u||e[37]!==i.connectedProviders||e[38]!==S?(N=S.map(e=>(0,Q.jsx)(lr,{id:e.id,activeTab:u,hint:e.hint,children:e.id===`services`?(0,Q.jsx)(kn,{labels:i.connectedProviders,onAdd:()=>f(!0),onManage:(e,t)=>m({providerId:e,isCustom:t})}):(0,Q.jsx)(cr,{tab:e.id})},e.id)),e[36]=u,e[37]=i.connectedProviders,e[38]=S,e[39]=N):N=e[39];let P;e[40]!==d||e[41]!==i.addProviderDialog||e[42]!==t||e[43]!==h.builtinRows||e[44]!==h.customConfig?(P=(0,Q.jsx)(Vn,{open:d,onOpenChange:f,builtinRows:h.builtinRows,customConfig:h.customConfig,labels:i.addProviderDialog,language:t,onSaved:T}),e[40]=d,e[41]=i.addProviderDialog,e[42]=t,e[43]=h.builtinRows,e[44]=h.customConfig,e[45]=P):P=e[45];let F;e[46]!==i.manageProviderDialog||e[47]!==t||e[48]!==p||e[49]!==h.allModels||e[50]!==h.builtinRows||e[51]!==h.customConfig?(F=p?(0,Q.jsx)(er,{open:!0,onOpenChange:e=>{e||m(null)},providerId:p.providerId,isCustom:p.isCustom,builtinRows:h.builtinRows,customConfig:h.customConfig,allModels:h.allModels,labels:i.manageProviderDialog,language:t,onSaved:T}):null,e[46]=i.manageProviderDialog,e[47]=t,e[48]=p,e[49]=h.allModels,e[50]=h.builtinRows,e[51]=h.customConfig,e[52]=F):F=e[52];let I;return e[53]!==A||e[54]!==M||e[55]!==N||e[56]!==P||e[57]!==F?(I=(0,Q.jsxs)(Ge,{children:[A,j,M,N,P,F]}),e[53]=A,e[54]=M,e[55]=N,e[56]=P,e[57]=F,e[58]=I):I=e[58],I}function or(){re()}function sr(e){return e.language}function cr(e){let t=(0,X.c)(3),{tab:n}=e;switch(n){case`services`:return null;case`image-models`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Tt,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Qt,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(bn,{}),t[2]=e):e=t[2],e}}}function lr({id:e,activeTab:t,hint:n,children:r}){let a=e===t,o=(0,Z.useRef)(a);return a&&(o.current=!0),o.current?(0,Q.jsxs)(`div`,{role:`tabpanel`,id:`hub-panel-${e}`,"aria-labelledby":`hub-tab-${e}`,hidden:!a,className:i(`min-w-0 rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,a?`flex flex-col gap-3`:void 0),children:[a?(0,Q.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n}):null,r]}):null}export{ar as ModelsHubPanel};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{Dl as n}from"./index-38TSE7ng.js";import{t as r}from"./notes-workbench-D_oaF0Pq.js";var i=e(),a=t();function o(){let e=(0,i.c)(2),{noteId:t}=n(),o;return e[0]===t?o=e[1]:(o=(0,a.jsx)(r,{selectedNoteId:t,basePath:`/notes`,managePageHeader:!0,showLibrary:!0,allowMediaCapture:!0,listWidthStorageKey:`xopc.notes.listWidth`}),e[0]=t,e[1]=o),o}export{o as NotesPage};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{Dl as n}from"./index-C4k6QSXw.js";import{t as r}from"./notes-workbench-BAELRM_O.js";var i=e(),a=t();function o(){let e=(0,i.c)(2),{noteId:t}=n(),o;return e[0]===t?o=e[1]:(o=(0,a.jsx)(r,{selectedNoteId:t,basePath:`/notes`,managePageHeader:!0,showLibrary:!0,allowMediaCapture:!0,listWidthStorageKey:`xopc.notes.listWidth`}),e[0]=t,e[1]=o),o}export{o as NotesPage};