@amd-gaia/agent-ui 0.27.1-rc.2 → 0.27.1-rc.4

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 (36) hide show
  1. package/dist/assets/AdvancedSettings-CyQ8DiPU.js +1 -0
  2. package/dist/assets/AutomationsSettings-eQQ5jHXv.js +1 -0
  3. package/dist/assets/ConnectorsPane-xII8pS8F.js +1 -0
  4. package/dist/assets/DeveloperSettings-Bz86hEjc.js +1 -0
  5. package/dist/assets/DocumentLibrary-Dl3CeRTF.js +5 -0
  6. package/dist/assets/FileBrowser-IIo3e80y.js +4 -0
  7. package/dist/assets/MemoryDashboard-BdnTNXlY.js +1 -0
  8. package/dist/assets/MessagingSettings-DUinxAVz.js +1 -0
  9. package/dist/assets/MobileAccessModal-D5gMqLRv.js +2 -0
  10. package/dist/assets/SaveError-B2REwpWX.js +1 -0
  11. package/dist/assets/ScheduleManager-CEpTqCkE.js +1 -0
  12. package/dist/assets/{browser-DfYHeeW3.js → browser-C2Fg9QrK.js} +1 -1
  13. package/dist/assets/folderIndexResult-BYn7wzCf.js +1 -0
  14. package/dist/assets/index-Ciz1qEdc.js +242 -0
  15. package/dist/assets/index-DpWsru6n.css +1 -0
  16. package/dist/index.html +2 -4
  17. package/dist/sw.js +1 -1
  18. package/package.json +1 -1
  19. package/services/context-menu.cjs +2 -0
  20. package/services/link-policy.cjs +26 -0
  21. package/dist/assets/AdvancedSettings-BNBv39MM.js +0 -1
  22. package/dist/assets/AutomationsSettings-DoLbbuYd.js +0 -1
  23. package/dist/assets/ConnectorsPane-DONLKims.js +0 -1
  24. package/dist/assets/DeveloperSettings-BjwXvDaj.js +0 -1
  25. package/dist/assets/DocumentLibrary-CGqKO-Dp.js +0 -5
  26. package/dist/assets/FileBrowser-BSlIywRC.js +0 -4
  27. package/dist/assets/MemoryDashboard-D2nxfLXc.js +0 -1
  28. package/dist/assets/MessagingSettings-ButjowTl.js +0 -1
  29. package/dist/assets/MobileAccessModal-DeqfE-s_.js +0 -2
  30. package/dist/assets/SaveError-CIUCwbOl.js +0 -1
  31. package/dist/assets/ScheduleManager-CAMGpqtC.js +0 -1
  32. package/dist/assets/folderIndexResult-DKQpxwD1.js +0 -1
  33. package/dist/assets/index-DnSSZ2b8.js +0 -234
  34. package/dist/assets/index-O8u9e_5g.css +0 -1
  35. package/dist/assets/rolldown-runtime-XKyaHtl9.js +0 -1
  36. package/dist/assets/useT-CWiHVf7i.js +0 -9
package/dist/index.html CHANGED
@@ -26,10 +26,8 @@
26
26
  // main.tsx applies the theme again and reports why it could not read the saved one.
27
27
  }
28
28
  </script>
29
- <script type="module" crossorigin src="./assets/index-DnSSZ2b8.js"></script>
30
- <link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-XKyaHtl9.js">
31
- <link rel="modulepreload" crossorigin href="./assets/useT-CWiHVf7i.js">
32
- <link rel="stylesheet" crossorigin href="./assets/index-O8u9e_5g.css">
29
+ <script type="module" crossorigin src="./assets/index-Ciz1qEdc.js"></script>
30
+ <link rel="stylesheet" crossorigin href="./assets/index-DpWsru6n.css">
33
31
  </head>
34
32
  <body>
35
33
  <div id="root"></div>
package/dist/sw.js CHANGED
@@ -9,7 +9,7 @@
9
9
  // never sees a stale UI or stale data.
10
10
 
11
11
  const CACHE_PREFIX = 'gaia-assets-';
12
- const CACHE_NAME = CACHE_PREFIX + '0.27.1rc2-bf77e524a857610d';
12
+ const CACHE_NAME = CACHE_PREFIX + '0.27.1rc4-647affb64a39df20';
13
13
  const ASSETS_PATH = new URL('assets/', self.registration.scope).pathname;
14
14
 
15
15
  self.addEventListener('install', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amd-gaia/agent-ui",
3
- "version": "0.27.1-rc.2",
3
+ "version": "0.27.1-rc.4",
4
4
  "type": "module",
5
5
  "productName": "GAIA Agent UI",
6
6
  "desktopName": "gaia-desktop.desktop",
@@ -12,6 +12,8 @@ const MAX_SUGGESTIONS = 5;
12
12
  const LABELS = {
13
13
  en: { addToDictionary: "Add to dictionary", copyLink: "Copy link address", copyImage: "Copy image" },
14
14
  ar: { addToDictionary: "إضافة إلى القاموس", copyLink: "نسخ عنوان الرابط", copyImage: "نسخ الصورة" },
15
+ pt: { addToDictionary: "Adicionar ao dicionário", copyLink: "Copiar endereço do link", copyImage: "Copiar imagem" },
16
+ es: { addToDictionary: "Agregar al diccionario", copyLink: "Copiar la dirección del enlace", copyImage: "Copiar imagen" },
15
17
  };
16
18
 
17
19
  /** The custom items' labels for an OS locale such as "ar-EG"; English for any language without them. */
@@ -90,6 +90,32 @@ const NOTICE_TEXT = {
90
90
  `تعذّر على GAIA فتح "${isolate(url)}": ${isolate(reason)}. ` +
91
91
  "تأكد من وجود تطبيق على هذا الجهاز مُعدّ لفتح هذا النوع من الروابط.",
92
92
  },
93
+ pt: {
94
+ blockedTitle: "Link bloqueado",
95
+ notOpenedTitle: "Link não aberto",
96
+ ok: "OK",
97
+ noScheme: "sem protocolo",
98
+ blocked: (url, scheme) =>
99
+ `O GAIA se recusou a abrir "${url}" (${scheme}). ` +
100
+ "Só links http, https e mailto abrem fora do app — um link que " +
101
+ "aponta para um arquivo local ou compartilhamento de rede nunca é aberto.",
102
+ openFailed: (url, reason) =>
103
+ `O GAIA não conseguiu abrir "${url}": ${reason}. ` +
104
+ "Verifique se este PC tem um app configurado para esse tipo de link.",
105
+ },
106
+ es: {
107
+ blockedTitle: "Enlace bloqueado",
108
+ notOpenedTitle: "Enlace no abierto",
109
+ ok: "OK",
110
+ noScheme: "sin protocolo",
111
+ blocked: (url, scheme) =>
112
+ `GAIA se negó a abrir "${url}" (${scheme}). ` +
113
+ "Solo los enlaces http, https y mailto se abren fuera de la app: un enlace " +
114
+ "que apunta a un archivo local o a una carpeta compartida en red nunca se abre.",
115
+ openFailed: (url, reason) =>
116
+ `GAIA no pudo abrir "${url}": ${reason}. ` +
117
+ "Verifica que esta PC tenga una app configurada para ese tipo de enlace.",
118
+ },
93
119
  };
94
120
 
