@zzusp/ccsm 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +236 -236
  3. package/bin/cli.mjs +52 -52
  4. package/dist/assets/{DiskUsage-CKhggLs5.js → DiskUsage-BY6XwffG.js} +2 -2
  5. package/dist/assets/DiskUsage-BY6XwffG.js.map +1 -0
  6. package/dist/assets/{ImportPage-wge4VhZ-.js → ImportPage-Cwq5bx7G.js} +2 -2
  7. package/dist/assets/ImportPage-Cwq5bx7G.js.map +1 -0
  8. package/dist/assets/MarkdownContent-BFu7Nkk_.js +2 -0
  9. package/dist/assets/MarkdownContent-BFu7Nkk_.js.map +1 -0
  10. package/dist/assets/{ProjectMemory-Q4XX40j_.js → ProjectMemory-CcE3KbUK.js} +2 -2
  11. package/dist/assets/ProjectMemory-CcE3KbUK.js.map +1 -0
  12. package/dist/assets/index-CrWxV6sb.css +1 -0
  13. package/dist/assets/index-DTbWl1jb.js +11 -0
  14. package/dist/assets/index-DTbWl1jb.js.map +1 -0
  15. package/dist/assets/markdown-Bag5rX3T.js +30 -0
  16. package/dist/assets/markdown-Bag5rX3T.js.map +1 -0
  17. package/dist/index.html +26 -26
  18. package/package.json +81 -83
  19. package/server/index.ts +130 -130
  20. package/server/lib/active-sessions.test.ts +119 -119
  21. package/server/lib/active-sessions.ts +95 -95
  22. package/server/lib/bundle.test.ts +182 -182
  23. package/server/lib/bundle.ts +86 -86
  24. package/server/lib/claude-paths.test.ts +126 -126
  25. package/server/lib/claude-paths.ts +43 -43
  26. package/server/lib/cleanup-suggestions.ts +131 -131
  27. package/server/lib/constants.ts +8 -8
  28. package/server/lib/delete-project.ts +100 -100
  29. package/server/lib/delete.test.ts +244 -244
  30. package/server/lib/delete.ts +192 -192
  31. package/server/lib/disk-usage.ts +81 -81
  32. package/server/lib/encode-cwd.ts +24 -24
  33. package/server/lib/export-bundle.ts +236 -236
  34. package/server/lib/export-import-bundle.test.ts +337 -337
  35. package/server/lib/fs-size.ts +38 -38
  36. package/server/lib/import-bundle.ts +488 -488
  37. package/server/lib/load-memory.ts +120 -120
  38. package/server/lib/load-session.ts +209 -209
  39. package/server/lib/modified-files.test.ts +280 -280
  40. package/server/lib/modified-files.ts +228 -228
  41. package/server/lib/open-folder.ts +47 -47
  42. package/server/lib/parse-jsonl.ts +160 -139
  43. package/server/lib/port.ts +23 -23
  44. package/server/lib/safe-id.test.ts +41 -41
  45. package/server/lib/safe-id.ts +6 -6
  46. package/server/lib/safe-remove.test.ts +73 -73
  47. package/server/lib/safe-remove.ts +25 -25
  48. package/server/lib/scan.ts +289 -286
  49. package/server/lib/search-all.ts +130 -130
  50. package/server/lib/search-session.ts +203 -203
  51. package/server/lib/system-tags.ts +20 -20
  52. package/server/lib/update.ts +67 -67
  53. package/server/lib/version.test.ts +39 -39
  54. package/server/lib/version.ts +117 -117
  55. package/server/routes/disk-cleanup.ts +54 -54
  56. package/server/routes/disk.ts +9 -9
  57. package/server/routes/import.ts +87 -87
  58. package/server/routes/projects.ts +104 -104
  59. package/server/routes/search.ts +79 -79
  60. package/server/routes/sessions.ts +130 -130
  61. package/server/routes/version.ts +34 -34
  62. package/server/types.ts +1 -1
  63. package/shared/constants.ts +7 -7
  64. package/shared/types.ts +513 -511
  65. package/dist/assets/DiskUsage-CKhggLs5.js.map +0 -1
  66. package/dist/assets/ImportPage-wge4VhZ-.js.map +0 -1
  67. package/dist/assets/ProjectMemory-Q4XX40j_.js.map +0 -1
  68. package/dist/assets/index-7aMrnHJG.js +0 -7
  69. package/dist/assets/index-7aMrnHJG.js.map +0 -1
  70. package/dist/assets/index-BOeI_J4B.css +0 -1
