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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
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
+ 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-CoGuFVPI.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-B66oMwwH.js";import{t as ne}from"./SaveError-julafhJc.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 +1 @@
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
+ 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-CoGuFVPI.js";import{f,fn as p}from"./index-B66oMwwH.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 +1 @@
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
+ 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-CoGuFVPI.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-B66oMwwH.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 +1 @@
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
+ 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-CoGuFVPI.js";import{Bt as l,Ht as u,I as d,Mn as f,T as ne,jn as p}from"./index-B66oMwwH.js";import{t as m}from"./SaveError-julafhJc.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,4 +1,4 @@
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(`
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-B66oMwwH.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-CoGuFVPI.js";import{t as b}from"./folderIndexResult-Cm68B9Ma.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
2
  `);return{summary:t.trim(),more:n.join(`
3
3
  `).trim()}}function D(e){let t=e.split(`
4
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(`
@@ -1,4 +1,4 @@
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(`
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-B66oMwwH.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-CoGuFVPI.js";import{t as de}from"./folderIndexResult-Cm68B9Ma.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
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
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
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};