95
121
  /** The link-notice strings for an OS locale such as "ar-EG"; English for any language without them. */
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Gn as t,Jt as n,Ni as r,Oi as i,P as a,Sn as o,Wn as s,a as c,an as l,c as u,er as d,f,o as p,pt as m,s as h,sn as g,tn as _}from"./useT-CWiHVf7i.js";import{Bt as v,Gt as y,Ht as b,I as x,It as S,Ln as C,Mn as w,Ut as T,Vt as E,c as D,d as O,fn as k,g as A,jn as j,l as M,m as N,n as P,o as F,p as I,rn as L,s as ee,u as te}from"./index-DnSSZ2b8.js";import{t as ne}from"./SaveError-CIUCwbOl.js";var R=e(r(),1);function re(){let e=c(),t=f(e=>e.runSetupAgain),r=f(e=>e.closeSettings),[i,a]=(0,R.useState)(null),[o,l]=(0,R.useState)(null),[d,m]=(0,R.useState)(``),[g,_]=(0,R.useState)(``),[v,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(null),[S,C]=(0,R.useState)(!1);(0,R.useEffect)(()=>{n().then(e=>{a(e),m(e.saved_base_url??e.base_url??``)}).catch(e=>l(e instanceof Error?e.message:String(e)))},[]);let w=(0,R.useCallback)(async e=>{y(!0),x(null);try{let n=await s(e);a(n),_(``),C(!1),n.mode===`gaia`&&!n.gaia_installed&&(r(),t(!0))}catch(e){C(I(e)),x(e instanceof Error?e.message:String(e))}finally{y(!1)}},[r,t]),T=()=>void w({mode:`external`,base_url:d.trim(),api_key:g.trim()||void 0});if(o)return u(`section`,{className:`settings-section`,children:[h(`h4`,{children:e(`settings.advanced.modelServer`)}),u(`div`,{className:`model-warning`,role:`alert`,children:[h(j,{size:14}),u(`div`,{className:`model-warning-content`,children:[h(`strong`,{children:e(`settings.server.readFailed`)}),h(`p`,{children:o})]})]})]});if(!i)return null;let E=i.mode===`external`,D=i.source===`env`;return u(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[h(`h4`,{children:e(`settings.advanced.modelServer`)}),h(`p`,{className:`model-override-desc`,role:`status`,children:D?e(`settings.server.usesEnv`,{url:i.base_url??``}):E?e(`settings.server.usesYours`,{url:i.base_url??``}):e(`settings.server.usesOwn`)}),!D&&i.env_url_ignored&&h(`p`,{className:`model-status-hint`,children:e(`settings.server.envIgnored`,{url:i.env_url_ignored})}),D?h(`p`,{className:`model-status-hint`,children:e(`settings.server.envUseOwn`)}):u(p.Fragment,{children:[u(`p`,{className:`model-status-hint`,children:[e(`settings.server.useYours`),` `,h(`bdi`,{children:i.what_gaia_does})]}),u(`form`,{className:`model-input-row`,onSubmit:e=>{e.preventDefault(),T()},children:[h(`input`,{type:`text`,className:`model-input`,placeholder:`http://localhost:13305`,value:d,onChange:e=>{m(e.target.value),x(null)},disabled:v,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":e(`settings.server.address`)}),h(`input`,{type:`password`,className:`model-input`,autoComplete:`off`,placeholder:i.api_key_stored?e.bare(`settings.server.keySaved`):e.bare(`settings.server.keyOptional`),value:g,onChange:e=>_(e.target.value),disabled:v,"aria-label":e(`settings.server.key`)}),h(`div`,{className:`model-btn-group`,children:h(`button`,{type:`submit`,className:`btn-primary`,disabled:v||!d.trim(),children:v?u(p.Fragment,{children:[h(k,{size:13,className:`btn-spinner`}),` `,e(`settings.server.checking`)]}):e(`settings.server.use`)})})]})]}),E&&h(`div`,{className:`setting-actions`,children:h(`button`,{type:`button`,className:`btn-secondary`,disabled:v,onClick:()=>void w({mode:`gaia`}),children:e(`settings.server.useOwn`)})}),b&&u(`div`,{className:`model-warning`,role:`alert`,children:[h(j,{size:14}),u(`div`,{className:`model-warning-content`,children:[h(`strong`,{children:e(S?`settings.server.needsKey`:`settings.server.notSwitched`)}),h(`p`,{children:b})]})]})]})}var z={vulkan:`Vulkan`,rocm:`ROCm`,metal:`Metal`,cpu:`CPU`,npu:`NPU`,remote:`Remote (cloud)`},B={gaia:`settings.server.ownerGaia`,user:`settings.server.ownerUser`,remote:`settings.server.ownerRemote`};function V(e){return e?z[e]??e:`unknown`}function H(e){if(!e)return`unknown`;let t=V(e.backend);return e.backend_source===`lemonade_default`?`${t} (Lemonade's default)`:t}function U(e){return e?`${Math.round(e/1024)}K tokens`:`unknown`}var W={asr:`settings.server.kind.speechRecognition`,embedding:`settings.server.kind.embedding`,image:`settings.server.kind.image`,llm:`settings.server.kind.language`,rerank:`settings.server.kind.reranker`,reranking:`settings.server.kind.reranker`,stt:`settings.server.kind.speechRecognition`,transcription:`settings.server.kind.speechRecognition`,tts:`settings.server.kind.speech`,vision:`settings.server.kind.vision`,"3d":`settings.server.kind.threeD`};function G(e,t){if(!e.model_type)return t(`settings.server.loadedModel`);let n=e.model_type.toLowerCase(),r=W[n];return r?t(r):t(`settings.server.kindOther`,{kind:`${n.charAt(0).toUpperCase()}${n.slice(1)}`})}function K(e,t){let n=[e.name?v(e.name):t.bare(`settings.server.unknownModel`),H(e)];return e.backend!==`remote`&&e.ctx_size&&n.push(U(e.ctx_size)),n.join(` · `)}function q({label:e,value:t,title:n}){return u(`div`,{className:`status-row`,children:[h(`span`,{className:`status-label`,children:e}),h(`span`,{className:`status-value model-server-value`,dir:`auto`,title:n??t,children:t})]})}function ie(){let e=c(),n=f(e=>e.openSettings),r=y(e=>e.show),[i,a]=(0,R.useState)(null),[s,l]=(0,R.useState)(null),[d,m]=(0,R.useState)(null),[g,b]=(0,R.useState)(null),[S,C]=(0,R.useState)(!1);(0,R.useEffect)(()=>{_().then(a).catch(e=>l(e instanceof Error?e.message:String(e)))},[]);let w=(0,R.useCallback)(async n=>{m(n),b(null);try{let r=await t(n);a(r),b({ok:!0,text:e(`settings.server.savedBackend`)})}catch(e){b({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{m(null)}},[e]),T=i?.chat_model??null,E=(0,R.useCallback)(async()=>{if(T?.name){C(!0);try{if(!await o(T.name,T.ctx_size??void 0))return;b({ok:!0,text:e(`settings.server.reloading`,{name:T.name})})}catch(e){b({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{C(!1)}}},[T,e]),D=h(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>n(`model`),children:e(`settings.server.changeModel`)}),O=u(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>r(`model_server`),children:[h(L,{size:13,"aria-hidden":`true`}),` `,e(`logs.serverLog`)]});if(s)return u(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[h(`h4`,{children:e(`settings.advanced.modelServer`)}),h(F,{message:s})]});if(!i)return u(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[h(`h4`,{children:e(`settings.advanced.modelServer`)}),h(`p`,{className:`loading-text`,children:e(`settings.server.checkingServer`)})]});if(!i.reachable)return u(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[h(`h4`,{children:e(`settings.advanced.modelServer`)}),h(F,{message:i.error??e(`settings.errors.serverDownTitle`)}),u(`div`,{className:`settings-row`,children:[D,O]})]});let A=i.available_backends??[],j=i.preferred_backend??null,M=A.map(e=>e.name);j&&!M.includes(j)&&M.push(j);let N=j??i.default_backend??null,P=A.filter(e=>e.state===`installable`).map(e=>V(e.name)),I=!!T?.name&&T.recipe===`llamacpp`;return u(`section`,{className:`settings-section`,"aria-label":e(`settings.advanced.modelServer`),children:[h(`h4`,{children:e(`settings.advanced.modelServer`)}),u(`div`,{className:`status-grid`,children:[h(q,{label:e(`settings.server.server`),value:`${B[i.owner]?e(B[i.owner]):i.owner}${i.version?` v${i.version}`:``}`}),h(q,{label:e(`settings.server.addressShort`),value:i.base_url}),h(q,{label:e(`settings.server.chatModel`),value:T?.name?v(T.name):e(`settings.advanced.noneLoaded`),title:T?.name??void 0}),T&&h(q,{label:e(`settings.server.runsOn`),value:H(T)}),T&&T.backend!==`remote`&&h(q,{label:e(`settings.advanced.context`),value:U(T.ctx_size)}),h(q,{label:e(`settings.advanced.embedding`),value:i.embedding_model?.name?`${i.embedding_model.name} · ${H(i.embedding_model)}`:e(`settings.advanced.noneLoaded`)}),(i.loaded_models??[]).map((t,n)=>h(q,{label:G(t,e),value:K(t,e),title:t.name??void 0},`${t.name??`unknown`}-${n}`))]}),i.embedding_note&&h(`p`,{className:`settings-hint`,children:h(`bdi`,{children:i.embedding_note})}),i.system_info_error&&h(`p`,{className:`settings-hint`,children:h(`bdi`,{children:i.system_info_error})}),u(`div`,{className:`settings-field model-server-backend`,children:[h(`span`,{className:`settings-label`,children:e(`settings.server.backend`)}),A.length===0&&!j?h(`span`,{className:`settings-hint`,children:e(`settings.server.noBackends`)}):u(p.Fragment,{children:[h(x,{className:`segmented`,"aria-label":e(`settings.server.backendShort`),children:M.map(e=>u(`button`,{type:`button`,role:`radio`,"aria-checked":N===e,className:N===e?`is-active`:``,disabled:d!==null,onClick:()=>{e!==N&&w(e)},children:[d===e?h(k,{size:12,className:`spin`}):null,V(e)]},e))}),u(`span`,{className:`settings-hint`,children:[e(`settings.server.backendHint`),P.length>0&&` ${e(`settings.server.installable`,{names:P.join(`, `)})}`]})]}),g?.ok&&h(`p`,{className:`settings-ok`,role:`status`,children:g.text}),g&&!g.ok&&h(F,{message:g.text})]}),u(`div`,{className:`settings-row`,children:[D,O,I&&u(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void E(),disabled:S,children:[S?h(k,{size:13,className:`spin`}):null,e(`settings.server.reload`)]})]})]})}function ae(e,t){return!e||!t||t.found?null:{kind:t.checked?`unlisted`:`unchecked`,id:e}}function J(){let e=c();b();let[t,n]=(0,R.useState)(null),[r,o]=(0,R.useState)(!0),[s,f]=(0,R.useState)(``),[_,y]=(0,R.useState)(``),[x,N]=(0,R.useState)(!1),[I,L]=(0,R.useState)(!1),[z,B]=(0,R.useState)(null),[V,H]=(0,R.useState)(null),[U,W]=(0,R.useState)(!1),G=(0,R.useRef)(null);(0,R.useEffect)(()=>{i.system.info(`Checking system status...`);let e=i.system.time();g().then(t=>{n(t),i.system.timed(`System status received`,e,{lemonade:t.lemonade_running?`running`:`stopped`,model:t.model_loaded||`none`,embedding:t.embedding_model_loaded?`yes`:`no`,disk:`${t.disk_space_gb}GB free`,memory:t.memory_available_gb==null?`unknown`:`${t.memory_available_gb}GB available`}),t.lemonade_running||i.system.warn(`Lemonade Server is NOT running.`)}).catch(e=>{i.system.error(`Failed to get system status`,e),n(null)}).finally(()=>o(!1)),l().then(e=>{let t=e.custom_model??``;f(t),y(t),H(ae(t,e.model_status))}).catch(e=>{i.system.error(`Failed to load settings`,e)}).finally(()=>N(!0))},[]),(0,R.useEffect)(()=>()=>{G.current&&clearTimeout(G.current)},[]);let K=(0,R.useCallback)(async()=>{let t=s.trim(),r=t.length>0?t:``,a=T.getState().active?.model;L(!0),B(null),H(null),W(!1);try{i.system.info(`Saving custom_model override`,{custom_model:r});let e=await d({custom_model:r}),t=e.custom_model??``;f(t),y(t),E(a),g().then(n).catch(e=>i.system.error(`Failed to get system status`,e)),H(ae(t,e.model_status)),W(!0),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>W(!1),2200)}catch(t){i.system.error(`Failed to save custom_model`,t);let n=t instanceof m&&t.httpStatus===422&&t.fields.includes(`custom_model`);B(n?e(`settings.advanced.customModelInvalid`):t instanceof Error?t.message:String(t))}finally{L(!1)}},[s,e]),q=s.trim()!==_.trim(),J=t?t.default_model_name:S,{isLoadingModel:Y,isDownloadingModel:Z,downloadError:Q,loadModel:ce,downloadModel:le}=P(J??void 0),$=!!t?.default_model_is_cloud,ue=!$&&!!(t?.lemonade_running&&t.model_loaded&&t.expected_model_loaded===!1&&t.model_downloaded!==!1),de=!$&&!!(t?.lemonade_running&&t.model_loaded&&t.context_size_sufficient===!1),fe=!$&&!(!t?.lemonade_running||t.model_loaded||t.model_downloaded!==!1),pe=(ue||de)&&J!==null;return u(`div`,{className:`settings-pane`,children:[h(`h2`,{className:`settings-pane-title`,children:e(`settings.section.advanced`)}),h(`section`,{className:`settings-card`,"aria-label":e(`settings.advanced.status`),children:r?h(`p`,{className:`loading-text`,children:e(`settings.advanced.checking`)}):t?u(p.Fragment,{children:[u(`div`,{className:`status-grid`,children:[h(X,{label:e(`settings.advanced.modelServer`),value:t.lemonade_running?t.lemonade_version?e(`settings.advanced.runningAt`,{version:t.lemonade_version}):e(`settings.advanced.running`):M(t)?e(`settings.advanced.notInstalled`):t.lemonade_error?e(`settings.advanced.unavailable`):e(`settings.advanced.notRunning`),ok:t.lemonade_running,hint:t.lemonade_running?void 0:M(t)?e(`settings.advanced.notInstalledHint`):t.lemonade_error?e(`settings.advanced.queryFailed`,{reason:t.lemonade_error}):t.start_instruction&&!D(t.start_instruction)?te(e,t.start_instruction)??void 0:e(`settings.advanced.notRunningHint`)}),M(t)&&h(ee,{className:`btn-primary`}),h(X,{label:e(`settings.section.model`),value:$&&J?v(J):t.model_loaded||e(`settings.advanced.noneLoaded`),ok:$?!!J:!!t.model_loaded&&t.expected_model_loaded!==!1,hint:$?void 0:t.model_loaded?t.expected_model_loaded===!1?e(`settings.advanced.expected`,{name:J??``}):void 0:e(t.lemonade_running?`settings.advanced.loadsFirst`:`settings.advanced.loadsWhenBack`)}),h(X,{label:e(`settings.advanced.disk`),value:u(`bdi`,{dir:`ltr`,children:[t.disk_space_gb,` GB`]}),ok:t.disk_space_gb>5,hint:!t.model_loaded&&t.disk_space_gb<30?e(`settings.advanced.diskLow`,{need:`6 GB`,size:`${t.disk_space_gb} GB`}):void 0})]}),fe&&u(`div`,{className:`model-action-row model-action-row--download`,children:[u(`div`,{className:`model-action-info`,children:[h(`span`,{className:`model-action-label`,children:e(`settings.advanced.notDownloaded`)}),h(`span`,{className:`model-action-desc`,children:e(`settings.advanced.notDownloadedHint`,{name:J??``,need:`6 GB`})})]}),h(`button`,{className:`btn-primary`,onClick:()=>le(!1,void 0,!t.model_loaded),disabled:Z,children:Z?u(p.Fragment,{children:[h(k,{size:13,className:`btn-spinner`}),` `,e(`settings.advanced.downloading`)]}):e(`settings.model.download`)})]}),fe&&Q&&h(F,{message:Q}),pe&&u(`div`,{className:`model-action-row model-action-row--load`,children:[u(`div`,{className:`model-action-info`,children:[h(`span`,{className:`model-action-label`,children:e(ue?`settings.advanced.wrongModel`:`settings.advanced.smallContext`)}),h(`span`,{className:`model-action-desc`,children:e(`settings.advanced.loadHint`,{name:J??``})})]}),h(`button`,{className:`btn-primary`,onClick:()=>ce(),disabled:Y,children:Y?u(p.Fragment,{children:[h(k,{size:13,className:`btn-spinner`}),` `,e(`settings.advanced.loading`)]}):e(`settings.advanced.load`)})]}),u(`details`,{className:`settings-more`,children:[u(`summary`,{children:[h(C,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.advanced.details`)]}),u(`div`,{className:`status-grid`,children:[t.model_size_gb!=null&&h(X,{label:e(`settings.advanced.modelSize`),value:u(`bdi`,{dir:`ltr`,children:[t.model_size_gb,` GB`]}),ok:!0}),t.model_device&&!$&&h(X,{label:e(`settings.advanced.device`),value:t.model_device.toUpperCase(),ok:t.model_device!==`cpu`}),t.model_context_size!=null&&h(X,{label:e(`settings.advanced.context`),value:e(`settings.ctx.tokens`,{size:`${(t.model_context_size/1024).toFixed(0)}K`}),ok:t.context_size_sufficient}),t.model_labels&&t.model_labels.length>0&&h(X,{label:e(`settings.advanced.capabilities`),value:se(e,t.model_labels),ok:!0}),h(X,{label:e(`settings.advanced.embedding`),value:t.embedding_model_loaded?e(`settings.advanced.available`):e(`settings.advanced.notLoaded`),ok:t.embedding_model_loaded}),t.gpu_name&&h(X,{label:`GPU`,value:h(`bdi`,{children:`${t.gpu_name}${t.gpu_vram_gb?` (${A(t.gpu_vram_gb)})`:``}`}),ok:!0}),h(X,{label:e(`settings.advanced.memory`),value:t.memory_available_gb==null?e(`settings.advanced.unknown`):u(`bdi`,{dir:`ltr`,children:[t.memory_available_gb,` GB`]}),ok:t.memory_available_gb!=null&&t.memory_available_gb>2}),t.processor_name&&h(X,{label:e(`settings.advanced.processor`),value:h(`bdi`,{children:t.processor_name}),ok:!0})]}),t.lemonade_running&&J!==null&&!$&&u(`div`,{className:`force-redownload-row`,children:[h(`span`,{className:`force-redownload-label`,children:e(`settings.advanced.corrupted`)}),h(`button`,{className:`btn-secondary`,onClick:()=>le(!0,void 0,!t.model_loaded),disabled:Z,children:Z?u(p.Fragment,{children:[h(k,{size:12,className:`btn-spinner`}),` `,e(`settings.advanced.downloading`)]}):e(`settings.advanced.redownload`)})]}),!fe&&Q&&h(F,{message:Q})]})]}):h(`div`,{className:`status-error`,children:h(`p`,{children:e(`settings.advanced.unreachable`)})})}),h(oe,{}),u(O,{title:e(`settings.advanced.serverTitle`),hint:e(`settings.advanced.serverHint`),targetId:`model-server`,children:[h(ie,{}),h(re,{})]}),u(O,{title:e(`settings.advanced.customTitle`),hint:_?a(_,`ltr`):e(`settings.advanced.customHint`),targetId:`custom-model`,children:[h(`p`,{className:`model-override-desc`,children:e(`settings.advanced.customDesc`)}),u(`div`,{className:`model-input-row`,children:[h(`input`,{type:`text`,className:`model-input${_?` has-override`:``}`,placeholder:e.bare(`settings.advanced.customPlaceholder`),value:s,dir:s?`ltr`:void 0,onChange:e=>{f(e.target.value),B(null),H(null),W(!1)},onKeyDown:e=>{e.key===`Enter`&&!I&&q&&x&&(e.preventDefault(),K())},disabled:!x||I,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":e(`settings.advanced.customAria`)}),h(`div`,{className:`model-btn-group`,children:h(`button`,{className:`btn-primary`,onClick:()=>{K()},disabled:!x||I||!q&&!U,"aria-label":e(`settings.advanced.customSave`),children:I?u(p.Fragment,{children:[h(k,{size:13,className:`btn-spinner`}),` `,e(`settings.models.applying`)]}):U?u(p.Fragment,{children:[h(w,{size:13}),` `,e(`settings.advanced.saved`)]}):e(`settings.advanced.save`)})})]}),h(`p`,{className:`model-status-hint`,children:e(`settings.advanced.customIds`)}),z&&h(ne,{message:z}),V&&u(`div`,{className:`model-warning`,role:`status`,children:[h(j,{size:14}),h(`div`,{className:`model-warning-content`,children:h(`p`,{children:V.kind===`unlisted`?e(`settings.advanced.customNotListed`,{id:V.id}):e(`settings.advanced.customNotChecked`)})})]})]})]})}function oe(){let e=c(),t=y(e=>e.show);return u(`section`,{className:`settings-card`,"aria-labelledby":`settings-logs-title`,children:[h(`h3`,{className:`settings-label`,id:`settings-logs-title`,children:e(`logs.title`)}),h(`p`,{className:`settings-hint`,children:e(`logs.settingsHint`)}),h(`div`,{className:`settings-row`,children:u(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`gaia`),children:[h(L,{size:13,"aria-hidden":`true`}),` `,e(`logs.view`)]})}),h(N,{})]})}var Y={cloud:`settings.advanced.capability.cloud`,chat:`settings.advanced.capability.chat`,vision:`settings.advanced.capability.vision`,"tool-calling":`settings.advanced.capability.toolCalling`,reasoning:`settings.advanced.capability.reasoning`,embeddings:`settings.advanced.capability.embeddings`,reranking:`settings.advanced.capability.reranking`,coding:`settings.advanced.capability.coding`,audio:`settings.advanced.capability.audio`,image:`settings.advanced.capability.image`,tts:`settings.advanced.capability.tts`,stt:`settings.advanced.capability.stt`,transcription:`settings.advanced.capability.transcription`};function se(e,t){return e.compose(e=>t.map(t=>Y[t]?e(Y[t]):t).join(e(`mem.listSeparator`)))}function X({label:e,value:t,ok:n,hint:r}){return u(`div`,{className:`status-row${r?` status-row--has-hint`:``}`,children:[h(`span`,{className:`status-label`,children:e}),u(`div`,{className:`status-value-wrap`,children:[h(`span`,{className:`status-value ${n?`ok`:`warn`}`,children:t}),r&&h(`span`,{className:`status-hint`,children:r})]})]})}export{J as AdvancedSettings};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{N as t,Ni as n,a as r,bt as i,c as a,f as o,gt as s,o as c,pt as l,s as u,t as d}from"./useT-CWiHVf7i.js";import{f,fn as p}from"./index-DnSSZ2b8.js";var m=e(n(),1);function h(){return i(`GET`,`/automations`)}function g(e,t){return i(`POST`,`/automations/${encodeURIComponent(e)}/${t?`pause`:`resume`}`,void 0,s)}function _(e){return i(`DELETE`,`/automations/${encodeURIComponent(e)}`,void 0,s)}function v(e){return e instanceof l?e.detail||e.message:e instanceof Error?e.message:String(e)}var y=[[`week`,604800],[`day`,86400],[`hour`,3600],[`minute`,60]];function b(e,n){let r=y.find(([,t])=>e%t===0)??y[y.length-1],i=Math.max(1,Math.round(e/r[1])),a=`schedules.span.${r[0]}.${new Intl.PluralRules(n.locale).select(i)}`;return t(a)?n.compose(e=>e(`schedules.desc.every`,{span:e(a,{n:i})})):null}function x(e,t){return new Intl.DateTimeFormat(d(t),{weekday:`short`,day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e*1e3))}var S=[`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`];function C(e,t){let n=e.split(`,`).map(e=>S.indexOf(e.trim()));return n.some(e=>e<0)?e:t.compose(e=>n.length===7?e(`schedules.days.every`):n.length===5&&n.every(e=>e<5)?e(`schedules.days.weekdays`):n.length===2&&n.includes(5)&&n.includes(6)?e(`schedules.days.weekends`):n.map(t=>e(`schedules.day.${t}`)).join(e(`schedules.days.join`)))}function w(e,t){return e.heartbeat?t(`settings.automations.kind.heartbeat`):t(`settings.automations.kind.${e.kind}`)}function T({item:e,busy:t,onToggle:n,onRemove:i}){let o=r(),s=u(`bdi`,{children:x(e.next_at,o)}),l=e.every_seconds>0?b(e.every_seconds,o):null,d=e.say||e.prompt;return a(`li`,{className:`settings-card automation-card${e.paused?` is-paused`:``}`,"data-automation":e.id,children:[a(`div`,{className:`automation-head`,children:[u(`h3`,{className:`settings-label automation-name`,children:u(`bdi`,{children:e.name})}),u(`span`,{className:`automation-kind`,children:w(e,o)}),e.paused&&u(`span`,{className:`automation-paused`,children:o(`settings.automations.paused`)})]}),a(`p`,{className:`settings-hint automation-when`,children:[e.every_seconds>0?a(c.Fragment,{children:[l&&u(`span`,{children:l}),!e.paused&&a(`span`,{children:[o(`settings.automations.next`),` `,s]})]}):a(`span`,{children:[o(`settings.automations.once`),` `,s]}),e.quiet&&a(`span`,{children:[o(`settings.automations.quiet`),` `,u(`bdi`,{dir:`ltr`,children:e.quiet})]}),e.days&&a(`span`,{children:[o(`settings.automations.days`),` `,C(e.days,o)]})]}),d&&u(`p`,{className:`automation-detail`,dir:`auto`,children:u(`bdi`,{children:d})}),e.check&&a(`p`,{className:`settings-hint automation-check`,children:[o(`settings.automations.check`),` `,u(`code`,{dir:`ltr`,children:e.check})]}),e.failures>0&&u(`p`,{className:`settings-error`,role:`status`,children:o.plural(`settings.automations.failing`,e.failures)}),a(`div`,{className:`settings-row`,children:[a(`button`,{type:`button`,className:`btn-secondary`,onClick:n,disabled:t,children:[t&&u(p,{size:13,className:`spin`,"aria-hidden":`true`}),e.paused?o(`settings.automations.resume`):o(`settings.automations.pause`)]}),u(`button`,{type:`button`,className:`btn-danger`,onClick:i,disabled:t,children:o(`settings.automations.remove`)})]})]})}function E(){let e=r(),t=o(e=>e.openSettings),[n,i]=(0,m.useState)(null),[s,l]=(0,m.useState)(null),[d,y]=(0,m.useState)(null),[b,x]=(0,m.useState)(new Set),[S,C]=(0,m.useState)(null),w=(0,m.useRef)(0),E=(0,m.useCallback)(()=>{let e=++w.current;h().then(t=>{e===w.current&&(l(null),i(t))}).catch(t=>{e===w.current&&l(v(t))})},[]);(0,m.useEffect)(E,[E]);let D=async(e,t)=>{x(t=>new Set(t).add(e)),y(null);try{await t()}catch(e){y(v(e))}finally{x(t=>{let n=new Set(t);return n.delete(e),n}),E()}},O=e=>{C(null),D(e.id,()=>_(e.id))};return a(`div`,{className:`settings-pane`,children:[u(`h2`,{className:`settings-pane-title`,children:e(`settings.section.automations`)}),u(`p`,{className:`settings-pane-lede`,children:e(`settings.automations.lede`)}),s&&a(c.Fragment,{children:[u(`p`,{className:`settings-error`,role:`alert`,children:e(`settings.automations.loadFailed`,{error:s})}),u(`button`,{type:`button`,className:`btn-secondary`,onClick:E,children:e(`settings.automations.retry`)})]}),!n&&!s&&a(`p`,{className:`settings-hint`,children:[u(p,{size:13,className:`spin`}),` `,e(`settings.loading`)]}),n&&n.delivers===null&&n.automations.length>0&&u(`p`,{className:`settings-hint automation-unchecked`,children:e(`settings.automations.deliveryUnknown`)}),n&&n.delivers===!1&&n.automations.length>0&&a(`div`,{className:`settings-warning`,children:[u(`p`,{children:e(`settings.automations.noDelivery`)}),u(`button`,{type:`button`,className:`btn-secondary automation-messaging`,onClick:()=>t(`messaging`),children:e(`settings.automations.openMessaging`)})]}),d&&u(`p`,{className:`settings-error`,role:`alert`,children:d}),n&&n.automations.length===0&&u(`p`,{className:`settings-hint automation-empty`,children:e(`settings.automations.empty`)}),n&&n.automations.length>0&&u(`ul`,{className:`automation-list`,children:n.automations.map(e=>u(T,{item:e,busy:b.has(e.id),onToggle:()=>void D(e.id,()=>g(e.id,!e.paused)),onRemove:()=>C(e)},e.id))}),S&&u(f,{title:e(`settings.automations.removeTitle`,{name:S.name}),confirmLabel:e(`settings.automations.remove`),cancelLabel:e(`settings.automations.cancel`),danger:!0,onConfirm:()=>O(S),onCancel:()=>C(null),children:u(`p`,{children:e(`settings.automations.removeBody`)})})]})}export{E as AutomationsSettings};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Br as t,Fr as n,Gr as r,Hr as i,Ir as a,Jr as o,Kr as s,L as c,Lr as l,N as u,Ni as d,Nr as f,Pr as p,Rr as m,Ur as h,Vr as g,Wr as _,Xr as v,Yr as y,a as b,c as x,f as S,i as C,o as w,qr as ee,r as T,s as E,zr as D}from"./useT-CWiHVf7i.js";import{At as O,Ct as te,Dt as ne,Et as k,Kt as A,Ln as j,Mn as M,Mt as N,Pn as P,Sn as F,St as I,Tt as L,bt as R,d as z,f as re,fn as B,i as V,jn as H,jt as U,r as W,wt as G,xn as K,xt as ie}from"./index-DnSSZ2b8.js";var q=e(d(),1),J={google:[{title:`guide.google.project`,body:`guide.google.projectBody`,link:{href:`https://console.cloud.google.com/projectcreate`,label:`guide.google.projectLink`}},{title:`guide.google.apis`,body:`guide.google.apisBody`,link:{href:`https://console.cloud.google.com/flows/enableapi?apiid=gmail.googleapis.com,calendar-json.googleapis.com,drive.googleapis.com`,label:`guide.google.apisLink`}},{title:`guide.google.consent`,body:`guide.google.consentBody`,link:{href:`https://console.cloud.google.com/auth/overview`,label:`guide.google.consentLink`}},{title:`guide.google.client`,body:`guide.google.clientBody`,link:{href:`https://console.cloud.google.com/auth/clients/create`,label:`guide.google.clientLink`}},{title:`guide.pasteBoth`}],microsoft:[{title:`guide.microsoft.register`,body:`guide.microsoft.registerBody`,link:{href:`https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade`,label:`guide.microsoft.registerLink`}},{title:`guide.microsoft.redirect`,body:`guide.microsoft.redirectBody`},{title:`guide.microsoft.paste`,body:`guide.microsoft.pasteBody`}],microsoft_work:[{title:`guide.microsoft.register`,body:`guide.microsoftWork.registerBody`,link:{href:`https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade`,label:`guide.microsoft.registerLink`}},{title:`guide.microsoft.redirect`,body:`guide.microsoft.redirectBody`},{title:`guide.microsoftWork.paste`,body:`guide.microsoftWork.pasteBody`}],"mcp-github":[{title:`guide.github.token`,body:`guide.github.tokenBody`,link:{href:`https://github.com/settings/tokens/new?description=GAIA&scopes=repo,read:user`,label:`guide.github.tokenLink`}},{title:`guide.pasteIt`}],"mcp-slack":[{title:`guide.slack.app`,body:`guide.slack.appBody`,link:{href:`setup_url`,label:`guide.slack.appLink`}},{title:`guide.slack.token`,body:`guide.slack.tokenBody`},{title:`guide.slack.invite`,body:`guide.slack.inviteBody`},{title:`guide.pasteIt`}],"mcp-discord":[{title:`guide.discord.bot`,body:`guide.discord.botBody`,link:{href:`https://discord.com/developers/applications`,label:`guide.discord.botLink`}},{title:`guide.discord.intent`,body:`guide.discord.intentBody`},{title:`guide.discord.invite`,body:`guide.discord.inviteBody`},{title:`guide.pasteIt`}],"mcp-notion":[{title:`guide.notion.integration`,body:`guide.notion.integrationBody`,link:{href:`https://www.notion.so/profile/integrations`,label:`guide.notion.integrationLink`}},{title:`guide.notion.share`,body:`guide.notion.shareBody`},{title:`guide.pasteIt`}],"mcp-brave-search":[{title:`guide.brave.key`,body:`guide.brave.keyBody`,link:{href:`https://api-dashboard.search.brave.com/`,label:`guide.brave.keyLink`}},{title:`guide.pasteIt`}],"mcp-tavily":[{title:`guide.tavily.key`,body:`guide.tavily.keyBody`,link:{href:`https://app.tavily.com/`,label:`guide.tavily.keyLink`}},{title:`guide.pasteIt`}]},ae={microsoft_work:[`tenant_id`]};function Y(e){return e in J}function X(e,t){return!Y(e)||(ae[e]??[]).includes(t)}function Z({connectorId:e,setupUrl:t}){let n=b(),r=J[e];return r?E(`div`,{className:`connector-guide`,children:E(`ol`,{className:`setup-steps`,children:r.map((e,r)=>{let i=e.link&&(e.link.href===`setup_url`?t:e.link.href),a=i?U(i):``;return x(`li`,{className:`setup-step`,children:[E(`span`,{className:`setup-step-number`,"aria-hidden":`true`,children:E(`bdi`,{dir:`ltr`,children:r+1})}),x(`div`,{className:`setup-step-body`,children:[E(`h4`,{className:`settings-label`,children:n(e.title)}),e.body&&E(`p`,{className:`settings-hint`,children:n(e.body)}),e.link&&a&&E(`div`,{children:x(`a`,{className:`btn-secondary setup-step-link`,href:a,target:`_blank`,rel:`noopener noreferrer`,children:[n(e.link.label),E(K,{size:12,"aria-hidden":`true`,className:`setup-step-link-icon`})]})})]})]},e.title+r)})})}):null}function Q(e,t,n,r=!1){return!u(t)||T(t)!==n?n:r?e.bare(t):e(t)}function oe(e,t){return Q(e,`connectors.${t.id}.description`,t.description)}function se(e,t){return Q(e,`connectors.${t.id}.description`,t.description,!0)}function $(e,t,n,r=!1){return Q(e,`connectors.${t}.${n.key}.label`,n.label,r)}function ce(e,t,n){return Q(e,`connectors.${t}.${n.key}.help`,n.help_md)}function le(e,t,n){return e.compose((e,r)=>{let i=C(r);return e(`settings.connectors.required`,{fields:n.map(e=>Q(i,`connectors.${t}.${e.key}.label`,e.label,!0)).join(e(`settings.connectors.fieldsJoin`))})})}function ue(e){return e.type===`mcp_server`&&e.configured}function de({connector:e,onChanged:t}){let n=b(),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(null),d=(0,q.useRef)(null),f=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!r)return;let e=e=>{let t=e.target;d.current&&!d.current.contains(t)&&f.current&&!f.current.contains(t)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);let p=(0,q.useCallback)(()=>i(!1),[]);if(A(r,p),(0,q.useEffect)(()=>{if(!r)return;let e=()=>{if(!d.current)return;let e=d.current.getBoundingClientRect();u({top:e.bottom+4,right:window.innerWidth-e.right})};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[r]),!ue(e))return null;let h=e=>{e.stopPropagation(),e.preventDefault()},_=e=>{if(h(e),!r&&d.current){let e=d.current.getBoundingClientRect();u({top:e.bottom+4,right:window.innerWidth-e.right})}i(e=>!e)},v=async e=>{o(!0),c(null);try{await e(),i(!1),t()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}};return x(`div`,{className:`connector-tile-menu`,onClick:h,onKeyDown:h,children:[E(`button`,{ref:d,type:`button`,className:`connector-tile-menu-trigger`,"aria-haspopup":`menu`,"aria-expanded":r,"aria-label":n(`settings.connectors.actions`),onClick:_,disabled:a,children:E(F,{size:14})}),r&&l&&x(`div`,{ref:f,role:`menu`,className:`connector-tile-menu-popup`,style:{position:`fixed`,top:l.top,right:l.right},children:[e.enabled?E(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void v(()=>m(e.id)),disabled:a,children:n(`settings.connectors.disable`)}):E(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item`,onClick:()=>void v(()=>g(e.id)),disabled:a,children:n(`settings.connectors.enable`)}),!e.custom&&x(w.Fragment,{children:[E(`div`,{className:`connector-tile-menu-divider`}),E(`button`,{role:`menuitem`,type:`button`,className:`connector-tile-menu-item connector-tile-menu-item--danger`,onClick:()=>void v(()=>D(e.id)),disabled:a,children:n(`settings.connectors.disconnect`)})]}),s&&E(`div`,{className:`connector-tile-menu-error`,children:s})]})]})}function fe({email:e,max:t}){let n=L(e,t);return E(`bdi`,{dir:`ltr`,className:`account-address`,title:n===e?void 0:e,children:n})}function pe({account:e}){let t=b();return e.status===`ok`?x(`span`,{className:`connector-status ok`,children:[E(M,{size:12,"aria-hidden":`true`}),t(`settings.connectors.connected`)]}):x(`span`,{className:`connector-status failed`,children:[E(H,{size:12,"aria-hidden":`true`}),t(e.status===`reauth_required`?`settings.connectors.signInExpired`:`settings.connectors.notWorking`)]})}function me({connector:e,onChanged:n,onSignIn:r}){let i=b(),a=e.accounts??[],o=e.display_name,[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(null),p=async(e,t)=>{c(e),u(null);try{return await t(),!0}catch(e){return u(e instanceof Error?e.message:String(e)),!1}finally{c(null)}},m=t=>void p(`default:${G(t)}`,async()=>{await y(e.id,G(t)),n()}),h=async r=>{await p(`disconnect`,async()=>{await t(e.id,G(r)),n()})&&f(null)};return x(`div`,{className:`connector-accounts`,children:[E(`ul`,{"aria-label":i(`settings.connectors.accountList`,{name:o}),children:a.map((e,t)=>{let n=G(e),o={address:R(i.locale,e.email||e.account_id)};return x(`li`,{className:`connector-account${k(e)?` connector-account--attention`:``}`,children:[x(`span`,{className:`connector-account-who`,children:[E(fe,{email:e.email||e.account_id}),e.is_default&&a.length>1&&E(`span`,{className:`connector-account-default`,children:i(`settings.connectors.default`)})]}),E(pe,{account:e}),x(`span`,{className:`connector-account-actions`,children:[k(e)&&x(`button`,{type:`button`,className:`btn-primary`,disabled:s!==null,"aria-label":i(`settings.connectors.reconnectNamed`,o),onClick:()=>void p(`signin:${n}`,()=>r(n)),children:[s===`signin:${n}`&&E(B,{size:12,className:`spin`}),i(`settings.connectors.reconnect`)]}),!e.is_default&&e.status===`ok`&&E(`button`,{type:`button`,className:`btn-secondary`,disabled:s!==null,"aria-label":i(`settings.connectors.makeDefaultNamed`,o),onClick:()=>m(e),children:i(`settings.connectors.makeDefault`)}),E(`button`,{type:`button`,className:`btn-secondary`,disabled:s!==null,"aria-label":i(`settings.connectors.disconnectNamed`,o),onClick:()=>f(e),children:i(`settings.connectors.disconnect`)})]})]},n==="default"?`default:${t}`:n)})}),a.length>1&&E(`p`,{className:`connector-account-hint`,children:i(`settings.connectors.defaultHint`)}),l&&!d&&x(`div`,{className:`configure-error`,role:`alert`,children:[E(H,{size:12}),` `,l]}),d&&x(re,{title:i(`settings.connectors.disconnectAccountAsk`,{address:R(i.locale,d.email||d.account_id)}),confirmLabel:i(`settings.connectors.disconnect`),cancelLabel:i(`settings.connectors.cancel`),onConfirm:()=>void h(d),onCancel:()=>{f(null),u(null)},danger:!0,busy:s===`disconnect`,children:[E(`p`,{children:i(a.length>1?`settings.connectors.disconnectAccountOthers`:`settings.connectors.disconnectAccountLast`,{name:o})}),l&&E(`p`,{className:`configure-error`,role:`alert`,children:l})]})]})}var he={"https://www.googleapis.com/auth/gmail.readonly":`settings.connectors.scope.gmailRead`,"https://www.googleapis.com/auth/gmail.modify":`settings.connectors.scope.gmailModify`,"https://www.googleapis.com/auth/gmail.send":`settings.connectors.scope.gmailSend`,"https://www.googleapis.com/auth/gmail.compose":`settings.connectors.scope.gmailCompose`,"https://www.googleapis.com/auth/calendar.readonly":`settings.connectors.scope.calendarRead`,"https://www.googleapis.com/auth/calendar.events":`settings.connectors.scope.calendarEvents`,"https://www.googleapis.com/auth/drive.readonly":`settings.connectors.scope.driveRead`,"https://www.googleapis.com/auth/drive.file":`settings.connectors.scope.driveFile`,"https://www.googleapis.com/auth/spreadsheets.readonly":`settings.connectors.scope.sheetsRead`,"https://www.googleapis.com/auth/spreadsheets":`settings.connectors.scope.sheets`,openid:`settings.connectors.scope.openid`,"https://www.googleapis.com/auth/userinfo.email":`settings.connectors.scope.email`,email:`settings.connectors.scope.email`,profile:`settings.connectors.scope.profile`,"https://graph.microsoft.com/Mail.Read":`settings.connectors.scope.gmailRead`,"https://graph.microsoft.com/Mail.ReadWrite":`settings.connectors.scope.outlookMail`,"https://graph.microsoft.com/Mail.Send":`settings.connectors.scope.outlookSend`,"https://graph.microsoft.com/Calendars.ReadWrite":`settings.connectors.scope.outlookCalendar`,"https://graph.microsoft.com/Calendars.Read":`settings.connectors.scope.outlookCalendarRead`,"https://graph.microsoft.com/User.Read":`settings.connectors.scope.microsoftProfile`};function ge(e,t){return t.length>0?[]:e.available_scopes?.length?e.available_scopes:e.default_scopes}function _e(e,t){let n=he[e];return n?t(n):e.split(/[/.:]/).pop()??e}var ve=6,ye=[`email`,`e-mail`,`inbox`,`calendar`],be={google:ye,microsoft:ye,microsoft_work:ye},xe=[`use`],Se=`gaia`;function Ce(e){let t=W(e.id);return t?c(`settings.connectors.personalize.source.${t}`):c(`settings.connectors.personalize.source.other`,{name:e.display_name})}async function we(e,t,n){if(t.type===`mcp_server`){let r=n.find(e=>e.id===Se)?.namespaced_agent_id;if(!r)throw Error(e(`settings.connectors.personalize.noAgent`,{name:t.display_name}));t.activations?.[r]||await f(t.id,r,xe)}V({connectorId:t.id,displayName:t.display_name})}function Te({connector:e,primary:t,onStarted:n}){let r=b(),{agents:i}=S(),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(null),l=async()=>{o(!0),c(null);try{await we(r,e,i),n?.()}catch(e){c(r(`settings.connectors.personalize.failed`,{error:e instanceof Error?e.message:String(e)}))}finally{o(!1)}};return x(w.Fragment,{children:[x(`button`,{type:`button`,className:t?`btn-primary`:`btn-secondary`,onClick:()=>void l(),disabled:a,children:[a&&E(B,{size:12,className:`spin`}),r(`settings.connectors.personalize.button`)]}),s&&E(`span`,{className:`connector-personalize-error`,role:`alert`,children:s})]})}function Ee(e,t){return e.nothing_stored?t(`settings.connectors.nothingStored`):!(`revoke_supported`in e)||e.revoke_supported&&e.revoked_remotely?null:e.revoke_attempted?t(`settings.connectors.notRevoked`,{reason:String(e.revoke_error??t.bare(`settings.advanced.unknown`))}):e.revoke_error?t(`settings.connectors.localOnly`,{reason:String(e.revoke_error)}):t(`settings.connectors.noRevokeApi`)}function De(){let e=b(),[t,n]=(0,q.useState)([]),[r,a]=(0,q.useState)([]),[o,s]=(0,q.useState)(!0),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(null),f=S(e=>e.settingsConnector),[p,m]=(0,q.useState)(f),[h,g]=(0,q.useState)(``);(0,q.useEffect)(()=>{f&&m(f)},[f]);let[y,C]=(0,q.useState)(new Set),[T,D]=(0,q.useState)(null),[O,te]=(0,q.useState)(null),ne=(0,q.useRef)([]);ne.current=t;let[k,A]=(0,q.useState)({}),j=(0,q.useRef)({}),M=(e,t)=>A(n=>({...n,[e]:t})),N=(0,q.useCallback)(e=>{j.current[e]=(j.current[e]??0)+1,M(e,null)},[]),P=(0,q.useCallback)(async e=>{let t=(j.current[e]??0)+1;j.current[e]=t,M(e,{state:`checking`});let n;try{let t=await v(e);n=t.ok?{state:`ok`}:{state:`failed`,detail:t.detail,slow:t.reason===`timeout`}}catch(e){n={state:`failed`,detail:e instanceof Error?e.message:String(e)}}j.current[e]===t&&M(e,n)},[]),F=(0,q.useCallback)(async()=>{try{let[{connectors:e},{agent_mcps:t}]=await Promise.all([ee(),_()]);n(e),C(new Set(e.filter(e=>!(`error`in e)&&(e.configured||!!e.accounts?.length)).map(e=>e.id))),a(t),l(null)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}},[]);(0,q.useEffect)(()=>{F()},[F]),(0,q.useEffect)(()=>{if(!O)return;let e=[...document.querySelectorAll(`.connector-tile`)].find(e=>e.dataset.connectorId===O)?.querySelector(`.connector-tile-header`);e&&(e.scrollIntoView?.({block:`nearest`}),document.activeElement&&document.activeElement!==document.body||e.focus({preventScroll:!0}))},[O]);let I=e=>m(t=>t===e?null:e),L=(0,q.useCallback)(async e=>{try{let t=await i(e),r=ne.current.find(t=>t.id===e);r&&`configured`in r&&!r.configured&&t.configured?(D(e),m(t=>t??e)):t.configured&&t.enabled!==!1||D(t=>t===e?null:t),r&&`configured`in r&&r.configured&&!t.configured&&(C(t=>new Set([...t].filter(t=>t!==e))),te(e)),n(n=>n.map(n=>n.id===e?t:n))}catch{F()}},[F]);ie((0,q.useCallback)(t=>{t.reason===`disconnected`&&d(Ee(t.payload,e)),t.connectorId?L(t.connectorId):F()},[L,F,e]));let R=h.trim().toLowerCase(),re=t=>`error`in t?[t.display_name]:[t.display_name,t.description,se(e,t),...be[t.id]??[]],V=t.filter(e=>!R||re(e).some(e=>e.toLowerCase().includes(R))),U=V.filter(e=>`error`in e),W=V.filter(e=>!(`error`in e)),G=W.filter(e=>y.has(e.id)),K=W.filter(e=>!y.has(e.id)&&e.type===`oauth_pkce`),J=W.filter(e=>!y.has(e.id)&&e.type!==`oauth_pkce`),ae=!t.some(e=>!(`error`in e)&&e.configured),Y=(e,t)=>O&&t.some(e=>e.id===O)?`${e}:${O}`:e,X=e=>!!O&&e.some(e=>e.id===O),Z=e=>E(`div`,{className:`connectors-list`,children:e.map(e=>E(Ae,{connector:e,wasConnected:y.has(e.id)||O===e.id,justConnected:T===e.id,onPersonalizeStarted:()=>D(null),expanded:p===e.id,onToggle:()=>I(e.id),onChanged:()=>void L(e.id),check:k[e.id]??null,onRunCheck:()=>void P(e.id),onClearCheck:()=>N(e.id)},e.id))});return x(`section`,{className:`connectors-section`,"aria-label":e(`settings.section.connectors`),children:[E(`p`,{className:`settings-pane-lede`,children:e(`settings.connectors.lede`)}),c&&x(`div`,{className:`error-banner`,children:[E(H,{size:14}),E(`span`,{children:c})]}),u&&x(`div`,{className:`error-banner`,role:`status`,onClick:()=>d(null),children:[E(H,{size:14}),E(`span`,{children:u})]}),o?E(`div`,{className:`connectors-loading`,children:E(B,{size:16,className:`spin`})}):x(w.Fragment,{children:[t.length>ve&&E(`input`,{className:`settings-input`,type:`search`,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.connectors.search`),"aria-label":e(`settings.connectors.search`)}),t.length===0&&!c&&E(`p`,{className:`settings-hint`,children:e(`settings.connectors.none`)}),R&&V.length===0&&E(`p`,{className:`settings-hint`,children:e(`settings.connectors.noMatch`)}),U.length>0&&E(z,{title:e(`settings.connectors.unavailable`),hint:Oe(U,e),count:U.length,defaultOpen:!0,forceOpen:!!R,children:E(`div`,{className:`connectors-list`,children:U.map(e=>E(ke,{connector:e},e.id))})}),G.length>0&&E(z,{title:e(`settings.connectors.connected`),count:G.filter(e=>e.configured).length,defaultOpen:!0,forceOpen:!!R,children:Z(G)}),K.length>0&&E(z,{title:e(`settings.connectors.accounts`),hint:e(`settings.connectors.accountsHint`),count:K.length,defaultOpen:ae||X(K),forceOpen:!!R,children:Z(K)},Y(`accounts`,K)),J.length>0&&E(z,{title:e(`settings.connectors.servers`),hint:e(`settings.connectors.serversHint`),count:J.length,defaultOpen:X(J),forceOpen:!!R,children:Z(J)},Y(`servers`,J)),r.length>0&&!R&&E(z,{title:e(`settings.connectors.agentServers`),count:r.length,children:E(Fe,{servers:r,expanded:p,onToggle:I})})]})]})}function Oe(e,t){let n=e.find(e=>e.reason===`activations_unreadable`&&e.path);return n?.path?t(`settings.connectors.activationsUnreadableHint`,{path:R(t.locale,n.path)}):t(`settings.connectors.unavailableHint`)}function ke({connector:e}){let t=b();return E(`div`,{className:`connector-tile`,children:x(`div`,{className:`connector-tile-header connector-tile-header--static`,children:[E(`bdi`,{className:`connector-tile-name`,children:e.display_name}),E(`span`,{className:`connector-status disabled`,children:t(`settings.connectors.unavailableStatus`)})]})})}function Ae({connector:e,wasConnected:t,justConnected:n,onPersonalizeStarted:r,expanded:i,onToggle:a,onChanged:o,check:s,onRunCheck:c,onClearCheck:l}){let u=b(),{agents:d}=S(),f=e.type===`mcp_server`?Re(d,e.id):null,p=e.accounts??[];return x(`div`,{className:`connector-tile${i?` connector-tile--open`:``}`,"data-connector-id":e.id,children:[x(`div`,{className:`connector-tile-row`,children:[x(`button`,{type:`button`,className:`connector-tile-header`,onClick:a,"aria-expanded":i,children:[E(`bdi`,{className:`connector-tile-name`,children:e.display_name}),e.configured&&E(`span`,{className:`connector-tile-type`,children:e.type===`oauth_pkce`?`OAuth`:`MCP`}),(()=>{if(p.length>1){let e=p.filter(k);return x(w.Fragment,{children:[x(`span`,{className:`connector-status ok`,children:[e.length===0&&E(M,{size:12}),u.plural(`settings.connectors.accountCount`,p.length)]}),e.length>0&&x(`span`,{className:`connector-status failed`,role:`status`,children:[E(H,{size:12}),u(e.some(e=>e.status===`reauth_required`)?`settings.connectors.signInExpired`:`settings.connectors.notWorking`)]})]})}return p.length===1&&k(p[0])?x(`span`,{className:`connector-status failed`,role:`status`,children:[E(H,{size:12}),u(p[0].status===`reauth_required`?`settings.connectors.signInExpired`:`settings.connectors.notWorking`)]}):e.configured?e.type===`mcp_server`&&e.enabled===!1?E(`span`,{className:`connector-status disabled`,children:u(`settings.connectors.paused`)}):s?.state===`failed`&&!s.slow?E(`span`,{className:`connector-status failed`,role:`status`,children:u(`settings.connectors.notWorking`)}):e.type===`mcp_server`&&s?.state!==`ok`?E(`span`,{className:`connector-status idle`,role:`status`,children:u(s?.state===`checking`?`settings.connectors.checkingShort`:`settings.connectors.turnedOn`)}):x(`span`,{className:`connector-status ok`,children:[E(M,{size:12}),e.account_id?E(fe,{email:e.account_id,max:40}):u(`settings.connectors.connected`)]}):t?E(`span`,{className:`connector-status idle`,role:`status`,children:u(`settings.connectors.disconnected`)}):e.configurable===!1?E(`span`,{className:`connector-status idle`,children:u(`settings.connectors.setupRequired`)}):null})(),E(`span`,{className:`connector-tile-chevron`,children:E(i?P:j,{size:14})})]}),!i&&E(de,{connector:e,onChanged:o})]}),i&&x(`div`,{className:`connector-detail`,children:[e.type===`oauth_pkce`?E(je,{connector:e,onChanged:o}):E(Ne,{connector:e,onChanged:o,showEnabledToggle:!f,check:s,onRunCheck:c,onClearCheck:l}),e.configured&&e.enabled!==!1&&!e.custom&&x(`div`,{className:`connector-personalize${n?` connector-personalize--offer`:``}`,role:n?`status`:void 0,children:[E(`p`,{children:u(n?`settings.connectors.personalize.offer`:`settings.connectors.personalize.tile`,{source:Ce(e),name:e.display_name})}),E(Te,{connector:e,primary:n,onStarted:r})]}),e.configured&&E(Le,{connectorId:e.id,connectorName:e.display_name,connectorType:e.type,connectorEnabled:e.enabled!==!1,soleAgent:f,onConnectorChanged:o,onClearCheck:l})]})]})}function je({connector:e,onChanged:t}){let r=b(),[i,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)({}),[d,f]=(0,q.useState)(null),{agents:m}=S(),h=m.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e.id)),g=h.map(e=>e.namespaced_agent_id).join(`,`),[_,v]=(0,q.useState)(()=>new Set);(0,q.useEffect)(()=>{v(new Set(h.map(e=>e.namespaced_agent_id)))},[g]);let y=e=>v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),C=()=>[..._];(0,q.useEffect)(()=>{let e=()=>{t()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[t]);let ee=async()=>{o(!0),c(null);try{let t=await p(e.id,ge(e,C()),C());I(t.authorization_url)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},T=async()=>{o(!0),c(null),f(null);try{let t=await n(e.id,ge(e,C()),C());f(t)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}};(0,q.useEffect)(()=>{e.configured&&f(null)},[e.configured]),ie((0,q.useCallback)(t=>{if(t.connectorId===e.id){if(t.reason===`oauth_error`){let e=t.payload.reason;c(e===`cancelled`?r(`connectCard.cancelled`):e?r(`connectCard.failed`):String(t.payload.error??r(`settings.connectors.deviceFailed`))),f(null)}else t.reason===`oauth_completed`&&f(null)}},[e.id,r]));let[O,k]=(0,q.useState)(null),A=async(n=!1)=>{o(!0),c(null);try{await(n?D(e.id,{all:!0}):D(e.id)),k(null),t()}catch(e){let t=n?null:te(e);t?k(t):c(e instanceof Error?e.message:String(e))}finally{o(!1)}},j=ne(e),M=(e.accounts?.length??0)>0,N=async t=>{let n=e.scopes.length>0?e.scopes:ge(e,[]),r=await p(e.id,n,[],t);I(r.authorization_url)},P=async()=>{o(!0),c(null);try{await N({addAccount:!0})}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},F=E(`button`,{type:`button`,className:`connector-add-account`,disabled:i,onClick:()=>void P(),children:r(`settings.connectors.addAccount`,{name:e.display_name})}),L=async()=>{let n=(e.oauth_setup_fields??[]).filter(e=>e.required!==!1&&!l[e.key]?.trim());if(n.length)c(le(r,e.id,n));else{o(!0),c(null);try{let n=ge(e,C()),r=await a(e.id,{...l,scopes:n,grant_agents:C()}),i=typeof r.authorization_url==`string`?r.authorization_url:null;i&&I(i),t()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}}},R=e.oauth_setup_fields??[],z=e.configurable===!1&&!e.configured&&R.length>0,V=Y(e.id),U=h.length>1;return x(`div`,{className:`configure-body`,children:[e.description&&E(`p`,{className:`connector-desc`,children:E(`bdi`,{children:oe(r,e)})}),z&&x(`div`,{className:`oauth-setup-form`,children:[V?E(Z,{connectorId:e.id}):E(`p`,{className:`connector-desc`,children:r(`settings.connectors.firstSetup`)}),R.map(t=>x(`label`,{className:`oauth-setup-field`,children:[E(`span`,{className:`oauth-setup-label`,children:$(r,e.id,t)}),E(`input`,{type:t.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:t.placeholder,value:l[t.key]??``,onChange:e=>u(n=>({...n,[t.key]:e.target.value})),autoComplete:`off`,spellCheck:!1}),t.help_md&&X(e.id,t.key)&&E(`span`,{className:`oauth-setup-help`,children:E(`bdi`,{children:ce(r,e.id,t)})})]},t.key))]}),!e.configured&&!M&&U&&x(`div`,{className:`oauth-grant-onconnect`,children:[E(`p`,{className:`oauth-grant-onconnect-label`,children:r(`settings.connectors.grantOnConnect`)}),h.map(e=>x(`label`,{className:`oauth-grant-onconnect-item`,children:[E(`input`,{type:`checkbox`,checked:_.has(e.namespaced_agent_id),onChange:()=>y(e.namespaced_agent_id)}),E(`span`,{children:e.name})]},e.namespaced_agent_id)),E(`p`,{className:`oauth-grant-onconnect-help`,children:r(`settings.connectors.grantLater`)})]}),!z&&E(Me,{connector:e,onChanged:t}),j&&E(me,{connector:e,onChanged:t,onSignIn:e=>N({account:e})}),s&&!O&&x(`div`,{className:`configure-error`,children:[E(H,{size:12}),` `,s]}),O&&x(re,{title:r(`settings.connectors.disconnectAllAsk`,{n:O.length,name:e.display_name}),confirmLabel:r(`settings.connectors.disconnectAll`),cancelLabel:r(`settings.connectors.cancel`),onConfirm:()=>void A(!0),onCancel:()=>{k(null),c(null),t()},danger:!0,busy:i,children:[E(`ul`,{className:`confirm-accounts`,children:O.map(e=>E(`li`,{children:E(fe,{email:e})},e))}),E(`p`,{children:r(`settings.connectors.disconnectAllBody`)}),s&&E(`p`,{className:`configure-error`,role:`alert`,children:s})]}),x(`div`,{className:`configure-actions`,children:[j?F:e.configured?x(w.Fragment,{children:[E(`button`,{className:`btn-secondary`,disabled:i,onClick:()=>void A(),children:i?E(B,{size:12,className:`spin`}):r(`settings.connectors.disconnect`)}),M&&F]}):z?E(`button`,{className:`btn-primary`,disabled:i,onClick:()=>void L(),children:i?E(B,{size:12,className:`spin`}):x(w.Fragment,{children:[E(K,{size:12}),` `,r(`settings.connectors.saveConnect`)]})}):e.configurable===!1?E(`span`,{className:`connector-setup-required`,title:e.config_error??void 0,children:r(`settings.connectors.setupRequired`)}):x(w.Fragment,{children:[E(`button`,{className:`btn-primary`,disabled:i||d!==null,onClick:()=>void ee(),children:i?E(B,{size:12,className:`spin`}):x(w.Fragment,{children:[E(K,{size:12}),` `,r(`settings.key.connect`)]})}),e.supports_device_code&&E(`button`,{className:`btn-secondary`,disabled:i||d!==null,onClick:()=>void T(),title:r(`settings.connectors.codeTitle`),children:r(`settings.connectors.code`)})]}),(e.docs_url||e.product_url)&&x(`a`,{href:e.docs_url||e.product_url||`#`,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[r(`settings.connectors.learnMore`),` `,E(K,{size:11})]})]}),d&&!e.configured&&x(`div`,{className:`device-code-block`,children:[x(`p`,{className:`device-code-instructions`,children:[r(`settings.connectors.goTo`),` `,E(`a`,{href:d.verification_uri,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),I(d.verification_uri)},children:d.verification_uri})]}),x(`div`,{className:`device-code-value`,children:[E(`code`,{children:d.user_code}),E(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void navigator.clipboard?.writeText(d.user_code),title:r(`settings.connectors.copyCode`),children:r(`gpu.copy`)})]}),x(`p`,{className:`device-code-waiting`,children:[E(B,{size:12,className:`spin`}),` `,r(`settings.connectors.waiting`)]}),E(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>f(null),children:r(`settings.key.cancel`)})]})]})}function Me({connector:e,onChanged:t}){let n=b(),[r,i]=(0,q.useState)(!1),[o,s]=(0,q.useState)({}),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(null),m=e.oauth_setup_fields??[];if(m.length===0)return null;let h=e.oauth_client,g=h?.source===`keyring`?n(`settings.connectors.savedClient`,{id:h.client_id??``}):h?.source===`env`?n(`settings.connectors.envClient`,{id:h.client_id??``}):n(`settings.connectors.noClient`),_=async()=>{if(!o.client_id?.trim())p(n(`settings.connectors.clientRequired`));else{l(!0),p(null),d(!1);try{await a(e.id,{...Object.fromEntries(Object.entries(o).map(([e,t])=>[e,t.trim()])),save_only:!0}),d(!0),s({}),t(),setTimeout(()=>d(!1),2200)}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}}};return x(`div`,{className:`oauth-client-editor`,children:[x(`button`,{type:`button`,className:`oauth-client-editor__toggle`,onClick:()=>i(e=>!e),"aria-expanded":r,children:[E(r?P:j,{size:12}),E(`span`,{children:n(`settings.connectors.client`)}),E(`span`,{className:`oauth-client-editor__status`,children:g})]}),r&&x(`div`,{className:`oauth-setup-form`,children:[E(`p`,{className:`connector-desc`,children:n(`settings.connectors.clientHelp`)}),m.map(t=>x(`label`,{className:`oauth-setup-field`,children:[E(`span`,{className:`oauth-setup-label`,children:$(n,e.id,t)}),E(`input`,{type:t.kind===`secret`?`password`:`text`,className:`oauth-setup-input`,placeholder:t.kind===`secret`&&h?.source===`keyring`&&h.has_secret?`••••••••`:t.placeholder,value:o[t.key]??``,onChange:e=>s(n=>({...n,[t.key]:e.target.value})),autoComplete:`off`,spellCheck:!1}),t.help_md&&E(`span`,{className:`oauth-setup-help`,children:E(`bdi`,{children:ce(n,e.id,t)})})]},t.key)),f&&x(`div`,{className:`configure-error`,children:[E(H,{size:12}),` `,f]}),E(`div`,{className:`configure-actions`,children:E(`button`,{className:`btn-primary`,disabled:c||!o.client_id?.trim(),onClick:()=>void _(),children:c?E(B,{size:12,className:`spin`}):u?x(w.Fragment,{children:[E(M,{size:12}),` `,n(`settings.advanced.saved`)]}):n(`settings.connectors.saveClient`)})})]})]})}function Ne({connector:e,onChanged:t,check:n,onRunCheck:r,onClearCheck:i,showEnabledToggle:o=!0}){let s=b(),[c,l]=(0,q.useState)(()=>Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[h,_]=(0,q.useState)(null);(0,q.useEffect)(()=>{l(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``])))},[e.mcp_env_keys.join(`,`)]);let v=e.mcp_env_keys.length===0,y=!e.configured&&!v&&Y(e.id),S=Object.values(c).every(e=>e.trim()===``),ee=async()=>{let n=Object.fromEntries(Object.entries(c).map(([e,t])=>[e,t.trim()]).filter(([,e])=>e!==``));if(!v&&Object.keys(n).length===0)return;let i=e.config_fields?.find(e=>e.prefix&&e.key in n&&!n[e.key].startsWith(e.prefix));if(i)_(s.compose((t,n)=>t(`settings.connectors.wrongPrefix`,{label:$(C(n),e.id,i,!0),prefix:R(n,i.prefix??``)})));else{d(!0),_(null),p(!1);try{await a(e.id,n),p(!0),t(),setTimeout(()=>p(!1),2200)}catch(e){_(e instanceof Error?e.message:String(e));return}finally{d(!1)}r()}},T=async()=>{d(!0),_(null);try{await D(e.id),i(),l(Object.fromEntries(e.mcp_env_keys.map(e=>[e,``]))),t()}catch(e){_(e instanceof Error?e.message:String(e))}finally{d(!1)}},te=async()=>{d(!0),_(null),i();try{e.enabled?await m(e.id):await g(e.id),t()}catch(e){_(e instanceof Error?e.message:String(e))}finally{d(!1)}};return x(`div`,{className:`configure-body`,children:[e.description&&E(`p`,{className:`connector-desc`,children:E(`bdi`,{children:oe(s,e)})}),e.custom&&E(`p`,{className:`connector-desc`,children:s(`settings.connectors.customServer`,{file:R(s.locale,`mcp_servers.json`)})}),h&&x(`div`,{className:`configure-error`,children:[E(H,{size:12}),` `,h]}),e.configured&&o&&x(`div`,{className:`connector-toggle-row`,children:[E(`span`,{className:`connector-toggle-label`,children:s(`settings.connectors.active`)}),x(`span`,{className:`toggle-switch`,children:[E(`input`,{type:`checkbox`,checked:e.enabled!==!1,onChange:()=>void te(),disabled:u,"aria-label":e.enabled?s(`settings.connectors.disableServer`):s(`settings.connectors.enableServer`)}),E(`span`,{className:`toggle-track`})]})]}),e.configured&&o&&e.enabled===!1&&E(`p`,{className:`connector-toggle-help`,children:s(`settings.connectors.disabledHelp`)}),y&&E(Z,{connectorId:e.id,setupUrl:e.setup_url}),e.setup_url&&!e.configured&&!y&&x(`a`,{href:U(e.setup_url)||void 0,target:`_blank`,rel:`noopener noreferrer`,className:`btn-secondary connector-setup-link`,children:[s(`settings.connectors.createApp`,{name:e.display_name}),E(K,{size:12})]}),e.mcp_env_keys.map(t=>{let n=e.config_fields?.find(e=>e.key===t);return x(`div`,{className:`mcp-key-row`,children:[E(`label`,{className:`mcp-key-label`,htmlFor:`mcp-key-${e.id}-${t}`,children:E(`bdi`,{children:n?$(s,e.id,n):t})}),E(`input`,{id:`mcp-key-${e.id}-${t}`,type:`password`,dir:`ltr`,className:`mcp-key-input`,placeholder:e.configured?`••••••••`:n?.placeholder||s.bare(`settings.connectors.enterValue`),value:c[t]??``,onChange:e=>l(n=>({...n,[t]:e.target.value})),spellCheck:!1,autoComplete:`off`}),n?.help_md&&!e.configured&&(!y||X(e.id,n.key))&&E(`div`,{className:`mcp-key-help`,dir:`auto`,children:E(N,{disallowedElements:[...O],urlTransform:U,components:{a:({href:e,children:t})=>E(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t})},children:ce(s,e.id,n)})})]},t)}),x(`div`,{className:`configure-actions`,children:[!(v&&e.configured)&&!e.custom&&E(`button`,{className:`btn-primary`,disabled:u||!v&&S,onClick:()=>void ee(),children:u?E(B,{size:12,className:`spin`}):f?x(w.Fragment,{children:[E(M,{size:12}),` `,s(`settings.advanced.saved`)]}):s(v?`settings.key.connect`:`settings.advanced.save`)}),e.configured&&e.enabled!==!1&&E(`button`,{className:`btn-secondary`,disabled:u||n?.state===`checking`,onClick:r,children:s(`settings.connectors.check`)}),e.configured&&!e.custom&&E(`button`,{className:`btn-secondary`,disabled:u,onClick:()=>void T(),children:s(`settings.connectors.disconnect`)}),e.product_url&&x(`a`,{href:e.product_url,target:`_blank`,rel:`noopener noreferrer`,className:`connector-product-link`,children:[s(`settings.connectors.docs`),` `,E(K,{size:11})]})]}),n?.state===`checking`&&x(`p`,{className:`connector-check`,role:`status`,children:[E(B,{size:12,className:`spin`}),s(`settings.connectors.checking`,{name:e.display_name})]}),n?.state===`ok`&&x(`p`,{className:`connector-check connector-check--ok`,role:`status`,children:[E(M,{size:12}),s(`settings.connectors.checkOk`,{name:e.display_name})]}),n?.state===`failed`&&x(`div`,{className:`connector-check connector-check--failed`,role:`alert`,children:[E(`p`,{children:n.slow?s(`settings.connectors.checkSlow`,{name:e.display_name}):s(v?`settings.connectors.checkFailed`:`settings.connectors.checkFailedKey`,{name:e.display_name})}),x(`details`,{children:[E(`summary`,{children:s(`settings.connectors.checkDetails`)}),E(`pre`,{dir:`ltr`,children:n.detail})]})]})]})}function Pe({agent:e,connectorId:t,grantedScopes:n,onChanged:r}){let i=b(),a=e.required_connections?.find(e=>e.connector_id===t),s=e.namespaced_agent_id;if(!a||!s)return null;let[c,l]=(0,q.useState)(()=>new Set(n)),[u,d]=(0,q.useState)(null),[f,p]=(0,q.useState)(null);(0,q.useEffect)(()=>{l(new Set(n))},[n.join(`,`)]);let m=async e=>{if(u!==null)return;let i=new Set(c);i.has(e)?i.delete(e):i.add(e),l(i),d(e),p(null);try{i.size===0?await o(t,s):await h(t,s,[...i]),r()}catch(e){l(new Set(n)),p(e instanceof Error?e.message:String(e))}finally{d(null)}};return x(`div`,{className:`grant-agent-card`,children:[E(`bdi`,{className:`grant-agent-card-name`,children:e.name}),E(`div`,{className:`grant-scope-list`,children:a.scopes.map(e=>x(`label`,{className:`grant-scope-item`,children:[E(`span`,{className:`grant-scope-label`,children:_e(e,i)}),x(`span`,{className:`toggle-switch`,children:[E(`input`,{type:`checkbox`,checked:c.has(e),onChange:()=>void m(e),disabled:u!==null}),E(`span`,{className:`toggle-track`})]})]},e))}),f&&x(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[E(H,{size:11}),` `,f]})]})}function Fe({servers:e,expanded:t,onToggle:n}){return E(`div`,{className:`agent-mcps-section`,children:E(`div`,{className:`connectors-list`,children:e.map(e=>{let r=`${e.agent_id}::${e.server_name}`;return E(Ie,{server:e,expanded:t===r,onToggle:()=>n(r)},r)})})})}function Ie({server:e,expanded:t,onToggle:n}){let r=b(),i=[e.command,...e.args].join(` `);return x(`div`,{className:`agent-mcp-tile${t?` agent-mcp-tile--open`:``}`,children:[x(`button`,{type:`button`,className:`agent-mcp-tile-header`,onClick:n,"aria-expanded":t,children:[E(`span`,{className:`agent-mcp-server-name`,children:e.server_name}),E(`span`,{className:`agent-mcp-agent-label`,children:r(`settings.connectors.via`,{name:e.agent_name})}),e.disabled?E(`span`,{className:`agent-mcp-status disabled`,children:r(`settings.connectors.paused`)}):x(`span`,{className:`agent-mcp-status enabled`,children:[E(M,{size:11}),` `,r(`settings.connectors.active`)]}),E(`span`,{className:`agent-mcp-readonly-badge`,children:r(`settings.connectors.readOnly`)}),E(`span`,{className:`agent-mcp-chevron`,children:E(t?P:j,{size:14})})]}),t&&x(`div`,{className:`agent-mcp-detail`,children:[i&&E(`bdi`,{dir:`ltr`,className:`agent-mcp-command-row`,children:i}),E(`bdi`,{dir:`ltr`,className:`agent-mcp-config-path`,children:e.config_path}),E(`div`,{className:`agent-mcp-config-hint`,children:r(`settings.connectors.editConfig`)})]})]})}function Le({connectorId:e,connectorName:t,connectorType:n,connectorEnabled:i,soleAgent:a,onConnectorChanged:o,onClearCheck:c}){let l=b(),{agents:u}=S(),[d,f]=(0,q.useState)({}),[p,m]=(0,q.useState)({}),[h,g]=(0,q.useState)(!0),_=(0,q.useCallback)(async()=>{try{let[{grants:t},{activations:n}]=await Promise.all([s(e),r(e)]);f(t),m(n)}catch{f({}),m({})}finally{g(!1)}},[e]);if((0,q.useEffect)(()=>{_()},[_]),ie((0,q.useCallback)(t=>{t.connectorId===e&&(t.reason===`grant_changed`||t.reason===`activation_changed`||t.reason===`disconnected`)&&_()},[e,_])),h)return null;if(a)return E(`div`,{className:`connection-grants`,children:E(ze,{agent:a,connectorId:e,connectorName:t,connectorEnabled:i,active:!!p[a.namespaced_agent_id],hasGrant:(d[a.namespaced_agent_id]??[]).length>0,onToggle:c,onChanged:()=>{o(),_()}})});let v=u.filter(t=>t.namespaced_agent_id&&t.required_connections?.some(t=>t.connector_id===e)),y=n===`mcp_server`?u.filter(t=>t.namespaced_agent_id&&(t.consumes_mcp_servers||t.required_connections?.some(t=>t.connector_id===e))):[];return v.length===0&&y.length===0?null:x(`div`,{className:`connection-grants`,children:[v.length>0&&x(w.Fragment,{children:[E(`div`,{className:`grants-header`,children:l(`settings.connectors.grants`)}),v.map(t=>E(Pe,{agent:t,connectorId:e,grantedScopes:d[t.namespaced_agent_id]??[],onChanged:()=>void _()},t.namespaced_agent_id))]}),y.length>0&&x(w.Fragment,{children:[E(`div`,{className:`grants-header grants-header--activations`,children:l(`settings.connectors.activeFor`)}),y.map(n=>E(Be,{agent:n,connectorId:e,connectorName:t,active:!!p[n.namespaced_agent_id],grantedScopes:d[n.namespaced_agent_id]??[],onChanged:()=>void _()},`activation-${n.namespaced_agent_id}`))]})]})}function Re(e,t){let n=e.filter(e=>e.namespaced_agent_id&&(e.consumes_mcp_servers||e.required_connections?.some(e=>e.connector_id===t))),r=e.some(e=>e.required_connections?.some(e=>e.connector_id===t));return n.length!==1||n[0].id!==`gaia`||r?null:{name:n[0].name,namespaced_agent_id:n[0].namespaced_agent_id}}function ze({agent:e,connectorId:t,connectorName:n,connectorEnabled:r,active:i,hasGrant:a,onToggle:o,onChanged:s}){let c=b(),[u,d]=(0,q.useState)(!1),[p,m]=(0,q.useState)(null),h=r&&i,_=async()=>{if(!u){d(!0),m(null),o();try{h?await l(t,e.namespaced_agent_id):(r||await g(t),i||await f(t,e.namespaced_agent_id,a?void 0:[...xe])),s()}catch(e){m(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return x(w.Fragment,{children:[x(`label`,{className:`connector-toggle-row`,children:[E(`span`,{className:`connector-toggle-label`,children:c(`settings.connectors.agentCanUse`,{agent:e.name,name:n})}),x(`span`,{className:`toggle-switch`,children:[E(`input`,{type:`checkbox`,checked:h,onChange:()=>void _(),disabled:u}),E(`span`,{className:`toggle-track`})]})]}),p&&x(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[E(H,{size:11}),` `,p]})]})}function Be({agent:e,connectorId:t,connectorName:n,active:r,grantedScopes:i,onChanged:a}){let o=b(),s=e.required_connections?.find(e=>e.connector_id===t),c=e.namespaced_agent_id;if(!c)return null;let[u,d]=(0,q.useState)(r),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(null);(0,q.useEffect)(()=>{d(r)},[r]);let _=async()=>{if(p)return;let e=!u;d(e),m(!0),g(null);try{if(e){let e=i.length===0?s?[...s.scopes]:[...xe]:void 0;await f(t,c,e)}else await l(t,c);a()}catch(e){d(r),g(e instanceof Error?e.message:String(e))}finally{m(!1)}};return x(`div`,{className:`grant-agent-card`,children:[E(`bdi`,{className:`grant-agent-card-name`,children:e.name}),E(`div`,{className:`grant-scope-list`,children:x(`label`,{className:`grant-scope-item`,children:[E(`span`,{className:`grant-scope-label`,children:o(u?`settings.connectors.toolsVisible`:`settings.connectors.toolsHidden`,{name:n})}),x(`span`,{className:`toggle-switch`,children:[E(`input`,{type:`checkbox`,checked:u,onChange:()=>void _(),disabled:p}),E(`span`,{className:`toggle-track`})]})]})}),h&&x(`div`,{className:`grant-scope-warning grant-scope-warning--error`,children:[E(H,{size:11}),` `,h]})]})}function Ve(){let e=b();return x(`div`,{className:`settings-pane`,children:[E(`h2`,{className:`settings-pane-title`,children:e(`settings.section.connectors`)}),E(De,{})]})}export{Ve as ConnectorsPane};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Ni as t,Oi as n,P as r,Qt as ee,a as i,an as a,c as o,er as s,f as te,s as c}from"./useT-CWiHVf7i.js";import{Bt as l,Ht as u,I as d,Mn as f,T as ne,jn as p}from"./index-DnSSZ2b8.js";import{t as m}from"./SaveError-CIUCwbOl.js";var h=e(t(),1),re=[{value:``,label:`settings.developer.tierAuto`},{value:`full`,label:`settings.developer.tierFull`},{value:`compact`,label:`settings.developer.tierCompact`}],g=[{value:`gaia`,label:`settings.developer.coderGaia`},{value:`claude-code`,label:`settings.developer.coderClaudeCode`}];function _(){let e=i();u();let t=te(e=>e.openSettings),[_,v]=(0,h.useState)(null),[y,b]=(0,h.useState)(!1),[x,S]=(0,h.useState)(null),[C,w]=(0,h.useState)(null),[T,E]=(0,h.useState)(``),[D,O]=(0,h.useState)(null),[k,A]=(0,h.useState)(!1),[j,M]=(0,h.useState)(null),[N,P]=(0,h.useState)(null),[F,I]=(0,h.useState)(!1),[L,R]=(0,h.useState)(null),[z,B]=(0,h.useState)(!1),[V,H]=(0,h.useState)(!1),[U,W]=(0,h.useState)(!1),[G,K]=(0,h.useState)(null),[q,J]=(0,h.useState)([]),Y=(0,h.useCallback)(e=>{v({developer_mode:e.developer_mode,developer_mode_locked:e.developer_mode_locked,developer_mode_blocked_by:e.developer_mode_blocked_by,developer_mode_chat_model:e.developer_mode_chat_model}),O({developer_coder:e.developer_coder,developer_coder_model:e.developer_coder_model,developer_coder_models:e.developer_coder_models,developer_coder_claude_code_installed:e.developer_coder_claude_code_installed}),E(e.developer_settings_error),P({feature_tier:e.feature_tier,feature_tier_locked:e.feature_tier_locked,flagship_agent:e.flagship_agent}),B(e.dynamic_tools),H(e.dynamic_tools_locked)},[]);(0,h.useEffect)(()=>{a().then(Y).catch(e=>{n.system.error(`Failed to load settings`,e),w(e instanceof Error?e.message:String(e))}),ee().then(e=>J(e.servers)).catch(e=>n.system.warn(`MCP status unavailable`,e))},[Y]);let ie=(0,h.useCallback)(async()=>{if(!_||_.developer_mode_locked||y)return;let e=!_.developer_mode;v({..._,developer_mode:e}),b(!0),S(null);try{n.system.info(`Saving developer_mode setting`,{developer_mode:e}),Y(await s({developer_mode:e}))}catch(e){n.system.error(`Failed to save developer_mode`,e),v(_),S(e instanceof Error?e.message:String(e))}finally{b(!1)}},[Y,_,y]),X=(0,h.useCallback)(async e=>{if(D&&!k){O({...D,...e}),A(!0),M(null);try{n.system.info(`Saving developer coder setting`,e),Y(await s(e))}catch(e){n.system.error(`Failed to save the developer coder`,e),O(D),M(e instanceof Error?e.message:String(e))}finally{A(!1)}}},[Y,D,k]),ae=(0,h.useCallback)(async e=>{if(!(!N||N.feature_tier_locked||F||N.feature_tier===e)){P({...N,feature_tier:e}),I(!0),R(null);try{n.system.info(`Saving feature_tier setting`,{feature_tier:e}),Y(await s({feature_tier:e}))}catch(e){n.system.error(`Failed to save feature_tier`,e),P(N),R(e instanceof Error?e.message:String(e))}finally{I(!1)}}},[Y,N,F]),oe=(0,h.useCallback)(async()=>{if(V||U)return;let e=z;B(!e),W(!0),K(null);try{n.system.info(`Saving dynamic_tools setting`,{dynamic_tools:!e});let t=await s({dynamic_tools:!e});B(t.dynamic_tools),H(t.dynamic_tools_locked)}catch(t){n.system.error(`Failed to save dynamic_tools`,t),B(e),K(t instanceof Error?t.message:String(t))}finally{W(!1)}},[z,V,U]),Z=!!_?.developer_mode,Q=_?.developer_mode_blocked_by??``,$=_?.developer_mode_chat_model;return o(`div`,{className:`settings-pane`,children:[c(`h2`,{className:`settings-pane-title`,children:e(`settings.section.developer`)}),o(`section`,{className:`settings-card`,"aria-labelledby":`developer-mode-title`,children:[o(`div`,{className:`setting-row developer-mode-row`,children:[o(`span`,{className:`developer-mode-name`,children:[c(`strong`,{id:`developer-mode-title`,children:e(`settings.developer.modeTitle`)}),o(ne,{label:e(`settings.developer.modeAbout`),children:[c(`div`,{className:`info-bubble-title`,children:e(`settings.developer.aboutTitle`)}),o(`ul`,{className:`info-bubble-lines`,children:[c(`li`,{children:e(`settings.developer.aboutWork`)}),c(`li`,{children:e(`settings.developer.aboutConsent`)}),c(`li`,{children:e(`settings.developer.aboutModel`)}),c(`li`,{children:e(`settings.developer.aboutCost`)})]})]})]}),o(`label`,{className:`toggle-switch`,children:[c(`input`,{type:`checkbox`,role:`switch`,checked:Z,"aria-labelledby":`developer-mode-title`,"aria-describedby":`developer-mode-hint`,onChange:()=>void ie(),disabled:!_||_.developer_mode_locked,"aria-busy":y}),c(`span`,{className:`toggle-track`})]})]}),c(`p`,{className:`settings-hint`,id:`developer-mode-hint`,children:e(`settings.developer.modeHint`)}),_?.developer_mode_locked&&c(`p`,{className:`model-status-hint`,children:e(`settings.developer.locked`)}),Z&&!Q&&o(`p`,{className:`settings-ok developer-mode-state`,role:`status`,children:[c(f,{size:13,"aria-hidden":`true`}),` `,e(`settings.developer.running`)]}),Z&&Q===`model`&&o(`div`,{className:`model-warning`,role:`status`,children:[c(p,{size:14}),o(`div`,{className:`model-warning-content`,children:[c(`p`,{children:$?e(`settings.developer.blockedModel`,{model:r(l($),`ltr`)}):e(`settings.developer.blockedNoModel`)}),c(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`),children:e(`settings.developer.chooseModel`)})]})]}),Z&&Q===`harness`&&o(`div`,{className:`model-warning`,role:`status`,children:[c(p,{size:14}),o(`div`,{className:`model-warning-content`,children:[c(`p`,{children:e(`settings.developer.blockedHarness`)}),c(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>t(`model`),children:e(`settings.developer.chooseAgent`)})]})]}),x&&c(m,{message:x}),C&&c(`p`,{className:`settings-error`,role:`alert`,children:e(`settings.developer.loadFailed`,{reason:C})}),T&&c(`p`,{className:`settings-error`,role:`alert`,children:c(`bdi`,{dir:`ltr`,children:T})})]}),D&&o(`section`,{className:`settings-card`,"aria-labelledby":`developer-coder-label`,children:[o(`div`,{className:`settings-field`,children:[c(`strong`,{id:`developer-coder-label`,children:e(`settings.developer.coderTitle`)}),c(d,{className:`segmented`,"aria-labelledby":`developer-coder-label`,"aria-describedby":`developer-coder-hint`,children:g.map(t=>c(`button`,{type:`button`,role:`radio`,"aria-checked":D.developer_coder===t.value,className:D.developer_coder===t.value?`is-active`:``,disabled:t.value===`claude-code`&&!D.developer_coder_claude_code_installed,onClick:()=>{D.developer_coder!==t.value&&X({developer_coder:t.value})},children:c(`bdi`,{children:e(t.label)})},t.value))}),c(`span`,{className:`settings-hint`,id:`developer-coder-hint`,children:D.developer_coder_claude_code_installed?D.developer_coder===`claude-code`?e(`settings.developer.coderClaudeNote`):e(`settings.developer.coderHint`):e(D.developer_coder===`claude-code`?`settings.developer.coderClaudeGone`:`settings.developer.coderClaudeMissing`)})]}),D.developer_coder===`gaia`&&o(`div`,{className:`settings-field`,children:[c(`span`,{className:`settings-label`,id:`developer-coder-model-label`,children:e(`settings.developer.coderModel`)}),c(d,{className:`segmented developer-coder-models`,"aria-labelledby":`developer-coder-model-label`,"aria-describedby":`developer-coder-model-hint`,children:D.developer_coder_models.map(e=>c(`button`,{type:`button`,role:`radio`,"aria-checked":D.developer_coder_model===e,className:D.developer_coder_model===e?`is-active`:``,onClick:()=>{D.developer_coder_model!==e&&X({developer_coder_model:e})},children:c(`bdi`,{dir:`ltr`,children:l(e)})},e))}),c(`span`,{className:`settings-hint`,id:`developer-coder-model-hint`,children:e(`settings.developer.coderModelHint`)})]}),j&&c(m,{message:j})]}),N&&o(`section`,{className:`settings-card`,"aria-labelledby":`developer-tier-label`,children:[o(`div`,{className:`settings-field`,children:[c(`strong`,{id:`developer-tier-label`,children:e(`settings.developer.tierTitle`)}),c(d,{className:`segmented`,"aria-labelledby":`developer-tier-label`,"aria-describedby":`developer-tier-hint`,children:re.map(t=>c(`button`,{type:`button`,role:`radio`,"aria-checked":N.feature_tier===t.value,className:N.feature_tier===t.value?`is-active`:``,disabled:N.feature_tier_locked||!Z&&t.value!==``,onClick:()=>void ae(t.value),children:e(t.label)},t.value||`auto`))}),c(`span`,{className:`settings-hint`,id:`developer-tier-hint`,children:e(Z?`settings.developer.tierHint`:`settings.developer.tierNeedsMode`)})]}),Z&&N.feature_tier===`full`&&o(`p`,{className:`model-status-hint developer-mode-state`,role:`status`,children:[c(p,{size:13,"aria-hidden":`true`}),` `,e(`settings.developer.tierFullWarning`)]}),N.feature_tier_locked&&c(`p`,{className:`model-status-hint`,children:e(`settings.developer.tierLocked`)}),N.flagship_agent===`gaiacpp`&&c(`p`,{className:`model-status-hint`,children:e(`settings.developer.tierNative`)}),L&&c(m,{message:L})]}),o(`section`,{className:`settings-card`,"aria-labelledby":`developer-dynamic-title`,children:[o(`label`,{className:`setting-row`,children:[c(`strong`,{id:`developer-dynamic-title`,children:e(`settings.advanced.dynamicTitle`)}),o(`span`,{className:`toggle-switch`,children:[c(`input`,{type:`checkbox`,role:`switch`,checked:z,onChange:()=>void oe(),disabled:!_||V,"aria-busy":U,"aria-describedby":`developer-dynamic-hint`}),c(`span`,{className:`toggle-track`})]})]}),c(`p`,{className:`settings-hint`,id:`developer-dynamic-hint`,children:e(`settings.advanced.dynamicDesc`)}),V&&c(`p`,{className:`model-status-hint`,children:e(`settings.advanced.dynamicLocked`)}),G&&c(m,{message:G})]}),q.length>0&&o(`section`,{className:`settings-card`,"aria-labelledby":`developer-mcp-title`,children:[o(`div`,{className:`developer-card-head`,children:[c(`strong`,{id:`developer-mcp-title`,children:e(`settings.advanced.mcp`)}),c(`bdi`,{dir:`ltr`,className:`settings-disclosure-count`,children:q.length})]}),c(`div`,{className:`status-grid`,children:q.map(t=>o(`div`,{className:`status-row`,children:[c(`bdi`,{className:`status-label`,children:t.name}),c(`div`,{className:`status-value-wrap`,children:t.connected?o(`span`,{className:`status-value ok mcp-status-connected`,children:[c(f,{size:12}),e.plural(`settings.advanced.tools`,t.tool_count)]}):o(`span`,{className:`status-value warn mcp-status-failed`,title:t.error??void 0,children:[c(p,{size:12}),e(`settings.custom.failed`)]})})]},t.name))})]})]})}export{_ as DeveloperSettings};
@@ -1,5 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$t as t,A as n,An as r,D as i,E as a,F as o,Ft as s,Jt as c,Kt as l,Lt as ee,M as te,N as ne,Nn as re,Nt as ie,O as ae,On as oe,P as se,Wt as ce,Xt as le,Zt as ue,_n as de,h as fe,j as pe,jn as u,k as me,kt as he,mn as ge,nn as _e,yn as ve,zt as ye}from"./index-DnSSZ2b8.js";import{Gt as be,I as d,Mi as f,Ni as p,Oi as m,Ot as xe,Tn as Se,a as Ce,c as h,f as g,fn as we,hn as _,jn as Te,nr as Ee,o as De,rr as Oe,s as v,t as y,wt as ke,xt as Ae}from"./useT-CWiHVf7i.js";import{t as b}from"./folderIndexResult-DKQpxwD1.js";var x={name:`loader`,size:24,node:[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]};x.node;var je=f(x),S={name:`refresh-ccw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]};S.node;var Me=f(S),C=e(p(),1);function Ne(e){let t=e.trim(),n=t.match(/^(["'])(.*)\1$/);if(n&&(t=n[2].trim()),/^file:\/\//i.test(t)){t=t.replace(/^file:\/\/(localhost)?/i,``);try{t=decodeURIComponent(t)}catch{}t=t.replace(/^\/([A-Za-z]:[\\/])/,`$1`)}return t}var w=e=>e.toLocaleString(`en-US`);function T(e,t){if(e.phase===`starting`)return t(`docs.progress.starting`);let n=w(e.done);return e.phase===`reading`?e.total==null?t(`docs.progress.readingCount`,{done:n}):t(`docs.progress.reading`,{done:n,total:w(e.total)}):e.total==null?t(`docs.progress.embeddingCount`,{done:n}):t(`docs.progress.embedding`,{done:n,total:w(e.total)})}function E(e){return e.total==null||e.total<=0?null:Math.min(100,Math.floor(e.done/e.total*100))}function Pe({progress:e}){let t=T(e,Ce()),n=E(e);return h(`div`,{className:`index-progress is-running`,children:[v(`div`,{className:`index-progress-track${n==null?` is-indeterminate`:``}`,role:`progressbar`,"aria-label":t,"aria-valuemin":n==null?void 0:0,"aria-valuemax":n==null?void 0:100,"aria-valuenow":n??void 0,children:v(`div`,{className:`index-progress-fill`,style:n==null?void 0:{inlineSize:`${n}%`}})}),h(`span`,{className:`index-progress-label`,children:[t,n!=null&&h(`span`,{className:`index-progress-pct`,children:[` · `,n,`%`]})]})]})}function Fe(e){let[t,...n]=e.replace(/^RAG indexing failed for [^:]+:\s*/,``).trim().split(`
2
- `);return{summary:t.trim(),more:n.join(`
3
- `).trim()}}function D(e){let t=e.split(`
4
- `)[0].replace(/RAG indexing failed for [^:]+:\s*/,``).trim(),n=t.split(`:`)[0];return n!==t&&t.endsWith(`: ${n}`)&&(t=t.slice(0,-(n.length+2))),/[.!?]$/.test(t)?t:`${t}.`}var O={corrupted:`docs.folder.reason.corrupted`,encrypted:`docs.folder.reason.encrypted`,empty:`docs.folder.reason.empty`,empty_file:`docs.folder.reason.emptyFile`,unsupported_workbook:`docs.folder.reason.unsupportedWorkbook`,model_server_down:`docs.folder.reason.serverDown`,model_server_busy:`docs.folder.reason.serverBusy`};function Ie(e,t,n){let r=n.skipped??0;return e.compose(e=>{let i=[];n.indexed>0?i.push(e(d(`docs.folder.indexed`,n.indexed),{n:n.indexed,name:t})):n.failed===0&&i.push(e(`docs.folder.none`,{name:t})),r>0&&i.push(e(d(`docs.folder.skipped`,r),{n:r})),i.push(...b(e,n));let a=n.skipped_images??0;if(a>0&&i.push(e(d(`docs.folder.images`,a),{n:a})),n.failed>0){i.push(e(d(`docs.folder.failed`,n.failed),{n:n.failed}));let t=n.failures?.[0],r=t?.kind?O[t.kind]:void 0;t&&r?i.push(e(r,{name:t.file})):n.errors[0]&&i.push(D(n.errors[0]))}return i.push(e(`docs.folder.noSubfolders`)),i.join(` `)})}var Le=1e3,Re=5,ze=6e3;function Be(e,t,n){if(n)return{...e,[t]:n};if(!(t in e))return e;let{[t]:r,...i}=e;return i}function Ve(e){let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function He(e,t){try{let n=new Date(e);if(isNaN(n.getTime()))return``;let r=new Date().getTime()-n.getTime(),i=Math.floor(r/1e3),a=Math.floor(i/60),o=Math.floor(a/60),s=Math.floor(o/24);return i<60?t(`time.justNow`):a<60?t(`time.minutesAgo`,{n:a}):o<24?t(`time.hoursAgo`,{n:o}):s===1?t(`time.yesterday`):s<7?t(`time.daysAgo`,{n:s}):n.toLocaleDateString(y(t),{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}catch{return``}}function Ue(e,t){try{let n=new Date(e);return isNaN(n.getTime())?``:n.toLocaleString(y(t),{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function We({name:e}){let t=Array.from(e);if(t.length<=28)return v(`span`,{className:`doc-name`,dir:`ltr`,children:e});let n=e.match(/\p{L}/u)?.[0]??``;if(/[֐-ࣿיִ-﷿ﹰ-]/.test(n)){let t=e.match(/\.[^.\s]{1,10}$/)?.[0]??``;return h(`span`,{className:`doc-name doc-name-split is-rtl-text`,dir:`auto`,title:e,children:[v(`span`,{className:`doc-name-head`,children:e.slice(0,e.length-t.length)}),t&&v(`span`,{className:`doc-name-tail`,dir:`ltr`,children:t})]})}return h(`span`,{className:`doc-name doc-name-split`,dir:`auto`,title:e,children:[v(`span`,{className:`doc-name-head`,children:t.slice(0,-14).join(``)}),v(`span`,{className:`doc-name-tail`,children:t.slice(-14).join(``)})]})}function Ge(){let e=Ce(),{documents:d,setDocuments:f,setShowDocLibrary:p,openFileBrowserFromLibrary:y,currentSessionId:b,sessions:x,updateSessionInList:S,draftDocumentIds:w,addDraftDocuments:T,removeDraftDocument:E}=g(),D=x.find(e=>e.id===b)??null,[O,Ge]=(0,C.useState)(b?`chat`:`next`),k=O===`chat`?b:null,A=`“${ie(e,D)||e(`docs.untitledChat`)}”`,[Ke,j]=(0,C.useState)(``),[M,qe]=(0,C.useState)(``),Je=d.length>Re?M.trim().toLowerCase():``,Ye=e=>!Je||e.filename.toLowerCase().includes(Je),Xe=(0,C.useRef)(null),Ze=(0,C.useCallback)(()=>p(!1),[p]);l(!0,Ze);let Qe=(0,C.useRef)(null),$e=(0,C.useRef)(null);he(Qe,!0),fe(Qe,!0);let[et,tt]=(0,C.useState)(!1),[N,nt]=(0,C.useState)(!1),[rt,P]=(0,C.useState)(``),[F,it]=(0,C.useState)(``),[I,L]=(0,C.useState)(null),[at,R]=(0,C.useState)(null),[ot,z]=(0,C.useState)(null),[B,V]=(0,C.useState)(null),H=(0,C.useRef)(null),U=(0,C.useRef)(null),[W,st]=(0,C.useState)(null),[G,ct]=(0,C.useState)(new Set),[lt,ut]=(0,C.useState)({}),K=(0,C.useRef)(new Map),[,dt]=(0,C.useState)(0),q=(0,C.useCallback)(()=>{m.doc.info(`Loading document library...`);let e=m.doc.time();st(null),_().then(t=>{let n=t.documents||[];f(n),m.doc.timed(`Loaded ${n.length} document(s), ${t.total_chunks||0} chunks, ${t.total_size_bytes||0} bytes total`,e)}).catch(e=>{m.doc.error(`Failed to load documents`,e),st({err:e})})},[f]);(0,C.useEffect)(q,[q]);let ft=d.some(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);(0,C.useEffect)(()=>{if(!ft)return;let e=g.getState().documents;for(let t of e)t.indexing_status!==`indexing`&&t.indexing_status!==`pending`||K.current.has(t.id)||K.current.set(t.id,Date.now());let t=!1;return ye(async()=>{if(dt(e=>e+1),!t){t=!0;try{let e=g.getState().documents.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);for(let t of e)try{let e=await be(t.id);if(ut(n=>Be(n,t.id,e.progress)),e.indexing_status!==`indexing`&&e.indexing_status!==`pending`){K.current.delete(t.id);let e=await _();f(e.documents||[]);break}}catch(e){m.doc.warn(`Indexing status for ${t.filename} unavailable`,e)}}finally{t=!1}}},Le)},[ft,f]),(0,C.useEffect)(()=>{let e=new Set(d.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`).map(e=>e.id));for(let t of K.current.keys())e.has(t)||K.current.delete(t);ut(t=>Object.keys(t).reduce((t,n)=>e.has(n)?t:Be(t,n,null),t))},[d]),(0,C.useEffect)(()=>ye(async()=>{try{let e=(await _()).documents||[],t=g.getState().documents;(e.length!==t.length||e.some((e,n)=>{let r=t.find(t=>t.id===e.id);return!r||r.indexing_status!==e.indexing_status||r.indexed_at!==e.indexed_at||r.chunk_count!==e.chunk_count}))&&(f(e),m.doc.debug(`Document list refreshed (server-side changes detected)`)),st(null)}catch(e){m.doc.warn(`Document list refresh failed`,e)}},15e3),[f]);let pt=d.filter(e=>e.id!==B?.id),mt=pt.length,ht=pt.reduce((e,t)=>e+t.file_size,0),J=pt.filter(e=>e.indexing_status===`failed`),Y=J.filter(e=>se(e.error_kind)).length,gt=J.filter(e=>pe(e.error_kind)).length,_t=J.length-Y-gt,X=(0,C.useCallback)(async(t,n)=>{if(Xe.current=t,!k){T([t]),j(e(`docs.willAttach`,{name:s(n)})),m.doc.info(`"${n}" will be attached to the next new chat`);return}await Ae(k,t);let r=g.getState().sessions.find(e=>e.id===k)?.document_ids??[];if(!r.includes(t)){S(k,{document_ids:[...r,t]});let e=g.getState();e.setDocuments(e.documents.map(e=>e.id===t?{...e,sessions_using:(e.sessions_using??0)+1}:e))}j(e(`docs.attached`,{name:s(n),chat:A})),m.doc.info(`Attached "${n}" to session ${k}`)},[k,A,S,T,e]),vt=(0,C.useCallback)(async(e,t)=>{if(e.length===0)return;if(!k){T(e),m.doc.info(`"${t}" will be attached to the next new chat`);return}let n=[];for(let t of e)try{await Ae(k,t),n.push(t)}catch(e){m.doc.warn(`Could not attach document to session: ${e}`)}let r=g.getState().sessions.find(e=>e.id===k)?.document_ids??[],i=n.filter(e=>!r.includes(e));i.length>0&&S(k,{document_ids:[...r,...i]}),m.doc.info(`Attached "${t}" to session ${k}`)},[k,S,T]),Z=(0,C.useCallback)(async(t,r,i)=>{if(!await ce(`embedding`))return!1;let a=t.includes(`.`)?`.`+t.split(`.`).pop()?.toLowerCase():``,o=a&&!n(a)?me(a)?.message??`The file type "${a}" is not supported for indexing.`:null;if(o&&!i)return m.doc.warn(`Unsupported file type: ${t} (${a})`),L({filename:t,error:o}),!1;m.doc.info(`Indexing document: ${t}`);let c=m.doc.time();nt(!0),P(e(`docs.indexingFile`,{name:t})),L(null),z(null),R(null),j(``);try{let n=await r();m.doc.timed(`Indexed "${t}": ${n?.chunk_count||`?`} chunks`,c);let i=n?.indexing_status===`failed`;if(i){m.doc.warn(`"${t}" couldn't be added (${n.error_kind??`unreadable`}); not attaching it`);let r=n.filename||t;z(ne(n.error_kind,r,e)??e(`docs.notAdded`,{name:r}))}else if(n?.id){let r=s(t),i=s(n.filename||t),a=r!==i&&g.getState().documents.some(e=>e.id===n.id)?i:null;try{await X(n.id,n.filename||t),a&&j(t=>`${e(`docs.sameContents`,{name:r,existing:a})} ${t}`)}catch(e){m.doc.error(`Could not attach "${t}" to ${A}`,e),L({filename:t,error:`Indexed, but not attached to ${A}: ${e instanceof Error?e.message:e}`})}}let a=await _();return f(a.documents||[]),P(``),!i}catch(n){let{httpStatus:r,reason:a,body:s}=n??{};if(a===`is_folder`&&i)return await i();m.doc.error(`Failed to index "${t}"`,n);let c=a===`too_large`?e(`docs.tooLargeDetail`,{max:String(s?.max_mb)}):te(a,e)??(r===400&&o?o:n instanceof Error?n.message:`Upload failed`);return L({filename:t,error:c,status:r,kind:a}),P(``),!1}finally{nt(!1)}},[X,A,f,e]),yt=(0,C.useCallback)(async(t,n)=>{m.doc.info(`"${t}" is a folder; indexing its documents`),P(e(`docs.indexingFolder`,{name:n}));try{let r=await we(t,!1);await vt(r.documents.map(e=>e.id).filter(Boolean),n),R(Ie(e,n,r));let i=await _();return f(i.documents||[]),!0}catch(e){m.doc.error(`Failed to index folder "${t}"`,e);let r=e instanceof Error?e.message:`Folder indexing failed`,{httpStatus:i}=e??{};return L({filename:n,error:r,status:i}),!1}finally{P(``)}},[vt,f,e]),bt=(0,C.useCallback)(async(e,t)=>Z(t,()=>Oe(e),()=>yt(e,t)),[Z,yt]),Q=(0,C.useCallback)(async e=>{await Z(e.name,()=>Ee(e))},[Z]),xt=(0,C.useCallback)(async e=>{e.preventDefault(),tt(!1);let t=Array.from(e.dataTransfer.files);m.doc.info(`Dropped ${t.length} file(s) into Document Library`);for(let e of t)await Q(e)},[Q]),St=(0,C.useCallback)(async e=>{let t=Array.from(e.target.files??[]);e.target.value=``;for(let e of t)await Q(e)},[Q]),Ct=(0,C.useCallback)(async({id:t,name:n})=>{m.doc.info(`Deleting document: ${n}`);try{await xe(t)}catch(r){m.doc.error(`Failed to delete document: ${n}`,r),V(e=>e?.id===t?null:e),z(e(`docs.deleteFailed`,{name:s(n),error:o(r)}));return}K.current.delete(t),E(t),Xe.current===t&&j(``),f(g.getState().documents.filter(e=>e.id!==t)),V(e=>e?.id===t?null:e),m.doc.info(`Deleted document: ${n}`)},[f,E,e]),$=(0,C.useCallback)(()=>{U.current!==null&&clearTimeout(U.current),U.current=null;let e=H.current;H.current=null,e&&Ct(e)},[Ct]),wt=(0,C.useCallback)(e=>{let t=d.find(t=>t.id===e)?.filename||e;z(null),L(null),R(null),j(``),$();let n={id:e,name:t};H.current=n,V(n),U.current=window.setTimeout($,ze)},[d,$]),Tt=(0,C.useCallback)(()=>{U.current!==null&&clearTimeout(U.current),U.current=null,H.current=null,V(null)},[]),Et=(0,C.useRef)($);Et.current=$,(0,C.useEffect)(()=>()=>Et.current(),[]);let Dt=(0,C.useCallback)(async(t,n)=>{m.doc.info(`Opening folder for: ${t}`),z(null);try{await Se(t,!0)}catch(t){m.doc.error(`Failed to open folder for: ${n}`,t),z(e(`docs.openFolderFailed`,{name:s(n),error:o(t)}))}},[e]),Ot=(0,C.useCallback)(async t=>{let n=d.find(e=>e.id===t)?.filename||t;m.doc.info(`Cancelling indexing for: ${n}`),z(null);try{await ke(t)}catch(t){m.doc.error(`Failed to cancel indexing: ${n}`,t),z(e(`docs.cancelFailed`,{name:s(n),error:o(t)}));return}K.current.delete(t),m.doc.info(`Cancelled indexing for: ${n}`);try{let e=await _();f(e.documents||[])}catch(e){m.doc.warn(`Could not refresh the documents after cancelling`,e)}},[d,f,e]),kt=(0,C.useCallback)(async e=>{if(G.has(e))return;let t=d.find(t=>t.id===e);m.doc.info(`Reindexing document: ${t?.filename||e}`),ct(t=>new Set(t).add(e));try{await Te(e),m.doc.info(`Reindex complete for: ${t?.filename||e}`)}catch(n){let r=n instanceof Error?n.message:String(n);m.doc.error(`Reindex failed for: ${t?.filename||e}`,n),L({filename:t?.filename||e,error:r})}finally{try{let e=await _();f(e.documents||[])}catch(e){m.doc.error(`Failed to refresh documents after reindex`,e)}ct(t=>{let n=new Set(t);return n.delete(e),n})}},[d,f,G]),At=(0,C.useCallback)(async e=>{let t=d.find(t=>t.id===e)?.filename||e;j(``);try{await X(e,t)}catch(e){m.doc.error(`Failed to attach ${t} to ${A}`,e),L({filename:t,error:`Not attached to ${A}: ${e instanceof Error?e.message:e}`})}},[d,X,A]),jt=(0,C.useCallback)(async e=>{e.preventDefault();let t=Ne(F);t&&(m.doc.info(`Indexing from path input: ${t}`),await bt(t,t.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||`file`)&&it(``))},[F,bt]),Mt=t=>{let n=t.indexing_status||`complete`,o=K.current.get(t.id),c=t.indexed_at?He(t.indexed_at,e):``,l=t.indexed_at?Ue(t.indexed_at,e):``;switch(n){case`indexing`:case`pending`:{let n=lt[t.id];return h(`div`,{className:`doc-indexing-status`,children:[n?v(Pe,{progress:n}):h(`div`,{className:`doc-indexing-bar`,children:[v(`div`,{className:`doc-indexing-bar-track`,children:v(`div`,{className:`doc-indexing-bar-fill`})}),h(`span`,{className:`doc-indexing-label`,children:[v(je,{size:12,className:`doc-spin`}),o?e.hint(e(`docs.indexingLabel`),Ve(o)):e(`docs.indexing`)]})]}),h(`button`,{className:`btn-cancel`,onClick:e=>{e.stopPropagation(),Ot(t.id)},title:e(`docs.cancelIndexing`),"aria-label":e(`docs.cancelIndexingAria`,{name:s(t.filename)}),children:[v(r,{size:14}),e(`docs.cancel`)]})]})}case`failed`:{let n=t.error_kind?i[t.error_kind]:void 0,r=n?e(n):void 0,a=te(t.error_kind,e),o=se(t.error_kind),c=a??t.last_error,l=c?Fe(c):null;return h(`div`,{className:`doc-failure`,children:[h(`div`,{className:`doc-indexing-status`,children:[h(`span`,{className:o?`doc-status-badge doc-status-waiting`:`doc-status-badge doc-status-failed`,title:c||void 0,"aria-label":c?e(o?`docs.waitingAria`:`docs.failedAria`,{error:c}):e(`docs.indexingFailed`),children:[v(u,{size:12}),` `,e(r?`docs.cantRead`:o?`docs.waiting`:`docs.failed`)]}),h(`button`,{className:r?`btn-retry btn-retry-quiet`:`btn-retry`,onClick:e=>{e.stopPropagation(),kt(t.id)},title:e(r?`docs.retryTitleFix`:`docs.retryTitle`),"aria-label":e(`docs.retryAria`,{name:s(t.filename)}),disabled:G.has(t.id),children:[v(Me,{size:r?12:14}),G.has(t.id)?e(`docs.retrying`):e(`docs.retry`)]})]}),r&&v(`p`,{className:`doc-failure-hint`,children:r}),r&&l&&h(`details`,{className:`doc-failure-reason`,children:[v(`summary`,{children:e(`docs.technicalDetails`)}),v(`p`,{children:[l.summary,l.more].filter(Boolean).join(`
5
- `)})]}),!r&&l&&(l.more?h(`details`,{className:`doc-failure-reason`,children:[v(`summary`,{children:l.summary}),v(`p`,{children:l.more})]}):v(`p`,{className:`doc-failure-reason`,children:l.summary})),!l&&!r&&v(`p`,{className:`doc-failure-reason`,children:e(`docs.noReason`)})]})}case`cancelled`:return h(`span`,{className:`doc-status-badge doc-status-cancelled`,children:[v(r,{size:12}),` `,e(`docs.cancelled`)]});case`missing`:return h(`span`,{className:`doc-status-badge doc-status-missing`,children:[v(u,{size:12}),` `,e(`docs.missing`)]});default:return h(`span`,{className:`doc-meta`,children:[v(`bdi`,{dir:`ltr`,children:a(t.file_size)}),c&&h(`span`,{className:`doc-timestamp`,title:e(`docs.indexedAt`,{time:l}),children:[v(oe,{size:10}),c]})]})}},Nt=t=>{if(t.indexing_status&&t.indexing_status!==`complete`)return null;let n=!!D?.document_ids?.includes(t.id),r=Math.max((t.sessions_using??0)-+!!n,0),i;return i=n?r>0?e.plural(`docs.usage.hereAndOthers`,r):e(`docs.usage.here`):w.includes(t.id)?e(`docs.usage.next`):r>0?e.plural(`docs.usage.chats`,r):e(`docs.usage.none`),v(`span`,{className:`doc-usage${n?` is-here`:``}`,children:i})};return v(`div`,{ref:Qe,className:`modal-overlay`,onClick:()=>p(!1),role:`dialog`,"aria-modal":`true`,"aria-label":e(`docs.title`),children:h(`div`,{className:`modal-panel doc-modal`,onClick:e=>e.stopPropagation(),children:[h(`div`,{className:`modal-header`,children:[v(`h3`,{children:e(`docs.title`)}),v(`button`,{className:`btn-icon`,onClick:()=>p(!1),"aria-label":e(`docs.close`),children:v(c,{size:18})})]}),h(`div`,{className:`modal-body`,children:[h(`div`,{className:`doc-target`,children:[b?h(`label`,{className:`doc-target-choice`,children:[e(`docs.addTo`),h(`select`,{value:O,onChange:e=>{Ge(e.target.value),j(``)},children:[v(`option`,{value:`chat`,children:e.bare(`docs.thisChat`,{chat:A})}),v(`option`,{value:`next`,children:e.bare(`docs.nextChat`)})]})]}):v(`span`,{children:e(`docs.nextChatOnly`)}),v(`span`,{className:`doc-target-hint`,children:e(`docs.hint`)})]}),h(`div`,{className:`drop-zone ${et?`drag-over`:``} ${N?`uploading`:``} ${d.length>0?`drop-zone-compact`:``}`,onDragOver:e=>{e.preventDefault(),tt(!0)},onDragLeave:()=>tt(!1),onDrop:xt,role:`button`,tabIndex:N?-1:0,"aria-label":e(`docs.drop`),onClick:()=>{N||$e.current?.click()},onKeyDown:e=>{N||e.target!==e.currentTarget||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),$e.current?.click())},children:[v(`input`,{ref:$e,type:`file`,multiple:!0,hidden:!0,onClick:e=>e.stopPropagation(),onChange:St}),N?h(De.Fragment,{children:[v(`div`,{className:`upload-spinner`}),v(`p`,{children:rt})]}):h(De.Fragment,{children:[v(le,{size:32,strokeWidth:1.5}),v(`p`,{children:e(`docs.drop`)}),v(`span`,{className:`drop-hint`,children:e(`docs.dropHint`)})]})]}),v(`p`,{className:`drop-hint path-hint`,children:e(`docs.pathHint`)}),h(`form`,{className:`path-input-form`,onSubmit:jt,children:[v(de,{size:16,className:`path-icon`}),v(`input`,{type:`text`,className:`path-input`,value:F,onChange:e=>it(e.target.value),placeholder:ee(),"aria-label":e(`docs.pathAria`),dir:`auto`}),v(`button`,{type:`submit`,className:`btn-secondary`,disabled:!F.trim()||N,children:e(`docs.index`)}),h(`button`,{type:`button`,className:`btn-secondary`,onClick:y,title:e(`docs.browseTitle`),children:[v(_e,{size:14}),e(`docs.browse`)]})]}),v(`p`,{className:`doc-path-hint`,children:e(`docs.pathSubfolders`)}),Ke&&v(`p`,{className:`doc-target-notice`,role:`status`,children:Ke}),I&&v(ae,{filename:I.filename,error:I.error,status:I.status,kind:I.kind,onDismiss:()=>L(null)}),W&&d.length>0&&h(`div`,{className:`doc-folder-notice doc-action-error`,role:`alert`,children:[v(u,{size:14}),v(`span`,{children:e(`docs.loadFailed`,{error:o(W.err)})}),v(`button`,{type:`button`,className:`btn-secondary`,onClick:q,children:e(`docs.loadRetry`)})]}),ot&&h(`div`,{className:`doc-folder-notice doc-action-error`,role:`alert`,children:[v(u,{size:14}),v(`span`,{children:ot}),v(`button`,{className:`btn-icon-sm`,onClick:()=>z(null),"aria-label":e(`docs.dismissError`),children:v(c,{size:12})})]}),B&&h(`div`,{className:`doc-folder-notice doc-removed-notice`,role:`status`,children:[v(t,{size:14}),v(`span`,{children:e(`docs.removed`,{name:B.name})}),h(`button`,{type:`button`,className:`doc-undo`,onClick:Tt,autoFocus:!0,children:[v(ue,{size:12}),` `,e(`docs.undo`)]})]},B.id),at&&h(`div`,{className:`doc-folder-notice`,role:`status`,children:[v(re,{size:14}),v(`span`,{children:at}),v(`button`,{className:`btn-icon-sm`,onClick:()=>R(null),"aria-label":e(`docs.dismissFolder`),children:v(c,{size:12})})]}),mt>0&&h(`div`,{className:`doc-stats`,children:[v(`span`,{children:e.plural(`docs.count`,mt-J.length)}),_t>0&&v(`span`,{className:`doc-stats-failed`,children:e.plural(`docs.unreadable`,_t)}),Y>0&&v(`span`,{className:`doc-stats-failed doc-stats-server`,children:e.plural(`docs.serverWaiting`,Y)}),gt>0&&v(`span`,{className:`doc-stats-failed`,children:e.plural(`docs.needsRetry`,gt)}),v(`span`,{children:`·`}),v(`bdi`,{dir:`ltr`,children:a(ht)})]}),d.length>Re&&h(`div`,{className:`doc-filter`,children:[v(_e,{size:14,className:`doc-filter-icon`,"aria-hidden":`true`}),v(`input`,{type:`search`,className:`doc-filter-input`,value:M,onChange:e=>qe(e.target.value),placeholder:e(`docs.filterPlaceholder`),"aria-label":e(`docs.filterAria`)})]}),Je&&d.length>0&&!d.some(Ye)&&v(`p`,{className:`doc-filter-empty`,children:e(`docs.filterNone`,{text:M.trim()})}),h(`div`,{className:`doc-list`,children:[W&&d.length===0&&h(`div`,{className:`empty-docs doc-load-error`,role:`alert`,children:[v(u,{size:32,strokeWidth:1}),v(`p`,{children:e(`docs.loadFailed`,{error:o(W.err)})}),v(`button`,{type:`button`,className:`btn-secondary`,onClick:q,children:e(`docs.loadRetry`)})]}),d.length===0&&!N&&!W&&h(`div`,{className:`empty-docs`,children:[v(ve,{size:32,strokeWidth:1}),v(`p`,{children:e(`docs.empty`)}),v(`span`,{children:e(`docs.emptyHint`)})]}),d.filter(e=>e.id!==B?.id).map(n=>h(`div`,{hidden:!Ye(n),className:`doc-row ${n.indexing_status===`indexing`?`doc-row-indexing`:``}`,children:[h(`div`,{className:`doc-info`,children:[v(We,{name:s(n.filename)}),Mt(n),Nt(n)]}),h(`div`,{className:`doc-row-actions`,children:[n.filepath&&v(`button`,{className:`btn-icon-sm doc-open-folder`,onClick:()=>Dt(n.filepath,n.filename),title:e(`docs.openFolder`,{path:s(n.filepath)}),"aria-label":e(`docs.openFolderAria`,{name:s(n.filename)}),children:v(de,{size:14})}),n.indexing_status===`complete`&&!(k?D?.document_ids?.includes(n.id):w.includes(n.id))&&h(`button`,{className:`doc-attach`,onClick:()=>At(n.id),title:k?e(`docs.useIn`,{chat:A}):e(`docs.useNext`),"aria-label":k?e(`docs.attachAria`,{name:s(n.filename),chat:A}):e(`docs.attachNextAria`,{name:s(n.filename)}),children:[v(ge,{size:14}),e(k?`docs.addToThisChat`:`docs.addToNextChat`)]}),n.indexing_status!==`indexing`&&n.indexing_status!==`pending`&&v(`button`,{className:`btn-icon-sm doc-delete`,onClick:()=>wt(n.id),title:e(`docs.remove`),"aria-label":e(`docs.removeAria`,{name:s(n.filename)}),children:v(t,{size:14})})]})]},n.id))]})]})]})})}export{Ge as DocumentLibrary};
@@ -1,4 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{A as t,Bn as n,Cn as r,Dn as i,E as a,Fn as o,Ft as s,Jt as c,Kt as l,O as u,Pt as d,Rt as f,Wt as p,Xt as m,_n as h,bn as ee,gn as g,h as te,hn as ne,k as re,kt as ie,nn as ae,un as _,vn as v,yn as y,zn as oe}from"./index-DnSSZ2b8.js";import{Ct as se,Mi as b,Ni as x,Oi as S,Rn as ce,a as le,c as C,f as w,fn as T,hn as E,kn as ue,rr as D,s as O,t as k,xt as A}from"./useT-CWiHVf7i.js";import{t as de}from"./folderIndexResult-DKQpxwD1.js";var j={name:`house`,size:24,node:[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]],aliases:[`home`]};j.node;var fe=b(j),M={name:`table`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]};M.node;var pe=b(M),N=e(x(),1);function me(e){if(e.type===`folder`)return O(g,{size:16});let t=(e.extension||``).toLowerCase();return[`.csv`,`.xlsx`,`.xls`,`.tsv`].includes(t)?O(pe,{size:16}):[`.py`,`.js`,`.ts`,`.java`,`.c`,`.cpp`,`.go`,`.rs`].includes(t)?O(i,{size:16}):[`.pdf`,`.doc`,`.docx`,`.txt`,`.md`].includes(t)?O(y,{size:16}):O(v,{size:16})}function he(e,t){if(!e)return``;let n=new Date(e),r=new Date,i=r.getTime()-n.getTime();if(i<6e4)return t(`time.justNow`);let a=Math.floor(i/6e4);if(a<60)return t(`time.minutesAgo`,{n:a});let o=Math.floor(a/60);if(o<24)return t(`time.hoursAgo`,{n:o});let s=Math.floor(o/24);return s<7?t(`time.daysAgo`,{n:s}):n.toLocaleDateString(k(t),{month:`short`,day:`numeric`,year:n.getFullYear()===r.getFullYear()?void 0:`numeric`})}function ge(e,t){if(e.length===0)return``;let[n,...r]=e;return r.length>0?t(`fileBrowser.scopeMore`,{first:n,n:r.length}):n}function _e(e){switch(e){case`home`:return O(fe,{size:14});case`desktop`:return O(_,{size:14});case`documents`:return O(y,{size:14});case`download`:return O(r,{size:14});default:return O(g,{size:14})}}var ve=[{label:`fileBrowser.filter.all`,value:``},{label:`fileBrowser.filter.documents`,value:`pdf,doc,docx,txt,md`},{label:`fileBrowser.filter.spreadsheets`,value:`csv,xlsx,xls,tsv`},{label:`fileBrowser.filter.code`,value:`py,js,ts,java,c,cpp,go,rs,rb,sh`},{label:`fileBrowser.filter.data`,value:`json,xml,yaml,yml,csv,tsv`}],ye={home:`fileBrowser.home`,desktop:`fileBrowser.desktop`,documents:`fileBrowser.documents`,download:`fileBrowser.downloads`};async function be(e,n,r,i){let a=[],o=[];for(let n of e){let e=n.includes(`.`)?`.`+n.split(`.`).pop()?.toLowerCase():``;e&&!t(e)?o.push(n):a.push(n)}let s=[],c=[],l=0,u=``,d=null,f=0,m=[],h=!1,ee=new Set(n.filter(e=>e.type===`folder`).map(e=>e.path));for(let e of a)try{if(ee.has(e)){let t=await T(e),n=[];t.documents.forEach(e=>{e.id&&n.push(e.id)}),f+=t.skipped_images??0,m.push(...t.skipped_files??[]),h||=t.skipped_files_truncated===!0,t.failed>0&&(l+=t.failed,u=t.errors[0]??u),n.length>0&&(n.forEach(e=>s.push(e)),c.push(e))}else{if(!await p(`embedding`))break;let t=await D(e);t?.indexing_status===`failed`?(l++,u=t.last_error??``,d=t.error_kind??null):t?.id&&(s.push(t.id),c.push(e))}}catch(e){l++,u=e instanceof Error?e.message:`Unknown error`,d=e?.reason??null}if(r&&s.length>0){let e=[];for(let t of s)try{await A(r,t),e.push(t)}catch(e){S.doc.warn(`Could not attach document to session: ${e}`)}let t=w.getState().sessions.find(e=>e.id===r)?.document_ids??[],n=e.filter(e=>!t.includes(e));n.length>0&&i(r,{document_ids:[...t,...n]})}else s.length>0&&w.getState().addDraftDocuments(s);if(s.length>0||l>0)try{let e=await E();w.getState().setDocuments(e.documents||[])}catch(e){S.doc.error(`Could not refresh the document list after indexing`,e)}return{docIds:s,supported:a,succeededFiles:c,unsupported:o,failed:l,lastError:u,lastErrorKind:d,skippedImages:f,skippedFiles:m,skippedFilesTruncated:h}}var xe=e=>e.startsWith(`.`);function P({onStartChat:e}){let r=le(),{setShowFileBrowser:i,leaveFileBrowser:p,currentSessionId:g,updateSessionInList:_,setPendingPrompt:v}=w(),y=(0,N.useCallback)(()=>i(!1),[i]);l(!0,y);let b=(0,N.useRef)(null);ie(b,!0),te(b,!0);let[x,T]=(0,N.useState)(``),[E,D]=(0,N.useState)(null),[k,A]=(0,N.useState)([]),[j,fe]=(0,N.useState)([]),[M,pe]=(0,N.useState)(!1),[P,F]=(0,N.useState)(null),[I,Se]=(0,N.useState)(null),[L,Ce]=(0,N.useState)(!1),[R,z]=(0,N.useState)(``),[B,V]=(0,N.useState)(null),[we,H]=(0,N.useState)([]),[Te,Ee]=(0,N.useState)(!1),[De,Oe]=(0,N.useState)(!1),[U,ke]=(0,N.useState)(``),[W,G]=(0,N.useState)(new Set),[K,q]=(0,N.useState)(null),[Ae,je]=(0,N.useState)(!1),[Me,J]=(0,N.useState)(new Set),[Ne,Y]=(0,N.useState)(null),X=(0,N.useRef)(null),[Z,Q]=(0,N.useState)(null),$=(0,N.useCallback)(async e=>{pe(!0),F(null),Se(null),V(null),z(``),H([]);try{let t=await se(e);T(t.current_path),D(t.parent_path),A(t.entries),t.quick_links.length>0&&fe(t.quick_links),S.ui.info(`Browsing: ${t.current_path} (${t.entries.length} items)`)}catch(t){if(e&&t.reason===`os_denied`){let t=e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;T(e),D(null),A([]),Se(t)}else F(t instanceof Error?t.message:`Failed to load directory`);S.ui.error(`Browse failed`,t)}finally{pe(!1)}},[]);(0,N.useEffect)(()=>{$()},[$]),(0,N.useEffect)(()=>()=>{X.current&&clearTimeout(X.current)},[]);let Pe=(0,N.useCallback)(async()=>{if(!R.trim())V(null),H([]);else{Oe(!0),F(null);try{let e=await ce(R.trim(),U||void 0,30);V(e.results),H(e.searched_locations??[]),Ee(e.truncated===!0),S.ui.info(`Search "${R}": ${e.total} results`)}catch(e){let t=e instanceof Error?e.message:`Search failed`;F(t),S.ui.error(`Search failed`,e)}finally{Oe(!1)}}},[R,U]),Fe=e=>{e.key===`Enter`&&Pe()},Ie=(0,N.useCallback)(e=>{e.type===`folder`&&($(e.path),G(new Set),q(null))},[$]),Le=(0,N.useCallback)(async e=>{je(!0);try{let t=await ue(e);q({...t,size_display:a(t.size)})}catch(e){S.ui.error(`Preview failed`,e)}finally{je(!1)}},[]),Re=(0,N.useCallback)(e=>{G(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ze=(0,N.useCallback)(async()=>{if(W.size===0)return;let e=Array.from(W);if(Q(null),!e.some(e=>{let n=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``;return!n||t(n)})){let t=e[0],n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=re(r);Q({filename:e.length===1?t.split(/[\\/]/).pop()||t:`${e.length} files`,error:i?i.message:`File type "${r}" is not supported for indexing.`})}else{J(new Set(e)),Y(r.plural(`fileBrowser.adding`,e.length));try{let t=await be(e,k,g,_);if(t.failed>0)Y(r(`fileBrowser.addedWithFailures`,{added:t.docIds.length,failed:t.failed})),Q({filename:`${t.failed} file(s)`,error:t.lastError||`Indexing failed for some files`,kind:t.lastErrorKind});else{let e=[r.plural(`fileBrowser.added`,t.docIds.length)];t.unsupported.length>0&&e.push(r.plural(`fileBrowser.skipped`,t.unsupported.length)),e.push(...de(r,{skipped_files:t.skippedFiles,skipped_files_truncated:t.skippedFilesTruncated})),t.skippedImages>0&&e.push(r.plural(`docs.folder.images`,t.skippedImages)),Y(e.join(` `))}X.current&&clearTimeout(X.current),X.current=setTimeout(()=>Y(null),5e3),G(new Set),t.failed===0&&t.unsupported.length===0&&w.getState().fileBrowserFromLibrary&&i(!1)}catch(t){S.doc.error(`Index selected failed`,t),Q({filename:e.length===1?e[0].split(/[\\/]/).pop()||e[0]:`${e.length} files`,error:t instanceof Error?t.message:`An unexpected error occurred.`})}finally{J(new Set)}}},[W,g,_,k,i,r]),Be=(0,N.useRef)(!1),Ve=(0,N.useRef)(null),He=(0,N.useCallback)(async()=>{if(W.size===0||Be.current)return;Be.current=!0;let t=Array.from(W);Q(null),J(new Set(t)),Y(r.plural(`fileBrowser.adding`,t.length));try{let n=await be(t,k,g,_);if(n.supported.length===0){let e=t[0].lastIndexOf(`.`),n=e>0?t[0].slice(e).toLowerCase():``,r=re(n);Q({filename:t.length===1?t[0].split(/[\\/]/).pop()||t[0]:`${t.length} files`,error:r?.message??`File type "${n}" is not supported for indexing.`});return}if(n.docIds.length===0){Q({filename:n.supported.length===1?n.supported[0].split(/[\\/]/).pop()||n.supported[0]:`${n.supported.length} files`,error:`Failed to index selected file(s). Please try again.`});return}n.failed>0&&Y(r.plural(`fileBrowser.someFailed`,n.failed));let i=(n.succeededFiles.length>0?n.succeededFiles:n.supported).map(e=>e.split(/[\\/]/).pop()||e),a=i.length===1?`Please analyze this document for me: ${i[0]}`:`Please analyze these documents for me:\n${i.map(e=>`- ${e}`).join(`
2
- `)}`;g?v({sessionId:g,text:a}):await e(a),p(),G(new Set)}catch(e){S.doc.error(`Ask Agent failed`,e),Q({filename:t.length===1?t[0].split(/[\\/]/).pop()||t[0]:`${t.length} files`,error:e instanceof Error?e.message:`An unexpected error occurred.`})}finally{Be.current=!1,J(new Set),Y(null)}},[W,g,_,k,v,p,e,r]),Ue=x?x.replace(/\\/g,`/`).split(`/`).filter(Boolean):[],We=Ue.map((e,t)=>({label:e,path:Ue.slice(0,t+1).join(`/`)+(t===0&&e.includes(`:`)?`/`:``)})),Ge=ge(we,r),Ke=k.filter(e=>!xe(e.name)),qe=B?B.map(e=>({name:e.name,path:e.path,type:`file`,size:e.size,extension:e.extension||``,modified:e.modified||``})):L?k:Ke,Je=k.length-Ke.length;return(0,N.useEffect)(()=>{let e=Ve.current;e&&(e.scrollLeft=getComputedStyle(e).direction===`rtl`?-e.scrollWidth:e.scrollWidth)},[x,B]),(0,N.useEffect)(()=>{L||B||G(e=>{let t=[...e].filter(e=>!xe(e.split(/[\\/]/).pop()??``));return t.length===e.size?e:new Set(t)})},[L,B]),O(`div`,{ref:b,className:`modal-overlay`,onClick:()=>i(!1),role:`dialog`,"aria-modal":`true`,"aria-label":r(`fileBrowser.title`),children:C(`div`,{className:`modal-panel file-browser-modal ${K?`has-preview`:``}`,onClick:e=>e.stopPropagation(),children:[C(`div`,{className:`modal-header`,children:[C(`h3`,{children:[O(h,{size:18}),` `,r(`fileBrowser.title`)]}),O(`button`,{className:`btn-icon`,onClick:()=>i(!1),"aria-label":r(`fileBrowser.close`),children:O(c,{size:18})})]}),C(`div`,{className:`file-browser-body`,children:[O(`div`,{className:`fb-quick-links`,children:j.map(e=>C(`button`,{className:`fb-quick-link`,onClick:()=>$(e.path),title:s(e.path),children:[_e(e.icon),O(`span`,{children:ye[e.icon]?r(ye[e.icon]):s(e.name)})]},e.path))}),C(`div`,{className:`fb-search-bar`,children:[C(`div`,{className:`fb-search-input-wrap`,children:[O(ae,{size:14,className:`fb-search-icon`}),O(`input`,{type:`text`,className:`fb-search-input`,placeholder:r(`fileBrowser.searchPlaceholder`),value:R,onChange:e=>z(e.target.value),onKeyDown:Fe,"aria-label":r(`fileBrowser.searchAria`)}),R&&O(`button`,{className:`fb-search-clear`,onClick:()=>{z(``),V(null),H([])},"aria-label":r(`fileBrowser.clearSearch`),children:O(c,{size:12})})]}),O(`select`,{className:`fb-type-filter`,value:U,onChange:e=>ke(e.target.value),"aria-label":r(`fileBrowser.typeFilter`),children:ve.map(e=>O(`option`,{value:e.value,children:r(e.label)},e.value))}),O(`button`,{className:`fb-search-btn`,onClick:Pe,disabled:!R.trim()||De,children:r(De?`fileBrowser.searching`:`fileBrowser.search`)})]}),!B&&C(`div`,{className:`fb-pathbar`,children:[C(`div`,{className:`fb-breadcrumb`,ref:Ve,children:[O(`button`,{className:`fb-crumb`,onClick:()=>$(`/`),children:O(ne,{size:12})}),We.map((e,t)=>C(`span`,{className:`fb-crumb-item`,children:[O(o,{size:12,className:`fb-crumb-sep`}),O(`button`,{className:`fb-crumb`,onClick:()=>$(e.path),children:s(e.label)})]},t))]}),E&&O(`button`,{className:`fb-up-btn`,onClick:()=>$(E),title:r(`fileBrowser.goUp`),children:O(n,{size:14})}),C(`label`,{className:`fb-hidden-toggle`,children:[O(`input`,{type:`checkbox`,checked:L,onChange:e=>Ce(e.target.checked)}),r(`fileBrowser.showHidden`)]})]}),B&&C(`div`,{className:`fb-search-header`,children:[C(`div`,{className:`fb-search-summary`,children:[O(`span`,{children:r.plural(`fileBrowser.found`,B.length,{query:R})}),Ge&&C(`span`,{className:`fb-search-scope`,title:we.join(`
3
- `),children:[r(`fileBrowser.searchingIn`),` `,O(`code`,{children:Ge})]}),Te&&O(`span`,{children:r(`fileBrowser.searchStopped`)})]}),O(`button`,{className:`fb-back-btn`,onClick:()=>{V(null),z(``),H([])},children:r(`fileBrowser.backToBrowsing`)})]}),(P||I)&&O(`div`,{className:`fb-error`,children:I?r(f()?`fileBrowser.deniedMac`:`fileBrowser.denied`,{name:I}):P}),C(`div`,{className:`fb-content`,children:[C(`div`,{className:`fb-file-list`,children:[M&&O(`div`,{className:`fb-loading`,children:r(`fileBrowser.loading`)}),!M&&!P&&!I&&qe.length===0&&O(`div`,{className:`fb-empty`,children:r(B?`fileBrowser.noFiles`:Je>0?`fileBrowser.onlyHidden`:`fileBrowser.empty`)}),!M&&qe.map(e=>{let n=e.extension||(e.name.includes(`.`)?`.`+e.name.split(`.`).pop()?.toLowerCase():``),i=e.type===`file`&&n&&!t(n);return C(`div`,{className:`fb-entry ${e.type} ${W.has(e.path)?`selected`:``} ${i?`unsupported`:``}`,onClick:()=>e.type===`folder`?Ie(e):Re(e.path),onDoubleClick:()=>e.type===`folder`?Ie(e):void 0,title:i?r(`fileBrowser.notIndexableTitle`):s(e.path),children:[O(`input`,{type:`checkbox`,className:`fb-entry-checkbox`,checked:W.has(e.path),onChange:()=>Re(e.path),onClick:e=>e.stopPropagation(),"aria-label":r(`fileBrowser.selectAria`,{name:s(e.name)})}),O(`span`,{className:`fb-entry-icon`,children:me(e)}),O(`span`,{className:`fb-entry-name`,title:s(e.path),dir:`auto`,children:s(e.name)}),i&&O(`span`,{className:`fb-unsupported-badge`,children:r(`fileBrowser.notIndexable`)}),e.type===`file`&&O(`button`,{type:`button`,className:`fb-entry-preview-btn`,onClick:t=>{t.stopPropagation(),Le(e.path)},"aria-label":r(`fileBrowser.previewAria`,{name:s(e.name)}),title:r(`fileBrowser.previewTitle`),children:O(ee,{size:14})}),O(`span`,{className:`fb-entry-size`,children:e.type===`file`?O(`bdi`,{dir:`ltr`,children:a(e.size)}):``}),O(`span`,{className:`fb-entry-date`,children:he(e.modified,r)})]},e.path)})]}),K&&C(`div`,{className:`fb-preview`,children:[C(`div`,{className:`fb-preview-header`,children:[O(`span`,{className:`fb-preview-name`,dir:`auto`,children:s(K.name)}),O(`button`,{className:`btn-icon-sm`,onClick:()=>q(null),"aria-label":r(`fileBrowser.closePreview`),children:O(c,{size:14})})]}),C(`div`,{className:`fb-preview-meta`,children:[O(`span`,{children:K.size_display}),K.total_lines?O(`span`,{children:r(`fileBrowser.lines`,{n:K.total_lines})}):null,K.columns&&O(`span`,{children:r(`fileBrowser.columnCount`,{n:K.columns.length})}),K.row_count!==null&&O(`span`,{children:r(`fileBrowser.rows`,{n:K.row_count})})]}),K.columns&&C(`div`,{className:`fb-preview-columns`,children:[O(`strong`,{children:r(`fileBrowser.columnsLabel`)}),` `,K.columns.join(`, `)]}),Ae?O(`div`,{className:`fb-preview-loading`,children:r(`fileBrowser.previewLoading`)}):K.is_text&&K.preview_lines.length>0?O(`pre`,{className:`fb-preview-content`,children:d(K.preview_lines.slice(0,30).join(`
4
- `))}):O(`div`,{className:`fb-preview-binary`,children:r(K.is_text?`fileBrowser.emptyFile`:`fileBrowser.binary`)})]})]}),Z&&O(u,{filename:Z.filename,error:Z.error,kind:Z.kind??void 0,onDismiss:()=>Q(null)}),C(`div`,{className:`fb-actions`,children:[O(`div`,{className:`fb-selection-info`,children:W.size>0?r.plural(`fileBrowser.selected`,W.size):r(`fileBrowser.selectHint`)}),Ne&&O(`span`,{className:`fb-index-status`,children:Ne}),C(`div`,{className:`fb-action-btns`,children:[C(`button`,{className:`fb-action-btn secondary`,onClick:ze,disabled:W.size===0||Me.size>0,title:r(`fileBrowser.addToLibraryTitle`),children:[O(m,{size:14}),r(`fileBrowser.addToLibrary`)]}),C(`button`,{className:`fb-action-btn primary`,onClick:He,disabled:W.size===0||Me.size>0,title:r(`fileBrowser.askGaiaTitle`),children:[O(oe,{size:14}),r(`fileBrowser.askGaia`)]})]})]})]})]})})}export{P as FileBrowser};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{L as t,Mi as n,Ni as r,Oi as i,a,c as o,f as s,o as c,r as l,s as u,t as d}from"./useT-CWiHVf7i.js";import{$ as ee,$t as te,B as f,E as p,En as ne,Fn as m,G as re,H as ie,In as ae,J as oe,Jt as se,K as ce,Kt as le,L as ue,Ln as de,Nn as h,On as fe,Q as pe,Qt as g,R as me,Tn as he,U as ge,V as _e,Vn as _,W as ve,X as ye,Y as be,Yt as xe,Z as v,Zt as Se,_t as Ce,an as we,at as Te,bn as Ee,cn as De,ct as Oe,dn as ke,dt as Ae,en as y,et as je,ft as Me,gt as Ne,ht as Pe,it as Fe,kn as Ie,kt as Le,lt as Re,mt as ze,nn as Be,nt as Ve,on as He,ot as Ue,pn as We,pt as Ge,q as Ke,qt as qe,rt as Je,st as Ye,t as Xe,tt as Ze,ut as Qe,vt as $e,wn as et,yt as tt,z as nt,zn as rt}from"./index-DnSSZ2b8.js";var it={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};it.node;var at=n(it),ot={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};ot.node;var st=n(ot),ct={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};ct.node;var lt=n(ct),b={name:`target`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};b.node;var ut=n(b),dt={name:`trending-up`,size:24,node:[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]};dt.node;var ft=n(dt),x={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};x.node;var pt=n(x),S=e(r(),1),mt=200,C=[{title:`mem.about.group.preferences`,categories:[`preference`]},{title:`mem.about.group.about`,categories:[`fact`,`profile`,`skill`]},{title:`mem.about.group.reminders`,categories:[`reminder`]},{title:`mem.about.group.notes`,categories:[`note`]}],ht={user:`mem.source.user`,tool:`mem.source.tool`,llm_extract:`mem.source.llm_extract`,consolidation:`mem.source.consolidation`,inferred:`mem.source.inferred`,discovery:`mem.source.discovery`,error_auto:`mem.source.error_auto`};function gt(e){return ht[e]??`mem.source.other`}function _t(e,n){let r=new Date(e);if(Number.isNaN(r.getTime()))return null;let i=Math.floor((Date.now()-r.getTime())/864e5);return i<=0?t(`mem.day.today`):i===1?t(`mem.day.yesterday`):i<30?t(`mem.day.daysAgo`,{n:i}):r.toLocaleDateString(d(n),{month:`short`,day:`numeric`,year:`numeric`})}function vt(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e),n=t?new Date(+t[1],t[2]-1,+t[3]):new Date(e);return Number.isNaN(n.getTime())?null:n}function yt(e){let t=e?vt(e):null;if(!t)return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function bt(e,t=new Date,n=l){let r=vt(e);if(!r)return null;let i=r.getHours()===0&&r.getMinutes()===0&&r.getSeconds()===0,a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),o=i?r.getTime()<a:r.getTime()<t.getTime(),s=r.toLocaleString(d(n),{weekday:`short`,month:`short`,day:`numeric`,...r.getFullYear()===t.getFullYear()?{}:{year:`numeric`},...i?{}:{hour:`numeric`,minute:`2-digit`}});return{text:n(o?`mem.due.past`:`mem.due.upcoming`,{when:s}),past:o}}function xt({agent:e,supports:n,memoryEnabled:r,reloadKey:s,onChanged:l,onOpenAdvanced:d,showToast:f}){let p=a(),ne=t(e===`gaiacpp`?`setup.agent.gaiacpp`:`setup.agent.gaiapy`),[m,ie]=(0,S.useState)(null),[ae,se]=(0,S.useState)(null),[ce,le]=(0,S.useState)(null),[ue,de]=(0,S.useState)(``),[h,fe]=(0,S.useState)(``),[pe,g]=(0,S.useState)([]),[me,he]=(0,S.useState)(new Set),[ge,_e]=(0,S.useState)(``),[_,ve]=(0,S.useState)(`fact`),[ye,be]=(0,S.useState)(``),[xe,v]=(0,S.useState)(null),[Ce,we]=(0,S.useState)(0),[Te,Oe]=(0,S.useState)(!1),ke=(0,S.useRef)(0),Ae=(0,S.useRef)(mt),y=(0,S.useCallback)(async e=>{let t=++ke.current,n=e??Ae.current;try{let e=[],r=new Set,i=0,a=0;for(;;){let o=Math.min(mt,n-e.length),s=await ee({about_user:!0,include_sensitive:!0,sort_by:`updated_at`,order:`desc`,offset:i,limit:o});if(t!==ke.current)return;i+=s.items.length;for(let t of s.items)r.has(t.id)||(r.add(t.id),e.push(t));if(a=typeof s.total==`number`?s.total:e.length,s.items.length<o||e.length>=Math.min(n,a))break}Ae.current=n,ie(e),we(a),se(null)}catch(e){if(t!==ke.current)return;i.system.warn(`Failed to load what GAIA knows about the user`,e),se(e instanceof Error?e.message:String(e))}},[]);(0,S.useEffect)(()=>{y()},[y,s]);let je=(0,S.useCallback)(async()=>{Oe(!0),Ae.current=Math.max(Ae.current,m?.length??0)+mt;try{await y()}finally{Oe(!1)}},[y,m]),Me=(0,S.useCallback)(async e=>{let t=ue.trim(),r=n.due_dates&&e.category===`reminder`&&!!h&&h!==yt(e.due_at);if(!t||t===e.content&&!r)le(null);else{v(e.id);try{await oe(e.id,{...t===e.content?{}:{content:t},...r?{due_at:h}:{}}),le(null),f(p(`mem.about.updated`),`success`),await y(),l()}catch(e){i.system.error(`Failed to edit memory`,e),f(p(`mem.about.editFailed`,{error:St(e)}),`error`)}finally{v(null)}}},[ue,h,y,l,f,n.due_dates,p]),Ne=(0,S.useCallback)(async e=>{v(e.id);try{await Ke(e.id),ke.current++,ie(t=>(t??[]).filter(t=>t.id!==e.id)),we(e=>Math.max(e-1,0)),g(t=>[e,...t]),l()}catch(e){i.system.error(`Failed to forget memory`,e),f(p(`mem.about.forgetFailed`,{error:St(e)}),`error`)}finally{v(null)}},[l,f,p]),Pe=(0,S.useCallback)(async e=>{v(e.id);try{await re({content:e.content,category:e.category,domain:e.domain??void 0,context:e.context??void 0,entity:e.entity??void 0,sensitive:e.sensitive,...n.due_dates&&e.due_at?{due_at:e.due_at}:{}}),g(t=>t.filter(t=>t.id!==e.id)),await y(),l()}catch(e){i.system.error(`Failed to restore memory`,e),f(p(`mem.about.restoreFailed`,{error:St(e)}),`error`)}finally{v(null)}},[y,l,f,n.due_dates,p]),Fe=(0,S.useCallback)(async()=>{let e=ge.trim(),t=_===`reminder`;if(!(!e||t&&!ye)){v(`new`);try{await re({content:e,category:_,...t?{due_at:ye}:{}}),_e(``),be(``),f(p(`mem.about.saved`),`success`),await y(),l()}catch(e){i.system.error(`Failed to add memory`,e),f(p(`mem.about.addFailed`,{error:St(e)}),`error`)}finally{v(null)}}},[ge,_,ye,y,l,f,p]);if(!r)return o(`div`,{className:`mem-about`,children:[u(`h2`,{className:`mem-about-title`,children:p(`mem.about.title`)}),o(`div`,{className:`mem-about-empty`,children:[u(`p`,{children:p(`mem.about.off`)}),u(`button`,{className:`btn-secondary`,onClick:d,children:p(`mem.about.turnOn`)})]})]});let Ie=C.map(e=>({...e,rows:(m??[]).filter(t=>e.categories.includes(t.category))})).filter(e=>e.rows.length>0);return o(`div`,{className:`mem-about`,children:[u(`h2`,{className:`mem-about-title`,children:p(`mem.about.title`)}),u(`p`,{className:`mem-about-intro`,children:p(`mem.about.intro`)}),(!n.due_dates||!n.sources)&&o(`p`,{className:`mem-about-limits`,role:`note`,children:[!n.due_dates&&u(`span`,{children:p(`mem.about.limit.dueDates`,{name:ne})}),!n.due_dates&&!n.sources&&` `,!n.sources&&u(`span`,{children:p(`mem.about.limit.sources`,{name:ne})})]}),o(`form`,{className:`mem-about-add`,onSubmit:e=>{e.preventDefault(),Fe()},children:[u(`input`,{className:`mem-input`,placeholder:p.bare(`mem.about.addPlaceholder`),"aria-label":p(`mem.about.addLabel`),value:ge,onChange:e=>_e(e.target.value)}),o(`select`,{className:`mem-select`,"aria-label":p(`mem.about.kind`),value:_,onChange:e=>ve(e.target.value),children:[u(`option`,{value:`fact`,children:p.bare(`mem.about.group.about`)}),u(`option`,{value:`preference`,children:p.bare(`mem.about.kind.preference`)}),n.due_dates&&u(`option`,{value:`reminder`,children:p.bare(`mem.about.kind.reminder`)}),u(`option`,{value:`note`,children:p.bare(`mem.about.kind.note`)})]}),_===`reminder`&&u(`input`,{type:`datetime-local`,className:`mem-input mem-about-when`,"aria-label":p(`mem.about.when`),value:ye,onChange:e=>be(e.target.value)}),o(`button`,{className:`btn-primary`,type:`submit`,disabled:!ge.trim()||_===`reminder`&&!ye||xe===`new`,children:[u(He,{size:14}),` `,p(`mem.about.add`)]})]}),pe.map(e=>o(`div`,{className:`mem-about-forgotten`,role:`status`,children:[u(`span`,{title:e.sensitive?void 0:e.content,children:e.sensitive?p(`mem.about.forgottenSensitive`):p(`mem.about.forgotten`,{content:Ct(e.content)})}),o(`button`,{className:`mem-about-link`,disabled:xe===e.id,onClick:()=>Pe(e),children:[u(Se,{size:12}),` `,p(`mem.about.undo`)]})]},e.id)),ae?o(`div`,{className:`mem-about-empty`,children:[u(`p`,{children:p(`mem.about.loadFailed`,{error:ae})}),u(`button`,{className:`btn-secondary`,onClick:()=>y(),children:p(`mem.about.retry`)})]}):m===null?o(`div`,{className:`mem-loading`,children:[u(`div`,{className:`mem-spinner`}),` `,p(`mem.loading`)]}):Ie.length===0?o(`div`,{className:`mem-about-empty`,children:[u(`p`,{children:p(`mem.about.empty`)}),u(`p`,{className:`mem-about-hint`,children:p(`mem.about.emptyHint`)})]}):Ie.map(e=>o(`section`,{className:`mem-about-group`,"aria-label":p(e.title),children:[u(`h3`,{className:`mem-about-group-title`,children:p(e.title)}),u(`ul`,{className:`mem-about-list`,children:e.rows.map(e=>{let r=e.sensitive&&!me.has(e.id),i=n.due_dates&&e.due_at?bt(e.due_at,new Date,p):null,a=n.sources&&e.source?gt(e.source):null,s=_t(e.updated_at,p),l=r?t(`mem.about.sensitiveMemory`):e.content;return u(`li`,{className:`mem-about-item`,children:ce===e.id?o(`form`,{className:`mem-about-edit`,onSubmit:t=>{t.preventDefault(),Me(e)},children:[u(`textarea`,{className:`mem-input`,"aria-label":p(`mem.about.editLabel`),rows:2,autoFocus:!0,value:ue,onChange:e=>de(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.stopPropagation(),le(null)),t.key===`Enter`&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),Me(e))}}),n.due_dates&&e.category===`reminder`&&u(`input`,{type:`datetime-local`,className:`mem-input mem-about-when`,"aria-label":p(`mem.about.when`),value:h,onChange:e=>fe(e.target.value)}),o(`div`,{className:`mem-about-edit-actions`,children:[u(`button`,{className:`btn-primary`,type:`submit`,disabled:xe===e.id,children:p(`mem.about.save`)}),u(`button`,{className:`btn-secondary`,type:`button`,onClick:()=>le(null),children:p(`mem.about.cancel`)})]})]}):o(c.Fragment,{children:[o(`div`,{className:`mem-about-text`,children:[r?o(`button`,{className:`mem-about-link`,onClick:()=>he(t=>new Set(t).add(e.id)),children:[u(Ee,{size:12}),` `,p(`mem.about.showSensitive`)]}):u(`bdi`,{children:e.content}),i&&u(`span`,{className:`mem-about-due${i.past?` is-overdue`:``}`,children:i.text}),(a||s!==null)&&u(`span`,{className:`mem-about-meta`,children:a===null?typeof s==`string`?s:p(s.ref,s.params):s===null?p(a):p(`mem.about.meta`,{source:t(a),when:s})})]}),o(`div`,{className:`mem-about-actions`,children:[u(`button`,{className:`mem-about-btn`,"aria-label":p(`mem.about.editAria`,{name:l}),title:p(r?`mem.about.editHidden`:`mem.about.edit`),disabled:r,onClick:()=>{le(e.id),de(e.content),fe(yt(e.due_at))},children:u(De,{size:14})}),o(`button`,{className:`mem-about-btn mem-about-btn-remove`,"aria-label":p(`mem.about.forgetAria`,{name:l}),title:p(`mem.about.forget`),disabled:xe===e.id,onClick:()=>Ne(e),children:[u(te,{size:14}),` `,p(`mem.about.forget`)]})]})]})},e.id)})})]},e.title)),!ae&&m!==null&&m.length<Ce&&o(`div`,{className:`mem-about-more`,children:[u(`span`,{children:p(`mem.about.showing`,{shown:m.length,total:Ce})}),u(`button`,{className:`btn-secondary`,disabled:Te,onClick:je,children:p(`mem.about.showMore`)})]})]})}function St(e){return e instanceof Error?e.message:String(e)}function Ct(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=80?t:`${t.slice(0,79).trimEnd()}…`}function w(e,t){if(!e)return`—`;try{let n=new Date(e);if(isNaN(n.getTime()))return`—`;let r={month:`short`,day:`numeric`};return n.getFullYear()!==new Date().getFullYear()&&(r.year=`numeric`),n.toLocaleDateString(t,r)}catch{return`—`}}function T(e,t){if(!e)return``;try{let n=new Date(e);return isNaN(n.getTime())?``:n.toLocaleString(t,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function E(e,t){if(!e)return`—`;try{let n=new Date(e);if(isNaN(n.getTime()))return`—`;let r=Date.now(),i=n.getTime()-r,a=Math.abs(i),o=Math.floor(a/1e3),s=Math.floor(a/6e4),c=Math.floor(a/36e5),l=Math.floor(a/864e5);return i<0?o<5?t(`time.justNow`):o<60?t(`mem.rel.secondsAgo`,{n:o}):c===0?t(`time.minutesAgo`,{n:s}):l===0?t(`time.hoursAgo`,{n:c}):l===1?t(`time.yesterday`):l<30?t(`time.daysAgo`,{n:l}):T(e,d(t)):o<5?t(`mem.rel.now`):o<60?t(`mem.rel.inSeconds`,{n:o}):c===0?t(`mem.rel.inMinutes`,{n:s}):l===0?t(`mem.rel.inHours`,{n:c}):l===1?t(`mem.rel.tomorrow`):l<30?t(`mem.rel.inDays`,{n:l}):T(e,d(t))}catch{return`—`}}function wt(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function Tt(e){try{return new Date(e).getTime()<Date.now()}catch{return!1}}function Et(e){return e>=.7?`high`:e>=.4?`medium`:`low`}function Dt(e){return e>=.9?`high`:e>=.7?`medium`:`low`}function Ot(e,t,n){let r=w(e,n),i=w(t,n);return r===`—`&&i===`—`?``:r===i?r:`${r} \u2013 ${i}`}function kt(e){if(e.length===0)return 0;let t=new Date().toISOString().slice(0,10),n=e.find(e=>e.date===t);return n?n.knowledge_added:0}var At=[`fact`,`preference`,`error`,`skill`,`note`,`reminder`],jt={fact:`mem.cat.fact`,preference:`mem.cat.preference`,error:`mem.cat.error`,skill:`mem.cat.skill`,note:`mem.cat.note`,reminder:`mem.cat.reminder`},Mt={pending_approval:`mem.status.pending_approval`,queued:`mem.status.queued`,in_progress:`mem.status.in_progress`,completed:`mem.status.completed`,failed:`mem.status.failed`,rejected:`mem.status.rejected`,cancelled:`mem.status.cancelled`,blocked:`mem.status.blocked`},Nt={low:`mem.priority.low`,medium:`mem.priority.medium`,high:`mem.priority.high`},Pt={agent_inferred:`mem.goals.source.agent_inferred`,agent_scheduled:`mem.goals.source.agent_scheduled`},Ft={user:`mem.role.user`,assistant:`mem.role.assistant`},It={work:`mem.domain.work`,technical:`mem.domain.technical`,personal:`mem.domain.personal`,general:`mem.domain.general`},Lt={...It,global:`mem.context.global`};function D({value:e,keys:t}){let n=a(),r=t[e];return r?u(c.Fragment,{children:n(r)}):u(`bdi`,{children:e})}function O(e){return e instanceof Error?e.message:String(e)}var Rt={work:`blue`,technical:`purple`,personal:`green`,general:`gray`},zt=`gaiacpp`;function Bt(){let e=a(),{setShowMemoryDashboard:n,sessions:r,setCurrentSession:l,openSettings:Se}=s(),it=s(e=>e.settingsSection!==null),ot=(0,S.useMemo)(()=>new Map(r.map(e=>[e.id,e.title])),[r]),ct=e=>ot.get(e)||`${e.slice(0,8)}...`,[b,dt]=(0,S.useState)(null),[x,mt]=(0,S.useState)([]),[C,gt]=(0,S.useState)(null),[_t,vt]=(0,S.useState)([]),[yt,bt]=(0,S.useState)([]),[St,Ct]=(0,S.useState)([]),[w,Bt]=(0,S.useState)(null),[Vt,Ht]=(0,S.useState)([]),[k,Ut]=(0,S.useState)(null),[Wt,Gt]=(0,S.useState)(null),Kt=(0,S.useRef)(null),qt=k?.supports.advanced===!0,[Jt,Yt]=(0,S.useState)(!0),[Xt,Zt]=(0,S.useState)(!1),[Qt,$t]=(0,S.useState)(null),[en,A]=(0,S.useState)(!1),[tn,nn]=(0,S.useState)(null),[rn,an]=(0,S.useState)([]),on=(0,S.useRef)(0),[j,sn]=(0,S.useState)([]),[cn,ln]=(0,S.useState)(``),[un,dn]=(0,S.useState)(``),[fn,pn]=(0,S.useState)(``),[M,mn]=(0,S.useState)(`updated_at`),[hn,gn]=(0,S.useState)(`desc`),[N,P]=(0,S.useState)(0),[_n,vn]=(0,S.useState)(!1),[yn,bn]=(0,S.useState)(``),[xn,Sn]=(0,S.useState)(null),Cn=(0,S.useRef)(null),[F,wn]=(0,S.useState)(null),[Tn,En]=(0,S.useState)(!1),[I,Dn]=(0,S.useState)(null),[L,R]=(0,S.useState)({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),[z,On]=(0,S.useState)(new Set),[B,kn]=(0,S.useState)(!1),[An,jn]=(0,S.useState)(!1),[Mn,Nn]=(0,S.useState)(!1),[V,H]=(0,S.useState)(!1),[Pn,Fn]=(0,S.useState)(!1),[U,In]=(0,S.useState)(null),[Ln,Rn]=(0,S.useState)(!1),[zn,W]=(0,S.useState)(null),[G,Bn]=(0,S.useState)(`about`),[Vn,Hn]=(0,S.useState)(0),[Un,Wn]=(0,S.useState)([]),[Gn,Kn]=(0,S.useState)(null),[qn,Jn]=(0,S.useState)(!1),Yn=Xe(e=>e.error),Xn=Xe(e=>e.damaged),[Zn,Qn]=(0,S.useState)(null),[$n,er]=(0,S.useState)(null),[tr,nr]=(0,S.useState)(!1),[rr,ir]=(0,S.useState)(null),[ar,or]=(0,S.useState)(null),[sr,cr]=(0,S.useState)(!1),[K,lr]=(0,S.useState)({title:``,description:``,priority:`medium`}),[q,ur]=(0,S.useState)(`idle`),[dr,fr]=(0,S.useState)([]),[pr,mr]=(0,S.useState)([]),[hr,gr]=(0,S.useState)(null),[_r,vr]=(0,S.useState)(new Set),yr=(0,S.useRef)(null),br=(0,S.useRef)(null),[J,xr]=(0,S.useState)(`idle`),[Sr,Cr]=(0,S.useState)([]),[wr,Tr]=(0,S.useState)([]),[Er,Dr]=(0,S.useState)(null),[Or,kr]=(0,S.useState)(!1),Ar=(0,S.useRef)(null),jr=(0,S.useRef)(null),[Mr,Nr]=(0,S.useState)(30),[Pr,Fr]=(0,S.useState)(!1),[Ir,Lr]=(0,S.useState)(!1),[Rr,zr]=(0,S.useState)(!1),[Br,Vr]=(0,S.useState)(!1),[Hr,Ur]=(0,S.useState)(!1),[Wr,Gr]=(0,S.useState)(!1),Kr=(0,S.useRef)(null),qr=(0,S.useRef)(null),Jr=(0,S.useRef)(null),Yr=(0,S.useRef)(new Set),Y=(0,S.useCallback)((e,t=`info`)=>{let n=++on.current;an(r=>[...r,{id:n,text:e,type:t}]);let r=setTimeout(()=>{Yr.current.delete(r),an(e=>e.filter(e=>e.id!==n))},4e3);Yr.current.add(r)},[]);(0,S.useEffect)(()=>{let e=Yr.current;return()=>{e.forEach(e=>clearTimeout(e)),Kr.current&&clearTimeout(Kr.current),Cn.current&&clearTimeout(Cn.current)}},[]),(0,S.useEffect)(()=>{if(!en)return;let e=e=>{qr.current&&!qr.current.contains(e.target)&&A(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[en]),le(!0,()=>{zn?W(null):Pn?Fn(!1):Ln?Rn(!1):F?wn(null):en?A(!1):Tn||I?(En(!1),Dn(null)):tn?nn(null):n(!1)}),Le(Jr,!!zn),(0,S.useEffect)(()=>{if(!zn)return;let e=Jr.current;if(!e)return;let t=document.activeElement;return e.focus(),()=>{t?.focus()}},[zn]);let Xr=(0,S.useCallback)(async()=>{try{let e=await Fe();if(!e)throw new ue;return Kt.current=e,Ut(e),Gt(null),e}catch(e){return i.system.error(`Could not tell which agent’s memory to show`,e),Kt.current=null,Ut(null),Gt({unknown:e instanceof ue,text:O(e)}),null}},[]),Zr=(0,S.useCallback)(async()=>{try{let e=await Je();dt(e)}catch(e){i.system.warn(`Failed to load memory stats`,e)}},[]),Qr=(0,S.useCallback)(async()=>{try{let e=await je(Mr);mt(e)}catch(e){i.system.warn(`Failed to load memory activity`,e)}},[Mr]),X=(0,S.useCallback)(async()=>{try{let e=await ee({category:j.length>0?j:void 0,context:cn||void 0,entity:un||void 0,search:fn||void 0,sort_by:M,order:hn,offset:N,limit:15,include_sensitive:!0,include_superseded:_n});gt(e)}catch(e){i.system.warn(`Failed to load knowledge`,e)}},[j,cn,un,fn,M,hn,N,_n]),$r=(0,S.useCallback)(async()=>{try{let e=await Te();vt(e)}catch(e){i.system.warn(`Failed to load tool summary`,e)}},[]),ei=(0,S.useCallback)(async()=>{try{let e=await Ze(20);bt(e)}catch(e){i.system.warn(`Failed to load conversations`,e)}},[]),ti=(0,S.useCallback)(async()=>{try{let e=await Ue(7);Ct(e)}catch(e){i.system.warn(`Failed to load upcoming items`,e)}},[]),ni=(0,S.useCallback)(async()=>{try{let e=await ye();Bt(e)}catch(e){i.system.warn(`Failed to load embedding coverage`,e)}},[]),ri=(0,S.useCallback)(async()=>{try{let e=await v();Ht(e||[])}catch(e){i.system.warn(`Failed to load entities`,e)}},[]),ii=(0,S.useCallback)(async()=>{try{let e=await Ve();jn(e.mcp_memory_enabled),kn(e.memory_enabled),Nn(e.system_discovery_consent)}catch(e){i.system.warn(`Failed to load memory settings`,e)}},[]),Z=(0,S.useCallback)(async()=>{Jn(!0),Xe.getState().check();try{let[e,t]=await Promise.all([Ye(),pe()]);Wn(e.goals),Kn(t),Qn(null)}catch(e){i.system.warn(`Failed to load goals`,e),Qn(O(e))}finally{Jn(!1)}},[]),ai=(0,S.useCallback)(async(n,r)=>{try{await n()}catch(n){i.system.error(`Goal action failed (${r})`,n),Y(e(`mem.goals.failed`,{what:t(r),error:O(n)}),`error`);return}Z()},[Z,Y,e]),oi=(0,S.useCallback)(async()=>{if(K.title.trim()){er(null);try{await ve(K)}catch(n){i.system.error(`Goal create failed`,n),er(e(`mem.goals.failed`,{what:t(`mem.goals.createFailed`),error:O(n)}));return}lr({title:``,description:``,priority:`medium`}),cr(!1),Z()}},[K,Z,e]);(0,S.useEffect)(()=>{Yn||er(null)},[Yn]);let si=(0,S.useCallback)(async()=>{nr(!0);try{let{kept:t}=await Ne();Y(e(`mem.goals.newListStarted`,{file:t}),`success`)}catch(n){i.system.error(`Starting a new goal list failed`,n),Y(e(`mem.goals.failed`,{what:t(`mem.goals.startNewListFailed`),error:O(n)}),`error`)}finally{nr(!1)}Z()},[Z,Y,e]);(0,S.useEffect)(()=>{if(!ar)return;let e=setTimeout(()=>or(null),3e3);return()=>clearTimeout(e)},[ar]);let Q=(0,S.useCallback)(async()=>{Yt(!0),Zt(!1);let e=()=>{dt(null),mt([]),gt(null),vt([]),bt([]),Ct([]),Bt(null),Ht([]),Sn(null),wn(null),A(!1)},t=()=>{Wn([]),Kn(null),Qn(null)};try{let n=await Xr();if(!n){e(),t();return}n.supports.advanced||e(),n.supports.goals||t(),await Promise.all([ii(),...n.supports.advanced?[Zr(),Qr(),X(),$r(),ei(),ti(),ni(),ri()]:[],...n.supports.goals?[Z()]:[]]),Hn(e=>e+1)}catch(e){Zt(!0),i.system.error(`Memory dashboard load failed`,e)}finally{Yt(!1)}},[Xr,Zr,Qr,X,$r,ei,ti,ni,ri,ii,Z]);(0,S.useEffect)(()=>{Q()},[Q]);let ci=(0,S.useRef)(!1);(0,S.useEffect)(()=>{let e=ci.current&&!it;if(ci.current=it,!e)return;let t=!0;return(async()=>{let e=null;try{e=(await Fe())?.agent??null}catch(e){i.system.warn(`Could not re-check which agent’s memory to show`,e)}t&&e!==Kt.current?.agent&&Q()})(),()=>{t=!1}},[it,Q]),(0,S.useEffect)(()=>{Kt.current?.supports.advanced&&X()},[X]);let li=(0,S.useRef)(!0);(0,S.useEffect)(()=>{li.current?li.current=!1:Kt.current?.supports.advanced&&Qr()},[Qr]);let ui=(0,S.useCallback)(e=>{pn(e),Gr(!0),Kr.current&&clearTimeout(Kr.current),Kr.current=setTimeout(()=>{P(0),Gr(!1)},300)},[]),di=(0,S.useCallback)(()=>{Kt.current?.supports.advanced&&(X(),Zr(),ni(),ti(),ri())},[X,Zr,ni,ti,ri]),$=(0,S.useCallback)(()=>{di(),Hn(e=>e+1)},[di]),fi=(0,S.useCallback)(async()=>{if(L.content.trim())try{let t=await re({content:L.content,category:L.category,domain:L.domain||void 0,context:L.context,entity:L.entity||void 0,sensitive:L.sensitive,due_at:L.due_at||void 0});En(!1),R({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),$(),i.ui.info(`Created new knowledge entry`),t?.embedded===!1?Y(t.embed_error?e(`mem.toast.server`,{message:t.embed_error}):e(`mem.toast.notEmbedded`),`error`):Y(e(`mem.toast.created`),`success`)}catch(t){i.system.error(`Failed to create knowledge`,t),Y(e(`mem.toast.createFailed`,{error:O(t)}),`error`)}},[L,$,Y,e]),pi=(0,S.useCallback)(async()=>{if(I&&L.content.trim())try{let t=await oe(I,{content:L.content,category:L.category,domain:L.domain||void 0,context:L.context,entity:L.entity||void 0,sensitive:L.sensitive,due_at:L.due_at||void 0});Dn(null),R({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),$(),i.ui.info(`Updated knowledge ${I}`),t?.embedded===!1?Y(t.embed_error?e(`mem.toast.server`,{message:t.embed_error}):e(`mem.toast.notEmbedded`),`error`):Y(e(`mem.toast.updated`),`success`)}catch(t){i.system.error(`Failed to update knowledge`,t),Y(e(`mem.toast.updateFailed`,{error:O(t)}),`error`)}},[I,L,$,Y,e]),mi=(0,S.useCallback)(async t=>{if(U!==t)In(t);else{In(null);try{await Ke(t),$(),i.ui.info(`Deleted knowledge ${t}`),Y(e(`mem.toast.deleted`),`info`)}catch(t){i.system.error(`Failed to delete knowledge`,t),Y(e(`mem.toast.deleteFailed`,{error:O(t)}),`error`)}}},[U,$,Y,e]);(0,S.useEffect)(()=>{if(!U)return;let e=setTimeout(()=>In(null),3e3);return()=>clearTimeout(e)},[U]);let hi=(0,S.useCallback)(async t=>{try{await oe(t.id,{sensitive:!t.sensitive}),!t.sensitive&&I===t.id&&!z.has(t.id)&&(Dn(null),R(e=>({...e,content:``}))),X(),i.ui.info(`Toggled sensitive for ${t.id}: ${!t.sensitive}`),Y(e(t.sensitive?`mem.toast.unmarkedSensitive`:`mem.toast.markedSensitive`),`info`)}catch(t){i.system.error(`Failed to toggle sensitive`,t),Y(e(`mem.toast.sensitiveFailed`,{error:O(t)}),`error`)}},[X,Y,e,I,z]),gi=(0,S.useCallback)(e=>{(!e.sensitive||z.has(e.id))&&(Dn(e.id),En(!1),R({content:e.content,category:e.category,domain:e.domain||``,context:e.context,entity:e.entity||``,sensitive:e.sensitive,due_at:e.due_at||``}))},[z]),_i=(0,S.useCallback)(e=>{let t=z.has(e.id);On(n=>{let r=new Set(n);return t?r.delete(e.id):r.add(e.id),r}),t&&I===e.id&&(Dn(null),R(e=>({...e,content:``})))},[z,I]),vi=(0,S.useCallback)(t=>{navigator.clipboard.writeText(t).then(()=>Y(e(`mem.toast.idCopied`),`info`),n=>{i.ui.warn(`Couldn't copy knowledge ID ${t}`,n),Y(e(`mem.toast.copyFailed`,{error:O(n)}),`error`)})},[Y,e]),yi=(0,S.useCallback)(e=>{bn(e),Cn.current&&clearTimeout(Cn.current),e.trim()?Cn.current=setTimeout(async()=>{try{let t=await $e(e.trim(),20);Sn(t)}catch(e){i.system.warn(`Conversation search failed`,e)}},300):Sn(null)},[]),bi=(0,S.useCallback)(async e=>{try{let t=await be(e);wn({sessionId:e,turns:t})}catch(e){i.system.error(`Failed to load conversation detail`,e)}},[]),xi=(0,S.useCallback)(e=>{sn(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),P(0)},[]),Si=(0,S.useCallback)(e=>{M===e?gn(e=>e===`desc`?`asc`:`desc`):(mn(e),gn(`desc`)),P(0)},[M]),Ci=(0,S.useCallback)(async()=>{Fr(!0),A(!1);try{let t=await ge();await Q(),Y(e(`mem.toast.consolidated`,{sessions:t.consolidated??0,items:t.extracted_items??0}),`success`)}catch(t){i.system.error(`Failed to consolidate sessions`,t),Y(e(`mem.toast.consolidateFailed`,{error:O(t)}),`error`)}finally{Fr(!1)}},[Q,Y,e]),wi=(0,S.useCallback)(async()=>{Lr(!0),A(!1);try{let t=await Qe();await ni(),Y(t.total_without?e(`mem.toast.backfilledMissing`,{n:t.backfilled??0,missing:t.total_without}):e(`mem.toast.backfilled`,{n:t.backfilled??0}),`success`)}catch(t){i.system.error(`Failed to rebuild embeddings`,t),Y(e(`mem.toast.rebuildFailed`,{error:O(t)}),`error`)}finally{Lr(!1)}},[ni,Y,e]),Ti=(0,S.useCallback)(async()=>{zr(!0),A(!1);try{let t=await Me();await Q(),Y(e(`mem.toast.reconciled`,{pairs:t.pairs_checked??0,reinforced:t.reinforced??0,contradicted:t.contradicted??0}),`success`)}catch(t){i.system.error(`Failed to reconcile memory`,t),Y(e(`mem.toast.reconcileFailed`,{error:O(t)}),`error`)}finally{zr(!1)}},[Q,Y,e]),Ei=(0,S.useCallback)(async()=>{Vr(!0),A(!1);try{await Ae(),await Q(),Y(e(`mem.toast.ftsRebuilt`),`success`)}catch(t){i.system.error(`Failed to rebuild FTS index`,t),Y(e(`mem.toast.ftsFailed`,{error:O(t)}),`error`)}finally{Vr(!1)}},[Q,Y,e]),Di=(0,S.useCallback)(async()=>{Ur(!0),A(!1);try{let t=await Ge();await Q(),t.skipped?Y(e(`mem.toast.systemDisabled`),`error`):Y(e(`mem.toast.systemRefreshed`,{n:t.stored}),`success`)}catch(t){i.system.error(`Failed to refresh system context`,t),Y(e(`mem.toast.systemFailed`,{error:O(t)}),`error`)}finally{Ur(!1)}},[Q,Y,e]),Oi=Pr||Ir||Rr||Br||Hr,ki=(0,S.useCallback)(()=>{ur(`running`),fr([]),mr([]),vr(new Set),gr(null);let t=Oe();br.current=t,t.onmessage=n=>{try{let r=JSON.parse(n.data);if(r.type===`log`)fr(e=>[...e,{text:r.message,kind:`log`,server:!0}]);else if(r.type===`finding`){let t=r.item,n=t.sensitive?e(`mem.log.foundSensitive`):e.bare(`mem.log.found`,{content:t.content});fr(e=>[...e,{text:n,kind:`finding`}]),mr(e=>[...e,{...t,_checked:!0}])}else r.type===`error`?fr(t=>[...t,{text:e.bare(`mem.log.error`,{message:r.message}),kind:`error`}]):r.type===`done`&&(t.close(),br.current=null,fr(t=>[...t,{text:e(`mem.log.discoveryDone`,{n:r.total??0}),kind:`log`}]),ur(`review`))}catch(t){i.system.warn(`Unreadable discovery event`,t),fr(t=>[...t,{text:e(`mem.log.parseFailed`),kind:`error`}])}},t.onerror=()=>{t.close(),br.current=null,fr(t=>[...t,{text:e(`mem.log.discoveryConnection`),kind:`error`}]),mr(e=>(ur(e.length>0?`review`:`idle`),e))}},[e]),Ai=(0,S.useCallback)(async()=>{let t=pr.filter(e=>e._checked);if(t.length!==0){ur(`saving`);try{let n=t.map(({_checked:e,...t})=>t),r=await _e(n);gr(r.stored),ur(`done`),$(),Y(e(`mem.disc.saved`,{n:r.stored}),`success`)}catch(t){i.system.error(`Failed to commit discovery items`,t),Y(e(`mem.disc.saveFailed`,{error:O(t)}),`error`),ur(`review`)}}},[pr,$,Y,e]),ji=(0,S.useCallback)(()=>{xr(`running`),Cr([]),Tr([]),Dr(null);let t=Re(Or);jr.current=t,t.onmessage=n=>{try{let r=JSON.parse(n.data);if(r.type===`log`)Cr(e=>[...e,{text:r.message,kind:`log`,server:!0}]);else if(r.type===`insight`){let t=r.item;Cr(n=>[...n,{text:e.bare(`mem.log.insight`,{content:t.content}),kind:`finding`}]),Tr(e=>[...e,{...t,_checked:!0}])}else r.type===`error`?Cr(t=>[...t,{text:e.bare(`mem.log.error`,{message:r.message}),kind:`error`}]):r.type===`done`&&(t.close(),jr.current=null,Cr(t=>[...t,{text:e(`mem.log.inferenceDone`,{n:r.total??0}),kind:`log`}]),xr(`review`))}catch(t){i.system.warn(`Unreadable inference event`,t),Cr(t=>[...t,{text:e(`mem.log.parseFailed`),kind:`error`}])}},t.onerror=()=>{t.close(),jr.current=null,Cr(t=>[...t,{text:e(`mem.log.inferenceConnection`),kind:`error`}]),Tr(e=>(xr(e.length>0?`review`:`idle`),e))}},[Or,e]),Mi=(0,S.useCallback)(async()=>{let t=wr.filter(e=>e._checked);if(t.length!==0){xr(`saving`);try{let n=t.map(({_checked:e,...t})=>t),r=await ie(n);Dr(r.stored),xr(`done`),$(),Y(e(`mem.inf.saved`,{n:r.stored}),`success`)}catch(t){i.system.error(`Failed to commit inference insights`,t),Y(e(`mem.inf.saveFailed`,{error:O(t)}),`error`),xr(`review`)}}},[wr,$,Y,e]);(0,S.useEffect)(()=>{yr.current&&(yr.current.scrollTop=yr.current.scrollHeight)},[dr]),(0,S.useEffect)(()=>{Ar.current&&(Ar.current.scrollTop=Ar.current.scrollHeight)},[Sr]),(0,S.useEffect)(()=>()=>{br.current&&=(br.current.close(),null),jr.current&&=(jr.current.close(),null)},[]);let Ni=e=>M===e?u(`span`,{className:`mem-sort-arrow`,children:hn===`desc`?`↓`:`↑`}):null,Pi=Math.max(1,...x.map(e=>e.conversations+e.tool_calls+e.knowledge_added+e.errors)),Fi=b?.knowledge?.by_context?Object.keys(b.knowledge.by_context):[];return o(`div`,{className:`memory-dashboard-page`,children:[o(`div`,{className:`memory-dashboard-header`,children:[o(`div`,{className:`memory-dashboard-header-left`,children:[u(`button`,{className:`btn-icon settings-back-btn`,onClick:()=>n(!1),"aria-label":e(`mem.back`),children:u(_,{size:18})}),o(`h1`,{children:[e(`mem.title`),` `,u(`span`,{className:`mem-beta`,style:{fontSize:11,fontWeight:500,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`2px 8px`,borderRadius:4,marginInlineStart:8,verticalAlign:`middle`,whiteSpace:`nowrap`},children:e(`mem.beta`)})]})]}),o(`div`,{className:`memory-dashboard-header-actions`,children:[G===`advanced`&&qt&&o(c.Fragment,{children:[w&&w.total_items>0&&o(`div`,{className:`mem-embedding-coverage`,title:e(`mem.coverage.title`,{n:w.with_embedding,total:w.total_items}),children:[u(`div`,{className:`mem-embedding-bar`,children:u(`div`,{className:`mem-embedding-fill`,style:{width:`${Math.round(w.coverage_pct)}%`}})}),u(`span`,{className:`mem-embedding-label`,children:e(`mem.coverage.label`,{pct:`${Math.round(w.coverage_pct)}%`})})]}),o(`div`,{className:`mem-maintenance-wrap`,ref:qr,children:[o(`button`,{className:`btn-icon ${Oi?`mem-spinning`:``}`,onClick:()=>A(e=>!e),title:e(`mem.maint.label`),"aria-label":e(`mem.maint.label`),"aria-expanded":en,children:[Oi?u(`div`,{className:`mem-spinner-sm`}):u(et,{size:16}),u(de,{size:10,style:{marginInlineStart:2}})]}),en&&o(`div`,{className:`mem-maintenance-menu`,role:`menu`,children:[o(`button`,{className:`mem-maintenance-item`,onClick:Ci,disabled:Pr,role:`menuitem`,children:[u(at,{size:14}),e(Pr?`mem.maint.consolidating`:`mem.maint.consolidate`)]}),o(`button`,{className:`mem-maintenance-item`,onClick:wi,disabled:Ir,role:`menuitem`,children:[u(qe,{size:14}),e(Ir?`mem.maint.rebuilding`:`mem.maint.rebuildEmbeddings`)]}),o(`button`,{className:`mem-maintenance-item`,onClick:Ti,disabled:Rr,role:`menuitem`,children:[u(h,{size:14}),e(Rr?`mem.maint.reconciling`:`mem.maint.reconcile`)]}),u(`div`,{className:`mem-maintenance-divider`}),o(`button`,{className:`mem-maintenance-item`,onClick:Di,disabled:Hr,role:`menuitem`,children:[u(we,{size:14}),e(Hr?`mem.maint.refreshing`:`mem.maint.refreshSystem`)]}),u(`div`,{className:`mem-maintenance-divider`}),o(`button`,{className:`mem-maintenance-item`,onClick:Ei,disabled:Br,role:`menuitem`,children:[u(Be,{size:14}),e(Br?`mem.maint.rebuilding`:`mem.maint.rebuildFts`)]})]})]})]}),u(`button`,{className:`btn-icon`,onClick:Q,title:e(`mem.refresh`),"aria-label":e(`mem.refreshAria`),children:u(we,{size:16})})]})]}),o(`div`,{className:`mem-tab-bar`,role:`tablist`,children:[o(`button`,{className:`mem-tab-btn${G===`about`?` mem-tab-active`:``}`,onClick:()=>Bn(`about`),role:`tab`,"aria-selected":G===`about`,children:[u(pt,{size:14}),` `,e(`mem.tab.about`)]}),o(`button`,{className:`mem-tab-btn${G===`goals`?` mem-tab-active`:``}`,onClick:()=>{Bn(`goals`),k?.supports.goals&&Z()},role:`tab`,"aria-selected":G===`goals`,children:[u(ut,{size:14}),` `,e(`mem.tab.goals`),k?.supports.goals&&Gn&&(Gn.goals.pending_approval??0)>0&&u(`span`,{className:`mem-tab-badge`,children:Gn.goals.pending_approval})]}),o(`button`,{className:`mem-tab-btn${G===`profile`?` mem-tab-active`:``}`,onClick:()=>Bn(`profile`),role:`tab`,"aria-selected":G===`profile`,children:[u(y,{size:14}),` `,e(`mem.tab.profile`)]}),o(`button`,{className:`mem-tab-btn${G===`advanced`?` mem-tab-active`:``}`,onClick:()=>Bn(`advanced`),role:`tab`,"aria-selected":G===`advanced`,children:[u(rt,{size:14}),` `,e(`mem.tab.advanced`)]})]}),k&&(k.agent===zt||k.other_available)&&o(`p`,{className:`mem-store-banner`,role:`note`,children:[u(`span`,{children:e(k.agent===zt?`mem.store.native`:`mem.store.python`,{name:zt})}),` `,u(`button`,{type:`button`,className:`link-btn`,onClick:()=>Se(`model`),children:e.compose(e=>e(`mem.store.change`,{tab:e(`settings.section.model`)}))})]}),o(`div`,{className:`memory-dashboard-body`,children:[Wt&&o(`div`,{className:`mem-empty`,role:`alert`,children:[u(`div`,{className:`mem-empty-icon`,children:u(g,{size:32})}),u(`p`,{children:Wt.unknown?e(`mem.store.unknown`):e(`mem.store.loadFailed`,{error:Wt.text})}),o(`button`,{className:`btn-secondary`,onClick:Q,style:{marginTop:12},children:[u(we,{size:14}),` `,e(`mem.retry`)]})]}),!k&&!Wt&&o(`div`,{className:`mem-loading`,children:[u(`div`,{className:`mem-spinner`}),e(`mem.loadingData`)]}),k&&o(c.Fragment,{children:[G===`about`&&u(xt,{agent:k.agent,supports:k.supports,memoryEnabled:B,reloadKey:Vn,onChanged:di,onOpenAdvanced:()=>Bn(`advanced`),showToast:Y},k.agent),G===`advanced`&&!qt&&u(`p`,{className:`mem-store-only`,role:`note`,children:e(`mem.store.pythonOnly.advanced`,{name:zt})}),G===`advanced`&&u(c.Fragment,{children:Jt&&!b?o(`div`,{className:`mem-loading`,children:[u(`div`,{className:`mem-spinner`}),e(`mem.loadingData`)]}):Xt?o(`div`,{className:`mem-empty`,children:[u(`div`,{className:`mem-empty-icon`,children:u(g,{size:32})}),u(`p`,{children:e(`mem.loadFailed`)}),o(`button`,{className:`btn-secondary`,onClick:Q,style:{marginTop:12},children:[u(we,{size:14}),` `,e(`mem.retry`)]})]}):o(c.Fragment,{children:[!B&&qt&&o(`div`,{className:`mem-empty-state`,style:{margin:`40px 0`},children:[u(`div`,{className:`mem-empty-icon`,style:{opacity:.5},children:u(lt,{size:32})}),u(`p`,{style:{color:`var(--text-secondary)`,fontSize:14},children:e(`mem.offAdvanced`)})]}),B&&qt&&o(c.Fragment,{children:[b?.embedding_error&&o(`div`,{className:`mem-advanced-error`,role:`alert`,children:[u(g,{size:14}),` `,u(`bdi`,{children:b.embedding_error})]}),o(`div`,{className:`mem-stat-cards`,children:[o(`div`,{className:`mem-stat-card`,children:[u(`div`,{className:`mem-stat-value`,children:b?.knowledge?.total??0}),u(`div`,{className:`mem-stat-label`,children:e(`mem.stat.stored`)}),u(`div`,{className:`mem-stat-sub`,children:(()=>{let n=kt(x);return n>0?e(`mem.stat.addedToday`,{n}):b?.knowledge?.by_category?e.compose(e=>Object.entries(b.knowledge.by_category).slice(0,3).map(([n,r])=>e(`mem.stat.categoryCount`,{category:jt[n]?t(jt[n]):n,n:r})).join(e(`mem.listSeparator`))):e(`mem.stat.noEntries`)})()})]}),o(`div`,{className:`mem-stat-card`,children:[u(`div`,{className:`mem-stat-value`,children:b?.knowledge?.total_retrievals??0}),u(`div`,{className:`mem-stat-label`,children:e(`mem.stat.retrieved`)}),u(`div`,{className:`mem-stat-sub`,children:b?.knowledge?.total&&b?.knowledge?.total_retrievals?e(`mem.stat.avgRecall`,{n:(b.knowledge.total_retrievals/b.knowledge.total).toFixed(1)}):e(`mem.stat.noRecalls`)})]}),o(`div`,{className:`mem-stat-card`,children:[u(`div`,{className:`mem-stat-value`,children:b?.conversations?.total_sessions??0}),u(`div`,{className:`mem-stat-label`,children:e(`mem.stat.sessions`)}),u(`div`,{className:`mem-stat-sub`,children:Ot(b?.conversations?.first_session??null,b?.conversations?.last_session??null,d(e))||e(`mem.stat.totalTurns`,{n:b?.conversations?.total_turns??0})})]}),o(`div`,{className:`mem-stat-card`,children:[u(`div`,{className:`mem-stat-value`,children:b?.tools?.total_calls??0}),u(`div`,{className:`mem-stat-label`,children:e(`mem.stat.toolCalls`)}),u(`div`,{className:`mem-stat-sub`,title:e(`mem.stat.toolsNotLogged`),children:e(`mem.stat.toolsExclMemory`,{n:b?.tools?.unique_tools??0})})]}),o(`div`,{className:`mem-stat-card`,children:[u(`div`,{className:`mem-stat-value`,children:b?.tools?.overall_success_rate!=null&&(b.tools.total_calls??0)>0?`${Math.round(b.tools.overall_success_rate*100)}%`:`—`}),u(`div`,{className:`mem-stat-label`,children:e(`mem.stat.successRate`)}),u(`div`,{className:`mem-stat-sub`,children:(b?.tools?.total_calls??0)>0?e(`mem.stat.errors`,{n:b?.tools?.total_errors??0}):e(`mem.stat.noToolCalls`)})]})]}),o(`div`,{className:`mem-section`,children:[o(`div`,{className:`mem-section-title mem-section-title-row`,children:[o(`span`,{className:`mem-section-title-left`,children:[u(ft,{size:14}),` `,e(`mem.activity.title`)]}),u(`div`,{className:`mem-range-tabs`,role:`group`,"aria-label":e(`mem.activity.range`),children:[1,7,30].map(t=>u(`button`,{className:`mem-range-tab${Mr===t?` active`:``}`,onClick:()=>Nr(t),children:e(t===1?`mem.activity.day1`:t===7?`mem.activity.days7`:`mem.activity.days30`)},t))})]}),x.length>0?o(c.Fragment,{children:[u(`div`,{className:`mem-activity-chart`,children:x.map((t,n)=>{let r=t.conversations+t.tool_calls+t.knowledge_added+t.errors,i=n===0||n===x.length-1||n%7==0,a=new Date(t.date+`T00:00:00`).toLocaleDateString(d(e),{month:`short`,day:`numeric`});return o(`div`,{className:`mem-activity-bar-group`,onMouseEnter:()=>$t(n),onMouseLeave:()=>$t(null),children:[t.errors>0&&u(`div`,{className:`mem-activity-bar errors`,style:{height:`${t.errors/Pi*100}%`}}),t.knowledge_added>0&&u(`div`,{className:`mem-activity-bar knowledge`,style:{height:`${t.knowledge_added/Pi*100}%`}}),t.tool_calls>0&&u(`div`,{className:`mem-activity-bar tool_calls`,style:{height:`${t.tool_calls/Pi*100}%`}}),t.conversations>0&&u(`div`,{className:`mem-activity-bar conversations`,style:{height:`${t.conversations/Pi*100}%`}}),i&&u(`span`,{className:`mem-activity-date-label`,children:a}),Qt===n&&r>0&&o(`div`,{className:`mem-activity-tooltip`,children:[u(`strong`,{children:a}),u(`br`,{}),t.conversations>0&&o(c.Fragment,{children:[e(`mem.activity.conversations`,{n:t.conversations}),u(`br`,{})]}),t.tool_calls>0&&o(c.Fragment,{children:[e(`mem.activity.toolCalls`,{n:t.tool_calls}),u(`br`,{})]}),t.knowledge_added>0&&o(c.Fragment,{children:[e(`mem.activity.learned`,{n:t.knowledge_added}),u(`br`,{})]}),t.errors>0&&u(c.Fragment,{children:e(`mem.stat.errors`,{n:t.errors})})]})]},t.date)})}),o(`div`,{className:`mem-activity-legend`,children:[o(`span`,{className:`mem-activity-legend-item`,children:[u(`span`,{className:`mem-activity-legend-dot conversations`}),` `,e(`mem.legend.conversations`)]}),o(`span`,{className:`mem-activity-legend-item`,children:[u(`span`,{className:`mem-activity-legend-dot tool_calls`}),` `,e(`mem.stat.toolCalls`)]}),o(`span`,{className:`mem-activity-legend-item`,children:[u(`span`,{className:`mem-activity-legend-dot knowledge`}),` `,e(`mem.legend.knowledge`)]}),o(`span`,{className:`mem-activity-legend-item`,children:[u(`span`,{className:`mem-activity-legend-dot errors`}),` `,e(`mem.legend.errors`)]})]})]}):o(`div`,{className:`mem-empty`,children:[u(`div`,{className:`mem-empty-icon`,children:u(ft,{size:28})}),u(`p`,{children:e(`mem.activity.empty`)})]})]}),o(`div`,{className:`mem-section`,children:[o(`div`,{className:`mem-section-title mem-section-title-row`,children:[o(`span`,{className:`mem-section-title-left`,children:[u(rt,{size:14}),` `,e(`mem.knowledge.title`),C&&C.total>0&&u(`span`,{className:`mem-section-count`,children:C.total})]}),!Tn&&!I&&o(`button`,{className:`mem-section-add-btn`,onClick:()=>En(!0),title:e(`mem.knowledge.addTitle`),children:[u(He,{size:13}),` `,e(`mem.knowledge.add`)]})]}),o(`div`,{className:`mem-filters`,children:[o(`div`,{className:`mem-category-pills`,role:`group`,"aria-label":e(`mem.knowledge.filterCategory`),children:[At.map(t=>u(`button`,{className:`mem-category-pill ${t}${j.includes(t)?` active`:``}`,onClick:()=>xi(t),"aria-pressed":j.includes(t),children:e(jt[t])},t)),j.length>0&&o(`button`,{className:`mem-category-pill clear`,onClick:()=>{sn([]),P(0)},"aria-label":e(`mem.knowledge.clearAria`),children:[`✕ `,e(`mem.knowledge.clear`)]})]}),o(`select`,{className:`mem-filter-select`,value:cn,onChange:e=>{ln(e.target.value),P(0)},"aria-label":e(`mem.knowledge.filterContext`),children:[u(`option`,{value:``,children:e.bare(`mem.knowledge.allContexts`)}),Fi.map(t=>u(`option`,{value:t,children:Lt[t]?e.bare(Lt[t]):t},t))]}),o(`select`,{className:`mem-filter-select`,value:un,onChange:e=>{dn(e.target.value),P(0)},"aria-label":e(`mem.knowledge.filterEntity`),children:[u(`option`,{value:``,children:e.bare(`mem.knowledge.allEntities`)}),Vt.map(e=>o(`option`,{value:e.entity,children:[e.entity,` (`,e.count,`)`]},e.entity))]}),o(`div`,{className:`mem-filter-search-wrap`,children:[Wr?u(`div`,{className:`mem-spinner-sm search-icon`,style:{width:12,height:12,borderWidth:1.5}}):u(Be,{size:13,className:`search-icon`}),u(`input`,{className:`mem-filter-search`,type:`text`,placeholder:e.bare(`mem.knowledge.searchPlaceholder`),value:fn,onChange:e=>ui(e.target.value),"aria-label":e(`mem.knowledge.search`)})]}),o(`label`,{className:`mem-filter-toggle`,title:e(`mem.knowledge.supersededTitle`),children:[u(`input`,{type:`checkbox`,checked:_n,onChange:e=>vn(e.target.checked)}),u(`span`,{children:e(`mem.knowledge.superseded`)})]})]}),(Tn||I)&&o(`div`,{className:`mem-inline-form`,children:[o(`div`,{className:`mem-inline-form-row`,children:[u(`label`,{children:e(`mem.col.content`)}),u(`textarea`,{value:L.content,onChange:e=>R(t=>({...t,content:e.target.value})),placeholder:e(`mem.form.contentPlaceholder`)})]}),o(`div`,{className:`mem-inline-form-row`,children:[u(`label`,{children:e(`mem.col.category`)}),u(`select`,{value:L.category,onChange:e=>R(t=>({...t,category:e.target.value})),children:At.map(t=>u(`option`,{value:t,children:e.bare(jt[t])},t))})]}),o(`div`,{className:`mem-inline-form-row`,children:[u(`label`,{children:e(`mem.col.context`)}),u(`input`,{type:`text`,value:L.context,onChange:e=>R(t=>({...t,context:e.target.value})),placeholder:`global`})]}),o(`div`,{className:`mem-inline-form-row`,children:[u(`label`,{children:e(`mem.detail.domain`)}),u(`input`,{type:`text`,value:L.domain,onChange:e=>R(t=>({...t,domain:e.target.value})),placeholder:e(`mem.form.domainPlaceholder`)})]}),o(`div`,{className:`mem-inline-form-row`,children:[u(`label`,{children:e(`mem.col.entity`)}),u(`input`,{type:`text`,value:L.entity,onChange:e=>R(t=>({...t,entity:e.target.value})),placeholder:e(`mem.form.entityPlaceholder`)})]}),o(`div`,{className:`mem-inline-form-row`,children:[u(`label`,{children:e(`mem.form.dueAt`)}),u(`input`,{type:`text`,value:L.due_at,onChange:e=>R(t=>({...t,due_at:e.target.value})),placeholder:e(`mem.form.dueAtPlaceholder`)})]}),o(`div`,{className:`mem-inline-form-row`,children:[u(`label`,{children:e(`mem.form.sensitive`)}),o(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontSize:12},children:[u(`input`,{type:`checkbox`,checked:L.sensitive,onChange:e=>R(t=>({...t,sensitive:e.target.checked}))}),e(`mem.form.sensitiveHint`)]})]}),o(`div`,{className:`mem-inline-form-actions`,children:[u(`button`,{className:`btn-secondary`,onClick:()=>{En(!1),Dn(null)},children:e(`mem.cancel`)}),u(`button`,{className:`btn-primary`,onClick:I?pi:fi,style:{padding:`8px 20px`,fontSize:13},children:e(I?`mem.form.update`:`mem.form.save`)})]})]}),C&&C.items.length>0?o(c.Fragment,{children:[u(`div`,{style:{overflowX:`auto`},children:o(`table`,{className:`mem-knowledge-table`,children:[u(`thead`,{children:o(`tr`,{children:[o(`th`,{onClick:()=>Si(`category`),className:M===`category`?`sorted`:``,children:[e(`mem.col.category`),Ni(`category`)]}),u(`th`,{children:e(`mem.col.content`)}),o(`th`,{onClick:()=>Si(`context`),className:M===`context`?`sorted`:``,children:[e(`mem.col.context`),Ni(`context`)]}),u(`th`,{children:e(`mem.col.entity`)}),o(`th`,{onClick:()=>Si(`confidence`),className:M===`confidence`?`sorted`:``,children:[e(`mem.col.confidence`),Ni(`confidence`)]}),u(`th`,{children:e(`mem.col.source`)}),o(`th`,{onClick:()=>Si(`updated_at`),className:M===`updated_at`?`sorted`:``,children:[e(`mem.col.updated`),Ni(`updated_at`)]}),o(`th`,{onClick:()=>Si(`created_at`),className:M===`created_at`?`sorted`:``,children:[e(`mem.col.created`),Ni(`created_at`)]}),u(`th`,{children:e(`mem.col.due`)}),u(`th`,{className:`mem-actions-cell`})]})}),u(`tbody`,{children:C.items.map(t=>{let n=tn===t.id,r=t.has_embedding,i=t.sensitive&&!z.has(t.id),a=o(`button`,{type:`button`,className:`mem-about-link`,onClick:e=>{e.stopPropagation(),_i(t)},onKeyDown:e=>e.stopPropagation(),children:[u(Ee,{size:12}),` `,e(`mem.about.showSensitive`)]});return o(S.Fragment,{children:[o(`tr`,{className:`${t.superseded_by?`mem-superseded-row`:``} ${n?`mem-expanded-row`:``}`,onClick:()=>nn(n?null:t.id),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),nn(n?null:t.id))},tabIndex:0,role:`row`,"aria-expanded":n,style:{cursor:`pointer`},children:[u(`td`,{children:u(`span`,{className:`mem-cat-badge ${t.category}`,children:t.category===`error`&&t.source===`error_auto`?e(`mem.cat.errorLearned`):u(D,{value:t.category,keys:jt})})}),u(`td`,{children:o(`div`,{className:`mem-content-cell`,title:i?void 0:t.content,children:[r!==void 0&&u(`span`,{className:`mem-embed-dot ${r?`embedded`:`missing`}`,title:e(r?`mem.knowledge.embedded`:`mem.knowledge.embedMissing`),children:u(Ie,{size:6,fill:`currentColor`})}),t.sensitive&&u(`span`,{className:`mem-sensitive-badge`,title:e(`mem.form.sensitive`),children:u(lt,{size:11})}),i?a:u(`span`,{className:t.superseded_by?`mem-superseded-text`:``,onClick:e=>{t.sensitive&&(e.stopPropagation(),_i(t))},children:u(`bdi`,{children:t.content})})]})}),u(`td`,{children:u(`span`,{className:`mem-date-cell`,children:u(D,{value:t.context,keys:Lt})})}),u(`td`,{children:t.entity?u(`span`,{className:`mem-entity-link`,onClick:e=>{e.stopPropagation(),dn(t.entity),P(0)},title:e(`mem.knowledge.filterBy`,{entity:t.entity}),children:u(`bdi`,{children:t.entity})}):u(`span`,{className:`mem-date-cell`,children:`—`})}),u(`td`,{children:o(`div`,{className:`mem-confidence`,children:[u(`div`,{className:`mem-confidence-bar`,children:u(`div`,{className:`mem-confidence-fill ${Et(t.confidence)}`,style:{width:`${t.confidence*100}%`}})}),t.confidence.toFixed(2)]})}),u(`td`,{children:u(`span`,{className:`mem-date-cell`,children:t.source?u(D,{value:t.source,keys:ht}):`—`})}),u(`td`,{children:u(`span`,{className:`mem-date-cell`,title:T(t.updated_at,d(e)),children:E(t.updated_at,e)})}),u(`td`,{children:u(`span`,{className:`mem-date-cell`,title:T(t.created_at,d(e)),children:E(t.created_at,e)})}),u(`td`,{children:t.due_at?u(`span`,{className:`mem-due-badge ${Tt(t.due_at)?`overdue`:`upcoming`}`,title:T(t.due_at,d(e)),children:E(t.due_at,e)}):u(`span`,{className:`mem-due-badge none`,children:`—`})}),u(`td`,{className:`mem-actions-cell`,children:o(`div`,{className:`mem-row-actions`,onClick:e=>e.stopPropagation(),children:[u(`button`,{className:`mem-row-action-btn`,onClick:()=>gi(t),disabled:i,title:e(i?`mem.about.editHidden`:`mem.row.edit`),children:u(De,{size:13})}),u(`button`,{className:`mem-row-action-btn`,onClick:()=>hi(t),title:e(t.sensitive?`mem.row.unmarkSensitive`:`mem.row.markSensitive`),children:t.sensitive?u(st,{size:13}):u(lt,{size:13})}),u(`button`,{className:`mem-row-action-btn`,onClick:()=>vi(t.id),title:e(`mem.row.copyId`),children:u(ne,{size:13})}),u(`button`,{className:`mem-row-action-btn delete${U===t.id?` is-confirm`:``}`,onClick:()=>mi(t.id),title:e(U===t.id?`mem.row.clickAgain`:`mem.row.delete`),"aria-label":e(U===t.id?`mem.row.confirmDeleteAria`:`mem.row.deleteAria`),children:U===t.id?u(`span`,{className:`mem-row-delete-label`,children:e(`mem.row.deleteConfirm`)}):u(te,{size:13})})]})})]}),n&&u(`tr`,{className:`mem-detail-row`,children:u(`td`,{colSpan:10,children:o(`div`,{className:`mem-detail-panel`,children:[o(`div`,{className:`mem-detail-grid`,children:[o(`div`,{className:`mem-detail-field`,children:[u(`span`,{className:`mem-detail-label`,children:e(`mem.detail.id`)}),u(`span`,{className:`mem-detail-value`,children:t.id})]}),o(`div`,{className:`mem-detail-field`,children:[u(`span`,{className:`mem-detail-label`,children:e(`mem.detail.domain`)}),u(`bdi`,{className:`mem-detail-value`,children:t.domain||`—`})]}),o(`div`,{className:`mem-detail-field`,children:[u(`span`,{className:`mem-detail-label`,children:e(`mem.col.source`)}),u(`bdi`,{className:`mem-detail-value`,children:t.source||`—`})]}),o(`div`,{className:`mem-detail-field`,children:[u(`span`,{className:`mem-detail-label`,children:e(`mem.detail.useCount`)}),u(`span`,{className:`mem-detail-value`,children:t.use_count??0})]}),o(`div`,{className:`mem-detail-field`,children:[u(`span`,{className:`mem-detail-label`,children:e(`mem.col.created`)}),u(`span`,{className:`mem-detail-value`,children:T(t.created_at,d(e))})]}),o(`div`,{className:`mem-detail-field`,children:[u(`span`,{className:`mem-detail-label`,children:e(`mem.col.updated`)}),u(`span`,{className:`mem-detail-value`,children:T(t.updated_at,d(e))})]}),o(`div`,{className:`mem-detail-field`,children:[u(`span`,{className:`mem-detail-label`,children:e(`mem.detail.lastUsed`)}),u(`span`,{className:`mem-detail-value`,children:T(t.last_used,d(e))})]}),o(`div`,{className:`mem-detail-field`,children:[u(`span`,{className:`mem-detail-label`,children:e(`mem.detail.remindedAt`)}),u(`span`,{className:`mem-detail-value`,children:T(t.reminded_at,d(e))})]}),t.superseded_by&&o(`div`,{className:`mem-detail-field`,children:[u(`span`,{className:`mem-detail-label`,children:e(`mem.detail.supersededBy`)}),u(`span`,{className:`mem-detail-value mem-detail-chain`,children:t.superseded_by})]}),t.metadata&&o(`div`,{className:`mem-detail-field mem-detail-full`,children:[u(`span`,{className:`mem-detail-label`,children:e(`mem.detail.metadata`)}),u(`span`,{className:`mem-detail-value`,children:u(`bdi`,{dir:`ltr`,children:typeof t.metadata==`object`?JSON.stringify(t.metadata,null,2):t.metadata})})]})]}),o(`div`,{className:`mem-detail-content-full`,children:[u(`span`,{className:`mem-detail-label`,children:e(`mem.detail.fullContent`)}),u(`div`,{className:`mem-detail-content-text`,children:i?a:u(`bdi`,{children:t.content})})]})]})})})]},t.id)})})]})}),o(`div`,{className:`mem-pagination`,children:[u(`span`,{children:e(`mem.page.range`,{from:N+1,to:Math.min(N+15,C.total),total:C.total})}),o(`div`,{className:`mem-pagination-btns`,children:[u(`button`,{type:`button`,className:`mem-page-btn`,"aria-label":e(`mem.page.previous`),disabled:N===0,onClick:()=>P(Math.max(0,N-15)),children:u(ae,{size:14})}),u(`button`,{type:`button`,className:`mem-page-btn`,"aria-label":e(`mem.page.next`),disabled:N+15>=C.total,onClick:()=>P(N+15),children:u(m,{size:14})})]})]})]}):o(`div`,{className:`mem-empty`,children:[u(`div`,{className:`mem-empty-icon`,children:u(rt,{size:28})}),u(`p`,{children:e(fn||j.length>0||cn||un?`mem.knowledge.noMatch`:`mem.knowledge.empty`)})]})]}),o(`div`,{className:`mem-two-col`,children:[o(`div`,{className:`mem-section`,children:[o(`div`,{className:`mem-section-title`,children:[u(xe,{size:14}),` `,e(`mem.tools.title`),u(`span`,{className:`mem-section-note`,title:e(`mem.tools.noteTitle`),children:e(`mem.tools.note`)})]}),_t.length>0?u(`div`,{style:{overflowX:`auto`},children:o(`table`,{className:`mem-tool-table`,children:[u(`thead`,{children:o(`tr`,{children:[u(`th`,{children:e(`mem.tools.tool`)}),u(`th`,{children:e(`mem.tools.calls`)}),u(`th`,{children:e(`mem.tools.success`)}),u(`th`,{children:e(`mem.tools.denied`)}),u(`th`,{children:e(`mem.tools.avgTime`)}),u(`th`,{children:e(`mem.detail.lastUsed`)}),u(`th`,{children:e(`mem.tools.lastError`)})]})}),u(`tbody`,{children:_t.map(t=>o(`tr`,{children:[u(`td`,{children:u(`bdi`,{className:`mem-tool-name`,children:t.tool_name})}),u(`td`,{children:t.total_calls}),u(`td`,{children:o(`div`,{className:`mem-confidence`,children:[u(`div`,{className:`mem-confidence-bar`,style:{width:40},children:u(`div`,{className:`mem-confidence-fill ${Dt(t.success_rate)}`,style:{width:`${t.success_rate*100}%`}})}),o(`span`,{className:`mem-success-rate ${Dt(t.success_rate)}`,children:[Math.round(t.success_rate*100),`%`]})]})}),u(`td`,{children:t.denied_count??0}),u(`td`,{children:u(`bdi`,{dir:`ltr`,children:wt(t.avg_duration_ms)})}),u(`td`,{children:u(`span`,{className:`mem-date-cell`,title:T(t.last_used,d(e)),children:E(t.last_used,e)})}),u(`td`,{children:u(`bdi`,{className:`mem-tool-error`,title:t.last_error||``,children:t.last_error||`—`})})]},t.tool_name))})]})}):o(`div`,{className:`mem-empty`,children:[u(`div`,{className:`mem-empty-icon`,children:u(xe,{size:28})}),u(`p`,{children:e(`mem.tools.empty`)})]})]}),o(`div`,{className:`mem-section`,children:[o(`div`,{className:`mem-section-title`,children:[u(fe,{size:14}),` `,e(`mem.upcoming.title`)]}),St.length>0?u(`div`,{className:`mem-temporal-list`,children:St.map(t=>{let n=Tt(t.due_at);return o(`div`,{className:`mem-temporal-item ${n?`overdue`:`upcoming`}`,children:[u(`span`,{className:`mem-temporal-icon`,children:u(n?g:fe,{size:16})}),o(`div`,{className:`mem-temporal-content`,children:[u(`div`,{className:`mem-temporal-text`,children:u(`bdi`,{children:t.content})}),o(`div`,{className:`mem-temporal-date`,children:[e(n?`mem.upcoming.overdue`:`mem.upcoming.due`,{when:E(t.due_at,e)}),t.context!==`global`&&o(c.Fragment,{children:[` `,`·`,` `,u(D,{value:t.context,keys:Lt})]})]})]})]},t.id)})}):o(`div`,{className:`mem-empty`,children:[u(`div`,{className:`mem-empty-icon`,children:u(h,{size:28})}),u(`p`,{children:e(`mem.upcoming.empty`)})]})]})]}),o(`div`,{className:`mem-section`,children:[o(`div`,{className:`mem-section-title`,children:[u(ke,{size:14}),` `,e(`mem.conv.title`)]}),o(`div`,{className:`mem-conv-search`,children:[u(Be,{size:13,className:`search-icon`}),u(`input`,{type:`text`,placeholder:e.bare(`mem.conv.searchPlaceholder`),value:yn,onChange:e=>yi(e.target.value),"aria-label":e(`mem.conv.search`)}),yn&&u(`button`,{className:`mem-search-clear`,onClick:()=>{bn(``),Sn(null)},"aria-label":e(`mem.conv.clearSearch`),children:u(se,{size:12})})]}),xn===null?yt.length>0?u(`div`,{className:`mem-conv-list`,children:yt.map(t=>o(`div`,{className:`mem-conv-item`,onClick:()=>bi(t.session_id),children:[o(`div`,{className:`mem-conv-info`,children:[o(`div`,{className:`mem-conv-session-id`,children:[u(`bdi`,{children:ct(t.session_id)}),t.consolidated&&u(`span`,{className:`mem-consolidated-badge`,title:e(`mem.conv.consolidated`),children:u(at,{size:11})})]}),t.first_message&&u(`div`,{className:`mem-conv-preview`,children:u(`bdi`,{children:t.first_message})})]}),o(`div`,{className:`mem-conv-meta`,children:[u(`span`,{children:e.plural(`mem.conv.turns`,t.turn_count)}),u(`span`,{children:E(t.last_activity,e)})]})]},t.session_id))}):o(`div`,{className:`mem-empty`,children:[u(`div`,{className:`mem-empty-icon`,children:u(ke,{size:28})}),u(`p`,{children:e(`mem.conv.empty`)})]}):xn.length>0?u(`div`,{className:`mem-conv-list`,children:xn.map(t=>o(`div`,{className:`mem-conv-item`,onClick:()=>bi(t.session_id),children:[o(`div`,{className:`mem-conv-info`,children:[o(`div`,{className:`mem-conv-session-id`,children:[u(`span`,{className:`mem-conv-turn-role ${t.role}`,children:u(D,{value:t.role,keys:Ft})}),` `,u(`bdi`,{children:ct(t.session_id)})]}),u(`div`,{className:`mem-conv-preview`,children:u(`bdi`,{children:t.content})})]}),u(`div`,{className:`mem-conv-meta`,children:u(`span`,{children:E(t.timestamp,e)})})]},t.id))}):u(`div`,{className:`mem-empty`,children:u(`p`,{children:e(`mem.conv.noMatch`,{query:yn})})})]}),F&&o(`div`,{className:`mem-conv-detail-overlay`,children:[o(`div`,{className:`mem-conv-detail-header`,children:[u(`h2`,{children:u(`bdi`,{children:ct(F.sessionId)})}),o(`div`,{className:`mem-conv-detail-actions`,children:[ot.has(F.sessionId)&&u(`button`,{className:`btn-secondary`,onClick:()=>l(F.sessionId),children:e(`mem.conv.openChat`)}),u(`button`,{className:`btn-icon`,onClick:()=>wn(null),"aria-label":e(`mem.conv.close`),children:u(se,{size:16})})]})]}),o(`div`,{className:`mem-conv-detail-body`,children:[F.turns.map(t=>o(`div`,{className:`mem-conv-turn`,children:[o(`div`,{className:`mem-conv-turn-header`,children:[u(`div`,{className:`mem-conv-turn-role ${t.role}`,children:u(D,{value:t.role,keys:Ft})}),u(`span`,{className:`mem-conv-turn-time`,title:T(t.timestamp,d(e)),children:E(t.timestamp,e)})]}),u(`div`,{className:`mem-conv-turn-content`,children:u(`bdi`,{children:t.content})})]},t.id)),F.turns.length===0&&u(`div`,{className:`mem-empty`,children:e(`mem.conv.noTurns`)})]})]})]}),o(`div`,{className:`mem-section`,children:[o(`div`,{className:`mem-section-title`,children:[u(lt,{size:14}),` `,e(`mem.settings.title`),` `,u(`span`,{className:`mem-beta`,style:{fontSize:10,fontWeight:500,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`1px 6px`,borderRadius:4,marginInlineStart:6,verticalAlign:`middle`},children:e(`mem.beta`)})]}),o(`div`,{className:`mem-setting-row`,children:[o(`div`,{className:`mem-setting-info`,children:[u(`span`,{className:`mem-setting-label`,children:e(`mem.settings.memory`)}),u(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.memoryDesc`)})]}),u(`button`,{className:`mem-toggle${B?` mem-toggle-on`:``}`,disabled:V,onClick:async()=>{if(!B)W(`memory`);else{H(!0);try{let e=await tt({memory_enabled:!1});kn(e.memory_enabled)}catch(t){i.system.warn(`Failed to disable memory`,t),Y(e(`mem.toast.settingFailed`,{error:O(t)}),`error`)}finally{H(!1)}}},"aria-pressed":B,"aria-label":e(B?`mem.settings.memoryOn`:`mem.settings.memoryOff`),children:u(`span`,{className:`mem-toggle-knob`,"aria-hidden":`true`})})]}),zn&&(()=>{let t={memory:{title:`mem.beta.memory.title`,description:`mem.beta.memory.desc`,bullets:[`mem.beta.memory.local`,`mem.beta.memory.lost`,`mem.beta.memory.disable`],buttonLabel:`mem.beta.memory.confirm`,onConfirm:async()=>{let t=await tt({memory_enabled:!0});kn(t.memory_enabled),Y(e(`mem.toast.memoryEnabled`),`info`)}},mcp:{title:`mem.beta.mcp.title`,description:`mem.beta.mcp.desc`,bullets:[`mem.beta.mcp.read`,`mem.beta.mcp.restart`,`mem.beta.mcp.debug`],buttonLabel:`mem.beta.mcp.confirm`,onConfirm:async()=>{let t=await tt({mcp_memory_enabled:!0});jn(t.mcp_memory_enabled),Y(e(`mem.toast.mcpEnabled`),`info`)}},discovery:{title:`mem.beta.discovery.title`,description:`mem.beta.discovery.desc`,bullets:[`mem.beta.discovery.collects`,`mem.beta.discovery.scans`,`mem.beta.discovery.local`],buttonLabel:`mem.beta.discovery.confirm`,onConfirm:async()=>{let t=await tt({system_discovery_consent:!0});if(Nn(t.system_discovery_consent),t.system_context_error)Y(e(`mem.toast.discoveryScanFailed`,{error:t.system_context_error}),`error`);else{let n=t.system_context_refresh?.stored??0;Y(e(`mem.toast.discoveryEnabled`,{n}),`info`)}Q()}}}[zn];return o(c.Fragment,{children:[u(`div`,{"aria-hidden":`true`,style:{position:`fixed`,inset:0,background:`var(--bg-modal-overlay)`,zIndex:9998,backdropFilter:`blur(4px)`},onClick:()=>W(null)}),o(`div`,{ref:Jr,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`mem-beta-confirm-title`,"aria-describedby":`mem-beta-confirm-desc`,tabIndex:-1,style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,zIndex:9999,background:`var(--bg-card)`,border:`1px solid var(--border)`,borderRadius:12,padding:`28px 32px`,maxWidth:420,width:`90vw`,boxShadow:`var(--shadow-lg)`},children:[o(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,marginBottom:16},children:[u(`span`,{className:`mem-beta`,style:{fontSize:11,fontWeight:500,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`3px 10px`,borderRadius:4},children:e(`mem.beta`)}),u(`h2`,{id:`mem-beta-confirm-title`,style:{fontSize:16,fontWeight:500,color:`var(--text-primary)`},children:e(t.title)})]}),u(`p`,{id:`mem-beta-confirm-desc`,style:{fontSize:13,lineHeight:1.6,color:`var(--text-secondary)`,margin:`0 0 8px`},children:e(t.description)}),u(`ul`,{style:{fontSize:13,lineHeight:1.7,color:`var(--text-secondary)`,margin:`0 0 24px`,paddingInlineStart:20},children:t.bullets.map(t=>u(`li`,{children:e(t)},t))}),o(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[u(`button`,{className:`btn-secondary`,onClick:()=>W(null),style:{padding:`8px 20px`,fontSize:13,borderRadius:6},children:e(`mem.cancel`)}),u(`button`,{disabled:V,onClick:async()=>{H(!0);try{await t.onConfirm()}catch(t){i.system.warn(`Failed to update setting`,t),Y(e(`mem.toast.settingFailed`,{error:O(t)}),`error`)}finally{H(!1),W(null)}},style:{padding:`8px 24px`,fontSize:13,fontWeight:500,borderRadius:6,border:`none`,cursor:`pointer`,background:`var(--accent-fill)`,color:`var(--accent-fill-text)`},children:e(t.buttonLabel)})]})]})]})})(),qt&&o(c.Fragment,{children:[o(`div`,{className:`mem-setting-row`,children:[o(`div`,{className:`mem-setting-info`,children:[u(`span`,{className:`mem-setting-label`,children:e(`mem.settings.mcp`)}),u(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.mcpDesc`)})]}),u(`button`,{className:`mem-toggle${An?` mem-toggle-on`:``}`,disabled:V,onClick:async()=>{if(!An)W(`mcp`);else{H(!0);try{let e=await tt({mcp_memory_enabled:!1});jn(e.mcp_memory_enabled)}catch(t){i.system.warn(`Failed to update memory settings`,t),Y(e(`mem.toast.settingFailed`,{error:O(t)}),`error`)}finally{H(!1)}}},"aria-label":e(`mem.settings.mcpToggle`),"aria-pressed":An,children:u(`span`,{className:`mem-toggle-knob`,"aria-hidden":`true`})})]}),o(`div`,{className:`mem-setting-row`,children:[o(`div`,{className:`mem-setting-info`,children:[u(`span`,{className:`mem-setting-label`,children:e(`mem.settings.discovery`)}),u(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.discoveryDesc`)})]}),u(`button`,{className:`mem-toggle${Mn?` mem-toggle-on`:``}`,disabled:V,onClick:async()=>{if(!Mn)W(`discovery`);else{H(!0);try{let e=await tt({system_discovery_consent:!1});Nn(e.system_discovery_consent)}catch(t){i.system.warn(`Failed to update system discovery setting`,t),Y(e(`mem.toast.settingFailed`,{error:O(t)}),`error`)}finally{H(!1)}}},"aria-label":e(`mem.settings.discoveryToggle`),"aria-pressed":Mn,children:u(`span`,{className:`mem-toggle-knob`,"aria-hidden":`true`})})]}),o(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[o(`div`,{className:`mem-setting-info`,children:[u(`span`,{className:`mem-setting-label`,children:e(`mem.settings.reinit`)}),u(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.reinitDesc`)})]}),Ln?o(`div`,{className:`mem-delete-confirm`,children:[u(`span`,{className:`mem-delete-confirm-label`,children:e(`mem.settings.sure`)}),u(`button`,{className:`mem-btn-danger`,disabled:V,onClick:async()=>{H(!0);try{let t=await ze();t.system_context.error?Y(e(`mem.toast.server`,{message:t.system_context.error}),`error`):Y(e(`mem.toast.reinitialized`,{cleared:t.cleared.knowledge,stored:t.system_context.stored}),`info`),Q()}catch(t){i.system.warn(`Failed to reinitialize memory`,t),Y(e(`mem.toast.reinitFailed`,{error:O(t)}),`error`)}finally{H(!1),Rn(!1)}},children:e(`mem.settings.reinitConfirm`)}),u(`button`,{className:`btn-secondary`,onClick:()=>Rn(!1),style:{padding:`6px 14px`,fontSize:12},children:e(`mem.cancel`)})]}):u(`button`,{className:`mem-btn-danger`,disabled:V,onClick:()=>Rn(!0),children:e(`mem.settings.reinitButton`)})]}),o(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[o(`div`,{className:`mem-setting-info`,children:[u(`span`,{className:`mem-setting-label`,children:e(`mem.settings.deleteAll`)}),u(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.deleteAllDesc`)})]}),Pn?o(`div`,{className:`mem-delete-confirm`,children:[u(`span`,{className:`mem-delete-confirm-label`,children:e(`mem.settings.sure`)}),u(`button`,{className:`mem-btn-danger`,disabled:V,onClick:async()=>{H(!0);try{let t=await f();Y(e(`mem.toast.cleared`,{knowledge:t.knowledge,conversations:t.conversations}),`info`),Q()}catch(t){i.system.warn(`Failed to clear memory`,t),Y(e(`mem.toast.clearFailed`,{error:O(t)}),`error`)}finally{H(!1),Fn(!1)}},children:e(`mem.settings.deleteConfirm`)}),u(`button`,{className:`btn-secondary`,onClick:()=>Fn(!1),style:{padding:`6px 14px`,fontSize:12},children:e(`mem.cancel`)})]}):u(`button`,{className:`mem-btn-danger`,disabled:V,onClick:()=>Fn(!0),children:e(`mem.settings.deleteButton`)})]})]})]}),qt&&b&&o(`div`,{className:`mem-db-footer`,children:[o(`span`,{children:[e(`mem.footer.database`),`: `,u(`bdi`,{dir:`ltr`,children:p(b.db_size_bytes)}),b.knowledge?.avg_confidence!=null&&o(c.Fragment,{children:[` · `,e(`mem.footer.avgConfidence`,{n:b.knowledge.avg_confidence.toFixed(2)})]})]}),o(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[b.knowledge?.entity_count!=null&&b.knowledge.entity_count>0&&u(`span`,{children:e(`mem.footer.entities`,{n:b.knowledge.entity_count})}),b.knowledge?.sensitive_count!=null&&b.knowledge.sensitive_count>0&&o(`span`,{children:[u(lt,{size:10}),` `,e(`mem.footer.sensitive`,{n:b.knowledge.sensitive_count})]})]})]})]})}),G===`profile`&&!k.supports.profile&&u(`p`,{className:`mem-store-only`,role:`note`,children:e(`mem.store.pythonOnly.profile`,{name:zt})}),G===`profile`&&k.supports.profile&&o(`div`,{className:`mem-profile-grid`,children:[u(`p`,{className:`mem-tab-intro`,children:e(`mem.profile.intro`)}),o(`div`,{className:`mem-profile-card`,children:[o(`div`,{className:`mem-profile-card-title`,children:[u(he,{size:16}),` `,e(`mem.disc.title`)]}),u(`p`,{className:`mem-profile-desc`,children:e(`mem.disc.desc`)}),u(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:q===`running`||q===`saving`,onClick:ki,children:q===`running`?o(c.Fragment,{children:[u(`div`,{className:`mem-spinner-sm`}),` `,e(`mem.running`)]}):e(`mem.disc.run`)}),dr.length>0&&u(`div`,{className:`mem-log`,ref:yr,children:dr.map((e,t)=>u(`div`,{className:`mem-log-line ${e.kind}`,children:e.server?u(`bdi`,{children:e.text}):e.text},t))}),(q===`review`||q===`saving`||q===`done`)&&pr.length>0&&o(`div`,{className:`mem-review-section`,children:[u(`div`,{className:`mem-review-header`,children:e(`mem.review.title`)}),u(`div`,{className:`mem-review-list`,children:pr.map((t,n)=>o(`label`,{className:`mem-review-item`,children:[u(`input`,{type:`checkbox`,checked:t._checked,disabled:q===`saving`||q===`done`,onChange:()=>{mr(e=>e.map((e,t)=>t===n?{...e,_checked:!e._checked}:e))}}),t.sensitive&&!_r.has(n)?u(`span`,{className:`mem-review-content`,children:o(`button`,{type:`button`,className:`mem-about-link`,onClick:e=>{e.preventDefault(),vr(e=>new Set(e).add(n))},children:[u(Ee,{size:12}),` `,e(`mem.about.showSensitive`)]})}):u(`bdi`,{className:`mem-review-content`,children:t.content}),u(`span`,{className:`mem-source-badge`,children:t._source_name?u(`bdi`,{children:t._source_name}):u(D,{value:t.category,keys:jt})}),o(`span`,{className:`mem-conf-badge`,children:[Math.round(t.confidence*100),`%`]})]},n))}),o(`div`,{className:`mem-review-actions`,children:[u(`button`,{className:`btn-primary`,disabled:q===`saving`||q===`done`||pr.filter(e=>e._checked).length===0,onClick:Ai,children:q===`saving`?o(c.Fragment,{children:[u(`div`,{className:`mem-spinner-sm`}),` `,e(`mem.saving`)]}):e(`mem.review.saveSelected`,{n:pr.filter(e=>e._checked).length})}),o(`span`,{className:`mem-review-select-links`,children:[u(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>mr(e=>e.map(e=>({...e,_checked:!0}))),children:e(`mem.review.selectAll`)}),` / `,u(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>mr(e=>e.map(e=>({...e,_checked:!1}))),children:e(`mem.review.none`)})]})]})]}),q===`done`&&hr!==null&&o(`div`,{className:`mem-profile-success`,children:[u(h,{size:14}),` `,e(`mem.disc.saved`,{n:hr})]}),q===`review`&&pr.length===0&&u(`div`,{className:`mem-profile-empty`,children:e(`mem.disc.empty`)})]}),o(`div`,{className:`mem-profile-card`,children:[o(`div`,{className:`mem-profile-card-title`,children:[u(y,{size:16}),` `,e(`mem.inf.title`)]}),u(`p`,{className:`mem-profile-desc`,children:e(`mem.inf.desc`)}),u(`p`,{className:`mem-profile-note`,children:e(`mem.inf.note`)}),o(`label`,{className:`mem-profile-checkbox`,children:[u(`input`,{type:`checkbox`,checked:Or,onChange:e=>kr(e.target.checked),disabled:J===`running`||J===`saving`}),e(`mem.inf.browser`)]}),u(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:J===`running`||J===`saving`,onClick:ji,children:J===`running`?o(c.Fragment,{children:[u(`div`,{className:`mem-spinner-sm`}),` `,e(`mem.running`)]}):e(`mem.inf.run`)}),Sr.length>0&&u(`div`,{className:`mem-log`,ref:Ar,children:Sr.map((e,t)=>u(`div`,{className:`mem-log-line ${e.kind}`,children:e.server?u(`bdi`,{children:e.text}):e.text},t))}),(J===`review`||J===`saving`||J===`done`)&&wr.length>0&&o(`div`,{className:`mem-review-section`,children:[u(`div`,{className:`mem-review-header`,children:e(`mem.review.title`)}),u(`div`,{className:`mem-review-list`,children:wr.map((e,t)=>o(`label`,{className:`mem-review-item`,children:[u(`input`,{type:`checkbox`,checked:e._checked,disabled:J===`saving`||J===`done`,onChange:()=>{Tr(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),u(`bdi`,{className:`mem-review-content`,children:e.content}),u(`span`,{className:`mem-domain-badge ${Rt[e.domain]||`gray`}`,children:u(D,{value:e.domain,keys:It})}),o(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),o(`div`,{className:`mem-review-actions`,children:[u(`button`,{className:`btn-primary`,disabled:J===`saving`||J===`done`||wr.filter(e=>e._checked).length===0,onClick:Mi,children:J===`saving`?o(c.Fragment,{children:[u(`div`,{className:`mem-spinner-sm`}),` `,e(`mem.saving`)]}):e(`mem.review.saveSelected`,{n:wr.filter(e=>e._checked).length})}),o(`span`,{className:`mem-review-select-links`,children:[u(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>Tr(e=>e.map(e=>({...e,_checked:!0}))),children:e(`mem.review.selectAll`)}),` / `,u(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>Tr(e=>e.map(e=>({...e,_checked:!1}))),children:e(`mem.review.none`)})]})]})]}),J===`done`&&Er!==null&&o(`div`,{className:`mem-profile-success`,children:[u(h,{size:14}),` `,e(`mem.inf.saved`,{n:Er})]}),J===`review`&&wr.length===0&&u(`div`,{className:`mem-profile-empty`,children:e(`mem.inf.empty`)})]})]}),G===`goals`&&!k.supports.goals&&u(`p`,{className:`mem-store-only`,role:`note`,children:e(`mem.store.pythonOnly.goals`,{name:zt})}),G===`goals`&&k.supports.goals&&o(`div`,{className:`mem-goals-tab`,children:[u(`p`,{className:`mem-tab-intro`,children:e(`mem.goals.intro`,{name:t(`chat.title.goals`)})}),Yn&&(Xn?o(`div`,{className:`mem-advanced-error`,role:`alert`,children:[u(g,{size:14}),` `,e(`mem.goals.storeDamaged`),` `,u(`button`,{type:`button`,className:`link-btn`,disabled:tr,onClick:si,children:e(`mem.goals.startNewList`)})]}):o(`div`,{className:`mem-advanced-error`,role:`alert`,children:[u(g,{size:14}),` `,e(`mem.goals.storeError`),`: `,u(`bdi`,{children:Yn})]})),u(`div`,{className:`mem-goals-stats-row`,children:[`queued`,`in_progress`,`completed`,`failed`].map(t=>o(`div`,{className:`mem-goals-stat-pill mem-goal-status-${t.replace(`_`,`-`)}`,children:[u(`span`,{className:`mem-goals-stat-n`,children:Gn?.goals[t]??0}),u(`span`,{className:`mem-goals-stat-label`,children:e(Mt[t])})]},t))}),Un.filter(e=>e.status===`pending_approval`).length>0&&o(`div`,{className:`mem-goals-approval-banner`,children:[o(`div`,{className:`mem-goals-approval-title`,children:[u(qe,{size:14}),` `,e(`mem.goals.suggested`,{n:Un.filter(e=>e.status===`pending_approval`).length})]}),Un.filter(e=>e.status===`pending_approval`).map(t=>o(`div`,{className:`mem-goals-approval-item`,children:[o(`div`,{className:`mem-goals-approval-text`,children:[u(`strong`,{children:u(`bdi`,{children:t.title})}),u(`bdi`,{children:t.description})]}),o(`div`,{className:`mem-goals-approval-actions`,children:[u(`button`,{className:`btn-danger-sm`,onClick:()=>ai(()=>Pe(t.id),`mem.goals.rejectFailed`),children:e(`mem.goals.reject`)}),u(`button`,{className:`btn-secondary`,onClick:()=>ai(()=>me(t.id),`mem.goals.acceptFailed`),children:e(`mem.goals.accept`)})]})]},t.id))]}),u(`div`,{className:`mem-goals-toolbar`,children:o(`button`,{className:`btn-primary`,onClick:()=>{er(null),cr(e=>!e)},children:[u(He,{size:14}),` `,e(`mem.goals.new`)]})}),sr&&o(`div`,{className:`mem-goals-add-form`,children:[u(`input`,{className:`mem-input`,placeholder:e(`mem.goals.titlePlaceholder`),value:K.title,onChange:e=>lr(t=>({...t,title:e.target.value}))}),u(`textarea`,{className:`mem-input`,placeholder:e(`mem.goals.descPlaceholder`),rows:2,value:K.description,onChange:e=>lr(t=>({...t,description:e.target.value}))}),o(`div`,{className:`mem-goals-form-row`,children:[o(`select`,{className:`mem-select`,value:K.priority,onChange:e=>lr(t=>({...t,priority:e.target.value})),children:[u(`option`,{value:`low`,children:e.bare(`mem.goals.priorityLow`)}),u(`option`,{value:`medium`,children:e.bare(`mem.goals.priorityMedium`)}),u(`option`,{value:`high`,children:e.bare(`mem.goals.priorityHigh`)})]}),u(`button`,{className:`btn-primary`,disabled:!K.title.trim(),onClick:oi,children:e(`mem.goals.create`)}),u(`button`,{className:`btn-secondary`,onClick:()=>{er(null),cr(!1)},children:e(`mem.cancel`)})]}),$n&&u(`p`,{className:`mem-form-error`,role:`alert`,children:u(`bdi`,{children:$n})})]}),qn?o(`div`,{className:`mem-loading`,children:[u(`div`,{className:`mem-spinner`}),` `,e(`mem.goals.loading`)]}):Zn?o(`p`,{className:`mem-form-error`,role:`alert`,children:[e(`mem.goals.loadFailed`),` `,u(`bdi`,{children:Zn})]}):Un.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).length===0?o(`div`,{className:`mem-empty`,children:[u(`div`,{className:`mem-empty-icon`,children:u(ut,{size:32})}),u(`p`,{children:e(`mem.goals.empty`)})]}):u(`div`,{className:`mem-goals-list`,children:Un.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).map(t=>o(`div`,{className:`mem-goal-card mem-goal-status-${t.status.replace(`_`,`-`)}`,children:[o(`div`,{className:`mem-goal-header`,role:`button`,tabIndex:0,"aria-expanded":rr===t.id,onClick:()=>ir(e=>e===t.id?null:t.id),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ir(e=>e===t.id?null:t.id))},children:[o(`div`,{className:`mem-goal-header-left`,children:[u(`span`,{className:`mem-goal-status-dot status-${t.status.replace(`_`,`-`)}`}),u(`bdi`,{className:`mem-goal-title`,children:t.title}),u(`span`,{className:`mem-goal-priority mem-priority-${t.priority}`,children:u(D,{value:t.priority,keys:Nt})}),(t.status===`cancelled`||t.status===`failed`)&&u(`span`,{className:`mem-goal-priority mem-goal-${t.status}-label`,children:e(Mt[t.status])}),t.source!==`user`&&o(`span`,{className:`mem-goal-source-badge`,children:[u(qe,{size:10}),` `,u(D,{value:t.source,keys:Pt})]})]}),o(`div`,{className:`mem-goal-header-right`,children:[o(`span`,{className:`mem-goal-task-count`,children:[u(We,{size:12}),o(`bdi`,{dir:`ltr`,children:[t.tasks.filter(e=>e.status===`completed`).length,`/`,t.tasks.length]})]}),t.status===`queued`&&u(`button`,{className:`mem-goal-action-btn mem-goal-cancel-btn`,onClick:e=>{e.stopPropagation(),ai(()=>nt(t.id),`mem.goals.cancelFailed`)},children:e(`mem.cancel`)}),t.status===`failed`&&u(`button`,{className:`mem-goal-action-btn mem-goal-retry-btn`,onClick:e=>{e.stopPropagation(),ai(()=>Ce(t.id),`mem.goals.retryFailed`)},children:e(`mem.goals.retry`)}),ar===t.id?u(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn mem-goal-delete-confirm`,onClick:e=>{e.stopPropagation(),or(null),ai(()=>ce(t.id),`mem.goals.deleteFailed`)},children:e(`mem.row.deleteConfirm`)}):u(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn`,"aria-label":e(`mem.goals.deleteAria`,{title:t.title}),onClick:e=>{e.stopPropagation(),or(t.id)},children:u(te,{size:12})}),u(de,{size:14,className:rr===t.id?`mem-chevron-open`:``})]})]}),rr===t.id&&o(`div`,{className:`mem-goal-body`,children:[t.description&&u(`p`,{className:`mem-goal-desc`,children:u(`bdi`,{children:t.description})}),t.progress_notes&&u(`p`,{className:`mem-goal-progress`,children:u(`bdi`,{children:t.progress_notes})}),t.tasks.length>0?u(`div`,{className:`mem-task-list`,children:t.tasks.map(e=>o(`div`,{className:`mem-task-row mem-task-status-${e.status}`,children:[u(`span`,{className:`mem-task-dot status-${e.status}`}),u(`bdi`,{className:`mem-task-desc`,children:e.description}),u(`span`,{className:`mem-task-status-label`,children:u(D,{value:e.status,keys:Mt})}),e.result&&u(`bdi`,{className:`mem-task-result`,children:e.result})]},e.id))}):t.status===`queued`||t.status===`in_progress`?u(`p`,{className:`mem-goal-no-tasks`,children:e(`mem.goals.noTasks`)}):null]})]},t.id))})]})]})]}),rn.length>0&&u(`div`,{className:`mem-toast-container`,"aria-live":`polite`,children:rn.map(e=>o(`div`,{className:`mem-toast mem-toast-${e.type}`,role:`status`,children:[e.type===`success`&&u(h,{size:14}),e.type===`error`&&u(g,{size:14}),e.type===`info`&&u(rt,{size:14}),u(`span`,{children:e.text})]},e.id))})]})}export{Bt as MemoryDashboard};