@@ -0,0 +1,11 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownContent-BFu7Nkk_.js","assets/react-CPkiFScu.js","assets/markdown-Bag5rX3T.js","assets/query-CS7JQ86v.js","assets/router-DwaHAh1G.js","assets/vendor-Cs8vYp-N.js","assets/DiskUsage-BY6XwffG.js","assets/charts-jxJqXXUr.js","assets/ProjectMemory-CcE3KbUK.js","assets/ImportPage-Cwq5bx7G.js"])))=>i.map(i=>d[i]);
2
+ import{j as e,r as d,a as pr,b as xr,R as hr}from"./react-CPkiFScu.js";import{u as Y,a as le,b as Le,Q as fr,c as gr}from"./query-CS7JQ86v.js";import{u as At,a as vr,L as ve,b as _t,c as jr,R as yr,d as me,B as br}from"./router-DwaHAh1G.js";import{G as Bt,H as $}from"./vendor-Cs8vYp-N.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const a of n)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function s(n){const a={};return n.integrity&&(a.integrity=n.integrity),n.referrerPolicy&&(a.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?a.credentials="include":n.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(n){if(n.ep)return;n.ep=!0;const a=s(n);fetch(n.href,a)}})();const kr="modulepreload",wr=function(t){return"/"+t},Ze={},Ee=function(r,s,o){let n=Promise.resolve();if(s&&s.length>0){let i=function(u){return Promise.all(u.map(m=>Promise.resolve(m).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));n=i(s.map(u=>{if(u=wr(u),u in Ze)return;Ze[u]=!0;const m=u.endsWith(".css"),h=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${h}`))return;const v=document.createElement("link");if(v.rel=m?"stylesheet":kr,m||(v.as="script"),v.crossOrigin="",v.href=u,c&&v.setAttribute("nonce",c),document.head.appendChild(v),m)return new Promise((g,x)=>{v.addEventListener("load",g),v.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${u}`)))})}))}function a(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return n.then(i=>{for(const l of i||[])l.status==="rejected"&&a(l.reason);return r().catch(a)})};function je({label:t,className:r}){return e.jsxs("div",{role:"status","aria-live":"polite",className:["flex flex-col gap-2.5",r].filter(Boolean).join(" "),children:[e.jsx("span",{className:"eyebrow tabular-nums",children:t}),e.jsx("span",{"aria-hidden":!0,className:"loading-rule"})]})}function Nr({className:t}){return e.jsxs("span",{"aria-hidden":!0,className:["loading-dots",t].filter(Boolean).join(" "),children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})}const _e=1024,Be=_e*1024,et=Be*1024;function F(t){return!Number.isFinite(t)||t<=0?"0 B":t>=et?`${(t/et).toFixed(2)} GB`:t>=Be?`${(t/Be).toFixed(1)} MB`:t>=_e?`${(t/_e).toFixed(1)} KB`:`${t} B`}function pe(t){if(!t)return"—";const r=new Date(t).getTime();if(Number.isNaN(r))return t;const s=Date.now()-r,o=Math.round(s/1e3);if(o<60)return`${o}s ago`;const n=Math.round(o/60);if(n<60)return`${n}m ago`;const a=Math.round(n/60);if(a<48)return`${a}h ago`;const i=Math.round(a/24);if(i<30)return`${i}d ago`;const l=Math.round(i/30);return l<12?`${l}mo ago`:`${Math.round(l/12)}y ago`}function Ue(t){if(!t)return"—";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}const Ft=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform);function Sr(t,r){d.useEffect(()=>{function s(o){(Ft?o.metaKey:o.ctrlKey)&&(o.key!=="k"&&o.key!=="K"||(o.preventDefault(),r()))}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t,r])}const $t=Ft?"⌘K":"Ctrl+K",Ot="locale",tt={en:{"app.brand.title":"Claude Sessions","app.brand.subtitle":"local archive","app.brand.footnote":"local · read-only by default","nav.workspace":"Workspace","nav.projects":"Projects","nav.disk":"Disk usage","nav.import":"Import","nav.theme":"Theme","nav.language":"Language","nav.toggleNav":"Toggle navigation","nav.closeNav":"Close navigation","version.label":"Version","version.badge.new":"Update {{v}}","version.upToDate":"Up to date","version.checkFailed":"Update check failed","version.modal.eyebrowUpdate":"Update available","version.modal.eyebrowLatest":"Version","version.modal.titleUpdate":"A new version is available","version.modal.titleLatest":"You're on the latest version","version.current":"Current","version.latest":"Latest","version.published":"Released {{date}}","version.notes":"What's new","version.notesEmpty":"No release notes were provided for this release.","version.btn.update":"Update now","version.btn.updating":"Updating…","version.btn.releasePage":"Release page","version.btn.repo":"Repository","version.btn.close":"Close","version.update.eyebrow":"Result","version.update.successTitle":"Update complete","version.update.success":"Updated to {{v}}. Restart ccsm to load the new version.","version.update.failTitle":"Update failed","version.update.fail":"npm could not complete the update — see the output below, or run the command manually.","version.update.command":"Or run manually","version.update.output":"Command output","common.loading":"loading","common.scanning":"scanning ~/.claude/projects/…","common.computing":"computing…","common.readingSessions":"reading sessions…","common.loadingSession":"loading session…","common.noData":"no data","common.entries":"entries","common.entry":"entry","common.selectAll":"select all","common.deselectAll":"deselect all","common.cancel":"Cancel","common.done":"Done","common.expand":"expand","common.collapse":"collapse","common.system":"system","common.onlyUser":"only me","common.onlyError":"errors","common.missing":"missing","common.noSessions":"No sessions in this project.","common.noProjects":"No projects found.","common.noMessagesMatch":"No messages match.","common.failedProjects":"Failed to load projects","common.failedSessions":"Failed to load sessions","common.failedSession":"Failed to load","common.failedMemory":"Failed to load memory","common.failed":"Failed","common.searchPlaceholder":"Search this session…","common.loadEarlier":"Load earlier (+{{n}})","common.scrollToTop":"Jump to top","common.scrollToBottom":"Jump to bottom","projects.title":"Projects","projects.tagline":"Every directory you've touched with Claude Code, sorted by recency. Open one to inspect or prune its sessions.","projects.indexHeading":"Index","projects.stat.projects":"Projects","projects.stat.sessions":"Sessions","projects.stat.onDisk":"On disk","projects.card.eyebrow":"project","projects.card.sessions":"Sessions","projects.card.onDisk":"On disk","projects.card.lastSeen":"Last seen","projects.warn.rootMissing":"Claude root {{root}} doesn't exist on this machine — nothing to display.","project.eyebrow":"Project","project.warn.missingDir":"Directory missing on disk","project.action.openFolder":"Open folder","project.action.openFolderTooltipMissing":"Directory no longer exists on disk","project.action.openFolderFailed":"Failed to open folder: {{msg}}","project.action.delete":"Delete · {{n}}","project.action.select":"Select","project.action.exitSelect":"Exit","project.bulk.selectedCount":"{{n}} selected","project.bulk.deleteCta":"Delete selected","project.bulk.deletePending":"Deleting {{i}}/{{total}}…","project.bulk.resultOk":"Deleted {{ok}}","project.bulk.resultSkipped":"skipped {{n}}","project.bulk.resultFailed":"failed {{n}}","project.bulk.viewDetail":"Details","project.bulk.hideDetail":"Hide","project.bulk.detailSkipped":"Skipped","project.bulk.detailFailed":"Failed","project.bulk.dismiss":"Dismiss","project.meta.sessions":"Sessions","project.meta.onDisk":"On disk","project.meta.working":"Working","project.meta.live":"Live","project.meta.recent":"Recent","project.heading":"Sessions","project.col.title":"Title","project.col.msgs":"Msgs","project.col.last":"Last","project.col.size":"Size","project.col.status":"Status","project.col.errors":"Errors","session.crumbProjects":"Projects","session.action.delete":"Delete","session.action.deleteTooltipBlocked":"Session metadata not available yet","session.action.rename":"Rename","session.action.renameTooltipLive":"Live PID {{pid}} owns this session — close the running claude first","session.tagline":"Started {{started}} · last touched {{lastTouched}}{{branchPart}}","session.tagline.branch":" · branch {{branch}}","session.meta.messages":"Messages","session.meta.size":"Size","session.meta.version":"Version","session.meta.started":"Started","session.truncated":"Session truncated to first {{n}} messages.","session.shown":"{{shown}} / {{total}}","session.live":"Live","session.live.tooltip":"Auto-updating — new messages stream in as they're written","session.working":"Working","session.working.tooltip":"Claude is processing this turn — generating a reply or running a tool","session.working.indicator":"Claude is working…","session.modified.title":"Modified files","session.modified.empty":"No files were modified in this session.","session.modified.loading":"scanning for file edits…","session.modified.failed":"Failed to load modified files","session.modified.count":"{{n}} file","session.modified.countPlural":"{{n}} files","session.modified.openAria":"Open modified files","session.modified.close":"Close","session.modified.openFile":"open file","session.modified.openFailed":"Failed to open file: {{msg}}","session.modified.col.file":"Files","session.modified.col.conversation":"Conversation","session.modified.collapseAll":"collapse all","session.modified.expandAll":"expand all","session.modified.selectFile":"Select a file to view its changes in this session.","session.modified.errorBadge":"{{n}} errored","session.modified.absolutePath":"absolute path","session.modified.jump":"Jump to","session.modified.opErrored":"errored","session.modified.opPending":"pending","session.modified.newContent":"new content","session.modified.linesOmitted":"{{n}} unchanged lines","session.modified.editN":"edit {{n}}","session.modified.contentUnavailable":"Edit content unavailable (session truncated past this point).","session.modified.noContent":"No content recorded for this operation.","session.modified.showEarlier":"show {{n}} earlier messages","session.modified.added":"added","session.modified.modified":"modified","message.role.you":"You","message.role.claude":"Claude","message.role.tool":"Tool","message.role.system":"system","tool.use":"tool","tool.result":"tool result","tool.error":"tool error","tool.thinking":"thinking","tool.thinkingEncrypted":"Content is encrypted, no readable text.","tool.image":"image","tool.copy":"copy","tool.copied":"copied","tool.moreLines":"… {{n}} more lines","tool.replaceAll":"replace all","status.working":"working","status.live":"live · pid {{pid}}","status.recent":"recent","status.idle":"idle","status.tooltip.working":"Claude is actively processing this session right now","status.tooltip.live":"PID {{pid}} is alive and registered for this session","status.tooltip.recent":"jsonl modified within the last {{n}} minutes","status.tooltip.idle":"idle — safe to delete","disk.tagline":"How `~/.claude/` is using your disk: which projects carry the most weight, and which sessions are heaviest.","disk.title":"Disk usage","disk.meta.total":"Total","disk.meta.projects":"Projects","disk.meta.sessions":"Sessions","disk.stat.total":"Total on disk","disk.stat.acrossProjects":"across {{n}} projects","disk.stat.sessions":"Sessions","disk.stat.largest":"largest {{size}}","disk.stat.months":"Months tracked","disk.composition.title":"Composition","disk.composition.subtitle":"bytes per project","disk.composition.total":"Total","disk.cadence.title":"Cadence","disk.cadence.subtitle":"MB per month","disk.heaviest.title":"Heaviest sessions","disk.heaviest.top":"top {{n}}","disk.col.num":"#","disk.col.title":"Title","disk.col.project":"Project","disk.col.last":"Last","disk.col.size":"Size","cleanup.title":"Cleanup suggestions","cleanup.tagline":"Things worth pruning. Review each row, then act — nothing here runs automatically.","cleanup.section.largeSessions":"Largest sessions","cleanup.section.largeSessions.hint":"Top {{n}} by total bytes on disk","cleanup.section.orphanFileHistory":"Orphan file-history","cleanup.section.orphanFileHistory.hint":"file-history/<sid>/ folders with no surviving session","cleanup.section.orphanSessionEnv":"Orphan session-env","cleanup.section.orphanSessionEnv.hint":"session-env/<sid>/ folders with no surviving session","cleanup.empty.largeSessions":"No sessions on disk yet.","cleanup.empty.orphan":"No orphans — nothing to prune.","cleanup.col.session":"Session","cleanup.col.project":"Project","cleanup.col.last":"Last","cleanup.col.size":"Size","cleanup.col.sid":"Session id","cleanup.col.actions":"Actions","cleanup.action.view":"View","cleanup.action.delete":"Delete","cleanup.action.deleting":"Deleting…","cleanup.confirm.title":"Delete orphan?","cleanup.confirm.body":"This removes {{kind}}/{{sid}}/ ({{size}}) permanently. The session jsonl is already gone, so nothing else is affected.","cleanup.confirm.confirm":"Delete","cleanup.confirm.cancel":"Cancel","cleanup.failed":"Failed: {{msg}}","memory.title":"Memory","memory.empty":"No memory recorded yet for this project.","memory.action.open":"Memory","memory.action.openCount":"Memory · {{n}}","memory.meta.entries":"Entries","memory.meta.types":"Types","memory.meta.lastUpdate":"Last update","memory.type.user":"User","memory.type.feedback":"Feedback","memory.type.project":"Project","memory.type.reference":"Reference","memory.type.other":"Untyped","memory.loading":"reading memory…","memory.search.placeholder":"Search title, hook, or body…","memory.search.hint":"Press {{hotkey}} to focus","memory.filter.all":"All","memory.sort.label":"Sort","memory.sort.index":"MEMORY.md order","memory.sort.recent":"Recent first","memory.sort.name":"Name A→Z","memory.sort.size":"Largest first","memory.list.noResults":"No entries match.","memory.list.count":"{{n}} of {{total}}","memory.cover.title":"Memory index","memory.cover.subtitle":"MEMORY.md","memory.cover.viewRaw":"view raw","memory.cover.showAll":"Show all ({{n}})","memory.cover.collapse":"Collapse","memory.cover.missingTooltip":"No matching entry file","memory.cover.orphan":"Not in index","memory.empty.title":"No memory yet","memory.empty.body":"Claude saves long-term notes here when you ask it to remember something or when it observes a stable preference. Memory files live under ~/.claude/projects/<id>/memory/.","memory.empty.orphanIndex":"The index references {{n}} entries, but none of them have memory files yet.","memory.section.untyped":"Untyped","memory.drawer.close":"Close","memory.drawer.indexHook":"Index hook","memory.drawer.notFound.title":"Entry not found","memory.drawer.notFound.body":"The selected memory file may have been removed. It might still appear in the curated index above.","memory.raw.title":"MEMORY.md","memory.raw.subtitle":"Curated index — raw source","delete.eyebrow.confirm":"Confirm deletion","delete.eyebrow.result":"Result","delete.title.confirm":"Delete sessions","delete.title.result":"Sessions removed","delete.summary":"{{n}} will be removed · {{skipped}} skipped · ~{{free}} to free","delete.skipped.heading":"These {{n}} will be skipped:","delete.skipped.reasonLive":"live PID {{pid}}","delete.skipped.reasonRecent":"modified within last {{n}} minutes","delete.skipped.reasonUnknown":"unknown","delete.success":"Deleted {{n}} session(s). {{free}} freed · {{lines}} history lines removed","delete.btn.confirm":"Delete {{n}} {{label}}","delete.btn.confirmPending":"Deleting…","delete.label.session":"session","delete.label.sessions":"sessions","delete.close":"Close","deleteProject.row.action":"Delete project","deleteProject.eyebrow.confirm":"Confirm deletion","deleteProject.eyebrow.result":"Result","deleteProject.title.confirm":"Delete project","deleteProject.title.result":"Project removed","deleteProject.summary":"{{n}} session(s) · ~{{free}} to free · directory will be removed","deleteProject.warning":"This removes every session in {{cwd}} along with its history.jsonl entries. Cannot be undone.","deleteProject.blocked.heading":"{{n}} session(s) are live or were modified in the last 5 minutes — nothing will be deleted. Try again later.","deleteProject.success":"Removed {{n}} session(s) and the project directory. {{free}} freed · {{lines}} history lines removed","deleteProject.successKept":"Removed {{n}} session(s). {{free}} freed · {{lines}} history lines removed · directory kept","deleteProject.btn.confirm":"Delete project","deleteProject.btn.confirmPending":"Deleting…","search.action.open":"Search sessions","search.placeholder":"Search across all sessions…","search.empty":"Type at least 2 characters to search across every session on disk.","search.refineQuery":"Type a longer query to refine the search.","search.scanning":"scanning…","search.noResults":"No matches.","search.error":"Search failed: {{msg}}","search.moreInSession":"+more in this session","search.moreSessions":"Showing first {{n}} sessions — refine your query for more.","search.summary":"{{matched}} session(s) · scanned {{scanned}} · {{ms}}ms","search.shortcut":"{{hint}} to open","search.escapeHint":"esc to close","search.kindText":"text","search.kindToolUse":"tool","search.kindToolResult":"tool result","search.kindThinking":"thinking","search.role.user":"You","search.role.assistant":"Claude","export.action":"Export","export.eyebrow.confirm":"Share across devices","export.eyebrow.result":"Result","export.title.confirm":"Export project","export.title.result":"Export complete","export.summary":"Bundle {{n}} session(s) + memory into a portable folder.","export.destLabel":"Destination folder","export.destPlaceholder":"e.g. D:\\sync\\claude-shared","export.destHint":"An absolute path outside ~/.claude. Drop it into a git repo or cloud drive to sync.","export.privacy":"This writes your conversations and memory outside the app. If you push the folder to a remote, those contents leave your machine.","export.btn.confirm":"Export","export.btn.pending":"Exporting…","export.success":"Exported {{sessions}} session(s) · {{memory}} memory file(s) · {{lines}} history line(s)","export.successDest":"Written to {{dest}}","export.close":"Close","import.title":"Import bundle","import.tagline":"Bring a project's sessions and memory from another device. Paths are remapped to this machine.","import.bundleLabel":"Bundle folder","import.bundlePlaceholder":"Path to an exported bundle","import.btn.load":"Load bundle","import.btn.recheck":"Re-check","import.btn.loading":"Loading…","import.source":"From {{platform}} · {{cwd}}","import.targetLabel":"Import into (this device)","import.targetHint":"Absolute path on this machine. Sessions are associated with this folder.","import.targetId":"Project id: {{id}}","import.suggestions":"Suggestions","import.suggestion.existing-project":"existing project","import.suggestion.original-path":"original path","import.suggestion.same-basename":"same folder name","import.policyLabel":"If a session already exists","import.policy.skip":"Skip","import.policy.overwrite-if-newer":"Overwrite if newer","import.policy.keep-both":"Keep both","import.sessions.heading":"Sessions","import.sessions.empty":"No sessions in this bundle.","import.action.create":"create","import.action.overwrite":"overwrite","import.action.keep-both":"keep both","import.action.skip":"skip","import.memory.heading":"Memory","import.memory.create":"create","import.memory.skip":"identical","import.memory.conflict":"conflict → {{name}}","import.history":"{{n}} history line(s) to add","import.btn.commit":"Import","import.btn.committing":"Importing…","import.result.title":"Import complete","import.result.summary":"Imported {{n}} session(s) · {{skipped}} skipped · {{memory}} memory file(s) · {{lines}} history line(s)","import.result.viewProject":"Open imported project","import.empty":"Enter a bundle folder path to begin."},zh:{"app.brand.title":"Claude 会话","app.brand.subtitle":"本地归档","app.brand.footnote":"本地 · 默认只读","nav.workspace":"工作区","nav.projects":"项目","nav.disk":"磁盘占用","nav.import":"导入","nav.theme":"主题","nav.language":"语言","nav.toggleNav":"切换导航","nav.closeNav":"关闭导航","version.label":"版本","version.badge.new":"新版本 {{v}}","version.upToDate":"已是最新","version.checkFailed":"检查更新失败","version.modal.eyebrowUpdate":"有可用更新","version.modal.eyebrowLatest":"版本","version.modal.titleUpdate":"发现新版本","version.modal.titleLatest":"已是最新版本","version.current":"当前版本","version.latest":"最新版本","version.published":"发布于 {{date}}","version.notes":"更新内容","version.notesEmpty":"本次发布没有提供更新说明。","version.btn.update":"立即更新","version.btn.updating":"更新中…","version.btn.releasePage":"发布页","version.btn.repo":"代码仓库","version.btn.close":"关闭","version.update.eyebrow":"结果","version.update.successTitle":"更新完成","version.update.success":"已更新到 {{v}}。请重启 ccsm 以加载新版本。","version.update.failTitle":"更新失败","version.update.fail":"npm 未能完成更新 — 请查看下方输出,或手动执行更新命令。","version.update.command":"或手动执行","version.update.output":"命令输出","common.loading":"加载中","common.scanning":"正在扫描 ~/.claude/projects/…","common.computing":"统计中…","common.readingSessions":"读取会话中…","common.loadingSession":"加载会话中…","common.noData":"暂无数据","common.entries":"项","common.entry":"项","common.selectAll":"全选","common.deselectAll":"取消全选","common.cancel":"取消","common.done":"完成","common.expand":"展开","common.collapse":"收起","common.system":"系统","common.onlyUser":"仅我","common.onlyError":"错误","common.missing":"已不存在","common.noSessions":"该项目下暂无会话。","common.noProjects":"未发现项目。","common.noMessagesMatch":"没有匹配的消息。","common.failedProjects":"加载项目失败","common.failedSessions":"加载会话列表失败","common.failedSession":"加载失败","common.failedMemory":"加载记忆失败","common.failed":"失败","common.searchPlaceholder":"在此会话中搜索…","common.loadEarlier":"加载更早 (+{{n}})","common.scrollToTop":"回到顶部","common.scrollToBottom":"回到底部","projects.title":"项目","projects.tagline":"所有曾用 Claude Code 的工作目录,按最近活跃度排序。点击进入查看或清理其会话。","projects.indexHeading":"索引","projects.stat.projects":"项目数","projects.stat.sessions":"会话数","projects.stat.onDisk":"占用","projects.card.eyebrow":"项目","projects.card.sessions":"会话","projects.card.onDisk":"占用","projects.card.lastSeen":"最近","projects.warn.rootMissing":"Claude 根目录 {{root}} 在本机不存在 — 无可显示内容。","project.eyebrow":"项目","project.warn.missingDir":"目录已从磁盘删除","project.action.openFolder":"打开目录","project.action.openFolderTooltipMissing":"目录已不在本机磁盘上","project.action.openFolderFailed":"打开目录失败:{{msg}}","project.action.delete":"删除 · {{n}}","project.action.select":"选择","project.action.exitSelect":"退出","project.bulk.selectedCount":"已选 {{n}} 条","project.bulk.deleteCta":"删除选中","project.bulk.deletePending":"正在删除 {{i}}/{{total}}…","project.bulk.resultOk":"成功 {{ok}} 条","project.bulk.resultSkipped":"跳过 {{n}} 条","project.bulk.resultFailed":"失败 {{n}} 条","project.bulk.viewDetail":"查看明细","project.bulk.hideDetail":"收起","project.bulk.detailSkipped":"跳过","project.bulk.detailFailed":"失败","project.bulk.dismiss":"关闭","project.meta.sessions":"会话","project.meta.onDisk":"占用","project.meta.working":"工作中","project.meta.live":"运行中","project.meta.recent":"近期","project.heading":"会话","project.col.title":"标题","project.col.msgs":"消息","project.col.last":"最近","project.col.size":"大小","project.col.status":"状态","project.col.errors":"错误","session.crumbProjects":"项目","session.action.delete":"删除","session.action.deleteTooltipBlocked":"暂无法获取该会话状态","session.action.rename":"重命名","session.action.renameTooltipLive":"运行中 PID {{pid}} 占用此会话 — 请先关闭对应的 claude","session.tagline":"开始于 {{started}} · 最后触达 {{lastTouched}}{{branchPart}}","session.tagline.branch":" · 分支 {{branch}}","session.meta.messages":"消息数","session.meta.size":"大小","session.meta.version":"版本","session.meta.started":"开始时间","session.truncated":"会话已截断至前 {{n}} 条消息。","session.shown":"{{shown}} / {{total}}","session.live":"实时","session.live.tooltip":"自动更新 — 新消息写入时实时追加","session.working":"工作中","session.working.tooltip":"Claude 正在处理这一轮 — 生成回复或执行工具","session.working.indicator":"Claude 正在处理…","session.modified.title":"修改的文件","session.modified.empty":"本次会话没有修改任何文件。","session.modified.loading":"扫描文件改动…","session.modified.failed":"加载修改文件清单失败","session.modified.count":"{{n}} 个文件","session.modified.countPlural":"{{n}} 个文件","session.modified.openAria":"打开修改的文件","session.modified.close":"关闭","session.modified.openFile":"打开文件","session.modified.openFailed":"打开文件失败:{{msg}}","session.modified.col.file":"文件","session.modified.col.conversation":"对话","session.modified.collapseAll":"全部收起","session.modified.expandAll":"全部展开","session.modified.selectFile":"从左侧选择一个文件,查看本次会话对它的改动。","session.modified.errorBadge":"{{n}} 次失败","session.modified.absolutePath":"绝对路径","session.modified.jump":"跳转到","session.modified.opErrored":"失败","session.modified.opPending":"未完成","session.modified.newContent":"新内容","session.modified.linesOmitted":"省略 {{n}} 行未改动","session.modified.editN":"改动 {{n}}","session.modified.contentUnavailable":"改动内容不可用(会话在此处之后被截断)。","session.modified.noContent":"该操作没有记录到内容。","session.modified.showEarlier":"显示更早的 {{n}} 条消息","session.modified.added":"新增","session.modified.modified":"修改","message.role.you":"我","message.role.claude":"Claude","message.role.tool":"工具","message.role.system":"系统","tool.use":"工具","tool.result":"工具返回","tool.error":"工具错误","tool.thinking":"思考","tool.thinkingEncrypted":"内容被加密,无可读文本。","tool.image":"图片","tool.copy":"复制","tool.copied":"已复制","tool.moreLines":"… 还有 {{n}} 行","tool.replaceAll":"全部替换","status.working":"工作中","status.live":"运行中 · pid {{pid}}","status.recent":"近期","status.idle":"空闲","status.tooltip.working":"Claude 正在这个会话里处理任务","status.tooltip.live":"PID {{pid}} 仍在运行并绑定此会话","status.tooltip.recent":"jsonl 在过去 {{n}} 分钟内被修改","status.tooltip.idle":"空闲 — 可安全删除","disk.tagline":"`~/.claude/` 占用磁盘的全貌:哪些项目最沉,哪些会话最大。","disk.title":"磁盘占用","disk.meta.total":"总计","disk.meta.projects":"项目","disk.meta.sessions":"会话","disk.stat.total":"总占用","disk.stat.acrossProjects":"覆盖 {{n}} 个项目","disk.stat.sessions":"会话","disk.stat.largest":"最大 {{size}}","disk.stat.months":"月份覆盖","disk.composition.title":"构成","disk.composition.subtitle":"按项目占用","disk.composition.total":"合计","disk.cadence.title":"节奏","disk.cadence.subtitle":"每月 MB","disk.heaviest.title":"最沉的会话","disk.heaviest.top":"前 {{n}}","disk.col.num":"#","disk.col.title":"标题","disk.col.project":"项目","disk.col.last":"最近","disk.col.size":"大小","cleanup.title":"清理建议","cleanup.tagline":"值得清理的目标。逐条审视并手动操作 — 这里没有任何自动清理。","cleanup.section.largeSessions":"最大的会话","cleanup.section.largeSessions.hint":"按总占用前 {{n}} 名","cleanup.section.orphanFileHistory":"孤儿 file-history","cleanup.section.orphanFileHistory.hint":"file-history/<sid>/ 目录但无对应会话","cleanup.section.orphanSessionEnv":"孤儿 session-env","cleanup.section.orphanSessionEnv.hint":"session-env/<sid>/ 目录但无对应会话","cleanup.empty.largeSessions":"磁盘上还没有会话。","cleanup.empty.orphan":"无孤儿 — 无可清理。","cleanup.col.session":"会话","cleanup.col.project":"项目","cleanup.col.last":"最近","cleanup.col.size":"大小","cleanup.col.sid":"会话 id","cleanup.col.actions":"操作","cleanup.action.view":"查看","cleanup.action.delete":"删除","cleanup.action.deleting":"删除中…","cleanup.confirm.title":"确认删除孤儿?","cleanup.confirm.body":"将永久删除 {{kind}}/{{sid}}/({{size}})。其会话主体已不存在,不会影响其他数据。","cleanup.confirm.confirm":"删除","cleanup.confirm.cancel":"取消","cleanup.failed":"失败:{{msg}}","memory.title":"记忆","memory.empty":"该项目尚未沉淀任何记忆。","memory.action.open":"记忆","memory.action.openCount":"记忆 · {{n}}","memory.meta.entries":"条目数","memory.meta.types":"类型","memory.meta.lastUpdate":"最近更新","memory.type.user":"用户","memory.type.feedback":"反馈","memory.type.project":"项目","memory.type.reference":"外链","memory.type.other":"未分类","memory.loading":"读取记忆中…","memory.search.placeholder":"搜索标题、摘要或正文…","memory.search.hint":"按 {{hotkey}} 聚焦","memory.filter.all":"全部","memory.sort.label":"排序","memory.sort.index":"MEMORY.md 顺序","memory.sort.recent":"最近修改","memory.sort.name":"名称 A→Z","memory.sort.size":"体积大→小","memory.list.noResults":"没有匹配的条目。","memory.list.count":"{{n}} / {{total}}","memory.cover.title":"记忆索引","memory.cover.subtitle":"MEMORY.md","memory.cover.viewRaw":"查看原文","memory.cover.showAll":"展开全部({{n}})","memory.cover.collapse":"收起","memory.cover.missingTooltip":"未找到对应条目文件","memory.cover.orphan":"未列入索引","memory.empty.title":"尚未沉淀记忆","memory.empty.body":"Claude 会在你明确要求记住或观察到稳定偏好时,把记忆存到 ~/.claude/projects/<id>/memory/ 下。","memory.empty.orphanIndex":"索引中引用了 {{n}} 条记忆,但目前一条都不存在。","memory.section.untyped":"未分类","memory.drawer.close":"关闭","memory.drawer.indexHook":"在索引中的呈现","memory.drawer.notFound.title":"未找到条目","memory.drawer.notFound.body":"该记忆文件可能已被移除;如果索引里还有,会以灰化的形态出现在上方。","memory.raw.title":"MEMORY.md","memory.raw.subtitle":"精选索引 —— 原文","delete.eyebrow.confirm":"确认删除","delete.eyebrow.result":"结果","delete.title.confirm":"删除会话","delete.title.result":"已删除会话","delete.summary":"将删除 {{n}} 项 · 跳过 {{skipped}} 项 · 释放约 {{free}}","delete.skipped.heading":"将跳过这 {{n}} 项:","delete.skipped.reasonLive":"运行中 PID {{pid}}","delete.skipped.reasonRecent":"过去 {{n}} 分钟内有修改","delete.skipped.reasonUnknown":"未知","delete.success":"已删除 {{n}} 个会话。释放 {{free}} · 清理 {{lines}} 条历史记录","delete.btn.confirm":"删除 {{n}} {{label}}","delete.btn.confirmPending":"删除中…","delete.label.session":"个会话","delete.label.sessions":"个会话","delete.close":"关闭","deleteProject.row.action":"删除项目","deleteProject.eyebrow.confirm":"确认删除","deleteProject.eyebrow.result":"结果","deleteProject.title.confirm":"删除项目","deleteProject.title.result":"项目已删除","deleteProject.summary":"{{n}} 个会话 · 约释放 {{free}} · 项目目录将被删除","deleteProject.warning":"将删除 {{cwd}} 下的全部会话及其在 history.jsonl 的记录,操作不可撤销。","deleteProject.blocked.heading":"{{n}} 个会话正在运行或最近 5 分钟内被修改 — 本次不会删除任何内容,请稍后再试。","deleteProject.success":"已删除 {{n}} 个会话及项目目录。释放 {{free}} · 清理 {{lines}} 条历史记录","deleteProject.successKept":"已删除 {{n}} 个会话。释放 {{free}} · 清理 {{lines}} 条历史记录 · 项目目录已保留","deleteProject.btn.confirm":"删除项目","deleteProject.btn.confirmPending":"删除中…","search.action.open":"搜索会话","search.placeholder":"在所有会话中搜索…","search.empty":"至少输入 2 个字符,将在磁盘上的所有会话中搜索。","search.refineQuery":"请输入更长的关键词以缩小范围。","search.scanning":"扫描中…","search.noResults":"没有匹配项。","search.error":"搜索失败:{{msg}}","search.moreInSession":"该会话中还有更多","search.moreSessions":"仅显示前 {{n}} 个会话 — 请细化关键词。","search.summary":"{{matched}} 个会话 · 扫描 {{scanned}} 项 · {{ms}}ms","search.shortcut":"{{hint}} 唤起","search.escapeHint":"esc 关闭","search.kindText":"文本","search.kindToolUse":"工具","search.kindToolResult":"工具返回","search.kindThinking":"思考","search.role.user":"我","search.role.assistant":"Claude","export.action":"导出","export.eyebrow.confirm":"跨设备共享","export.eyebrow.result":"结果","export.title.confirm":"导出项目","export.title.result":"导出完成","export.summary":"将 {{n}} 个会话 + 记忆打包到可移植文件夹。","export.destLabel":"目标文件夹","export.destPlaceholder":"例如 D:\\sync\\claude-shared","export.destHint":"~/.claude 之外的绝对路径。放进 git 仓库或云盘即可同步。","export.privacy":"这会把你的对话与记忆写到应用之外。如果把该文件夹推送到远端,这些内容将离开本机。","export.btn.confirm":"导出","export.btn.pending":"导出中…","export.success":"已导出 {{sessions}} 个会话 · {{memory}} 个记忆文件 · {{lines}} 条历史","export.successDest":"写入到 {{dest}}","export.close":"关闭","import.title":"导入归档","import.tagline":"从另一台设备导入项目的会话与记忆。路径会被重映射到本机。","import.bundleLabel":"归档文件夹","import.bundlePlaceholder":"已导出归档的路径","import.btn.load":"加载归档","import.btn.recheck":"重新检查","import.btn.loading":"加载中…","import.source":"来自 {{platform}} · {{cwd}}","import.targetLabel":"导入到(本机)","import.targetHint":"本机绝对路径。会话将与该目录关联。","import.targetId":"项目 id:{{id}}","import.suggestions":"建议","import.suggestion.existing-project":"已有项目","import.suggestion.original-path":"原始路径","import.suggestion.same-basename":"同名目录","import.policyLabel":"当会话已存在时","import.policy.skip":"跳过","import.policy.overwrite-if-newer":"较新则覆盖","import.policy.keep-both":"两者都留","import.sessions.heading":"会话","import.sessions.empty":"此归档没有会话。","import.action.create":"新建","import.action.overwrite":"覆盖","import.action.keep-both":"另存","import.action.skip":"跳过","import.memory.heading":"记忆","import.memory.create":"新建","import.memory.skip":"相同","import.memory.conflict":"冲突 → {{name}}","import.history":"将新增 {{n}} 条历史","import.btn.commit":"导入","import.btn.committing":"导入中…","import.result.title":"导入完成","import.result.summary":"已导入 {{n}} 个会话 · 跳过 {{skipped}} · {{memory}} 个记忆文件 · {{lines}} 条历史","import.result.viewProject":"打开已导入项目","import.empty":"输入归档文件夹路径以开始。"}};function Cr(){if(typeof window>"u")return"en";try{const t=localStorage.getItem(Ot);if(t==="en"||t==="zh")return t}catch{}return navigator.language.toLowerCase().startsWith("zh")?"zh":"en"}let Se=typeof window<"u"?Cr():"en";const Fe=new Set;function rt(t){if(t!==Se){Se=t;try{localStorage.setItem(Ot,t)}catch{}document.documentElement.setAttribute("lang",t),Fe.forEach(r=>r(t))}}function We(){const[t,r]=d.useState(Se);d.useEffect(()=>{const n=a=>r(a);return Fe.add(n),()=>{Fe.delete(n)}},[]);const s=d.useCallback(n=>{rt(n)},[]),o=d.useCallback(()=>{rt(Se==="en"?"zh":"en")},[]);return{locale:t,setLocale:s,toggle:o}}function N(){const{locale:t}=We();return d.useCallback((r,s)=>Ne(t,r,s),[t])}function Ne(t,r,s){let n=tt[t][r]??tt.en[r]??r;if(s)for(const[a,i]of Object.entries(s))n=n.replaceAll(`{{${a}}}`,String(i));return n}async function*Lr(t){const r=new URLSearchParams({q:t.query});t.perSession!==void 0&&r.set("perSession",String(t.perSession)),t.maxSessions!==void 0&&r.set("maxSessions",String(t.maxSessions));const s=await fetch(`/api/search?${r.toString()}`,{signal:t.signal,headers:{accept:"application/x-ndjson"}});if(!s.ok){const a=await s.text().catch(()=>"");throw new Error(`${s.status} ${s.statusText}${a?` — ${a}`:""}`)}if(!s.body)throw new Error("search stream returned no body");const o=s.body.pipeThrough(new TextDecoderStream).getReader();let n="";try{for(;;){const{value:a,done:i}=await o.read();if(i){if(n.trim()){const c=ot(n);c&&(yield c)}return}n+=a;let l;for(;(l=n.indexOf(`
3
+ `))!==-1;){const c=n.slice(0,l);n=n.slice(l+1);const u=ot(c);u&&(yield u)}}}finally{try{await o.cancel()}catch{}}}function ot(t){const r=t.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}const Te=2,Er=220;function Mr({open:t,onClose:r}){const s=N(),o=At(),[n,a]=d.useState(""),[i,l]=d.useState([]),[c,u]=d.useState(null),[m,h]=d.useState(!1),[v,g]=d.useState(null),[x,y]=d.useState(0),T=d.useRef(null),L=d.useRef(null),O=d.useRef(null),U=d.useMemo(()=>{const w=[];let E=0;return i.forEach((W,D)=>{W.snippets.forEach((z,Q)=>{w.push({hit:W,snippet:z,hitIndex:D,snippetIndex:Q,flatIndex:E++})})}),w},[i]),_=n.trim();d.useEffect(()=>{if(!t)return;const w=window.setTimeout(()=>{S(_)},Er);return()=>window.clearTimeout(w)},[_,t]),d.useEffect(()=>{y(0)},[i.length]),d.useEffect(()=>{var W;if(!t){(W=O.current)==null||W.abort(),O.current=null,a(""),l([]),u(null),g(null),h(!1),y(0);return}let w=0;w=requestAnimationFrame(()=>{var D;(D=T.current)==null||D.focus()});function E(D){D.key==="Escape"&&(D.preventDefault(),r())}return window.addEventListener("keydown",E),()=>{cancelAnimationFrame(w),window.removeEventListener("keydown",E)}},[t,r]);const S=d.useCallback(w=>{var W;if((W=O.current)==null||W.abort(),w.length<Te){l([]),u(null),g(null),h(!1);return}const E=new AbortController;O.current=E,l([]),u(null),g(null),h(!0),(async()=>{try{for await(const D of Lr({query:w,signal:E.signal})){if(E.signal.aborted)return;D.type==="session"?l(z=>[...z,D]):D.type==="done"&&u(D)}}catch(D){if(E.signal.aborted)return;g(D.message)}finally{E.signal.aborted||h(!1)}})()},[]),M=d.useCallback((w,E)=>{const W=new URLSearchParams({focus:E.uuid,q:_});o(`/projects/${encodeURIComponent(w.projectId)}/sessions/${encodeURIComponent(w.sessionId)}?${W.toString()}`),r()},[o,r,_]);function G(w){if(U.length!==0){if(w.key==="ArrowDown")w.preventDefault(),y(E=>Math.min(E+1,U.length-1));else if(w.key==="ArrowUp")w.preventDefault(),y(E=>Math.max(E-1,0));else if(w.key==="Home")w.preventDefault(),y(0);else if(w.key==="End")w.preventDefault(),y(U.length-1);else if(w.key==="Enter"){w.preventDefault();const E=U[x];E&&M(E.hit,E.snippet)}}}if(d.useEffect(()=>{if(!L.current)return;const w=L.current.querySelector(`[data-flat-index="${x}"]`);w==null||w.scrollIntoView({block:"nearest"})},[x]),!t)return null;const J=_.length===0,te=!J&&_.length<Te,K=!m&&!v&&_.length>=Te&&i.length===0&&c!==null;return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center px-4 pt-[12vh] sm:px-6",children:[e.jsx("button",{type:"button","aria-label":s("delete.close"),onClick:r,className:"fixed inset-0 bg-[var(--color-canvas)]/65 backdrop-blur-sm"}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":s("search.action.open"),className:"relative z-10 w-full max-w-2xl rounded-[var(--radius-panel)] border border-[var(--color-hairline)] bg-[var(--color-surface)] shadow-[var(--shadow-pop)]",onKeyDown:G,children:[e.jsxs("header",{className:"flex items-center gap-3 border-b border-[var(--color-hairline)] px-5 py-4",children:[e.jsx(Rr,{className:"text-[var(--color-fg-muted)]"}),e.jsx("input",{ref:T,type:"search",autoFocus:!0,value:n,onChange:w=>a(w.target.value),placeholder:s("search.placeholder"),className:"flex-1 bg-transparent text-[15px] text-[var(--color-fg-primary)] placeholder:text-[var(--color-fg-faint)] focus:outline-none"}),m&&e.jsxs("span",{className:"inline-flex items-center gap-2 font-mono text-[10px] uppercase tracking-[0.18em] text-[var(--color-fg-muted)]",children:[s("search.scanning"),e.jsx(Nr,{})]})]}),e.jsxs("div",{ref:L,className:"max-h-[60vh] overflow-y-auto px-1 py-2",children:[J&&e.jsx(ge,{children:s("search.empty")}),te&&e.jsx(ge,{children:s("search.refineQuery")}),v&&e.jsx(ge,{tone:"danger",children:s("search.error",{msg:v})}),K&&e.jsx(ge,{children:s("search.noResults")}),i.map((w,E)=>e.jsx(Pr,{hit:w,hitIndex:E,flatItems:U,activeIndex:x,query:_,onPick:M,onHover:y},`${w.projectId}/${w.sessionId}`)),(c==null?void 0:c.truncated)&&e.jsx(ge,{children:s("search.moreSessions",{n:c.matched})})]}),e.jsxs("footer",{className:"flex items-center justify-between border-t border-[var(--color-hairline)] px-5 py-2.5 font-mono text-[10px] uppercase tracking-[0.18em] text-[var(--color-fg-muted)]",children:[e.jsxs("span",{children:[s("search.shortcut",{hint:$t})," · ",s("search.escapeHint")]}),c&&i.length>0&&e.jsx("span",{children:s("search.summary",{matched:c.matched,scanned:c.scanned,ms:c.durationMs})})]})]})]})}function Pr({hit:t,hitIndex:r,flatItems:s,activeIndex:o,query:n,onPick:a,onHover:i}){const l=N(),c=t.customTitle??t.title,u=d.useMemo(()=>t.projectDecodedCwd.split(/[\\/]+/).filter(Boolean).at(-1)??t.projectDecodedCwd,[t.projectDecodedCwd]);return e.jsxs("div",{className:"px-2 pb-1 pt-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3 px-2",children:[e.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-[var(--color-accent)]",children:u}),e.jsx("span",{className:"truncate font-display text-[13px] text-[var(--color-fg-primary)]",children:c})]}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-[var(--color-fg-muted)]",children:pe(t.lastAt)})]}),e.jsx("ul",{className:"mt-1.5 space-y-0.5",children:t.snippets.map((m,h)=>{const v=s.find(y=>y.hitIndex===r&&y.snippetIndex===h),g=(v==null?void 0:v.flatIndex)??-1,x=g===o;return e.jsx("li",{children:e.jsxs("button",{type:"button","data-flat-index":g,onMouseEnter:()=>i(g),onClick:()=>a(t,m),className:"block w-full rounded-[var(--radius-input)] px-3 py-2 text-left transition "+(x?"bg-[var(--color-accent-soft)] text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]":"text-[var(--color-fg-secondary)] hover:bg-[var(--color-sunken)]"),children:[e.jsxs("div",{className:"flex items-baseline gap-2 font-mono text-[10px] uppercase tracking-[0.16em] text-[var(--color-fg-muted)]",children:[e.jsx("span",{children:l(`search.role.${m.role}`)}),e.jsx("span",{children:"·"}),e.jsx("span",{children:Tr(m.blockKind,l)})]}),e.jsxs("p",{className:"mt-1 truncate text-[13px] leading-relaxed",children:[e.jsx("span",{className:"text-[var(--color-fg-faint)]",children:m.before}),e.jsx("mark",{className:"rounded-sm bg-[var(--color-accent-soft)] px-0.5 font-medium text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]",children:m.match}),e.jsx("span",{className:"text-[var(--color-fg-faint)]",children:m.after})]})]})},`${m.uuid}-${h}`)})}),t.hasMore&&e.jsx("p",{className:"px-3 pt-1 font-mono text-[10px] uppercase tracking-[0.16em] text-[var(--color-fg-faint)]",children:l("search.moreInSession")})]})}function Tr(t,r){switch(t){case"text":return r("search.kindText");case"tool_use":return r("search.kindToolUse");case"tool_result":return r("search.kindToolResult");case"thinking":return r("search.kindThinking")}}function ge({children:t,tone:r="normal"}){const s=r==="danger"?"text-[var(--color-danger)]":"text-[var(--color-fg-muted)]";return e.jsx("p",{className:`px-5 py-6 text-center text-sm ${s}`,children:t})}function Rr({className:t=""}){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",className:t,"aria-hidden":!0,children:[e.jsx("circle",{cx:"11",cy:"11",r:"6.2"}),e.jsx("path",{d:"M20 20l-4.3-4.3"})]})}function Ir({className:t=""}){const{locale:r,setLocale:s}=We();return e.jsxs("div",{role:"group","aria-label":"Language",className:"inline-flex h-9 items-center rounded-full border border-[var(--color-hairline)] bg-[var(--color-sunken)] p-0.5 text-[11px] font-medium "+t,children:[e.jsx(st,{active:r==="en",onClick:()=>s("en"),label:"EN"}),e.jsx(st,{active:r==="zh",onClick:()=>s("zh"),label:"中"})]})}function st({active:t,onClick:r,label:s}){return e.jsx("button",{type:"button",onClick:r,"aria-pressed":t,className:"h-7 min-w-[2rem] rounded-full px-2 transition "+(t?"bg-[var(--color-surface)] text-[var(--color-fg-primary)] shadow-[var(--shadow-rise)]":"text-[var(--color-fg-muted)] hover:text-[var(--color-fg-primary)]"),children:s})}const nt="theme";function Dr(){return typeof document>"u"?"light":document.documentElement.classList.contains("dark")?"dark":"light"}function Ar(){const[t,r]=d.useState(Dr),s=d.useCallback(n=>{r(n),document.documentElement.classList.toggle("dark",n==="dark");try{localStorage.setItem(nt,n)}catch{}},[]),o=d.useCallback(()=>{s(t==="dark"?"light":"dark")},[t,s]);return d.useEffect(()=>{const n=window.matchMedia("(prefers-color-scheme: dark)"),a=i=>{localStorage.getItem(nt)||s(i.matches?"dark":"light")};return n.addEventListener("change",a),()=>n.removeEventListener("change",a)},[s]),{theme:t,setTheme:s,toggle:o}}function _r({className:t=""}){const{theme:r,toggle:s}=Ar(),o=r==="dark";return e.jsxs("button",{type:"button",onClick:s,"aria-label":o?"Switch to light theme":"Switch to dark theme",title:o?"Light":"Dark",className:"group inline-flex h-9 w-16 items-center rounded-full border border-[var(--color-hairline)] bg-[var(--color-sunken)] px-1 transition hover:border-[var(--color-hairline-strong)] "+t,children:[e.jsx("span",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-[var(--color-surface)] text-[var(--color-fg-secondary)] shadow-[var(--shadow-rise)] transition-transform duration-300",style:{transform:o?"translateX(28px)":"translateX(0)"},children:o?e.jsx(Fr,{}):e.jsx(Br,{})}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}function Br(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3.6"}),e.jsx("path",{d:"M12 3v2.4M12 18.6V21M3 12h2.4M18.6 12H21M5.6 5.6l1.7 1.7M16.7 16.7l1.7 1.7M5.6 18.4l1.7-1.7M16.7 7.3l1.7-1.7"})]})}function Fr(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"M20.5 14.4A8.5 8.5 0 1 1 9.6 3.5a7 7 0 0 0 10.9 10.9z"})})}async function B(t,r){const s=await fetch(t,{...r,headers:{"content-type":"application/json",...(r==null?void 0:r.headers)??{}}});if(!s.ok){const o=await s.text().catch(()=>"");let n=o;if(o)try{const a=JSON.parse(o);typeof a.error=="string"&&(n=a.error)}catch{}throw new Error(`${s.status} ${s.statusText}${n?` — ${n}`:""}`)}return s.json()}const R={health:()=>["health"],projects:()=>["projects"],projectSessions:t=>["project-sessions",t],projectMemory:t=>["project-memory",t],session:(t,r)=>["session",t,r],sessionModifiedFiles:(t,r)=>["session-modified-files",t,r],diskUsage:()=>["disk-usage"],diskCleanupSuggestions:()=>["disk-cleanup-suggestions"],search:t=>["search",t],version:()=>["version"]},at="npm install -g @zzusp/ccsm@latest";function Ut(){return Y({queryKey:R.version(),queryFn:()=>B("/api/version"),staleTime:1800*1e3,refetchOnWindowFocus:!1})}function $r(){const t=N(),[r,s]=d.useState(!1),{data:o}=Ut();return o?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>s(!0),className:"group flex w-full items-center justify-between gap-2 text-left",children:[e.jsx("span",{className:"eyebrow",children:t("version.label")}),o.hasUpdate?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-[var(--radius-control)] border border-[var(--color-accent)]/45 bg-[var(--color-accent-soft)] px-2 py-0.5 font-mono text-[10px] font-medium uppercase tracking-[0.1em] text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]",children:[e.jsxs("span",{"aria-hidden":!0,className:"relative inline-flex h-1.5 w-1.5",children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-[var(--color-danger)] pulse-danger"}),e.jsx("span",{className:"absolute inset-0 rounded-full bg-[var(--color-danger)]"})]}),t("version.badge.new",{v:`v${o.latest}`})]}):e.jsxs("span",{className:"font-mono text-[11px] text-[var(--color-fg-faint)] transition-colors group-hover:text-[var(--color-fg-secondary)]",children:["v",o.current]})]}),pr.createPortal(e.jsx(Bt,{children:r&&e.jsx(Or,{info:o,onClose:()=>s(!1)})}),document.body)]}):null}function Or({info:t,onClose:r}){var h;const s=N(),o=le({mutationFn:()=>B("/api/version/update",{method:"POST"})}),n=d.useRef(o.isPending);n.current=o.isPending,d.useEffect(()=>{function v(g){g.key==="Escape"&&!n.current&&r()}return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[r]);const a=o.data,i=t.hasUpdate,l=(h=t.releaseNotes)==null?void 0:h.trim(),c=t.publishedAt?new Date(t.publishedAt).toLocaleDateString():null,u=!!(a!=null&&a.ok),m=i&&!u;return e.jsx($.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:"fixed inset-0 z-[60] flex items-start justify-center bg-[oklch(0.16_0.006_85_/_0.55)] px-4 py-12 backdrop-blur-[2px]",onClick:()=>!o.isPending&&r(),children:e.jsxs($.div,{initial:{y:8,opacity:0},animate:{y:0,opacity:1},transition:{duration:.24,ease:[.16,1,.3,1]},className:"flex max-h-[80vh] w-full max-w-xl flex-col overflow-hidden rounded-[var(--radius-panel)] border border-[var(--color-hairline)] bg-[var(--color-surface)] shadow-[var(--shadow-pop)]",onClick:v=>v.stopPropagation(),children:[e.jsxs("header",{className:"flex items-start justify-between gap-4 border-b border-[var(--color-hairline)] px-6 py-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"eyebrow text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]",children:s(i?"version.modal.eyebrowUpdate":"version.modal.eyebrowLatest")}),e.jsx("h2",{className:"mt-1 font-display text-2xl font-light tracking-tight text-[var(--color-fg-primary)]",children:s(i?"version.modal.titleUpdate":"version.modal.titleLatest")}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx(ct,{label:s("version.current"),value:`v${t.current}`}),i&&t.latest&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,className:"font-mono text-sm text-[var(--color-fg-faint)]",children:"→"}),e.jsx(ct,{label:s("version.latest"),value:`v${t.latest}`,accent:!0})]})]}),(c||t.checkError)&&e.jsxs("p",{className:"mt-2 font-mono text-[11px] text-[var(--color-fg-faint)]",children:[c&&s("version.published",{date:c}),t.checkError&&(c?` · ${s("version.checkFailed")}`:s("version.checkFailed"))]})]}),e.jsx("button",{type:"button",onClick:r,disabled:o.isPending,"aria-label":s("version.btn.close"),className:"shrink-0 rounded-xl p-1.5 text-[var(--color-fg-muted)] hover:bg-[var(--color-sunken)] hover:text-[var(--color-fg-primary)] disabled:opacity-50",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:e.jsx("path",{d:"M6 6l12 12M18 6L6 18"})})})]}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto px-6 py-5",children:[a?e.jsx(Ur,{result:a}):e.jsxs("section",{children:[e.jsx("p",{className:"eyebrow mb-2",children:s("version.notes")}),l?e.jsx("div",{className:"max-h-72 overflow-y-auto rounded-[var(--radius-input)] border border-[var(--color-hairline)] bg-[var(--color-sunken)] px-4 py-3.5",children:e.jsx(qr,{source:l})}):e.jsx("p",{className:"text-sm text-[var(--color-fg-muted)]",children:s("version.notesEmpty")})]}),o.error&&e.jsx("p",{className:"rounded-md border border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] px-3 py-2 text-sm text-[var(--color-danger)]",children:o.error.message})]}),e.jsxs("footer",{className:"flex items-center justify-between gap-2 border-t border-[var(--color-hairline)] px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[t.releaseUrl&&e.jsx(lt,{href:t.releaseUrl,label:s("version.btn.releasePage")}),e.jsx(lt,{href:t.repositoryUrl,label:s("version.btn.repo")})]}),e.jsx("div",{className:"flex items-center gap-2",children:m?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:r,disabled:o.isPending,className:"rounded-[var(--radius-control)] border border-[var(--color-hairline-strong)] px-4 py-1.5 text-sm text-[var(--color-fg-secondary)] hover:bg-[var(--color-sunken)] disabled:opacity-50",children:s("common.cancel")}),e.jsxs("button",{type:"button",onClick:()=>o.mutate(),disabled:o.isPending,className:"inline-flex items-center gap-2 rounded-[var(--radius-control)] bg-[var(--color-fg-primary)] px-4 py-1.5 text-sm font-medium text-[var(--color-canvas)] shadow-[var(--shadow-rise)] hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",children:[o.isPending&&e.jsx(Hr,{}),o.isPending?s("version.btn.updating"):s("version.btn.update")]})]}):e.jsx("button",{type:"button",onClick:r,className:"rounded-[var(--radius-control)] bg-[var(--color-fg-primary)] px-4 py-1.5 text-sm font-medium text-[var(--color-canvas)] hover:opacity-90",children:s("common.done")})})]})]})})}function Ur({result:t}){const r=N();return t.ok?e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-[var(--radius-card)] border border-[var(--color-moss)]/40 bg-[var(--color-moss-soft)] px-3 py-2.5 text-sm text-[var(--color-fg-primary)]",children:[e.jsx("p",{className:"font-medium",children:r("version.update.successTitle")}),e.jsx("p",{className:"mt-0.5 text-[var(--color-fg-secondary)]",children:r("version.update.success",{v:`v${t.toVersion??""}`})})]}),t.output&&e.jsx(it,{output:t.output})]}):e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-[var(--radius-card)] border border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] px-3 py-2.5 text-sm",children:[e.jsx("p",{className:"font-medium text-[var(--color-danger)]",children:r("version.update.failTitle")}),e.jsx("p",{className:"mt-0.5 text-[var(--color-fg-secondary)]",children:r("version.update.fail")})]}),e.jsx(Wr,{}),t.output&&e.jsx(it,{output:t.output})]})}function Wr(){const t=N();return e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow mb-1.5",children:t("version.update.command")}),e.jsxs("div",{className:"flex items-center gap-2 rounded-[var(--radius-input)] border border-[var(--color-hairline)] bg-[var(--color-sunken)] px-3 py-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-[12.5px] text-[var(--color-fg-primary)]",children:at}),e.jsx(zr,{text:at})]})]})}function it({output:t}){const r=N();return e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow mb-1.5",children:r("version.update.output")}),e.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded-[var(--radius-input)] border border-[var(--color-hairline)] bg-[var(--color-sunken)] px-3 py-2 font-mono text-[11.5px] leading-[1.6] text-[var(--color-fg-muted)]",children:t})]})}function zr({text:t}){const[r,s]=d.useState(!1);return e.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(t),s(!0),window.setTimeout(()=>s(!1),1500)}catch{}},className:"shrink-0 rounded-[var(--radius-control)] border border-[var(--color-hairline-strong)] px-2 py-1 text-[var(--color-fg-muted)] hover:bg-[var(--color-surface)] hover:text-[var(--color-fg-primary)]","aria-label":"copy",children:r?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M5 12l5 5L20 6"})}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),e.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10"})]})})}function lt({href:t,label:r}){return e.jsxs("a",{href:t,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 rounded-[var(--radius-control)] px-2.5 py-1.5 text-xs font-medium text-[var(--color-fg-secondary)] hover:bg-[var(--color-sunken)] hover:text-[var(--color-fg-primary)]",children:[r,e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M7 17L17 7"}),e.jsx("path",{d:"M8 7h9v9"})]})]})}function Hr(){return e.jsxs("svg",{className:"animate-spin",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2.5",opacity:"0.25"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})}function ct({label:t,value:r,accent:s=!1}){return e.jsxs("span",{className:"inline-flex items-baseline gap-1.5 rounded-[var(--radius-control)] border px-2.5 py-1 font-mono "+(s?"border-[var(--color-accent)]/45 bg-[var(--color-accent-soft)]":"border-[var(--color-hairline)] bg-[var(--color-surface)]"),children:[e.jsx("span",{className:"text-[9px] uppercase tracking-[0.12em] text-[var(--color-fg-faint)]",children:t}),e.jsx("span",{className:"text-[13px] "+(s?"text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]":"text-[var(--color-fg-primary)]"),children:r})]})}function qr({source:t}){return e.jsx("div",{className:"space-y-2.5 text-[13px] leading-[1.65] text-[var(--color-fg-primary)]",children:Qr(t)})}function Kr(t){return/^\s*```/.test(t)||/^(#{1,6})\s+/.test(t)||/^\s*([-*+]|\d+\.)\s+/.test(t)||/^\s*([-*_])\1{2,}\s*$/.test(t)}function Qr(t){const r=t.replace(/\r\n/g,`
4
+ `).split(`
5
+ `),s=i=>r[i]??"",o=[];let n=0,a=0;for(;n<r.length;){const i=s(n);if(!i.trim()){n++;continue}if(/^\s*```/.test(i)){const u=[];for(n++;n<r.length&&!/^\s*```/.test(s(n));)u.push(s(n)),n++;n++,o.push(e.jsx("pre",{className:"overflow-x-auto rounded-[var(--radius-control)] border border-[var(--color-hairline)] bg-[var(--color-surface)] px-3 py-2 font-mono text-[12px] leading-[1.6] text-[var(--color-fg-secondary)]",children:u.join(`
6
+ `)},a++));continue}const l=i.match(/^(#{1,6})\s+(.*)$/);if(l){const u=(l[1]??"").length;o.push(e.jsx("p",{className:"font-display font-medium tracking-tight text-[var(--color-fg-primary)] "+(u<=2?"text-[15px]":"text-[13.5px]"),children:Re(l[2]??"")},a++)),n++;continue}if(/^\s*([-*_])\1{2,}\s*$/.test(i)){o.push(e.jsx("hr",{className:"border-[var(--color-hairline)]"},a++)),n++;continue}if(/^\s*([-*+]|\d+\.)\s+/.test(i)){const u=/^\s*\d+\.\s+/.test(i),m=[];for(;n<r.length&&/^\s*([-*+]|\d+\.)\s+/.test(s(n));){const v=s(n).replace(/^\s*([-*+]|\d+\.)\s+/,"");m.push(e.jsx("li",{children:Re(v)},m.length)),n++}const h="ml-4 space-y-1 marker:text-[var(--color-fg-faint)] "+(u?"list-decimal":"list-disc");o.push(u?e.jsx("ol",{className:h,children:m},a++):e.jsx("ul",{className:h,children:m},a++));continue}const c=[i];for(n++;n<r.length&&s(n).trim()&&!Kr(s(n));)c.push(s(n)),n++;o.push(e.jsx("p",{children:Re(c.join(" "))},a++))}return o}const dt=/(`[^`]+`)|(\[[^\]]+\]\([^)\s]+\))|(\*\*[^*]+\*\*)|(\*[^*\s][^*]*\*)|(_[^_\s][^_]*_)/g;function Re(t){const r=[];let s=0,o=0,n;for(dt.lastIndex=0;(n=dt.exec(t))!==null;){n.index>s&&r.push(t.slice(s,n.index));const a=n[0]??"";if(n[1])r.push(e.jsx("code",{className:"rounded bg-[var(--color-surface)] px-1 py-0.5 font-mono text-[12px] text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]",children:a.slice(1,-1)},o++));else if(n[2]){const i=/^\[([^\]]+)\]\(([^)\s]+)\)$/.exec(a);r.push(e.jsx("a",{href:i[2]??"#",target:"_blank",rel:"noreferrer",className:"text-[var(--color-accent-ink)] underline decoration-[var(--color-hairline-strong)] underline-offset-2 hover:decoration-[var(--color-accent)] dark:text-[var(--color-accent)]",children:i[1]??""},o++))}else n[3]?r.push(e.jsx("strong",{className:"font-semibold text-[var(--color-fg-primary)]",children:a.slice(2,-2)},o++)):r.push(e.jsx("em",{children:a.slice(1,-1)},o++));s=n.index+a.length}return s<t.length&&r.push(t.slice(s)),r}const Vr=[{to:"/",labelKey:"nav.projects",icon:e.jsx(Jr,{}),match:t=>t==="/"||t.startsWith("/projects/")},{to:"/disk",labelKey:"nav.disk",icon:e.jsx(Xr,{}),match:t=>t==="/disk"||t.startsWith("/disk/")},{to:"/import",labelKey:"nav.import",icon:e.jsx(Zr,{}),match:t=>t==="/import"||t.startsWith("/import/")}];function Yr({onSearchOpen:t}){var i;const r=N(),{pathname:s}=vr(),[o,n]=d.useState(!1),a=((i=Ut().data)==null?void 0:i.hasUpdate)??!1;return d.useEffect(()=>{const l=()=>n(!1);return window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)},[]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"topbar-glass sticky top-0 z-40 flex items-center justify-between border-b border-[var(--color-hairline)] px-4 py-3 lg:hidden",children:[e.jsx(mt,{}),e.jsxs("div",{className:"flex items-center gap-2",children:[t&&e.jsx("button",{type:"button",onClick:t,"aria-label":r("search.action.open"),className:"inline-flex h-9 w-9 items-center justify-center rounded-xl border border-[var(--color-hairline)] text-[var(--color-fg-secondary)] hover:border-[var(--color-hairline-strong)] hover:text-[var(--color-accent)]",children:e.jsx(ut,{})}),e.jsxs("button",{type:"button",onClick:()=>n(l=>!l),"aria-label":r("nav.toggleNav"),className:"relative inline-flex h-9 w-9 items-center justify-center rounded-xl border border-[var(--color-hairline)] text-[var(--color-fg-secondary)] hover:border-[var(--color-hairline-strong)]",children:[e.jsx(eo,{open:o}),a&&!o&&e.jsxs("span",{"aria-hidden":!0,className:"absolute right-1 top-1 inline-flex h-2 w-2",title:r("version.modal.eyebrowUpdate"),children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-[var(--color-danger)] pulse-danger"}),e.jsx("span",{className:"absolute inset-0 rounded-full bg-[var(--color-danger)]"})]})]})]})]}),o&&e.jsx("button",{type:"button","aria-label":r("nav.closeNav"),onClick:()=>n(!1),className:"fixed inset-0 z-40 bg-[var(--color-canvas)]/70 backdrop-blur-sm lg:hidden"}),e.jsxs("aside",{className:"fixed inset-y-0 left-0 z-50 flex w-72 flex-col border-r border-[var(--color-hairline)] bg-[var(--color-sunken)] transition-transform duration-300 lg:sticky lg:top-0 lg:h-dvh lg:translate-x-0 "+(o?"translate-x-0":"-translate-x-full"),children:[e.jsx("div",{className:"flex h-[68px] items-center px-5",children:e.jsx(mt,{})}),t&&e.jsx("div",{className:"px-4 pb-2",children:e.jsxs("button",{type:"button",onClick:()=>{n(!1),t()},"aria-label":r("search.action.open"),className:"surface-card is-interactive flex w-full items-center gap-2.5 px-3 py-3 text-left",style:{borderRadius:"var(--radius-input)"},children:[e.jsx(ut,{className:"text-[var(--color-fg-muted)]"}),e.jsx("span",{className:"flex-1 truncate text-[13px] text-[var(--color-fg-muted)]",children:r("search.action.open")}),e.jsx("kbd",{className:"rounded border border-[var(--color-hairline)] bg-[var(--color-sunken)] px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-[0.14em] text-[var(--color-fg-faint)]",children:$t})]})}),e.jsxs("nav",{className:"flex-1 overflow-y-auto px-4 py-3",children:[e.jsx("p",{className:"eyebrow px-2 pb-2",children:r("nav.workspace")}),e.jsx("ul",{className:"space-y-1",children:Vr.map(l=>{const c=l.match(s);return e.jsx("li",{children:e.jsxs(ve,{to:l.to,"aria-current":c?"page":void 0,onClick:()=>n(!1),className:"group flex items-center gap-3 rounded-[var(--radius-input)] border px-4 py-3 text-sm transition "+(c?"border-[var(--color-hairline)] bg-[var(--color-surface)] text-[var(--color-fg-primary)] shadow-[var(--shadow-rise)]":"border-transparent text-[var(--color-fg-secondary)] hover:bg-[color-mix(in_oklch,var(--color-surface)_60%,transparent)] hover:text-[var(--color-fg-primary)]"),children:[e.jsx("span",{className:"transition-colors "+(c?"text-[var(--color-accent)]":"text-[var(--color-fg-muted)] group-hover:text-[var(--color-accent)]"),children:l.icon}),e.jsx("span",{className:"font-medium tracking-tight",children:r(l.labelKey)})]})},l.to)})})]}),e.jsxs("div",{className:"surface-card mx-4 mb-4 space-y-3 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"eyebrow",children:r("nav.language")}),e.jsx(Ir,{})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"eyebrow",children:r("nav.theme")}),e.jsx(_r,{})]}),e.jsx($r,{}),e.jsx("p",{className:"font-mono text-[10px] leading-snug text-[var(--color-fg-faint)]",children:r("app.brand.footnote")})]})]})]})}function mt(){const t=N();return e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{"aria-hidden":!0,className:"inline-flex h-9 w-9 items-center justify-center rounded-2xl border border-[var(--color-hairline)] bg-[var(--color-surface)] text-[var(--color-accent)] shadow-[var(--shadow-rise)]",children:e.jsx(Gr,{})}),e.jsxs("span",{className:"flex flex-col leading-tight",children:[e.jsx("span",{className:"font-display text-[15px] font-medium tracking-tight text-[var(--color-fg-primary)]",children:t("app.brand.title")}),e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-[var(--color-fg-muted)]",children:t("app.brand.subtitle")})]})]})}function Gr(){return e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M19 7.5A8 8 0 1 0 19 16.5"}),e.jsx("path",{d:"M15.5 9.5a4.5 4.5 0 1 0 0 5",opacity:"0.45"})]})}function Jr(){return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"M3 6.5A1.5 1.5 0 0 1 4.5 5h4.2a1.5 1.5 0 0 1 1.05.43l1.34 1.32A1.5 1.5 0 0 0 12.14 7.2H19.5A1.5 1.5 0 0 1 21 8.7v9.3a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 18z"})})}function Xr(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("ellipse",{cx:"12",cy:"6.5",rx:"8",ry:"2.5"}),e.jsx("path",{d:"M4 6.5v5c0 1.4 3.6 2.5 8 2.5s8-1.1 8-2.5v-5"}),e.jsx("path",{d:"M4 11.5v5c0 1.4 3.6 2.5 8 2.5s8-1.1 8-2.5v-5"})]})}function Zr(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M12 14V3"}),e.jsx("path",{d:"M8 10l4 4 4-4"}),e.jsx("path",{d:"M4 15v3.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V15"})]})}function ut({className:t=""}){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",className:t,"aria-hidden":!0,children:[e.jsx("circle",{cx:"11",cy:"11",r:"6.2"}),e.jsx("path",{d:"M20 20l-4.3-4.3"})]})}function eo({open:t}){return e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:t?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M6 6l12 12"}),e.jsx("path",{d:"M18 6L6 18"})]}):e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M4 7h16"}),e.jsx("path",{d:"M4 12h16"}),e.jsx("path",{d:"M4 17h12"})]})})}const pt="inline-flex min-w-0 items-center gap-1.5 rounded-lg px-3 py-1";function $e({items:t}){return e.jsx("nav",{"aria-label":"Breadcrumb",className:"inline-flex max-w-full items-center gap-1 overflow-hidden rounded-xl border border-[var(--color-accent)] bg-[var(--color-surface)] px-2 py-1.5 text-sm shadow-[var(--shadow-rise)]",children:t.map((r,s)=>{const o=s===t.length-1,n=r.mono?"font-mono":"font-sans",a=o?"text-[var(--color-fg-primary)]":"text-[var(--color-fg-secondary)]",i=e.jsxs(e.Fragment,{children:[r.icon&&e.jsx("span",{className:"shrink-0 text-[var(--color-accent)]",children:r.icon}),e.jsx("span",{className:"truncate",children:r.label})]});return e.jsxs(d.Fragment,{children:[r.to&&!o?e.jsx(ve,{to:r.to,className:`${pt} ${n} ${a} transition-colors duration-150 hover:bg-[var(--color-accent-soft)] hover:text-[var(--color-accent-ink)]`,children:i}):e.jsx("span",{className:`${pt} ${n} ${a}`,"aria-current":o?"page":void 0,children:i}),!o&&e.jsx(to,{})]},`${r.label}-${s}`)})})}function to(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-[var(--color-accent)]","aria-hidden":!0,children:e.jsx("polyline",{points:"9 6 15 12 9 18"})})}function Oe(){return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"M3 6.5A1.5 1.5 0 0 1 4.5 5h4.2a1.5 1.5 0 0 1 1.05.43l1.34 1.32A1.5 1.5 0 0 0 12.14 7.2H19.5A1.5 1.5 0 0 1 21 8.7v9.3a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 18z"})})}function ro({projectId:t,sessions:r,onClose:s}){const o=N(),[n,a]=d.useState(""),i=le({mutationFn:()=>B(`/api/projects/${encodeURIComponent(t)}/export`,{method:"POST",body:JSON.stringify({sessionIds:r.map(h=>h.id),destDir:n.trim()})})}),l=d.useRef(i.isPending);l.current=i.isPending,d.useEffect(()=>{function h(v){v.key==="Escape"&&!l.current&&s()}return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[s]);const c=i.data,u=!!c,m=n.trim()!==""&&!i.isPending;return e.jsx($.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:"fixed inset-0 z-[60] flex items-start justify-center bg-[oklch(0.16_0.006_85_/_0.55)] px-4 py-12 backdrop-blur-[2px]",onClick:()=>!i.isPending&&s(),children:e.jsxs($.div,{initial:{y:8,opacity:0},animate:{y:0,opacity:1},transition:{duration:.24,ease:[.16,1,.3,1]},className:"w-full max-w-xl overflow-hidden rounded-[var(--radius-panel)] border border-[var(--color-hairline)] bg-[var(--color-surface)] shadow-[var(--shadow-pop)]",onClick:h=>h.stopPropagation(),children:[e.jsxs("header",{className:"flex items-start justify-between gap-4 border-b border-[var(--color-hairline)] px-6 py-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]",children:o(u?"export.eyebrow.result":"export.eyebrow.confirm")}),e.jsx("h2",{className:"mt-1 font-display text-2xl font-light tracking-tight text-[var(--color-fg-primary)]",children:o(u?"export.title.result":"export.title.confirm")}),!u&&e.jsx("p",{className:"mt-1.5 text-sm text-[var(--color-fg-muted)]",children:o("export.summary",{n:r.length})})]}),e.jsx("button",{type:"button",onClick:s,disabled:i.isPending,"aria-label":o("export.close"),className:"rounded-xl p-1.5 text-[var(--color-fg-muted)] hover:bg-[var(--color-sunken)] hover:text-[var(--color-fg-primary)] disabled:opacity-50",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:e.jsx("path",{d:"M6 6l12 12M18 6L6 18"})})})]}),!u&&e.jsxs("div",{className:"space-y-4 px-6 py-5",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"eyebrow",children:o("export.destLabel")}),e.jsx("input",{type:"text",value:n,onChange:h=>a(h.target.value),placeholder:o("export.destPlaceholder"),spellCheck:!1,autoFocus:!0,className:"mt-1.5 w-full rounded-[var(--radius-input)] border border-[var(--color-hairline-strong)] bg-[var(--color-canvas)] px-3 py-2 font-mono text-sm text-[var(--color-fg-primary)] outline-none focus:border-[var(--color-accent)]"}),e.jsx("span",{className:"mt-1.5 block text-xs text-[var(--color-fg-muted)]",children:o("export.destHint")})]}),e.jsx("p",{className:"rounded-[var(--radius-card)] border border-[var(--color-accent)]/40 bg-[var(--color-accent-soft)] px-3 py-2.5 text-xs leading-relaxed text-[var(--color-accent-ink)] dark:text-[var(--color-fg-secondary)]",children:o("export.privacy")})]}),u&&c&&e.jsxs("div",{className:"space-y-3 px-6 py-5 text-sm",children:[e.jsx("div",{className:"rounded-[var(--radius-card)] border border-[var(--color-moss)]/40 bg-[var(--color-moss-soft)] px-3 py-2.5 text-[var(--color-fg-primary)]",children:o("export.success",{sessions:c.sessionsExported,memory:c.memoryFilesExported,lines:c.historyLinesExported})}),e.jsx("p",{className:"break-all font-mono text-xs text-[var(--color-fg-muted)]",children:o("export.successDest",{dest:c.destDir})})]}),i.error&&e.jsx("p",{className:"mx-6 mb-3 rounded-md border border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] px-3 py-2 text-sm text-[var(--color-danger)]",children:i.error.message}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-[var(--color-hairline)] px-6 py-4",children:u?e.jsx("button",{type:"button",onClick:s,className:"rounded-[var(--radius-control)] bg-[var(--color-fg-primary)] px-4 py-1.5 text-sm font-medium text-[var(--color-canvas)] hover:opacity-90",children:o("common.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:s,disabled:i.isPending,className:"rounded-[var(--radius-control)] border border-[var(--color-hairline-strong)] px-4 py-1.5 text-sm text-[var(--color-fg-secondary)] hover:bg-[var(--color-sunken)] disabled:opacity-50",children:o("common.cancel")}),e.jsx("button",{type:"button",onClick:()=>i.mutate(),disabled:!m,className:"rounded-[var(--radius-control)] bg-[var(--color-fg-primary)] px-4 py-1.5 text-sm font-medium text-[var(--color-canvas)] shadow-[var(--shadow-rise)] hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",children:i.isPending?o("export.btn.pending"):o("export.btn.confirm")})]})})]})})}function oo({eyebrow:t,title:r,actions:s,meta:o,editableValue:n,onTitleEdit:a}){return e.jsxs("header",{className:"relative",children:[t&&e.jsx("div",{className:"eyebrow mb-1",children:t}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-6 gap-y-2",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(so,{title:r,editableValue:n,onTitleEdit:a})}),s&&e.jsx("div",{className:"flex shrink-0 items-center gap-2",children:s})]}),o&&e.jsx("div",{className:"mt-2 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-xs",children:o})]})}const Ie="font-display text-[clamp(1.375rem,2.4vw,1.75rem)] font-light leading-[1.15] tracking-[-0.015em] text-[var(--color-fg-primary)]";function so({title:t,editableValue:r,onTitleEdit:s}){const[o,n]=d.useState(!1),[a,i]=d.useState(r??""),[l,c]=d.useState(!1),[u,m]=d.useState(null),h=d.useRef(null);if(d.useEffect(()=>{!o&&r!==void 0&&i(r)},[o,r]),d.useEffect(()=>{var x;o&&((x=h.current)==null||x.select())},[o]),!s)return e.jsx("h1",{className:Ie,children:t});function v(){i(r??""),m(null),n(!0)}async function g(){const x=a.trim();if(!s||!x||x===(r??"")){n(!1);return}c(!0),m(null);try{await s(x),n(!1)}catch(y){m(y.message)}finally{c(!1)}}return o?e.jsxs("div",{children:[e.jsx("input",{ref:h,value:a,disabled:l,onChange:x=>i(x.target.value),onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),g()):x.key==="Escape"&&(x.preventDefault(),n(!1),m(null))},onBlur:()=>{l||(n(!1),m(null))},maxLength:200,className:Ie+" w-full bg-transparent border-b border-[var(--color-accent)] outline-none focus:outline-none disabled:opacity-60"}),u&&e.jsx("p",{className:"mt-1 text-xs text-[var(--color-danger)]",children:u})]}):e.jsxs("div",{className:"group flex items-center gap-3",children:[e.jsx("h1",{className:Ie,children:t}),e.jsx("button",{type:"button",onClick:v,"aria-label":"Rename",title:"Rename",className:"flex-shrink-0 rounded-xl p-1.5 text-[var(--color-fg-muted)] opacity-0 transition hover:bg-[var(--color-sunken)] hover:text-[var(--color-fg-primary)] focus:opacity-100 group-hover:opacity-100",children:e.jsx(no,{})})]})}function no(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function ee({label:t,value:r}){return e.jsxs("span",{className:"inline-flex items-baseline gap-1.5",children:[e.jsx("span",{className:"eyebrow",children:t}),e.jsx("span",{className:"font-mono text-[13px] tabular-nums text-[var(--color-fg-primary)]",children:r})]})}function ie(){return e.jsx("span",{"aria-hidden":!0,className:"text-[var(--color-fg-faint)]",children:"·"})}const ze=5,ao=5e3,io=/^\s*\[Request interrupted by user/;function lo(t){return t.isWorking?"working":t.isLivePid?"live":t.isRecentlyActive?"recent":"idle"}function co({session:t,withLabel:r=!0}){const s=N(),o=lo(t),n=o==="working"?s("status.tooltip.working"):o==="live"?s("status.tooltip.live",{pid:t.livePid??"?"}):o==="recent"?s("status.tooltip.recent",{n:ze}):s("status.tooltip.idle"),a=o==="working"?s("status.working"):o==="live"?s("status.live",{pid:t.livePid??"?"}):s(o==="recent"?"status.recent":"status.idle"),i=o==="idle"?"text-[var(--color-fg-faint)]":o==="recent"?"text-[var(--color-fg-secondary)]":"text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]";return e.jsxs("span",{title:n,className:"inline-flex items-center gap-2 text-xs",children:[e.jsx(mo,{variant:o}),r&&e.jsx("span",{className:"font-mono uppercase tracking-[0.14em] "+i,children:a})]})}function mo({variant:t}){return t==="working"?e.jsxs("span",{"aria-hidden":!0,className:"loading-dots text-[var(--color-accent)]",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):t==="live"?e.jsxs("span",{"aria-hidden":!0,className:"relative inline-flex h-2.5 w-2.5",children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-[var(--color-accent)] pulse-amber"}),e.jsx("span",{className:"absolute inset-0 rounded-full bg-[var(--color-accent)]"})]}):t==="recent"?e.jsx("span",{"aria-hidden":!0,className:"inline-block h-2.5 w-2.5 rounded-full bg-[var(--color-accent)]"}):e.jsx("span",{"aria-hidden":!0,className:"inline-block h-2.5 w-2.5 rounded-full border border-[var(--color-hairline-strong)]"})}const He={hidden:{},show:{transition:{staggerChildren:.035,delayChildren:.04}}},qe={hidden:{opacity:0,y:8},show:{opacity:1,y:0,transition:{duration:.36,ease:[.16,1,.3,1]}}};function uo(){var oe;const t=N(),r=Le(),{projectId:s}=_t(),o=s??"",[n,a]=d.useState(new Set),[i,l]=d.useState(!1),[c,u]=d.useState(!1),[m,h]=d.useState(null),[v,g]=d.useState(null),[x,y]=d.useState(!1),T=Y({queryKey:R.projectSessions(o),queryFn:()=>B(`/api/projects/${encodeURIComponent(o)}/sessions`),enabled:!!o}),L=Y({queryKey:R.projects(),queryFn:()=>B("/api/projects")}),U=((oe=Y({queryKey:R.projectMemory(o),queryFn:()=>B(`/api/projects/${encodeURIComponent(o)}/memory`),enabled:!!o}).data)==null?void 0:oe.entries.length)??0,_=le({mutationFn:()=>B(`/api/projects/${encodeURIComponent(o)}/reveal`,{method:"POST"}),onError:p=>{window.alert(t("project.action.openFolderFailed",{msg:p.message}))}}),S=d.useMemo(()=>{var p;return(p=L.data)==null?void 0:p.find(k=>k.id===o)},[L.data,o]),M=T.data??[],G=d.useMemo(()=>M.filter(p=>n.has(p.id)),[M,n]),J=n.size>0?G:M,te=d.useMemo(()=>M.reduce((p,k)=>p+xt(k),0),[M]),K=d.useMemo(()=>M.filter(p=>p.isWorking).length,[M]),w=d.useMemo(()=>M.filter(p=>p.isLivePid&&!p.isWorking).length,[M]),E=d.useMemo(()=>M.filter(p=>p.isRecentlyActive&&!p.isLivePid).length,[M]);function W(p){const k=new Set(n);k.has(p)?k.delete(p):k.add(p),a(k)}function D(){n.size===M.length?a(new Set):a(new Set(M.map(p=>p.id)))}function z(){l(!0),g(null),y(!1)}function Q(){l(!1),a(new Set)}async function re(){var de;const p=G;if(p.length===0)return;const k={ok:[],skipped:[],failed:[]};g(null),y(!1);let P=0;for(const A of p){P++;const ne=A.customTitle??A.title;h({index:P,total:p.length});try{const H=await B("/api/sessions",{method:"DELETE",body:JSON.stringify({items:[{projectId:o,sessionId:A.id}]})});H.deleted.length>0?k.ok.push({sessionId:A.id,title:ne}):H.skipped.length>0?k.skipped.push({sessionId:A.id,title:ne,reason:((de=H.skipped[0])==null?void 0:de.reason)??"unknown"}):k.failed.push({sessionId:A.id,title:ne,error:"no-op"})}catch(H){k.failed.push({sessionId:A.id,title:ne,error:H instanceof Error?H.message:String(H)})}}h(null),g(k),y(k.skipped.length+k.failed.length>0),l(!1),a(new Set),r.invalidateQueries({queryKey:R.projects()}),r.invalidateQueries({queryKey:R.projectSessions(o)}),r.invalidateQueries({queryKey:R.diskUsage()})}const Z=(S==null?void 0:S.decodedCwd)??o,j=Z.split(/[\\/]+/).filter(Boolean),ce=j.at(-1)??Z,V=j.slice(0,-1).join("/");return e.jsxs("section",{children:[e.jsx($e,{items:[{label:t("session.crumbProjects"),to:"/"},{label:ce,mono:!0,icon:e.jsx(Oe,{})}]}),e.jsx("div",{className:"surface-card mt-6 p-6",children:e.jsx(oo,{eyebrow:e.jsxs("span",{className:"inline-flex items-center gap-2",children:[V?e.jsxs("span",{className:"font-mono normal-case tracking-normal",children:[V,"/"]}):t("project.eyebrow"),(S==null?void 0:S.cwdResolved)===!1&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-[var(--color-danger)]",children:[e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-[var(--color-danger)]"}),t("project.warn.missingDir")]})]}),title:e.jsx("span",{className:"font-mono",children:ce}),actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>_.mutate(),disabled:_.isPending||(S==null?void 0:S.cwdResolved)===!1,title:(S==null?void 0:S.cwdResolved)===!1?t("project.action.openFolderTooltipMissing"):Z,className:"inline-flex items-center gap-2 rounded-[var(--radius-control)] border border-[var(--color-hairline)] bg-[var(--color-surface)] px-4 py-1.5 text-xs font-medium uppercase tracking-[0.14em] text-[var(--color-fg-secondary)] transition hover:border-[var(--color-accent)] hover:text-[var(--color-accent-ink)] disabled:cursor-not-allowed disabled:opacity-40 dark:hover:text-[var(--color-accent)]",children:[e.jsx(jo,{}),t("project.action.openFolder")]}),e.jsxs(ve,{to:`/projects/${encodeURIComponent(o)}/memory`,className:"inline-flex items-center gap-2 rounded-[var(--radius-control)] border border-[var(--color-hairline)] bg-[var(--color-surface)] px-4 py-1.5 text-xs font-medium uppercase tracking-[0.14em] text-[var(--color-fg-secondary)] transition hover:border-[var(--color-accent)] hover:text-[var(--color-accent-ink)] dark:hover:text-[var(--color-accent)]",children:[e.jsx(yo,{}),U>0?t("memory.action.openCount",{n:U}):t("memory.action.open")]}),e.jsxs("button",{type:"button",onClick:()=>u(!0),disabled:M.length===0,title:n.size>0?`${n.size}`:void 0,className:"inline-flex items-center gap-2 rounded-[var(--radius-control)] border border-[var(--color-hairline)] bg-[var(--color-surface)] px-4 py-1.5 text-xs font-medium uppercase tracking-[0.14em] text-[var(--color-fg-secondary)] transition hover:border-[var(--color-accent)] hover:text-[var(--color-accent-ink)] disabled:cursor-not-allowed disabled:opacity-40 dark:hover:text-[var(--color-accent)]",children:[e.jsx(vo,{}),n.size>0?`${t("export.action")} · ${n.size}`:t("export.action")]}),e.jsxs("button",{type:"button",onClick:()=>i?Q():z(),disabled:M.length===0||m!==null,"aria-pressed":i,className:"inline-flex items-center gap-2 rounded-[var(--radius-control)] border px-4 py-1.5 text-xs font-medium uppercase tracking-[0.14em] transition disabled:cursor-not-allowed disabled:opacity-40 "+(i?"border-[var(--color-accent)] bg-[var(--color-accent-soft)] text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]":"border-[var(--color-hairline)] bg-[var(--color-surface)] text-[var(--color-fg-secondary)] hover:border-[var(--color-accent)] hover:text-[var(--color-accent-ink)] dark:hover:text-[var(--color-accent)]"),children:[e.jsx(ho,{}),t(i?"project.action.exitSelect":"project.action.select")]})]}),meta:M.length>0?e.jsxs(e.Fragment,{children:[e.jsx(ee,{label:t("project.meta.sessions"),value:M.length}),e.jsx(ie,{}),e.jsx(ee,{label:t("project.meta.onDisk"),value:F(te)}),K>0&&e.jsxs(e.Fragment,{children:[e.jsx(ie,{}),e.jsx(ee,{label:t("project.meta.working"),value:e.jsx("span",{className:"text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]",children:K})})]}),e.jsx(ie,{}),e.jsx(ee,{label:t("project.meta.live"),value:w>0?e.jsx("span",{className:"text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]",children:w}):0}),e.jsx(ie,{}),e.jsx(ee,{label:t("project.meta.recent"),value:E})]}):null})}),T.isLoading&&e.jsx(je,{label:t("common.readingSessions"),className:"mt-10"}),T.error&&e.jsxs("p",{className:"mt-10 rounded-md border border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] px-4 py-3 text-sm text-[var(--color-danger)]",children:[t("common.failedSessions"),": ",T.error.message]}),T.data&&T.data.length===0&&e.jsx("p",{className:"mt-10 text-sm text-[var(--color-fg-muted)]",children:t("common.noSessions")}),M.length>0&&e.jsxs("div",{className:"surface-card mt-6 p-6",children:[(i||m||v)&&e.jsx(fo,{selectMode:i,selectedCount:n.size,totalCount:M.length,progress:m,outcome:v,detailOpen:x,onToggleAll:D,onDelete:re,onCancel:Q,onToggleDetail:()=>y(p=>!p),onDismiss:()=>{g(null),y(!1)},t}),e.jsx("div",{className:"flex items-baseline justify-between",children:e.jsx("h2",{className:"font-display text-xl font-light tracking-tight text-[var(--color-fg-primary)]",children:t("project.heading")})}),e.jsx("div",{className:"rule-dotted mt-3","aria-hidden":!0}),e.jsx("div",{className:"mt-4 -mx-6 overflow-x-auto px-6",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left",children:[i&&e.jsx("th",{className:"w-9 px-2 py-3"}),e.jsx("th",{className:"px-2 py-3 eyebrow",children:t("project.col.title")}),e.jsx("th",{className:"px-2 py-3 eyebrow text-right",children:t("project.col.msgs")}),e.jsx("th",{className:"px-2 py-3 eyebrow text-right",children:t("project.col.errors")}),e.jsx("th",{className:"px-2 py-3 eyebrow text-right",children:t("project.col.last")}),e.jsx("th",{className:"px-2 py-3 eyebrow text-right",children:t("project.col.size")}),e.jsx("th",{className:"px-2 py-3 eyebrow",children:t("project.col.status")})]})}),e.jsx($.tbody,{initial:"hidden",animate:"show",variants:He,className:"border-t border-[var(--color-hairline)]",children:M.map(p=>{const k=n.has(p.id),P=p.customTitle??p.title;return e.jsxs($.tr,{variants:qe,"data-active":k&&i?"true":void 0,className:"ribbon-row border-b border-[var(--color-hairline)] transition-colors "+(k&&i?"bg-[var(--color-accent-soft)]/40":"hover:bg-[var(--color-sunken)]"),children:[i&&e.jsx("td",{className:"px-2 py-3 align-top",children:e.jsx("input",{type:"checkbox","aria-label":P,checked:k,onChange:()=>W(p.id),disabled:m!==null,className:"mt-0.5 h-3.5 w-3.5 cursor-pointer accent-[var(--color-accent)] disabled:cursor-not-allowed"})}),e.jsxs("td",{className:"px-2 py-3 align-top",children:[e.jsx(ve,{to:`/projects/${encodeURIComponent(o)}/sessions/${p.id}`,className:"block max-w-md truncate font-medium text-[var(--color-fg-primary)] hover:text-[var(--color-accent-ink)] dark:hover:text-[var(--color-accent)]",title:P,children:P}),e.jsx("div",{className:"mt-1 truncate font-mono text-[10.5px] tracking-[0.04em] text-[var(--color-fg-faint)]",children:p.id})]}),e.jsx("td",{className:"px-2 py-3 text-right align-top font-mono tabular-nums text-[var(--color-fg-secondary)]",children:p.messageCount.toLocaleString()}),e.jsx("td",{className:"px-2 py-3 text-right align-top font-mono tabular-nums",children:p.errorCount>0?e.jsx("span",{className:"text-[var(--color-danger)]",children:p.errorCount.toLocaleString()}):e.jsx("span",{className:"text-[var(--color-fg-faint)]",children:"0"})}),e.jsx("td",{className:"px-2 py-3 text-right align-top font-mono text-[12.5px] text-[var(--color-fg-secondary)]",children:pe(p.lastAt)}),e.jsx("td",{className:"px-2 py-3 text-right align-top font-mono tabular-nums text-[var(--color-fg-secondary)]",title:po(p),children:F(xt(p))}),e.jsx("td",{className:"px-2 py-3 align-top",children:e.jsx(co,{session:p})})]},p.id)})})]})})]}),c&&e.jsx(ro,{projectId:o,sessions:J,onClose:()=>u(!1)})]})}function xt(t){const r=t.relatedBytes;return r.jsonl+r.subdir+r.fileHistory+r.sessionEnv}function po(t){const r=t.relatedBytes;return[`jsonl ${F(r.jsonl)}`,`subdir ${F(r.subdir)}`,`file-history ${F(r.fileHistory)}`,`session-env ${F(r.sessionEnv)}`].join(" · ")}function xo(){return e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M8 6V4.5A1.5 1.5 0 0 1 9.5 3h5A1.5 1.5 0 0 1 16 4.5V6"}),e.jsx("path",{d:"M5.5 6l1.1 13.2A1.5 1.5 0 0 0 8.1 20.5h7.8a1.5 1.5 0 0 0 1.5-1.3L18.5 6"})]})}function ho(){return e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2.5"}),e.jsx("path",{d:"M8 12.2l3 3 5.5-6"})]})}function fo({selectMode:t,selectedCount:r,totalCount:s,progress:o,outcome:n,detailOpen:a,onToggleAll:i,onDelete:l,onCancel:c,onToggleDetail:u,onDismiss:m,t:h}){const v=r===s&&s>0,g=o!==null;return e.jsxs("div",{className:"sticky top-2 z-30 -mx-6 mb-4 px-6",children:[t&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-[var(--radius-input)] border border-[var(--color-hairline-strong)] bg-[var(--color-surface)] px-4 py-2.5 shadow-[var(--shadow-rise)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"font-mono text-[12px] font-medium uppercase tracking-[0.14em] text-[var(--color-fg-primary)]",children:g?h("project.bulk.deletePending",{i:o.index,total:o.total}):h("project.bulk.selectedCount",{n:r})}),e.jsx("button",{type:"button",onClick:i,disabled:g,className:"font-mono text-[11px] uppercase tracking-[0.16em] text-[var(--color-fg-muted)] hover:text-[var(--color-fg-primary)] disabled:cursor-not-allowed disabled:opacity-40",children:h(v?"common.deselectAll":"common.selectAll")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:c,disabled:g,className:"rounded-[var(--radius-control)] border border-[var(--color-hairline-strong)] px-3 py-1.5 text-xs font-medium uppercase tracking-[0.14em] text-[var(--color-fg-secondary)] hover:bg-[var(--color-sunken)] disabled:cursor-not-allowed disabled:opacity-40",children:h("common.cancel")}),e.jsxs("button",{type:"button",onClick:l,disabled:g||r===0,className:"inline-flex items-center gap-2 rounded-[var(--radius-control)] bg-[var(--color-danger)] px-3 py-1.5 text-xs font-medium uppercase tracking-[0.14em] text-white shadow-[var(--shadow-rise)] hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40",children:[e.jsx(xo,{}),h("project.bulk.deleteCta")]})]})]}),!t&&n&&e.jsx(go,{outcome:n,detailOpen:a,onToggleDetail:u,onDismiss:m,t:h})]})}function go({outcome:t,detailOpen:r,onToggleDetail:s,onDismiss:o,t:n}){const a=t.skipped.length+t.failed.length>0,i=a?"border-[var(--color-accent)]/40 bg-[var(--color-accent-soft)]":"border-[var(--color-moss)]/40 bg-[var(--color-moss-soft)]",l=a;return e.jsxs("div",{className:`rounded-[var(--radius-input)] border ${i} px-4 py-2.5`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-[var(--color-fg-primary)]",children:[e.jsx("span",{className:"font-medium",children:n("project.bulk.resultOk",{ok:t.ok.length})}),t.skipped.length>0&&e.jsxs("span",{className:"font-mono text-[12px] text-[var(--color-fg-secondary)]",children:["· ",n("project.bulk.resultSkipped",{n:t.skipped.length})]}),t.failed.length>0&&e.jsxs("span",{className:"font-mono text-[12px] text-[var(--color-danger)]",children:["· ",n("project.bulk.resultFailed",{n:t.failed.length})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[l&&e.jsx("button",{type:"button",onClick:s,className:"rounded-[var(--radius-control)] border border-[var(--color-hairline)] bg-[var(--color-surface)] px-3 py-1 text-[11px] font-medium uppercase tracking-[0.14em] text-[var(--color-fg-secondary)] hover:text-[var(--color-fg-primary)]",children:n(r?"project.bulk.hideDetail":"project.bulk.viewDetail")}),e.jsx("button",{type:"button",onClick:o,className:"rounded-[var(--radius-control)] border border-[var(--color-hairline)] bg-[var(--color-surface)] px-3 py-1 text-[11px] font-medium uppercase tracking-[0.14em] text-[var(--color-fg-muted)] hover:text-[var(--color-fg-primary)]",children:n("project.bulk.dismiss")})]})]}),r&&l&&e.jsxs("div",{className:"mt-3 space-y-2",children:[t.skipped.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"eyebrow text-[var(--color-fg-muted)]",children:n("project.bulk.detailSkipped")}),e.jsx("ul",{className:"mt-1 space-y-0.5 font-mono text-[11px] text-[var(--color-fg-secondary)]",children:t.skipped.map(c=>e.jsxs("li",{children:[e.jsx("span",{className:"text-[var(--color-fg-primary)]",children:c.title}),e.jsx("span",{className:"ml-2 text-[var(--color-fg-faint)]",children:c.sessionId}),e.jsxs("span",{className:"ml-2",children:["— ",c.reason]})]},c.sessionId))})]}),t.failed.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"eyebrow text-[var(--color-danger)]",children:n("project.bulk.detailFailed")}),e.jsx("ul",{className:"mt-1 space-y-0.5 font-mono text-[11px] text-[var(--color-fg-secondary)]",children:t.failed.map(c=>e.jsxs("li",{children:[e.jsx("span",{className:"text-[var(--color-fg-primary)]",children:c.title}),e.jsx("span",{className:"ml-2 text-[var(--color-fg-faint)]",children:c.sessionId}),e.jsxs("span",{className:"ml-2 text-[var(--color-danger)]",children:["— ",c.error]})]},c.sessionId))})]})]})]})}function vo(){return e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M12 3v12"}),e.jsx("path",{d:"M8 7l4-4 4 4"}),e.jsx("path",{d:"M4 15v3.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V15"})]})}function jo(){return e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M3 7.5A1.5 1.5 0 0 1 4.5 6h4.4a1.5 1.5 0 0 1 1.06.44l1.1 1.1a1.5 1.5 0 0 0 1.06.44H19.5A1.5 1.5 0 0 1 21 9.48"}),e.jsx("path",{d:"M3.2 9.5h17.6a1 1 0 0 1 .98 1.2l-1.5 7.5a1.5 1.5 0 0 1-1.47 1.2H5.2a1.5 1.5 0 0 1-1.47-1.2l-1.5-7.5A1 1 0 0 1 3.2 9.5z"})]})}function yo(){return e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M9 4.5a3 3 0 0 0-3 3v.4a3 3 0 0 0-1.5 5.2A3 3 0 0 0 6 18.5a3 3 0 0 0 6 0V4.5a3 3 0 0 0-3 0z"}),e.jsx("path",{d:"M15 4.5a3 3 0 0 1 3 3v.4a3 3 0 0 1 1.5 5.2A3 3 0 0 1 18 18.5a3 3 0 0 1-6 0"})]})}function bo({project:t,onClose:r}){const s=N(),o=Le(),n=Y({queryKey:R.projectSessions(t.id),queryFn:()=>B(`/api/projects/${encodeURIComponent(t.id)}/sessions`)}),i=(n.data??[]).filter(g=>g.isLivePid||g.isRecentlyActive),l=i.length>0,c=le({mutationFn:()=>B(`/api/projects/${encodeURIComponent(t.id)}`,{method:"DELETE"}),onSuccess:()=>{o.invalidateQueries({queryKey:R.projects()}),o.invalidateQueries({queryKey:R.projectSessions(t.id)}),o.invalidateQueries({queryKey:R.diskUsage()})}}),u=d.useRef(c.isPending);u.current=c.isPending,d.useEffect(()=>{function g(x){x.key==="Escape"&&!u.current&&r()}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[r]);const m=c.data,h=!!m,v=(m==null?void 0:m.deleted.reduce((g,x)=>g+x.freedBytes,0))??0;return e.jsx($.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:"fixed inset-0 z-[60] flex items-start justify-center bg-[oklch(0.16_0.006_85_/_0.55)] backdrop-blur-[2px] px-4 py-12",onClick:()=>!c.isPending&&r(),children:e.jsxs($.div,{initial:{y:8,opacity:0},animate:{y:0,opacity:1},transition:{duration:.24,ease:[.16,1,.3,1]},className:"w-full max-w-2xl overflow-hidden rounded-[var(--radius-panel)] border border-[var(--color-hairline)] bg-[var(--color-surface)] shadow-[var(--shadow-pop)]",onClick:g=>g.stopPropagation(),children:[e.jsxs("header",{className:"flex items-start justify-between gap-4 border-b border-[var(--color-hairline)] px-6 py-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"eyebrow text-[var(--color-danger)]",children:s(h?"deleteProject.eyebrow.result":"deleteProject.eyebrow.confirm")}),e.jsx("h2",{className:"mt-1 font-display text-2xl font-light tracking-tight text-[var(--color-fg-primary)]",children:s(h?"deleteProject.title.result":"deleteProject.title.confirm")}),e.jsx("p",{className:"mt-1.5 truncate font-mono text-[12px] text-[var(--color-fg-muted)]",title:t.decodedCwd,children:t.decodedCwd}),!h&&e.jsx("p",{className:"mt-2 text-sm text-[var(--color-fg-muted)]",children:s("deleteProject.summary",{n:t.sessionCount,free:F(t.totalBytes)})})]}),e.jsx("button",{type:"button",onClick:r,disabled:c.isPending,"aria-label":s("delete.close"),className:"rounded-xl p-1.5 text-[var(--color-fg-muted)] hover:bg-[var(--color-sunken)] hover:text-[var(--color-fg-primary)] disabled:opacity-50",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:e.jsx("path",{d:"M6 6l12 12M18 6L6 18"})})})]}),!h&&e.jsxs("div",{className:"space-y-3 px-6 py-4 text-sm",children:[e.jsx("p",{className:"rounded-md border border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] px-3 py-2.5 text-[var(--color-danger)]",children:s("deleteProject.warning",{cwd:t.decodedCwd})}),l&&e.jsxs("div",{className:"rounded-md border border-[var(--color-accent)]/40 bg-[var(--color-accent-soft)] px-3 py-2.5 text-xs",children:[e.jsx("div",{className:"mb-1.5 font-medium text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]",children:s("deleteProject.blocked.heading",{n:i.length})}),e.jsx("ul",{className:"space-y-0.5",children:i.map(g=>e.jsxs("li",{className:"font-mono text-[11px] text-[var(--color-accent-ink)] dark:text-[var(--color-fg-secondary)]",children:[g.id," — ",g.isLivePid?`live PID ${g.livePid??"?"}`:"recent"]},g.id))})]})]}),h&&m&&e.jsxs("div",{className:"max-h-[50vh] space-y-3 overflow-auto px-6 py-4 text-sm",children:[m.projectDirRemoved?e.jsx("div",{className:"rounded-md border border-[var(--color-moss)]/40 bg-[var(--color-moss-soft)] px-3 py-2.5 text-[var(--color-fg-primary)]",children:s("deleteProject.success",{n:m.deleted.length,free:F(v),lines:m.historyLinesRemoved})}):m.deleted.length>0?e.jsx("div",{className:"rounded-md border border-[var(--color-accent)]/40 bg-[var(--color-accent-soft)] px-3 py-2.5 text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]",children:s("deleteProject.successKept",{n:m.deleted.length,free:F(v),lines:m.historyLinesRemoved})}):null,m.skipped.length>0&&e.jsxs("div",{className:"rounded-md border border-[var(--color-accent)]/40 bg-[var(--color-accent-soft)] px-3 py-2.5 text-xs",children:[e.jsx("div",{className:"mb-1 font-medium text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]",children:s("deleteProject.blocked.heading",{n:m.skipped.length})}),e.jsx("ul",{className:"space-y-0.5",children:m.skipped.map(g=>e.jsxs("li",{className:"font-mono text-[11px] text-[var(--color-accent-ink)] dark:text-[var(--color-fg-secondary)]",children:[g.sessionId||"(project)"," — ",g.reason]},`${g.sessionId}-${g.reason}`))})]})]}),c.error&&e.jsx("p",{className:"mx-6 mb-3 rounded-md border border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] px-3 py-2 text-sm text-[var(--color-danger)]",children:c.error.message}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-[var(--color-hairline)] px-6 py-4",children:h?e.jsx("button",{type:"button",onClick:r,className:"rounded-[var(--radius-control)] bg-[var(--color-fg-primary)] px-4 py-1.5 text-sm font-medium text-[var(--color-canvas)] hover:opacity-90",children:s("common.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:r,disabled:c.isPending,className:"rounded-[var(--radius-control)] border border-[var(--color-hairline-strong)] px-4 py-1.5 text-sm text-[var(--color-fg-secondary)] hover:bg-[var(--color-sunken)] disabled:opacity-50",children:s("common.cancel")}),e.jsx("button",{type:"button",onClick:()=>c.mutate(),disabled:c.isPending||n.isLoading||l,className:"rounded-[var(--radius-control)] bg-[var(--color-danger)] px-4 py-1.5 text-sm font-medium text-white shadow-[var(--shadow-rise)] hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",children:c.isPending?s("deleteProject.btn.confirmPending"):s("deleteProject.btn.confirm")})]})})]})})}function ko(){const t=N(),[r,s]=d.useState(null),o=Y({queryKey:R.health(),queryFn:()=>B("/api/health")}),n=Y({queryKey:R.projects(),queryFn:()=>B("/api/projects")}),a=n.data??[],i=a.reduce((u,m)=>u+m.totalBytes,0),l=a.reduce((u,m)=>u+m.sessionCount,0),c=a.map(u=>u.lastActiveAt).filter(u=>!!u).sort().at(-1)??null;return e.jsxs("section",{children:[e.jsx("div",{className:"surface-card p-6",children:e.jsx(wo,{title:t("projects.title"),tagline:t("projects.tagline"),stats:a.length>0?{totalBytes:i,totalSessions:l,projectCount:a.length,lastActive:c}:null})}),o.data&&!o.data.claudeRootExists&&e.jsx(ht,{tone:"warn",className:"mt-6",children:t("projects.warn.rootMissing",{root:o.data.claudeRoot})}),n.isLoading&&e.jsx(je,{label:t("common.scanning"),className:"mt-10"}),n.error&&e.jsxs(ht,{tone:"danger",className:"mt-6",children:[t("common.failedProjects"),": ",n.error.message]}),n.data&&n.data.length===0&&e.jsx("p",{className:"mt-10 text-sm text-[var(--color-fg-muted)]",children:t("common.noProjects")}),a.length>0&&e.jsxs("div",{className:"surface-card mt-6 p-6",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("h2",{className:"font-display text-xl font-light tracking-tight text-[var(--color-fg-primary)]",children:t("projects.indexHeading")}),e.jsxs("span",{className:"font-mono text-[11px] uppercase tracking-[0.16em] tabular-nums text-[var(--color-fg-muted)]",children:[String(a.length).padStart(2,"0")," ",a.length===1?t("common.entry"):t("common.entries")]})]}),e.jsx("div",{className:"rule-dotted mt-3","aria-hidden":!0}),e.jsx(No,{projects:a,onRequestDelete:u=>s(u)})]}),r&&e.jsx(bo,{project:r,onClose:()=>s(null)})]})}function wo({title:t,tagline:r,stats:s}){const o=N();return e.jsxs("header",{className:"relative",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1",children:[e.jsxs("h1",{className:"font-display text-[clamp(1.75rem,3.5vw,2.25rem)] font-light leading-[1.1] tracking-[-0.02em] text-[var(--color-fg-primary)]",children:[t,e.jsx("span",{className:"text-[var(--color-accent)]",children:"."})]}),e.jsx("p",{className:"min-w-0 flex-1 font-display text-[13px] italic leading-snug text-[var(--color-fg-muted)]",children:r})]}),s&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-xs",children:[e.jsx(ee,{label:o("projects.stat.onDisk"),value:F(s.totalBytes)}),e.jsx(ie,{}),e.jsx(ee,{label:o("projects.stat.projects"),value:s.projectCount}),e.jsx(ie,{}),e.jsx(ee,{label:o("projects.stat.sessions"),value:s.totalSessions.toLocaleString()}),e.jsx(ie,{}),e.jsx(ee,{label:o("projects.card.lastSeen"),value:pe(s.lastActive)})]})]})}function No({projects:t,onRequestDelete:r}){const s=N();return e.jsxs($.ol,{initial:"hidden",animate:"show",variants:He,className:"mt-4",children:[e.jsxs("li",{"aria-hidden":!0,className:"grid grid-cols-[2.5rem_minmax(0,1fr)_5rem_5.5rem_5rem_3.5rem] items-center gap-x-4 border-b border-[var(--color-hairline)] py-3 sm:grid-cols-[3rem_minmax(0,1fr)_6rem_6rem_6rem_4rem]",children:[e.jsx("span",{className:"eyebrow text-right",children:"№"}),e.jsx("span",{className:"eyebrow",children:s("projects.card.eyebrow")}),e.jsx("span",{className:"eyebrow text-right",children:s("projects.card.sessions")}),e.jsx("span",{className:"eyebrow text-right",children:s("projects.card.onDisk")}),e.jsx("span",{className:"eyebrow text-right",children:s("projects.card.lastSeen")}),e.jsx("span",{className:"eyebrow"})]}),t.map((o,n)=>e.jsx($.li,{variants:qe,children:e.jsx(So,{project:o,index:n,onRequestDelete:r})},o.id))]})}function So({project:t,index:r,onRequestDelete:s}){const o=N(),n=t.decodedCwd,a=n.split(/[\\/]+/).filter(Boolean),i=a.slice(-2).join("/"),l=a.slice(0,-2).join("/");return e.jsxs("div",{className:"ribbon-row group relative grid grid-cols-[2.5rem_minmax(0,1fr)_5rem_5.5rem_5rem_3.5rem] items-center gap-x-4 border-b border-[var(--color-hairline)] py-3 pl-3 transition-colors hover:bg-[var(--color-sunken)] sm:grid-cols-[3rem_minmax(0,1fr)_6rem_6rem_6rem_4rem]",children:[e.jsx(ve,{to:`/projects/${encodeURIComponent(t.id)}`,"aria-label":n,className:"absolute inset-0 z-[1] rounded-[inherit] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[var(--color-accent)]",children:e.jsx("span",{className:"sr-only",children:n})}),e.jsx("span",{className:"pointer-events-none text-right font-mono text-[11px] uppercase tracking-[0.16em] tabular-nums text-[var(--color-fg-faint)] group-hover:text-[var(--color-accent)]",children:String(r+1).padStart(2,"0")}),e.jsx("div",{className:"pointer-events-none min-w-0",children:e.jsxs("div",{className:"flex items-baseline gap-2 truncate font-mono text-[13px] text-[var(--color-fg-primary)]",title:n,children:[l&&e.jsxs("span",{className:"text-[var(--color-fg-faint)]",children:[l,"/"]}),e.jsx("span",{className:"font-medium",children:i}),!t.cwdResolved&&e.jsx("span",{className:"ml-1 shrink-0 rounded-full border border-[var(--color-hairline-strong)] px-1.5 py-px font-mono text-[9px] uppercase tracking-[0.16em] text-[var(--color-fg-muted)]",children:o("common.missing")})]})}),e.jsx("span",{className:"pointer-events-none text-right font-mono text-sm tabular-nums text-[var(--color-fg-primary)]",children:t.sessionCount.toLocaleString()}),e.jsx("span",{className:"pointer-events-none text-right font-mono text-sm tabular-nums text-[var(--color-fg-secondary)]",children:F(t.totalBytes)}),e.jsx("span",{className:"pointer-events-none text-right font-mono text-[12.5px] tabular-nums text-[var(--color-fg-secondary)]",children:pe(t.lastActiveAt)}),e.jsxs("div",{className:"relative z-[2] flex items-center justify-end gap-1 pr-1",children:[e.jsx("button",{type:"button",onClick:c=>{c.preventDefault(),c.stopPropagation(),s(t)},"aria-label":o("deleteProject.row.action"),title:o("deleteProject.row.action"),className:"rounded-md border border-transparent p-1.5 text-[var(--color-fg-faint)] transition-colors hover:border-[var(--color-danger)]/40 hover:bg-[var(--color-danger-soft)] hover:text-[var(--color-danger)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-danger)]",children:e.jsx(Co,{})}),e.jsx("span",{"aria-hidden":!0,className:"pointer-events-none text-[var(--color-fg-faint)] transition-transform duration-200 group-hover:translate-x-0.5 group-hover:text-[var(--color-accent)]",children:e.jsx(Lo,{})})]})]})}function Co(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M8 6V4.5A1.5 1.5 0 0 1 9.5 3h5A1.5 1.5 0 0 1 16 4.5V6"}),e.jsx("path",{d:"M5.5 6l1.1 13.2A1.5 1.5 0 0 0 8.1 20.5h7.8a1.5 1.5 0 0 0 1.5-1.3L18.5 6"})]})}function Lo(){return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"M9 6l6 6-6 6"})})}function ht({tone:t,className:r="",children:s}){const o=t==="warn"?"border-[var(--color-accent)]/40 bg-[var(--color-accent-soft)] text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]":"border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] text-[var(--color-danger)]";return e.jsx("div",{className:`rounded-[10px] border px-4 py-3 text-sm ${o} ${r}`,children:s})}function Eo({projectId:t,selected:r,onClose:s,onDeleted:o}){const n=N(),{locale:a}=We(),i=Le(),l=r.filter(x=>x.isLivePid||x.isRecentlyActive),c=r.filter(x=>!x.isLivePid&&!x.isRecentlyActive),u=c.reduce((x,y)=>x+y.relatedBytes.jsonl+y.relatedBytes.subdir+y.relatedBytes.fileHistory+y.relatedBytes.sessionEnv,0),m=le({mutationFn:x=>B("/api/sessions",{method:"DELETE",body:JSON.stringify({items:x})}),onSuccess:x=>{if(x.deleted.length>0){const y=new Set(x.deleted.map(T=>T.sessionId));i.setQueryData(R.projectSessions(t),T=>T==null?void 0:T.filter(L=>!y.has(L.id)))}i.invalidateQueries({queryKey:R.projects()}),i.invalidateQueries({queryKey:R.projectSessions(t)}),i.invalidateQueries({queryKey:R.diskUsage()}),x.deleted.length>0&&(o==null||o(x.deleted.map(y=>y.sessionId)))}}),h=d.useRef(m.isPending);h.current=m.isPending,d.useEffect(()=>{function x(y){y.key==="Escape"&&!h.current&&s()}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[s]);const v=m.data,g=!!v;return e.jsx($.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},className:"fixed inset-0 z-[60] flex items-start justify-center bg-[oklch(0.16_0.006_85_/_0.55)] backdrop-blur-[2px] px-4 py-12",onClick:()=>!m.isPending&&s(),children:e.jsxs($.div,{initial:{y:8,opacity:0},animate:{y:0,opacity:1},transition:{duration:.24,ease:[.16,1,.3,1]},className:"w-full max-w-2xl overflow-hidden rounded-[var(--radius-panel)] border border-[var(--color-hairline)] bg-[var(--color-surface)] shadow-[var(--shadow-pop)]",onClick:x=>x.stopPropagation(),children:[e.jsxs("header",{className:"flex items-start justify-between gap-4 border-b border-[var(--color-hairline)] px-6 py-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow text-[var(--color-danger)]",children:n(g?"delete.eyebrow.result":"delete.eyebrow.confirm")}),e.jsx("h2",{className:"mt-1 font-display text-2xl font-light tracking-tight text-[var(--color-fg-primary)]",children:n(g?"delete.title.result":"delete.title.confirm")}),!g&&e.jsx("p",{className:"mt-1.5 text-sm text-[var(--color-fg-muted)]",children:n("delete.summary",{n:c.length,skipped:l.length,free:F(u)})})]}),e.jsx("button",{type:"button",onClick:s,disabled:m.isPending,"aria-label":n("delete.close"),className:"rounded-xl p-1.5 text-[var(--color-fg-muted)] hover:bg-[var(--color-sunken)] hover:text-[var(--color-fg-primary)] disabled:opacity-50",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:e.jsx("path",{d:"M6 6l12 12M18 6L6 18"})})})]}),!g&&e.jsxs("div",{className:"max-h-[50vh] space-y-2 overflow-auto px-6 py-4",children:[c.map(x=>e.jsxs("div",{className:"rounded-md border border-[var(--color-hairline)] bg-[var(--color-canvas)] px-3 py-2 text-xs",children:[e.jsx("div",{className:"font-medium text-[var(--color-fg-primary)]",children:x.title}),e.jsx("div",{className:"mt-0.5 truncate font-mono text-[10.5px] text-[var(--color-fg-faint)]",children:x.id}),e.jsxs("div",{className:"mt-1.5 grid grid-cols-2 gap-x-3 gap-y-0.5 font-mono text-[11px] text-[var(--color-fg-muted)] sm:grid-cols-4",children:[e.jsxs("span",{children:["jsonl ",e.jsx("span",{className:"text-[var(--color-fg-secondary)]",children:F(x.relatedBytes.jsonl)})]}),e.jsxs("span",{children:["subdir ",e.jsx("span",{className:"text-[var(--color-fg-secondary)]",children:F(x.relatedBytes.subdir)})]}),e.jsxs("span",{children:["file-history ",e.jsx("span",{className:"text-[var(--color-fg-secondary)]",children:F(x.relatedBytes.fileHistory)})]}),e.jsxs("span",{children:["session-env ",e.jsx("span",{className:"text-[var(--color-fg-secondary)]",children:F(x.relatedBytes.sessionEnv)})]})]})]},x.id)),l.length>0&&e.jsxs("div",{className:"rounded-md border border-[var(--color-accent)]/40 bg-[var(--color-accent-soft)] px-3 py-2.5 text-xs",children:[e.jsx("div",{className:"mb-1.5 font-medium text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]",children:n("delete.skipped.heading",{n:l.length})}),e.jsx("ul",{className:"space-y-0.5",children:l.map(x=>e.jsxs("li",{className:"font-mono text-[11px] text-[var(--color-accent-ink)] dark:text-[var(--color-fg-secondary)]",children:[x.id," — ",Mo(x,a)]},x.id))})]})]}),g&&v&&e.jsxs("div",{className:"max-h-[50vh] space-y-3 overflow-auto px-6 py-4 text-sm",children:[e.jsx("div",{className:"rounded-md border border-[var(--color-moss)]/40 bg-[var(--color-moss-soft)] px-3 py-2.5 text-[var(--color-fg-primary)]",children:n("delete.success",{n:v.deleted.length,free:F(v.deleted.reduce((x,y)=>x+y.freedBytes,0)),lines:v.historyLinesRemoved})}),v.skipped.length>0&&e.jsxs("div",{className:"rounded-md border border-[var(--color-accent)]/40 bg-[var(--color-accent-soft)] px-3 py-2.5 text-xs",children:[e.jsx("div",{className:"mb-1 font-medium text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]",children:n("delete.skipped.heading",{n:v.skipped.length})}),e.jsx("ul",{className:"space-y-0.5",children:v.skipped.map(x=>e.jsxs("li",{className:"font-mono text-[11px] text-[var(--color-accent-ink)] dark:text-[var(--color-fg-secondary)]",children:[x.sessionId," — ",x.reason]},x.sessionId))})]})]}),m.error&&e.jsx("p",{className:"mx-6 mb-3 rounded-md border border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] px-3 py-2 text-sm text-[var(--color-danger)]",children:m.error.message}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-[var(--color-hairline)] px-6 py-4",children:g?e.jsx("button",{type:"button",onClick:s,className:"rounded-[var(--radius-control)] bg-[var(--color-fg-primary)] px-4 py-1.5 text-sm font-medium text-[var(--color-canvas)] hover:opacity-90",children:n("common.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:s,disabled:m.isPending,className:"rounded-[var(--radius-control)] border border-[var(--color-hairline-strong)] px-4 py-1.5 text-sm text-[var(--color-fg-secondary)] hover:bg-[var(--color-sunken)] disabled:opacity-50",children:n("common.cancel")}),e.jsx("button",{type:"button",onClick:()=>m.mutate(r.map(x=>({projectId:t,sessionId:x.id}))),disabled:m.isPending||c.length===0,className:"rounded-[var(--radius-control)] bg-[var(--color-danger)] px-4 py-1.5 text-sm font-medium text-white shadow-[var(--shadow-rise)] hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",children:m.isPending?n("delete.btn.confirmPending"):n("delete.btn.confirm",{n:c.length,label:c.length===1?n("delete.label.session"):n("delete.label.sessions")})})]})})]})})}function Mo(t,r){return t.isLivePid?Ne(r,"delete.skipped.reasonLive",{pid:t.livePid??"?"}):t.isRecentlyActive?Ne(r,"delete.skipped.reasonRecent",{n:ze}):Ne(r,"delete.skipped.reasonUnknown")}function Po(t,r){if(!r)return[{text:t,match:!1}];const s=t.toLowerCase(),o=r.toLowerCase(),n=[];let a=0;for(;a<t.length;){const i=s.indexOf(o,a);if(i===-1){n.push({text:t.slice(a),match:!1});break}i>a&&n.push({text:t.slice(a,i),match:!1}),n.push({text:t.slice(i,i+r.length),match:!0}),a=i+r.length}return n}function xe({text:t,query:r,className:s}){const o=Po(t,r);return e.jsx("span",{className:s,children:o.map((n,a)=>n.match?e.jsx("mark",{className:"rounded-sm bg-[var(--color-accent-soft)] px-0.5 text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]",children:n.text},a):e.jsx("span",{children:n.text},a))})}function To(t){const r=[];let s=0;for(const o of t){const n=o.newStart-s-1;n>0&&r.push({oldNo:null,newNo:null,kind:"gap",text:null,gap:n,segs:null});let a=o.oldStart,i=o.newStart;const l=o.lines;let c=0;for(;c<l.length;){const u=l[c][0];if(u==="-"||u==="+"){const m=[],h=[],v=a,g=i;for(;c<l.length&&l[c][0]==="-";)m.push(l[c].slice(1)),a++,c++;for(;c<l.length&&l[c][0]==="+";)h.push(l[c].slice(1)),i++,c++;for(let x=0;x<m.length;x++){const y=x<h.length?Ce(m[x],h[x]):null;r.push({oldNo:v+x,newNo:null,kind:"del",text:m[x],segs:(y==null?void 0:y.left)??null})}for(let x=0;x<h.length;x++){const y=x<m.length?Ce(m[x],h[x]):null;r.push({oldNo:null,newNo:g+x,kind:"add",text:h[x],segs:(y==null?void 0:y.right)??null})}}else r.push({oldNo:a,newNo:i,kind:"context",text:l[c].slice(1),segs:null}),a++,i++,c++}s=i-1}return r}function se(t,r){const s=Wt(t===""?[]:t.split(`
7
+ `),r===""?[]:r.split(`
8
+ `)),o=[];let n=0,a=0,i=0;for(;i<s.length;){const l=s[i];if(l.type==="equal"){n++,a++,o.push({oldNo:n,newNo:a,kind:"context",text:l.text,segs:null}),i++;continue}const c=[],u=[];for(;i<s.length&&s[i].type!=="equal";){const m=s[i];m.type==="del"?c.push(m.text):u.push(m.text),i++}for(let m=0;m<c.length;m++){const h=m<u.length?Ce(c[m],u[m]):null;n++,o.push({oldNo:n,newNo:null,kind:"del",text:c[m],segs:(h==null?void 0:h.left)??null})}for(let m=0;m<u.length;m++){const h=m<c.length?Ce(c[m],u[m]):null;a++,o.push({oldNo:null,newNo:a,kind:"add",text:u[m],segs:(h==null?void 0:h.right)??null})}}return o}const ft=/\s+|\w+|[^\w\s]+/g;function Ce(t,r){const s=t.match(ft)??[],o=r.match(ft)??[];if(s.length===0||o.length===0||s.length*o.length>2e4)return null;const n=Wt(s,o),a=[],i=[];for(const l of n)l.type==="equal"?(be(a,l.text,!1),be(i,l.text,!1)):l.type==="del"?be(a,l.text,!0):be(i,l.text,!0);return a.every(l=>l.changed)&&i.every(l=>l.changed)?null:{left:a,right:i}}function be(t,r,s){const o=t[t.length-1];o&&o.changed===s?o.text+=r:t.push({text:r,changed:s})}const Ro=1e6;function Wt(t,r){const s=t.length,o=r.length;if(s*o>Ro)return[...t.map(c=>({type:"del",text:c})),...r.map(c=>({type:"add",text:c}))];const n=[];for(let c=0;c<=s;c++)n.push(new Array(o+1).fill(0));for(let c=s-1;c>=0;c--){const u=n[c],m=n[c+1];for(let h=o-1;h>=0;h--)u[h]=t[c]===r[h]?m[h+1]+1:Math.max(m[h],u[h+1])}const a=[];let i=0,l=0;for(;i<s&&l<o;)t[i]===r[l]?(a.push({type:"equal",text:t[i]}),i++,l++):n[i+1][l]>=n[i][l+1]?(a.push({type:"del",text:t[i]}),i++):(a.push({type:"add",text:r[l]}),l++);for(;i<s;)a.push({type:"del",text:t[i++]});for(;l<o;)a.push({type:"add",text:r[l++]});return a}const gt=280,vt=160;function Io({block:t,query:r}){const[s,o]=d.useState(!1),n=Ke(t.input),a=_o(t.name,n),i=r.length>0;return e.jsxs("div",{className:"overflow-hidden rounded-xl border border-[var(--color-hairline)] bg-[var(--color-sunken)] text-sm",children:[e.jsxs("button",{type:"button",onClick:()=>o(!s),className:"flex w-full items-center gap-2 px-3 py-2 text-left transition hover:bg-[var(--color-canvas)]",children:[e.jsxs("span",{className:"flex shrink-0 items-center gap-2 font-mono text-[11.5px] font-medium uppercase tracking-[0.06em] text-[var(--color-fg-secondary)]",children:[e.jsx(Qe,{kind:"tool"})," ",t.name]}),a&&e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-[var(--color-fg-muted)]",children:e.jsx(xe,{text:a,query:r})}),e.jsx("span",{className:"ml-auto shrink-0",children:e.jsx(qt,{open:s})})]}),s&&e.jsx("div",{className:"border-t border-[var(--color-hairline)] bg-[var(--color-surface)]",children:i?e.jsx(Ht,{input:n,query:r}):e.jsx(Do,{name:t.name,input:n})})]})}function Do({name:t,input:r}){const s=N(),o=d.useMemo(()=>Ao(t,r),[t,r]);switch(o.kind){case"diff":return e.jsxs(e.Fragment,{children:[e.jsx(jt,{path:o.filePath,children:o.replaceAll&&e.jsx("span",{className:"rounded-sm border border-[var(--color-hairline-strong)] px-1 py-px font-mono text-[9px] uppercase tracking-[0.1em] text-[var(--color-fg-muted)]",children:s("tool.replaceAll")})}),e.jsx(yt,{rows:o.rows})]});case"multidiff":return e.jsxs(e.Fragment,{children:[e.jsx(jt,{path:o.filePath}),o.sections.map((n,a)=>e.jsxs("div",{children:[a>0&&e.jsx("div",{className:"rule-dotted mx-3 my-1","aria-hidden":!0}),e.jsx(yt,{rows:n})]},a))]});case"bash":return e.jsx(Fo,{command:o.command,description:o.description});case"todo":return e.jsx(Bo,{todos:o.todos});default:return e.jsx(Ht,{input:r})}}function Ao(t,r){switch(t){case"Edit":return{kind:"diff",filePath:I(r.file_path),rows:se(I(r.old_string),I(r.new_string)),replaceAll:r.replace_all===!0};case"Write":return{kind:"diff",filePath:I(r.file_path),rows:se("",I(r.content)),replaceAll:!1};case"NotebookEdit":return{kind:"diff",filePath:I(r.notebook_path),rows:se("",I(r.new_source)),replaceAll:!1};case"MultiEdit":{const s=Array.isArray(r.edits)?r.edits:[];return{kind:"multidiff",filePath:I(r.file_path),sections:s.map(o=>{const n=Ke(o);return se(I(n.old_string),I(n.new_string))})}}case"Bash":return{kind:"bash",command:I(r.command),description:I(r.description)};case"TodoWrite":{const s=zt(r);return s.length>0?{kind:"todo",todos:s}:{kind:"json"}}default:return{kind:"json"}}}function _o(t,r){switch(t){case"Bash":return bt(I(r.description)||I(r.command));case"Edit":case"Write":case"MultiEdit":case"Read":return kt(I(r.file_path));case"NotebookEdit":return kt(I(r.notebook_path));case"Glob":case"Grep":return I(r.pattern)||null;case"Task":case"Agent":return I(r.description)||null;case"WebFetch":return I(r.url)||null;case"WebSearch":return I(r.query)||null;case"Skill":return I(r.skill)||null;case"TodoWrite":{const s=zt(r);if(s.length===0)return null;const o=s.filter(i=>i.status==="completed").length,n=s.find(i=>i.status==="in_progress"),a=n?n.activeForm||n.content:"";return`${o}/${s.length}${a?` · ${a}`:""}`}default:{for(const s of Object.values(r))if(typeof s=="string"&&s.trim())return bt(s);return null}}}function zt(t){return Array.isArray(t.todos)?t.todos.map(r=>{const s=Ke(r);return{content:I(s.content),status:I(s.status),activeForm:I(s.activeForm)}}):[]}function Bo({todos:t}){return e.jsx("ul",{className:"space-y-1 px-3 py-2",children:t.map((r,s)=>{const o=r.status==="completed",n=r.status==="in_progress",a=n&&r.activeForm?r.activeForm:r.content;return e.jsxs("li",{className:"flex items-start gap-2 text-[13px] leading-snug",children:[e.jsx("span",{"aria-hidden":!0,className:"mt-px w-3.5 shrink-0 text-center font-mono text-[12px] "+(o?"text-[var(--color-moss)]":n?"text-[var(--color-accent)]":"text-[var(--color-fg-faint)]"),children:o?"✓":n?"●":"○"}),e.jsx("span",{className:o?"text-[var(--color-fg-muted)] line-through decoration-[var(--color-hairline-strong)]":n?"font-medium text-[var(--color-fg-primary)]":"text-[var(--color-fg-secondary)]",children:a})]},s)})})}function Fo({command:t,description:r}){return e.jsxs("div",{className:"px-3 py-2",children:[r&&e.jsx("p",{className:"mb-1.5 text-[12.5px] text-[var(--color-fg-muted)]",children:r}),e.jsxs("div",{className:"group/cmd relative rounded-[var(--radius-control)] border border-[var(--color-hairline)] bg-[var(--color-sunken)]",children:[e.jsx("span",{className:"absolute right-1 top-1 opacity-0 transition group-hover/cmd:opacity-100",children:e.jsx(Wo,{text:t})}),e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-[11.5px] leading-[1.6] text-[var(--color-fg-primary)]",children:t})]})]})}function Ht({input:t,query:r}){const s=JSON.stringify(t,null,2);return e.jsx("pre",{className:"overflow-x-auto px-3 py-2 font-mono text-[11.5px] text-[var(--color-fg-primary)]",children:r?e.jsx(xe,{text:s,query:r}):s})}function jt({path:t,children:r}){return t?e.jsxs("div",{className:"flex items-center gap-1.5 px-3 pb-1 pt-2",children:[e.jsx("span",{className:"min-w-0 break-all font-mono text-[10.5px] text-[var(--color-fg-faint)]",children:t}),r]}):null}function yt({rows:t}){const r=N();if(t.length===0)return null;const s=t.length>vt?t.slice(0,vt):t,o=t.length-s.length;return e.jsxs("div",{className:"overflow-x-auto pb-1.5",children:[e.jsx("div",{className:"w-max min-w-full font-mono text-[11.5px] leading-[1.65]",children:s.map((n,a)=>e.jsx($o,{row:n},a))}),o>0&&e.jsx("p",{className:"px-3 pt-1 font-mono text-[10px] italic text-[var(--color-fg-faint)]",children:r("tool.moreLines",{n:o})})]})}function $o({row:t}){if(t.kind==="gap")return null;const r=t.kind==="del"?"bg-[var(--color-danger-soft)]":t.kind==="add"?"bg-[var(--color-moss-soft)]":"",s=t.kind==="del"?"−":t.kind==="add"?"+":"",o=t.kind==="del"?"text-[var(--color-danger)]":t.kind==="add"?"text-[var(--color-moss)]":"text-transparent",n=t.kind==="del"?"bg-[var(--color-danger)]/25":"bg-[var(--color-moss)]/30";return e.jsxs("div",{className:`flex ${r}`,children:[e.jsx("span",{className:`w-5 shrink-0 select-none text-center ${o}`,children:s}),e.jsx("span",{className:"whitespace-pre pr-3 text-[var(--color-fg-primary)]",children:t.segs&&t.segs.length>0?t.segs.map((a,i)=>a.changed?e.jsx("span",{className:n,children:a.text},i):e.jsx("span",{children:a.text},i)):t.text===null||t.text===""?" ":t.text})]})}function Oo({block:t,query:r,toolName:s}){const o=N(),[n,a]=d.useState(!1),i=t.content.length>gt,l=n||!i?t.content:t.content.slice(0,gt)+"…",c=t.isError?"border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] text-[var(--color-danger)]":"border-[var(--color-hairline)] bg-[var(--color-sunken)] text-[var(--color-fg-primary)]";return e.jsxs("div",{className:`overflow-hidden rounded-xl border text-sm ${c}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2",children:[e.jsxs("span",{className:"flex items-center gap-2 font-mono text-[11.5px] font-medium uppercase tracking-[0.06em]",children:[e.jsx(Qe,{kind:t.isError?"error":"result"}),t.isError?o("tool.error"):o("tool.result"),s&&e.jsxs("span",{className:t.isError?"opacity-70":"text-[var(--color-fg-muted)]",children:["· ",s]})]}),i&&e.jsx("button",{type:"button",onClick:()=>a(!n),className:"font-mono text-[10.5px] uppercase tracking-[0.16em] underline-offset-2 hover:underline",children:o(n?"common.collapse":"common.expand")})]}),e.jsx("pre",{className:`overflow-x-auto whitespace-pre-wrap break-words border-t px-3 py-2 font-mono text-[11.5px] ${t.isError?"border-[var(--color-danger)]/30":"border-[var(--color-hairline)] bg-[var(--color-surface)]"}`,children:e.jsx(xe,{text:l,query:r})})]})}function Uo({block:t,query:r}){const s=N(),[o,n]=d.useState(!1),a=t.text.trim()!=="";return e.jsxs("div",{className:"overflow-hidden rounded-xl border border-[var(--color-hairline-strong)] bg-[var(--color-sunken)] text-sm text-[var(--color-fg-secondary)]",children:[e.jsxs("button",{type:"button",onClick:()=>n(!o),className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left",children:[e.jsxs("span",{className:"flex items-center gap-2 font-mono text-[11.5px] font-medium uppercase tracking-[0.06em]",children:[e.jsx(Qe,{kind:"thinking"})," ",s("tool.thinking")]}),e.jsx(qt,{open:o})]}),o&&(a?e.jsx("div",{className:"whitespace-pre-wrap break-words border-t border-[var(--color-hairline-strong)] bg-[var(--color-surface)] px-3 py-2 text-[13px] leading-relaxed text-[var(--color-fg-secondary)]",children:e.jsx(xe,{text:t.text,query:r})}):e.jsx("p",{className:"border-t border-[var(--color-hairline-strong)] bg-[var(--color-surface)] px-3 py-2 text-[12px] italic text-[var(--color-fg-muted)]",children:s("tool.thinkingEncrypted")}))]})}function Wo({text:t}){const r=N(),[s,o]=d.useState(!1);return e.jsx("button",{type:"button","aria-label":r(s?"tool.copied":"tool.copy"),title:r(s?"tool.copied":"tool.copy"),onClick:()=>{navigator.clipboard.writeText(t).then(()=>{o(!0),window.setTimeout(()=>o(!1),1500)})},className:"inline-flex items-center justify-center rounded-md border border-[var(--color-hairline)] bg-[var(--color-surface)] p-1 shadow-[var(--shadow-rise)] transition "+(s?"text-[var(--color-moss)]":"text-[var(--color-fg-muted)] hover:text-[var(--color-fg-primary)]"),children:s?e.jsx(Ho,{}):e.jsx(zo,{})})}function I(t){return typeof t=="string"?t:""}function Ke(t){return t&&typeof t=="object"?t:{}}function bt(t){return t.split(`
9
+ `,1)[0].trim()||null}function kt(t){return t&&t.split(/[\\/]+/).filter(Boolean).slice(-2).join("/")||null}function qt({open:t}){return e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--color-fg-muted)] transition-transform",style:{transform:t?"rotate(90deg)":"rotate(0)"},"aria-hidden":!0,children:e.jsx("path",{d:"M9 6l6 6-6 6"})})}function zo(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),e.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10"})]})}function Ho(){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"M4 12.5l5 5L20 6.5"})})}function Qe({kind:t}){const r={width:11,height:11,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};return t==="tool"?e.jsx("svg",{...r,children:e.jsx("path",{d:"M14.7 5.3a3 3 0 1 0 4 4l-2.5 2.5 5 5-2.7 2.7-5-5-2.5 2.5a3 3 0 1 0-4-4z"})}):t==="result"?e.jsxs("svg",{...r,children:[e.jsx("path",{d:"M5 12h13"}),e.jsx("path",{d:"M13 7l5 5-5 5"})]}):t==="error"?e.jsxs("svg",{...r,children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 8v4.5"}),e.jsx("path",{d:"M12 16h.01"})]}):e.jsxs("svg",{...r,children:[e.jsx("path",{d:"M9 18h6"}),e.jsx("path",{d:"M10 21h4"}),e.jsx("path",{d:"M12 3a6 6 0 0 0-3.6 10.8c.8.6 1.1 1.6 1.1 2.7v.5h5v-.5c0-1.1.3-2.1 1.1-2.7A6 6 0 0 0 12 3z"})]})}const qo=d.lazy(()=>Ee(()=>import("./MarkdownContent-BFu7Nkk_.js"),__vite__mapDeps([0,1,2,3,4,5])));function Kt({message:t,query:r,toolNames:s}){return t.isMeta?e.jsx(Qo,{message:t,query:r}):t.type==="user"&&t.blocks.length>0&&t.blocks.every(o=>o.type==="tool_result")?e.jsx(wt,{message:t,query:r,toolNames:s,variant:"tool"}):t.type==="user"?e.jsx(Ko,{message:t,query:r,toolNames:s}):e.jsx(wt,{message:t,query:r,toolNames:s})}function wt({message:t,query:r,toolNames:s,variant:o="assistant"}){const n=N(),a=o==="tool",i=n(a?"message.role.tool":"message.role.claude"),l=a?"border-l-[var(--color-hairline-strong)]":"border-l-[var(--color-accent)]";return e.jsxs("div",{className:"flex items-start gap-3","data-uuid":t.uuid,children:[e.jsx(Gt,{role:"assistant"}),e.jsxs("div",{className:"min-w-0 flex-1 max-w-[min(54rem,calc(100%-3rem))]",children:[e.jsx(Qt,{align:"left",label:i,model:t.model,ts:t.ts,accent:!a}),e.jsx("article",{className:"mt-1.5 rounded-2xl rounded-tl-sm border border-l-[3px] border-[var(--color-hairline)] bg-[var(--color-surface)] px-4 py-3 shadow-[0_1px_0_0_var(--color-hairline)] "+l,children:e.jsx(Vt,{blocks:t.blocks,query:r,toolNames:s,markdown:!a&&!r})})]})]})}function Ko({message:t,query:r,toolNames:s}){const o=N();return e.jsxs("div",{className:"flex items-start justify-end gap-3","data-uuid":t.uuid,children:[e.jsxs("div",{className:"min-w-0 max-w-[min(46rem,calc(100%-3rem))]",children:[e.jsx(Qt,{align:"right",label:o("message.role.you"),model:t.model,ts:t.ts}),e.jsx("article",{className:"mt-1.5 rounded-2xl rounded-tr-sm bg-[var(--color-accent-soft)] px-4 py-3 text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]",children:e.jsx(Vt,{blocks:t.blocks,query:r,toolNames:s})})]}),e.jsx(Gt,{role:"user"})]})}function Qo({message:t,query:r}){const s=N();return e.jsxs("div",{className:"my-2 flex items-center gap-3 px-4","data-uuid":t.uuid,children:[e.jsx("span",{className:"h-px flex-1 bg-[var(--color-hairline)]"}),e.jsxs("div",{className:"max-w-2xl text-center",children:[e.jsxs("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-[var(--color-fg-muted)]",children:[s("message.role.system")," · ",Ue(t.ts)]}),e.jsx("div",{className:"mt-1 space-y-1 text-xs italic text-[var(--color-fg-muted)]",children:t.blocks.map((o,n)=>{if(o.type==="text"){const a=o.text.length>200?o.text.slice(0,200)+"…":o.text;return e.jsx("p",{className:"whitespace-pre-wrap break-words",children:e.jsx(xe,{text:a,query:r})},n)}return o.type==="tool_use"?e.jsxs("p",{children:[s("tool.use")," · ",o.name]},n):o.type==="tool_result"?e.jsx("p",{children:s("tool.result")},n):null})})]}),e.jsx("span",{className:"h-px flex-1 bg-[var(--color-hairline)]"})]})}function Qt({align:t,label:r,model:s,ts:o,accent:n}){return e.jsxs("div",{className:"flex items-baseline gap-2 text-[11px] "+(t==="right"?"flex-row-reverse text-right":""),children:[e.jsx("span",{className:"font-display text-[14px] font-medium tracking-tight "+(n?"text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]":"text-[var(--color-fg-primary)]"),children:r}),s&&e.jsx("span",{className:"truncate font-mono text-[10px] uppercase tracking-[0.14em] text-[var(--color-fg-faint)]",children:s}),e.jsx("time",{className:"font-mono tabular-nums text-[var(--color-fg-muted)]",children:Ue(o)})]})}function Vt({blocks:t,query:r,toolNames:s,markdown:o=!1}){const n=N();return e.jsx("div",{className:"space-y-2.5",children:t.map((a,i)=>{switch(a.type){case"text":{const l=e.jsx("p",{className:"whitespace-pre-wrap break-words text-[14.5px] leading-relaxed",children:e.jsx(xe,{text:a.text,query:r})},i);return o?e.jsx(d.Suspense,{fallback:l,children:e.jsx(qo,{text:a.text})},i):l}case"tool_use":return e.jsx(Io,{block:a,query:r},i);case"tool_result":return e.jsx(Oo,{block:a,query:r,toolName:s==null?void 0:s.get(a.toolUseId)},i);case"thinking":return e.jsx(Uo,{block:a,query:r},i);case"image":return e.jsxs("div",{className:"rounded-xl border border-[var(--color-hairline)] bg-[var(--color-sunken)] px-3 py-2 font-mono text-[11px] text-[var(--color-fg-muted)]",children:[n("tool.image"),a.mediaType?` · ${a.mediaType}`:""]},i);default:return e.jsx("pre",{className:"overflow-x-auto rounded-xl border border-[var(--color-hairline)] bg-[var(--color-sunken)] px-3 py-2 font-mono text-xs text-[var(--color-fg-secondary)]",children:JSON.stringify(a.raw,null,2)},i)}})})}function Yt(){const t=N();return e.jsx("li",{className:"py-3","aria-live":"polite",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{"aria-hidden":!0,className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-[var(--color-hairline-strong)] bg-[var(--color-surface)]",children:e.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5",children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-[var(--color-accent)] pulse-amber"}),e.jsx("span",{className:"absolute inset-0 rounded-full bg-[var(--color-accent)]"})]})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-display text-[14px] font-medium tracking-tight text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]",children:t("message.role.claude")}),e.jsxs("article",{className:"mt-1.5 inline-flex items-center gap-2.5 rounded-2xl rounded-tl-sm border border-l-[3px] border-[var(--color-hairline)] border-l-[var(--color-accent)] bg-[var(--color-surface)] px-4 py-3",children:[e.jsxs("span",{"aria-hidden":!0,className:"loading-dots text-[var(--color-accent)]",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("span",{className:"font-display text-[13.5px] italic text-[var(--color-fg-muted)]",children:t("session.working.indicator")})]})]})]})})}function Gt({role:t}){return t==="assistant"?e.jsx("span",{"aria-hidden":!0,className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-[var(--color-hairline-strong)] bg-[var(--color-surface)] text-[var(--color-accent)]",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M19 7.5A8 8 0 1 0 19 16.5"}),e.jsx("path",{d:"M15.5 9.5a4.5 4.5 0 1 0 0 5",opacity:"0.45"})]})}):e.jsx("span",{"aria-hidden":!0,className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[var(--color-fg-primary)] font-display text-sm font-medium text-[var(--color-canvas)]",children:"Y"})}const Vo=320,Yo=20,Go=40,Jo=120;function Xo({files:t,cwd:r,editLookup:s,messages:o,query:n,isWorking:a,loading:i,error:l,onClose:c,onOpenFile:u}){const m=N(),h=d.useMemo(()=>Zo(t),[t]),v=d.useMemo(()=>{const p=new Map;for(const[k,P]of s)p.set(k,P.name);return p},[s]),[g,x]=d.useState(null);d.useEffect(()=>{x(p=>{var k;return p&&t.some(P=>P.filePath===p)?p:((k=t[0])==null?void 0:k.filePath)??null})},[t]);const y=d.useMemo(()=>t.find(p=>p.filePath===g)??null,[t,g]),T=d.useMemo(()=>es(h),[h]),[L,O]=d.useState(()=>new Set),U=p=>O(k=>{const P=new Set(k);return P.has(p)?P.delete(p):P.add(p),P}),_=d.useRef(null),S=d.useRef(null),[M,G]=d.useState(420),[J,te]=d.useState(280),[K,w]=d.useState(Yo),E=Math.max(0,o.length-K),W=d.useMemo(()=>o.slice(E),[o,E]),D=E,z=d.useRef(null),Q=d.useRef(!0),re=d.useRef(o.length),Z=d.useRef(a);d.useLayoutEffect(()=>{const p=S.current;p&&(p.scrollTop=p.scrollHeight)},[]),d.useLayoutEffect(()=>{const p=S.current;p&&z.current!=null&&(p.scrollTop=p.scrollHeight-z.current,z.current=null)},[K]);function j(){const p=S.current;p&&(Q.current=p.scrollHeight-(p.scrollTop+p.clientHeight)<Jo)}d.useLayoutEffect(()=>{const p=o.length>re.current,k=a&&!Z.current;if(re.current=o.length,Z.current=a,!p&&!k||z.current!=null||!Q.current)return;const P=S.current;P&&(P.scrollTop=P.scrollHeight)},[o.length,a]);function ce(){const p=S.current;z.current=p?p.scrollHeight-p.scrollTop:null,w(k=>Math.min(o.length,k+Go))}d.useEffect(()=>{function p(P){P.key==="Escape"&&c()}window.addEventListener("keydown",p);const k=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",p),document.body.style.overflow=k}},[c]);const V=t.length,oe=V===1?m("session.modified.count",{n:V}):m("session.modified.countPlural",{n:V});return e.jsxs(e.Fragment,{children:[e.jsx($.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},onClick:c,className:"fixed inset-0 z-[55] bg-[oklch(0.16_0.006_85_/_0.5)] backdrop-blur-[2px]","aria-hidden":!0}),e.jsxs($.aside,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{duration:.26,ease:[.16,1,.3,1]},role:"dialog","aria-modal":"true","aria-label":m("session.modified.title"),className:"fixed inset-0 z-[60] flex w-full flex-col bg-[var(--color-surface)] shadow-[var(--shadow-pop)]",children:[e.jsxs("header",{className:"flex items-center justify-between gap-3 border-b border-[var(--color-hairline)] px-5 py-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("span",{className:"text-[var(--color-accent)]",children:e.jsx(ls,{})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"font-display text-[14px] font-light leading-tight tracking-tight text-[var(--color-fg-primary)]",children:m("session.modified.title")}),r&&e.jsx("p",{className:"truncate font-mono text-[10.5px] tracking-[0.02em] text-[var(--color-fg-faint)]",title:r,children:r})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2.5",children:[V>0&&e.jsx("span",{className:"font-mono text-[10.5px] uppercase tracking-[0.16em] tabular-nums text-[var(--color-fg-muted)]",children:oe}),e.jsx("button",{type:"button",onClick:c,"aria-label":m("session.modified.close"),className:"rounded-[var(--radius-control)] p-1.5 text-[var(--color-fg-muted)] transition hover:bg-[var(--color-sunken)] hover:text-[var(--color-fg-primary)]",children:e.jsx(cs,{})})]})]}),i&&e.jsx(je,{label:m("session.modified.loading"),className:"m-6"}),l&&!i&&e.jsxs("p",{className:"m-5 rounded-[var(--radius-control)] border border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] px-4 py-3 text-sm text-[var(--color-danger)]",children:[m("session.modified.failed"),": ",l.message]}),!i&&!l&&e.jsxs("div",{ref:_,className:"flex min-h-0 flex-1",children:[e.jsxs($.div,{initial:{opacity:0,x:-32},animate:{opacity:1,x:0},transition:{duration:.34,ease:[.16,1,.3,1],delay:.06},className:"flex shrink-0 flex-col border-r border-[var(--color-hairline)]",style:{width:M},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--color-hairline)] px-4 py-1.5",children:[e.jsx("span",{className:"eyebrow",children:m("session.modified.col.conversation")}),e.jsx("span",{className:"ml-auto font-mono text-[10px] tabular-nums text-[var(--color-fg-muted)]",children:o.length})]}),e.jsx("div",{ref:S,onScroll:j,className:"min-h-0 flex-1 overflow-auto px-4 py-2",children:o.length===0&&!a?e.jsx("p",{className:"px-1 py-3 text-sm italic text-[var(--color-fg-muted)]",children:m("common.noMessagesMatch")}):e.jsxs(e.Fragment,{children:[D>0&&e.jsx("button",{type:"button",onClick:ce,className:"mb-1 flex w-full items-center justify-center gap-1.5 rounded-[var(--radius-input)] border border-dashed border-[var(--color-hairline-strong)] py-2 font-mono text-[10.5px] uppercase tracking-[0.14em] text-[var(--color-fg-muted)] transition hover:border-[var(--color-accent)] hover:text-[var(--color-accent-ink)] dark:hover:text-[var(--color-accent)]",children:m("session.modified.showEarlier",{n:D})}),e.jsxs("ol",{children:[W.map((p,k)=>e.jsx("li",{className:"py-3",children:e.jsx(Kt,{message:p,query:n,toolNames:v})},p.uuid||p.ts||String(E+k))),a&&e.jsx(Yt,{})]})]})})]}),e.jsx(Nt,{getRect:()=>{var p;return((p=_.current)==null?void 0:p.getBoundingClientRect())??null},onResize:(p,k)=>G(St(p-k.left,k.width-J))}),e.jsx("div",{className:"min-w-0 flex-1 overflow-auto",children:y?e.jsx(ts,{file:y,editLookup:s,onOpenFile:u},y.filePath):e.jsx("div",{className:"flex h-full items-center justify-center px-6",children:e.jsx("p",{className:"text-center text-sm italic text-[var(--color-fg-muted)]",children:m(V===0?"session.modified.empty":"session.modified.selectFile")})})}),e.jsx(Nt,{getRect:()=>{var p;return((p=_.current)==null?void 0:p.getBoundingClientRect())??null},onResize:(p,k)=>te(St(k.right-p,k.width-M))}),e.jsxs($.div,{initial:{opacity:0,x:32},animate:{opacity:1,x:0},transition:{duration:.34,ease:[.16,1,.3,1],delay:.06},className:"flex shrink-0 flex-col border-l border-[var(--color-hairline)]",style:{width:J},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-[var(--color-hairline)] px-3 py-1.5",children:[e.jsx("span",{className:"eyebrow",children:m("session.modified.col.file")}),T.length>0&&e.jsx("button",{type:"button",onClick:()=>O(p=>p.size===0?new Set(T):new Set),className:"font-mono text-[10px] uppercase tracking-[0.14em] text-[var(--color-fg-muted)] transition hover:text-[var(--color-accent-ink)] dark:hover:text-[var(--color-accent)]",children:L.size===0?m("session.modified.collapseAll"):m("session.modified.expandAll")})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto py-1.5",children:e.jsx("ul",{role:"tree",className:"w-max min-w-full select-none",children:h.map(p=>e.jsx(Zt,{node:p,depth:0,collapsed:L,onToggleFolder:U,selected:g,onSelectFile:x,onOpenFile:u},Jt(p)))})})]})]})]})]})}function Nt({getRect:t,onResize:r}){const s=d.useRef(!1);return e.jsx("div",{role:"separator","aria-orientation":"vertical",onPointerDown:o=>{o.preventDefault(),o.currentTarget.setPointerCapture(o.pointerId),s.current=!0},onPointerMove:o=>{if(!s.current)return;const n=t();n&&r(o.clientX,n)},onPointerUp:o=>{s.current=!1,o.currentTarget.releasePointerCapture(o.pointerId)},className:"relative w-px shrink-0 cursor-col-resize touch-none bg-[var(--color-hairline)] transition-colors hover:bg-[var(--color-accent)]",children:e.jsx("span",{className:"absolute inset-y-0 -left-1.5 -right-1.5","aria-hidden":!0})})}function St(t,r){const o=Math.max(220,r-Vo);return Math.min(o,Math.max(220,t))}function Jt(t){return t.kind==="folder"?`d:${t.path}`:`f:${t.file.filePath}`}function Xt(t){const r=t.operations[0];return!!r&&(r.toolName==="Write"||r.toolName==="NotebookEdit")&&Array.isArray(r.structuredPatch)&&r.structuredPatch.length===0?"added":"modified"}function Ve(t){return t==="added"?"text-[var(--color-moss)]":"text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]"}function Zo(t){const r={folders:new Map,files:[],path:""};for(const n of t){const a=n.relativePath??n.filePath,i=a.split(/[\\/]+/).filter(Boolean),l=i.pop()??a;let c=r;for(const u of i){let m=c.folders.get(u);m||(m={folders:new Map,files:[],path:c.path?`${c.path}/${u}`:u},c.folders.set(u,m)),c=m}c.files.push({name:l,file:n})}function s(n){const a=[];for(const[l,c]of n.folders)a.push(o({kind:"folder",name:l,path:c.path,children:s(c)}));a.sort((l,c)=>l.name.localeCompare(c.name,void 0,{sensitivity:"base"}));const i=n.files.map(l=>({kind:"file",name:l.name,file:l.file})).sort((l,c)=>l.name.localeCompare(c.name,void 0,{sensitivity:"base"}));return[...a,...i]}function o(n){let a=n;for(;a.children.length===1&&a.children[0].kind==="folder";){const i=a.children[0];a={kind:"folder",name:`${a.name}/${i.name}`,path:i.path,children:i.children}}return a}return s(r)}function es(t){const r=[],s=o=>{for(const n of o)n.kind==="folder"&&(r.push(n.path),s(n.children))};return s(t),r}function Zt({node:t,depth:r,collapsed:s,onToggleFolder:o,selected:n,onSelectFile:a,onOpenFile:i}){const l=N(),c={paddingLeft:`${r*14+10}px`};if(t.kind==="folder"){const x=s.has(t.path);return e.jsxs("li",{role:"treeitem","aria-expanded":!x,children:[e.jsxs("button",{type:"button",onClick:()=>o(t.path),style:c,className:"flex w-full items-center gap-1.5 py-1 pr-2 text-left transition hover:bg-[var(--color-sunken)]",children:[e.jsx(as,{open:!x}),e.jsx(is,{open:!x}),e.jsx("span",{className:"whitespace-nowrap font-mono text-[12px] text-[var(--color-fg-secondary)]",children:t.name})]}),!x&&e.jsx("ul",{role:"group",children:t.children.map(y=>e.jsx(Zt,{node:y,depth:r+1,collapsed:s,onToggleFolder:o,selected:n,onSelectFile:a,onOpenFile:i},Jt(y)))})]})}const u=t.file,m=n===u.filePath,h=l("session.modified.openFile"),v=Xt(u),g=Ve(v);return e.jsxs("li",{role:"treeitem","aria-selected":m,className:"group flex w-full items-center transition "+(m?"bg-[var(--color-accent-soft)] text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]":"hover:bg-[var(--color-sunken)]"),children:[e.jsxs("button",{type:"button",onClick:()=>a(u.filePath),style:c,title:u.filePath,className:"flex flex-1 items-center gap-1.5 py-1 pr-2 text-left",children:[e.jsx("span",{className:"w-[11px] shrink-0","aria-hidden":!0}),e.jsx(er,{errored:u.errorCount>0,tone:v}),e.jsx("span",{className:"whitespace-nowrap font-mono text-[12px] "+g+(m?" font-medium":""),children:t.name})]}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1 pl-1 pr-2",children:[u.errorCount>0&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--color-danger)]"}),e.jsx("span",{className:`font-mono text-[10px] font-semibold leading-none ${g}`,title:l(v==="added"?"session.modified.added":"session.modified.modified"),children:v==="added"?"A":"M"}),e.jsx("span",{className:"font-mono text-[10px] tabular-nums text-[var(--color-fg-muted)] group-hover:hidden",children:u.totalCount}),e.jsx("button",{type:"button",onClick:()=>i(u.filePath),title:h,"aria-label":h,className:"hidden rounded-[var(--radius-control)] p-0.5 text-[var(--color-fg-muted)] transition hover:text-[var(--color-accent-ink)] group-hover:inline-flex dark:hover:text-[var(--color-accent)]",children:e.jsx(tr,{})})]})]})}function ts({file:t,editLookup:r,onOpenFile:s}){const o=N(),n=t.relativePath??t.filePath,a=n.split(/[\\/]+/).pop()??n,i=Xt(t),{rows:l,newFile:c}=d.useMemo(()=>rs(t,r),[t,r]);return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"sticky top-0 z-10 border-b border-[var(--color-hairline)] bg-[var(--color-surface)]/95 px-5 py-3 backdrop-blur",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(er,{errored:t.errorCount>0,tone:i}),e.jsx("h3",{className:"min-w-0 flex-1 truncate font-mono text-[13.5px] font-medium "+(t.errorCount>0?"text-[var(--color-danger)]":Ve(i)),title:t.filePath,children:a}),e.jsxs("button",{type:"button",onClick:()=>s(t.filePath),title:o("session.modified.openFile"),className:"inline-flex shrink-0 items-center gap-1 rounded-[var(--radius-control)] border border-[var(--color-hairline)] bg-[var(--color-surface)] px-2 py-0.5 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--color-fg-secondary)] transition hover:border-[var(--color-accent)] hover:text-[var(--color-accent-ink)] dark:hover:text-[var(--color-accent)]",children:[e.jsx(tr,{}),o("session.modified.openFile")]})]}),e.jsx("p",{className:"mt-0.5 truncate font-mono text-[10.5px] text-[var(--color-fg-faint)]",title:t.filePath,children:t.relativePath??`${o("session.modified.absolutePath")} · ${t.filePath}`}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[t.editCount>0&&e.jsx(ke,{name:"Edit",count:t.editCount}),t.writeCount>0&&e.jsx(ke,{name:"Write",count:t.writeCount}),t.multiEditCount>0&&e.jsx(ke,{name:"MultiEdit",count:t.multiEditCount}),t.notebookEditCount>0&&e.jsx(ke,{name:"NotebookEdit",count:t.notebookEditCount}),t.errorCount>0&&e.jsx("span",{className:"rounded-[var(--radius-control)] border border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] px-2 py-0.5 font-mono text-[10px] uppercase tracking-[0.1em] text-[var(--color-danger)]",children:o("session.modified.errorBadge",{n:t.errorCount})})]})]}),e.jsx("div",{className:"px-5 py-4",children:e.jsx(ss,{rows:l,label:c?o("session.modified.newContent"):void 0})})]})}const ue=t=>typeof t=="string"?t:"";function rs(t,r){var a;const s=t.operations.flatMap(i=>i.structuredPatch??[]);if(s.length>0){const i=[...s].sort((l,c)=>l.newStart-c.newStart);return{rows:To(i),newFile:!1}}const o=[];let n=!0;for(const i of t.operations){const l=Lt((a=r.get(i.toolUseId))==null?void 0:a.input);if(i.toolName==="Write")o.push(...se("",ue(l.content)));else if(i.toolName==="NotebookEdit")o.push(...se("",ue(l.new_source)));else if(i.toolName==="MultiEdit"){n=!1;const c=Array.isArray(l.edits)?l.edits:[];for(const u of c){const m=Lt(u);o.push(...se(ue(m.old_string),ue(m.new_string)))}}else n=!1,o.push(...se(ue(l.old_string),ue(l.new_string)))}return{rows:o,newFile:n}}function os(t){const r=[];let s=0;for(;s<t.length;){const o=t[s];if(o.kind==="gap"){r.push({kind:"gap",gap:o.gap??0}),s++;continue}if(o.kind==="context"){r.push({kind:"pair",left:{no:o.oldNo,kind:"context",text:o.text,segs:null},right:{no:o.newNo,kind:"context",text:o.text,segs:null}}),s++;continue}const n=[],a=[];for(;s<t.length&&t[s].kind==="del";)n.push(t[s++]);for(;s<t.length&&t[s].kind==="add";)a.push(t[s++]);const i=Math.max(n.length,a.length);for(let l=0;l<i;l++){const c=n[l],u=a[l];r.push({kind:"pair",left:c?{no:c.oldNo,kind:"del",text:c.text,segs:c.segs}:{no:null,kind:"empty",text:null,segs:null},right:u?{no:u.newNo,kind:"add",text:u.text,segs:u.segs}:{no:null,kind:"empty",text:null,segs:null}})}}return r}function ss({rows:t,label:r}){if(t.length===0)return e.jsx(ns,{});const s=os(t);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-[var(--color-hairline)]",children:[r&&e.jsx("div",{className:"border-b border-[var(--color-hairline)] bg-[var(--color-sunken)] px-3 py-1 font-mono text-[9.5px] uppercase tracking-[0.16em] text-[var(--color-fg-muted)]",children:r}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-1/2 overflow-x-auto border-r border-[var(--color-hairline)]",children:e.jsx("div",{className:"w-max min-w-full",children:s.map((o,n)=>e.jsx(Ct,{row:o,side:"left"},n))})}),e.jsx("div",{className:"w-1/2 overflow-x-auto",children:e.jsx("div",{className:"w-max min-w-full",children:s.map((o,n)=>e.jsx(Ct,{row:o,side:"right"},n))})})]})]})}function Ct({row:t,side:r}){const s=N();if(t.kind==="gap")return e.jsxs("div",{className:"flex bg-[var(--color-sunken)] leading-[1.65] text-[var(--color-fg-faint)]",children:[e.jsx("span",{className:"w-[3em] shrink-0 select-none border-r border-[var(--color-hairline)] bg-[inherit] px-1.5 text-center font-mono text-[11px]",children:"⋯"}),e.jsx("span",{className:"whitespace-nowrap px-3 font-mono text-[10px] italic tracking-[0.04em]",children:s("session.modified.linesOmitted",{n:t.gap??0})})]});const o=r==="left"?t.left:t.right,n=o.kind==="del"?"bg-[var(--color-danger-soft)]":o.kind==="add"?"bg-[var(--color-moss-soft)]":o.kind==="empty"?"bg-[var(--color-sunken)]/40":"bg-[var(--color-surface)]",a=o.kind==="del"?"−":o.kind==="add"?"+":"",i=o.kind==="del"?"text-[var(--color-danger)]":o.kind==="add"?"text-[var(--color-moss)]":"text-transparent",l=o.kind==="del"?"bg-[var(--color-danger)]/25":"bg-[var(--color-moss)]/30";return e.jsxs("div",{className:`flex leading-[1.65] ${n}`,children:[e.jsx("span",{className:"w-[3em] shrink-0 select-none border-r border-[var(--color-hairline)] bg-[inherit] px-1.5 text-right font-mono text-[10px] tabular-nums text-[var(--color-fg-faint)]",children:o.no??""}),e.jsx("span",{className:`w-4 shrink-0 select-none text-center font-mono text-[11.5px] ${i}`,children:a}),e.jsx("div",{className:"whitespace-pre pr-3 font-mono text-[11.5px] text-[var(--color-fg-primary)]",children:o.segs&&o.segs.length>0?o.segs.map((c,u)=>c.changed?e.jsx("span",{className:l,children:c.text},u):e.jsx("span",{children:c.text},u)):o.text==null||o.text===""?" ":o.text})]})}function ns(){const t=N();return e.jsx("p",{className:"px-3 py-2.5 text-[12px] italic text-[var(--color-fg-muted)]",children:t("session.modified.noContent")})}function Lt(t){return t&&typeof t=="object"?t:{}}function ke({name:t,count:r}){return e.jsxs("span",{className:"rounded-[var(--radius-control)] border border-[var(--color-hairline-strong)] bg-[var(--color-surface)] px-2 py-0.5 font-mono text-[10px] uppercase tracking-[0.1em] text-[var(--color-fg-secondary)]",children:[t,e.jsxs("span",{className:"ml-1 tabular-nums text-[var(--color-fg-muted)]",children:["×",r]})]})}function as({open:t}){return e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-[var(--color-fg-muted)] transition-transform "+(t?"rotate-90":""),"aria-hidden":!0,children:e.jsx("path",{d:"M9 6l6 6-6 6"})})}function is({open:t}){return e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-[var(--color-accent)]","aria-hidden":!0,children:t?e.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h3.5l2 2H19a2 2 0 0 1 2 2v1H6.5a2 2 0 0 0-1.9 1.4L3 18z"}):e.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h3.5l2 2H19a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"})})}function er({errored:t,tone:r}){const s=t?"text-[var(--color-danger)]":r?Ve(r):"text-[var(--color-fg-muted)]";return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 "+s,"aria-hidden":!0,children:[e.jsx("path",{d:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"}),e.jsx("path",{d:"M14 3v5h5"})]})}function ls(){return e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M3 5h7l2 2h9"}),e.jsx("path",{d:"M3 5v14h18V9"}),e.jsx("path",{d:"M8 13h8M8 16h5",opacity:"0.5"})]})}function tr(){return e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0","aria-hidden":!0,children:[e.jsx("path",{d:"M14 4h6v6"}),e.jsx("path",{d:"M20 4l-9 9"}),e.jsx("path",{d:"M19 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5"})]})}function cs(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":!0,children:e.jsx("path",{d:"M6 6l12 12M18 6L6 18"})})}const Et=50,Mt=50,ds=2e3,ms=ze*60*1e3,us=120;function Pt(t){if(!t)return!1;const r=new Date(t).getTime();return Number.isNaN(r)?!1:Date.now()-r<ms}function ps(t){var o;const r=t[t.length-1];if(!r)return!1;if(r.type==="assistant")return((o=r.blocks[r.blocks.length-1])==null?void 0:o.type)==="tool_use";const s=r.blocks.find(n=>n.type==="text");return!(s&&io.test(s.text))}function xs(){var Je,Xe;const t=N(),r=At(),{projectId:s,sessionId:o}=_t(),[n]=jr(),a=s??"",i=o??"",l=n.get("focus"),c=n.get("q"),[u,m]=d.useState(!1),[h,v]=d.useState(!1),[g,x]=d.useState(!1),[y,T]=d.useState(""),L=d.useDeferredValue(y),[O,U]=d.useState(Et),[_,S]=d.useState(!1),[M,G]=d.useState(!1),J=d.useRef(null),te=d.useRef(null),[K,w]=d.useState(0),[E,W]=d.useState(!1),D=d.useRef(null),z=d.useRef(null),Q=d.useRef(!0),re=d.useRef(null),Z=d.useRef(!1);d.useEffect(()=>{U(Et),re.current=null},[a,i]);const{data:j,isLoading:ce,error:V}=Y({queryKey:R.session(a,i),queryFn:()=>B(`/api/sessions/${encodeURIComponent(a)}/${encodeURIComponent(i)}`),enabled:!!a&&!!i,refetchInterval:f=>{var b;return Pt((b=f.state.data)==null?void 0:b.meta.lastAt)?ds:!1}}),oe=Pt(j==null?void 0:j.meta.lastAt),p=oe&&!!j&&ps(j.messages),k=Y({queryKey:R.projects(),queryFn:()=>B("/api/projects")}),P=d.useMemo(()=>{var f;return(f=k.data)==null?void 0:f.find(b=>b.id===a)},[k.data,a]),de=Y({queryKey:R.projectSessions(a),queryFn:()=>B(`/api/projects/${encodeURIComponent(a)}/sessions`),enabled:!!a}),A=d.useMemo(()=>{var f;return((f=de.data)==null?void 0:f.find(b=>b.id===i))??null},[de.data,i]),ne=A?void 0:de.isLoading?t("common.loading"):t("session.action.deleteTooltipBlocked"),H=Y({queryKey:R.sessionModifiedFiles(a,i),queryFn:()=>B(`/api/sessions/${encodeURIComponent(a)}/${encodeURIComponent(i)}/modified-files`),enabled:!!a&&!!i}),Me=((Je=H.data)==null?void 0:Je.files)??[],nr=le({mutationFn:f=>B(`/api/sessions/${encodeURIComponent(a)}/${encodeURIComponent(i)}/open-file`,{method:"POST",body:JSON.stringify({filePath:f})}),onError:f=>{window.alert(t("session.modified.openFailed",{msg:f.message}))}}),Ye=d.useMemo(()=>j?j.messages.map(f=>({message:f,haystack:ws(f)})):[],[j]),Pe=d.useMemo(()=>{const f=new Map;if(!j)return f;for(const b of j.messages)for(const C of b.blocks)C.type==="tool_use"&&C.id&&f.set(C.id,{name:C.name,input:C.input});return f},[j]),ar=d.useMemo(()=>{const f=new Map;for(const[b,C]of Pe)f.set(b,C.name);return f},[Pe]),ir=d.useMemo(()=>(j==null?void 0:j.messages.filter(f=>!f.isMeta))??[],[j]),q=d.useMemo(()=>{let f=Ye;if(u||(f=f.filter(b=>!b.message.isMeta)),h&&(f=f.filter(b=>bs(b.message))),g&&(f=f.filter(b=>ks(b.message))),L){const b=L.toLowerCase();f=f.filter(C=>C.haystack.includes(b))}return f},[Ye,u,h,g,L]),X=!!L||h||g,ae=d.useMemo(()=>X?q:q.slice(-O),[q,X,O]),lr=!X&&ae.length<q.length;d.useEffect(()=>{if(!j)return;const f=`${i}|${l??""}|${c??""}`;if(D.current!==f&&(D.current=f,c&&T(c),l)){const b=j.messages.find(C=>C.uuid===l);b!=null&&b.isMeta&&m(!0)}},[j,i,l,c]),d.useEffect(()=>{if(!l||!j||X)return;const f=q.findIndex(C=>C.message.uuid===l);if(f===-1)return;const b=q.length-f;b>O&&U(b)},[l,q,O,X,j]),d.useEffect(()=>{if(!l||!j)return;const f=`${i}|${l}`;if(z.current===f||!ae.some(C=>C.message.uuid===l))return;z.current=f;const b=requestAnimationFrame(()=>{const C=document.querySelector(`[data-uuid="${CSS.escape(l)}"]`);if(!C)return;C.scrollIntoView({block:"center",behavior:"smooth"});const fe=C.closest("li")??C;fe.classList.add("flash-focus"),window.setTimeout(()=>fe.classList.remove("flash-focus"),1300)});return()=>cancelAnimationFrame(b)},[l,ae,j,i]),d.useEffect(()=>{const f=()=>{const b=document.documentElement.scrollHeight-(window.scrollY+window.innerHeight);Q.current=b<us};return f(),window.addEventListener("scroll",f,{passive:!0}),()=>window.removeEventListener("scroll",f)},[]),d.useLayoutEffect(()=>{const f=te.current;if(!f)return;const b=()=>w(f.offsetHeight);b();const C=new ResizeObserver(b);return C.observe(f),()=>C.disconnect()},[]),d.useEffect(()=>{let f=0;const b=()=>{f=0;const fe=J.current;fe&&W(fe.getBoundingClientRect().top<=K+1)},C=()=>{f||(f=requestAnimationFrame(b))};return b(),window.addEventListener("scroll",C,{passive:!0}),window.addEventListener("resize",C,{passive:!0}),()=>{window.removeEventListener("scroll",C),window.removeEventListener("resize",C),f&&cancelAnimationFrame(f)}},[K]),d.useEffect(()=>{const f=(j==null?void 0:j.meta.messageCount)??null,b=re.current;if(re.current=f,b===null||f===null||f<=b||l||X||!Q.current)return;const C=requestAnimationFrame(()=>window.scrollTo({top:document.documentElement.scrollHeight,behavior:"smooth"}));return()=>cancelAnimationFrame(C)},[j==null?void 0:j.meta.messageCount,l,X]),d.useEffect(()=>{const f=p&&!Z.current;if(Z.current=p,!f||l||X||!Q.current)return;const b=requestAnimationFrame(()=>window.scrollTo({top:document.documentElement.scrollHeight,behavior:"smooth"}));return()=>cancelAnimationFrame(b)},[p,l,X]);const cr=d.useMemo(()=>{const f=P==null?void 0:P.decodedCwd;return f?f.split(/[\\/]+/).filter(Boolean).at(-1)??f:a.slice(-12)},[P,a]),he=d.useMemo(()=>j?j.meta.customTitle??j.meta.title:null,[j]),ye=Le(),dr=le({mutationFn:f=>B(`/api/sessions/${encodeURIComponent(a)}/${encodeURIComponent(i)}`,{method:"PATCH",body:JSON.stringify({customTitle:f})}),onSuccess:({customTitle:f})=>{ye.setQueryData(R.session(a,i),b=>b&&{...b,meta:{...b.meta,customTitle:f}}),ye.setQueryData(R.projectSessions(a),b=>b==null?void 0:b.map(C=>C.id===i?{...C,customTitle:f}:C)),ye.invalidateQueries({queryKey:R.session(a,i)}),ye.invalidateQueries({queryKey:R.projectSessions(a)})}}),mr=j!=null&&j.meta.gitBranch?t("session.tagline.branch",{branch:j.meta.gitBranch}):"",Ge=[{label:t("session.crumbProjects"),to:"/"},{label:cr,to:`/projects/${encodeURIComponent(a)}`,mono:!0,icon:e.jsx(Oe,{})},{label:he??i.slice(0,8),mono:!he,icon:e.jsx(Oe,{})}],ur=he??i.slice(0,12)+"…";return e.jsxs("section",{children:[e.jsx($e,{items:Ge}),j&&e.jsx("div",{className:"surface-card mt-4 p-6",children:e.jsx(hs,{sid:i,isLive:oe,isWorking:p,title:he,tagline:t("session.tagline",{started:pe(j.meta.firstAt),lastTouched:pe(j.meta.lastAt),branchPart:mr}),firstAt:j.meta.firstAt,messageCount:j.meta.messageCount,bytes:j.meta.bytes,version:j.meta.version,branch:j.meta.gitBranch,editableValue:he??"",onTitleEdit:async f=>{await dr.mutateAsync(f)},renameDisabled:(A==null?void 0:A.isLivePid)===!0,renameTooltip:(A==null?void 0:A.isLivePid)===!0?t("session.action.renameTooltipLive",{pid:A.livePid??"?"}):void 0,onDelete:A?()=>S(!0):void 0,deleteDisabled:!A,deleteTooltip:ne,deleteLabel:t("session.action.delete"),onOpenModified:()=>G(!0),modifiedCount:Me.length,modifiedLoading:H.isLoading})}),_&&A&&e.jsx(Eo,{projectId:a,selected:[A],onClose:()=>S(!1),onDeleted:f=>{f.includes(i)&&(S(!1),r(`/projects/${encodeURIComponent(a)}`,{replace:!0}))}}),e.jsx(Bt,{children:M&&e.jsx(Xo,{files:Me,cwd:((Xe=H.data)==null?void 0:Xe.cwd)??(j==null?void 0:j.meta.cwd)??null,editLookup:Pe,messages:ir,query:L,isWorking:p,loading:H.isLoading,error:H.error,onOpenFile:f=>nr.mutate(f),onClose:()=>G(!1)},"modified-files-drawer")}),e.jsxs("div",{ref:J,className:"sticky top-2 z-30 mt-6 lg:top-[var(--ccsm-pin-top)]",style:{"--ccsm-pin-top":`${K}px`},children:[e.jsxs("div",{ref:te,"aria-hidden":!E,className:"topbar-glass absolute inset-x-0 bottom-full pb-2 hidden flex-col gap-2 transition-opacity duration-200 lg:flex "+(E?"opacity-100":"pointer-events-none opacity-0"),children:[e.jsx($e,{items:Ge}),j&&e.jsx(fs,{title:ur,isLive:oe,isWorking:p,onOpenModified:()=>G(!0),modifiedCount:Me.length,modifiedLoading:H.isLoading,onDelete:A?()=>S(!0):void 0,deleteDisabled:!A,deleteTooltip:ne,deleteLabel:t("session.action.delete")})]}),e.jsx(ys,{query:y,onQuery:T,showMeta:u,onShowMeta:m,onlyUser:h,onOnlyUser:v,onlyError:g,onOnlyError:x,shown:ae.length,total:q.length,hasData:!!j})]}),e.jsxs("div",{className:"mt-6",children:[(j==null?void 0:j.truncated)&&e.jsx(Rt,{tone:"warn",className:"mb-6",children:t("session.truncated",{n:ao.toLocaleString()})}),ce&&e.jsx(je,{label:t("common.loadingSession")}),V&&e.jsxs(Rt,{tone:"danger",children:[t("common.failedSession"),": ",V.message]}),j&&q.length===0&&e.jsx("p",{className:"mt-2 max-w-2xl font-display text-[15px] italic text-[var(--color-fg-muted)]",children:t("common.noMessagesMatch")}),j&&q.length>0&&e.jsxs("ol",{className:"border-t border-[var(--color-hairline-strong)]",children:[lr&&e.jsx("li",{className:"flex justify-center border-b border-[var(--color-hairline)] py-3",children:e.jsx("button",{type:"button",onClick:()=>U(f=>Math.min(f+Mt,q.length)),className:"rounded-[var(--radius-control)] border border-[var(--color-hairline)] bg-[var(--color-surface)] px-4 py-1.5 font-mono text-[11px] uppercase tracking-[0.14em] text-[var(--color-fg-secondary)] transition hover:border-[var(--color-accent)] hover:text-[var(--color-accent-ink)] dark:hover:text-[var(--color-accent)]",children:t("common.loadEarlier",{n:Math.min(Mt,q.length-ae.length)})})}),e.jsx($.div,{initial:"hidden",animate:"show",variants:He,children:ae.map((f,b)=>{const C=f.message.isMeta;return e.jsx($.li,{variants:qe,className:C?"py-2":"py-3",children:e.jsx(Kt,{message:f.message,query:L,toolNames:ar})},f.message.uuid||f.message.ts||String(b))})},ae.length===0?"empty":"list"),p&&!X&&e.jsx(Yt,{})]})]}),j&&e.jsx(Ls,{})]})}function hs({sid:t,isLive:r,isWorking:s,title:o,tagline:n,firstAt:a,messageCount:i,bytes:l,version:c,branch:u,editableValue:m,onTitleEdit:h,renameDisabled:v,renameTooltip:g,onDelete:x,deleteDisabled:y,deleteTooltip:T,deleteLabel:L,onOpenModified:O,modifiedCount:U,modifiedLoading:_}){const S=N(),M=js(a);return e.jsxs("header",{className:"relative",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 border-b border-[var(--color-hairline)] pb-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3 font-mono text-[10px] uppercase tracking-[0.22em] text-[var(--color-fg-muted)]",children:[e.jsx("span",{className:"text-[var(--color-accent)]",children:"●"}),e.jsx("span",{children:"§ SESSION"}),s?e.jsxs("span",{title:S("session.working.tooltip"),className:"inline-flex items-center gap-1.5 rounded-full bg-[var(--color-accent-soft)] px-2 py-0.5 normal-case tracking-[0.14em] text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]",children:[e.jsxs("span",{"aria-hidden":!0,className:"loading-dots text-[var(--color-accent)]",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),S("session.working")]}):r?e.jsxs("span",{title:S("session.live.tooltip"),className:"inline-flex items-center gap-1.5 rounded-full bg-[var(--color-accent-soft)] px-2 py-0.5 normal-case tracking-[0.14em] text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]",children:[e.jsxs("span",{"aria-hidden":!0,className:"relative inline-flex h-1.5 w-1.5",children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-[var(--color-accent)] pulse-amber"}),e.jsx("span",{className:"absolute inset-0 rounded-full bg-[var(--color-accent)]"})]}),S("session.live")]}):null,e.jsx("span",{className:"hidden h-3 w-px bg-[var(--color-hairline-strong)] sm:inline-block"}),e.jsx("span",{className:"hidden truncate normal-case tracking-[0.05em] text-[var(--color-fg-faint)] sm:inline",children:t}),u&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden h-3 w-px bg-[var(--color-hairline-strong)] md:inline-block"}),e.jsx("span",{className:"hidden truncate md:inline",children:u})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[e.jsx("div",{className:"hidden font-mono text-[10px] uppercase tracking-[0.22em] tabular-nums text-[var(--color-fg-muted)] sm:block",children:M}),e.jsxs("button",{type:"button",onClick:O,disabled:_,"aria-label":S("session.modified.openAria"),className:"inline-flex items-center gap-1.5 rounded-[var(--radius-control)] border border-[var(--color-hairline-strong)] bg-[var(--color-surface)] px-3 py-1 text-[11px] font-medium uppercase tracking-[0.14em] text-[var(--color-fg-secondary)] transition hover:border-[var(--color-accent)] hover:text-[var(--color-accent-ink)] disabled:cursor-not-allowed disabled:opacity-40 dark:hover:text-[var(--color-accent)]",children:[e.jsx(or,{})," ",S("session.modified.title"),U>0&&e.jsx("span",{className:"rounded-full bg-[var(--color-accent-soft)] px-1.5 font-mono text-[10px] tabular-nums text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]",children:U})]}),(x||y)&&e.jsxs("button",{type:"button",onClick:x,disabled:y||!x,title:T,"aria-label":L,className:"inline-flex items-center gap-1.5 rounded-[var(--radius-control)] border border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] px-3 py-1 text-[11px] font-medium uppercase tracking-[0.14em] text-[var(--color-danger)] transition hover:border-[var(--color-danger)] disabled:cursor-not-allowed disabled:opacity-40",children:[e.jsx(rr,{})," ",L]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-x-10 gap-y-6 pt-5 pb-2 lg:grid-cols-12",children:[e.jsx("div",{className:"lg:col-span-8",children:e.jsx(vs,{title:o??t.slice(0,12)+"…",editableValue:m,onTitleEdit:h,isFallback:!o,disabled:v,disabledTooltip:g})}),e.jsx("div",{className:"lg:col-span-4 lg:pt-3",children:e.jsx("p",{className:"border-l-2 border-[var(--color-accent)] pl-4 font-display text-[15px] italic leading-[1.55] text-[var(--color-fg-secondary)]",children:n})})]}),e.jsx("div",{className:"rule-dotted mt-6","aria-hidden":!0}),e.jsxs("dl",{className:"mt-3 flex flex-wrap items-baseline gap-x-8 gap-y-2",children:[e.jsx(we,{label:S("session.meta.messages"),value:i.toLocaleString()}),e.jsx(we,{label:S("session.meta.size"),value:F(l)}),c&&e.jsx(we,{label:S("session.meta.version"),value:c}),e.jsx(we,{label:S("session.meta.started"),value:Ue(a)})]})]})}function fs({title:t,isLive:r,isWorking:s,onOpenModified:o,modifiedCount:n,modifiedLoading:a,onDelete:i,deleteDisabled:l,deleteTooltip:c,deleteLabel:u}){const m=N();return e.jsxs("div",{className:"flex items-center gap-3 rounded-[var(--radius-input)] border border-[var(--color-hairline)] bg-[var(--color-surface)] px-4 sm:px-5 py-2 shadow-[var(--shadow-rise)]",children:[e.jsx(gs,{isLive:r,isWorking:s}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-display text-[15px] font-light tracking-[-0.01em] text-[var(--color-fg-primary)]",children:t}),e.jsxs("button",{type:"button",onClick:o,disabled:a,"aria-label":m("session.modified.openAria"),className:"inline-flex shrink-0 items-center gap-1.5 rounded-[var(--radius-control)] border border-[var(--color-hairline-strong)] bg-[var(--color-surface)] px-3 py-1 text-[11px] font-medium uppercase tracking-[0.14em] text-[var(--color-fg-secondary)] transition hover:border-[var(--color-accent)] hover:text-[var(--color-accent-ink)] disabled:cursor-not-allowed disabled:opacity-40 dark:hover:text-[var(--color-accent)]",children:[e.jsx(or,{})," ",m("session.modified.title"),n>0&&e.jsx("span",{className:"rounded-full bg-[var(--color-accent-soft)] px-1.5 font-mono text-[10px] tabular-nums text-[var(--color-accent-ink)] dark:text-[var(--color-accent)]",children:n})]}),(i||l)&&e.jsxs("button",{type:"button",onClick:i,disabled:l||!i,title:c,"aria-label":u,className:"inline-flex shrink-0 items-center gap-1.5 rounded-[var(--radius-control)] border border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] px-3 py-1 text-[11px] font-medium uppercase tracking-[0.14em] text-[var(--color-danger)] transition hover:border-[var(--color-danger)] disabled:cursor-not-allowed disabled:opacity-40",children:[e.jsx(rr,{})," ",u]})]})}function gs({isLive:t,isWorking:r}){return r?e.jsxs("span",{"aria-hidden":!0,className:"loading-dots shrink-0 text-[var(--color-accent)]",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):t?e.jsxs("span",{"aria-hidden":!0,className:"relative inline-flex h-2 w-2 shrink-0",children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-[var(--color-accent)] pulse-amber"}),e.jsx("span",{className:"absolute inset-0 rounded-full bg-[var(--color-accent)]"})]}):e.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-[10px] text-[var(--color-accent)]",children:"●"})}const Tt="font-display text-[clamp(1.5rem,3vw,2rem)] font-light leading-[1.15] tracking-[-0.018em] text-[var(--color-fg-primary)]";function vs({title:t,editableValue:r,onTitleEdit:s,isFallback:o,disabled:n,disabledTooltip:a}){const[i,l]=d.useState(!1),[c,u]=d.useState(r),[m,h]=d.useState(!1),[v,g]=d.useState(null),x=d.useRef(null);d.useEffect(()=>{i||u(r)},[i,r]),d.useEffect(()=>{var L;i&&((L=x.current)==null||L.select())},[i]);function y(){u(r),g(null),l(!0)}async function T(){const L=c.trim();if(!L||L===r){l(!1);return}h(!0),g(null);try{await s(L),l(!1)}catch(O){g(O.message)}finally{h(!1)}}return i?e.jsxs("div",{children:[e.jsx("input",{ref:x,value:c,disabled:m,onChange:L=>{u(L.target.value),v&&g(null)},onKeyDown:L=>{L.key==="Enter"?(L.preventDefault(),T()):L.key==="Escape"&&(L.preventDefault(),l(!1),g(null))},onBlur:()=>{!m&&!v&&l(!1)},maxLength:200,className:Tt+" w-full bg-transparent border-b border-[var(--color-accent)] outline-none focus:outline-none disabled:opacity-60"}),v&&e.jsx("p",{className:"mt-1 text-xs text-[var(--color-danger)]",children:v})]}):e.jsxs("div",{className:"group flex items-baseline gap-3",children:[e.jsxs("h1",{className:Tt+(o?" font-mono":""),children:[t,e.jsx("span",{className:"text-[var(--color-accent)]",children:"."})]}),e.jsx("button",{type:"button",onClick:y,"aria-label":"Rename",title:n?a??"Rename unavailable":"Rename",disabled:n,className:"flex-shrink-0 rounded-md p-1.5 text-[var(--color-fg-muted)] opacity-0 transition hover:bg-[var(--color-sunken)] hover:text-[var(--color-fg-primary)] focus:opacity-100 group-hover:opacity-100 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-[var(--color-fg-muted)] disabled:opacity-40 disabled:group-hover:opacity-40",children:e.jsx(Cs,{})})]})}function we({label:t,value:r}){return e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("dt",{className:"eyebrow",children:t}),e.jsx("dd",{className:"font-mono text-[12px] tabular-nums text-[var(--color-fg-primary)]",children:r})]})}function js(t){if(!t)return"—";const r=new Date(t);return Number.isNaN(r.getTime())?"—":r.toLocaleDateString("en-GB",{weekday:"short",day:"2-digit",month:"short",year:"numeric"}).toUpperCase().replace(/,/g," ·")}function ys({query:t,onQuery:r,showMeta:s,onShowMeta:o,onlyUser:n,onOnlyUser:a,onlyError:i,onOnlyError:l,shown:c,total:u,hasData:m}){const h=N();return e.jsx("div",{className:"rounded-[var(--radius-input)] border border-[var(--color-hairline)] bg-[var(--color-surface)] px-4 sm:px-5 py-2.5 shadow-[var(--shadow-rise)]",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex flex-1 min-w-[14rem] items-center gap-2 border-b border-[var(--color-hairline)] py-1 transition focus-within:border-[var(--color-accent)]",children:[e.jsx(Ss,{className:"text-[var(--color-fg-muted)]"}),e.jsx("input",{type:"search",value:t,onChange:v=>r(v.target.value),placeholder:h("common.searchPlaceholder"),className:"w-full bg-transparent text-sm text-[var(--color-fg-primary)] placeholder:text-[var(--color-fg-faint)] focus:outline-none"})]}),e.jsx("span",{className:"hidden h-4 w-px bg-[var(--color-hairline-strong)] sm:inline-block"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(De,{checked:s,onChange:o,label:h("common.system")}),e.jsx(De,{checked:n,onChange:a,label:h("common.onlyUser")}),e.jsx(De,{checked:i,onChange:l,label:h("common.onlyError")})]}),m&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden h-4 w-px bg-[var(--color-hairline-strong)] sm:inline-block"}),e.jsx("span",{className:"font-mono text-[11px] tabular-nums text-[var(--color-fg-muted)]",children:h("session.shown",{shown:c,total:u})})]})]})})}function De({checked:t,onChange:r,label:s}){return e.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-1.5",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:o=>r(o.target.checked),className:"sr-only"}),e.jsx("span",{"aria-hidden":!0,className:"font-mono text-[11px] uppercase tracking-[0.16em] transition "+(t?"text-[var(--color-accent)] underline underline-offset-[6px] decoration-[var(--color-accent)]/50":"text-[var(--color-fg-faint)] hover:text-[var(--color-fg-secondary)]"),children:s})]})}function Rt({tone:t,className:r="",children:s}){const o=t==="warn"?"border-[var(--color-accent)]/40 bg-[var(--color-accent-soft)] text-[var(--color-accent-ink)] dark:text-[var(--color-fg-primary)]":"border-[var(--color-danger)]/40 bg-[var(--color-danger-soft)] text-[var(--color-danger)]";return e.jsx("div",{className:`rounded-[10px] border px-4 py-3 text-sm ${o} ${r}`,children:s})}function bs(t){return t.type!=="user"?!1:t.blocks.length===0?!0:t.blocks.some(r=>r.type!=="tool_result")}function ks(t){return t.blocks.some(r=>r.type==="tool_result"&&r.isError)}function ws(t){return t.blocks.map(Ns).join(`
10
+ `).toLowerCase()}function Ns(t){switch(t.type){case"text":case"thinking":return t.text;case"tool_use":return`${t.name} ${JSON.stringify(t.input)}`;case"tool_result":return t.content;case"image":return"";default:return JSON.stringify(t.raw)}}function Ss({className:t=""}){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",className:t,"aria-hidden":!0,children:[e.jsx("circle",{cx:"11",cy:"11",r:"6.2"}),e.jsx("path",{d:"M20 20l-4.3-4.3"})]})}function rr(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M8 6V4.5A1.5 1.5 0 0 1 9.5 3h5A1.5 1.5 0 0 1 16 4.5V6"}),e.jsx("path",{d:"M5.5 6l1.1 13.2A1.5 1.5 0 0 0 8.1 20.5h7.8a1.5 1.5 0 0 0 1.5-1.3L18.5 6"})]})}function or(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M3 5h6l2 2h10"}),e.jsx("path",{d:"M3 5v14h18V9H3"})]})}function Cs(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}const It=320;function Ls(){const t=N(),[r,s]=d.useState(!1),[o,n]=d.useState(!1);if(d.useEffect(()=>{let i=0;const l=()=>{i=0;const u=window.scrollY,m=window.innerHeight,h=document.documentElement.scrollHeight;s(u>=It),n(h-(u+m)>=It)},c=()=>{i||(i=requestAnimationFrame(l))};return l(),window.addEventListener("scroll",c,{passive:!0}),window.addEventListener("resize",c,{passive:!0}),()=>{window.removeEventListener("scroll",c),window.removeEventListener("resize",c),i&&cancelAnimationFrame(i)}},[]),!r&&!o)return null;const a="rounded-full border border-[var(--color-hairline)] bg-[var(--color-surface)] p-2.5 text-[var(--color-fg-secondary)] shadow-[var(--shadow-pop)] transition hover:border-[var(--color-accent)] hover:text-[var(--color-accent)]";return e.jsxs("div",{className:"fixed bottom-6 right-6 z-30 flex flex-col gap-2",children:[r&&e.jsx("button",{type:"button","aria-label":t("common.scrollToTop"),title:t("common.scrollToTop"),onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),className:a,children:e.jsx(Dt,{direction:"up"})}),o&&e.jsx("button",{type:"button","aria-label":t("common.scrollToBottom"),title:t("common.scrollToBottom"),onClick:()=>window.scrollTo({top:document.documentElement.scrollHeight,behavior:"smooth"}),className:a,children:e.jsx(Dt,{direction:"down"})})]})}function Dt({direction:t}){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:t==="up"?"M6 15l6-6 6 6":"M6 9l6 6 6-6"})})}const Es=d.lazy(()=>Ee(()=>import("./DiskUsage-BY6XwffG.js"),__vite__mapDeps([6,1,3,4,5,7]))),Ms=d.lazy(()=>Ee(()=>import("./ProjectMemory-CcE3KbUK.js"),__vite__mapDeps([8,1,3,4,5]))),Ps=d.lazy(()=>Ee(()=>import("./ImportPage-Cwq5bx7G.js"),__vite__mapDeps([9,1,3,4,5])));function Ts(){const[t,r]=d.useState(!1),s=d.useCallback(()=>r(a=>!a),[]),o=d.useCallback(()=>r(!0),[]),n=d.useCallback(()=>r(!1),[]);return Sr("mod+k",s),e.jsxs("div",{className:"flex min-h-dvh",children:[e.jsx(Yr,{onSearchOpen:o}),e.jsx("main",{className:"flex-1 min-w-0",children:e.jsx("div",{className:"mx-auto w-full max-w-6xl px-5 py-8 sm:px-8 lg:px-12",children:e.jsxs(yr,{children:[e.jsx(me,{path:"/",element:e.jsx(ko,{})}),e.jsx(me,{path:"/projects/:projectId",element:e.jsx(uo,{})}),e.jsx(me,{path:"/projects/:projectId/memory",element:e.jsx(d.Suspense,{fallback:e.jsx(Ae,{}),children:e.jsx(Ms,{})})}),e.jsx(me,{path:"/projects/:projectId/sessions/:sessionId",element:e.jsx(xs,{})}),e.jsx(me,{path:"/disk",element:e.jsx(d.Suspense,{fallback:e.jsx(Ae,{}),children:e.jsx(Es,{})})}),e.jsx(me,{path:"/import",element:e.jsx(d.Suspense,{fallback:e.jsx(Ae,{}),children:e.jsx(Ps,{})})})]})})}),e.jsx(Mr,{open:t,onClose:n})]})}function Ae(){const t=N();return e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(je,{label:t("common.loading"),className:"items-center"})})}const Rs=new fr({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1}}}),sr=document.getElementById("root");if(!sr)throw new Error("#root not found");xr.createRoot(sr).render(e.jsx(hr.StrictMode,{children:e.jsx(gr,{client:Rs,children:e.jsx(br,{children:e.jsx(Ts,{})})})}));export{$e as B,Wo as C,je as L,ee as M,oo as P,ie as S,F as a,B as b,qe as c,Oe as d,pe as f,R as q,He as s,N as u};
11
+ //# sourceMappingURL=index-DTbWl1jb.js.map