@amd-gaia/agent-ui 0.27.0-rc.8 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/bin/gaia-ui.cjs +57 -3
  2. package/dist/assets/AdvancedSettings-R8_C2uBe.js +1 -0
  3. package/dist/assets/AutomationsSettings-B3zbjgZt.js +1 -0
  4. package/dist/assets/ConnectorsPane-BxG6qzLb.css +1 -0
  5. package/dist/assets/ConnectorsPane-BzcyOZRr.js +1 -0
  6. package/dist/assets/{DocumentLibrary-fEMoY7lH.css → DocumentLibrary-Ctwq2m2t.css} +1 -1
  7. package/dist/assets/DocumentLibrary-o3Fy8URO.js +5 -0
  8. package/dist/assets/FileBrowser-DxS29ShT.css +1 -0
  9. package/dist/assets/FileBrowser-_6Dx8AKt.js +4 -0
  10. package/dist/assets/MemoryDashboard-Bfy9g6TS.css +1 -0
  11. package/dist/assets/MemoryDashboard-ao_en1zm.js +1 -0
  12. package/dist/assets/MessagingSettings-DJq0F5BO.js +1 -0
  13. package/dist/assets/{MobileAccessModal-BrZMaERi.css → MobileAccessModal-DSFjH6di.css} +1 -1
  14. package/dist/assets/MobileAccessModal-ld0MPTgk.js +2 -0
  15. package/dist/assets/ScheduleManager-CEBoBLPV.css +1 -0
  16. package/dist/assets/ScheduleManager-px6Ly00O.js +1 -0
  17. package/dist/assets/folderIndexResult-BIoxqF5I.js +1 -0
  18. package/dist/assets/index-DXyVxzzC.css +1 -0
  19. package/dist/assets/index-Qh2EUbOw.js +226 -0
  20. package/dist/assets/useFocusTrap-Cy_PGcml.js +6 -0
  21. package/dist/index.html +3 -3
  22. package/dist/sw.js +1 -1
  23. package/main-safety-net.cjs +26 -2
  24. package/main.cjs +196 -58
  25. package/package.json +2 -2
  26. package/services/backend-crash-dialog.cjs +19 -5
  27. package/services/backend-health-monitor.cjs +86 -0
  28. package/services/backend-installer.cjs +1 -0
  29. package/services/backend-supervisor.cjs +35 -9
  30. package/services/browser-pane/dev-servers.cjs +44 -1
  31. package/services/browser-pane/listen-addresses.cjs +140 -0
  32. package/services/context-menu.cjs +79 -0
  33. package/services/link-policy.cjs +78 -7
  34. package/services/port-manager.cjs +2 -3
  35. package/services/process-tree.cjs +84 -14
  36. package/services/quit-guard.cjs +8 -4
  37. package/services/ui-token.cjs +156 -0
  38. package/dist/assets/AdvancedSettings-DPIu61Ug.js +0 -1
  39. package/dist/assets/AutomationsSettings-B-JefRcu.js +0 -1
  40. package/dist/assets/ConnectorsPane-BGI8nBUb.css +0 -1
  41. package/dist/assets/ConnectorsPane-DR1BXwSE.js +0 -1
  42. package/dist/assets/DocumentLibrary-je0OG0yL.js +0 -5
  43. package/dist/assets/FileBrowser-1goNp4CP.css +0 -1
  44. package/dist/assets/FileBrowser-CsVRdbcE.js +0 -4
  45. package/dist/assets/MemoryDashboard-CeioRY3q.js +0 -1
  46. package/dist/assets/MemoryDashboard-RpfLag-v.css +0 -1
  47. package/dist/assets/MessagingSettings-naPht5_K.js +0 -1
  48. package/dist/assets/MobileAccessModal-Bi6c7ior.js +0 -2
  49. package/dist/assets/ScheduleManager-BZzEH2-W.css +0 -1
  50. package/dist/assets/ScheduleManager-Dod2vW7s.js +0 -1
  51. package/dist/assets/index-B5hpAuDg.css +0 -1
  52. package/dist/assets/index-BLw-Jjdx.js +0 -222
  53. package/dist/assets/useFocusTrap-ChaVFhZD.js +0 -6
@@ -1,5 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{At as t,Bt as n,Ft as r,Kt as i,Ot as a,Rt as o,Sn as s,Ut as ee,Vt as te,_n as ne,bn as c,ct as re,dt as ie,ft as ae,gt as l,h as oe,ht as se,in as ce,ln as le,lt as ue,mt as de,pt as fe,sn as pe,st as me,ut as he,yn as ge}from"./index-BLw-Jjdx.js";import{$t as _e,B as u,Bn as ve,Nt as ye,_ as be,b as d,c as xe,ci as f,fn as Se,ft as Ce,gi as p,gt as we,hi as m,l as h,lt as Te,n as Ee,nn as g,r as _,s as De,u as v,vn as Oe,zn as ke}from"./useFocusTrap-ChaVFhZD.js";var y={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`}]]};y.node;var Ae=m(y),b={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`}]]};b.node;var je=m(b),x=e(p(),1);function Me(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 S=e=>e.toLocaleString(`en-US`);function C(e,t){if(e.phase===`starting`)return t(`docs.progress.starting`);let n=S(e.done);return e.phase===`reading`?e.total==null?t(`docs.progress.readingCount`,{done:n}):t(`docs.progress.reading`,{done:n,total:S(e.total)}):e.total==null?t(`docs.progress.embeddingCount`,{done:n}):t(`docs.progress.embedding`,{done:n,total:S(e.total)})}function w(e){return e.total==null||e.total<=0?null:Math.min(100,Math.floor(e.done/e.total*100))}function Ne({progress:e}){let t=C(e,De()),n=w(e);return v(`div`,{className:`index-progress is-running`,children:[h(`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:h(`div`,{className:`index-progress-fill`,style:n==null?void 0:{inlineSize:`${n}%`}})}),v(`span`,{className:`index-progress-label`,children:[t,n!=null&&v(`span`,{className:`index-progress-pct`,children:[` · `,n,`%`]})]})]})}function Pe(e){let[t,...n]=e.replace(/^RAG indexing failed for [^:]+:\s*/,``).trim().split(`
2
- `);return{summary:t.trim(),more:n.join(`
3
- `).trim()}}function Fe(e,t,n){let r=n.skipped??0;return e.compose(e=>{let i=[];n.indexed>0?i.push(e(u(`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(u(`docs.folder.skipped`,r),{n:r}));let a=n.skipped_images??0;return a>0&&i.push(e(u(`docs.folder.images`,a),{n:a})),n.failed>0&&(i.push(e(u(`docs.folder.failed`,n.failed),{n:n.failed})),n.errors[0]&&i.push(n.errors[0].split(`
4
- `)[0])),i.push(e(`docs.folder.noSubfolders`)),i.join(` `)})}var Ie=1e3,Le=5,Re=6e3;function ze(e,t,n){if(n)return{...e,[t]:n};if(!(t in e))return e;let{[t]:r,...i}=e;return i}function Be(e){let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Ve(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(_(t),{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}catch{return``}}function He(e,t){try{let n=new Date(e);return isNaN(n.getTime())?``:n.toLocaleString(_(t),{year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function Ue({name:e}){let t=Array.from(e);if(t.length<=28)return h(`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 v(`span`,{className:`doc-name doc-name-split is-rtl-text`,dir:`auto`,title:e,children:[h(`span`,{className:`doc-name-head`,children:e.slice(0,e.length-t.length)}),t&&h(`span`,{className:`doc-name-tail`,dir:`ltr`,children:t})]})}return v(`span`,{className:`doc-name doc-name-split`,dir:`auto`,title:e,children:[h(`span`,{className:`doc-name-head`,children:t.slice(0,-14).join(``)}),h(`span`,{className:`doc-name-tail`,children:t.slice(-14).join(``)})]})}function T(){let e=De(),{documents:u,setDocuments:p,setShowDocLibrary:m,openFileBrowserFromLibrary:_,currentSessionId:y,sessions:b,updateSessionInList:S,draftDocumentIds:C,addDraftDocuments:w,removeDraftDocument:T}=d(),E=b.find(e=>e.id===y)??null,[We,Ge]=(0,x.useState)(y?`chat`:`next`),D=We===`chat`?y:null,O=`“${E?.title||e(`docs.untitledChat`)}”`,[Ke,k]=(0,x.useState)(``),[qe,Je]=(0,x.useState)(``),Ye=u.length>Le?qe.trim().toLowerCase():``,Xe=e=>!Ye||e.filename.toLowerCase().includes(Ye),Ze=(0,x.useRef)(null),Qe=(0,x.useCallback)(()=>m(!1),[m]);be(!0,Qe);let $e=(0,x.useRef)(null),A=(0,x.useRef)(null);Ee($e,!0),oe($e,!0);let[et,j]=(0,x.useState)(!1),[M,tt]=(0,x.useState)(!1),[nt,N]=(0,x.useState)(``),[P,rt]=(0,x.useState)(``),[F,I]=(0,x.useState)(null),[it,L]=(0,x.useState)(null),[at,R]=(0,x.useState)(null),[z,B]=(0,x.useState)(null),V=(0,x.useRef)(null),H=(0,x.useRef)(null),[U,W]=(0,x.useState)(null),[G,ot]=(0,x.useState)(new Set),[st,ct]=(0,x.useState)({}),K=(0,x.useRef)(new Map),[,lt]=(0,x.useState)(0),q=(0,x.useCallback)(()=>{f.doc.info(`Loading document library...`);let e=f.doc.time();W(null),g().then(t=>{let n=t.documents||[];p(n),f.doc.timed(`Loaded ${n.length} document(s), ${t.total_chunks||0} chunks, ${t.total_size_bytes||0} bytes total`,e)}).catch(e=>{f.doc.error(`Failed to load documents`,e),W({err:e})})},[p]);(0,x.useEffect)(q,[q]);let ut=u.some(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);(0,x.useEffect)(()=>{if(!ut)return;let e=d.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,n=setInterval(async()=>{if(lt(e=>e+1),!t){t=!0;try{let e=d.getState().documents.filter(e=>e.indexing_status===`indexing`||e.indexing_status===`pending`);for(let t of e)try{let e=await ye(t.id);if(ct(n=>ze(n,t.id,e.progress)),e.indexing_status!==`indexing`&&e.indexing_status!==`pending`){K.current.delete(t.id);let e=await g();p(e.documents||[]);break}}catch(e){f.doc.warn(`Indexing status for ${t.filename} unavailable`,e)}}finally{t=!1}}},Ie);return()=>clearInterval(n)},[ut,p]),(0,x.useEffect)(()=>{let e=new Set(u.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);ct(t=>Object.keys(t).reduce((t,n)=>e.has(n)?t:ze(t,n,null),t))},[u]),(0,x.useEffect)(()=>{let e=setInterval(async()=>{try{let e=(await g()).documents||[],t=d.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}))&&(p(e),f.doc.debug(`Document list refreshed (server-side changes detected)`)),W(null)}catch(e){f.doc.warn(`Document list refresh failed`,e)}},15e3);return()=>clearInterval(e)},[p]);let J=u.filter(e=>e.id!==z?.id),dt=J.length,ft=J.reduce((e,t)=>e+t.file_size,0),Y=J.filter(e=>e.indexing_status===`failed`),pt=Y.filter(e=>se(e.error_kind)).length,mt=Y.filter(e=>ae(e.error_kind)).length,ht=Y.length-pt-mt,X=(0,x.useCallback)(async(t,n)=>{if(Ze.current=t,!D){w([t]),k(e(`docs.willAttach`,{name:a(n)})),f.doc.info(`"${n}" will be attached to the next new chat`);return}await Te(D,t);let r=d.getState().sessions.find(e=>e.id===D)?.document_ids??[];if(!r.includes(t)){S(D,{document_ids:[...r,t]});let e=d.getState();e.setDocuments(e.documents.map(e=>e.id===t?{...e,sessions_using:(e.sessions_using??0)+1}:e))}k(e(`docs.attached`,{name:a(n),chat:O})),f.doc.info(`Attached "${n}" to session ${D}`)},[D,O,S,w,e]),gt=(0,x.useCallback)(async(e,t)=>{if(e.length===0)return;if(!D){w(e),f.doc.info(`"${t}" will be attached to the next new chat`);return}let n=[];for(let t of e)try{await Te(D,t),n.push(t)}catch(e){f.doc.warn(`Could not attach document to session: ${e}`)}let r=d.getState().sessions.find(e=>e.id===D)?.document_ids??[],i=n.filter(e=>!r.includes(e));i.length>0&&S(D,{document_ids:[...r,...i]}),f.doc.info(`Attached "${t}" to session ${D}`)},[D,S,w]),Z=(0,x.useCallback)(async(t,n,i)=>{if(!await r(`embedding`))return!1;let a=t.includes(`.`)?`.`+t.split(`.`).pop()?.toLowerCase():``,o=a&&!ie(a)?he(a)?.message??`The file type "${a}" is not supported for indexing.`:null;if(o&&!i)return f.doc.warn(`Unsupported file type: ${t} (${a})`),I({filename:t,error:o}),!1;f.doc.info(`Indexing document: ${t}`);let s=f.doc.time();tt(!0),N(e(`docs.indexingFile`,{name:t})),I(null),R(null),L(null),k(``);try{let r=await n();f.doc.timed(`Indexed "${t}": ${r?.chunk_count||`?`} chunks`,s);let i=r?.indexing_status===`failed`;if(i){f.doc.warn(`"${t}" couldn't be added (${r.error_kind??`unreadable`}); not attaching it`);let n=r.filename||t;R(de(r.error_kind,n,e)??e(`docs.notAdded`,{name:n}))}else if(r?.id)try{await X(r.id,r.filename||t)}catch(e){f.doc.error(`Could not attach "${t}" to ${O}`,e),I({filename:t,error:`Indexed, but not attached to ${O}: ${e instanceof Error?e.message:e}`})}let a=await g();return p(a.documents||[]),N(``),!i}catch(n){let{httpStatus:r,reason:a,body:s}=n??{};if(a===`is_folder`&&i)return await i();f.doc.error(`Failed to index "${t}"`,n);let ee=a===`too_large`?e(`docs.tooLargeDetail`,{max:String(s?.max_mb)}):fe(a,e)??(r===400&&o?o:n instanceof Error?n.message:`Upload failed`);return I({filename:t,error:ee,status:r,kind:a}),N(``),!1}finally{tt(!1)}},[X,O,p,e]),_t=(0,x.useCallback)(async(t,n)=>{f.doc.info(`"${t}" is a folder; indexing its documents`),N(e(`docs.indexingFolder`,{name:n}));try{let r=await _e(t,!1);await gt(r.documents.map(e=>e.id).filter(Boolean),n),L(Fe(e,n,r));let i=await g();return p(i.documents||[]),!0}catch(e){f.doc.error(`Failed to index folder "${t}"`,e);let r=e instanceof Error?e.message:`Folder indexing failed`,{httpStatus:i}=e??{};return I({filename:n,error:r,status:i}),!1}finally{N(``)}},[gt,p,e]),vt=(0,x.useCallback)(async(e,t)=>Z(t,()=>ve(e),()=>_t(e,t)),[Z,_t]),Q=(0,x.useCallback)(async e=>{await Z(e.name,()=>ke(e))},[Z]),yt=(0,x.useCallback)(async e=>{e.preventDefault(),j(!1);let t=Array.from(e.dataTransfer.files);f.doc.info(`Dropped ${t.length} file(s) into Document Library`);for(let e of t)await Q(e)},[Q]),bt=(0,x.useCallback)(async e=>{let t=Array.from(e.target.files??[]);e.target.value=``;for(let e of t)await Q(e)},[Q]),xt=(0,x.useCallback)(async({id:t,name:n})=>{f.doc.info(`Deleting document: ${n}`);try{await we(t)}catch(r){f.doc.error(`Failed to delete document: ${n}`,r),B(e=>e?.id===t?null:e),R(e(`docs.deleteFailed`,{name:a(n),error:l(r)}));return}K.current.delete(t),T(t),Ze.current===t&&k(``),p(d.getState().documents.filter(e=>e.id!==t)),B(e=>e?.id===t?null:e),f.doc.info(`Deleted document: ${n}`)},[p,T,e]),$=(0,x.useCallback)(()=>{H.current!==null&&clearTimeout(H.current),H.current=null;let e=V.current;V.current=null,e&&xt(e)},[xt]),St=(0,x.useCallback)(e=>{let t=u.find(t=>t.id===e)?.filename||e;R(null),I(null),L(null),k(``),$();let n={id:e,name:t};V.current=n,B(n),H.current=window.setTimeout($,Re)},[u,$]),Ct=(0,x.useCallback)(()=>{H.current!==null&&clearTimeout(H.current),H.current=null,V.current=null,B(null)},[]),wt=(0,x.useRef)($);wt.current=$,(0,x.useEffect)(()=>()=>wt.current(),[]);let Tt=(0,x.useCallback)(async(t,n)=>{f.doc.info(`Opening folder for: ${t}`),R(null);try{await Se(t,!0)}catch(t){f.doc.error(`Failed to open folder for: ${n}`,t),R(e(`docs.openFolderFailed`,{name:a(n),error:l(t)}))}},[e]),Et=(0,x.useCallback)(async t=>{let n=u.find(e=>e.id===t)?.filename||t;f.doc.info(`Cancelling indexing for: ${n}`),R(null);try{await Ce(t)}catch(t){f.doc.error(`Failed to cancel indexing: ${n}`,t),R(e(`docs.cancelFailed`,{name:a(n),error:l(t)}));return}K.current.delete(t),f.doc.info(`Cancelled indexing for: ${n}`);try{let e=await g();p(e.documents||[])}catch(e){f.doc.warn(`Could not refresh the documents after cancelling`,e)}},[u,p,e]),Dt=(0,x.useCallback)(async e=>{if(G.has(e))return;let t=u.find(t=>t.id===e);f.doc.info(`Reindexing document: ${t?.filename||e}`),ot(t=>new Set(t).add(e));try{await Oe(e),f.doc.info(`Reindex complete for: ${t?.filename||e}`)}catch(n){let r=n instanceof Error?n.message:String(n);f.doc.error(`Reindex failed for: ${t?.filename||e}`,n),I({filename:t?.filename||e,error:r})}finally{try{let e=await g();p(e.documents||[])}catch(e){f.doc.error(`Failed to refresh documents after reindex`,e)}ot(t=>{let n=new Set(t);return n.delete(e),n})}},[u,p,G]),Ot=(0,x.useCallback)(async e=>{let t=u.find(t=>t.id===e)?.filename||e;k(``);try{await X(e,t)}catch(e){f.doc.error(`Failed to attach ${t} to ${O}`,e),I({filename:t,error:`Not attached to ${O}: ${e instanceof Error?e.message:e}`})}},[u,X,O]),kt=(0,x.useCallback)(async e=>{e.preventDefault();let t=Me(P);t&&(f.doc.info(`Indexing from path input: ${t}`),await vt(t,t.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||`file`)&&rt(``))},[P,vt]),At=t=>{let n=t.indexing_status||`complete`,r=K.current.get(t.id),i=t.indexed_at?Ve(t.indexed_at,e):``,o=t.indexed_at?He(t.indexed_at,e):``;switch(n){case`indexing`:case`pending`:{let n=st[t.id];return v(`div`,{className:`doc-indexing-status`,children:[n?h(Ne,{progress:n}):v(`div`,{className:`doc-indexing-bar`,children:[h(`div`,{className:`doc-indexing-bar-track`,children:h(`div`,{className:`doc-indexing-bar-fill`})}),v(`span`,{className:`doc-indexing-label`,children:[h(Ae,{size:12,className:`doc-spin`}),r?e.hint(e(`docs.indexingLabel`),Be(r)):e(`docs.indexing`)]})]}),v(`button`,{className:`btn-cancel`,onClick:e=>{e.stopPropagation(),Et(t.id)},title:e(`docs.cancelIndexing`),"aria-label":e(`docs.cancelIndexingAria`,{name:a(t.filename)}),children:[h(ge,{size:14}),e(`docs.cancel`)]})]})}case`failed`:{let n=t.error_kind?re[t.error_kind]:void 0,r=fe(t.error_kind,e),i=se(t.error_kind),o=r??t.last_error,s=o?Pe(o):null;return v(`div`,{className:`doc-failure`,children:[v(`div`,{className:`doc-indexing-status`,children:[v(`span`,{className:i?`doc-status-badge doc-status-waiting`:`doc-status-badge doc-status-failed`,title:o||void 0,"aria-label":o?e(i?`docs.waitingAria`:`docs.failedAria`,{error:o}):e(`docs.indexingFailed`),children:[h(c,{size:12}),` `,e(n?`docs.cantRead`:i?`docs.waiting`:`docs.failed`)]}),v(`button`,{className:n?`btn-retry btn-retry-quiet`:`btn-retry`,onClick:e=>{e.stopPropagation(),Dt(t.id)},title:e(n?`docs.retryTitleFix`:`docs.retryTitle`),"aria-label":e(`docs.retryAria`,{name:a(t.filename)}),disabled:G.has(t.id),children:[h(je,{size:n?12:14}),G.has(t.id)?e(`docs.retrying`):e(`docs.retry`)]})]}),n&&h(`p`,{className:`doc-failure-hint`,children:n}),n&&s&&v(`details`,{className:`doc-failure-reason`,children:[h(`summary`,{children:e(`docs.technicalDetails`)}),h(`p`,{children:[s.summary,s.more].filter(Boolean).join(`
5
- `)})]}),!n&&s&&(s.more?v(`details`,{className:`doc-failure-reason`,children:[h(`summary`,{children:s.summary}),h(`p`,{children:s.more})]}):h(`p`,{className:`doc-failure-reason`,children:s.summary})),!s&&!n&&h(`p`,{className:`doc-failure-reason`,children:e(`docs.noReason`)})]})}case`cancelled`:return v(`span`,{className:`doc-status-badge doc-status-cancelled`,children:[h(ge,{size:12}),` `,e(`docs.cancelled`)]});case`missing`:return v(`span`,{className:`doc-status-badge doc-status-missing`,children:[h(c,{size:12}),` `,e(`docs.missing`)]});default:return v(`span`,{className:`doc-meta`,children:[h(`bdi`,{dir:`ltr`,children:me(t.file_size)}),i&&v(`span`,{className:`doc-timestamp`,title:e(`docs.indexedAt`,{time:o}),children:[h(ne,{size:10}),i]})]})}},jt=t=>{if(t.indexing_status&&t.indexing_status!==`complete`)return null;let n=!!E?.document_ids?.includes(t.id),r=Math.max((t.sessions_using??0)-+!!n,0),i;return i=n?r>0?e.plural(`docs.usage.hereAndOthers`,r):e(`docs.usage.here`):C.includes(t.id)?e(`docs.usage.next`):r>0?e.plural(`docs.usage.chats`,r):e(`docs.usage.none`),h(`span`,{className:`doc-usage${n?` is-here`:``}`,children:i})};return h(`div`,{ref:$e,className:`modal-overlay`,onClick:()=>m(!1),role:`dialog`,"aria-modal":`true`,"aria-label":e(`docs.title`),children:v(`div`,{className:`modal-panel doc-modal`,onClick:e=>e.stopPropagation(),children:[v(`div`,{className:`modal-header`,children:[h(`h3`,{children:e(`docs.title`)}),h(`button`,{className:`btn-icon`,onClick:()=>m(!1),"aria-label":e(`docs.close`),children:h(o,{size:18})})]}),v(`div`,{className:`modal-body`,children:[v(`div`,{className:`doc-target`,children:[y?v(`label`,{className:`doc-target-choice`,children:[e(`docs.addTo`),v(`select`,{value:We,onChange:e=>{Ge(e.target.value),k(``)},children:[h(`option`,{value:`chat`,children:e.bare(`docs.thisChat`,{chat:O})}),h(`option`,{value:`next`,children:e.bare(`docs.nextChat`)})]})]}):h(`span`,{children:e(`docs.nextChatOnly`)}),h(`span`,{className:`doc-target-hint`,children:e(`docs.hint`)})]}),v(`div`,{className:`drop-zone ${et?`drag-over`:``} ${M?`uploading`:``} ${u.length>0?`drop-zone-compact`:``}`,onDragOver:e=>{e.preventDefault(),j(!0)},onDragLeave:()=>j(!1),onDrop:yt,role:`button`,tabIndex:M?-1:0,"aria-label":e(`docs.drop`),onClick:()=>{M||A.current?.click()},onKeyDown:e=>{M||e.target!==e.currentTarget||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),A.current?.click())},children:[h(`input`,{ref:A,type:`file`,multiple:!0,hidden:!0,onClick:e=>e.stopPropagation(),onChange:bt}),M?v(xe.Fragment,{children:[h(`div`,{className:`upload-spinner`}),h(`p`,{children:nt})]}):v(xe.Fragment,{children:[h(n,{size:32,strokeWidth:1.5}),h(`p`,{children:e(`docs.drop`)}),h(`span`,{className:`drop-hint`,children:e(`docs.dropHint`)})]})]}),h(`p`,{className:`drop-hint path-hint`,children:e(`docs.pathHint`)}),v(`form`,{className:`path-input-form`,onSubmit:kt,children:[h(pe,{size:16,className:`path-icon`}),h(`input`,{type:`text`,className:`path-input`,value:P,onChange:e=>rt(e.target.value),placeholder:t(),"aria-label":e(`docs.pathAria`),dir:`auto`}),h(`button`,{type:`submit`,className:`btn-secondary`,disabled:!P.trim()||M,children:e(`docs.index`)}),v(`button`,{type:`button`,className:`btn-secondary`,onClick:_,title:e(`docs.browseTitle`),children:[h(i,{size:14}),e(`docs.browse`)]})]}),h(`p`,{className:`doc-path-hint`,children:e(`docs.pathSubfolders`)}),Ke&&h(`p`,{className:`doc-target-notice`,role:`status`,children:Ke}),F&&h(ue,{filename:F.filename,error:F.error,status:F.status,kind:F.kind,onDismiss:()=>I(null)}),U&&u.length>0&&v(`div`,{className:`doc-folder-notice doc-action-error`,role:`alert`,children:[h(c,{size:14}),h(`span`,{children:e(`docs.loadFailed`,{error:l(U.err)})}),h(`button`,{type:`button`,className:`btn-secondary`,onClick:q,children:e(`docs.loadRetry`)})]}),at&&v(`div`,{className:`doc-folder-notice doc-action-error`,role:`alert`,children:[h(c,{size:14}),h(`span`,{children:at}),h(`button`,{className:`btn-icon-sm`,onClick:()=>R(null),"aria-label":e(`docs.dismissError`),children:h(o,{size:12})})]}),z&&v(`div`,{className:`doc-folder-notice doc-removed-notice`,role:`status`,children:[h(ee,{size:14}),h(`span`,{children:e(`docs.removed`,{name:z.name})}),v(`button`,{type:`button`,className:`doc-undo`,onClick:Ct,autoFocus:!0,children:[h(te,{size:12}),` `,e(`docs.undo`)]})]},z.id),it&&v(`div`,{className:`doc-folder-notice`,role:`status`,children:[h(s,{size:14}),h(`span`,{children:it}),h(`button`,{className:`btn-icon-sm`,onClick:()=>L(null),"aria-label":e(`docs.dismissFolder`),children:h(o,{size:12})})]}),dt>0&&v(`div`,{className:`doc-stats`,children:[h(`span`,{children:e.plural(`docs.count`,dt-Y.length)}),ht>0&&h(`span`,{className:`doc-stats-failed`,children:e.plural(`docs.unreadable`,ht)}),pt>0&&h(`span`,{className:`doc-stats-failed doc-stats-server`,children:e.plural(`docs.serverWaiting`,pt)}),mt>0&&h(`span`,{className:`doc-stats-failed`,children:e.plural(`docs.needsRetry`,mt)}),h(`span`,{children:`·`}),h(`bdi`,{dir:`ltr`,children:me(ft)})]}),u.length>Le&&v(`div`,{className:`doc-filter`,children:[h(i,{size:14,className:`doc-filter-icon`,"aria-hidden":`true`}),h(`input`,{type:`search`,className:`doc-filter-input`,value:qe,onChange:e=>Je(e.target.value),placeholder:e(`docs.filterPlaceholder`),"aria-label":e(`docs.filterAria`)})]}),Ye&&u.length>0&&!u.some(Xe)&&h(`p`,{className:`doc-filter-empty`,children:e(`docs.filterNone`,{text:qe.trim()})}),v(`div`,{className:`doc-list`,children:[U&&u.length===0&&v(`div`,{className:`empty-docs doc-load-error`,role:`alert`,children:[h(c,{size:32,strokeWidth:1}),h(`p`,{children:e(`docs.loadFailed`,{error:l(U.err)})}),h(`button`,{type:`button`,className:`btn-secondary`,onClick:q,children:e(`docs.loadRetry`)})]}),u.length===0&&!M&&!U&&v(`div`,{className:`empty-docs`,children:[h(le,{size:32,strokeWidth:1}),h(`p`,{children:e(`docs.empty`)}),h(`span`,{children:e(`docs.emptyHint`)})]}),u.filter(e=>e.id!==z?.id).map(t=>v(`div`,{hidden:!Xe(t),className:`doc-row ${t.indexing_status===`indexing`?`doc-row-indexing`:``}`,children:[v(`div`,{className:`doc-info`,children:[h(Ue,{name:a(t.filename)}),At(t),jt(t)]}),v(`div`,{className:`doc-row-actions`,children:[t.filepath&&h(`button`,{className:`btn-icon-sm doc-open-folder`,onClick:()=>Tt(t.filepath,t.filename),title:e(`docs.openFolder`,{path:a(t.filepath)}),"aria-label":e(`docs.openFolderAria`,{name:a(t.filename)}),children:h(pe,{size:14})}),t.indexing_status===`complete`&&!(D?E?.document_ids?.includes(t.id):C.includes(t.id))&&v(`button`,{className:`doc-attach`,onClick:()=>Ot(t.id),title:D?e(`docs.useIn`,{chat:O}):e(`docs.useNext`),"aria-label":D?e(`docs.attachAria`,{name:a(t.filename),chat:O}):e(`docs.attachNextAria`,{name:a(t.filename)}),children:[h(ce,{size:14}),e(D?`docs.addToThisChat`:`docs.addToNextChat`)]}),t.indexing_status!==`indexing`&&t.indexing_status!==`pending`&&h(`button`,{className:`btn-icon-sm doc-delete`,onClick:()=>St(t.id),title:e(`docs.remove`),"aria-label":e(`docs.removeAria`,{name:a(t.filename)}),children:h(ee,{size:14})})]})]},t.id))]})]})]})})}export{T as DocumentLibrary};
@@ -1 +0,0 @@
1
- .file-browser-modal{flex-direction:column;width:min(95vw,1000px);max-height:85vh;display:flex}.file-browser-modal.has-preview{width:min(95vw,1200px)}.file-browser-body{flex-direction:column;flex:1;gap:10px;padding:0 16px 16px;display:flex;overflow-y:auto}.fb-quick-links{flex-wrap:wrap;gap:6px;padding:4px 0;display:flex}.fb-quick-link{border-radius:var(--radius-sm);border:1px solid var(--border-light);background:var(--bg-secondary);color:var(--text-secondary);cursor:pointer;transition:all var(--duration) var(--ease);align-items:center;gap:5px;padding:5px 10px;font-size:12px;display:flex}.fb-quick-link:hover{background:var(--bg-hover);color:var(--text-primary);border-color:var(--border)}.fb-search-bar{align-items:center;gap:8px;display:flex}.fb-search-input-wrap{flex:1;align-items:center;display:flex;position:relative}.fb-search-icon{color:var(--text-muted);pointer-events:none;position:absolute;inset-inline-start:10px}.fb-search-input{border-radius:var(--radius-md);border:1px solid var(--border);background:var(--bg-input);width:100%;color:var(--text-primary);font-size:13px;font-family:var(--font-sans);transition:border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);outline:none;padding:8px 30px 8px 32px}.fb-search-input:focus{border-color:color-mix(in srgb, var(--accent) 40%, transparent)}.fb-search-clear{color:var(--text-muted);cursor:pointer;background:0 0;border:none;padding:2px;display:flex;position:absolute;inset-inline-end:8px}.fb-type-filter{border-radius:var(--radius-md);border:1px solid var(--border);background:var(--bg-input);color:var(--text-primary);font-size:12px;font-family:var(--font-sans);outline:none;min-width:110px;padding:8px}.fb-type-filter:focus-visible{border-color:color-mix(in srgb, var(--accent) 40%, transparent)}.fb-search-btn{border-radius:var(--radius-md);border:1px solid var(--accent-fill);background:var(--accent-fill);color:var(--accent-fill-text);font-size:var(--fs-label);font-weight:500;font-family:var(--font-sans);cursor:pointer;white-space:nowrap;transition:all var(--duration) var(--ease);padding:8px 14px}.fb-search-btn:hover{background:var(--accent-fill-hover)}.fb-search-btn:disabled{opacity:.4;cursor:not-allowed;box-shadow:none}.fb-pathbar{align-items:center;gap:12px;display:flex}.fb-pathbar .fb-breadcrumb{flex:1;min-width:0}.fb-hidden-toggle{color:var(--text-secondary);cursor:pointer;flex-shrink:0;align-items:center;gap:6px;font-size:12px;display:flex}.fb-breadcrumb{color:var(--text-secondary);flex-wrap:nowrap;align-items:center;gap:2px;padding:4px 0;font-size:12px;display:flex;overflow-x:auto}.fb-crumb{color:var(--text-secondary);cursor:pointer;border-radius:var(--radius-sm);white-space:nowrap;transition:all var(--duration) var(--ease);background:0 0;border:none;padding:2px 4px;font-size:12px}.fb-crumb:hover{background:var(--bg-hover);color:var(--text-primary)}.fb-crumb-item{align-items:center;display:flex}.fb-crumb-sep{color:var(--text-muted);flex-shrink:0}.fb-up-btn{border:1px solid var(--border);color:var(--text-secondary);cursor:pointer;border-radius:var(--radius-sm);transition:all var(--duration) var(--ease);background:0 0;align-items:center;margin-inline-start:auto;padding:3px 6px;display:flex}.fb-up-btn:hover{background:var(--bg-hover);border-color:var(--accent);color:var(--accent)}.fb-search-header{color:var(--text-secondary);justify-content:space-between;align-items:center;gap:12px;padding:4px 0;font-size:12px;display:flex}.fb-search-summary{flex-direction:column;gap:3px;min-width:0;display:flex}.fb-search-scope{color:var(--text-muted);text-overflow:clip;white-space:nowrap;animation:both fade-cut-inline;animation-timeline:scroll(self inline);overflow:hidden}.fb-search-scope code{color:var(--text-secondary);font-family:var(--font-mono)}.fb-back-btn{color:var(--accent);cursor:pointer;transition:color var(--duration) var(--ease);background:0 0;border:none;font-size:12px}.fb-back-btn:hover{color:var(--accent-light)}.fb-content{flex:1;gap:12px;min-height:min(300px,40vh);display:flex;overflow:hidden}.fb-file-list{border:1px solid var(--border);border-radius:var(--radius-lg);scrollbar-width:thin;scrollbar-color:var(--border) transparent;flex:1;min-width:250px;overflow-y:auto}.fb-file-list::-webkit-scrollbar{width:5px}.fb-file-list::-webkit-scrollbar-track{background:0 0}.fb-file-list::-webkit-scrollbar-thumb{background:var(--border);border-radius:var(--radius-full)}.fb-file-list::-webkit-scrollbar-thumb:hover{background:var(--text-muted)}.fb-entry{cursor:pointer;border-bottom:1px solid var(--border-light);transition:background var(--duration-fast) var(--ease);font-size:13px;font-family:var(--font-sans);align-items:center;gap:8px;padding:8px 10px;display:flex}.fb-entry:hover{background:var(--bg-hover)}.fb-entry.selected{background:var(--accent-dim2);border-color:color-mix(in srgb, var(--accent) 12%, transparent)}.fb-entry.folder .fb-entry-icon{color:var(--text-secondary)}.fb-entry .fb-entry-icon{color:var(--text-muted);flex-shrink:0}.fb-entry-name{text-overflow:clip;white-space:nowrap;color:var(--text-primary);flex:1;animation:both fade-cut-inline;animation-timeline:scroll(self inline);overflow:hidden}.fb-entry.folder .fb-entry-name{font-weight:500}.fb-entry-size,.fb-entry-date{font-size:var(--fs-caption);color:var(--text-muted);white-space:nowrap;font-family:var(--font-sans);font-variant-numeric:tabular-nums;flex-shrink:0}.fb-entry-size{text-align:end;min-width:55px}.fb-entry-date{text-align:end;min-width:65px}.fb-entry-checkbox{cursor:pointer;width:16px;min-width:16px;height:16px;min-height:16px;accent-color:var(--accent);flex-shrink:0}.fb-entry-preview-btn{width:24px;min-width:24px;height:24px;color:var(--text-muted);cursor:pointer;border-radius:var(--radius-sm);opacity:0;transition:opacity var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);background:0 0;border:none;flex-shrink:0;justify-content:center;align-items:center;padding:0;display:inline-flex}.fb-entry:hover .fb-entry-preview-btn,.fb-entry.selected .fb-entry-preview-btn{opacity:1}.fb-entry-preview-btn:hover{color:var(--text-primary);background:var(--bg-hover)}.fb-entry-preview-btn:focus-visible{opacity:1;outline:2px solid var(--accent);outline-offset:1px}.fb-preview{border:1px solid var(--border);border-radius:var(--radius-lg);flex-direction:column;flex-shrink:0;width:280px;display:flex;overflow:hidden}.fb-preview-header{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;padding:8px 12px;display:flex}.fb-preview-name{color:var(--text-primary);text-overflow:clip;white-space:nowrap;font-size:12px;font-weight:500;animation:both fade-cut-inline;animation-timeline:scroll(self inline);overflow:hidden}.fb-preview-meta{font-size:var(--fs-caption);color:var(--text-muted);border-bottom:1px solid var(--border-light);font-family:var(--font-sans);font-variant-numeric:tabular-nums;gap:10px;padding:6px 12px;display:flex}.fb-preview-columns{color:var(--text-secondary);border-bottom:1px solid var(--border-light);word-break:break-word;padding:6px 12px;font-size:11px}.fb-preview-content{font-size:11px;font-family:var(--font-mono);color:var(--text-code);white-space:pre-wrap;word-break:break-all;background:var(--bg-code);scrollbar-width:thin;scrollbar-color:var(--border-code) transparent;flex:1;margin:0;padding:10px 12px;line-height:1.5;overflow:auto}.fb-preview-content::-webkit-scrollbar{width:5px;height:5px}.fb-preview-content::-webkit-scrollbar-track{background:0 0}.fb-preview-content::-webkit-scrollbar-thumb{background:var(--border-code);border-radius:var(--radius-full)}.fb-preview-content::-webkit-scrollbar-thumb:hover{background:var(--text-code-dim)}.fb-preview-loading,.fb-preview-binary{text-align:center;color:var(--text-muted);padding:20px;font-size:12px}.fb-actions{border-top:1px solid var(--border);align-items:center;gap:10px;padding-top:12px;display:flex}.fb-selection-info{color:var(--text-muted);flex:1;font-size:12px}.fb-index-status{font-size:var(--fs-caption);color:var(--accent);font-family:var(--font-sans)}.fb-action-btns{gap:8px;display:flex}.fb-action-btn{border-radius:var(--radius-md);font-size:12px;font-weight:500;font-family:var(--font-sans);cursor:pointer;transition:all var(--duration) var(--ease);align-items:center;gap:5px;padding:8px 16px;display:flex}.fb-action-btn.secondary{border:1px solid var(--border);color:var(--text-primary);background:0 0}.fb-action-btn.secondary:hover{background:var(--bg-hover);border-color:var(--text-muted)}.fb-action-btn.primary{border:1px solid var(--accent-fill);background:var(--accent-fill);color:var(--accent-fill-text)}.fb-action-btn.primary:hover{background:var(--accent-fill-hover)}.fb-action-btn:disabled{opacity:.4;cursor:not-allowed}.fb-loading,.fb-empty,.fb-error{text-align:center;color:var(--text-muted);padding:30px;font-size:13px}.fb-error{color:var(--danger);background:var(--danger-dim2);border-radius:var(--radius-md);padding:10px}@media (width<=768px){.file-browser-modal{border-radius:0;width:100vw;max-height:100vh}.fb-preview{display:none}.fb-search-bar{flex-wrap:wrap}.fb-type-filter{min-width:100%}}
@@ -1,4 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Bt as t,Dt as n,Ft as r,Kt as i,On as a,Ot as o,Rt as s,an as c,cn as l,dt as u,en as d,h as f,jt as p,kn as ee,ln as m,lt as te,on as h,pn as g,sn as ne,st as re,un as ie,ut as ae,wn as oe}from"./index-BLw-Jjdx.js";import{$t as se,Bn as _,Cn as ce,_ as le,b as v,ci as y,dt as ue,gi as b,gn as de,hi as x,l as S,lt as C,n as fe,nn as w,r as T,s as pe,u as E}from"./useFocusTrap-ChaVFhZD.js";var D={name:`code`,size:24,node:[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]};D.node;var me=x(D),O={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`]};O.node;var k=x(O),A={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`}]]};A.node;var j=x(A),M=e(b(),1);function he(e){if(e.type===`folder`)return S(h,{size:16});let t=(e.extension||``).toLowerCase();return[`.csv`,`.xlsx`,`.xls`,`.tsv`].includes(t)?S(j,{size:16}):[`.py`,`.js`,`.ts`,`.java`,`.c`,`.cpp`,`.go`,`.rs`].includes(t)?S(me,{size:16}):[`.pdf`,`.doc`,`.docx`,`.txt`,`.md`].includes(t)?S(m,{size:16}):S(l,{size:16})}function ge(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(T(t),{month:`short`,day:`numeric`,year:n.getFullYear()===r.getFullYear()?void 0:`numeric`})}function _e(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 ve(e){switch(e){case`home`:return S(k,{size:14});case`desktop`:return S(d,{size:14});case`documents`:return S(m,{size:14});case`download`:return S(g,{size:14});default:return S(h,{size:14})}}var ye=[{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`}],be={home:`fileBrowser.home`,desktop:`fileBrowser.desktop`,documents:`fileBrowser.documents`,download:`fileBrowser.downloads`};async function xe(e,t,n,i){let a=[],o=[];for(let t of e){let e=t.includes(`.`)?`.`+t.split(`.`).pop()?.toLowerCase():``;e&&!u(e)?o.push(t):a.push(t)}let s=[],c=[],l=0,d=``,f=null,p=0,ee=new Set(t.filter(e=>e.type===`folder`).map(e=>e.path));for(let e of a)try{if(ee.has(e)){let t=await se(e),n=[];t.documents.forEach(e=>{e.id&&n.push(e.id)}),p+=t.skipped_images??0,t.failed>0&&(l+=t.failed,d=t.errors[0]??d),n.length>0&&(n.forEach(e=>s.push(e)),c.push(e))}else{if(!await r(`embedding`))break;let t=await _(e);t?.indexing_status===`failed`?(l++,d=t.last_error??``,f=t.error_kind??null):t?.id&&(s.push(t.id),c.push(e))}}catch(e){l++,d=e instanceof Error?e.message:`Unknown error`,f=e?.reason??null}if(n&&s.length>0){let e=[];for(let t of s)try{await C(n,t),e.push(t)}catch(e){y.doc.warn(`Could not attach document to session: ${e}`)}let t=v.getState().sessions.find(e=>e.id===n)?.document_ids??[],r=e.filter(e=>!t.includes(e));r.length>0&&i(n,{document_ids:[...t,...r]})}else s.length>0&&v.getState().addDraftDocuments(s);if(s.length>0||l>0)try{let e=await w();v.getState().setDocuments(e.documents||[])}catch(e){y.doc.error(`Could not refresh the document list after indexing`,e)}return{docIds:s,supported:a,succeededFiles:c,unsupported:o,failed:l,lastError:d,lastErrorKind:f,skippedImages:p}}var Se=e=>e.startsWith(`.`);function N({onStartChat:e}){let r=pe(),{setShowFileBrowser:l,leaveFileBrowser:d,currentSessionId:m,updateSessionInList:h,setPendingPrompt:g}=v(),se=(0,M.useCallback)(()=>l(!1),[l]);le(!0,se);let _=(0,M.useRef)(null);fe(_,!0),f(_,!0);let[b,x]=(0,M.useState)(``),[C,w]=(0,M.useState)(null),[T,D]=(0,M.useState)([]),[me,O]=(0,M.useState)([]),[k,A]=(0,M.useState)(!1),[j,N]=(0,M.useState)(null),[P,Ce]=(0,M.useState)(null),[F,we]=(0,M.useState)(!1),[I,L]=(0,M.useState)(``),[R,z]=(0,M.useState)(null),[Te,B]=(0,M.useState)([]),[Ee,De]=(0,M.useState)(!1),[Oe,ke]=(0,M.useState)(!1),[V,Ae]=(0,M.useState)(``),[H,U]=(0,M.useState)(new Set),[W,G]=(0,M.useState)(null),[je,Me]=(0,M.useState)(!1),[Ne,K]=(0,M.useState)(new Set),[Pe,q]=(0,M.useState)(null),J=(0,M.useRef)(null),[Y,X]=(0,M.useState)(null),Z=(0,M.useCallback)(async e=>{A(!0),N(null),Ce(null),z(null),L(``),B([]);try{let t=await ue(e);x(t.current_path),w(t.parent_path),D(t.entries),t.quick_links.length>0&&O(t.quick_links),y.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;x(e),w(null),D([]),Ce(t)}else N(t instanceof Error?t.message:`Failed to load directory`);y.ui.error(`Browse failed`,t)}finally{A(!1)}},[]);(0,M.useEffect)(()=>{Z()},[Z]),(0,M.useEffect)(()=>()=>{J.current&&clearTimeout(J.current)},[]);let Fe=(0,M.useCallback)(async()=>{if(!I.trim())z(null),B([]);else{ke(!0),N(null);try{let e=await ce(I.trim(),V||void 0,30);z(e.results),B(e.searched_locations??[]),De(e.truncated===!0),y.ui.info(`Search "${I}": ${e.total} results`)}catch(e){let t=e instanceof Error?e.message:`Search failed`;N(t),y.ui.error(`Search failed`,e)}finally{ke(!1)}}},[I,V]),Ie=e=>{e.key===`Enter`&&Fe()},Le=(0,M.useCallback)(e=>{e.type===`folder`&&(Z(e.path),U(new Set),G(null))},[Z]),Re=(0,M.useCallback)(async e=>{Me(!0);try{let t=await de(e);G(t)}catch(e){y.ui.error(`Preview failed`,e)}finally{Me(!1)}},[]),Q=(0,M.useCallback)(e=>{U(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ze=(0,M.useCallback)(async()=>{if(H.size===0)return;let e=Array.from(H);if(X(null),!e.some(e=>{let t=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``;return!t||u(t)})){let t=e[0],n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=ae(r);X({filename:e.length===1?t.split(/[\\/]/).pop()||t:`${e.length} files`,error:i?i.message:`File type "${r}" is not supported for indexing.`})}else{K(new Set(e)),q(r.plural(`fileBrowser.adding`,e.length));try{let t=await xe(e,T,m,h);if(t.failed>0)q(r(`fileBrowser.addedWithFailures`,{added:t.docIds.length,failed:t.failed})),X({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)),t.skippedImages>0&&e.push(r.plural(`docs.folder.images`,t.skippedImages)),q(e.join(` `))}J.current&&clearTimeout(J.current),J.current=setTimeout(()=>q(null),5e3),U(new Set),t.failed===0&&t.unsupported.length===0&&v.getState().fileBrowserFromLibrary&&l(!1)}catch(t){y.doc.error(`Index selected failed`,t),X({filename:e.length===1?e[0].split(/[\\/]/).pop()||e[0]:`${e.length} files`,error:t instanceof Error?t.message:`An unexpected error occurred.`})}finally{K(new Set)}}},[H,m,h,T,l,r]),$=(0,M.useRef)(!1),Be=(0,M.useCallback)(async()=>{if(H.size===0||$.current)return;$.current=!0;let t=Array.from(H);X(null),K(new Set(t)),q(r.plural(`fileBrowser.adding`,t.length));try{let n=await xe(t,T,m,h);if(n.supported.length===0){let e=t[0].lastIndexOf(`.`),n=e>0?t[0].slice(e).toLowerCase():``,r=ae(n);X({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){X({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&&q(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
- `)}`;m?g({sessionId:m,text:a}):await e(a),d(),U(new Set)}catch(e){y.doc.error(`Ask Agent failed`,e),X({filename:t.length===1?t[0].split(/[\\/]/).pop()||t[0]:`${t.length} files`,error:e instanceof Error?e.message:`An unexpected error occurred.`})}finally{$.current=!1,K(new Set),q(null)}},[H,m,h,T,g,d,e,r]),Ve=b?b.replace(/\\/g,`/`).split(`/`).filter(Boolean):[],He=Ve.map((e,t)=>({label:e,path:Ve.slice(0,t+1).join(`/`)+(t===0&&e.includes(`:`)?`/`:``)})),Ue=_e(Te,r),We=T.filter(e=>!Se(e.name)),Ge=R?R.map(e=>({name:e.name,path:e.path,type:`file`,size:e.size,extension:e.extension||``,modified:e.modified||``})):F?T:We,Ke=T.length-We.length;return(0,M.useEffect)(()=>{F||R||U(e=>{let t=[...e].filter(e=>!Se(e.split(/[\\/]/).pop()??``));return t.length===e.size?e:new Set(t)})},[F,R]),S(`div`,{ref:_,className:`modal-overlay`,onClick:()=>l(!1),role:`dialog`,"aria-modal":`true`,"aria-label":r(`fileBrowser.title`),children:E(`div`,{className:`modal-panel file-browser-modal ${W?`has-preview`:``}`,onClick:e=>e.stopPropagation(),children:[E(`div`,{className:`modal-header`,children:[E(`h3`,{children:[S(ne,{size:18}),` `,r(`fileBrowser.title`)]}),S(`button`,{className:`btn-icon`,onClick:()=>l(!1),"aria-label":r(`fileBrowser.close`),children:S(s,{size:18})})]}),E(`div`,{className:`file-browser-body`,children:[S(`div`,{className:`fb-quick-links`,children:me.map(e=>E(`button`,{className:`fb-quick-link`,onClick:()=>Z(e.path),title:o(e.path),children:[ve(e.icon),S(`span`,{children:be[e.icon]?r(be[e.icon]):o(e.name)})]},e.path))}),E(`div`,{className:`fb-search-bar`,children:[E(`div`,{className:`fb-search-input-wrap`,children:[S(i,{size:14,className:`fb-search-icon`}),S(`input`,{type:`text`,className:`fb-search-input`,placeholder:r(`fileBrowser.searchPlaceholder`),value:I,onChange:e=>L(e.target.value),onKeyDown:Ie,"aria-label":r(`fileBrowser.searchAria`)}),I&&S(`button`,{className:`fb-search-clear`,onClick:()=>{L(``),z(null),B([])},"aria-label":r(`fileBrowser.clearSearch`),children:S(s,{size:12})})]}),S(`select`,{className:`fb-type-filter`,value:V,onChange:e=>Ae(e.target.value),"aria-label":r(`fileBrowser.typeFilter`),children:ye.map(e=>S(`option`,{value:e.value,children:r(e.label)},e.value))}),S(`button`,{className:`fb-search-btn`,onClick:Fe,disabled:!I.trim()||Oe,children:r(Oe?`fileBrowser.searching`:`fileBrowser.search`)})]}),!R&&E(`div`,{className:`fb-pathbar`,children:[E(`div`,{className:`fb-breadcrumb`,children:[S(`button`,{className:`fb-crumb`,onClick:()=>Z(`/`),children:S(c,{size:12})}),He.map((e,t)=>E(`span`,{className:`fb-crumb-item`,children:[S(oe,{size:12,className:`fb-crumb-sep`}),S(`button`,{className:`fb-crumb`,onClick:()=>Z(e.path),children:o(e.label)})]},t)),C&&S(`button`,{className:`fb-up-btn`,onClick:()=>Z(C),title:r(`fileBrowser.goUp`),children:S(ee,{size:14})})]}),E(`label`,{className:`fb-hidden-toggle`,children:[S(`input`,{type:`checkbox`,checked:F,onChange:e=>we(e.target.checked)}),r(`fileBrowser.showHidden`)]})]}),R&&E(`div`,{className:`fb-search-header`,children:[E(`div`,{className:`fb-search-summary`,children:[S(`span`,{children:r.plural(`fileBrowser.found`,R.length,{query:I})}),Ue&&E(`span`,{className:`fb-search-scope`,title:Te.join(`
3
- `),children:[r(`fileBrowser.searchingIn`),` `,S(`code`,{children:Ue})]}),Ee&&S(`span`,{children:r(`fileBrowser.searchStopped`)})]}),S(`button`,{className:`fb-back-btn`,onClick:()=>{z(null),L(``),B([])},children:r(`fileBrowser.backToBrowsing`)})]}),(j||P)&&S(`div`,{className:`fb-error`,children:P?r(p()?`fileBrowser.deniedMac`:`fileBrowser.denied`,{name:P}):j}),E(`div`,{className:`fb-content`,children:[E(`div`,{className:`fb-file-list`,children:[k&&S(`div`,{className:`fb-loading`,children:r(`fileBrowser.loading`)}),!k&&!j&&!P&&Ge.length===0&&S(`div`,{className:`fb-empty`,children:r(R?`fileBrowser.noFiles`:Ke>0?`fileBrowser.onlyHidden`:`fileBrowser.empty`)}),!k&&Ge.map(e=>{let t=e.extension||(e.name.includes(`.`)?`.`+e.name.split(`.`).pop()?.toLowerCase():``),n=e.type===`file`&&t&&!u(t);return E(`div`,{className:`fb-entry ${e.type} ${H.has(e.path)?`selected`:``} ${n?`unsupported`:``}`,onClick:()=>e.type===`folder`?Le(e):Q(e.path),onDoubleClick:()=>e.type===`folder`?Le(e):void 0,title:n?r(`fileBrowser.notIndexableTitle`):o(e.path),children:[S(`input`,{type:`checkbox`,className:`fb-entry-checkbox`,checked:H.has(e.path),onChange:()=>Q(e.path),onClick:e=>e.stopPropagation(),"aria-label":r(`fileBrowser.selectAria`,{name:o(e.name)})}),S(`span`,{className:`fb-entry-icon`,children:he(e)}),S(`span`,{className:`fb-entry-name`,title:o(e.path),children:o(e.name)}),n&&S(`span`,{className:`fb-unsupported-badge`,children:r(`fileBrowser.notIndexable`)}),e.type===`file`&&S(`button`,{type:`button`,className:`fb-entry-preview-btn`,onClick:t=>{t.stopPropagation(),Re(e.path)},"aria-label":r(`fileBrowser.previewAria`,{name:o(e.name)}),title:r(`fileBrowser.previewTitle`),children:S(ie,{size:14})}),S(`span`,{className:`fb-entry-size`,children:e.type===`file`?re(e.size):``}),S(`span`,{className:`fb-entry-date`,children:ge(e.modified,r)})]},e.path)})]}),W&&E(`div`,{className:`fb-preview`,children:[E(`div`,{className:`fb-preview-header`,children:[S(`span`,{className:`fb-preview-name`,children:o(W.name)}),S(`button`,{className:`btn-icon-sm`,onClick:()=>G(null),"aria-label":r(`fileBrowser.closePreview`),children:S(s,{size:14})})]}),E(`div`,{className:`fb-preview-meta`,children:[S(`span`,{children:W.size_display}),W.total_lines&&S(`span`,{children:r(`fileBrowser.lines`,{n:W.total_lines})}),W.columns&&S(`span`,{children:r(`fileBrowser.columnCount`,{n:W.columns.length})}),W.row_count!==null&&S(`span`,{children:r(`fileBrowser.rows`,{n:W.row_count})})]}),W.columns&&E(`div`,{className:`fb-preview-columns`,children:[S(`strong`,{children:r(`fileBrowser.columnsLabel`)}),` `,W.columns.join(`, `)]}),je?S(`div`,{className:`fb-preview-loading`,children:r(`fileBrowser.previewLoading`)}):W.is_text&&W.preview_lines.length>0?S(`pre`,{className:`fb-preview-content`,children:n(W.preview_lines.slice(0,30).join(`
4
- `))}):S(`div`,{className:`fb-preview-binary`,children:r(`fileBrowser.binary`)})]})]}),Y&&S(te,{filename:Y.filename,error:Y.error,kind:Y.kind??void 0,onDismiss:()=>X(null)}),E(`div`,{className:`fb-actions`,children:[S(`div`,{className:`fb-selection-info`,children:H.size>0?r.plural(`fileBrowser.selected`,H.size):r(`fileBrowser.selectHint`)}),Pe&&S(`span`,{className:`fb-index-status`,children:Pe}),E(`div`,{className:`fb-action-btns`,children:[E(`button`,{className:`fb-action-btn secondary`,onClick:ze,disabled:H.size===0||Ne.size>0,title:r(`fileBrowser.addToLibraryTitle`),children:[S(t,{size:14}),r(`fileBrowser.addToLibrary`)]}),E(`button`,{className:`fb-action-btn primary`,onClick:Be,disabled:H.size===0||Ne.size>0,title:r(`fileBrowser.askGaiaTitle`),children:[S(a,{size:14}),r(`fileBrowser.askGaia`)]})]})]})]})]})})}export{N as FileBrowser};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{V as t,_ as n,a as r,b as i,c as a,ci as o,gi as s,hi as c,l,n as u,r as d,s as ee,u as f}from"./useFocusTrap-ChaVFhZD.js";import{A as te,An as ne,B as re,C as ie,D as ae,E as oe,En as se,F as ce,G as le,H as ue,Ht as p,I as de,J as fe,K as pe,Kt as m,L as me,Lt as h,M as he,N as ge,O as _e,On as ve,P as ye,Qt as be,R as g,Rt as xe,S as Se,Sn as Ce,T as we,Tn as Te,U as Ee,Ut as De,V as _,Vt as Oe,W as ke,Wt as Ae,X as v,Xt as je,Y as Me,Yt as Ne,_ as Pe,_n as Fe,b as Ie,gn as Le,hn as Re,j as ze,k as Be,mn as Ve,q as He,rn as Ue,st as We,t as Ge,tn as Ke,un as qe,v as Je,vn as Ye,w as Xe,wn as Ze,x as Qe,y as $e,z as et,zt as tt}from"./index-BLw-Jjdx.js";var nt={name:`git-merge`,size:24,node:[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]};nt.node;var rt=c(nt),y={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};y.node;var it=c(y),at={name:`shield`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]};at.node;var ot=c(at),b={name:`target`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};b.node;var st=c(b),ct={name:`trending-up`,size:24,node:[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]};ct.node;var lt=c(ct),x={name:`user`,size:24,node:[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]};x.node;var ut=c(x),S=e(s(),1),dt=200,ft=[{title:`mem.about.group.preferences`,categories:[`preference`]},{title:`mem.about.group.about`,categories:[`fact`,`profile`,`skill`]},{title:`mem.about.group.reminders`,categories:[`reminder`]},{title:`mem.about.group.notes`,categories:[`note`]}],pt={user:`mem.source.user`,tool:`mem.source.tool`,llm_extract:`mem.source.llm_extract`,consolidation:`mem.source.consolidation`,inferred:`mem.source.inferred`,discovery:`mem.source.discovery`,error_auto:`mem.source.error_auto`};function mt(e){return pt[e]??`mem.source.other`}function ht(e,n){let r=new Date(e);if(Number.isNaN(r.getTime()))return null;let i=Math.floor((Date.now()-r.getTime())/864e5);return i<=0?t(`mem.day.today`):i===1?t(`mem.day.yesterday`):i<30?t(`mem.day.daysAgo`,{n:i}):r.toLocaleDateString(d(n),{month:`short`,day:`numeric`,year:`numeric`})}function gt(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e),n=t?new Date(+t[1],t[2]-1,+t[3]):new Date(e);return Number.isNaN(n.getTime())?null:n}function _t(e){let t=e?gt(e):null;if(!t)return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function vt(e,t=new Date,n=r){let i=gt(e);if(!i)return null;let a=i.getHours()===0&&i.getMinutes()===0&&i.getSeconds()===0,o=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),s=a?i.getTime()<o:i.getTime()<t.getTime(),c=i.toLocaleString(d(n),{weekday:`short`,month:`short`,day:`numeric`,...i.getFullYear()===t.getFullYear()?{}:{year:`numeric`},...a?{}:{hour:`numeric`,minute:`2-digit`}});return{text:n(s?`mem.due.past`:`mem.due.upcoming`,{when:c}),past:s}}function yt({memoryEnabled:e,reloadKey:n,onChanged:r,onOpenAdvanced:i,showToast:s}){let c=ee(),[u,d]=(0,S.useState)(null),[te,ne]=(0,S.useState)(null),[re,ie]=(0,S.useState)(null),[se,ce]=(0,S.useState)(``),[le,ue]=(0,S.useState)(``),[p,de]=(0,S.useState)([]),[fe,pe]=(0,S.useState)(new Set),[m,me]=(0,S.useState)(``),[h,ge]=(0,S.useState)(`fact`),[_e,ve]=(0,S.useState)(``),[ye,g]=(0,S.useState)(null),[xe,Se]=(0,S.useState)(0),[Ce,we]=(0,S.useState)(!1),Te=(0,S.useRef)(0),Ee=(0,S.useRef)(dt),_=(0,S.useCallback)(async e=>{let t=++Te.current,n=e??Ee.current;try{let e=[],r=new Set,i=0,a=0;for(;;){let o=Math.min(dt,n-e.length),s=await he({about_user:!0,include_sensitive:!0,sort_by:`updated_at`,order:`desc`,offset:i,limit:o});if(t!==Te.current)return;i+=s.items.length;for(let t of s.items)r.has(t.id)||(r.add(t.id),e.push(t));if(a=typeof s.total==`number`?s.total:e.length,s.items.length<o||e.length>=Math.min(n,a))break}Ee.current=n,d(e),Se(a),ne(null)}catch(e){if(t!==Te.current)return;o.system.warn(`Failed to load what GAIA knows about the user`,e),ne(e instanceof Error?e.message:String(e))}},[]);(0,S.useEffect)(()=>{_()},[_,n]);let ke=(0,S.useCallback)(async()=>{we(!0),Ee.current=Math.max(Ee.current,u?.length??0)+dt;try{await _()}finally{we(!1)}},[_,u]),Ae=(0,S.useCallback)(async e=>{let t=se.trim(),n=e.category===`reminder`&&!!le&&le!==_t(e.due_at);if(!t||t===e.content&&!n)ie(null);else{g(e.id);try{await ae(e.id,{...t===e.content?{}:{content:t},...n?{due_at:le}:{}}),ie(null),s(c(`mem.about.updated`),`success`),await _(),r()}catch(e){o.system.error(`Failed to edit memory`,e),s(c(`mem.about.editFailed`,{error:C(e)}),`error`)}finally{g(null)}}},[se,le,_,r,s,c]),v=(0,S.useCallback)(async e=>{g(e.id);try{await oe(e.id),Te.current++,d(t=>(t??[]).filter(t=>t.id!==e.id)),Se(e=>Math.max(e-1,0)),de(t=>[e,...t]),r()}catch(e){o.system.error(`Failed to forget memory`,e),s(c(`mem.about.forgetFailed`,{error:C(e)}),`error`)}finally{g(null)}},[r,s,c]),Me=(0,S.useCallback)(async e=>{g(e.id);try{await Xe({content:e.content,category:e.category,domain:e.domain??void 0,context:e.context,entity:e.entity??void 0,sensitive:e.sensitive,due_at:e.due_at??void 0}),de(t=>t.filter(t=>t.id!==e.id)),await _(),r()}catch(e){o.system.error(`Failed to restore memory`,e),s(c(`mem.about.restoreFailed`,{error:C(e)}),`error`)}finally{g(null)}},[_,r,s,c]),Ne=(0,S.useCallback)(async()=>{let e=m.trim(),t=h===`reminder`;if(!(!e||t&&!_e)){g(`new`);try{await Xe({content:e,category:h,...t?{due_at:_e}:{}}),me(``),ve(``),s(c(`mem.about.saved`),`success`),await _(),r()}catch(e){o.system.error(`Failed to add memory`,e),s(c(`mem.about.addFailed`,{error:C(e)}),`error`)}finally{g(null)}}},[m,h,_e,_,r,s,c]);if(!e)return f(`div`,{className:`mem-about`,children:[l(`h2`,{className:`mem-about-title`,children:c(`mem.about.title`)}),f(`div`,{className:`mem-about-empty`,children:[l(`p`,{children:c(`mem.about.off`)}),l(`button`,{className:`btn-secondary`,onClick:i,children:c(`mem.about.turnOn`)})]})]});let Pe=ft.map(e=>({...e,rows:(u??[]).filter(t=>e.categories.includes(t.category))})).filter(e=>e.rows.length>0);return f(`div`,{className:`mem-about`,children:[l(`h2`,{className:`mem-about-title`,children:c(`mem.about.title`)}),l(`p`,{className:`mem-about-intro`,children:c(`mem.about.intro`)}),f(`form`,{className:`mem-about-add`,onSubmit:e=>{e.preventDefault(),Ne()},children:[l(`input`,{className:`mem-input`,placeholder:c.bare(`mem.about.addPlaceholder`),"aria-label":c(`mem.about.addLabel`),value:m,onChange:e=>me(e.target.value)}),f(`select`,{className:`mem-select`,"aria-label":c(`mem.about.kind`),value:h,onChange:e=>ge(e.target.value),children:[l(`option`,{value:`fact`,children:c.bare(`mem.about.group.about`)}),l(`option`,{value:`preference`,children:c.bare(`mem.about.kind.preference`)}),l(`option`,{value:`reminder`,children:c.bare(`mem.about.kind.reminder`)}),l(`option`,{value:`note`,children:c.bare(`mem.about.kind.note`)})]}),h===`reminder`&&l(`input`,{type:`datetime-local`,className:`mem-input mem-about-when`,"aria-label":c(`mem.about.when`),value:_e,onChange:e=>ve(e.target.value)}),f(`button`,{className:`btn-primary`,type:`submit`,disabled:!m.trim()||h===`reminder`&&!_e||ye===`new`,children:[l(je,{size:14}),` `,c(`mem.about.add`)]})]}),p.map(e=>f(`div`,{className:`mem-about-forgotten`,role:`status`,children:[l(`span`,{title:e.sensitive?void 0:e.content,children:e.sensitive?c(`mem.about.forgottenSensitive`):c(`mem.about.forgotten`,{content:bt(e.content)})}),f(`button`,{className:`mem-about-link`,disabled:ye===e.id,onClick:()=>Me(e),children:[l(Oe,{size:12}),` `,c(`mem.about.undo`)]})]},e.id)),te?f(`div`,{className:`mem-about-empty`,children:[l(`p`,{children:c(`mem.about.loadFailed`,{error:te})}),l(`button`,{className:`btn-secondary`,onClick:()=>_(),children:c(`mem.about.retry`)})]}):u===null?f(`div`,{className:`mem-loading`,children:[l(`div`,{className:`mem-spinner`}),` `,c(`mem.loading`)]}):Pe.length===0?f(`div`,{className:`mem-about-empty`,children:[l(`p`,{children:c(`mem.about.empty`)}),l(`p`,{className:`mem-about-hint`,children:c(`mem.about.emptyHint`)})]}):Pe.map(e=>f(`section`,{className:`mem-about-group`,"aria-label":c(e.title),children:[l(`h3`,{className:`mem-about-group-title`,children:c(e.title)}),l(`ul`,{className:`mem-about-list`,children:e.rows.map(e=>{let n=e.sensitive&&!fe.has(e.id),r=e.due_at?vt(e.due_at,new Date,c):null,i=ht(e.updated_at,c),o=n?t(`mem.about.sensitiveMemory`):e.content;return l(`li`,{className:`mem-about-item`,children:re===e.id?f(`form`,{className:`mem-about-edit`,onSubmit:t=>{t.preventDefault(),Ae(e)},children:[l(`textarea`,{className:`mem-input`,"aria-label":c(`mem.about.editLabel`),rows:2,autoFocus:!0,value:se,onChange:e=>ce(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.stopPropagation(),ie(null)),t.key===`Enter`&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),Ae(e))}}),e.category===`reminder`&&l(`input`,{type:`datetime-local`,className:`mem-input mem-about-when`,"aria-label":c(`mem.about.when`),value:le,onChange:e=>ue(e.target.value)}),f(`div`,{className:`mem-about-edit-actions`,children:[l(`button`,{className:`btn-primary`,type:`submit`,disabled:ye===e.id,children:c(`mem.about.save`)}),l(`button`,{className:`btn-secondary`,type:`button`,onClick:()=>ie(null),children:c(`mem.about.cancel`)})]})]}):f(a.Fragment,{children:[f(`div`,{className:`mem-about-text`,children:[n?f(`button`,{className:`mem-about-link`,onClick:()=>pe(t=>new Set(t).add(e.id)),children:[l(qe,{size:12}),` `,c(`mem.about.showSensitive`)]}):l(`bdi`,{children:e.content}),r&&l(`span`,{className:`mem-about-due${r.past?` is-overdue`:``}`,children:r.text}),l(`span`,{className:`mem-about-meta`,children:i===null?c(mt(e.source)):c(`mem.about.meta`,{source:t(mt(e.source)),when:i})})]}),f(`div`,{className:`mem-about-actions`,children:[l(`button`,{className:`mem-about-btn`,"aria-label":c(`mem.about.editAria`,{name:o}),title:c(n?`mem.about.editHidden`:`mem.about.edit`),disabled:n,onClick:()=>{ie(e.id),ce(e.content),ue(_t(e.due_at))},children:l(be,{size:14})}),f(`button`,{className:`mem-about-btn mem-about-btn-remove`,"aria-label":c(`mem.about.forgetAria`,{name:o}),title:c(`mem.about.forget`),disabled:ye===e.id,onClick:()=>v(e),children:[l(De,{size:14}),` `,c(`mem.about.forget`)]})]})]})},e.id)})})]},e.title)),!te&&u!==null&&u.length<xe&&f(`div`,{className:`mem-about-more`,children:[l(`span`,{children:c(`mem.about.showing`,{shown:u.length,total:xe})}),l(`button`,{className:`btn-secondary`,disabled:Ce,onClick:ke,children:c(`mem.about.showMore`)})]})]})}function C(e){return e instanceof Error?e.message:String(e)}function bt(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=80?t:`${t.slice(0,79).trimEnd()}…`}function xt(e,t){if(!e)return`—`;try{let n=new Date(e);if(isNaN(n.getTime()))return`—`;let r={month:`short`,day:`numeric`};return n.getFullYear()!==new Date().getFullYear()&&(r.year=`numeric`),n.toLocaleDateString(t,r)}catch{return`—`}}function w(e,t){if(!e)return``;try{let n=new Date(e);return isNaN(n.getTime())?``:n.toLocaleString(t,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function T(e,t){if(!e)return`—`;try{let n=new Date(e);if(isNaN(n.getTime()))return`—`;let r=Date.now(),i=n.getTime()-r,a=Math.abs(i),o=Math.floor(a/1e3),s=Math.floor(a/6e4),c=Math.floor(a/36e5),l=Math.floor(a/864e5);return i<0?o<5?t(`time.justNow`):o<60?t(`mem.rel.secondsAgo`,{n:o}):c===0?t(`time.minutesAgo`,{n:s}):l===0?t(`time.hoursAgo`,{n:c}):l===1?t(`time.yesterday`):l<30?t(`time.daysAgo`,{n:l}):w(e,d(t)):o<5?t(`mem.rel.now`):o<60?t(`mem.rel.inSeconds`,{n:o}):c===0?t(`mem.rel.inMinutes`,{n:s}):l===0?t(`mem.rel.inHours`,{n:c}):l===1?t(`mem.rel.tomorrow`):l<30?t(`mem.rel.inDays`,{n:l}):w(e,d(t))}catch{return`—`}}function St(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function Ct(e){try{return new Date(e).getTime()<Date.now()}catch{return!1}}function wt(e){return e>=.7?`high`:e>=.4?`medium`:`low`}function Tt(e){return e>=.9?`high`:e>=.7?`medium`:`low`}function Et(e,t,n){let r=xt(e,n),i=xt(t,n);return r===`—`&&i===`—`?``:r===i?r:`${r} \u2013 ${i}`}function Dt(e){if(e.length===0)return 0;let t=new Date().toISOString().slice(0,10),n=e.find(e=>e.date===t);return n?n.knowledge_added:0}var Ot=[`fact`,`preference`,`error`,`skill`,`note`,`reminder`],kt={fact:`mem.cat.fact`,preference:`mem.cat.preference`,error:`mem.cat.error`,skill:`mem.cat.skill`,note:`mem.cat.note`,reminder:`mem.cat.reminder`},At={pending_approval:`mem.status.pending_approval`,queued:`mem.status.queued`,in_progress:`mem.status.in_progress`,completed:`mem.status.completed`,failed:`mem.status.failed`,rejected:`mem.status.rejected`,cancelled:`mem.status.cancelled`,blocked:`mem.status.blocked`},jt={low:`mem.priority.low`,medium:`mem.priority.medium`,high:`mem.priority.high`},Mt={agent_inferred:`mem.goals.source.agent_inferred`,agent_scheduled:`mem.goals.source.agent_scheduled`},Nt={user:`mem.role.user`,assistant:`mem.role.assistant`},Pt={work:`mem.domain.work`,technical:`mem.domain.technical`,personal:`mem.domain.personal`,general:`mem.domain.general`},Ft={...Pt,global:`mem.context.global`};function E({value:e,keys:t}){let n=ee(),r=t[e];return r?l(a.Fragment,{children:n(r)}):l(`bdi`,{children:e})}function D(e){return e instanceof Error?e.message:String(e)}var It={work:`blue`,technical:`purple`,personal:`green`,general:`gray`};function Lt(){let e=ee(),{setShowMemoryDashboard:r,sessions:s,setCurrentSession:c}=i(),Oe=(0,S.useMemo)(()=>new Map(s.map(e=>[e.id,e.title])),[s]),nt=e=>Oe.get(e)||`${e.slice(0,8)}...`,[y,at]=(0,S.useState)(null),[b,ct]=(0,S.useState)([]),[x,dt]=(0,S.useState)(null),[ft,mt]=(0,S.useState)([]),[ht,gt]=(0,S.useState)([]),[_t,vt]=(0,S.useState)([]),[C,bt]=(0,S.useState)(null),[xt,Lt]=(0,S.useState)([]),[Rt,zt]=(0,S.useState)(!0),[Bt,Vt]=(0,S.useState)(!1),[Ht,Ut]=(0,S.useState)(null),[Wt,O]=(0,S.useState)(!1),[Gt,Kt]=(0,S.useState)(null),[qt,Jt]=(0,S.useState)([]),Yt=(0,S.useRef)(0),[k,Xt]=(0,S.useState)([]),[Zt,Qt]=(0,S.useState)(``),[$t,en]=(0,S.useState)(``),[tn,nn]=(0,S.useState)(``),[A,rn]=(0,S.useState)(`updated_at`),[an,on]=(0,S.useState)(`desc`),[j,M]=(0,S.useState)(0),[sn,cn]=(0,S.useState)(!1),[ln,un]=(0,S.useState)(``),[dn,fn]=(0,S.useState)(null),pn=(0,S.useRef)(null),[N,mn]=(0,S.useState)(null),[hn,gn]=(0,S.useState)(!1),[P,_n]=(0,S.useState)(null),[F,I]=(0,S.useState)({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),[L,vn]=(0,S.useState)(new Set),[R,yn]=(0,S.useState)(!1),[bn,xn]=(0,S.useState)(!1),[Sn,Cn]=(0,S.useState)(!1),[z,B]=(0,S.useState)(!1),[wn,Tn]=(0,S.useState)(!1),[V,En]=(0,S.useState)(null),[Dn,On]=(0,S.useState)(!1),[kn,H]=(0,S.useState)(null),[U,An]=(0,S.useState)(`about`),[jn,Mn]=(0,S.useState)(0),[Nn,Pn]=(0,S.useState)([]),[Fn,In]=(0,S.useState)(null),[Ln,Rn]=(0,S.useState)(!1),zn=Ge(e=>e.error),Bn=Ge(e=>e.damaged),[Vn,Hn]=(0,S.useState)(null),[Un,Wn]=(0,S.useState)(null),[Gn,Kn]=(0,S.useState)(!1),[qn,Jn]=(0,S.useState)(null),[Yn,Xn]=(0,S.useState)(null),[Zn,Qn]=(0,S.useState)(!1),[W,$n]=(0,S.useState)({title:``,description:``,priority:`medium`}),[G,er]=(0,S.useState)(`idle`),[tr,K]=(0,S.useState)([]),[q,nr]=(0,S.useState)([]),[rr,ir]=(0,S.useState)(null),[ar,or]=(0,S.useState)(new Set),sr=(0,S.useRef)(null),cr=(0,S.useRef)(null),[J,lr]=(0,S.useState)(`idle`),[ur,dr]=(0,S.useState)([]),[fr,pr]=(0,S.useState)([]),[mr,hr]=(0,S.useState)(null),[gr,_r]=(0,S.useState)(!1),vr=(0,S.useRef)(null),yr=(0,S.useRef)(null),[br,xr]=(0,S.useState)(30),[Sr,Cr]=(0,S.useState)(!1),[wr,Tr]=(0,S.useState)(!1),[Er,Dr]=(0,S.useState)(!1),[Or,kr]=(0,S.useState)(!1),[Ar,jr]=(0,S.useState)(!1),[Mr,Nr]=(0,S.useState)(!1),Pr=(0,S.useRef)(null),Fr=(0,S.useRef)(null),Ir=(0,S.useRef)(null),Y=(0,S.useCallback)((e,t=`info`)=>{let n=++Yt.current;Jt(r=>[...r,{id:n,text:e,type:t}]),setTimeout(()=>{Jt(e=>e.filter(e=>e.id!==n))},4e3)},[]);(0,S.useEffect)(()=>{if(!Wt)return;let e=e=>{Fr.current&&!Fr.current.contains(e.target)&&O(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Wt]),n(!0,()=>{kn?H(null):wn?Tn(!1):Dn?On(!1):N?mn(null):Wt?O(!1):hn||P?(gn(!1),_n(null)):Gt?Kt(null):r(!1)}),u(Ir,!!kn),(0,S.useEffect)(()=>{if(!kn)return;let e=Ir.current;if(!e)return;let t=document.activeElement;return e.focus(),()=>{t?.focus()}},[kn]);let Lr=(0,S.useCallback)(async()=>{try{let e=await de();at(e)}catch(e){o.system.warn(`Failed to load memory stats`,e)}},[]),Rr=(0,S.useCallback)(async()=>{try{let e=await ge(br);ct(e)}catch(e){o.system.warn(`Failed to load memory activity`,e)}},[br]),X=(0,S.useCallback)(async()=>{try{let e=await he({category:k.length>0?k:void 0,context:Zt||void 0,entity:$t||void 0,search:tn||void 0,sort_by:A,order:an,offset:j,limit:15,include_sensitive:!0,include_superseded:sn});dt(e)}catch(e){o.system.warn(`Failed to load knowledge`,e)}},[k,Zt,$t,tn,A,an,j,sn]),zr=(0,S.useCallback)(async()=>{try{let e=await me();mt(e)}catch(e){o.system.warn(`Failed to load tool summary`,e)}},[]),Br=(0,S.useCallback)(async()=>{try{let e=await ye(20);gt(e)}catch(e){o.system.warn(`Failed to load conversations`,e)}},[]),Vr=(0,S.useCallback)(async()=>{try{let e=await g(7);vt(e)}catch(e){o.system.warn(`Failed to load upcoming items`,e)}},[]),Hr=(0,S.useCallback)(async()=>{try{let e=await Be();bt(e)}catch(e){o.system.warn(`Failed to load embedding coverage`,e)}},[]),Ur=(0,S.useCallback)(async()=>{try{let e=await te();Lt(e||[])}catch(e){o.system.warn(`Failed to load entities`,e)}},[]),Wr=(0,S.useCallback)(async()=>{try{let e=await ce();xn(e.mcp_memory_enabled),yn(e.memory_enabled),Cn(e.system_discovery_consent)}catch(e){o.system.warn(`Failed to load memory settings`,e)}},[]),Z=(0,S.useCallback)(async()=>{Rn(!0),Ge.getState().check();try{let[e,t]=await Promise.all([et(),ze()]);Pn(e.goals),In(t),Hn(null)}catch(e){o.system.warn(`Failed to load goals`,e),Hn(D(e))}finally{Rn(!1)}},[]),Gr=(0,S.useCallback)(async(n,r)=>{try{await n()}catch(n){o.system.error(`Goal action failed (${r})`,n),Y(e(`mem.goals.failed`,{what:t(r),error:D(n)}),`error`);return}Z()},[Z,Y,e]),Kr=(0,S.useCallback)(async()=>{if(W.title.trim()){Wn(null);try{await ie(W)}catch(n){o.system.error(`Goal create failed`,n),Wn(e(`mem.goals.failed`,{what:t(`mem.goals.createFailed`),error:D(n)}));return}$n({title:``,description:``,priority:`medium`}),Qn(!1),Z()}},[W,Z,e]);(0,S.useEffect)(()=>{zn||Wn(null)},[zn]);let qr=(0,S.useCallback)(async()=>{Kn(!0);try{let{kept:t}=await fe();Y(e(`mem.goals.newListStarted`,{file:t}),`success`)}catch(n){o.system.error(`Starting a new goal list failed`,n),Y(e(`mem.goals.failed`,{what:t(`mem.goals.startNewListFailed`),error:D(n)}),`error`)}finally{Kn(!1)}Z()},[Z,Y,e]);(0,S.useEffect)(()=>{if(!Yn)return;let e=setTimeout(()=>Xn(null),3e3);return()=>clearTimeout(e)},[Yn]);let Q=(0,S.useCallback)(async()=>{zt(!0),Vt(!1);try{await Promise.all([Lr(),Rr(),X(),zr(),Br(),Vr(),Hr(),Ur(),Wr(),Z()]),Mn(e=>e+1)}catch(e){Vt(!0),o.system.error(`Memory dashboard load failed`,e)}finally{zt(!1)}},[Lr,Rr,X,zr,Br,Vr,Hr,Ur,Wr,Z]);(0,S.useEffect)(()=>{Q()},[Q]),(0,S.useEffect)(()=>{X()},[X]);let Jr=(0,S.useRef)(!0);(0,S.useEffect)(()=>{Jr.current?Jr.current=!1:Rr()},[Rr]);let Yr=(0,S.useCallback)(e=>{nn(e),Nr(!0),Pr.current&&clearTimeout(Pr.current),Pr.current=setTimeout(()=>{M(0),Nr(!1)},300)},[]),Xr=(0,S.useCallback)(()=>{X(),Lr(),Hr(),Vr(),Ur()},[X,Lr,Hr,Vr,Ur]),$=(0,S.useCallback)(()=>{Xr(),Mn(e=>e+1)},[Xr]),Zr=(0,S.useCallback)(async()=>{if(F.content.trim())try{let t=await Xe({content:F.content,category:F.category,domain:F.domain||void 0,context:F.context,entity:F.entity||void 0,sensitive:F.sensitive,due_at:F.due_at||void 0});gn(!1),I({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),$(),o.ui.info(`Created new knowledge entry`),t?.embedded===!1?Y(t.embed_error?e(`mem.toast.server`,{message:t.embed_error}):e(`mem.toast.notEmbedded`),`error`):Y(e(`mem.toast.created`),`success`)}catch(t){o.system.error(`Failed to create knowledge`,t),Y(e(`mem.toast.createFailed`,{error:D(t)}),`error`)}},[F,$,Y,e]),Qr=(0,S.useCallback)(async()=>{if(P&&F.content.trim())try{let t=await ae(P,{content:F.content,category:F.category,domain:F.domain||void 0,context:F.context,entity:F.entity||void 0,sensitive:F.sensitive,due_at:F.due_at||void 0});_n(null),I({content:``,category:`fact`,domain:``,context:`global`,entity:``,sensitive:!1,due_at:``}),$(),o.ui.info(`Updated knowledge ${P}`),t?.embedded===!1?Y(t.embed_error?e(`mem.toast.server`,{message:t.embed_error}):e(`mem.toast.notEmbedded`),`error`):Y(e(`mem.toast.updated`),`success`)}catch(t){o.system.error(`Failed to update knowledge`,t),Y(e(`mem.toast.updateFailed`,{error:D(t)}),`error`)}},[P,F,$,Y,e]),$r=(0,S.useCallback)(async t=>{if(V!==t)En(t);else{En(null);try{await oe(t),$(),o.ui.info(`Deleted knowledge ${t}`),Y(e(`mem.toast.deleted`),`info`)}catch(t){o.system.error(`Failed to delete knowledge`,t),Y(e(`mem.toast.deleteFailed`,{error:D(t)}),`error`)}}},[V,$,Y,e]);(0,S.useEffect)(()=>{if(!V)return;let e=setTimeout(()=>En(null),3e3);return()=>clearTimeout(e)},[V]);let ei=(0,S.useCallback)(async t=>{try{await ae(t.id,{sensitive:!t.sensitive}),!t.sensitive&&P===t.id&&!L.has(t.id)&&(_n(null),I(e=>({...e,content:``}))),X(),o.ui.info(`Toggled sensitive for ${t.id}: ${!t.sensitive}`),Y(e(t.sensitive?`mem.toast.unmarkedSensitive`:`mem.toast.markedSensitive`),`info`)}catch(t){o.system.error(`Failed to toggle sensitive`,t),Y(e(`mem.toast.sensitiveFailed`,{error:D(t)}),`error`)}},[X,Y,e,P,L]),ti=(0,S.useCallback)(e=>{(!e.sensitive||L.has(e.id))&&(_n(e.id),gn(!1),I({content:e.content,category:e.category,domain:e.domain||``,context:e.context,entity:e.entity||``,sensitive:e.sensitive,due_at:e.due_at||``}))},[L]),ni=(0,S.useCallback)(e=>{let t=L.has(e.id);vn(n=>{let r=new Set(n);return t?r.delete(e.id):r.add(e.id),r}),t&&P===e.id&&(_n(null),I(e=>({...e,content:``})))},[L,P]),ri=(0,S.useCallback)(t=>{navigator.clipboard.writeText(t).then(()=>Y(e(`mem.toast.idCopied`),`info`),n=>{o.ui.warn(`Couldn't copy knowledge ID ${t}`,n),Y(e(`mem.toast.copyFailed`,{error:D(n)}),`error`)})},[Y,e]),ii=(0,S.useCallback)(e=>{un(e),pn.current&&clearTimeout(pn.current),e.trim()?pn.current=setTimeout(async()=>{try{let t=await Me(e.trim(),20);fn(t)}catch(e){o.system.warn(`Conversation search failed`,e)}},300):fn(null)},[]),ai=(0,S.useCallback)(async e=>{try{let t=await _e(e);mn({sessionId:e,turns:t})}catch(e){o.system.error(`Failed to load conversation detail`,e)}},[]),oi=(0,S.useCallback)(e=>{Xt(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),M(0)},[]),si=(0,S.useCallback)(e=>{A===e?on(e=>e===`desc`?`asc`:`desc`):(rn(e),on(`desc`)),M(0)},[A]),ci=(0,S.useCallback)(async()=>{Cr(!0),O(!1);try{let t=await Se();await Q(),Y(e(`mem.toast.consolidated`,{sessions:t.consolidated??0,items:t.extracted_items??0}),`success`)}catch(t){o.system.error(`Failed to consolidate sessions`,t),Y(e(`mem.toast.consolidateFailed`,{error:D(t)}),`error`)}finally{Cr(!1)}},[Q,Y,e]),li=(0,S.useCallback)(async()=>{Tr(!0),O(!1);try{let t=await ue();await Hr(),Y(t.total_without?e(`mem.toast.backfilledMissing`,{n:t.backfilled??0,missing:t.total_without}):e(`mem.toast.backfilled`,{n:t.backfilled??0}),`success`)}catch(t){o.system.error(`Failed to rebuild embeddings`,t),Y(e(`mem.toast.rebuildFailed`,{error:D(t)}),`error`)}finally{Tr(!1)}},[Hr,Y,e]),ui=(0,S.useCallback)(async()=>{Dr(!0),O(!1);try{let t=await ke();await Q(),Y(e(`mem.toast.reconciled`,{pairs:t.pairs_checked??0,reinforced:t.reinforced??0,contradicted:t.contradicted??0}),`success`)}catch(t){o.system.error(`Failed to reconcile memory`,t),Y(e(`mem.toast.reconcileFailed`,{error:D(t)}),`error`)}finally{Dr(!1)}},[Q,Y,e]),di=(0,S.useCallback)(async()=>{kr(!0),O(!1);try{await Ee(),await Q(),Y(e(`mem.toast.ftsRebuilt`),`success`)}catch(t){o.system.error(`Failed to rebuild FTS index`,t),Y(e(`mem.toast.ftsFailed`,{error:D(t)}),`error`)}finally{kr(!1)}},[Q,Y,e]),fi=(0,S.useCallback)(async()=>{jr(!0),O(!1);try{let t=await le();await Q(),t.skipped?Y(e(`mem.toast.systemDisabled`),`error`):Y(e(`mem.toast.systemRefreshed`,{n:t.stored}),`success`)}catch(t){o.system.error(`Failed to refresh system context`,t),Y(e(`mem.toast.systemFailed`,{error:D(t)}),`error`)}finally{jr(!1)}},[Q,Y,e]),pi=Sr||wr||Er||Or||Ar,mi=(0,S.useCallback)(()=>{er(`running`),K([]),nr([]),or(new Set),ir(null);let t=re();cr.current=t,t.onmessage=n=>{try{let r=JSON.parse(n.data);if(r.type===`log`)K(e=>[...e,{text:r.message,kind:`log`,server:!0}]);else if(r.type===`finding`){let t=r.item,n=t.sensitive?e(`mem.log.foundSensitive`):e.bare(`mem.log.found`,{content:t.content});K(e=>[...e,{text:n,kind:`finding`}]),nr(e=>[...e,{...t,_checked:!0}])}else r.type===`error`?K(t=>[...t,{text:e.bare(`mem.log.error`,{message:r.message}),kind:`error`}]):r.type===`done`&&(t.close(),cr.current=null,K(t=>[...t,{text:e(`mem.log.discoveryDone`,{n:r.total??0}),kind:`log`}]),er(`review`))}catch(t){o.system.warn(`Unreadable discovery event`,t),K(t=>[...t,{text:e(`mem.log.parseFailed`),kind:`error`}])}},t.onerror=()=>{t.close(),cr.current=null,K(t=>[...t,{text:e(`mem.log.discoveryConnection`),kind:`error`}]),nr(e=>(er(e.length>0?`review`:`idle`),e))}},[e]),hi=(0,S.useCallback)(async()=>{let t=q.filter(e=>e._checked);if(t.length!==0){er(`saving`);try{let n=t.map(({_checked:e,...t})=>t),r=await Ie(n);ir(r.stored),er(`done`),$(),Y(e(`mem.disc.saved`,{n:r.stored}),`success`)}catch(t){o.system.error(`Failed to commit discovery items`,t),Y(e(`mem.disc.saveFailed`,{error:D(t)}),`error`),er(`review`)}}},[q,$,Y,e]),gi=(0,S.useCallback)(()=>{lr(`running`),dr([]),pr([]),hr(null);let t=_(gr);yr.current=t,t.onmessage=n=>{try{let r=JSON.parse(n.data);if(r.type===`log`)dr(e=>[...e,{text:r.message,kind:`log`,server:!0}]);else if(r.type===`insight`){let t=r.item;dr(n=>[...n,{text:e.bare(`mem.log.insight`,{content:t.content}),kind:`finding`}]),pr(e=>[...e,{...t,_checked:!0}])}else r.type===`error`?dr(t=>[...t,{text:e.bare(`mem.log.error`,{message:r.message}),kind:`error`}]):r.type===`done`&&(t.close(),yr.current=null,dr(t=>[...t,{text:e(`mem.log.inferenceDone`,{n:r.total??0}),kind:`log`}]),lr(`review`))}catch(t){o.system.warn(`Unreadable inference event`,t),dr(t=>[...t,{text:e(`mem.log.parseFailed`),kind:`error`}])}},t.onerror=()=>{t.close(),yr.current=null,dr(t=>[...t,{text:e(`mem.log.inferenceConnection`),kind:`error`}]),pr(e=>(lr(e.length>0?`review`:`idle`),e))}},[gr,e]),_i=(0,S.useCallback)(async()=>{let t=fr.filter(e=>e._checked);if(t.length!==0){lr(`saving`);try{let n=t.map(({_checked:e,...t})=>t),r=await Qe(n);hr(r.stored),lr(`done`),$(),Y(e(`mem.inf.saved`,{n:r.stored}),`success`)}catch(t){o.system.error(`Failed to commit inference insights`,t),Y(e(`mem.inf.saveFailed`,{error:D(t)}),`error`),lr(`review`)}}},[fr,$,Y,e]);(0,S.useEffect)(()=>{sr.current&&(sr.current.scrollTop=sr.current.scrollHeight)},[tr]),(0,S.useEffect)(()=>{vr.current&&(vr.current.scrollTop=vr.current.scrollHeight)},[ur]),(0,S.useEffect)(()=>()=>{cr.current&&=(cr.current.close(),null),yr.current&&=(yr.current.close(),null)},[]);let vi=e=>A===e?l(`span`,{className:`mem-sort-arrow`,children:an===`desc`?`↓`:`↑`}):null,yi=Math.max(1,...b.map(e=>e.conversations+e.tool_calls+e.knowledge_added+e.errors)),bi=y?.knowledge?.by_context?Object.keys(y.knowledge.by_context):[];return f(`div`,{className:`memory-dashboard-page`,children:[f(`div`,{className:`memory-dashboard-header`,children:[f(`div`,{className:`memory-dashboard-header-left`,children:[l(`button`,{className:`btn-icon settings-back-btn`,onClick:()=>r(!1),"aria-label":e(`mem.back`),children:l(ne,{size:18})}),f(`h1`,{children:[e(`mem.title`),` `,l(`span`,{className:`mem-beta`,style:{fontSize:11,fontWeight:500,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`2px 8px`,borderRadius:4,marginInlineStart:8,verticalAlign:`middle`,whiteSpace:`nowrap`},children:e(`mem.beta`)})]})]}),f(`div`,{className:`memory-dashboard-header-actions`,children:[U===`advanced`&&f(a.Fragment,{children:[C&&C.total_items>0&&f(`div`,{className:`mem-embedding-coverage`,title:e(`mem.coverage.title`,{n:C.with_embedding,total:C.total_items}),children:[l(`div`,{className:`mem-embedding-bar`,children:l(`div`,{className:`mem-embedding-fill`,style:{width:`${Math.round(C.coverage_pct)}%`}})}),l(`span`,{className:`mem-embedding-label`,children:e(`mem.coverage.label`,{pct:`${Math.round(C.coverage_pct)}%`})})]}),f(`div`,{className:`mem-maintenance-wrap`,ref:Fr,children:[f(`button`,{className:`btn-icon ${pi?`mem-spinning`:``}`,onClick:()=>O(e=>!e),title:e(`mem.maint.label`),"aria-label":e(`mem.maint.label`),"aria-expanded":Wt,children:[pi?l(`div`,{className:`mem-spinner-sm`}):l(Ve,{size:16}),l(se,{size:10,style:{marginInlineStart:2}})]}),Wt&&f(`div`,{className:`mem-maintenance-menu`,role:`menu`,children:[f(`button`,{className:`mem-maintenance-item`,onClick:ci,disabled:Sr,role:`menuitem`,children:[l(rt,{size:14}),e(Sr?`mem.maint.consolidating`:`mem.maint.consolidate`)]}),f(`button`,{className:`mem-maintenance-item`,onClick:li,disabled:wr,role:`menuitem`,children:[l(h,{size:14}),e(wr?`mem.maint.rebuilding`:`mem.maint.rebuildEmbeddings`)]}),f(`button`,{className:`mem-maintenance-item`,onClick:ui,disabled:Er,role:`menuitem`,children:[l(Ce,{size:14}),e(Er?`mem.maint.reconciling`:`mem.maint.reconcile`)]}),l(`div`,{className:`mem-maintenance-divider`}),f(`button`,{className:`mem-maintenance-item`,onClick:fi,disabled:Ar,role:`menuitem`,children:[l(Ne,{size:14}),e(Ar?`mem.maint.refreshing`:`mem.maint.refreshSystem`)]}),l(`div`,{className:`mem-maintenance-divider`}),f(`button`,{className:`mem-maintenance-item`,onClick:di,disabled:Or,role:`menuitem`,children:[l(m,{size:14}),e(Or?`mem.maint.rebuilding`:`mem.maint.rebuildFts`)]})]})]})]}),l(`button`,{className:`btn-icon`,onClick:Q,title:e(`mem.refresh`),"aria-label":e(`mem.refreshAria`),children:l(Ne,{size:16})})]})]}),f(`div`,{className:`mem-tab-bar`,role:`tablist`,children:[f(`button`,{className:`mem-tab-btn${U===`about`?` mem-tab-active`:``}`,onClick:()=>An(`about`),role:`tab`,"aria-selected":U===`about`,children:[l(ut,{size:14}),` `,e(`mem.tab.about`)]}),f(`button`,{className:`mem-tab-btn${U===`goals`?` mem-tab-active`:``}`,onClick:()=>{An(`goals`),Z()},role:`tab`,"aria-selected":U===`goals`,children:[l(st,{size:14}),` `,e(`mem.tab.goals`),Fn&&(Fn.goals.pending_approval??0)>0&&l(`span`,{className:`mem-tab-badge`,children:Fn.goals.pending_approval})]}),f(`button`,{className:`mem-tab-btn${U===`profile`?` mem-tab-active`:``}`,onClick:()=>An(`profile`),role:`tab`,"aria-selected":U===`profile`,children:[l(Ae,{size:14}),` `,e(`mem.tab.profile`)]}),f(`button`,{className:`mem-tab-btn${U===`advanced`?` mem-tab-active`:``}`,onClick:()=>An(`advanced`),role:`tab`,"aria-selected":U===`advanced`,children:[l(ve,{size:14}),` `,e(`mem.tab.advanced`)]})]}),f(`div`,{className:`memory-dashboard-body`,children:[U===`about`&&l(yt,{memoryEnabled:R,reloadKey:jn,onChanged:Xr,onOpenAdvanced:()=>An(`advanced`),showToast:Y}),U===`advanced`&&l(a.Fragment,{children:Rt&&!y?f(`div`,{className:`mem-loading`,children:[l(`div`,{className:`mem-spinner`}),e(`mem.loadingData`)]}):Bt?f(`div`,{className:`mem-empty`,children:[l(`div`,{className:`mem-empty-icon`,children:l(p,{size:32})}),l(`p`,{children:e(`mem.loadFailed`)}),f(`button`,{className:`btn-secondary`,onClick:Q,style:{marginTop:12},children:[l(Ne,{size:14}),` `,e(`mem.retry`)]})]}):f(a.Fragment,{children:[!R&&f(`div`,{className:`mem-empty-state`,style:{margin:`40px 0`},children:[l(`div`,{className:`mem-empty-icon`,style:{opacity:.5},children:l(ot,{size:32})}),l(`p`,{style:{color:`var(--text-secondary)`,fontSize:14},children:e(`mem.offAdvanced`)})]}),R&&f(a.Fragment,{children:[y?.embedding_error&&f(`div`,{className:`mem-advanced-error`,role:`alert`,children:[l(p,{size:14}),` `,l(`bdi`,{children:y.embedding_error})]}),f(`div`,{className:`mem-stat-cards`,children:[f(`div`,{className:`mem-stat-card`,children:[l(`div`,{className:`mem-stat-value`,children:y?.knowledge?.total??0}),l(`div`,{className:`mem-stat-label`,children:e(`mem.stat.stored`)}),l(`div`,{className:`mem-stat-sub`,children:(()=>{let n=Dt(b);return n>0?e(`mem.stat.addedToday`,{n}):y?.knowledge?.by_category?e.compose(e=>Object.entries(y.knowledge.by_category).slice(0,3).map(([n,r])=>e(`mem.stat.categoryCount`,{category:kt[n]?t(kt[n]):n,n:r})).join(e(`mem.listSeparator`))):e(`mem.stat.noEntries`)})()})]}),f(`div`,{className:`mem-stat-card`,children:[l(`div`,{className:`mem-stat-value`,children:y?.knowledge?.total_retrievals??0}),l(`div`,{className:`mem-stat-label`,children:e(`mem.stat.retrieved`)}),l(`div`,{className:`mem-stat-sub`,children:y?.knowledge?.total&&y?.knowledge?.total_retrievals?e(`mem.stat.avgRecall`,{n:(y.knowledge.total_retrievals/y.knowledge.total).toFixed(1)}):e(`mem.stat.noRecalls`)})]}),f(`div`,{className:`mem-stat-card`,children:[l(`div`,{className:`mem-stat-value`,children:y?.conversations?.total_sessions??0}),l(`div`,{className:`mem-stat-label`,children:e(`mem.stat.sessions`)}),l(`div`,{className:`mem-stat-sub`,children:Et(y?.conversations?.first_session??null,y?.conversations?.last_session??null,d(e))||e(`mem.stat.totalTurns`,{n:y?.conversations?.total_turns??0})})]}),f(`div`,{className:`mem-stat-card`,children:[l(`div`,{className:`mem-stat-value`,children:y?.tools?.total_calls??0}),l(`div`,{className:`mem-stat-label`,children:e(`mem.stat.toolCalls`)}),l(`div`,{className:`mem-stat-sub`,title:e(`mem.stat.toolsNotLogged`),children:e(`mem.stat.toolsExclMemory`,{n:y?.tools?.unique_tools??0})})]}),f(`div`,{className:`mem-stat-card`,children:[l(`div`,{className:`mem-stat-value`,children:y?.tools?.overall_success_rate!=null&&(y.tools.total_calls??0)>0?`${Math.round(y.tools.overall_success_rate*100)}%`:`—`}),l(`div`,{className:`mem-stat-label`,children:e(`mem.stat.successRate`)}),l(`div`,{className:`mem-stat-sub`,children:(y?.tools?.total_calls??0)>0?e(`mem.stat.errors`,{n:y?.tools?.total_errors??0}):e(`mem.stat.noToolCalls`)})]})]}),f(`div`,{className:`mem-section`,children:[f(`div`,{className:`mem-section-title mem-section-title-row`,children:[f(`span`,{className:`mem-section-title-left`,children:[l(lt,{size:14}),` `,e(`mem.activity.title`)]}),l(`div`,{className:`mem-range-tabs`,role:`group`,"aria-label":e(`mem.activity.range`),children:[1,7,30].map(t=>l(`button`,{className:`mem-range-tab${br===t?` active`:``}`,onClick:()=>xr(t),children:e(t===1?`mem.activity.day1`:t===7?`mem.activity.days7`:`mem.activity.days30`)},t))})]}),b.length>0?f(a.Fragment,{children:[l(`div`,{className:`mem-activity-chart`,children:b.map((t,n)=>{let r=t.conversations+t.tool_calls+t.knowledge_added+t.errors,i=n===0||n===b.length-1||n%7==0,o=new Date(t.date+`T00:00:00`).toLocaleDateString(d(e),{month:`short`,day:`numeric`});return f(`div`,{className:`mem-activity-bar-group`,onMouseEnter:()=>Ut(n),onMouseLeave:()=>Ut(null),children:[t.errors>0&&l(`div`,{className:`mem-activity-bar errors`,style:{height:`${t.errors/yi*100}%`}}),t.knowledge_added>0&&l(`div`,{className:`mem-activity-bar knowledge`,style:{height:`${t.knowledge_added/yi*100}%`}}),t.tool_calls>0&&l(`div`,{className:`mem-activity-bar tool_calls`,style:{height:`${t.tool_calls/yi*100}%`}}),t.conversations>0&&l(`div`,{className:`mem-activity-bar conversations`,style:{height:`${t.conversations/yi*100}%`}}),i&&l(`span`,{className:`mem-activity-date-label`,children:o}),Ht===n&&r>0&&f(`div`,{className:`mem-activity-tooltip`,children:[l(`strong`,{children:o}),l(`br`,{}),t.conversations>0&&f(a.Fragment,{children:[e(`mem.activity.conversations`,{n:t.conversations}),l(`br`,{})]}),t.tool_calls>0&&f(a.Fragment,{children:[e(`mem.activity.toolCalls`,{n:t.tool_calls}),l(`br`,{})]}),t.knowledge_added>0&&f(a.Fragment,{children:[e(`mem.activity.learned`,{n:t.knowledge_added}),l(`br`,{})]}),t.errors>0&&l(a.Fragment,{children:e(`mem.stat.errors`,{n:t.errors})})]})]},t.date)})}),f(`div`,{className:`mem-activity-legend`,children:[f(`span`,{className:`mem-activity-legend-item`,children:[l(`span`,{className:`mem-activity-legend-dot conversations`}),` `,e(`mem.legend.conversations`)]}),f(`span`,{className:`mem-activity-legend-item`,children:[l(`span`,{className:`mem-activity-legend-dot tool_calls`}),` `,e(`mem.stat.toolCalls`)]}),f(`span`,{className:`mem-activity-legend-item`,children:[l(`span`,{className:`mem-activity-legend-dot knowledge`}),` `,e(`mem.legend.knowledge`)]}),f(`span`,{className:`mem-activity-legend-item`,children:[l(`span`,{className:`mem-activity-legend-dot errors`}),` `,e(`mem.legend.errors`)]})]})]}):f(`div`,{className:`mem-empty`,children:[l(`div`,{className:`mem-empty-icon`,children:l(lt,{size:28})}),l(`p`,{children:e(`mem.activity.empty`)})]})]}),f(`div`,{className:`mem-section`,children:[f(`div`,{className:`mem-section-title mem-section-title-row`,children:[f(`span`,{className:`mem-section-title-left`,children:[l(ve,{size:14}),` `,e(`mem.knowledge.title`),x&&x.total>0&&l(`span`,{className:`mem-section-count`,children:x.total})]}),!hn&&!P&&f(`button`,{className:`mem-section-add-btn`,onClick:()=>gn(!0),title:e(`mem.knowledge.addTitle`),children:[l(je,{size:13}),` `,e(`mem.knowledge.add`)]})]}),f(`div`,{className:`mem-filters`,children:[f(`div`,{className:`mem-category-pills`,role:`group`,"aria-label":e(`mem.knowledge.filterCategory`),children:[Ot.map(t=>l(`button`,{className:`mem-category-pill ${t}${k.includes(t)?` active`:``}`,onClick:()=>oi(t),"aria-pressed":k.includes(t),children:e(kt[t])},t)),k.length>0&&f(`button`,{className:`mem-category-pill clear`,onClick:()=>{Xt([]),M(0)},"aria-label":e(`mem.knowledge.clearAria`),children:[`✕ `,e(`mem.knowledge.clear`)]})]}),f(`select`,{className:`mem-filter-select`,value:Zt,onChange:e=>{Qt(e.target.value),M(0)},"aria-label":e(`mem.knowledge.filterContext`),children:[l(`option`,{value:``,children:e.bare(`mem.knowledge.allContexts`)}),bi.map(t=>l(`option`,{value:t,children:Ft[t]?e.bare(Ft[t]):t},t))]}),f(`select`,{className:`mem-filter-select`,value:$t,onChange:e=>{en(e.target.value),M(0)},"aria-label":e(`mem.knowledge.filterEntity`),children:[l(`option`,{value:``,children:e.bare(`mem.knowledge.allEntities`)}),xt.map(e=>f(`option`,{value:e.entity,children:[e.entity,` (`,e.count,`)`]},e.entity))]}),f(`div`,{className:`mem-filter-search-wrap`,children:[Mr?l(`div`,{className:`mem-spinner-sm search-icon`,style:{width:12,height:12,borderWidth:1.5}}):l(m,{size:13,className:`search-icon`}),l(`input`,{className:`mem-filter-search`,type:`text`,placeholder:e.bare(`mem.knowledge.searchPlaceholder`),value:tn,onChange:e=>Yr(e.target.value),"aria-label":e(`mem.knowledge.search`)})]}),f(`label`,{className:`mem-filter-toggle`,title:e(`mem.knowledge.supersededTitle`),children:[l(`input`,{type:`checkbox`,checked:sn,onChange:e=>cn(e.target.checked)}),l(`span`,{children:e(`mem.knowledge.superseded`)})]})]}),(hn||P)&&f(`div`,{className:`mem-inline-form`,children:[f(`div`,{className:`mem-inline-form-row`,children:[l(`label`,{children:e(`mem.col.content`)}),l(`textarea`,{value:F.content,onChange:e=>I(t=>({...t,content:e.target.value})),placeholder:e(`mem.form.contentPlaceholder`)})]}),f(`div`,{className:`mem-inline-form-row`,children:[l(`label`,{children:e(`mem.col.category`)}),l(`select`,{value:F.category,onChange:e=>I(t=>({...t,category:e.target.value})),children:Ot.map(t=>l(`option`,{value:t,children:e.bare(kt[t])},t))})]}),f(`div`,{className:`mem-inline-form-row`,children:[l(`label`,{children:e(`mem.col.context`)}),l(`input`,{type:`text`,value:F.context,onChange:e=>I(t=>({...t,context:e.target.value})),placeholder:`global`})]}),f(`div`,{className:`mem-inline-form-row`,children:[l(`label`,{children:e(`mem.detail.domain`)}),l(`input`,{type:`text`,value:F.domain,onChange:e=>I(t=>({...t,domain:e.target.value})),placeholder:e(`mem.form.domainPlaceholder`)})]}),f(`div`,{className:`mem-inline-form-row`,children:[l(`label`,{children:e(`mem.col.entity`)}),l(`input`,{type:`text`,value:F.entity,onChange:e=>I(t=>({...t,entity:e.target.value})),placeholder:e(`mem.form.entityPlaceholder`)})]}),f(`div`,{className:`mem-inline-form-row`,children:[l(`label`,{children:e(`mem.form.dueAt`)}),l(`input`,{type:`text`,value:F.due_at,onChange:e=>I(t=>({...t,due_at:e.target.value})),placeholder:e(`mem.form.dueAtPlaceholder`)})]}),f(`div`,{className:`mem-inline-form-row`,children:[l(`label`,{children:e(`mem.form.sensitive`)}),f(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontSize:12},children:[l(`input`,{type:`checkbox`,checked:F.sensitive,onChange:e=>I(t=>({...t,sensitive:e.target.checked}))}),e(`mem.form.sensitiveHint`)]})]}),f(`div`,{className:`mem-inline-form-actions`,children:[l(`button`,{className:`btn-secondary`,onClick:()=>{gn(!1),_n(null)},children:e(`mem.cancel`)}),l(`button`,{className:`btn-primary`,onClick:P?Qr:Zr,style:{padding:`8px 20px`,fontSize:13},children:e(P?`mem.form.update`:`mem.form.save`)})]})]}),x&&x.items.length>0?f(a.Fragment,{children:[l(`div`,{style:{overflowX:`auto`},children:f(`table`,{className:`mem-knowledge-table`,children:[l(`thead`,{children:f(`tr`,{children:[f(`th`,{onClick:()=>si(`category`),className:A===`category`?`sorted`:``,children:[e(`mem.col.category`),vi(`category`)]}),l(`th`,{children:e(`mem.col.content`)}),f(`th`,{onClick:()=>si(`context`),className:A===`context`?`sorted`:``,children:[e(`mem.col.context`),vi(`context`)]}),l(`th`,{children:e(`mem.col.entity`)}),f(`th`,{onClick:()=>si(`confidence`),className:A===`confidence`?`sorted`:``,children:[e(`mem.col.confidence`),vi(`confidence`)]}),l(`th`,{children:e(`mem.col.source`)}),f(`th`,{onClick:()=>si(`updated_at`),className:A===`updated_at`?`sorted`:``,children:[e(`mem.col.updated`),vi(`updated_at`)]}),f(`th`,{onClick:()=>si(`created_at`),className:A===`created_at`?`sorted`:``,children:[e(`mem.col.created`),vi(`created_at`)]}),l(`th`,{children:e(`mem.col.due`)}),l(`th`,{className:`mem-actions-cell`})]})}),l(`tbody`,{children:x.items.map(t=>{let n=Gt===t.id,r=t.has_embedding,i=t.sensitive&&!L.has(t.id),a=f(`button`,{type:`button`,className:`mem-about-link`,onClick:e=>{e.stopPropagation(),ni(t)},onKeyDown:e=>e.stopPropagation(),children:[l(qe,{size:12}),` `,e(`mem.about.showSensitive`)]});return f(S.Fragment,{children:[f(`tr`,{className:`${t.superseded_by?`mem-superseded-row`:``} ${n?`mem-expanded-row`:``}`,onClick:()=>Kt(n?null:t.id),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Kt(n?null:t.id))},tabIndex:0,role:`row`,"aria-expanded":n,style:{cursor:`pointer`},children:[l(`td`,{children:l(`span`,{className:`mem-cat-badge ${t.category}`,children:t.category===`error`&&t.source===`error_auto`?e(`mem.cat.errorLearned`):l(E,{value:t.category,keys:kt})})}),l(`td`,{children:f(`div`,{className:`mem-content-cell`,title:i?void 0:t.content,children:[r!==void 0&&l(`span`,{className:`mem-embed-dot ${r?`embedded`:`missing`}`,title:e(r?`mem.knowledge.embedded`:`mem.knowledge.embedMissing`),children:l(Ye,{size:6,fill:`currentColor`})}),t.sensitive&&l(`span`,{className:`mem-sensitive-badge`,title:e(`mem.form.sensitive`),children:l(ot,{size:11})}),i?a:l(`span`,{className:t.superseded_by?`mem-superseded-text`:``,onClick:e=>{t.sensitive&&(e.stopPropagation(),ni(t))},children:l(`bdi`,{children:t.content})})]})}),l(`td`,{children:l(`span`,{className:`mem-date-cell`,children:l(E,{value:t.context,keys:Ft})})}),l(`td`,{children:t.entity?l(`span`,{className:`mem-entity-link`,onClick:e=>{e.stopPropagation(),en(t.entity),M(0)},title:e(`mem.knowledge.filterBy`,{entity:t.entity}),children:l(`bdi`,{children:t.entity})}):l(`span`,{className:`mem-date-cell`,children:`—`})}),l(`td`,{children:f(`div`,{className:`mem-confidence`,children:[l(`div`,{className:`mem-confidence-bar`,children:l(`div`,{className:`mem-confidence-fill ${wt(t.confidence)}`,style:{width:`${t.confidence*100}%`}})}),t.confidence.toFixed(2)]})}),l(`td`,{children:l(`span`,{className:`mem-date-cell`,children:t.source?l(E,{value:t.source,keys:pt}):`—`})}),l(`td`,{children:l(`span`,{className:`mem-date-cell`,title:w(t.updated_at,d(e)),children:T(t.updated_at,e)})}),l(`td`,{children:l(`span`,{className:`mem-date-cell`,title:w(t.created_at,d(e)),children:T(t.created_at,e)})}),l(`td`,{children:t.due_at?l(`span`,{className:`mem-due-badge ${Ct(t.due_at)?`overdue`:`upcoming`}`,title:w(t.due_at,d(e)),children:T(t.due_at,e)}):l(`span`,{className:`mem-due-badge none`,children:`—`})}),l(`td`,{className:`mem-actions-cell`,children:f(`div`,{className:`mem-row-actions`,onClick:e=>e.stopPropagation(),children:[l(`button`,{className:`mem-row-action-btn`,onClick:()=>ti(t),disabled:i,title:e(i?`mem.about.editHidden`:`mem.row.edit`),children:l(be,{size:13})}),l(`button`,{className:`mem-row-action-btn`,onClick:()=>ei(t),title:e(t.sensitive?`mem.row.unmarkSensitive`:`mem.row.markSensitive`),children:t.sensitive?l(it,{size:13}):l(ot,{size:13})}),l(`button`,{className:`mem-row-action-btn`,onClick:()=>ri(t.id),title:e(`mem.row.copyId`),children:l(Le,{size:13})}),l(`button`,{className:`mem-row-action-btn delete${V===t.id?` is-confirm`:``}`,onClick:()=>$r(t.id),title:e(V===t.id?`mem.row.clickAgain`:`mem.row.delete`),"aria-label":e(V===t.id?`mem.row.confirmDeleteAria`:`mem.row.deleteAria`),children:V===t.id?l(`span`,{className:`mem-row-delete-label`,children:e(`mem.row.deleteConfirm`)}):l(De,{size:13})})]})})]}),n&&l(`tr`,{className:`mem-detail-row`,children:l(`td`,{colSpan:10,children:f(`div`,{className:`mem-detail-panel`,children:[f(`div`,{className:`mem-detail-grid`,children:[f(`div`,{className:`mem-detail-field`,children:[l(`span`,{className:`mem-detail-label`,children:e(`mem.detail.id`)}),l(`span`,{className:`mem-detail-value`,children:t.id})]}),f(`div`,{className:`mem-detail-field`,children:[l(`span`,{className:`mem-detail-label`,children:e(`mem.detail.domain`)}),l(`bdi`,{className:`mem-detail-value`,children:t.domain||`—`})]}),f(`div`,{className:`mem-detail-field`,children:[l(`span`,{className:`mem-detail-label`,children:e(`mem.col.source`)}),l(`bdi`,{className:`mem-detail-value`,children:t.source||`—`})]}),f(`div`,{className:`mem-detail-field`,children:[l(`span`,{className:`mem-detail-label`,children:e(`mem.detail.useCount`)}),l(`span`,{className:`mem-detail-value`,children:t.use_count??0})]}),f(`div`,{className:`mem-detail-field`,children:[l(`span`,{className:`mem-detail-label`,children:e(`mem.col.created`)}),l(`span`,{className:`mem-detail-value`,children:w(t.created_at,d(e))})]}),f(`div`,{className:`mem-detail-field`,children:[l(`span`,{className:`mem-detail-label`,children:e(`mem.col.updated`)}),l(`span`,{className:`mem-detail-value`,children:w(t.updated_at,d(e))})]}),f(`div`,{className:`mem-detail-field`,children:[l(`span`,{className:`mem-detail-label`,children:e(`mem.detail.lastUsed`)}),l(`span`,{className:`mem-detail-value`,children:w(t.last_used,d(e))})]}),f(`div`,{className:`mem-detail-field`,children:[l(`span`,{className:`mem-detail-label`,children:e(`mem.detail.remindedAt`)}),l(`span`,{className:`mem-detail-value`,children:w(t.reminded_at,d(e))})]}),t.superseded_by&&f(`div`,{className:`mem-detail-field`,children:[l(`span`,{className:`mem-detail-label`,children:e(`mem.detail.supersededBy`)}),l(`span`,{className:`mem-detail-value mem-detail-chain`,children:t.superseded_by})]}),t.metadata&&f(`div`,{className:`mem-detail-field mem-detail-full`,children:[l(`span`,{className:`mem-detail-label`,children:e(`mem.detail.metadata`)}),l(`span`,{className:`mem-detail-value`,children:l(`bdi`,{dir:`ltr`,children:typeof t.metadata==`object`?JSON.stringify(t.metadata,null,2):t.metadata})})]})]}),f(`div`,{className:`mem-detail-content-full`,children:[l(`span`,{className:`mem-detail-label`,children:e(`mem.detail.fullContent`)}),l(`div`,{className:`mem-detail-content-text`,children:i?a:l(`bdi`,{children:t.content})})]})]})})})]},t.id)})})]})}),f(`div`,{className:`mem-pagination`,children:[l(`span`,{children:e(`mem.page.range`,{from:j+1,to:Math.min(j+15,x.total),total:x.total})}),f(`div`,{className:`mem-pagination-btns`,children:[l(`button`,{type:`button`,className:`mem-page-btn`,"aria-label":e(`mem.page.previous`),disabled:j===0,onClick:()=>M(Math.max(0,j-15)),children:l(Te,{size:14})}),l(`button`,{type:`button`,className:`mem-page-btn`,"aria-label":e(`mem.page.next`),disabled:j+15>=x.total,onClick:()=>M(j+15),children:l(Ze,{size:14})})]})]})]}):f(`div`,{className:`mem-empty`,children:[l(`div`,{className:`mem-empty-icon`,children:l(ve,{size:28})}),l(`p`,{children:e(tn||k.length>0||Zt||$t?`mem.knowledge.noMatch`:`mem.knowledge.empty`)})]})]}),f(`div`,{className:`mem-two-col`,children:[f(`div`,{className:`mem-section`,children:[f(`div`,{className:`mem-section-title`,children:[l(tt,{size:14}),` `,e(`mem.tools.title`),l(`span`,{className:`mem-section-note`,title:e(`mem.tools.noteTitle`),children:e(`mem.tools.note`)})]}),ft.length>0?l(`div`,{style:{overflowX:`auto`},children:f(`table`,{className:`mem-tool-table`,children:[l(`thead`,{children:f(`tr`,{children:[l(`th`,{children:e(`mem.tools.tool`)}),l(`th`,{children:e(`mem.tools.calls`)}),l(`th`,{children:e(`mem.tools.success`)}),l(`th`,{children:e(`mem.tools.denied`)}),l(`th`,{children:e(`mem.tools.avgTime`)}),l(`th`,{children:e(`mem.detail.lastUsed`)}),l(`th`,{children:e(`mem.tools.lastError`)})]})}),l(`tbody`,{children:ft.map(t=>f(`tr`,{children:[l(`td`,{children:l(`bdi`,{className:`mem-tool-name`,children:t.tool_name})}),l(`td`,{children:t.total_calls}),l(`td`,{children:f(`div`,{className:`mem-confidence`,children:[l(`div`,{className:`mem-confidence-bar`,style:{width:40},children:l(`div`,{className:`mem-confidence-fill ${Tt(t.success_rate)}`,style:{width:`${t.success_rate*100}%`}})}),f(`span`,{className:`mem-success-rate ${Tt(t.success_rate)}`,children:[Math.round(t.success_rate*100),`%`]})]})}),l(`td`,{children:t.denied_count??0}),l(`td`,{children:l(`bdi`,{dir:`ltr`,children:St(t.avg_duration_ms)})}),l(`td`,{children:l(`span`,{className:`mem-date-cell`,title:w(t.last_used,d(e)),children:T(t.last_used,e)})}),l(`td`,{children:l(`bdi`,{className:`mem-tool-error`,title:t.last_error||``,children:t.last_error||`—`})})]},t.tool_name))})]})}):f(`div`,{className:`mem-empty`,children:[l(`div`,{className:`mem-empty-icon`,children:l(tt,{size:28})}),l(`p`,{children:e(`mem.tools.empty`)})]})]}),f(`div`,{className:`mem-section`,children:[f(`div`,{className:`mem-section-title`,children:[l(Fe,{size:14}),` `,e(`mem.upcoming.title`)]}),_t.length>0?l(`div`,{className:`mem-temporal-list`,children:_t.map(t=>{let n=Ct(t.due_at);return f(`div`,{className:`mem-temporal-item ${n?`overdue`:`upcoming`}`,children:[l(`span`,{className:`mem-temporal-icon`,children:l(n?p:Fe,{size:16})}),f(`div`,{className:`mem-temporal-content`,children:[l(`div`,{className:`mem-temporal-text`,children:l(`bdi`,{children:t.content})}),f(`div`,{className:`mem-temporal-date`,children:[e(n?`mem.upcoming.overdue`:`mem.upcoming.due`,{when:T(t.due_at,e)}),t.context!==`global`&&f(a.Fragment,{children:[` `,`·`,` `,l(E,{value:t.context,keys:Ft})]})]})]})]},t.id)})}):f(`div`,{className:`mem-empty`,children:[l(`div`,{className:`mem-empty-icon`,children:l(Ce,{size:28})}),l(`p`,{children:e(`mem.upcoming.empty`)})]})]})]}),f(`div`,{className:`mem-section`,children:[f(`div`,{className:`mem-section-title`,children:[l(Ke,{size:14}),` `,e(`mem.conv.title`)]}),f(`div`,{className:`mem-conv-search`,children:[l(m,{size:13,className:`search-icon`}),l(`input`,{type:`text`,placeholder:e.bare(`mem.conv.searchPlaceholder`),value:ln,onChange:e=>ii(e.target.value),"aria-label":e(`mem.conv.search`)}),ln&&l(`button`,{className:`mem-search-clear`,onClick:()=>{un(``),fn(null)},"aria-label":e(`mem.conv.clearSearch`),children:l(xe,{size:12})})]}),dn===null?ht.length>0?l(`div`,{className:`mem-conv-list`,children:ht.map(t=>f(`div`,{className:`mem-conv-item`,onClick:()=>ai(t.session_id),children:[f(`div`,{className:`mem-conv-info`,children:[f(`div`,{className:`mem-conv-session-id`,children:[l(`bdi`,{children:nt(t.session_id)}),t.consolidated&&l(`span`,{className:`mem-consolidated-badge`,title:e(`mem.conv.consolidated`),children:l(rt,{size:11})})]}),t.first_message&&l(`div`,{className:`mem-conv-preview`,children:l(`bdi`,{children:t.first_message})})]}),f(`div`,{className:`mem-conv-meta`,children:[l(`span`,{children:e.plural(`mem.conv.turns`,t.turn_count)}),l(`span`,{children:T(t.last_activity,e)})]})]},t.session_id))}):f(`div`,{className:`mem-empty`,children:[l(`div`,{className:`mem-empty-icon`,children:l(Ke,{size:28})}),l(`p`,{children:e(`mem.conv.empty`)})]}):dn.length>0?l(`div`,{className:`mem-conv-list`,children:dn.map(t=>f(`div`,{className:`mem-conv-item`,onClick:()=>ai(t.session_id),children:[f(`div`,{className:`mem-conv-info`,children:[f(`div`,{className:`mem-conv-session-id`,children:[l(`span`,{className:`mem-conv-turn-role ${t.role}`,children:l(E,{value:t.role,keys:Nt})}),` `,l(`bdi`,{children:nt(t.session_id)})]}),l(`div`,{className:`mem-conv-preview`,children:l(`bdi`,{children:t.content})})]}),l(`div`,{className:`mem-conv-meta`,children:l(`span`,{children:T(t.timestamp,e)})})]},t.id))}):l(`div`,{className:`mem-empty`,children:l(`p`,{children:e(`mem.conv.noMatch`,{query:ln})})})]}),N&&f(`div`,{className:`mem-conv-detail-overlay`,children:[f(`div`,{className:`mem-conv-detail-header`,children:[l(`h2`,{children:l(`bdi`,{children:nt(N.sessionId)})}),f(`div`,{className:`mem-conv-detail-actions`,children:[Oe.has(N.sessionId)&&l(`button`,{className:`btn-secondary`,onClick:()=>c(N.sessionId),children:e(`mem.conv.openChat`)}),l(`button`,{className:`btn-icon`,onClick:()=>mn(null),"aria-label":e(`mem.conv.close`),children:l(xe,{size:16})})]})]}),f(`div`,{className:`mem-conv-detail-body`,children:[N.turns.map(t=>f(`div`,{className:`mem-conv-turn`,children:[f(`div`,{className:`mem-conv-turn-header`,children:[l(`div`,{className:`mem-conv-turn-role ${t.role}`,children:l(E,{value:t.role,keys:Nt})}),l(`span`,{className:`mem-conv-turn-time`,title:w(t.timestamp,d(e)),children:T(t.timestamp,e)})]}),l(`div`,{className:`mem-conv-turn-content`,children:l(`bdi`,{children:t.content})})]},t.id)),N.turns.length===0&&l(`div`,{className:`mem-empty`,children:e(`mem.conv.noTurns`)})]})]})]}),f(`div`,{className:`mem-section`,children:[f(`div`,{className:`mem-section-title`,children:[l(ot,{size:14}),` `,e(`mem.settings.title`),` `,l(`span`,{className:`mem-beta`,style:{fontSize:10,fontWeight:500,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`1px 6px`,borderRadius:4,marginInlineStart:6,verticalAlign:`middle`},children:e(`mem.beta`)})]}),f(`div`,{className:`mem-setting-row`,children:[f(`div`,{className:`mem-setting-info`,children:[l(`span`,{className:`mem-setting-label`,children:e(`mem.settings.memory`)}),l(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.memoryDesc`)})]}),l(`button`,{className:`mem-toggle${R?` mem-toggle-on`:``}`,disabled:z,onClick:async()=>{if(!R)H(`memory`);else{B(!0);try{let e=await v({memory_enabled:!1});yn(e.memory_enabled)}catch(t){o.system.warn(`Failed to disable memory`,t),Y(e(`mem.toast.settingFailed`,{error:D(t)}),`error`)}finally{B(!1)}}},"aria-pressed":R,"aria-label":e(R?`mem.settings.memoryOn`:`mem.settings.memoryOff`),children:l(`span`,{className:`mem-toggle-knob`,"aria-hidden":`true`})})]}),kn&&(()=>{let t={memory:{title:`mem.beta.memory.title`,description:`mem.beta.memory.desc`,bullets:[`mem.beta.memory.local`,`mem.beta.memory.lost`,`mem.beta.memory.disable`],buttonLabel:`mem.beta.memory.confirm`,onConfirm:async()=>{let t=await v({memory_enabled:!0});yn(t.memory_enabled),Y(e(`mem.toast.memoryEnabled`),`info`)}},mcp:{title:`mem.beta.mcp.title`,description:`mem.beta.mcp.desc`,bullets:[`mem.beta.mcp.read`,`mem.beta.mcp.restart`,`mem.beta.mcp.debug`],buttonLabel:`mem.beta.mcp.confirm`,onConfirm:async()=>{let t=await v({mcp_memory_enabled:!0});xn(t.mcp_memory_enabled),Y(e(`mem.toast.mcpEnabled`),`info`)}},discovery:{title:`mem.beta.discovery.title`,description:`mem.beta.discovery.desc`,bullets:[`mem.beta.discovery.collects`,`mem.beta.discovery.scans`,`mem.beta.discovery.local`],buttonLabel:`mem.beta.discovery.confirm`,onConfirm:async()=>{let t=await v({system_discovery_consent:!0});if(Cn(t.system_discovery_consent),t.system_context_error)Y(e(`mem.toast.discoveryScanFailed`,{error:t.system_context_error}),`error`);else{let n=t.system_context_refresh?.stored??0;Y(e(`mem.toast.discoveryEnabled`,{n}),`info`)}Q()}}}[kn];return f(a.Fragment,{children:[l(`div`,{"aria-hidden":`true`,style:{position:`fixed`,inset:0,background:`var(--bg-modal-overlay)`,zIndex:9998,backdropFilter:`blur(4px)`},onClick:()=>H(null)}),f(`div`,{ref:Ir,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`mem-beta-confirm-title`,"aria-describedby":`mem-beta-confirm-desc`,tabIndex:-1,style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,zIndex:9999,background:`var(--bg-card)`,border:`1px solid var(--border)`,borderRadius:12,padding:`28px 32px`,maxWidth:420,width:`90vw`,boxShadow:`var(--shadow-lg)`},children:[f(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,marginBottom:16},children:[l(`span`,{className:`mem-beta`,style:{fontSize:11,fontWeight:500,color:`var(--accent-yellow)`,background:`var(--accent-yellow-dim)`,padding:`3px 10px`,borderRadius:4},children:e(`mem.beta`)}),l(`h2`,{id:`mem-beta-confirm-title`,style:{fontSize:16,fontWeight:500,color:`var(--text-primary)`},children:e(t.title)})]}),l(`p`,{id:`mem-beta-confirm-desc`,style:{fontSize:13,lineHeight:1.6,color:`var(--text-secondary)`,margin:`0 0 8px`},children:e(t.description)}),l(`ul`,{style:{fontSize:13,lineHeight:1.7,color:`var(--text-secondary)`,margin:`0 0 24px`,paddingInlineStart:20},children:t.bullets.map(t=>l(`li`,{children:e(t)},t))}),f(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[l(`button`,{className:`btn-secondary`,onClick:()=>H(null),style:{padding:`8px 20px`,fontSize:13,borderRadius:6},children:e(`mem.cancel`)}),l(`button`,{disabled:z,onClick:async()=>{B(!0);try{await t.onConfirm()}catch(t){o.system.warn(`Failed to update setting`,t),Y(e(`mem.toast.settingFailed`,{error:D(t)}),`error`)}finally{B(!1),H(null)}},style:{padding:`8px 24px`,fontSize:13,fontWeight:500,borderRadius:6,border:`none`,cursor:`pointer`,background:`var(--accent-fill)`,color:`var(--accent-fill-text)`},children:e(t.buttonLabel)})]})]})]})})(),f(`div`,{className:`mem-setting-row`,children:[f(`div`,{className:`mem-setting-info`,children:[l(`span`,{className:`mem-setting-label`,children:e(`mem.settings.mcp`)}),l(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.mcpDesc`)})]}),l(`button`,{className:`mem-toggle${bn?` mem-toggle-on`:``}`,disabled:z,onClick:async()=>{if(!bn)H(`mcp`);else{B(!0);try{let e=await v({mcp_memory_enabled:!1});xn(e.mcp_memory_enabled)}catch(t){o.system.warn(`Failed to update memory settings`,t),Y(e(`mem.toast.settingFailed`,{error:D(t)}),`error`)}finally{B(!1)}}},"aria-label":e(`mem.settings.mcpToggle`),"aria-pressed":bn,children:l(`span`,{className:`mem-toggle-knob`,"aria-hidden":`true`})})]}),f(`div`,{className:`mem-setting-row`,children:[f(`div`,{className:`mem-setting-info`,children:[l(`span`,{className:`mem-setting-label`,children:e(`mem.settings.discovery`)}),l(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.discoveryDesc`)})]}),l(`button`,{className:`mem-toggle${Sn?` mem-toggle-on`:``}`,disabled:z,onClick:async()=>{if(!Sn)H(`discovery`);else{B(!0);try{let e=await v({system_discovery_consent:!1});Cn(e.system_discovery_consent)}catch(t){o.system.warn(`Failed to update system discovery setting`,t),Y(e(`mem.toast.settingFailed`,{error:D(t)}),`error`)}finally{B(!1)}}},"aria-label":e(`mem.settings.discoveryToggle`),"aria-pressed":Sn,children:l(`span`,{className:`mem-toggle-knob`,"aria-hidden":`true`})})]}),f(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[f(`div`,{className:`mem-setting-info`,children:[l(`span`,{className:`mem-setting-label`,children:e(`mem.settings.reinit`)}),l(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.reinitDesc`)})]}),Dn?f(`div`,{className:`mem-delete-confirm`,children:[l(`span`,{className:`mem-delete-confirm-label`,children:e(`mem.settings.sure`)}),l(`button`,{className:`mem-btn-danger`,disabled:z,onClick:async()=>{B(!0);try{let t=await pe();t.system_context.error?Y(e(`mem.toast.server`,{message:t.system_context.error}),`error`):Y(e(`mem.toast.reinitialized`,{cleared:t.cleared.knowledge,stored:t.system_context.stored}),`info`),Q()}catch(t){o.system.warn(`Failed to reinitialize memory`,t),Y(e(`mem.toast.reinitFailed`,{error:D(t)}),`error`)}finally{B(!1),On(!1)}},children:e(`mem.settings.reinitConfirm`)}),l(`button`,{className:`btn-secondary`,onClick:()=>On(!1),style:{padding:`6px 14px`,fontSize:12},children:e(`mem.cancel`)})]}):l(`button`,{className:`mem-btn-danger`,disabled:z,onClick:()=>On(!0),children:e(`mem.settings.reinitButton`)})]}),f(`div`,{className:`mem-setting-row mem-setting-row-danger`,children:[f(`div`,{className:`mem-setting-info`,children:[l(`span`,{className:`mem-setting-label`,children:e(`mem.settings.deleteAll`)}),l(`span`,{className:`mem-setting-desc`,children:e(`mem.settings.deleteAllDesc`)})]}),wn?f(`div`,{className:`mem-delete-confirm`,children:[l(`span`,{className:`mem-delete-confirm-label`,children:e(`mem.settings.sure`)}),l(`button`,{className:`mem-btn-danger`,disabled:z,onClick:async()=>{B(!0);try{let t=await $e();Y(e(`mem.toast.cleared`,{knowledge:t.knowledge,conversations:t.conversations}),`info`),Q()}catch(t){o.system.warn(`Failed to clear memory`,t),Y(e(`mem.toast.clearFailed`,{error:D(t)}),`error`)}finally{B(!1),Tn(!1)}},children:e(`mem.settings.deleteConfirm`)}),l(`button`,{className:`btn-secondary`,onClick:()=>Tn(!1),style:{padding:`6px 14px`,fontSize:12},children:e(`mem.cancel`)})]}):l(`button`,{className:`mem-btn-danger`,disabled:z,onClick:()=>Tn(!0),children:e(`mem.settings.deleteButton`)})]})]}),y&&f(`div`,{className:`mem-db-footer`,children:[f(`span`,{children:[e(`mem.footer.database`),`: `,l(`bdi`,{dir:`ltr`,children:We(y.db_size_bytes)}),y.knowledge?.avg_confidence!=null&&f(a.Fragment,{children:[` · `,e(`mem.footer.avgConfidence`,{n:y.knowledge.avg_confidence.toFixed(2)})]})]}),f(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[y.knowledge?.entity_count!=null&&y.knowledge.entity_count>0&&l(`span`,{children:e(`mem.footer.entities`,{n:y.knowledge.entity_count})}),y.knowledge?.sensitive_count!=null&&y.knowledge.sensitive_count>0&&f(`span`,{children:[l(ot,{size:10}),` `,e(`mem.footer.sensitive`,{n:y.knowledge.sensitive_count})]})]})]})]})}),U===`profile`&&f(`div`,{className:`mem-profile-grid`,children:[l(`p`,{className:`mem-tab-intro`,children:e(`mem.profile.intro`)}),f(`div`,{className:`mem-profile-card`,children:[f(`div`,{className:`mem-profile-card-title`,children:[l(Re,{size:16}),` `,e(`mem.disc.title`)]}),l(`p`,{className:`mem-profile-desc`,children:e(`mem.disc.desc`)}),l(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:G===`running`||G===`saving`,onClick:mi,children:G===`running`?f(a.Fragment,{children:[l(`div`,{className:`mem-spinner-sm`}),` `,e(`mem.running`)]}):e(`mem.disc.run`)}),tr.length>0&&l(`div`,{className:`mem-log`,ref:sr,children:tr.map((e,t)=>l(`div`,{className:`mem-log-line ${e.kind}`,children:e.server?l(`bdi`,{children:e.text}):e.text},t))}),(G===`review`||G===`saving`||G===`done`)&&q.length>0&&f(`div`,{className:`mem-review-section`,children:[l(`div`,{className:`mem-review-header`,children:e(`mem.review.title`)}),l(`div`,{className:`mem-review-list`,children:q.map((t,n)=>f(`label`,{className:`mem-review-item`,children:[l(`input`,{type:`checkbox`,checked:t._checked,disabled:G===`saving`||G===`done`,onChange:()=>{nr(e=>e.map((e,t)=>t===n?{...e,_checked:!e._checked}:e))}}),t.sensitive&&!ar.has(n)?l(`span`,{className:`mem-review-content`,children:f(`button`,{type:`button`,className:`mem-about-link`,onClick:e=>{e.preventDefault(),or(e=>new Set(e).add(n))},children:[l(qe,{size:12}),` `,e(`mem.about.showSensitive`)]})}):l(`bdi`,{className:`mem-review-content`,children:t.content}),l(`span`,{className:`mem-source-badge`,children:t._source_name?l(`bdi`,{children:t._source_name}):l(E,{value:t.category,keys:kt})}),f(`span`,{className:`mem-conf-badge`,children:[Math.round(t.confidence*100),`%`]})]},n))}),f(`div`,{className:`mem-review-actions`,children:[l(`button`,{className:`btn-primary`,disabled:G===`saving`||G===`done`||q.filter(e=>e._checked).length===0,onClick:hi,children:G===`saving`?f(a.Fragment,{children:[l(`div`,{className:`mem-spinner-sm`}),` `,e(`mem.saving`)]}):e(`mem.review.saveSelected`,{n:q.filter(e=>e._checked).length})}),f(`span`,{className:`mem-review-select-links`,children:[l(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>nr(e=>e.map(e=>({...e,_checked:!0}))),children:e(`mem.review.selectAll`)}),` / `,l(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>nr(e=>e.map(e=>({...e,_checked:!1}))),children:e(`mem.review.none`)})]})]})]}),G===`done`&&rr!==null&&f(`div`,{className:`mem-profile-success`,children:[l(Ce,{size:14}),` `,e(`mem.disc.saved`,{n:rr})]}),G===`review`&&q.length===0&&l(`div`,{className:`mem-profile-empty`,children:e(`mem.disc.empty`)})]}),f(`div`,{className:`mem-profile-card`,children:[f(`div`,{className:`mem-profile-card-title`,children:[l(Ae,{size:16}),` `,e(`mem.inf.title`)]}),l(`p`,{className:`mem-profile-desc`,children:e(`mem.inf.desc`)}),l(`p`,{className:`mem-profile-note`,children:e(`mem.inf.note`)}),f(`label`,{className:`mem-profile-checkbox`,children:[l(`input`,{type:`checkbox`,checked:gr,onChange:e=>_r(e.target.checked),disabled:J===`running`||J===`saving`}),e(`mem.inf.browser`)]}),l(`button`,{className:`btn-primary mem-profile-run-btn`,disabled:J===`running`||J===`saving`,onClick:gi,children:J===`running`?f(a.Fragment,{children:[l(`div`,{className:`mem-spinner-sm`}),` `,e(`mem.running`)]}):e(`mem.inf.run`)}),ur.length>0&&l(`div`,{className:`mem-log`,ref:vr,children:ur.map((e,t)=>l(`div`,{className:`mem-log-line ${e.kind}`,children:e.server?l(`bdi`,{children:e.text}):e.text},t))}),(J===`review`||J===`saving`||J===`done`)&&fr.length>0&&f(`div`,{className:`mem-review-section`,children:[l(`div`,{className:`mem-review-header`,children:e(`mem.review.title`)}),l(`div`,{className:`mem-review-list`,children:fr.map((e,t)=>f(`label`,{className:`mem-review-item`,children:[l(`input`,{type:`checkbox`,checked:e._checked,disabled:J===`saving`||J===`done`,onChange:()=>{pr(e=>e.map((e,n)=>n===t?{...e,_checked:!e._checked}:e))}}),l(`bdi`,{className:`mem-review-content`,children:e.content}),l(`span`,{className:`mem-domain-badge ${It[e.domain]||`gray`}`,children:l(E,{value:e.domain,keys:Pt})}),f(`span`,{className:`mem-conf-badge`,children:[Math.round(e.confidence*100),`%`]})]},t))}),f(`div`,{className:`mem-review-actions`,children:[l(`button`,{className:`btn-primary`,disabled:J===`saving`||J===`done`||fr.filter(e=>e._checked).length===0,onClick:_i,children:J===`saving`?f(a.Fragment,{children:[l(`div`,{className:`mem-spinner-sm`}),` `,e(`mem.saving`)]}):e(`mem.review.saveSelected`,{n:fr.filter(e=>e._checked).length})}),f(`span`,{className:`mem-review-select-links`,children:[l(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>pr(e=>e.map(e=>({...e,_checked:!0}))),children:e(`mem.review.selectAll`)}),` / `,l(`button`,{type:`button`,className:`mem-link-btn`,onClick:()=>pr(e=>e.map(e=>({...e,_checked:!1}))),children:e(`mem.review.none`)})]})]})]}),J===`done`&&mr!==null&&f(`div`,{className:`mem-profile-success`,children:[l(Ce,{size:14}),` `,e(`mem.inf.saved`,{n:mr})]}),J===`review`&&fr.length===0&&l(`div`,{className:`mem-profile-empty`,children:e(`mem.inf.empty`)})]})]}),U===`goals`&&f(`div`,{className:`mem-goals-tab`,children:[l(`p`,{className:`mem-tab-intro`,children:e(`mem.goals.intro`)}),zn&&(Bn?f(`div`,{className:`mem-advanced-error`,role:`alert`,children:[l(p,{size:14}),` `,e(`mem.goals.storeDamaged`),` `,l(`button`,{type:`button`,className:`link-btn`,disabled:Gn,onClick:qr,children:e(`mem.goals.startNewList`)})]}):f(`div`,{className:`mem-advanced-error`,role:`alert`,children:[l(p,{size:14}),` `,e(`mem.goals.storeError`),`: `,l(`bdi`,{children:zn})]})),l(`div`,{className:`mem-goals-stats-row`,children:[`queued`,`in_progress`,`completed`,`failed`].map(t=>f(`div`,{className:`mem-goals-stat-pill mem-goal-status-${t.replace(`_`,`-`)}`,children:[l(`span`,{className:`mem-goals-stat-n`,children:Fn?.goals[t]??0}),l(`span`,{className:`mem-goals-stat-label`,children:e(At[t])})]},t))}),Nn.filter(e=>e.status===`pending_approval`).length>0&&f(`div`,{className:`mem-goals-approval-banner`,children:[f(`div`,{className:`mem-goals-approval-title`,children:[l(h,{size:14}),` `,e(`mem.goals.suggested`,{n:Nn.filter(e=>e.status===`pending_approval`).length})]}),Nn.filter(e=>e.status===`pending_approval`).map(t=>f(`div`,{className:`mem-goals-approval-item`,children:[f(`div`,{className:`mem-goals-approval-text`,children:[l(`strong`,{children:l(`bdi`,{children:t.title})}),l(`bdi`,{children:t.description})]}),f(`div`,{className:`mem-goals-approval-actions`,children:[l(`button`,{className:`btn-danger-sm`,onClick:()=>Gr(()=>He(t.id),`mem.goals.rejectFailed`),children:e(`mem.goals.reject`)}),l(`button`,{className:`btn-secondary`,onClick:()=>Gr(()=>Pe(t.id),`mem.goals.acceptFailed`),children:e(`mem.goals.accept`)})]})]},t.id))]}),l(`div`,{className:`mem-goals-toolbar`,children:f(`button`,{className:`btn-primary`,onClick:()=>{Wn(null),Qn(e=>!e)},children:[l(je,{size:14}),` `,e(`mem.goals.new`)]})}),Zn&&f(`div`,{className:`mem-goals-add-form`,children:[l(`input`,{className:`mem-input`,placeholder:e(`mem.goals.titlePlaceholder`),value:W.title,onChange:e=>$n(t=>({...t,title:e.target.value}))}),l(`textarea`,{className:`mem-input`,placeholder:e(`mem.goals.descPlaceholder`),rows:2,value:W.description,onChange:e=>$n(t=>({...t,description:e.target.value}))}),f(`div`,{className:`mem-goals-form-row`,children:[f(`select`,{className:`mem-select`,value:W.priority,onChange:e=>$n(t=>({...t,priority:e.target.value})),children:[l(`option`,{value:`low`,children:e.bare(`mem.goals.priorityLow`)}),l(`option`,{value:`medium`,children:e.bare(`mem.goals.priorityMedium`)}),l(`option`,{value:`high`,children:e.bare(`mem.goals.priorityHigh`)})]}),l(`button`,{className:`btn-primary`,disabled:!W.title.trim(),onClick:Kr,children:e(`mem.goals.create`)}),l(`button`,{className:`btn-secondary`,onClick:()=>{Wn(null),Qn(!1)},children:e(`mem.cancel`)})]}),Un&&l(`p`,{className:`mem-form-error`,role:`alert`,children:l(`bdi`,{children:Un})})]}),Ln?f(`div`,{className:`mem-loading`,children:[l(`div`,{className:`mem-spinner`}),` `,e(`mem.goals.loading`)]}):Vn?f(`p`,{className:`mem-form-error`,role:`alert`,children:[e(`mem.goals.loadFailed`),` `,l(`bdi`,{children:Vn})]}):Nn.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).length===0?f(`div`,{className:`mem-empty`,children:[l(`div`,{className:`mem-empty-icon`,children:l(st,{size:32})}),l(`p`,{children:e(`mem.goals.empty`)})]}):l(`div`,{className:`mem-goals-list`,children:Nn.filter(e=>e.status!==`pending_approval`&&e.status!==`rejected`).map(t=>f(`div`,{className:`mem-goal-card mem-goal-status-${t.status.replace(`_`,`-`)}`,children:[f(`div`,{className:`mem-goal-header`,role:`button`,tabIndex:0,"aria-expanded":qn===t.id,onClick:()=>Jn(e=>e===t.id?null:t.id),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Jn(e=>e===t.id?null:t.id))},children:[f(`div`,{className:`mem-goal-header-left`,children:[l(`span`,{className:`mem-goal-status-dot status-${t.status.replace(`_`,`-`)}`}),l(`bdi`,{className:`mem-goal-title`,children:t.title}),l(`span`,{className:`mem-goal-priority mem-priority-${t.priority}`,children:l(E,{value:t.priority,keys:jt})}),t.status===`cancelled`&&l(`span`,{className:`mem-goal-priority mem-goal-cancelled-label`,children:e(At.cancelled)}),t.source!==`user`&&f(`span`,{className:`mem-goal-source-badge`,children:[l(h,{size:10}),` `,l(E,{value:t.source,keys:Mt})]})]}),f(`div`,{className:`mem-goal-header-right`,children:[f(`span`,{className:`mem-goal-task-count`,children:[l(Ue,{size:12}),f(`bdi`,{dir:`ltr`,children:[t.tasks.filter(e=>e.status===`completed`).length,`/`,t.tasks.length]})]}),t.status===`queued`&&l(`button`,{className:`mem-goal-action-btn mem-goal-cancel-btn`,onClick:e=>{e.stopPropagation(),Gr(()=>Je(t.id),`mem.goals.cancelFailed`)},children:e(`mem.cancel`)}),Yn===t.id?l(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn mem-goal-delete-confirm`,onClick:e=>{e.stopPropagation(),Xn(null),Gr(()=>we(t.id),`mem.goals.deleteFailed`)},children:e(`mem.row.deleteConfirm`)}):l(`button`,{className:`mem-goal-action-btn mem-goal-delete-btn`,"aria-label":e(`mem.goals.deleteAria`,{title:t.title}),onClick:e=>{e.stopPropagation(),Xn(t.id)},children:l(De,{size:12})}),l(se,{size:14,className:qn===t.id?`mem-chevron-open`:``})]})]}),qn===t.id&&f(`div`,{className:`mem-goal-body`,children:[t.description&&l(`p`,{className:`mem-goal-desc`,children:l(`bdi`,{children:t.description})}),t.progress_notes&&l(`p`,{className:`mem-goal-progress`,children:l(`bdi`,{children:t.progress_notes})}),t.tasks.length>0?l(`div`,{className:`mem-task-list`,children:t.tasks.map(e=>f(`div`,{className:`mem-task-row mem-task-status-${e.status}`,children:[l(`span`,{className:`mem-task-dot status-${e.status}`}),l(`bdi`,{className:`mem-task-desc`,children:e.description}),l(`span`,{className:`mem-task-status-label`,children:l(E,{value:e.status,keys:At})}),e.result&&l(`bdi`,{className:`mem-task-result`,children:e.result})]},e.id))}):t.status===`queued`||t.status===`in_progress`?l(`p`,{className:`mem-goal-no-tasks`,children:e(`mem.goals.noTasks`)}):null]})]},t.id))})]})]}),qt.length>0&&l(`div`,{className:`mem-toast-container`,"aria-live":`polite`,children:qt.map(e=>f(`div`,{className:`mem-toast mem-toast-${e.type}`,role:`status`,children:[e.type===`success`&&l(Ce,{size:14}),e.type===`error`&&l(p,{size:14}),e.type===`info`&&l(ve,{size:14}),l(`span`,{children:e.text})]},e.id))})]})}export{Lt as MemoryDashboard};
@@ -1 +0,0 @@
1
- .memory-dashboard-page{background:var(--bg-primary);font-variant-numeric:tabular-nums;flex-direction:column;height:100%;display:flex;overflow:hidden}.memory-dashboard-body>*{max-width:1080px;margin-inline:auto}.mem-tool-name{font-family:var(--font-mono)}.mem-beta{letter-spacing:.5px}.memory-dashboard-page .i18n-gloss.i18n-gloss{font-size:min(1em,max(.8em,11px))}.memory-dashboard-page bdi:is(.mem-review-content,.mem-task-desc,.mem-detail-value,.mem-goal-title){text-align:left}:root[dir=rtl] .memory-dashboard-page bdi:is(.mem-review-content,.mem-task-desc,.mem-detail-value,.mem-goal-title){text-align:right}.memory-dashboard-header{border-bottom:1px solid var(--border-light);flex-shrink:0;justify-content:space-between;align-items:center;padding:16px 24px;display:flex}.memory-dashboard-header-left{align-items:center;gap:12px;display:flex}.memory-dashboard-header h1{font-size:15px;font-weight:500;font-family:var(--font-sans);color:var(--text-primary)}.memory-dashboard-header-actions{align-items:center;gap:6px;display:flex}.memory-dashboard-body{scrollbar-width:thin;scrollbar-color:var(--border) transparent;flex:1;padding:24px;overflow-y:auto;container-type:inline-size}.memory-dashboard-body::-webkit-scrollbar{width:5px}.memory-dashboard-body::-webkit-scrollbar-track{background:0 0}.memory-dashboard-body::-webkit-scrollbar-thumb{background:var(--border);border-radius:var(--radius-full)}.mem-section{margin-bottom:28px}.mem-section:last-child{margin-bottom:0}.mem-section-title{font-size:13px;font-weight:500;font-family:var(--font-sans);letter-spacing:0;color:var(--text-secondary);align-items:center;gap:8px;margin-bottom:14px;display:flex}.mem-section-title-row{justify-content:space-between}.mem-section-title-left{align-items:center;gap:8px;display:flex}.mem-section-note{letter-spacing:.5px;text-transform:none;opacity:.8;margin-inline-start:8px;font-weight:400}.mem-section-count{background:var(--bg-tertiary);border:1px solid var(--border);border-radius:var(--radius-full);min-width:20px;height:18px;color:var(--text-muted);letter-spacing:0;font-size:10px;font-weight:500;font-family:var(--font-sans);justify-content:center;align-items:center;padding:0 6px;display:inline-flex}.mem-section-add-btn{font-size:11px;font-weight:500;font-family:var(--font-sans);letter-spacing:.5px;border-radius:var(--radius-md);border:1px solid var(--border);background:var(--bg-secondary);color:var(--text-secondary);cursor:pointer;transition:all var(--duration) var(--ease);align-items:center;gap:5px;padding:4px 10px;display:inline-flex}.mem-section-add-btn:hover{border-color:var(--accent);color:var(--accent);background:var(--accent-dim)}.mem-range-tabs{border:1px solid var(--border);border-radius:var(--radius-md);display:flex;overflow:hidden}.mem-range-tab{font-size:10px;font-weight:500;font-family:var(--font-sans);letter-spacing:.5px;color:var(--text-muted);cursor:pointer;transition:all var(--duration) var(--ease);background:0 0;border:none;padding:3px 10px}.mem-range-tab+.mem-range-tab{border-inline-start:1px solid var(--border)}.mem-range-tab:hover{color:var(--text-primary);background:var(--bg-hover)}.mem-range-tab.active{background:var(--accent-fill);color:var(--accent-fill-text)}.mem-stat-cards{grid-template-columns:repeat(5,minmax(0,1fr));gap:14px;margin-bottom:28px;display:grid}.mem-stat-card{background:var(--bg-secondary);border:1px solid var(--border-light);border-radius:var(--radius-lg);transition:border-color var(--duration) var(--ease), transform var(--duration) var(--ease);padding:18px 20px}.mem-stat-card:hover{border-color:var(--border);transform:translateY(-1px)}.mem-stat-value{font-size:28px;font-weight:500;font-family:var(--font-display);color:var(--text-primary);line-height:1.1}.mem-stat-label{color:var(--text-secondary);font-size:12px;font-weight:500;font-family:var(--font-sans);margin-top:4px}.mem-stat-sub{color:var(--text-muted);font-size:11px;font-family:var(--font-sans);margin-top:2px}.mem-activity-chart{background:var(--bg-secondary);border:1px solid var(--border-light);border-radius:var(--radius-lg);align-items:flex-end;gap:2px;height:120px;padding:14px 10px 28px;display:flex;position:relative;overflow:hidden}.mem-activity-bar-group{cursor:default;flex-direction:column;flex:1;justify-content:flex-end;align-items:center;gap:1px;height:100%;display:flex;position:relative}.mem-activity-bar{width:100%;min-height:0;transition:opacity var(--duration-fast) var(--ease);border-radius:2px 2px 0 0}.mem-activity-bar.conversations{background:var(--accent-blue);opacity:.85}.mem-activity-bar.tool_calls{background:var(--accent-green);opacity:.85}.mem-activity-bar.knowledge{background:var(--accent-purple);opacity:.85}.mem-activity-bar.errors{background:var(--danger);opacity:.85}.mem-activity-bar-group:hover .mem-activity-bar{opacity:1}.mem-activity-date-label{color:var(--text-muted);font-size:9px;font-family:var(--font-sans);white-space:nowrap;position:absolute;bottom:-22px}.mem-activity-legend{font-size:11px;font-family:var(--font-sans);color:var(--text-secondary);gap:16px;margin-top:10px;display:flex}.mem-activity-legend-item{align-items:center;gap:5px;display:flex}.mem-activity-legend-dot{border-radius:2px;width:8px;height:8px}.mem-activity-legend-dot.conversations{background:var(--accent-blue)}.mem-activity-legend-dot.tool_calls{background:var(--accent-green)}.mem-activity-legend-dot.knowledge{background:var(--accent-purple)}.mem-activity-legend-dot.errors{background:var(--danger)}.mem-activity-tooltip{background:var(--bg-tertiary);border:1px solid var(--border);border-radius:var(--radius-sm);font-size:11px;font-family:var(--font-sans);color:var(--text-primary);white-space:nowrap;pointer-events:none;z-index:10;box-shadow:var(--shadow-md);padding:6px 10px;position:absolute;bottom:calc(100% + 8px);left:50%;transform:translate(-50%)}.mem-filters{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:12px;display:flex}.mem-filter-select{font-size:12px;font-family:var(--font-sans);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-input);color:var(--text-primary);cursor:pointer;transition:border-color var(--duration) var(--ease);appearance:none;padding:7px 12px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239898b0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");background-position:right 8px center;background-repeat:no-repeat;outline:none;padding-inline-end:28px}.mem-filter-select:dir(rtl){background-position:8px}.mem-filter-select:focus{border-color:var(--accent)}.mem-category-pills{flex-wrap:wrap;align-items:center;gap:5px;display:flex}.mem-category-pill{font-size:11px;font-weight:500;font-family:var(--font-sans);letter-spacing:.5px;border-radius:var(--radius-full);border:1px solid var(--border);color:var(--text-muted);cursor:pointer;transition:all var(--duration) var(--ease);white-space:nowrap;background:0 0;padding:4px 11px;line-height:1.4}.mem-category-pill:hover{border-color:var(--text-secondary);color:var(--text-primary);background:var(--bg-hover)}.mem-category-pill:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.mem-category-pill.fact.active{background:color-mix(in srgb, var(--accent-blue) 12%, transparent);border-color:var(--accent-blue);color:var(--accent-blue)}.mem-category-pill.preference.active{background:color-mix(in srgb, var(--accent-purple) 12%, transparent);border-color:var(--accent-purple);color:var(--accent-purple)}.mem-category-pill.error.active{background:var(--danger-dim);border-color:var(--danger);color:var(--danger)}.mem-category-pill.skill.active{background:var(--accent-green-dim);border-color:var(--accent-green);color:var(--accent-green)}.mem-category-pill.note.active{background:color-mix(in srgb, var(--accent-yellow) 12%, transparent);border-color:var(--accent-yellow);color:var(--accent-yellow)}.mem-category-pill.reminder.active{background:color-mix(in srgb, var(--accent) 10%, transparent);border-color:var(--accent);color:var(--accent)}.mem-category-pill.clear{border-style:dashed}.mem-category-pill.clear:hover{border-color:var(--danger);color:var(--danger);background:var(--danger-dim);border-style:solid}.mem-filter-search{box-sizing:border-box;width:100%;min-width:180px;font-size:12px;font-family:var(--font-sans);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-input);color:var(--text-primary);transition:border-color var(--duration) var(--ease);outline:none;flex:1;padding-block:7px;padding-inline:32px 12px}.mem-filter-search:focus{border-color:var(--accent)}.mem-filter-search::placeholder{color:var(--text-muted)}.mem-filter-search-wrap{flex:1;min-width:180px;position:relative}.mem-filter-search-wrap .search-icon{inset-inline-start:10px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;transform:translateY(-50%)}.mem-knowledge-table{border-collapse:separate;border-spacing:0;width:100%;font-size:13px}.mem-knowledge-table th{text-align:start;font-size:10px;font-weight:500;font-family:var(--font-sans);letter-spacing:0;color:var(--text-muted);border-bottom:1px solid var(--border);white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none;transition:color var(--duration) var(--ease);padding:8px 12px}.mem-knowledge-table th:hover{color:var(--text-primary)}.mem-knowledge-table th.sorted{color:var(--accent)}.mem-sort-arrow{margin-inline-start:4px;font-size:10px}.mem-knowledge-table td{border-bottom:1px solid var(--border-light);vertical-align:top;font-family:var(--font-sans);padding:10px 12px}.mem-knowledge-table tbody tr{transition:background var(--duration-fast) var(--ease)}.mem-knowledge-table tbody tr:hover{background:var(--tint-subtle)}.mem-cat-badge{font-size:10px;font-weight:500;font-family:var(--font-sans);letter-spacing:.5px;border-radius:var(--radius-full);white-space:nowrap;padding:2px 8px;display:inline-block}.mem-cat-badge.fact{background:color-mix(in srgb, var(--accent-blue) 12%, transparent);color:var(--accent-blue)}.mem-cat-badge.preference{background:color-mix(in srgb, var(--accent-purple) 12%, transparent);color:var(--accent-purple)}.mem-cat-badge.error{background:var(--danger-dim);color:var(--danger)}.mem-cat-badge.skill{background:var(--accent-green-dim);color:var(--accent-green)}.mem-confidence{font-family:var(--font-sans);color:var(--text-secondary);align-items:center;gap:6px;font-size:12px;display:flex}.mem-confidence-bar{background:var(--border);border-radius:var(--radius-full);width:48px;height:4px;overflow:hidden}.mem-confidence-fill{border-radius:var(--radius-full);height:100%;transition:width var(--duration-slow) var(--ease)}.mem-confidence-fill.high{background:var(--accent-green)}.mem-confidence-fill.medium{background:var(--accent-yellow)}.mem-confidence-fill.low{background:var(--text-muted)}.mem-content-cell{text-overflow:clip;white-space:nowrap;max-width:320px;animation:both fade-cut-inline;animation-timeline:scroll(self inline);overflow:hidden}.mem-sensitive-badge{align-items:center;gap:3px;margin-inline-end:4px;font-size:11px;display:inline-flex}.mem-entity-link{color:var(--accent-blue);cursor:pointer;font-size:11px;font-family:var(--font-sans);align-items:center;gap:3px;display:inline-flex}.mem-entity-link:hover{text-decoration:underline}.mem-due-badge{font-size:11px;font-family:var(--font-sans);white-space:nowrap}.mem-due-badge.overdue{color:var(--danger)}.mem-due-badge.upcoming{color:var(--accent-yellow)}.mem-due-badge.none{color:var(--text-muted)}.mem-date-cell{font-size:12px;font-family:var(--font-sans);color:var(--text-secondary);white-space:nowrap}.mem-row-actions{opacity:0;transition:opacity var(--duration-fast) var(--ease);gap:2px;display:flex}.mem-knowledge-table tbody tr:hover .mem-row-actions,.mem-knowledge-table tbody tr:focus-within .mem-row-actions{opacity:1}.mem-row-actions:has(.is-confirm){opacity:1}.mem-knowledge-table .mem-actions-cell{background:var(--bg-primary);position:sticky;inset-inline-end:0;box-shadow:-8px 0 8px -8px #00000059}.mem-knowledge-table .mem-actions-cell:dir(rtl){box-shadow:8px 0 8px -8px #00000059}.mem-knowledge-table tbody tr:hover .mem-actions-cell,.mem-knowledge-table .mem-expanded-row .mem-actions-cell{background:color-mix(in srgb, var(--text-primary) 3%, var(--bg-primary))}.mem-row-action-btn{border-radius:var(--radius-sm);width:26px;height:26px;color:var(--text-muted);transition:all var(--duration-fast) var(--ease);justify-content:center;align-items:center;display:flex}.mem-row-action-btn:hover{background:var(--bg-hover);color:var(--text-primary)}.mem-row-action-btn:disabled{opacity:.45;cursor:not-allowed;color:var(--text-muted);background:0 0}.mem-row-action-btn.delete:hover,.mem-row-action-btn.delete.is-confirm{color:var(--danger)}.mem-row-action-btn.is-confirm{width:auto;padding:0 6px}.mem-row-delete-label{font-size:11px;font-weight:500}.mem-pagination{font-size:12px;font-family:var(--font-sans);color:var(--text-muted);justify-content:space-between;align-items:center;margin-top:12px;display:flex}.mem-pagination-btns{gap:4px;display:flex}.mem-page-btn{border:1px solid var(--border);border-radius:var(--radius-sm);font-size:12px;font-family:var(--font-sans);color:var(--text-secondary);transition:all var(--duration) var(--ease);padding:4px 12px}.mem-page-btn:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}.mem-page-btn:disabled{opacity:.3;cursor:not-allowed}.mem-tool-table{border-collapse:separate;border-spacing:0;width:100%;font-size:13px}.mem-tool-table th{text-align:start;font-size:10px;font-weight:500;font-family:var(--font-sans);letter-spacing:0;color:var(--text-muted);border-bottom:1px solid var(--border);white-space:nowrap;padding:8px 12px}.mem-tool-table td{border-bottom:1px solid var(--border-light);font-family:var(--font-sans);padding:10px 12px;font-size:12px}.mem-tool-table tbody tr{transition:background var(--duration-fast) var(--ease);cursor:default}.mem-tool-table tbody tr:hover{background:var(--tint-subtle)}.mem-tool-name{color:var(--text-primary);font-weight:500}.mem-success-rate{font-weight:500}.mem-success-rate.high{color:var(--accent-green)}.mem-success-rate.medium{color:var(--accent-yellow)}.mem-success-rate.low{color:var(--danger)}.mem-tool-error{vertical-align:top;text-overflow:clip;white-space:nowrap;max-width:260px;color:var(--text-muted);font-size:11px;animation:both fade-cut-inline;animation-timeline:scroll(self inline);display:inline-block;overflow:hidden}.mem-conv-search{margin-bottom:12px;position:relative}.mem-conv-search .search-icon{inset-inline-start:10px;color:var(--text-muted);pointer-events:none;position:absolute;top:50%;transform:translateY(-50%)}.mem-conv-search input{width:100%;font-size:12px;font-family:var(--font-sans);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-input);color:var(--text-primary);transition:border-color var(--duration) var(--ease);outline:none;padding-block:8px;padding-inline:32px 12px}.mem-conv-search input:focus{border-color:var(--accent)}.mem-conv-search input{padding-inline-end:32px}.mem-search-clear{inset-inline-end:8px;border-radius:var(--radius-full);background:var(--bg-tertiary);width:20px;height:20px;color:var(--text-muted);cursor:pointer;transition:all var(--duration) var(--ease);border:none;justify-content:center;align-items:center;display:flex;position:absolute;top:50%;transform:translateY(-50%)}.mem-search-clear:hover{background:var(--border);color:var(--text-primary)}.mem-delete-confirm{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.mem-delete-confirm-label{color:var(--danger);font-size:12px;font-weight:500;font-family:var(--font-sans);white-space:nowrap}.mem-conv-list{flex-direction:column;gap:4px;display:flex}.mem-conv-item{border:1px solid var(--border-light);border-radius:var(--radius-md);transition:border-color var(--duration) var(--ease), background var(--duration) var(--ease);cursor:pointer;justify-content:space-between;align-items:center;padding:10px 14px;display:flex}.mem-conv-item:hover{border-color:var(--border);background:var(--tint-subtle)}.mem-conv-info{flex:1;min-width:0}.mem-conv-session-id{color:var(--text-primary);text-overflow:clip;white-space:nowrap;font-size:12px;font-weight:500;animation:both fade-cut-inline;animation-timeline:scroll(self inline);overflow:hidden}.mem-conv-preview{color:var(--text-muted);text-overflow:clip;white-space:nowrap;margin-top:2px;font-size:12px;animation:both fade-cut-inline;animation-timeline:scroll(self inline);overflow:hidden}.mem-conv-meta{font-size:11px;font-family:var(--font-sans);color:var(--text-muted);flex-shrink:0;gap:12px;margin-inline-start:12px;display:flex}.mem-conv-detail-overlay{background:var(--bg-card);z-index:5;border-radius:var(--radius-xl);flex-direction:column;display:flex;position:absolute;inset:0}.mem-conv-detail-header{border-bottom:1px solid var(--border);flex-shrink:0;justify-content:space-between;align-items:center;padding:14px 20px;display:flex}.mem-conv-detail-header h2{color:var(--text-secondary);font-size:12px}.mem-conv-detail-actions{align-items:center;gap:8px;display:flex}.mem-conv-detail-body{flex:1;padding:16px 20px;overflow-y:auto}.mem-conv-turn{border-bottom:1px solid var(--border-light);padding:8px 0}.mem-conv-turn:last-child{border-bottom:none}.mem-conv-turn-header{justify-content:space-between;align-items:center;margin-bottom:4px;display:flex}.mem-conv-turn-time{color:var(--text-muted);font-size:10px;font-family:var(--font-sans);flex-shrink:0}.mem-conv-turn-role{font-size:10px;font-weight:500;font-family:var(--font-sans);letter-spacing:0;margin-bottom:4px}.mem-conv-turn-role.user{color:var(--accent-blue)}.mem-conv-turn-role.assistant{color:var(--accent-green)}.mem-conv-turn-content{color:var(--text-primary);white-space:pre-wrap;word-break:break-word;font-size:13px;line-height:1.6}.mem-temporal-list{flex-direction:column;gap:6px;display:flex}.mem-temporal-item{border:1px solid var(--border-light);border-radius:var(--radius-md);transition:border-color var(--duration) var(--ease);align-items:flex-start;gap:10px;padding:10px 14px;font-size:13px;display:flex}.mem-temporal-item:hover{border-color:var(--border)}.mem-temporal-item.overdue{border-inline-start:3px solid var(--danger)}.mem-temporal-item.upcoming{border-inline-start:3px solid var(--accent-yellow)}.mem-temporal-icon{flex-shrink:0;margin-top:1px;font-size:16px;line-height:1}.mem-temporal-content{flex:1;min-width:0}.mem-temporal-text{font-family:var(--font-sans);color:var(--text-primary)}.mem-temporal-date{font-size:11px;font-family:var(--font-sans);color:var(--text-muted);margin-top:2px}.mem-two-col{grid-template-columns:repeat(2,minmax(0,1fr));gap:24px;display:grid}.mem-two-col>*{min-width:0}@container (width<=860px){.mem-two-col{grid-template-columns:minmax(0,1fr)}.mem-stat-cards{grid-template-columns:repeat(3,minmax(0,1fr))}}@container (width<=640px){.mem-stat-cards{grid-template-columns:repeat(2,minmax(0,1fr))}}.mem-empty{text-align:center;color:var(--text-muted);font-size:13px;font-family:var(--font-sans);padding:32px 20px}.mem-empty-icon{opacity:.4;margin-bottom:8px;font-size:32px}.mem-loading{color:var(--text-muted);font-size:13px;font-family:var(--font-sans);justify-content:center;align-items:center;gap:10px;padding:40px;display:flex}.mem-spinner{border:2px solid var(--border);border-top-color:var(--accent);width:18px;height:18px;animation:spin var(--duration-spin) var(--ease-linear) infinite;border-radius:50%}.mem-inline-form{background:var(--bg-secondary);border:1px solid var(--border);border-radius:var(--radius-lg);flex-direction:column;gap:10px;margin-bottom:12px;padding:16px;display:flex}.mem-inline-form-row{align-items:center;gap:8px;display:flex}.mem-inline-form-row label{font-size:11px;font-weight:500;font-family:var(--font-sans);letter-spacing:0;color:var(--text-muted);flex-shrink:0;width:80px}.mem-inline-form-row input,.mem-inline-form-row select,.mem-inline-form-row textarea{font-size:12px;font-family:var(--font-sans);border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-input);color:var(--text-primary);transition:border-color var(--duration) var(--ease);outline:none;flex:1;padding:7px 12px}.mem-inline-form-row input:focus,.mem-inline-form-row select:focus,.mem-inline-form-row textarea:focus{border-color:var(--accent)}.mem-inline-form-row textarea{resize:vertical;min-height:60px}.mem-inline-form-actions{justify-content:flex-end;gap:8px;display:flex}.mem-expanded-row{background:var(--tint-subtle)!important}.mem-detail-row td{border-bottom:1px solid var(--border)!important;padding:0!important}.mem-detail-panel{background:var(--bg-secondary);border-top:1px solid var(--border-light);animation:detailExpand var(--duration) var(--ease);padding:14px 20px 16px}@keyframes detailExpand{0%{opacity:0;max-height:0}to{opacity:1;max-height:500px}}.mem-detail-grid{grid-template-columns:repeat(4,1fr);gap:10px 20px;margin-bottom:10px;display:grid}.mem-detail-field{flex-direction:column;gap:2px;display:flex}.mem-detail-field.mem-detail-full{grid-column:1/-1}.mem-detail-label{font-size:10px;font-weight:500;font-family:var(--font-sans);letter-spacing:0;color:var(--text-muted)}.mem-detail-value{font-size:12px;font-family:var(--font-sans);color:var(--text-primary);word-break:break-all}.mem-detail-chain{color:var(--accent-blue)}.mem-detail-content-full{border-top:1px solid var(--border-light);margin-top:8px;padding-top:8px}.mem-detail-content-text{font-size:13px;font-family:var(--font-sans);color:var(--text-primary);white-space:pre-wrap;word-break:break-word;max-height:200px;margin-top:4px;line-height:1.6;overflow-y:auto}.mem-embedding-coverage{align-items:center;gap:8px;padding:0 8px;display:flex}.mem-embedding-bar{background:var(--border);border-radius:var(--radius-full);width:60px;height:5px;overflow:hidden}.mem-embedding-fill{background:var(--accent-green);border-radius:var(--radius-full);height:100%;transition:width var(--duration-slow) var(--ease)}.mem-embedding-label{font-size:11px;font-family:var(--font-sans);color:var(--text-secondary);white-space:nowrap}.mem-maintenance-wrap{position:relative}.mem-maintenance-wrap .btn-icon{align-items:center;gap:0;display:flex}.mem-maintenance-menu{top:calc(100% + 6px);background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-lg);min-width:220px;box-shadow:var(--shadow-lg);z-index:20;animation:modalPanelIn var(--duration-fast) var(--ease);padding:4px;position:absolute;inset-inline-end:0}.mem-maintenance-item{width:100%;font-size:12px;font-family:var(--font-sans);color:var(--text-primary);border-radius:var(--radius-md);transition:background var(--duration-fast) var(--ease);text-align:start;align-items:center;gap:10px;padding:9px 14px;display:flex}.mem-maintenance-item:hover:not(:disabled){background:var(--tint-subtle)}.mem-maintenance-item:disabled{opacity:.5;cursor:not-allowed}.mem-maintenance-divider{background:var(--border-light);height:1px;margin:4px 8px}.mem-spinner-sm{border:2px solid var(--border);border-top-color:var(--accent);width:14px;height:14px;animation:spin var(--duration-spin) var(--ease-linear) infinite;border-radius:50%}.mem-embed-dot{vertical-align:middle;align-items:center;margin-inline-end:5px;display:inline-flex}.mem-embed-dot.embedded{color:var(--accent-green)}.mem-embed-dot.missing{color:var(--danger);opacity:.6}.mem-superseded-row{opacity:.55}.mem-superseded-text{color:var(--text-muted);text-decoration:line-through}.mem-filter-toggle{font-size:11px;font-family:var(--font-sans);color:var(--text-secondary);cursor:pointer;white-space:nowrap;border:1px solid var(--border);border-radius:var(--radius-md);transition:border-color var(--duration) var(--ease);align-items:center;gap:5px;padding:7px 10px;display:flex}.mem-filter-toggle:hover{border-color:var(--border)}.mem-filter-toggle input{cursor:pointer;margin:0}.mem-consolidated-badge{color:var(--accent-green);opacity:.7;vertical-align:middle;align-items:center;margin-inline-start:6px;display:inline-flex}.mem-cat-badge.note{background:color-mix(in srgb, var(--accent-yellow) 12%, transparent);color:var(--accent-yellow)}.mem-cat-badge.reminder{background:color-mix(in srgb, var(--danger) 12%, transparent);color:var(--danger)}.mem-toast-container{bottom:24px;z-index:200;pointer-events:none;flex-direction:column;gap:8px;display:flex;position:fixed;inset-inline-end:24px}.mem-toast{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-lg);font-size:12px;font-family:var(--font-sans);color:var(--text-primary);animation:toastIn var(--duration) var(--ease);pointer-events:auto;align-items:center;gap:8px;padding:10px 18px;display:flex}.mem-toast-success{border-inline-start:3px solid var(--accent-green)}.mem-toast-error{border-inline-start:3px solid var(--danger)}.mem-toast-info{border-inline-start:3px solid var(--accent-blue)}@keyframes toastIn{0%{opacity:0;transform:translateY(10px)scale(.96)}to{opacity:1;transform:none}}.mem-toggle{border-radius:var(--radius-full);background:var(--border);cursor:pointer;width:36px;height:20px;transition:background var(--duration-fast) var(--ease);border:none;flex-shrink:0;padding:0;position:relative}.mem-toggle:disabled{opacity:.5;cursor:not-allowed}.mem-toggle-on{background:var(--accent)}.mem-toggle-knob{top:2px;background:var(--switch-knob);width:16px;height:16px;transition:transform var(--duration-fast) var(--ease);border-radius:50%;position:absolute;inset-inline-start:2px}.mem-toggle-on .mem-toggle-knob{transform:translate(16px)}.mem-toggle-on:dir(rtl) .mem-toggle-knob{transform:translate(-16px)}.mem-setting-row{border-bottom:1px solid var(--border-light);justify-content:space-between;align-items:center;gap:16px;padding:10px 0;display:flex}.mem-setting-row:last-child{border-bottom:none}.mem-setting-info{flex-direction:column;flex:1;gap:3px;min-width:0;display:flex}.mem-setting-label{color:var(--text-primary);font-size:12px;font-weight:500}.mem-setting-desc{color:var(--text-muted);font-size:11px;line-height:1.4}.mem-setting-row-danger .mem-setting-label{color:var(--danger)}.mem-btn-danger{border:1px solid var(--danger);color:var(--danger);cursor:pointer;transition:background var(--duration) var(--ease), color var(--duration) var(--ease);white-space:nowrap;background:0 0;border-radius:6px;flex-shrink:0;padding:5px 12px;font-size:11px;font-weight:500}.mem-btn-danger:hover:not(:disabled){background:var(--danger);color:var(--text-inverse)}.mem-btn-danger:disabled{opacity:.5;cursor:not-allowed}.mem-db-footer{border-top:1px solid var(--border-light);font-size:11px;font-family:var(--font-sans);color:var(--text-muted);justify-content:space-between;align-items:center;margin-top:20px;padding-top:14px;display:flex}.mem-tab-bar{border-bottom:1px solid var(--border);background:var(--bg-card);flex-shrink:0;gap:0;padding:0 24px;display:flex}.mem-tab-btn{font-size:13px;font-weight:500;font-family:var(--font-sans);color:var(--text-muted);cursor:pointer;transition:color var(--duration) var(--ease), border-color var(--duration) var(--ease);background:0 0;border:none;border-bottom:2px solid #0000;align-items:center;gap:6px;margin-bottom:-1px;padding:10px 18px;display:flex}.mem-tab-btn:hover{color:var(--text-secondary)}.mem-tab-active{color:var(--text-primary);border-bottom-color:var(--accent)}.mem-profile-grid{grid-template-columns:1fr 1fr;gap:20px;display:grid}.mem-profile-card{background:var(--bg-secondary);border:1px solid var(--border-light);border-radius:var(--radius-lg);flex-direction:column;gap:10px;padding:20px;display:flex}.mem-profile-card-title{font-size:13px;font-weight:500;font-family:var(--font-sans);color:var(--text-primary);align-items:center;gap:8px;display:flex}.mem-profile-desc{color:var(--text-secondary);margin:0;font-size:12px;line-height:1.5}.mem-profile-note{color:var(--text-muted);margin:0;font-size:12px}.mem-tab-intro{max-width:72ch;color:var(--text-secondary);grid-column:1/-1;margin:0;font-size:14px;line-height:1.5}.mem-profile-checkbox{font-size:12px;font-family:var(--font-sans);color:var(--text-secondary);cursor:pointer;align-items:center;gap:6px;display:flex}.mem-profile-checkbox input{cursor:pointer;margin:0}.mem-profile-run-btn{align-self:flex-start;align-items:center;gap:6px;padding:8px 18px;font-size:12px;display:flex}.mem-log{background:var(--bg-code);border:1px solid var(--border-code);border-radius:var(--radius-md);max-height:200px;font-family:var(--font-sans);scrollbar-width:thin;scrollbar-color:var(--border-code) transparent;padding:8px;font-size:12px;line-height:1.6;overflow-y:auto}.mem-log::-webkit-scrollbar{width:4px}.mem-log::-webkit-scrollbar-track{background:0 0}.mem-log::-webkit-scrollbar-thumb{background:var(--border-code);border-radius:2px}.mem-log-line{white-space:pre-wrap;word-break:break-word;color:var(--text-code)}.mem-log-line.finding{color:var(--code-warning)}.mem-log-line.error{color:var(--code-danger)}.mem-review-section{flex-direction:column;gap:8px;display:flex}.mem-review-header{font-size:11px;font-weight:500;font-family:var(--font-sans);letter-spacing:0;color:var(--text-muted)}.mem-review-list{scrollbar-width:thin;scrollbar-color:var(--border) transparent;flex-direction:column;gap:4px;max-height:240px;display:flex;overflow-y:auto}.mem-review-list::-webkit-scrollbar{width:4px}.mem-review-list::-webkit-scrollbar-track{background:0 0}.mem-review-list::-webkit-scrollbar-thumb{background:var(--border);border-radius:2px}.mem-review-item{background:var(--bg-card);border:1px solid var(--border-light);border-radius:var(--radius-md);cursor:pointer;transition:border-color var(--duration) var(--ease);align-items:center;gap:8px;padding:6px 8px;display:flex}.mem-review-item:hover{border-color:var(--border)}.mem-review-item input{cursor:pointer;flex-shrink:0;margin:0}.mem-review-content{min-width:0;color:var(--text-primary);text-overflow:clip;white-space:nowrap;flex:1;font-size:12px;animation:both fade-cut-inline;animation-timeline:scroll(self inline);overflow:hidden}.mem-conf-badge{font-size:10px;font-family:var(--font-sans);border-radius:var(--radius-sm);background:color-mix(in srgb, var(--text-muted) 12%, transparent);color:var(--text-muted);flex-shrink:0;padding:2px 6px}.mem-source-badge{font-size:10px;font-family:var(--font-sans);border-radius:var(--radius-sm);background:color-mix(in srgb, var(--text-muted) 12%, transparent);color:var(--text-secondary);flex-shrink:0;padding:2px 6px}.mem-domain-badge{font-size:10px;font-family:var(--font-sans);border-radius:var(--radius-sm);flex-shrink:0;padding:2px 8px;font-weight:500}.mem-domain-badge.blue{background:color-mix(in srgb, var(--accent-blue) 15%, transparent);color:var(--accent-blue)}.mem-domain-badge.purple{background:color-mix(in srgb, var(--accent-purple) 15%, transparent);color:var(--accent-purple)}.mem-domain-badge.green{background:color-mix(in srgb, var(--accent-green) 15%, transparent);color:var(--accent-green)}.mem-domain-badge.gray{background:color-mix(in srgb, var(--text-muted) 12%, transparent);color:var(--text-muted)}.mem-review-actions{align-items:center;gap:12px;margin-top:4px;display:flex}.mem-review-actions .btn-primary{align-items:center;gap:6px;padding:7px 16px;font-size:12px;display:flex}.mem-review-select-links{font-size:11px;font-family:var(--font-sans);color:var(--text-muted)}.mem-link-btn{font:inherit;color:var(--accent-blue);cursor:pointer;background:0 0;border:none;padding:0}.mem-link-btn:hover,.mem-link-btn:focus-visible{text-decoration:underline}.mem-profile-success{background:color-mix(in srgb, var(--accent-green) 10%, transparent);border:1px solid color-mix(in srgb, var(--accent-green) 25%, transparent);border-radius:var(--radius-md);font-size:12px;font-family:var(--font-sans);color:var(--accent-green);align-items:center;gap:6px;padding:8px 12px;display:flex}.mem-profile-empty{text-align:center;color:var(--text-muted);font-size:12px;font-family:var(--font-sans);padding:12px}@media (width<=768px){.memory-dashboard-header{padding-inline-start:var(--sidebar-toggle-clearance)}}@media (width<=900px){.mem-stat-cards{grid-template-columns:repeat(2,1fr)}.mem-two-col{grid-template-columns:1fr}.mem-embedding-coverage{display:none}.mem-detail-grid{grid-template-columns:repeat(2,1fr)}.mem-profile-grid{grid-template-columns:1fr}}@media (width<=600px){.mem-stat-cards{grid-template-columns:1fr}.memory-dashboard-page{height:100%}.mem-knowledge-table{font-size:12px}.mem-filters{flex-direction:column}.mem-toast-container{inset-inline:12px;bottom:12px}}.mem-goals-tab{flex-direction:column;gap:14px;padding:16px;display:flex}.mem-goals-stats-row{flex-wrap:wrap;gap:10px;display:flex}.mem-goals-stat-pill{background:var(--bg-hover);border:1px solid var(--border);border-radius:20px;align-items:center;gap:6px;padding:5px 12px;font-size:12px;font-weight:500;display:flex}.mem-goals-stat-n{font-size:16px;font-weight:500}.mem-goals-stat-label{opacity:.7;text-transform:capitalize}.mem-goal-status-queued{border-color:var(--accent-blue)!important}.mem-goal-status-in-progress{border-color:var(--accent-yellow)!important}.mem-goal-status-completed{border-color:var(--accent-green)!important}.mem-goal-status-failed{border-color:var(--danger)!important}.mem-goal-status-cancelled{opacity:.6;border-color:var(--border)!important}.mem-goals-approval-banner{background:color-mix(in srgb, var(--accent-yellow) 10%, transparent);border:1px solid color-mix(in srgb, var(--accent-yellow) 40%, transparent);border-radius:var(--radius-lg);flex-direction:column;gap:10px;padding:12px 14px;display:flex}.mem-goals-approval-title{opacity:.85;align-items:center;gap:6px;font-size:12px;font-weight:500;display:flex}.mem-goals-approval-item{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-md);justify-content:space-between;align-items:flex-start;gap:12px;padding:8px 10px;display:flex}.mem-goals-approval-text{flex-direction:column;gap:3px;font-size:13px;display:flex}.mem-goals-approval-text strong{font-weight:500}.mem-goals-approval-text span{opacity:.7;font-size:12px}.mem-goals-approval-actions{flex-shrink:0;gap:6px;display:flex}.btn-danger-sm{border-radius:var(--radius-md);background:color-mix(in srgb, var(--danger) 15%, transparent);border:1px solid color-mix(in srgb, var(--danger) 40%, transparent);color:var(--text-primary);cursor:pointer;padding:4px 10px;font-size:12px}.btn-danger-sm:hover{background:color-mix(in srgb, var(--danger) 25%, transparent)}.mem-goals-toolbar{gap:8px;display:flex}.mem-form-error{color:var(--danger);margin:8px 0 0;font-size:13px}.mem-goals-add-form{background:var(--bg-hover);border:1px solid var(--border);border-radius:var(--radius-lg);flex-direction:column;gap:8px;padding:12px;display:flex}.mem-goals-form-row{align-items:center;gap:8px;display:flex}.mem-select{border-radius:var(--radius-md);background:var(--bg-card);border:1px solid var(--border);color:var(--text-primary);cursor:pointer;padding:6px 10px;font-size:13px}.mem-input{border:1px solid var(--border);border-radius:var(--radius-md);background:var(--bg-card);min-height:34px;color:var(--text-primary);font-family:var(--font-sans);transition:border-color var(--duration-fast) var(--ease);padding:7px 12px;font-size:14px;line-height:1.45}.mem-input::placeholder{color:var(--text-muted)}.mem-input:focus{border-color:var(--accent)}textarea.mem-input{resize:vertical}.mem-goals-list{flex-direction:column;gap:8px;display:flex}.mem-goal-card{border:1px solid var(--border);border-radius:var(--radius-lg);background:var(--bg-card);transition:border-color var(--duration-fast) var(--ease);overflow:hidden}.mem-goal-header{cursor:pointer;-webkit-user-select:none;user-select:none;justify-content:space-between;align-items:center;gap:8px;padding:10px 14px;display:flex}.mem-goal-header:hover{background:var(--bg-hover)}.mem-goal-header-left{flex:1;align-items:center;gap:8px;min-width:0;display:flex}.mem-goal-header-right{flex-shrink:0;align-items:center;gap:8px;display:flex}.mem-goal-status-dot{background:var(--text-muted);border-radius:50%;flex-shrink:0;width:8px;height:8px}.mem-goal-status-dot.status-queued{background:var(--accent-blue)}.mem-goal-status-dot.status-in-progress{background:var(--accent-yellow)}.mem-goal-status-dot.status-completed{background:var(--accent-green)}.mem-goal-status-dot.status-failed{background:var(--danger)}.mem-goal-title{white-space:nowrap;text-overflow:clip;font-size:13px;font-weight:500;animation:both fade-cut-inline;animation-timeline:scroll(self inline);overflow:hidden}.mem-goal-priority{border-radius:10px;flex-shrink:0;padding:1px 6px;font-size:11px;font-weight:500}.mem-priority-high{background:color-mix(in srgb, var(--danger) 15%, transparent)}.mem-priority-medium{background:color-mix(in srgb, var(--accent-yellow) 15%, transparent)}.mem-priority-low{background:color-mix(in srgb, var(--accent-blue) 15%, transparent)}.mem-goal-cancelled-label{background:var(--bg-hover);border:1px solid var(--border)}.mem-goal-source-badge{background:color-mix(in srgb, var(--accent-purple) 15%, transparent);border-radius:10px;flex-shrink:0;align-items:center;gap:3px;padding:1px 6px;font-size:10px;display:flex}.mem-goal-task-count{opacity:.6;align-items:center;gap:4px;font-size:12px;display:flex}.mem-goal-action-btn{border-radius:var(--radius-md);background:var(--bg-hover);border:1px solid var(--border);color:var(--text-primary);cursor:pointer;align-items:center;gap:4px;padding:3px 8px;font-size:11px;display:flex}.mem-goal-action-btn:hover{background:var(--bg-active)}.mem-goal-delete-btn:hover{background:color-mix(in srgb, var(--danger) 15%, transparent);border-color:color-mix(in srgb, var(--danger) 40%, transparent)}.mem-chevron-open{transition:transform var(--duration-fast) var(--ease);transform:rotate(180deg)}.mem-goal-body{border-top:1px solid var(--border);flex-direction:column;gap:8px;padding:0 14px 12px;display:flex}.mem-goal-desc{opacity:.7;margin:8px 0 0;font-size:12px}.mem-goal-progress{background:var(--bg-hover);border-radius:var(--radius-md);opacity:.8;padding:6px 8px;font-size:12px}.mem-goal-no-tasks{opacity:.5;font-size:12px;font-style:italic}.mem-task-list{flex-direction:column;gap:4px;margin-top:4px;display:flex}.mem-task-row{border-radius:var(--radius-md);align-items:flex-start;gap:8px;padding:5px 8px;font-size:12px;display:flex}.mem-task-row:hover{background:var(--bg-hover)}.mem-task-dot{background:var(--text-muted);border-radius:50%;flex-shrink:0;width:7px;height:7px;margin-top:3px}.mem-task-dot.status-in-progress{background:var(--accent-yellow)}.mem-task-dot.status-completed{background:var(--accent-green)}.mem-task-dot.status-failed{background:var(--danger)}.mem-task-dot.status-blocked{background:var(--accent-purple)}.mem-task-desc{flex:1}.mem-task-status-label{opacity:.5;text-transform:capitalize;flex-shrink:0;font-size:10px}.mem-task-result{opacity:.6;text-overflow:clip;white-space:nowrap;flex-shrink:0;max-width:200px;font-size:11px;animation:both fade-cut-inline;animation-timeline:scroll(self inline);overflow:hidden}.mem-tab-badge{background:var(--accent-yellow);min-width:16px;height:16px;color:var(--text-inverse);border-radius:8px;justify-content:center;align-items:center;margin-inline-start:2px;padding:0 4px;font-size:10px;font-weight:500;display:inline-flex}.mem-goal-header:focus-visible{outline:2px solid var(--accent-blue);outline-offset:-2px}.mem-goal-delete-confirm{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 40%, transparent)}.mem-advanced-error{border-radius:var(--radius-md);border:1px solid color-mix(in srgb, var(--danger) 40%, transparent);background:color-mix(in srgb, var(--danger) 10%, transparent);color:var(--text-primary);align-items:center;gap:8px;margin-bottom:16px;padding:10px 14px;font-size:13px;display:flex}.mem-about-title{color:var(--text-primary);margin:4px 0 6px;font-size:20px;font-weight:500}.mem-about-intro{color:var(--text-secondary);margin:0 0 18px;font-size:14px}.mem-about-add{flex-wrap:wrap;gap:8px;margin-bottom:20px;display:flex}.mem-about-add .mem-input{flex:360px;min-width:0}.mem-about-add .mem-about-when{flex:none}.mem-about-edit .mem-about-when{align-self:flex-start}.mem-about-group{margin-bottom:22px}.mem-about-group-title{letter-spacing:.5px;color:var(--text-muted);margin:0 0 8px;font-size:12px;font-weight:500}.mem-about-list{border:1px solid var(--border);border-radius:var(--radius-lg);background:var(--bg-secondary);margin:0;padding:0;list-style:none}.mem-about-item{align-items:flex-start;gap:12px;padding:12px 14px;display:flex}.mem-about-item+.mem-about-item{border-top:1px solid var(--border)}.mem-about-text{min-width:0;color:var(--text-primary);overflow-wrap:anywhere;flex:1;font-size:14px;line-height:1.45}.mem-about-meta{color:var(--text-muted);margin-top:2px;font-size:12px;display:block}.mem-about-due{color:var(--text-secondary);margin-top:2px;font-size:12px;font-weight:500;display:block}.mem-about-due.is-overdue{color:var(--danger)}.mem-about-actions{flex-shrink:0;gap:6px;display:flex}.mem-about-btn{border:1px solid var(--border);border-radius:var(--radius-md);color:var(--text-secondary);cursor:pointer;background:0 0;align-items:center;gap:4px;padding:4px 8px;font-size:12px;display:inline-flex}.mem-about-btn:not(:disabled):hover,.mem-about-btn:focus-visible{color:var(--text-primary);background:var(--bg-hover)}.mem-about-btn:disabled{opacity:.45;cursor:not-allowed}.mem-about-btn-remove:hover,.mem-about-btn-remove:focus-visible{color:var(--danger);border-color:color-mix(in srgb, var(--danger) 40%, transparent)}.mem-about-edit{flex-direction:column;flex:1;gap:8px;display:flex}.mem-about-edit-actions{gap:8px;display:flex}.mem-about-forgotten{border-radius:var(--radius-md);background:var(--bg-tertiary);color:var(--text-secondary);justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px;padding:8px 12px;font-size:13px;display:flex}.mem-about-link{font:inherit;color:var(--accent);cursor:pointer;white-space:nowrap;background:0 0;border:none;align-items:center;gap:4px;padding:0;font-weight:500;display:inline-flex}.mem-about-forgotten>span{flex:1;min-width:0}.mem-about-link:hover,.mem-about-link:focus-visible{text-decoration:underline}.mem-about-empty{text-align:center;color:var(--text-secondary);padding:32px 16px;font-size:14px}.mem-about-hint{color:var(--text-muted);font-size:13px}.mem-about-more{color:var(--text-secondary);justify-content:center;align-items:center;gap:12px;padding:12px 0;font-size:13px;display:flex}@media (width<=600px){.mem-about-add{flex-wrap:wrap}.mem-about-add .mem-input{flex-basis:100%}.mem-about-add .mem-select{flex:1}.mem-about-item{flex-direction:column}.mem-tab-bar{padding:0 12px;overflow-x:auto}.mem-tab-btn{white-space:nowrap;flex-shrink:0;padding:10px 12px}}
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{c as t,ct as n,gi as r,it as i,l as a,s as o,tt as s,u as c}from"./useFocusTrap-ChaVFhZD.js";import{Dn as ee,Z as te,dn as l,f as u,gn as d,nn as f}from"./index-BLw-Jjdx.js";var p=e(r(),1);function m(){return n(`GET`,`/messaging/discord`)}function h(e){return n(`POST`,`/messaging/discord/connect`,{token:e},i)}function g(e=!1){return n(`POST`,`/messaging/discord/start`,{take_over:e},i)}function _(){return n(`POST`,`/messaging/discord/stop`,void 0,i)}function ne(){return n(`POST`,`/messaging/discord/restart`,void 0,i)}function re(){return n(`POST`,`/messaging/discord/forget-always`,void 0,i)}function v(){return n(`POST`,`/messaging/discord/pair`,void 0,i)}function y(){return n(`POST`,`/messaging/discord/disconnect`,void 0,i)}var b=3e3,x=new Set([`starting`,`pairing`,`connected`]),S=new Set([`error`,`taken_over`,`token_invalid`,`credentials_unavailable`,`conflict`]),C=new Set([`error`,`credentials_unavailable`]),w={newApp:`New Application`,create:`Create`,bot:`Bot`,reset:`Reset Token`,copy:`Copy`,publicBot:`Public Bot`,message:`Message`,createOwn:`Create My Own`,forFriends:`For me and my friends`};function T(e){return e instanceof s?e.detail||e.message:e instanceof Error?e.message:String(e)}function E(e){return e.length===8?`${e.slice(0,4)}-${e.slice(4)}`:e}function D({href:e,children:t,primary:n}){return c(`a`,{className:`${n?`btn-primary`:`btn-secondary`} messaging-link`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:[t,a(l,{size:13,"aria-hidden":`true`,className:`messaging-link-icon`})]})}function O({n:e,title:t,children:n}){return c(`li`,{className:`messaging-step`,children:[a(`span`,{className:`messaging-step-number`,"aria-hidden":`true`,children:a(`bdi`,{dir:`ltr`,children:e})}),c(`div`,{className:`messaging-step-body`,children:[a(`h4`,{className:`settings-label`,children:t}),n]})]})}function k(){let e=o(),[n,r]=(0,p.useState)(null),[i,s]=(0,p.useState)(null),[l,k]=(0,p.useState)(null),[A,j]=(0,p.useState)(null),[M,N]=(0,p.useState)(``),[P,F]=(0,p.useState)(!1),[I,L]=(0,p.useState)(!1),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(!1),H=(0,p.useRef)(!1),U=(0,p.useCallback)(e=>{H.current&&e.paired&&e.state===`connected`&&L(!0),H.current=e.state===`pairing`,r(e)},[]),W=(0,p.useCallback)(()=>{m().then(e=>{s(null),U(e)}).catch(e=>s(T(e)))},[U]);(0,p.useEffect)(W,[W]),(0,p.useEffect)(()=>z(null),[n?.pairing_code]);let G=n!==null&&x.has(n.state);(0,p.useEffect)(()=>{if(G)return te(W,b)},[G,W]);let K=async(e,t)=>{k(e),j(null),L(!1);try{U(await t())}catch(e){j(T(e))}finally{k(null)}},q=async()=>{k(`connect`),j(null);try{let e=await h(M.trim());N(``),F(e.connect.bot_public),U(e.status)}catch(e){j(T(e))}finally{k(null)}},J=e=>{navigator.clipboard.writeText(e).then(()=>z(`ok`),()=>z(`failed`))},Y=e=>l===e&&a(f,{size:13,className:`spin`,"aria-hidden":`true`});if(!n)return c(`div`,{className:`settings-pane`,children:[a(`h2`,{className:`settings-pane-title`,children:e(`settings.section.messaging`)}),i?c(`div`,{className:`settings-card`,children:[a(`p`,{className:`settings-error`,role:`alert`,children:e(`settings.messaging.loadFailed`,{error:i})}),a(`button`,{type:`button`,className:`btn-secondary`,onClick:W,children:e(`settings.messaging.retry`)})]}):c(`p`,{className:`settings-hint`,children:[a(f,{size:13,className:`spin`}),` `,e(`settings.loading`)]})]});let X=n,Z=!X.connected||X.state===`token_invalid`||X.state===`conflict`,ie=X.connected&&!Z&&(X.state===`pairing`||X.state===`connected`&&!X.paired),ae=X.connected&&X.paired&&X.state===`connected`,oe=c(`ol`,{className:`messaging-steps`,children:[c(O,{n:1,title:e(`settings.messaging.step1.title`),children:[c(`ol`,{className:`messaging-substeps settings-hint`,children:[a(`li`,{children:e(`settings.messaging.step1.a`,{label:w.newApp})}),a(`li`,{children:e(`settings.messaging.step1.b`,{label:w.create})}),a(`li`,{children:e(`settings.messaging.step1.c`,{label:w.bot})}),a(`li`,{children:e(`settings.messaging.step1.d`,{reset:w.reset,copy:w.copy})})]}),a(`p`,{className:`settings-hint`,children:e(`settings.messaging.step1.noIntents`)}),a(`div`,{className:`settings-row`,children:a(D,{href:X.portal_url,children:e(`settings.messaging.openPortal`)})})]}),c(O,{n:2,title:e(`settings.messaging.step2.title`),children:[c(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),M.trim()&&!l&&q()},children:[a(`input`,{type:`password`,className:`settings-input`,"aria-label":e(`settings.messaging.tokenLabel`),placeholder:e(`settings.messaging.tokenPlaceholder`),autoComplete:`off`,spellCheck:!1,value:M,onChange:e=>N(e.target.value),disabled:l!==null}),c(`button`,{type:`submit`,className:`btn-primary`,disabled:!M.trim()||l!==null,children:[Y(`connect`),e(l===`connect`?`settings.messaging.connecting`:`settings.messaging.connect`)]})]}),l===`connect`&&a(`p`,{className:`settings-hint`,children:e(`settings.messaging.connectingHint`)})]})]}),se=c(`ol`,{className:`messaging-steps`,start:3,children:[c(O,{n:3,title:e(`settings.messaging.step3.title`),children:[a(`p`,{className:`settings-hint`,children:e(`settings.messaging.step3.why`)}),a(`p`,{className:`settings-hint`,children:e(`settings.messaging.step3.how`,{own:w.createOwn,friends:w.forFriends})}),a(`div`,{className:`settings-row`,children:a(D,{href:X.invite_url,children:e(`settings.messaging.openInvite`)})}),a(`p`,{className:`settings-note`,children:e(`settings.messaging.step3.safe`)})]}),c(O,{n:4,title:e(`settings.messaging.step4.title`),children:[X.pairing_code?c(`div`,{className:`messaging-code-row`,children:[a(`bdi`,{dir:`ltr`,className:`messaging-code`,"data-testid":`discord-pairing-code`,children:E(X.pairing_code)}),c(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>J(X.pairing_code),children:[a(R===`ok`?ee:d,{size:13,"aria-hidden":`true`}),e(R===`ok`?`settings.messaging.copied`:`settings.messaging.copy`)]})]}):c(`p`,{className:`settings-hint`,children:[a(f,{size:13,className:`spin`}),` `,e(`settings.messaging.waitingCode`)]}),R===`failed`&&a(`p`,{className:`settings-error`,role:`alert`,children:e(`settings.messaging.copyFailed`)}),X.bot_profile_url&&a(`div`,{className:`settings-row`,children:a(D,{href:X.bot_profile_url,children:e(`settings.messaging.openBot`)})}),a(`p`,{className:`settings-hint`,children:e(`settings.messaging.step4.hint`,{label:w.message})}),a(`p`,{className:`settings-note`,children:e(`settings.messaging.step4.onlyYou`)})]})]}),ce=(()=>{switch(X.state){case`stopped`:case`error`:return c(`button`,{type:`button`,className:`btn-primary`,disabled:l!==null,onClick:()=>K(`start`,()=>g()),children:[Y(`start`),e(`settings.messaging.start`)]});case`credentials_unavailable`:return c(`button`,{type:`button`,className:`btn-primary`,disabled:l!==null,onClick:()=>K(`start`,()=>g()),children:[Y(`start`),e(`settings.messaging.retry`)]});case`taken_over`:return c(`button`,{type:`button`,className:`btn-primary`,disabled:l!==null,onClick:()=>K(`takeOver`,()=>g(!0)),children:[Y(`takeOver`),e(`settings.messaging.takeOver`)]});default:return null}})(),Q=X.state===`starting`||l===`start`||l===`takeOver`,$={stopped:e(X.autostart?`settings.messaging.state.crashed`:`settings.messaging.state.stopped`),error:e(`settings.messaging.state.error`),taken_over:e(`settings.messaging.state.takenOver`),token_invalid:e(`settings.messaging.state.tokenInvalid`),credentials_unavailable:e(`settings.messaging.state.credentials`),conflict:e(`settings.messaging.state.conflict`)};return c(`div`,{className:`settings-pane`,children:[a(`h2`,{className:`settings-pane-title`,children:e(`settings.section.messaging`)}),c(`section`,{className:`settings-card messaging-card`,"aria-label":e(`settings.messaging.discord`),children:[c(`div`,{className:`settings-row settings-row-between`,children:[a(`h3`,{className:`settings-label messaging-card-title`,children:e(`settings.messaging.discord`)}),X.connected&&X.bot_name&&c(`span`,{className:`settings-hint`,children:[e(`settings.messaging.botIs`),` `,a(`bdi`,{children:X.bot_name})]})]}),!X.connected&&c(t.Fragment,{children:[a(`p`,{className:`settings-pane-lede`,children:e(`settings.messaging.pitch`)}),a(`p`,{className:`settings-hint`,children:e(`settings.messaging.onlyYou`)})]}),$[X.state]&&X.connected&&!Q&&c(`div`,{className:S.has(X.state)||X.state===`stopped`&&X.autostart?`settings-notice`:`messaging-status`,children:[a(`p`,{children:$[X.state]}),C.has(X.state)&&X.detail&&a(`p`,{className:`settings-hint`,children:a(`bdi`,{dir:`auto`,children:X.detail})}),ce]}),!X.connected&&X.state===`conflict`&&a(`div`,{className:`settings-notice`,children:a(`p`,{children:e(`settings.messaging.state.conflict`)})}),X.connected&&Q&&c(`p`,{className:`settings-hint`,role:`status`,children:[a(f,{size:13,className:`spin`}),` `,e(`settings.messaging.starting`)]}),Z&&oe,ie&&c(t.Fragment,{children:[a(`p`,{className:`settings-hint`,children:e(`settings.messaging.pairingLede`)}),se,P&&X.bot_page_url&&c(`div`,{className:`settings-notice`,children:[a(`p`,{children:e(`settings.messaging.publicTip`,{label:w.publicBot})}),a(D,{href:X.bot_page_url,children:e(`settings.messaging.openBotPage`)})]}),X.state===`connected`&&!X.paired&&c(`button`,{type:`button`,className:`btn-primary`,disabled:l!==null,onClick:()=>K(`pair`,v),children:[Y(`pair`),e(`settings.messaging.showCode`)]})]}),ae&&c(t.Fragment,{children:[I&&a(`p`,{className:`settings-ok`,role:`status`,children:e(`settings.messaging.paired`)}),c(`p`,{className:`messaging-answering`,children:[a(`span`,{className:`settings-key-status settings-ok`}),c(`span`,{className:`messaging-answering-text`,children:[a(`span`,{children:e(`settings.messaging.answering`,{owner:X.owner_name,bot:X.bot_name})}),X.model&&a(`bdi`,{className:`settings-hint messaging-model`,children:X.model})]})]}),a(`p`,{className:`settings-hint`,children:e(`settings.messaging.answeringHint`)}),c(`div`,{className:`settings-row`,children:[X.bot_profile_url&&a(D,{href:X.bot_profile_url,primary:!0,children:e(`settings.messaging.openInDiscord`)}),c(`button`,{type:`button`,className:`btn-secondary`,disabled:l!==null,onClick:()=>K(`stop`,_),children:[Y(`stop`),e(`settings.messaging.stop`)]}),c(`button`,{type:`button`,className:`btn-secondary`,disabled:l!==null,onClick:()=>K(`restart`,ne),children:[Y(`restart`),e(`settings.messaging.restart`)]}),c(`button`,{type:`button`,className:`btn-secondary`,disabled:l!==null,onClick:()=>K(`pair`,v),children:[Y(`pair`),e(`settings.messaging.pairOther`)]})]})]}),X.connected&&(X.always_allowed?.length??0)>0&&c(`div`,{className:`messaging-status`,children:[a(`p`,{children:e(`settings.messaging.alwaysAllowed`)}),a(`ul`,{className:`settings-hint messaging-always-list`,children:X.always_allowed.map(e=>a(`li`,{children:a(`bdi`,{dir:`auto`,children:e})},e))}),a(`div`,{className:`settings-row`,children:c(`button`,{type:`button`,className:`btn-secondary`,disabled:l!==null,onClick:()=>K(`forget`,re),children:[Y(`forget`),e(`settings.messaging.forgetAlways`)]})})]}),A&&a(`p`,{className:`settings-error`,role:`alert`,children:a(`bdi`,{dir:`auto`,children:A})}),X.connected&&a(`div`,{className:`messaging-footer`,children:c(`button`,{type:`button`,className:`btn-danger`,disabled:l!==null,onClick:()=>V(!0),children:[Y(`disconnect`),e(`settings.messaging.disconnect`)]})})]}),B&&a(u,{title:e(`settings.messaging.disconnectTitle`),confirmLabel:e(`settings.messaging.disconnect`),cancelLabel:e(`settings.messaging.cancel`),danger:!0,onConfirm:()=>{V(!1),K(`disconnect`,y)},onCancel:()=>V(!1),children:a(`p`,{children:e(`settings.messaging.disconnectBody`)})})]})}export{k as MessagingSettings};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-DfYHeeW3.js","./rolldown-runtime-XKyaHtl9.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Yt as t,_ as n,c as r,ci as i,gi as a,l as o,n as s,s as c,u as l}from"./useFocusTrap-ChaVFhZD.js";import{Dn as u,Gt as d,Jt as f,Rt as p,a as m,dn as h,gn as g,h as _}from"./index-BLw-Jjdx.js";var v=e(a(),1),y=null,b=`https://ngrok.com/download`;function x({isOpen:a,onClose:x,onStop:S,error:C,setupCommands:w,onRetry:T}){let[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(!1),A=c(),j=Array.isArray(w),M=!!C||j,[N,P]=(0,v.useState)(null),F=(0,v.useRef)(null);n(a,x);let I=(0,v.useRef)(null);s(I,a),_(I,a);let L=(0,v.useCallback)(async()=>{try{let e=await t();return D(e),e}catch(e){return i.system.error(`Failed to fetch tunnel status`,e),null}},[]);(0,v.useEffect)(()=>{if(!a||M)return;L();let e=setInterval(async()=>{let t=await L();t?.active&&t?.url&&clearInterval(e)},2e3);return()=>clearInterval(e)},[a,M,L]),(0,v.useEffect)(()=>{if(!E?.active||!E.url||!E.token||!F.current)return;let t=`${E.url}/?token=${E.token}`;i.system.info(`Generating QR code for: ${t}`),(async()=>{if(P(null),!y)try{let t=await m(()=>import(`./browser-DfYHeeW3.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1]),import.meta.url);y=t.default||t}catch{i.system.error(`QR code library not available - install with: npm install qrcode`),P(`QR code unavailable on this build. Use the link below instead.`);return}let n=getComputedStyle(document.documentElement),r=n.getPropertyValue(`--text-primary`).trim(),a=n.getPropertyValue(`--bg-primary`).trim();if(!r||!a)i.system.error(`QR code skipped: --text-primary/--bg-primary did not resolve. styles/index.css must be loaded before this modal renders.`),P(`QR code unavailable — the theme did not load. Use the link below instead.`);else try{await y.toCanvas(F.current,t,{width:200,margin:2,color:{dark:r,light:a}})}catch(e){i.system.error(`QR code generation failed`,e),P(`QR code could not be drawn. Use the link below instead.`)}})()},[E?.active,E?.url,E?.token]);let R=(0,v.useRef)(null),z=(0,v.useCallback)(()=>{if(!E?.url||!E?.token)return;let e=`${E.url}/?token=${E.token}`;navigator.clipboard.writeText(e).then(()=>{k(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>k(!1),2e3)})},[E]);if((0,v.useEffect)(()=>()=>{R.current&&clearTimeout(R.current)},[]),!a)return null;let B=E?.active&&E?.url&&E?.token?`${E.url}/?token=${E.token}`:``;return o(`div`,{ref:I,className:`modal-overlay`,onClick:x,role:`dialog`,"aria-modal":`true`,"aria-label":A(`sidebar.mobileAccess`),children:l(`div`,{className:`modal-panel mobile-modal`,onClick:e=>e.stopPropagation(),children:[l(`div`,{className:`modal-header`,children:[l(`h3`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[o(d,{size:18}),A(`sidebar.mobileAccess`)]}),o(`button`,{className:`btn-icon`,onClick:x,"aria-label":A(`mobile.close`),children:o(p,{size:18})})]}),l(`div`,{className:`modal-body mobile-modal-body`,children:[l(`div`,{className:`tunnel-status`,children:[o(`span`,{className:`status-dot ${E?.active?`is-active`:j?`is-setup`:C?`is-error`:`is-starting`}`}),o(`span`,{children:E?.active?`Tunnel active`:j?A(`mobile.ngrokRequired`):C?`Couldn't start mobile access`:`Starting tunnel...`}),!E?.active&&!M&&o(`span`,{className:`tunnel-spinner`})]}),j&&l(`div`,{className:`tunnel-setup`,children:[o(`div`,{className:`tunnel-setup-title`,children:A(`mobile.setupTitle`)}),o(`p`,{children:A(`mobile.setupIntro`)}),l(`a`,{href:b,target:`_blank`,rel:`noopener noreferrer`,className:`tunnel-setup-link`,children:[A(`mobile.downloadPage`),` `,o(h,{size:11})]})]}),C&&!j&&o(`div`,{className:`tunnel-error`,children:C}),!M&&o(`div`,{className:`qr-code-area`,children:E?.active?l(r.Fragment,{children:[o(`canvas`,{ref:F,hidden:!!N}),N&&o(`div`,{className:`qr-placeholder error`,children:N})]}):l(`div`,{className:`qr-placeholder`,children:[o(`div`,{className:`placeholder-spinner`}),o(`span`,{children:`Connecting...`})]})}),E?.active&&B&&l(`div`,{className:`tunnel-url-area`,children:[o(`label`,{children:`Mobile URL`}),l(`div`,{className:`tunnel-url-row`,children:[o(`input`,{type:`text`,readOnly:!0,value:B}),l(`button`,{className:`copy-url-btn ${O?`copied`:``}`,onClick:z,title:`Copy URL`,children:[o(O?u:g,{size:13}),O?`Copied`:`Copy`]})]})]}),E?.active&&E?.publicIp&&E?.url&&!E.url.includes(`ngrok-free.app`)&&l(`div`,{className:`tunnel-password-hint`,children:[o(`label`,{children:`Tunnel password`}),o(`div`,{className:`tunnel-password-value`,children:E.publicIp}),o(`span`,{className:`tunnel-password-note`,children:`Enter this when the tunnel page asks for a password`})]}),!M&&o(`div`,{className:`mobile-instructions`,children:l(`ol`,{children:[o(`li`,{children:N?`Open the mobile URL above on your phone`:`Scan the QR code with your phone's camera`}),E?.url&&!E.url.includes(`ngrok-free.app`)&&o(`li`,{children:`Enter the tunnel password shown above when prompted`}),o(`li`,{children:`Chat with GAIA from your mobile device`}),o(`li`,{children:`Your data stays secure via encrypted tunnel`})]})}),E?.active&&!C&&l(`div`,{className:`mobile-install-hint`,children:[o(`div`,{className:`mobile-install-hint-title`,children:A(`mobileAccess.installTitle`)}),o(`p`,{children:A(`mobileAccess.installSteps`)}),o(`p`,{children:A(`mobileAccess.linkLifetime`)})]}),l(`div`,{className:`mobile-access-actions`,children:[E?.active&&S&&o(`button`,{className:`btn-danger`,onClick:S,title:`Close the tunnel and revoke the mobile URL`,children:`Stop tunnel`}),j&&T&&l(`button`,{className:`btn-primary`,onClick:T,children:[o(f,{size:13}),` `,A(`mobile.retry`)]}),o(`button`,{className:`btn-secondary`,onClick:x,children:A(`mobile.close`)})]})]})]})})}export{x as MobileAccessModal};
@@ -1 +0,0 @@
1
- .schedule-modal{flex-direction:column;width:640px;max-height:80vh;display:flex}.schedule-modal .modal-body{flex:1;overflow-y:auto}.schedule-create-form{flex-direction:column;gap:10px;margin-bottom:20px;display:flex}.schedule-field{flex-direction:column;gap:4px;display:flex}.schedule-field-label{font-size:var(--fs-label);color:var(--text-secondary);font-weight:500}.schedule-field-hint,.schedule-prompt-hint{color:var(--text-muted);font-size:11px}.schedule-form-row{gap:8px;display:flex}.schedule-form-row input{border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--bg-input);color:var(--text-primary);font-size:13px;font-family:var(--font-sans);flex:1;padding:8px 12px}.schedule-form-row input:focus{border-color:var(--accent);outline:none}.schedule-form-row input::placeholder{color:var(--text-muted)}.schedule-form-row input[readonly]{background:var(--bg-secondary);color:var(--text-secondary)}.schedule-prompt-input{border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--bg-input);width:100%;color:var(--text-primary);font-size:13px;font-family:var(--font-sans);resize:vertical;min-height:60px;padding:8px 12px}.schedule-prompt-input:focus{border-color:var(--accent);outline:none}.schedule-prompt-input::placeholder{color:var(--text-muted)}.schedule-create-actions{justify-content:flex-end;gap:8px;display:flex}.schedule-form-error{color:var(--accent);margin-top:-4px;font-size:12px}.schedule-action-error{border-inline-start:2px solid var(--danger);background:color-mix(in srgb, var(--danger) 8%, transparent);color:var(--text-primary);overflow-wrap:anywhere;justify-content:space-between;align-items:flex-start;gap:8px;margin-bottom:8px;padding:6px 8px;font-size:12px;display:flex}.schedule-section{margin-bottom:20px}.schedule-section:last-child{margin-bottom:0}.schedule-section h4{font-size:var(--fs-label);color:var(--text-muted);margin-bottom:10px;font-weight:500}.schedule-empty{color:var(--text-muted);text-align:center;padding:24px 12px;font-size:13px}.schedule-list{flex-direction:column;gap:6px;display:flex}.schedule-card{border-radius:var(--radius-sm);background:var(--bg-secondary);border:1px solid var(--border-light);cursor:pointer;transition:background var(--duration-fast) var(--ease);flex-direction:column;padding:10px 12px;display:flex}.schedule-card:hover{background:var(--bg-hover)}.schedule-card.selected{border-color:var(--accent);background:var(--bg-hover)}.schedule-card.just-ran{animation:schedule-flash var(--duration-pulse) var(--ease)}@keyframes schedule-flash{0%{border-color:var(--accent-green)}to{border-color:var(--border-light)}}.schedule-card-header{justify-content:space-between;align-items:center;gap:8px;display:flex}.schedule-card-name{text-overflow:clip;white-space:nowrap;flex:1;font-size:13px;font-weight:500;animation:both fade-cut-inline;animation-timeline:scroll(self inline);overflow:hidden}.schedule-card-status{font-size:var(--fs-caption);text-transform:capitalize;border-radius:var(--radius-sm);padding:2px 8px;font-weight:500}.schedule-card-status.active{color:var(--accent-green);background:color-mix(in srgb, var(--accent-green) 10%, transparent)}.schedule-card-status.paused{color:var(--accent-yellow);background:color-mix(in srgb, var(--accent-yellow) 10%, transparent)}.schedule-card-status.cancelled{color:var(--text-muted);background:var(--bg-tertiary)}.schedule-card-meta{color:var(--text-secondary);align-items:center;gap:12px;margin-top:6px;font-size:12px;display:flex}.schedule-card-error{border-inline-start:2px solid var(--danger);background:color-mix(in srgb, var(--danger) 8%, transparent);color:var(--text-primary);white-space:pre-wrap;overflow-wrap:anywhere;margin-top:6px;padding:6px 8px;font-size:12px}.schedule-card-prompt{color:var(--text-secondary);-webkit-line-clamp:3;overflow-wrap:anywhere;-webkit-box-orient:vertical;margin-top:4px;font-size:12px;animation:both fade-cut-block;animation-timeline:scroll(self);display:-webkit-box;overflow:hidden}.schedule-card-actions{gap:4px;margin-top:8px;display:flex}.schedule-card-actions .btn-sm{border-radius:var(--radius-sm);border:1px solid var(--border);background:var(--bg-tertiary);color:var(--text-primary);cursor:pointer;transition:background var(--duration-fast) var(--ease);align-items:center;gap:4px;padding:3px 10px;font-size:11px;display:inline-flex}.schedule-card-actions .btn-sm:hover{background:var(--bg-active)}.schedule-card-actions .btn-sm.chat{color:var(--accent-blue);border-color:var(--accent-blue)}.schedule-card-actions .btn-sm.chat:hover{background:color-mix(in srgb, var(--accent-blue) 10%, transparent)}.schedule-card-actions .btn-sm.danger{color:var(--accent);border-color:var(--accent)}.schedule-card-actions .btn-sm.danger:hover{background:color-mix(in srgb, var(--danger) 10%, transparent)}.schedule-card-actions{flex-wrap:wrap}.schedule-card-actions .schedule-history-toggle{color:var(--text-secondary);background:0 0;border-color:#0000;margin-inline-start:auto}.schedule-form-title{color:var(--text-primary);margin:0;font-size:14px;font-weight:500}.schedule-presets{flex-wrap:wrap;gap:6px;display:flex}.schedule-preset{border:1px solid var(--border);border-radius:var(--radius-full);background:var(--bg-secondary);color:var(--text-secondary);transition:border-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);padding:3px 10px;font-size:12px}.schedule-preset:hover,.schedule-preset.is-picked{border-color:var(--accent);color:var(--accent)}.schedule-results{border-top:1px solid var(--border);margin-top:16px;padding-top:14px}.schedule-results h4{font-size:var(--fs-label);color:var(--text-muted);margin-bottom:10px;font-weight:500}.schedule-results-list{flex-direction:column;gap:6px;max-height:200px;display:flex;overflow-y:auto}.schedule-result-item{border-radius:var(--radius-sm);background:var(--bg-tertiary);padding:8px 10px;font-size:12px}.schedule-result-time{color:var(--text-muted);font-family:var(--font-sans);font-size:var(--fs-caption);font-variant-numeric:tabular-nums;margin-bottom:4px}.schedule-result-content{color:var(--text-primary);white-space:pre-wrap;word-break:break-word;max-height:60px;overflow-y:auto}.schedule-result-error{color:var(--accent);max-height:none}.schedule-results-empty{color:var(--text-muted);text-align:center;padding:12px;font-size:12px}.schedule-nl-input{border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--bg-input);width:100%;color:var(--text-primary);font-size:13px;font-family:var(--font-sans);resize:vertical;min-height:50px;padding:10px 12px}.schedule-nl-input:focus{border-color:var(--accent);outline:none}.schedule-nl-input::placeholder{color:var(--text-muted)}.schedule-parsed-preview{border-radius:var(--radius-sm);border:1px solid var(--border-light);background:var(--bg-tertiary);padding:10px 12px;font-size:12px}.schedule-parsed-preview.valid{border-color:var(--accent-green);background:color-mix(in srgb, var(--accent-green) 5%, transparent)}.schedule-parsed-preview.invalid{border-color:var(--accent);background:color-mix(in srgb, var(--danger) 5%, transparent)}.schedule-parsed-loading{color:var(--text-muted);font-style:italic}.schedule-parsed-description{color:var(--text-primary);margin-bottom:4px;font-weight:500}.schedule-parsed-hint{color:var(--text-secondary);margin-bottom:4px}.schedule-parsed-next{color:var(--text-secondary);margin-bottom:6px;font-size:11px}.schedule-parsed-details{flex-wrap:wrap;gap:8px;display:flex}.schedule-parsed-tag{border-radius:var(--radius-sm);background:var(--bg-secondary);border:1px solid var(--border);color:var(--text-secondary);align-items:center;gap:4px;padding:2px 8px;font-size:11px;display:inline-flex}.schedule-field-missing{box-shadow:0 0 0 1px color-mix(in srgb, var(--accent-yellow) 30%, transparent);border-color:var(--accent-yellow)!important}
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{H as t,_ as n,b as ee,c as r,ci as i,gi as a,l as o,n as te,o as s,r as c,s as ne,tt as l,u}from"./useFocusTrap-ChaVFhZD.js";import{$ as d,$t as re,Cn as ie,En as f,Lt as p,Q as ae,Qt as m,Rt as h,Ut as g,Xt as _,Zt as v,_n as y,at as b,et as oe,f as se,h as x,it as S,nt as C,rt as w,tn as T,tt as E}from"./index-BLw-Jjdx.js";var D=e(a(),1),O={active:`schedules.status.active`,paused:`schedules.status.paused`,cancelled:`schedules.status.cancelled`};function ce(e,t){return e.length===5&&!e.includes(5)&&!e.includes(6)?t(`schedules.days.weekdays`):e.length===2&&e.includes(5)&&e.includes(6)?t(`schedules.days.weekends`):e.length===7?t(`schedules.days.every`):e.map(e=>t(`schedules.day.${e}`)).join(t(`schedules.days.join`))}var k=[{label:`schedules.preset.morning`,value:`daily at 8am`},{label:`schedules.preset.weekdays`,value:`weekdays at 9am`},{label:`schedules.preset.hourly`,value:`every 1h`}];function A(e){if(e.schedule_config)try{let t=JSON.parse(e.schedule_config).raw_input;if(typeof t==`string`&&t.trim())return t}catch(t){i.ui.warn(`Schedule "${e.name}" has an unreadable schedule_config`,t)}return e.description}function j({schedule:e,onEdit:n}){let a=ne(),{selectedSchedule:te,selectSchedule:l,updateScheduleStatus:d,runScheduleNow:h,deleteSchedule:_,results:b,resultsLoading:x,loadSchedules:C,loadResults:ce}=S(),{setCurrentSession:k,setShowSchedules:A}=ee(),j=te===e.name,M=ae(e.description_parts,a),[N,P]=(0,D.useState)(!1),[F,I]=(0,D.useState)(()=>new Date),L=(0,D.useRef)(null);(0,D.useEffect)(()=>{let t=e.status===`active`&&w(e.next_run_at);return t&&!L.current?L.current=setInterval(()=>{I(new Date),e.next_run_at&&new Date(e.next_run_at).getTime()<=Date.now()&&C()},1e3):!t&&L.current&&(clearInterval(L.current),L.current=null),()=>{L.current&&=(clearInterval(L.current),null)}},[e.status,e.next_run_at,C]);let R=(0,D.useRef)(e.last_run_at);(0,D.useEffect)(()=>{j&&e.last_run_at!==R.current&&(R.current=e.last_run_at,ce(e.name))},[j,e.last_run_at,e.name,ce]);let z=e.last_run_at&&Date.now()-new Date(e.last_run_at).getTime()<5e3,B=(0,D.useCallback)(t=>{t.stopPropagation();let n=e.status===`active`?`paused`:`active`;i.ui.info(`Schedule "${e.name}": ${e.status} -> ${n}`),d(e.name,n)},[e.name,e.status,d]),V=(0,D.useCallback)(t=>{t.stopPropagation(),i.ui.info(`Schedule "${e.name}": run now`),h(e.name)},[e.name,h]),H=(0,D.useCallback)(e=>{e.stopPropagation(),P(!0)},[]),U=(0,D.useCallback)(()=>{P(!1),i.ui.info(`Deleting schedule "${e.name}"`),_(e.name)},[e.name,_]),W=(0,D.useCallback)(t=>{t.stopPropagation(),n(e)},[n,e]),G=(0,D.useCallback)(t=>{t.stopPropagation(),l(j?null:e.name)},[j,e.name,l]),K=(0,D.useCallback)(t=>{t.stopPropagation(),e.session_id&&(i.ui.info(`Opening chat session for schedule "${e.name}"`),k(e.session_id),A(!1))},[e.session_id,e.name,k,A]);return u(`div`,{className:`schedule-card ${j?`selected`:``} ${z?`just-ran`:``}`,onClick:t=>{t.currentTarget.contains(t.target)&&l(j?null:e.name)},children:[u(`div`,{className:`schedule-card-header`,children:[o(`span`,{className:`schedule-card-name`,dir:`auto`,title:e.name,children:e.name}),o(`span`,{className:`schedule-card-status ${e.status}`,children:a(O[e.status])})]}),o(`div`,{className:`schedule-card-prompt`,dir:`auto`,title:e.prompt,children:e.prompt}),u(`div`,{className:`schedule-card-meta`,children:[u(`span`,{title:t(M??e.description),children:[o(y,{size:11}),` `,M??o(`bdi`,{children:e.description})]}),o(`span`,{children:a(`schedules.card.runs`,{n:e.run_count})}),e.error_count>0&&o(`span`,{children:a(`schedules.card.errors`,{n:e.error_count})}),o(`span`,{children:a.compose((t,n)=>t(`schedules.card.last`,{when:E(e.last_run_at,t,void 0,c(s(n)))}))}),o(`span`,{children:a.compose((t,n)=>t(`schedules.card.next`,{when:e.status===`paused`?t(`schedules.status.paused`):oe(e.next_run_at,F,t,c(s(n)))}))})]}),e.last_error&&!(j&&!x&&b.some(e=>e.error))&&o(`div`,{className:`schedule-card-error`,children:a(`schedules.card.lastFailed`,{error:e.last_error})}),u(`div`,{className:`schedule-card-actions`,children:[e.session_id&&u(`button`,{className:`btn-sm chat`,onClick:K,title:a(`schedules.card.openChatTitle`),children:[o(T,{size:11}),` `,a(`schedules.card.openChat`)]}),u(`button`,{className:`btn-sm`,onClick:V,disabled:e.running,title:a(`schedules.card.runNowTitle`),children:[o(p,{size:11}),` `,a(e.running?`schedules.card.running`:`schedules.card.runNow`)]}),o(`button`,{className:`btn-sm`,onClick:B,title:a(e.status===`active`?`schedules.card.pause`:`schedules.card.resume`),children:e.status===`active`?u(r.Fragment,{children:[o(re,{size:11}),` `,a(`schedules.card.pause`)]}):u(r.Fragment,{children:[o(v,{size:11}),` `,a(`schedules.card.resume`)]})}),u(`button`,{className:`btn-sm`,onClick:W,disabled:e.running,title:a(`schedules.card.editTitle`),children:[o(m,{size:11}),` `,a(`schedules.card.edit`)]}),u(`button`,{className:`btn-sm danger`,onClick:H,title:a(`schedules.card.delete`),children:[o(g,{size:11}),` `,a(`schedules.card.delete`)]}),u(`button`,{className:`btn-sm schedule-history-toggle`,onClick:G,"aria-expanded":j,children:[o(j?ie:f,{size:11}),` `,a(`schedules.card.pastRuns`)]})]}),N&&u(se,{title:a(`schedules.delete.ask`,{name:e.name}),confirmLabel:a(`schedules.delete.confirm`),cancelLabel:a(`schedules.delete.cancel`),onConfirm:U,onCancel:()=>P(!1),danger:!0,children:[o(`p`,{children:a(`schedules.delete.what`)}),e.session_id&&o(`p`,{children:a(`schedules.delete.chatStays`)}),e.running&&o(`p`,{children:a(`schedules.delete.runStops`)})]}),j&&u(`div`,{className:`schedule-results`,children:[o(`h4`,{children:a(`schedules.history`)}),x?o(`p`,{className:`schedule-results-empty`,children:a(`schedules.historyLoading`)}):b.length===0?o(`p`,{className:`schedule-results-empty`,children:a(`schedules.historyEmpty`)}):o(`div`,{className:`schedule-results-list`,children:b.map(e=>u(`div`,{className:`schedule-result-item`,children:[o(`div`,{className:`schedule-result-time`,children:a.compose((t,n)=>E(e.executed_at,t,void 0,c(s(n))))}),e.error?o(`div`,{className:`schedule-result-content schedule-result-error`,children:o(`bdi`,{children:e.error})}):o(`div`,{className:`schedule-result-content`,children:e.result?o(`bdi`,{children:e.result}):a(`schedules.noOutput`)})]},e.id))})]})]})}function M(){let e=ne(),{setShowSchedules:t}=ee(),{schedules:a,loading:re,error:ie,actionError:f,loadSchedules:p,createSchedule:m,editSchedule:g,dismissActionError:v}=S(),se=(0,D.useCallback)(()=>t(!1),[t]);n(!0,se);let w=(0,D.useRef)(null);te(w,!0),x(w,!0);let[T]=(0,D.useState)(()=>S.getState().draft),[E,O]=(0,D.useState)(T!==null),[M,N]=(0,D.useState)(T?.when??``),[P,F]=(0,D.useState)(T?.name??``),[I,L]=(0,D.useState)(T?.prompt??``),[R,z]=(0,D.useState)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(!1),[W,G]=(0,D.useState)(null),[K,le]=(0,D.useState)(null),ue=(0,D.useRef)(null),[q,J]=(0,D.useState)(!1),Y=(0,D.useId)(),de=`${Y}-when`,fe=`${Y}-when-error`,X=`${Y}-when-hint`,pe=`${Y}-name`,me=`${Y}-name-error`,he=`${Y}-prompt`,Z=!B&&R!==null&&!R.valid,ge=Z&&/[A-Za-z]/.test(M);(0,D.useEffect)(()=>{if(K)return;let e=M.trim()||P.trim()||I.trim();S.getState().setDraft(e?{when:M,name:P,prompt:I}:null)},[K,M,P,I]);let Q=(0,D.useRef)(null);(0,D.useEffect)(()=>{if(!M.trim())z(null);else return Q.current&&clearTimeout(Q.current),Q.current=window.setTimeout(async()=>{V(!0);try{let e=await b(M);z(e)}catch{z(null)}finally{V(!1)}},400),()=>{Q.current&&clearTimeout(Q.current)}},[M]);let $=(0,D.useRef)(null);(0,D.useEffect)(()=>(i.ui.info(`Schedule Manager opened`),p(),$.current=window.setInterval(()=>p(),5e3),()=>{$.current&&clearInterval($.current),v()}),[p,v]);let _e=M.trim()&&P.trim()&&I.trim()&&(R===null||R.valid),ve=(0,D.useCallback)(()=>{O(!1),le(null),G(null),J(!1),z(null),N(``),F(``),L(``)},[]),ye=(0,D.useCallback)(e=>{le(e.name),F(e.name),L(e.prompt),N(A(e)),G(null),O(!0),i.ui.info(`Editing schedule "${e.name}"`)},[]);(0,D.useEffect)(()=>{K&&ue.current?.scrollIntoView?.({block:`nearest`})},[K]);let be=(0,D.useCallback)(async()=>{if(_e){U(!0),G(null),J(!1);try{K?(await g(K,M.trim(),I.trim()),i.ui.info(`Schedule "${K}" edited`)):(await m(P.trim(),M.trim(),I.trim()),S.getState().setDraft(null),i.ui.info(`Schedule "${P}" created`)),ve()}catch(t){!K&&t instanceof l&&t.httpStatus===409?J(!0):G(t instanceof Error?t.message:e(K?`schedules.editFailed`:`schedules.createFailed`))}finally{U(!1)}}},[_e,K,P,M,I,m,g,ve,e]);return o(`div`,{ref:w,className:`modal-overlay`,onClick:()=>t(!1),role:`dialog`,"aria-modal":`true`,"aria-label":e(`schedules.title`),children:u(`div`,{className:`modal-panel schedule-modal`,onClick:e=>e.stopPropagation(),children:[u(`div`,{className:`modal-header`,children:[o(`h3`,{children:e(`schedules.title`)}),o(`button`,{className:`btn-icon`,onClick:()=>t(!1),"aria-label":e(`schedules.close`),children:o(h,{size:18})})]}),u(`div`,{className:`modal-body`,children:[o(`section`,{className:`schedule-section`,children:E?u(`div`,{className:`schedule-create-form`,ref:ue,children:[K&&o(`h4`,{className:`schedule-form-title`,children:e(`schedules.editingTitle`,{name:K})}),u(`div`,{className:`schedule-field`,children:[o(`label`,{className:`schedule-field-label`,htmlFor:de,children:e(`schedules.when`)}),o(`div`,{className:`schedule-presets`,children:k.map(t=>o(`button`,{type:`button`,className:`schedule-preset${M.trim()===t.value?` is-picked`:``}`,onClick:()=>N(t.value),"aria-pressed":M.trim()===t.value,children:e(t.label)},t.value))}),o(`textarea`,{id:de,className:`schedule-nl-input`,placeholder:e.bare(`schedules.whenPlaceholder`),value:M,onChange:e=>N(e.target.value),"aria-invalid":Z,"aria-describedby":Z?`${fe} ${X}`:X,autoFocus:!0,rows:2}),o(`div`,{id:X,className:`schedule-field-hint`,children:e(`schedules.whenHint`)})]}),(R||B)&&o(`div`,{className:`schedule-parsed-preview ${R?.valid?`valid`:`invalid`}`,"aria-live":`polite`,children:B?o(`span`,{className:`schedule-parsed-loading`,children:e(`schedules.parsing`)}):R?u(r.Fragment,{children:[R.valid?o(`div`,{className:`schedule-parsed-description`,children:ae(R.description_parts,e)??o(`bdi`,{children:R.description})}):u(`div`,{id:fe,children:[o(`div`,{className:`schedule-parsed-description`,children:e(`schedules.notUnderstood`)}),ge&&o(`div`,{className:`schedule-parsed-hint`,children:o(`bdi`,{children:R.description})})]}),R.valid&&R.next_run_at&&o(`div`,{className:`schedule-parsed-next`,children:e.compose((e,t)=>e(`schedules.nextRun`,{when:oe(R.next_run_at,void 0,e,c(s(t)))}))}),R.valid&&u(`div`,{className:`schedule-parsed-details`,children:[R.time_of_day&&u(`span`,{className:`schedule-parsed-tag`,children:[o(y,{size:10}),` `,C(R.time_of_day,e)]}),R.start_hour!=null&&R.end_hour!=null&&u(`span`,{className:`schedule-parsed-tag`,children:[o(y,{size:10}),` `,e.compose((e,t)=>e(`schedules.hours`,{start:d(s(t),R.start_hour),end:d(s(t),R.end_hour)}))]}),R.days_of_week&&o(`span`,{className:`schedule-parsed-tag`,children:e.compose(e=>ce(R.days_of_week,e))})]})]}):null}),u(`div`,{className:`schedule-field`,children:[o(`label`,{className:`schedule-field-label`,htmlFor:pe,children:e(`schedules.name`)}),o(`div`,{className:`schedule-form-row`,children:o(`input`,{id:pe,type:`text`,placeholder:e(`schedules.namePlaceholder`),value:P,onChange:e=>{F(e.target.value),J(!1)},readOnly:K!==null,className:!P.trim()&&M.trim()?`schedule-field-missing`:``,"aria-invalid":q,"aria-describedby":q?me:void 0})}),q&&o(`p`,{id:me,className:`schedule-form-error`,role:`alert`,children:e(`schedules.nameTaken`)})]}),u(`div`,{className:`schedule-field`,children:[o(`label`,{className:`schedule-field-label`,htmlFor:he,children:e(`schedules.prompt`)}),o(`textarea`,{id:he,className:`schedule-prompt-input ${!I.trim()&&M.trim()?`schedule-field-missing`:``}`,placeholder:e(`schedules.promptPlaceholder`),value:I,onChange:e=>L(e.target.value)}),o(`div`,{className:`schedule-prompt-hint`,children:e(`schedules.promptHint`)})]}),W&&o(`p`,{className:`schedule-form-error`,children:o(`bdi`,{children:W})}),u(`div`,{className:`schedule-create-actions`,children:[o(`button`,{className:`btn-secondary`,onClick:ve,children:e(`schedules.cancel`)}),o(`button`,{className:`btn-primary`,onClick:be,disabled:!_e||H,children:e(K?H?`schedules.saving`:`schedules.save`:H?`schedules.creating`:`schedules.create`)})]})]}):u(`button`,{className:`btn-primary`,onClick:()=>O(!0),children:[o(_,{size:14}),` `,e(`schedules.new`)]})}),u(`section`,{className:`schedule-section`,children:[o(`h4`,{children:e(`schedules.list`)}),f&&u(`div`,{className:`schedule-action-error`,role:`alert`,children:[o(`span`,{children:o(`bdi`,{children:f})}),o(`button`,{className:`btn-icon`,onClick:v,"aria-label":e(`schedules.dismissError`),children:o(h,{size:14})})]}),re?o(`p`,{className:`schedule-empty`,children:e(`schedules.loading`)}):ie?o(`p`,{className:`schedule-empty`,children:e(`schedules.loadFailed`)}):a.length===0?o(`p`,{className:`schedule-empty`,children:e(`schedules.empty`)}):o(`div`,{className:`schedule-list`,children:a.map(e=>o(j,{schedule:e,onEdit:ye},e.id))})]})]})]})})}export{M as ScheduleManager};