@karlorz/codexhost-cli-win32-x64 0.18.0-1 → 0.19.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +59 -2
  4. package/app/console-web.js +76 -4
  5. package/app/cpa-live-voice-hook.js +59 -2
  6. package/app/desktop-controller.mjs +290 -12
  7. package/app/host-runtime.mjs +12896 -2966
  8. package/app/plugins/antigravity/plugin.mjs +654 -216
  9. package/app/plugins/claude-code/plugin.mjs +138 -11
  10. package/app/plugins/codebuddy/plugin.mjs +152 -20
  11. package/app/plugins/codex-usage/plugin.mjs +59 -2
  12. package/app/plugins/copilot/plugin.mjs +59 -2
  13. package/app/plugins/cursor-cli/plugin.mjs +134 -12
  14. package/app/plugins/deepseek-harness/manifest.json +2 -2
  15. package/app/plugins/deepseek-harness/plugin.mjs +86 -7
  16. package/app/plugins/devin/plugin.mjs +59 -2
  17. package/app/plugins/grok/plugin.mjs +1093 -970
  18. package/app/plugins/hermes/plugin.mjs +138 -14
  19. package/app/plugins/kimi-code/plugin.mjs +59 -2
  20. package/app/plugins/kiro-cli/plugin.mjs +287 -18
  21. package/app/plugins/omp/plugin.mjs +789 -628
  22. package/app/plugins/opencode/plugin.mjs +59 -2
  23. package/app/plugins/pi/plugin.mjs +786 -660
  24. package/app/plugins/qoder/plugin.mjs +61 -6
  25. package/app/plugins/qoder-cn/plugin.mjs +61 -6
  26. package/app/plugins/qwen-code/plugin.mjs +168 -94
  27. package/app/plugins/workbuddy/plugin.mjs +152 -20
  28. package/app/plugins/zcode/plugin.mjs +132 -5
  29. package/app/renderer-extension.js +426 -39
  30. package/app/web/assets/{index-py6Ho-Dy.js → index-BCyiiDDL.js} +62 -62
  31. package/app/web/assets/index-BNQIOOHE.css +1 -0
  32. package/app/web/codexhost-settings.js +76 -4
  33. package/app/web/index.html +2 -2
  34. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  35. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  36. package/app/web/plugins/deepseek-ai__dsh-client-file-upload/client.js +1 -1
  37. package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +3 -3
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +129 -8
  40. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +8 -6
  41. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +95 -93
  42. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  43. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.excel.js +1 -1
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +16 -16
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
  51. package/app/web-modules/server.mjs +2345 -1518
  52. package/bin/codexhost.exe +0 -0
  53. package/libexec/codexhost-node-repl.exe +0 -0
  54. package/libexec/codexhost-shim.exe +0 -0
  55. package/libexec/codexhost-updater.exe +0 -0
  56. package/package.json +1 -1
  57. package/app/web/assets/index-C3lniEH1.css +0 -1
@@ -1,23 +1,23 @@
1
- window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-workspace`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});let r=e("@deepseek-ai/dsh-client-store"),i=e("@deepseek-ai/cordis"),a=e("react"),o=e("@deepseek-ai/dsh-client-ui-primitives"),s=e("react/jsx-runtime"),c=(e,t)=>()=>t;function l(){let e=(0,r.createSnapshotStore)({searchRequest:0,addRequested:!1,directoryBusy:!1,renameTarget:null,forkError:null}),t=0;return{state:e,search:()=>{e.set({...e.getSnapshot(),searchRequest:e.getSnapshot().searchRequest+1})},add:()=>{e.set(e.getSnapshot().directoryBusy?e.getSnapshot():{...e.getSnapshot(),addRequested:!0})},closeAdd:()=>{e.set({...e.getSnapshot(),addRequested:!1})},directoryBusy:t=>{e.set({...e.getSnapshot(),directoryBusy:t})},rename:(t,n)=>{e.set({...e.getSnapshot(),renameTarget:{sessionId:t,currentTitle:n}})},closeRename:()=>{e.set({...e.getSnapshot(),renameTarget:null})},forkFailed:n=>{t+=1,e.set({...e.getSnapshot(),forkError:{reason:n,seq:t}})},dismissForkError:()=>{e.set({...e.getSnapshot(),forkError:null})}}}function u(e,t,n,r){let i=e.locale.bind(`workspace`),a=()=>Object.values(e.sessions.list.getSnapshot().byId).find(e=>(e.retainedBy.mainView??0)>0),o=()=>e.slots.entries(`sidebar.workspaces.directoryFlow`).length===0?i(`shortcut.noPicker`):n.state.getSnapshot().directoryBusy?i(`shortcut.directoryBusy`):null,s=(t,n,r,i,a,o,s)=>{e.effect(()=>e.shortcuts.register({id:t,label:n,aliases:r,defaults:{"desktop:macos":{code:i,modifiers:a},"desktop:windows":{code:i,modifiers:a},"desktop:linux":{code:i,modifiers:a},"web:macos":{code:i,modifiers:o},"web:windows":{code:i,modifiers:o}},regions:[`page`,`editable`],modals:[],resolve:s}),`ui-workspace: ${t}`)};s(`session.new`,()=>i(`session.new`),[`new session`,`new chat`],`KeyN`,[`primary`],[`primary`,`alt`],()=>({status:`handled`,run:()=>{t.startSession()}})),s(`session.search`,()=>i(`search.sessions.aria`),[`search sessions`],`KeyK`,[`primary`],[`primary`,`alt`],()=>({status:`handled`,run:n.search})),s(`workspace.add`,()=>i(`workspace.add`),[`add workspace`,`open folder`],`KeyO`,[`primary`],[`primary`,`alt`],()=>{let e=o();return e===null?{status:`handled`,run:n.add}:{status:`blocked`,reason:e}}),s(`session.rename`,()=>i(`rename.session.title`),[`rename session`],`KeyG`,[`primary`,`alt`],[`primary`,`alt`],t=>{let r=a();return r===void 0||r.blank||t.modal!==null||e.layout.panelInfo.getSnapshot().activePanelId!==null?{status:`blocked`,reason:i(`shortcut.noSession`)}:{status:`handled`,run:()=>{n.rename(r.id,r.title?.trim()??``)}}}),s(`session.fork`,()=>i(`menu.fork`),[`fork session`],`KeyF`,[`primary`,`alt`],[`primary`,`shift`],()=>{let e=a();return e===void 0?{status:`blocked`,reason:i(`shortcut.noSession`)}:e.blank?{status:`blocked`,reason:i(`shortcut.noCompletedTurn`)}:{status:`handled`,run:()=>{t.forkSession(e.id).catch(e=>{let t=e instanceof Error&&e.name===`SessionForkError`&&e.rpcError.code===`session/fork-unavailable`;n.forkFailed(t?`unavailable`:`failed`),t||console.warn(`session fork rejected:`,e)})}}}),s(`session.archive`,()=>i(`menu.archiveSession`),[`archive session`],`KeyA`,[`primary`,`shift`],[`primary`,`alt`],()=>{let e=a();return e===void 0?{status:`blocked`,reason:i(`shortcut.noSession`)}:{status:`handled`,run:()=>{r(e.id)}}})}let d={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
2
- `,r:`\r`,t:` `},f=/[\\\u0000-\u001f]/u;function p(e){return e===` `||e===`
3
- `||e===`\r`||e===` `}function m(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}(class e{static EMPTY=e.fromObject({});static fromText(t){let n=new e;return n.append(t),n.sealed=!0,n}static fromObject(t){let n=new e;return n.object=typeof t==`object`&&t&&!Array.isArray(t)?t:{},n.sealed=!0,n}chunks=[];object;sealed=!1;#e=[];#t=0;#n=0;#r=`root`;#i=!1;#a=0;#o=!1;#s=``;#c=null;#l=[];#u=!1;#d;#f=!1;#p=/* @__PURE__ */ new Map;#m=[];#h=/* @__PURE__ */ new Map;get isSealed(){return this.sealed}get invalid(){return this.scan(),this.#r===`invalid`||this.#f}append(e){if(this.sealed)throw Error(`PartialArguments: cannot append to a sealed view`);e.length!==0&&(this.chunks.push(e),this.#t+=e.length,this.#e.push(this.#t))}settle(t){if(this.object!==void 0||t.length!==this.#t)return e.fromText(t);let n=0;for(let r of this.chunks){if(!t.startsWith(r,n))return e.fromText(t);n+=r.length}return this.chunks=t.length===0?[]:[t],this.#e=t.length===0?[]:[t.length],this.sealed=!0,this}refresh(){if(this.#h.size===0)return!1;this.scan();let e=!1,t=!1;for(let n of this.#h.values())n.completion?t=!0:e=this.refreshRead(n)||e;if(t)for(let t of this.#h.values())t.completion&&(e=this.refreshRead(t)||e);return this.sealed&&this.#h.clear(),e}refreshRead(e){let t=e.answer();return!Object.is(t,e.last)&&(e.last=t,!0)}closed(){return this.remember(`closed`,``,()=>this.closedNow())}keys(){return this.remember(`keys`,``,()=>this.keysNow(),e=>e.length)}has(e){return this.remember(`has`,e,()=>this.hasNow(e))}complete(e){return this.remember(`complete`,e,()=>this.completeNow(e))}stringLength(e,t){let n=Math.max(1,Math.floor(t?.step??1)),r=t?.offset??0;return this.remember(`length:${n}:${r}`,e,()=>this.lengthNow(e),e=>e===void 0?void 0:Math.ceil((e+r)/n))}stringExceeds(e,t){let n=Math.max(0,Math.floor(t));return this.remember(`exceeds:${n}`,e,()=>(this.lengthNow(e,n+1)??0)>n)}text(e){return this.remember(`text`,e,()=>this.textNow(e))}textPrefix(e,t){let n=Math.max(1,Math.floor(t));return this.remember(`prefix:${n}`,e,()=>this.textPrefixNow(e,n))}value(e){return this.remember(`value`,e,()=>this.valueNow(e))}remember(e,t,n,r){this.scan();let i=n();if(!this.sealed){let a=`${e}/${t}`;this.#h.has(a)||this.#h.set(a,{completion:e===`complete`,answer:r===void 0?n:()=>r(n()),last:r===void 0?i:r(i)})}return i}closedNow(){return this.sealed||this.#r===`closed`||this.#r===`invalid`}keysNow(){return this.object===void 0?this.#m:Object.keys(this.object)}hasNow(e){return this.object===void 0?this.#p.has(e):Object.hasOwn(this.object,e)}completeNow(e){if(this.object!==void 0)return Object.hasOwn(this.object,e);let t=this.#p.get(e);return t!==void 0&&t.end>=0&&(t.kind===`string`?t.invalidAt===void 0:!t.invalid)}lengthNow(e,t=1/0){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t.length:void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;if(n.text!==void 0&&n.text.at===n.end)return n.text.length;let r=n.length??={at:n.start,length:0,text:``};return this.readString(n,r,t,!1),r.length}textNow(e){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t:void 0}let t=this.#p.get(e);if(t?.kind!==`string`)return;if(t.text===void 0&&t.end>=0&&t.needsDecoding&&t.invalidAt===void 0){let e;try{e=JSON.parse(`"${this.slice(t.start,t.end)}"`)}catch{}e!==void 0&&(t.text={at:t.end,length:e.length,text:e})}let n=t.text??={at:t.start,length:0,text:``};return this.readString(t,n,1/0,!0),n.text}textPrefixNow(e,t){if(this.object!==void 0){let n=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof n==`string`?n.slice(0,t):void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;let r=n.prefixes??=/* @__PURE__ */ new Map,i=r.get(t);return i===void 0&&(i={at:n.start,length:0,text:``},r.set(t,i)),this.readString(n,i,t,!0),i.text}valueNow(e){if(this.object!==void 0){if(!Object.hasOwn(this.object,e))return;let t=this.object[e];return typeof t==`string`?void 0:t}let t=this.#p.get(e);if(!(t?.kind!==`value`||t.end<0||t.invalid)){if(t.parsed===void 0)try{t.parsed=JSON.parse(this.slice(t.start,t.end))}catch{t.invalid=!0,this.#f=!0}return t.parsed}}chunkAt(e){let t=0,n=this.#e.length;for(;t<n;){let r=t+n>>>1;this.#e[r]<=e?t=r+1:n=r}return t}slice(e,t){if(e>=t)return``;let n=this.chunkAt(e),r=this.chunkAt(t-1),i=n===0?0:this.#e[n-1];if(n===r)return this.chunks[n].slice(e-i,t-i);let a=[this.chunks[n].slice(e-i)];for(let e=n+1;e<r;e++)a.push(this.chunks[e]);return a.push(this.chunks[r].slice(0,t-this.#e[r-1])),a.join(``)}readString(e,t,n,r){let i=Math.min(e.end<0?this.#n:e.end,e.invalidAt??1/0,this.#d??1/0);if(!e.needsDecoding){let e=Math.min(i-t.at,n-t.length);if(e<=0)return;r&&(t.text+=this.slice(t.at,t.at+e)),t.at+=e,t.length+=e;return}let a=this.chunkAt(t.at);for(;t.at<i&&t.length<n;){let o=a===0?0:this.#e[a-1],s=this.chunks[a],c=s.slice(t.at-o,Math.min(s.length,i-o)),l=c.search(f),u=Math.min(l<0?c.length:l,n-t.length);if(u>0){r&&(t.text+=c.slice(0,u)),t.at+=u,t.length+=u,t.at===o+s.length&&a++;continue}let p=c.length>1?c[1]:t.at+1<i?this.chunks[a+1][0]:void 0,h,g=2;if(c[0]===`\\`&&p===void 0&&e.end<0)return;if(c[0]===`\\`&&p===`u`){let n=this.slice(t.at+2,Math.min(i,t.at+6)),r=!0;for(let e=0;e<n.length;e++)m(n[e])||(r=!1);if(r){if(n.length<4&&e.end<0)return;n.length===4&&(h=String.fromCharCode(Number.parseInt(n,16)))}g=6}else c[0]===`\\`&&p!==void 0&&(h=d[p]);if(h===void 0){e.invalidAt=t.at,this.#f=!0;return}for(r&&(t.text+=h),t.length++,t.at+=g;a<this.chunks.length&&t.at>=this.#e[a];)a++}}scan(){if(this.object===void 0&&this.#n!==this.#t)for(let e=this.chunkAt(this.#n);e<this.chunks.length&&this.#d===void 0;e++){let t=this.chunks[e],n=e===0?0:this.#e[e-1];for(let e=this.#n-n;e<t.length&&this.#r!==`invalid`;e++){if(this.#r===`string`||this.#r===`nested`&&this.#u){let n=this.stringBoundary(t,e);if(this.#n+=n-e,e=n,e===t.length)break}this.step(t[e],this.#n),this.#n++}}}stringBoundary(e,t){let n=t;for(;;){let t=e.indexOf(`"`,n),r=t<0?e.length:t;if(this.#r===`string`){let t=this.#c;!t.needsDecoding&&f.test(e.slice(n,r))&&(t.needsDecoding=!0)}let i=r;for(;i>n&&e[i-1]===`\\`;)i--;let a=(r-i)%2==1!==(i===n&&this.#i);if(this.#i=t<0&&a,t<0||!a)return r;n=t+1}}step(e,t){switch(this.#r){case`root`:if(p(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(p(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(p(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(p(e))return;if(e===`:`){this.#r=`value`;return}this.fail();return;case`value`:this.beginValue(e,t);return;case`string`:{let e=this.#c;e.end=t,this.#c=null,this.#r=`comma-or-end`;return}case`scalar`:this.stepScalar(e,t);return;case`nested`:this.stepNested(e,t);return;case`comma-or-end`:if(p(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(p(e))return;this.fail();return;
1
+ window.__ModuleLoader__.load({id:`@deepseek-ai/dsh-client-ui-workspace`,factory:e=>{var t={exports:{}},n=t.exports;Object.defineProperty(n,Symbol.toStringTag,{value:`Module`});let r=e("@deepseek-ai/dsh-client-store"),i=e("@deepseek-ai/cordis"),a=e("react"),o=e("@deepseek-ai/dsh-client-ui-primitives"),s=e("react/jsx-runtime"),c=(e,t)=>()=>t;function l(){let e=(0,r.createSnapshotStore)({searchRequest:0,addRequested:!1,directoryBusy:!1,renameTarget:null,forkError:null}),t=0;return{state:e,search:()=>{e.set({...e.getSnapshot(),searchRequest:e.getSnapshot().searchRequest+1})},add:()=>{e.set(e.getSnapshot().directoryBusy?e.getSnapshot():{...e.getSnapshot(),addRequested:!0})},closeAdd:()=>{e.set({...e.getSnapshot(),addRequested:!1})},directoryBusy:t=>{e.set({...e.getSnapshot(),directoryBusy:t})},rename:(t,n)=>{e.set({...e.getSnapshot(),renameTarget:{sessionId:t,currentTitle:n}})},closeRename:()=>{e.set({...e.getSnapshot(),renameTarget:null})},forkFailed:n=>{t+=1,e.set({...e.getSnapshot(),forkError:{reason:n,seq:t}})},dismissForkError:()=>{e.set({...e.getSnapshot(),forkError:null})}}}function u(e,t,n,r){let i=e.locale.bind(`workspace`),a=()=>Object.values(e.sessions.list.getSnapshot().byId).find(e=>(e.retainedBy.mainView??0)>0),o=()=>e.slots.entries(`sidebar.workspaces.directoryFlow`).length===0?i(`shortcut.noPicker`):n.state.getSnapshot().directoryBusy?i(`shortcut.directoryBusy`):null,s=(t,n,r,i,a,o,s)=>{e.effect(()=>e.shortcuts.register({id:t,label:n,aliases:r,defaults:{"desktop:macos":{code:i,modifiers:a},"desktop:windows":{code:i,modifiers:a},"desktop:linux":{code:i,modifiers:a},"web:macos":{code:i,modifiers:o},"web:windows":{code:i,modifiers:o}},regions:[`page`,`editable`],modals:[],resolve:s}),`ui-workspace: ${t}`)};s(`session.new`,()=>i(`session.new`),[`new session`,`new chat`],`KeyN`,[`primary`],[`primary`,`alt`],()=>({status:`handled`,run:()=>{t.startSession()}})),s(`session.search`,()=>i(`search.sessions.aria`),[`search sessions`],`KeyK`,[`primary`],[`primary`,`alt`],()=>({status:`handled`,run:n.search})),s(`workspace.add`,()=>i(`workspace.add`),[`add workspace`,`open folder`],`KeyO`,[`primary`],[`primary`,`alt`],()=>{let e=o();return e===null?{status:`handled`,run:n.add}:{status:`blocked`,reason:e}}),s(`session.rename`,()=>i(`rename.session.title`),[`rename session`],`KeyG`,[`primary`,`alt`],[`primary`,`alt`],t=>{let r=a();return r===void 0||r.blank||t.modal!==null||e.layout.panelInfo.getSnapshot().activePanelId!==null?{status:`blocked`,reason:i(`shortcut.noSession`)}:{status:`handled`,run:()=>{n.rename(r.id,r.title?.trim()??``)}}}),s(`session.fork`,()=>i(`menu.fork`),[`fork session`],`KeyF`,[`primary`,`alt`],[`primary`,`shift`],()=>{let e=a();return e===void 0?{status:`blocked`,reason:i(`shortcut.noSession`)}:e.blank?{status:`blocked`,reason:i(`shortcut.noCompletedTurn`)}:{status:`handled`,run:()=>{t.forkSession(e.id).catch(e=>{let t=e instanceof Error&&e.name===`SessionForkError`&&e.rpcError.code===`session/fork-unavailable`;n.forkFailed(t?`unavailable`:`failed`),t||console.warn(`session fork rejected:`,e)})}}}),s(`session.archive`,()=>i(`menu.archiveSession`),[`archive session`],`KeyA`,[`primary`,`shift`],[`primary`,`alt`],()=>{let e=a();return e===void 0?{status:`blocked`,reason:i(`shortcut.noSession`)}:{status:`handled`,run:()=>{r(e.id)}}})}function d(e){return e}function f(e){return d(e)}let p={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
2
+ `,r:`\r`,t:` `},m=/[\\\u0000-\u001f]/u;function h(e){return e===` `||e===`
3
+ `||e===`\r`||e===` `}function g(e){return e>=`0`&&e<=`9`||e>=`a`&&e<=`f`||e>=`A`&&e<=`F`}(class e{static EMPTY=e.fromObject({});static fromText(t){let n=new e;return n.append(t),n.sealed=!0,n}static fromObject(t){let n=new e;return n.object=typeof t==`object`&&t&&!Array.isArray(t)?t:{},n.sealed=!0,n}chunks=[];object;sealed=!1;#e=[];#t=0;#n=0;#r=`root`;#i=!1;#a=0;#o=!1;#s=``;#c=null;#l=[];#u=!1;#d;#f=!1;#p=/* @__PURE__ */ new Map;#m=[];#h=/* @__PURE__ */ new Map;get isSealed(){return this.sealed}get invalid(){return this.scan(),this.#r===`invalid`||this.#f}append(e){if(this.sealed)throw Error(`PartialArguments: cannot append to a sealed view`);e.length!==0&&(this.chunks.push(e),this.#t+=e.length,this.#e.push(this.#t))}settle(t){if(this.object!==void 0||t.length!==this.#t)return e.fromText(t);let n=0;for(let r of this.chunks){if(!t.startsWith(r,n))return e.fromText(t);n+=r.length}return this.chunks=t.length===0?[]:[t],this.#e=t.length===0?[]:[t.length],this.sealed=!0,this}refresh(){if(this.#h.size===0)return!1;this.scan();let e=!1,t=!1;for(let n of this.#h.values())n.completion?t=!0:e=this.refreshRead(n)||e;if(t)for(let t of this.#h.values())t.completion&&(e=this.refreshRead(t)||e);return this.sealed&&this.#h.clear(),e}refreshRead(e){let t=e.answer();return!Object.is(t,e.last)&&(e.last=t,!0)}closed(){return this.remember(`closed`,``,()=>this.closedNow())}keys(){return this.remember(`keys`,``,()=>this.keysNow(),e=>e.length)}has(e){return this.remember(`has`,e,()=>this.hasNow(e))}complete(e){return this.remember(`complete`,e,()=>this.completeNow(e))}stringLength(e,t){let n=Math.max(1,Math.floor(t?.step??1)),r=t?.offset??0;return this.remember(`length:${n}:${r}`,e,()=>this.lengthNow(e),e=>e===void 0?void 0:Math.ceil((e+r)/n))}stringExceeds(e,t){let n=Math.max(0,Math.floor(t));return this.remember(`exceeds:${n}`,e,()=>(this.lengthNow(e,n+1)??0)>n)}text(e){return this.remember(`text`,e,()=>this.textNow(e))}textPrefix(e,t){let n=Math.max(1,Math.floor(t));return this.remember(`prefix:${n}`,e,()=>this.textPrefixNow(e,n))}value(e){return this.remember(`value`,e,()=>this.valueNow(e))}remember(e,t,n,r){this.scan();let i=n();if(!this.sealed){let a=`${e}/${t}`;this.#h.has(a)||this.#h.set(a,{completion:e===`complete`,answer:r===void 0?n:()=>r(n()),last:r===void 0?i:r(i)})}return i}closedNow(){return this.sealed||this.#r===`closed`||this.#r===`invalid`}keysNow(){return this.object===void 0?this.#m:Object.keys(this.object)}hasNow(e){return this.object===void 0?this.#p.has(e):Object.hasOwn(this.object,e)}completeNow(e){if(this.object!==void 0)return Object.hasOwn(this.object,e);let t=this.#p.get(e);return t!==void 0&&t.end>=0&&(t.kind===`string`?t.invalidAt===void 0:!t.invalid)}lengthNow(e,t=1/0){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t.length:void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;if(n.text!==void 0&&n.text.at===n.end)return n.text.length;let r=n.length??={at:n.start,length:0,text:``};return this.readString(n,r,t,!1),r.length}textNow(e){if(this.object!==void 0){let t=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof t==`string`?t:void 0}let t=this.#p.get(e);if(t?.kind!==`string`)return;if(t.text===void 0&&t.end>=0&&t.needsDecoding&&t.invalidAt===void 0){let e;try{e=JSON.parse(`"${this.slice(t.start,t.end)}"`)}catch{}e!==void 0&&(t.text={at:t.end,length:e.length,text:e})}let n=t.text??={at:t.start,length:0,text:``};return this.readString(t,n,1/0,!0),n.text}textPrefixNow(e,t){if(this.object!==void 0){let n=Object.hasOwn(this.object,e)?this.object[e]:void 0;return typeof n==`string`?n.slice(0,t):void 0}let n=this.#p.get(e);if(n?.kind!==`string`)return;let r=n.prefixes??=/* @__PURE__ */ new Map,i=r.get(t);return i===void 0&&(i={at:n.start,length:0,text:``},r.set(t,i)),this.readString(n,i,t,!0),i.text}valueNow(e){if(this.object!==void 0){if(!Object.hasOwn(this.object,e))return;let t=this.object[e];return typeof t==`string`?void 0:t}let t=this.#p.get(e);if(!(t?.kind!==`value`||t.end<0||t.invalid)){if(t.parsed===void 0)try{t.parsed=JSON.parse(this.slice(t.start,t.end))}catch{t.invalid=!0,this.#f=!0}return t.parsed}}chunkAt(e){let t=0,n=this.#e.length;for(;t<n;){let r=t+n>>>1;this.#e[r]<=e?t=r+1:n=r}return t}slice(e,t){if(e>=t)return``;let n=this.chunkAt(e),r=this.chunkAt(t-1),i=n===0?0:this.#e[n-1];if(n===r)return this.chunks[n].slice(e-i,t-i);let a=[this.chunks[n].slice(e-i)];for(let e=n+1;e<r;e++)a.push(this.chunks[e]);return a.push(this.chunks[r].slice(0,t-this.#e[r-1])),a.join(``)}readString(e,t,n,r){let i=Math.min(e.end<0?this.#n:e.end,e.invalidAt??1/0,this.#d??1/0);if(!e.needsDecoding){let e=Math.min(i-t.at,n-t.length);if(e<=0)return;r&&(t.text+=this.slice(t.at,t.at+e)),t.at+=e,t.length+=e;return}let a=this.chunkAt(t.at);for(;t.at<i&&t.length<n;){let o=a===0?0:this.#e[a-1],s=this.chunks[a],c=s.slice(t.at-o,Math.min(s.length,i-o)),l=c.search(m),u=Math.min(l<0?c.length:l,n-t.length);if(u>0){r&&(t.text+=c.slice(0,u)),t.at+=u,t.length+=u,t.at===o+s.length&&a++;continue}let d=c.length>1?c[1]:t.at+1<i?this.chunks[a+1][0]:void 0,f,h=2;if(c[0]===`\\`&&d===void 0&&e.end<0)return;if(c[0]===`\\`&&d===`u`){let n=this.slice(t.at+2,Math.min(i,t.at+6)),r=!0;for(let e=0;e<n.length;e++)g(n[e])||(r=!1);if(r){if(n.length<4&&e.end<0)return;n.length===4&&(f=String.fromCharCode(Number.parseInt(n,16)))}h=6}else c[0]===`\\`&&d!==void 0&&(f=p[d]);if(f===void 0){e.invalidAt=t.at,this.#f=!0;return}for(r&&(t.text+=f),t.length++,t.at+=h;a<this.chunks.length&&t.at>=this.#e[a];)a++}}scan(){if(this.object===void 0&&this.#n!==this.#t)for(let e=this.chunkAt(this.#n);e<this.chunks.length&&this.#d===void 0;e++){let t=this.chunks[e],n=e===0?0:this.#e[e-1];for(let e=this.#n-n;e<t.length&&this.#r!==`invalid`;e++){if(this.#r===`string`||this.#r===`nested`&&this.#u){let n=this.stringBoundary(t,e);if(this.#n+=n-e,e=n,e===t.length)break}this.step(t[e],this.#n),this.#n++}}}stringBoundary(e,t){let n=t;for(;;){let t=e.indexOf(`"`,n),r=t<0?e.length:t;if(this.#r===`string`){let t=this.#c;!t.needsDecoding&&m.test(e.slice(n,r))&&(t.needsDecoding=!0)}let i=r;for(;i>n&&e[i-1]===`\\`;)i--;let a=(r-i)%2==1!==(i===n&&this.#i);if(this.#i=t<0&&a,t<0||!a)return r;n=t+1}}step(e,t){switch(this.#r){case`root`:if(h(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(h(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(h(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(h(e))return;if(e===`:`){this.#r=`value`;return}this.fail();return;case`value`:this.beginValue(e,t);return;case`string`:{let e=this.#c;e.end=t,this.#c=null,this.#r=`comma-or-end`;return}case`scalar`:this.stepScalar(e,t);return;case`nested`:this.stepNested(e,t);return;case`comma-or-end`:if(h(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(h(e))return;this.fail();return;
4
4
  /* v8 ignore next 2 -- scan() stops stepping once the view is invalid. */
5
5
  case`invalid`:return;
6
6
  /* v8 ignore next 2 -- Every scanner mode has a handler above. */
7
- default:h(this.#r)}}fail(){this.#d=this.#n,this.#r=`invalid`,this.#c=null}beginKey(e){this.#r=`key`,this.#a=e+1,this.#o=!1,this.#i=!1}stepKey(e,t){if(e<` `){this.fail();return}if(this.#i){this.#i=!1;return}if(e===`\\`){this.#i=!0,this.#o=!0;return}if(e!==`"`)return;let n=this.slice(this.#a,t);if(this.#o)try{this.#s=JSON.parse(`"${n}"`)}catch{this.fail();return}else this.#s=n;this.#r=`colon`}open(e){this.#p.has(this.#s)||this.#m.push(this.#s),this.#p.set(this.#s,e),this.#c=e}beginValue(e,t){p(e)||(e===`"`?(this.open({kind:`string`,start:t+1,end:-1,needsDecoding:!1,invalidAt:void 0,length:void 0,text:void 0,prefixes:void 0}),this.#i=!1,this.#r=`string`):e===`}`||e===`,`||e===`:`||e===`]`?this.fail():(this.open({kind:`value`,start:t,end:-1,parsed:void 0,invalid:!1}),e===`{`||e===`[`?(this.#r=`nested`,this.#l=[e===`{`?`}`:`]`],this.#u=!1,this.#i=!1):this.#r=`scalar`))}stepScalar(e,t){(e===`,`||e===`}`||p(e))&&(this.closeValue(t),this.#r=e===`,`?`key-only`:e===`}`?`closed`:`comma-or-end`)}stepNested(e,t){if(this.#u)this.#u=!1;else if(e===`"`)this.#u=!0;else if(e===`{`||e===`[`)this.#l.push(e===`{`?`}`:`]`);else if(e===`}`||e===`]`){if(this.#l.pop()!==e){this.fail();return}this.#l.length===0&&(this.closeValue(t+1),this.#r=`comma-or-end`)}}closeValue(e){let t=this.#c;t.end=e,this.#c=null}});function h(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}function g(e){return/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)}function _(e,t){if(t===void 0||t===``||g(e)||g(t))return e;let n=t.replace(/\/+$/,``);return n===``||n===`/`?e:e.replace(/\/+$/,``)===n?`~`:e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function v(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return t.slice(n+1)}function y(e){let t=e.projectionValues?.threadReference;if(!e.blank&&t?.hostId&&(t.hostId===`local`||/^remote-(?:ssh(?:-|:)|control:)/u.test(t.hostId)&&t.threadId))return{threadId:t.threadId??e.id,hostId:t.hostId,title:e.title?.replace(/[\s\u0000-\u001f\u007f]+/gu,` `).trim()||e.id.slice(0,8)}}function b(e){return`thread://${encodeURIComponent(e.threadId).replace(/[!'()*]/gu,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}?hostId=${encodeURIComponent(e.hostId)}`}function x(e){let t=`[@${e.title.replace(/[\\`*{}[\]()#+.!_<>|~-]/gu,e=>`\\${e}`)}](${b(e)})`;return{source:`codexhost-thread`,ref:t,label:e.title,appearance:`session`,clipboardText:t}}function S(e,t){return e.find(e=>e.sessionIds.includes(t))?.workspaceId??``}function C(e){return Object.values(e.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id}function w(e){if(e===void 0||e===``)return``;let t=v(e);return t===``?e:t}function T(e,t){return e.flatMap(e=>{let n=t[e];return n===void 0?[]:[{id:e,rank:n.updatedAt}]}).sort((e,t)=>e.rank===t.rank?e.id<t.id?-1:1:t.rank-e.rank).map(e=>e.id)}function E(e,t,n,r){let i=new Map(e.map(e=>[e,e])),a=/* @__PURE__ */ new Set,o=[];for(let e of t??[]){let t=i.get(e);t===void 0||a.has(e)||(o.push(t),a.add(e))}let s=new Set(r?.archivedSessionIds),c=[];for(let e of r?.pinnedSessionIds??[]){let t=i.get(e);t===void 0||a.has(t)||s.has(t)||n[t]===void 0||(c.push(t),a.add(t))}let l=[],u=[];for(let e of T([...i.values()].filter(e=>!a.has(e)),n))s.has(e)?u.push(e):l.push(e);let d=[...c,...o,...l,...u],f=new Set(l),p=e=>{if(!f.delete(e))return;let t=n[e]?.parentId;t!==void 0&&t!==e&&d.includes(t)&&(p(t),d.splice(d.indexOf(e),1),d.splice(d.indexOf(t),0,e))};for(let e of[...l].reverse())p(e);return d}function D(e,t){return t===void 0?[...e]:[t,...e.filter(e=>e!==t)]}function O(e,t,n){if(e.origin===`subagent`||e.blank)return!1;switch(n){case`default`:return!t.has(e.id);case`show`:return!0;case`only`:return t.has(e.id);
7
+ default:_(this.#r)}}fail(){this.#d=this.#n,this.#r=`invalid`,this.#c=null}beginKey(e){this.#r=`key`,this.#a=e+1,this.#o=!1,this.#i=!1}stepKey(e,t){if(e<` `){this.fail();return}if(this.#i){this.#i=!1;return}if(e===`\\`){this.#i=!0,this.#o=!0;return}if(e!==`"`)return;let n=this.slice(this.#a,t);if(this.#o)try{this.#s=JSON.parse(`"${n}"`)}catch{this.fail();return}else this.#s=n;this.#r=`colon`}open(e){this.#p.has(this.#s)||this.#m.push(this.#s),this.#p.set(this.#s,e),this.#c=e}beginValue(e,t){h(e)||(e===`"`?(this.open({kind:`string`,start:t+1,end:-1,needsDecoding:!1,invalidAt:void 0,length:void 0,text:void 0,prefixes:void 0}),this.#i=!1,this.#r=`string`):e===`}`||e===`,`||e===`:`||e===`]`?this.fail():(this.open({kind:`value`,start:t,end:-1,parsed:void 0,invalid:!1}),e===`{`||e===`[`?(this.#r=`nested`,this.#l=[e===`{`?`}`:`]`],this.#u=!1,this.#i=!1):this.#r=`scalar`))}stepScalar(e,t){(e===`,`||e===`}`||h(e))&&(this.closeValue(t),this.#r=e===`,`?`key-only`:e===`}`?`closed`:`comma-or-end`)}stepNested(e,t){if(this.#u)this.#u=!1;else if(e===`"`)this.#u=!0;else if(e===`{`||e===`[`)this.#l.push(e===`{`?`}`:`]`);else if(e===`}`||e===`]`){if(this.#l.pop()!==e){this.fail();return}this.#l.length===0&&(this.closeValue(t+1),this.#r=`comma-or-end`)}}closeValue(e){let t=this.#c;t.end=e,this.#c=null}});function _(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}function v(e){return/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)}function y(e,t){if(t===void 0||t===``||v(e)||v(t))return e;let n=t.replace(/\/+$/,``);return n===``||n===`/`?e:e.replace(/\/+$/,``)===n?`~`:e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function b(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return t.slice(n+1)}function x(e){let t=e.projectionValues?.threadReference;if(!e.blank&&t?.hostId&&(t.hostId===`local`||/^remote-(?:ssh(?:-|:)|control:)/u.test(t.hostId)&&t.threadId))return{threadId:t.threadId??e.id,hostId:t.hostId,title:e.title?.replace(/[\s\u0000-\u001f\u007f]+/gu,` `).trim()||e.id.slice(0,8)}}function S(e){return`thread://${encodeURIComponent(e.threadId).replace(/[!'()*]/gu,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}?hostId=${encodeURIComponent(e.hostId)}`}function C(e){let t=`[@${e.title.replace(/[\\`*{}[\]()#+.!_<>|~-]/gu,e=>`\\${e}`)}](${S(e)})`;return{source:`codexhost-thread`,ref:t,label:e.title,appearance:`session`,clipboardText:t}}function w(e,t){let n=new Map(e.map(e=>[e.id,e])),r=/* @__PURE__ */ new Map;for(let e of n.values()){let i=t(e);i!=null&&n.has(i)&&r.set(e.id,i)}let i=/* @__PURE__ */ new Set;for(let e of n.keys()){let t=[],n=/* @__PURE__ */ new Map,a=e;for(;a!==void 0&&!i.has(a);){let e=n.get(a);if(e!==void 0){for(let n of t.slice(e))r.delete(n);break}n.set(a,t.length),t.push(a),a=r.get(a)}for(let e of t)i.add(e)}let a=/* @__PURE__ */ new Map;for(let e of n.values())a.set(e.id,{...e,tree:{depth:0,parentId:r.get(e.id)??null,children:[],descendantIds:[],descendantCount:0,activity:{running:0,pendingInteraction:0,completed:0},updatedAt:e.updatedAt}});let o=[];for(let e of a.values()){let t=e.tree.parentId===null?void 0:a.get(e.tree.parentId);t===void 0?o.push(e):t.tree.children.push(e)}let s=[],c=[...o];for(let e=c.pop();e!==void 0;e=c.pop()){s.push(e);let t=[...e.tree.children].sort((e,t)=>t.updatedAt-e.updatedAt||e.id.localeCompare(t.id));e.tree.children=t;for(let n of t)n.tree.depth=e.tree.depth+1,c.push(n)}for(let e of s.reverse()){let t=[];for(let n of e.tree.children)t.push(n.id,...n.tree.descendantIds),e.tree.updatedAt=Math.max(e.tree.updatedAt,n.tree.updatedAt),e.tree.activity.running+=Number(n.running)+n.tree.activity.running,e.tree.activity.pendingInteraction+=Number(n.pendingInteraction!==void 0)+n.tree.activity.pendingInteraction,e.tree.activity.completed+=Number(n.completed)+n.tree.activity.completed;e.tree.descendantIds=t,e.tree.descendantCount=t.length}return o}function T(e,t){let n=[],r=[...e].reverse();for(let e=r.pop();e!==void 0;e=r.pop())n.push(e),t[e.id]&&r.push(...[...e.tree?.children??[]].reverse());return n}function E(e,t){return e.find(e=>e.sessionIds.includes(t))?.workspaceId??``}function D(e){return Object.values(e.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id}function O(e){if(e===void 0||e===``)return``;let t=b(e);return t===``?e:t}function k(e,t){return e.flatMap(e=>{let n=t[e];return n===void 0?[]:[{id:e,rank:n.updatedAt}]}).sort((e,t)=>e.rank===t.rank?e.id<t.id?-1:1:t.rank-e.rank).map(e=>e.id)}function A(e,t,n,r){let i=new Map(e.map(e=>[e,e])),a=/* @__PURE__ */ new Set,o=[];for(let e of t??[]){let t=i.get(e);t===void 0||a.has(e)||(o.push(t),a.add(e))}let s=new Set(r?.archivedSessionIds),c=[];for(let e of r?.pinnedSessionIds??[]){let t=i.get(e);t===void 0||a.has(t)||s.has(t)||n[t]===void 0||(c.push(t),a.add(t))}let l=[],u=[];for(let e of k([...i.values()].filter(e=>!a.has(e)),n))s.has(e)?u.push(e):l.push(e);let d=[...c,...o,...l,...u],f=new Set(l),p=e=>{if(!f.delete(e))return;let t=n[e]?.parentId;t!==void 0&&t!==e&&d.includes(t)&&(p(t),d.splice(d.indexOf(e),1),d.splice(d.indexOf(t),0,e))};for(let e of[...l].reverse())p(e);return d}function j(e,t){return t===void 0?[...e]:[t,...e.filter(e=>e!==t)]}function M(e,t,n){if(e.origin===`subagent`||e.blank)return!1;switch(n){case`default`:return!t.has(e.id);case`show`:return!0;case`only`:return t.has(e.id);
8
8
  /* v8 ignore next 2 -- closed-union backstop; only reached if the filter is forged */
9
- default:return h(n)}}function k(e,t,n){let r=[],i=[];for(let a of e)!n.has(a.id)&&t.has(a.id)?r.push(a):i.push(a);return[...r,...i]}function A(e){return e.blank?``:e.title?.trim()??``}function j(e,t,n,r,i,a,o){return{key:e,workspaceId:t,cwd:n,createdAt:r,label:i,sessions:[...a],remote:o}}function ee(e,t,n,r){let i=[];for(let a of t){let t=[];for(let i of a.sessionIds){let a=e.byId[i];a!==void 0&&O(a,n,r)&&t.push(a)}(r!==`only`||t.length!==0)&&i.push(j(a.workspaceId,a.workspaceId,a.path,Date.parse(a.createdAt),a.title,t,a.remote))}let a=T(e.ids,e.byId).map(t=>e.byId[t]).filter(e=>e!==void 0&&O(e,n,r));return a.length>0&&i.push(j(``,void 0,void 0,void 0,``,a)),i}function te(e){switch(e){case`approval`:case`plan-review`:case`question`:return e;default:return}}function M(e,t,n){return e.projectionsBySession[t]?.values.subagentCatalog?.reduce((t,r)=>t+ +((n.get(r.id)?.running??e.byId[r.id]?.running)===!0),0)??0}function N(e,t,n){let r=n.get(e.id),i=te(r?.pendingInteraction?.kind);return{running:r?.running??e.running,runningSubagentCount:M(t,e.id,n),completed:r?.completionUnread===!0,...i===void 0?{}:{pendingInteraction:i}}}function P(e,t,n,r,i){return{id:e.id,reference:y(e),remote:e.projectionValues?.remoteHost??void 0,title:A(e),blank:e.blank,...N(e,t,n),pinned:!i.has(e.id)&&r.has(e.id),archived:i.has(e.id),updatedAt:e.updatedAt}}function F(e,t,n,r,i){let a=new Set(n.archivedSessionIds),o=new Set(n.pinnedSessionIds),s=new Set(i.expandedGroups),c=C(e),l=[];for(let u of ee(e,t,a,n.archivedFilter)){let t=s.has(u.key),n=i.excludePinned?u.sessions.filter(e=>!o.has(e.id)||a.has(e.id)):u.sessions;l.push({key:u.key,workspaceId:u.workspaceId,cwd:u.cwd,createdAt:u.createdAt,label:u.label,remote:u.remote,sessionCount:n.length,expanded:t,containsCurrent:u.sessions.some(e=>e.id===c),sessions:t?k(n,o,a).map(t=>P(t,e,r,o,a)):[]})}return l}function ne(e,t=[]){return[...re(e,[],`show`),...t.filter(t=>e.byId[t]===void 0)]}function re(e,t,n){let r=new Set(t);return e.ids.filter(t=>{let i=e.byId[t];return i!==void 0&&O(i,r,n)})}function ie(e,t,n,r){let i=new Set(n.archivedSessionIds),a=new Set(n.pinnedSessionIds);return k(t.flatMap(t=>{let r=e.byId[t];return r!==void 0&&O(r,i,n.archivedFilter)?[r]:[]}),a,i).map(t=>P(t,e,r,a,i))}function I(e,t,n,r,i,a,o,s){let c=n.trim().toLowerCase();if(c===``)return{items:[],hasMore:!1};let l=new Set(r),u=/* @__PURE__ */ new Map;for(let e of t)for(let t of e.sessionIds)u.has(t)||u.set(t,e.title);let d=e=>u.get(e.id)??w(e.cwd),f=/* @__PURE__ */ new Map;for(let e of o.items)f.has(e.sessionId)||f.set(e.sessionId,e);let p=[];for(let t of e.ids){let n=e.byId[t];n!==void 0&&!n.blank&&O(n,l,i)&&(A(n).toLowerCase().includes(c)||d(n).toLowerCase().includes(c))&&p.push(n)}let m=new Map(p.map(e=>[e.id,e])),h=T(p.map(e=>e.id),e.byId).map(e=>m.get(e)),g=[],_=/* @__PURE__ */ new Set,v=e=>{_.has(e.id)||(_.add(e.id),g.push(e))};for(let e of h)v(e);for(let t of o.items){let n=e.byId[t.sessionId];n!==void 0&&!n.blank&&O(n,l,i)&&v(n)}return{items:g.slice(0,s).map(t=>{let n=f.get(t.id),r=a.get(t.id),i=te(r?.pendingInteraction?.kind);return{id:t.id,title:A(t),workspace:d(t),remote:t.projectionValues?.remoteHost??void 0,running:r?.running??t.running,runningSubagentCount:M(e,t.id,a),...i===void 0?{}:{pendingInteraction:i},completed:r?.completionUnread===!0,archived:l.has(t.id),...n===void 0?{}:{snippet:n.snippet}}}),hasMore:o.hasMore||g.length>s}}function ae(e){return(/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)?e.replaceAll(`\\`,`/`):e).replace(/\/+$/,``)}function oe(e,t){let n=ae(e),r,i=-1;for(let e of t){let t=ae(e);t.length>i&&n!==t&&n.startsWith(`${t}/`)&&(r=e,i=t.length)}return r}let se=`__flat_session_order__`,L=`pinned`,ce=`workspaces`;function le(e,t){return e?.[t]??!0}function R(e,t,n){let r=new Map(Object.entries(n.summaries)),i=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(n.members))if(e!==`__flat_session_order__`)for(let n of t)i.set(n,e);return Object.fromEntries(Object.entries(e).map(([e,n])=>{let a=[...n],o=n[0]===void 0?void 0:r.get(n[0]),s=o?.blank&&(o.retainedBy.mainView??0)>0?1:0;for(let n of t[e]??[]){let t=a.indexOf(n);t===-1?!r.has(n)&&(e===`__flat_session_order__`||!i.has(n)||i.get(n)===e)&&a.splice(s++,0,n):s=t+1}return[e,a]}))}function z(){return(0,r.defineStore)({init:()=>({groupBy:`workspace`,orderBy:`updated`,groupExpansion:{},sectionExpansion:{},sessionOrderByAccount:{},archivedFilter:`default`}),persist:`dsh.workspace.view.v5`,actions:{setGroupBy:(e,t)=>{e.groupBy=t},setOrderBy:(e,t,n,r)=>{t!==e.orderBy&&(e.sessionOrderByAccount=t===`manual`?R(n,e.sessionOrderByAccount,r):{},e.orderBy=t)},setGroupExpanded:(e,t,n)=>{e.groupExpansion[t]=n},setSectionExpanded:(e,t,n)=>{e.sectionExpansion={...e.sectionExpansion,[t]:n}},retainAccountKeys:(e,t)=>{let n=new Set(t);e.groupExpansion=Object.fromEntries(Object.entries(e.groupExpansion).filter(([e])=>n.has(e))),e.sessionOrderByAccount=Object.fromEntries(Object.entries(e.sessionOrderByAccount).filter(([e])=>n.has(e))),delete e.sessionUpdatedAtByAccount},syncSessionOrders:(e,t,n)=>{e.orderBy===`manual`&&Object.assign(e.sessionOrderByAccount,R(t,e.sessionOrderByAccount,n))},setSessionOrder:(e,t,n,r,i)=>{let a=R({...r,[t]:n},e.sessionOrderByAccount,i);e.orderBy===`updated`?e.sessionOrderByAccount=a:Object.assign(e.sessionOrderByAccount,a),e.orderBy=`manual`},pinSessionOrder:(e,t,n,r)=>{let i=new Set(n),a=R(Object.fromEntries(Object.entries(r.members).map(([t,n])=>[t,E(n,e.sessionOrderByAccount[t],r.summaries,r.rowState)])),e.sessionOrderByAccount,r);for(let e of i)a[e]!==void 0&&(a[e]=[t,...a[e].filter(e=>e!==t)]);Object.assign(e.sessionOrderByAccount,a)},setArchivedFilter:(e,t)=>{e.archivedFilter=t}}})}function ue(e,t,n){let r=new Set(e.flatMap(e=>e.sessionIds));return{members:Object.fromEntries([...e.map(e=>[e.workspaceId,e.sessionIds]),[``,[.../* @__PURE__ */ new Set([...t.ids,...n.archivedSessionIds])].filter(e=>!r.has(e))],[se,ne(t,n.archivedSessionIds)]]),summaries:t.byId,rowState:n}}function de(e,t){return[S(e,t),se]}var fe=class{sessions;workspaces;held=/* @__PURE__ */ new Map;recent=/* @__PURE__ */ new Map;running=/* @__PURE__ */ new Set;failed=/* @__PURE__ */ new Set;active=!1;reconciling=!1;dirty=!1;constructor(e,t){this.sessions=e,this.workspaces=t}start(){this.active=!0;let e=this.sessions.list.subscribe(()=>this.reconcile()),t=this.workspaces.list.subscribe(()=>this.reconcile());return this.reconcile(),()=>{this.active=!1,e(),t();let n=[...this.held.values()];this.held.clear(),this.recent.clear(),this.running.clear(),this.failed.clear();for(let{reference:e}of n)e.release()}}visit(e,t){this.active&&(this.failed.delete(e.sessionId),this.remember(e.sessionId,typeof t==`string`?this.sessions.subagentAddress(e.sessionId)??t:t),this.reconcile())}remember(e,t){this.recent.delete(e),this.recent.set(e,t)}reconcile(){if(this.active&&(this.dirty=!0,!this.reconciling)){this.reconciling=!0;try{for(;this.dirty&&this.active;)this.dirty=!1,this.update()}finally{this.reconciling=!1}}}update(){let e=this.sessions.list.getSnapshot(),t=new Set(e.ids),n=new Set(e.summaryOnlyIds??[]),r=new Set(this.workspaces.list.getSnapshot().archivedSessionIds),i=/* @__PURE__ */ new Set;for(let t of e.ids){let a=e.byId[t];a?.running&&a.origin!==`subagent`&&!r.has(t)&&(!n.has(t)||this.recent.has(t))&&i.add(t)}if(e.phase===`pending`)for(let e of this.running)r.has(e)||i.add(e);else for(let e of this.running)!i.has(e)&&t.has(e)&&!r.has(e)&&this.remember(e,e);this.running=i;for(let[n,i]of this.recent)(r.has(n)||this.sessions.binding(n)?.session.getSnapshot().removed||e.phase===`ready`&&!t.has(n)&&typeof i==`string`)&&this.recent.delete(n);let a=[...this.recent.keys()].filter(e=>!i.has(e));for(let e of a.slice(0,Math.max(0,a.length-8)))this.recent.delete(e);let o=new Map(this.recent);for(let e of i)o.set(e,e);for(let e of this.failed)o.has(e)||this.failed.delete(e);for(let[e,t]of this.held){let n=this.sessions.binding(e)!==t.binding;(!o.has(e)||n)&&(this.held.delete(e),n&&(this.recent.delete(e),this.failed.add(e)),t.reference.release())}for(let[e,t]of o){if(this.held.has(e)||this.failed.has(e))continue;let n;try{n=this.sessions.retain(t,{source:`backgroundWarm`});let r={reference:n,binding:n.binding};this.held.set(e,r),n.ready.catch(()=>this.fail(e,r))}catch{this.failed.add(e),n?.release()}}}fail(e,t){this.active&&this.held.get(e)===t&&(this.failed.add(e),this.held.delete(e),t.reference.release())}};function B(e){return e}function pe(e){return B(e)}let me=`codexhost.web.session-tabs.v2:local`,he=`codexhost.web.session-tabs.v1:local`,V=`codexhost.web.recent-visits.v1:local`,ge=1048576;function _e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ve(e){return typeof e==`string`&&e.length>0&&e.length<=1024&&e.trim()===e&&!/[\u0000-\u001f\u007f]/u.test(e)?pe(e):void 0}function ye(e,t){if(typeof e==`string`)return e===t?t:void 0;if(!_e(e)||Object.keys(e).length!==3)return;let n=ve(e.parentSessionId),r=ve(e.childSessionId),i=e.mode;if(!(n===void 0||r!==t||n===r||i!==`one-shot`&&i!==`continuable`&&i!==`unknown`))return{parentSessionId:n,childSessionId:r,mode:i}}function be(e,t){if(e===null||e.length>ge)return[];try{let n=JSON.parse(e);if(!_e(n)||Object.keys(n).length!==2||n.version!==t||!Array.isArray(n.entries))return[];let r=[],i=/* @__PURE__ */ new Set,a=Date.now();for(let e of n.entries){if(!_e(e))continue;let n=Object.keys(e);if(t===2&&n.length!==3||n.length!==2&&(n.length!==3||!Object.hasOwn(e,`lastVisitedAt`)))continue;let o=ve(e.sessionId);if(o===void 0||i.has(o))continue;let s=Object.hasOwn(e,`lastVisitedAt`)?e.lastVisitedAt:a;if(typeof s!=`number`||!Number.isSafeInteger(s)||s<0||s>a)continue;let c=ye(e.target,o);c!==void 0&&(i.add(o),r.push({sessionId:o,target:c,lastVisitedAt:s}))}return r}catch{return[]}}var xe=class{onFailure;enabled=typeof window<`u`&&/^https?:$/u.test(window.location.protocol);reported=!1;constructor(e){this.onFailure=e}read(){if(!this.enabled)return[];try{return this.latest()}catch{return this.failed(),[]}}update(e,t){if(this.enabled)try{let n=this.latest().filter(e=>t?.(e)!==!0),r=new Map(n.map((e,t)=>[e.sessionId,t]));for(let i of e){if(t?.(i)===!0)continue;let e=r.get(i.sessionId);e===void 0?(r.set(i.sessionId,n.length),n.push(i)):n[e]=i}let i=JSON.stringify({version:2,entries:n.map(e=>({sessionId:e.sessionId,lastVisitedAt:e.lastVisitedAt,target:typeof e.target==`string`?e.target:{parentSessionId:e.target.parentSessionId,childSessionId:e.target.childSessionId,mode:e.target.mode}}))});if(i.length>ge){this.failed();return}localStorage.getItem(me)!==i&&localStorage.setItem(me,i),localStorage.removeItem(he),localStorage.removeItem(V)}catch{this.failed()}}latest(){let e=localStorage.getItem(me);return e===null?be(localStorage.getItem(he)??localStorage.getItem(V),1):be(e,2)}failed(){if(!this.reported){this.reported=!0;try{this.onFailure()}catch{}}}},Se=class{sessions;workspaces;subscribeRemoved;entries=(0,r.createSnapshotStore)([]);records=[];current;awaitingFormalSession=!1;active=!1;headRevision=0;restoring=!1;cache;constructor(e,t,n,r=()=>{}){this.sessions=e,this.workspaces=t,this.subscribeRemoved=n,this.cache=new xe(r)}start(e){this.active=!0,this.headRevision=this.sessions.list.getSnapshot().headRefreshRevision??0,this.records=this.cache.read(),this.cache.update([]);let t=this.sessions.list.subscribe(()=>{let t=this.sessions.list.getSnapshot().headRefreshRevision??0;t!==this.headRevision&&(this.headRevision=t,this.restoreSummaries(this.current?.sessionId??e)),this.reconcile()}),n=this.workspaces.list.subscribe(()=>this.reconcile()),r=this.subscribeRemoved?.(e=>{this.sessions.subagentAddress(e)!==void 0||this.sessions.list.getSnapshot().byId[e]?.origin===`subagent`||this.records.some(t=>t.sessionId===e&&typeof t.target!=`string`)||(this.records=this.records.filter(t=>!this.includesIdentity(t,e)),this.cache.update([],t=>this.includesIdentity(t,e)),this.publish())});return this.reconcile(),this.restoreSummaries(e),()=>{this.active=!1,t(),n(),r?.(),this.current=void 0,this.awaitingFormalSession=!1,this.records=[],this.entries.set([])}}visit(e,t){let n=Date.now(),r=this.depart(n);r!==void 0&&this.remember(r),this.current={sessionId:e,target:typeof t==`string`?this.sessions.subagentAddress(e)??t:t,lastVisitedAt:n},this.awaitingFormalSession=!0,this.reconcile(r===void 0?[]:[r])}clearCurrent(){let e=this.depart(Date.now());e!==void 0&&this.remember(e),this.current=void 0,this.awaitingFormalSession=!1,this.reconcile(e===void 0?[]:[e])}depart(e){let t=this.current;return t!==void 0&&this.records.some(e=>e.sessionId===t.sessionId)&&this.formal(t)?{...t,lastVisitedAt:e}:void 0}close(e){this.records=this.records.filter(t=>t.sessionId!==e),this.cache.update([],t=>t.sessionId===e),this.current?.sessionId===e&&(this.awaitingFormalSession=!1),this.publish()}closeAll(){let e=new Set(this.records.map(e=>e.sessionId));this.records=[],this.awaitingFormalSession=!1,this.cache.update([],t=>e.has(t.sessionId)),this.publish()}expireInactive(e,t,n=Date.now()){let r=this.sessions.list.getSnapshot();if(!this.active||!Number.isFinite(e)||e<=0||r.phase!==`ready`||r.loading===!0||r.listError!=null||this.workspaces.list.getSnapshot().phase!==`ready`)return!1;let i=new Set(this.entries.getSnapshot().map(e=>e.sessionId)),a=a=>{let o=r.byId[a.sessionId];if(a.sessionId===this.current?.sessionId||!i.has(a.sessionId)||o===void 0||o.blank||(o.retainedBy.mainView??0)>0||o.running||t.get(a.sessionId)?.pendingInteraction!==void 0||typeof a.target!=`string`&&t.get(a.sessionId)?.running===void 0||!Number.isFinite(o.updatedAt))return!1;let s=N(o,r,t);return s.running||s.runningSubagentCount>0?!1:n-Math.max(a.lastVisitedAt,o.updatedAt)>=e},o=new Set(this.records.filter(a).map(e=>e.sessionId));return o.size!==0&&(this.records=this.records.filter(e=>!o.has(e.sessionId)),this.cache.update([],e=>o.has(e.sessionId)&&a(e)),this.publish(),!0)}remember(e){let t=this.records.findIndex(t=>t.sessionId===e.sessionId);this.records=t===-1?[...this.records,e]:this.records.map((n,r)=>r===t?e:n)}formal(e){let t=this.sessions.list.getSnapshot();return t.byId[e.sessionId]?.blank===!1&&!this.invalid(e,t)}reconcile(e=[]){if(!this.active)return;let t=this.sessions.list.getSnapshot(),n=new Set(this.records.filter(e=>this.invalid(e,t)).map(e=>e.sessionId));this.records=this.records.filter(e=>!n.has(e.sessionId));let r=[...e],i=this.current;this.awaitingFormalSession&&i!==void 0&&this.formal(i)&&(this.awaitingFormalSession=!1,this.remember(i),r.push(i)),this.publish(),(r.length>0||n.size>0)&&this.cache.update(r,e=>n.has(e.sessionId))}publish(){let e=this.sessions.list.getSnapshot(),t=this.workspaces.list.getSnapshot().phase===`ready`,n=this.records.flatMap(n=>{if(!t||e.byId[n.sessionId]?.blank!==!1||this.invalid(n,e))return[];if(typeof n.target==`string`)return[n];let r=this.sessions.subagentAddress(n.sessionId);if(r===void 0||r.parentSessionId!==n.target.parentSessionId||r.childSessionId!==n.sessionId)return[];if(r.mode===n.target.mode)return[n];let i={...n,target:r};return this.records=this.records.map(e=>e===n?i:e),[i]}),r=this.entries.getSnapshot();(n.length!==r.length||n.some((e,t)=>e!==r[t]))&&this.entries.set(n)}restoreSummaries(e=this.current?.sessionId){if(this.restoring)return;let t=this.records.filter(t=>t.sessionId!==e&&this.sessions.list.getSnapshot().byId[t.sessionId]===void 0);if(t.length===0)return;this.restoring=!0;let n=0;Promise.all(Array.from({length:Math.min(4,t.length)},async()=>{for(;this.active;){let e=t[n++];if(e===void 0)return;let r=e.sessionId;if(this.records.some(e=>e.sessionId===r)&&this.sessions.list.getSnapshot().byId[r]===void 0){try{await this.sessions.loadSummary(r)}catch{}this.active&&this.reconcile()}}})).finally(()=>{this.restoring=!1})}includesIdentity(e,t){if(e.sessionId===t)return!0;if(typeof e.target==`string`)return!1;let n=/* @__PURE__ */ new Set,r=e.target.parentSessionId;for(;r!==void 0&&!n.has(r);){if(r===t)return!0;n.add(r),r=this.sessions.subagentAddress(r)?.parentSessionId}return!1}invalid(e,t){let n=this.workspaces.list.getSnapshot().archivedSessionIds,r=e=>n.includes(e)||this.sessions.binding(e)?.session.getSnapshot().removed===!0;if(r(e.sessionId))return!0;if(typeof e.target==`string`)return!1;let i=/* @__PURE__ */ new Set([e.sessionId]),a=e.target;for(;!i.has(a.parentSessionId);){if(r(a.parentSessionId)||Ce(t,a.parentSessionId,a.childSessionId))return!0;i.add(a.parentSessionId);let e=this.sessions.subagentAddress(a.parentSessionId);if(e===void 0)break;a=e}return!1}};function Ce(e,t,n){let r=e.projectionsBySession[t];return e.phase===`ready`&&r?.state!==`loading`&&r?.state!==`error`&&r?.values.subagentCatalog!==void 0&&!r.values.subagentCatalog.some(e=>e.id===n)}var H=class extends Error{rpcError;name=`DirectoryBrowseError`;constructor(e){super(`directory browse failed: ${e.code}: ${e.message}`),this.rpcError=e}},we=class extends i.Service{directoryPicker;workspaces;sessions;view;notify;connecting=/* @__PURE__ */ new Map;lifetime=new AbortController;selection=(0,r.createSnapshotStore)({},{persist:{name:`dsh.sessions.current`}});mainReference;opening=(0,r.createSnapshotStore)({state:`idle`});retryOpen;openingLoad;keepalive;recentVisits;constructor(e,t,n,r,i,a){super(e,`uiWorkspace`),this.directoryPicker=t,this.workspaces=n,this.sessions=r,this.view=i,this.notify=a,this.keepalive=new fe(r,n);let o=e.get(`remote`);this.recentVisits=new Se(r,n,o===void 0?void 0:e=>o.$on(`api-session/removed`,e),()=>a({kind:`recentVisitsStorageFailed`})),e.effect(()=>{let e=this.selection.getSnapshot(),t=this.recentVisits.start(e.subagentAddress?.childSessionId??e.sessionId),n=this.keepalive.start(),r=this.watchNavigation();return()=>{r(),this.lifetime.abort(),n(),t();let e=this.mainReference;this.mainReference=void 0,e?.release()}},`ui-workspace: Workspace navigation policy`)}async connectWorkspace(e){let t=this.workspaces.list.getSnapshot().items.find(t=>t.workspaceId===e);if(t===void 0)throw Error(`uiWorkspace.connectWorkspace: unknown workspace ${e}`);let n=this.connecting.get(e);if(n!==void 0)return n;let r=this.reuseOrCreateBlank(t).finally(()=>{this.connecting.delete(e)});return this.connecting.set(e,r),r}reuseOrCreateBlank(e){let t=this.workspaces.list.getSnapshot().archivedSessionIds,n=this.sessions.list.getSnapshot();for(let r of n.ids){let i=n.byId[r];if(i!==void 0&&i.blank&&i.cwd===e.path&&e.sessionIds.includes(r)&&!t.includes(r))return this.reuseBlank(e.workspaceId,r)}return this.sessions.create({workspaceId:e.workspaceId})}async reuseBlank(e,t){try{return await this.sessions.create({workspaceId:e,sessionId:t})}catch(t){if(Te(t)?.rpcError.code!==`session/writer-held`)throw t;return this.sessions.create({workspaceId:e})}}openSession(e){let t=AbortSignal.any([this.ctx.layout.beginNavigation(),this.lifetime.signal]);this.opening.set({state:`idle`}),this.retryOpen=void 0,typeof e!=`string`||this.sessions.list.getSnapshot().byId[e]!==void 0?this.replaceMain(e,t,`reveal`):this.resolveSession(e,t,()=>{this.replaceMain(e,t,`reveal`)},()=>this.openSession(e))}closeSessionTab(e){this.recentVisits.close(e)}closeAllSessionTabs(){this.recentVisits.closeAll()}retryOpening(){this.retryOpen?.()}async resolveSession(e,t,n,r){if(t.aborted)return;this.openingLoad?.stop(),this.retryOpen=void 0;let i={stop:()=>t.removeEventListener(`abort`,a)},a=()=>{i.stop(),this.openingLoad===i&&(this.openingLoad=void 0,this.opening.set({state:`idle`}),this.retryOpen=void 0)};t.addEventListener(`abort`,a,{once:!0}),this.openingLoad=i,this.opening.set({state:`loading`,sessionId:e});try{if(t.aborted||this.openingLoad!==i||(await this.sessions.loadSummary(e),t.aborted||this.openingLoad!==i))return;if(this.sessions.list.getSnapshot().byId[e]===void 0)throw Error(`Session not found: ${e}`);n(),a()}catch(n){if(t.aborted||this.openingLoad!==i)return;this.retryOpen=r,this.opening.set({state:`error`,sessionId:e,message:Ee(n)})}}async openWorkspace(e,t){let n=AbortSignal.any([this.ctx.layout.beginNavigation(),this.lifetime.signal]),r;try{if(e===null&&!this.workspaces.list.getSnapshot().canStartProjectless)throw Error(`This Host requires a Workspace.`);r=e===null?await this.sessions.create():await this.connectWorkspace(e)}catch(e){throw n.aborted||this.notify({kind:`createFailed`,message:Ee(e)}),e}n.aborted||this.replaceMain(r,n,`reveal`,t)}async forkSession(e,t){return this.sessions.fork({sessionId:e,increaseTitle:!0,...t===void 0?{}:{onCreated:t}})}startSession(e,t){let n=t===void 0?void 0:{...t},r=n!==void 0&&(n.prompt!==void 0||n.clearPreviousDraft===!0),i=this.workspaces.list.getSnapshot(),a=this.sessions.list.getSnapshot(),o=this.mainReference?.sessionId,s=o===void 0?void 0:i.items.find(e=>e.sessionIds.includes(o))?.workspaceId,c=i.phase===`ready`&&a.phase===`ready`?De(i.items,a.byId):void 0,l=e??(i.canStartProjectless?null:s??c);if(l===void 0){if(this.ctx.layout.beginNavigation(),r){this.notify({kind:`createFailed`,message:this.ctx.locale.bind(`workspace`)(`draft.workspaceRequired`)});return}this.clearMain()}else this.openWorkspace(l,r?e=>{let t=this.sessions.binding(e);t===void 0&&this.draftPreparationFailed(),this.prepareDraft(t,n)}:void 0).catch(e=>{console.warn(`new session failed:`,e)})}prepareDraft(e,t){let n=this.ctx.get(`conversation`);n===void 0&&this.draftPreparationFailed(),n.input.requestDraftInitialization(e,t)===`blocked`&&this.draftPreparationFailed()}draftPreparationFailed(){let e=this.ctx.locale.bind(`workspace`)(`draft.initializationFailed`);throw this.notify({kind:`createFailed`,message:e}),Error(e)}async archiveSession(e,t={}){await this.workspaces.archiveSession(e,t),this.mainReference?.sessionId===e&&this.clearMain()}async unarchiveSession(e){await this.workspaces.unarchiveSession(e)}async pinSession(e){await this.workspaces.pinSession(e);let{items:t,pinnedSessionIds:n,archivedSessionIds:r}=this.workspaces.list.getSnapshot();this.view.pinSessionOrder(e,de(t,e),ue(t,this.sessions.list.getSnapshot(),{pinnedSessionIds:n,archivedSessionIds:r}))}async unpinSession(e){await this.workspaces.unpinSession(e)}async pickDirectory(){let e=await this.directoryPicker.pick();if(!e.ok)throw Error(`directory picker failed: ${e.error.message}`);return e.value}async listDirectory(e,t){let n=await this.directoryPicker.list(e,t);if(!n.ok)throw new H(n.error);return n.value}async createDirectory(e,t){let n=await this.directoryPicker.createDirectory(e,t);if(!n.ok)throw new H(n.error);return n.value}watchNavigation(){let e=`waiting`,t=AbortSignal.any([this.ctx.layout.beginNavigation(),this.lifetime.signal]);t.addEventListener(`abort`,()=>{e=`done`},{once:!0});let n=()=>{if(this.lifetime.signal.aborted||this.clearArchivedCurrent()||e!==`waiting`)return;let n=this.workspaces.list.getSnapshot(),r=this.sessions.list.getSnapshot();this.mainReference===void 0?n.phase===`ready`&&r.phase===`ready`&&(e=`connecting`,this.restoreSelection(n,r,t).then(()=>{e=`done`},n=>{t.aborted||(e=`waiting`,console.warn(`initial Session restoration failed:`,n))})):e=`done`},r=this.workspaces.list.subscribe(n),i=this.sessions.list.subscribe(n),a=this.selection.getSnapshot();if(a.sessionId!==void 0||a.subagentAddress!==void 0){if(e=`connecting`,a.subagentAddress!==void 0)this.replaceMain(a.subagentAddress,t,`preserve`),e=`done`;else if(a.sessionId!==void 0){let r=a.sessionId,i=()=>{this.resolveSession(r,t,()=>{this.sessions.list.getSnapshot().byId[r]?.blank===!0?(e=`waiting`,n()):(this.replaceMain(r,t,`preserve`),e=`done`)},i)};i()}}return n(),()=>{this.lifetime.abort(),i(),r()}}async restoreSelection(e,t,n){let r=this.selection.getSnapshot();if(r.subagentAddress!==void 0){this.replaceMain(r.subagentAddress,n,`preserve`);return}let i=r.sessionId===void 0?void 0:t.byId[r.sessionId],a=i===void 0?void 0:e.items.find(e=>e.sessionIds.includes(i.id));if(i!==void 0&&(!i.blank||a===void 0)){this.replaceMain(i.id,n,`preserve`);return}let o;if(i!==void 0&&a!==void 0&&i.cwd===a.path&&!e.archivedSessionIds.includes(i.id)&&(o=await this.reuseBlank(a.workspaceId,i.id)),o===void 0&&e.canStartProjectless&&i===void 0){o=await this.sessions.create(),n.aborted||this.replaceMain(o,n,`preserve`);return}let s=a?.workspaceId??De(e.items,t.byId);if(s===void 0&&e.items.length===0&&t.ids.length===0){let e=await this.initializeDefaultWorkspace(n);if(n.aborted)return;s=e?.workspaceId}o===void 0&&s!==void 0&&(o=await this.connectWorkspace(s)),o!==void 0&&!n.aborted&&this.replaceMain(o,n,`preserve`)}async initializeDefaultWorkspace(e){try{return await this.workspaces.initializeDefault(e)}catch{e.aborted||this.notify({kind:`defaultWorkspaceFailed`});return}}clearArchivedCurrent(){let e=this.mainReference?.sessionId;return e===void 0||!this.workspaces.list.getSnapshot().archivedSessionIds.includes(e)?!1:(this.clearMain(),!0)}clearMain(){let e=this.mainReference;this.mainReference=void 0,this.recentVisits.clearCurrent(),this.selection.set({}),e?.release(),this.ctx.layout.selectPanel(null)}replaceMain(e,t,n,r){t.throwIfAborted();let i=this.sessions.retain(e,{source:`mainView`});try{if(t.throwIfAborted(),r?.(i.sessionId),t.aborted){i.release();return}let n=typeof e==`string`?this.sessions.subagentAddress(i.sessionId):e;this.selection.set({sessionId:i.sessionId,...n===void 0?{}:{subagentAddress:n}})}catch(e){throw i.release(),e}let a=this.mainReference;this.mainReference=i,this.keepalive.visit(i,e),this.recentVisits.visit(i.sessionId,e),a?.release(),n===`reveal`&&this.ctx.layout.selectPanel(null)}};function Te(e){return e instanceof Error&&e.name===`SessionCreateError`?e:void 0}function Ee(e){let t=Te(e);return t===void 0?e instanceof Error?e.message:String(e):`${t.rpcError.code}: ${t.rpcError.message}`}function De(e,t){let n,r=-1/0;for(let i of e){let e=-1/0;for(let n of i.sessionIds){let r=t[n];r!==void 0&&(e=Math.max(e,r.updatedAt))}e===-1/0&&(e=Date.parse(i.createdAt)),(n===void 0||e>r)&&(n=i.workspaceId,r=e)}return n}let Oe=`@deepseek-ai/dsh-client-ui-workspace/RecentShortcut.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Oe)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Oe,e.textContent=`.oOF3UG_shortcut{isolation:isolate;box-sizing:border-box;width:max-content;min-width:0;max-width:min(164px,100% - 24px);min-height:44px;color:var(--dsw-alias-label-primary);background:0 0;border:0;border-radius:8px;flex:none;align-items:center;padding:0;font-size:13px;font-weight:500;line-height:20px;display:inline-flex;position:relative}.oOF3UG_select,.oOF3UG_close{border-radius:inherit;min-height:44px;color:inherit;font:inherit;cursor:pointer;background:0 0;border:0;align-items:center;padding:0;display:inline-flex}.oOF3UG_select{box-sizing:border-box;text-align:start;flex:1;align-self:stretch;gap:6px;min-width:44px;padding-inline-start:8px}.oOF3UG_close{width:44px;color:var(--dsw-alias-label-secondary);flex:0 0 44px;justify-content:center}.oOF3UG_close:active{color:var(--dsw-alias-label-primary)}.oOF3UG_shortcut:before{content:"";z-index:-1;box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l2);border-radius:inherit;background:var(--dsw-alias-bg-module-platform);box-shadow:inset 0 .5px 0 color-mix(in srgb, var(--dsw-alias-bg-layer-1) 65%, transparent), 0 1px 3px color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent);pointer-events:none;position:absolute;inset:6px 0}.oOF3UG_shortcut[data-active]:before{border-width:1px;border-color:color-mix(in srgb, var(--dsw-alias-label-primary) 34%, var(--dsw-alias-border-l2));background:color-mix(in srgb, var(--dsw-alias-bg-module-platform) 90%, var(--dsw-alias-label-primary))}.oOF3UG_shortcut:active:before{background:var(--dsw-alias-button-ghost-active-fill)}@supports (backdrop-filter:blur(8px)){.oOF3UG_shortcut:before{background:color-mix(in srgb, var(--dsw-alias-bg-module-platform) 64%, transparent);backdrop-filter:blur(8px)saturate(115%)}.oOF3UG_shortcut[data-active]:before{background:color-mix(in srgb, color-mix(in srgb, var(--dsw-alias-bg-module-platform) 90%, var(--dsw-alias-label-primary)) 82%, transparent)}.oOF3UG_shortcut:active:before{background:color-mix(in srgb, var(--dsw-alias-button-ghost-active-fill) 82%, transparent)}}.oOF3UG_select:focus-visible,.oOF3UG_close:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:-2px}.oOF3UG_identity{flex:0 0 14px;justify-content:center;align-items:center;width:14px;height:14px;display:inline-flex}.oOF3UG_title{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}.oOF3UG_activity{flex:none;justify-content:center;align-items:center;display:inline-flex}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){.oOF3UG_shortcut:before,.oOF3UG_shortcut[data-active]:before{border-color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-module-platform);backdrop-filter:none;box-shadow:none}.oOF3UG_shortcut[data-active]:before{border-width:1px;border-color:var(--dsw-alias-label-primary)}.oOF3UG_shortcut:active:before{background:var(--dsw-alias-button-ghost-active-fill)}}@media (forced-colors:active){.oOF3UG_shortcut{color:buttontext}.oOF3UG_shortcut:before{backdrop-filter:none;box-shadow:none;background:buttonface;border:1px solid buttontext}.oOF3UG_shortcut[data-active],.oOF3UG_shortcut:active{color:highlighttext}.oOF3UG_shortcut[data-active]:before,.oOF3UG_shortcut:active:before{background:highlight;border-color:highlight}.oOF3UG_close,.oOF3UG_close:active{color:inherit}.oOF3UG_select:focus-visible,.oOF3UG_close:focus-visible{outline-color:highlight}.oOF3UG_shortcut[data-active] .oOF3UG_select:focus-visible,.oOF3UG_shortcut[data-active] .oOF3UG_close:focus-visible{outline-color:highlighttext}}`,document.head.appendChild(e)}var U={activity:`oOF3UG_activity`,close:`oOF3UG_close`,identity:`oOF3UG_identity`,select:`oOF3UG_select`,shortcut:`oOF3UG_shortcut`,title:`oOF3UG_title`};function ke({visit:e,summary:t,identity:n,activityLabel:r,activity:i,active:c,closeLabel:l,closeHint:u,open:d,close:f,restoreNavigationFocus:p}){let m=(0,a.useRef)(null),h=(0,a.useCallback)(e=>{e===null&&m.current?.contains(document.activeElement)&&p(),m.current=e},[p]);return/* @__PURE__ */ (0,s.jsxs)(`div`,{ref:h,className:U.shortcut,"data-active":c||void 0,children:[/* @__PURE__ */ (0,s.jsxs)(`button`,{type:`button`,className:U.select,onMouseDown:e=>e.preventDefault(),title:t.displayTitle,"aria-current":c?`page`:void 0,"aria-label":[t.displayTitle,t.id,r].filter(Boolean).join(` · `),onClick:()=>{c||(p(),d(e.target))},children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:U.identity,children:n}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:U.title,children:t.displayTitle}),i!=null&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:U.activity,title:r,children:i})]}),/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:U.close,onMouseDown:e=>e.preventDefault(),"aria-label":l,title:u,onClick:()=>{p(),f(e.sessionId)},children:/* @__PURE__ */ (0,s.jsx)(o.IconCloseOutlineRegular,{size:12})})]})}let Ae=`@deepseek-ai/dsh-client-ui-workspace/Rows.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ae)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Ae,e.textContent=`._5OaiBG_hostBadge{max-width:96px;color:var(--dsw-alias-label-secondary);flex-shrink:0;align-items:center;gap:6px;font-size:11px;display:inline-flex}._5OaiBG_hostBadge>span:first-child{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}._5OaiBG_hostDot{background:#92949a;border-radius:50%;flex-shrink:0;width:7px;height:7px}._5OaiBG_hostBadge[data-state=connected] ._5OaiBG_hostDot{background:#16a34a}._5OaiBG_hostBadge[data-state=connecting] ._5OaiBG_hostDot{background:#d97706}._5OaiBG_projectRow,._5OaiBG_sessionRow{--dsh-row-surface:var(--dsw-specific-sidebar-fill);border-radius:var(--dsw-radius-md);padding:0 8px;cursor:pointer;-webkit-tap-highlight-color:transparent;user-select:none;color:var(--dsw-alias-label-primary);align-items:center;gap:6px;padding-inline-start:calc(8px + var(--dsh-workspace-indent,0px));display:flex;position:relative}._5OaiBG_projectRow:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen),._5OaiBG_sessionRow:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen){--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 4%, var(--dsw-specific-sidebar-fill));background:var(--dsh-row-surface)}._5OaiBG_sessionRow._5OaiBG_selected{--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, var(--dsw-specific-sidebar-fill));background:var(--dsh-row-surface)}._5OaiBG_sessionRow._5OaiBG_selected:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen){--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 8%, var(--dsw-specific-sidebar-fill))}._5OaiBG_sessionRow,._5OaiBG_searchResultRow{--ch-sidebar-text-primary:#1a1c1f;letter-spacing:normal;color:color-mix(in oklab, var(--ch-sidebar-text-primary) 85%, transparent);font-family:-apple-system,"system-ui",Segoe UI,sans-serif;font-size:14px;font-weight:430;line-height:20px}body[data-ds-dark-theme] ._5OaiBG_sessionRow,body[data-ds-dark-theme] ._5OaiBG_searchResultRow{--ch-sidebar-text-primary:#fff}._5OaiBG_projectRow:focus-visible,._5OaiBG_sessionRow:focus-visible,._5OaiBG_iconButton:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}._5OaiBG_searchResultRow{box-sizing:border-box;border-radius:var(--dsw-radius-lg);cursor:pointer;text-align:left;background:0 0;border:none;flex-direction:column;align-items:stretch;width:100%;min-height:48px;padding:4px 8px;display:flex}._5OaiBG_searchResultRow:hover,._5OaiBG_searchResultRow._5OaiBG_selected{background:var(--dsw-alias-interactive-bg-hover)}._5OaiBG_searchResultHeading{align-items:center;min-width:0;display:flex}._5OaiBG_searchResultTitle{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;margin-left:4px;font-size:14px;line-height:20px;overflow:hidden}._5OaiBG_searchResultMeta{align-items:center;gap:6px;min-width:0;margin-left:20px;display:flex}._5OaiBG_searchResultWorkspace,._5OaiBG_searchResultSnippet{text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:17px;overflow:hidden}._5OaiBG_searchResultWorkspace{max-width:40%;color:var(--dsw-alias-label-tertiary);flex:none}._5OaiBG_searchResultWorkspace:only-child{max-width:100%}._5OaiBG_searchResultSnippet{min-width:0;color:var(--dsw-alias-label-secondary);flex:1}._5OaiBG_projectRow{box-sizing:border-box;align-items:center;height:34px}._5OaiBG_sessionRow{gap:0;height:32px}._5OaiBG_sessionRow ._5OaiBG_title{margin:0 6px 0 4px}._5OaiBG_slot{width:16px;height:20px;color:var(--dsw-alias-label-tertiary);flex:none;justify-content:center;align-items:center;display:inline-flex;position:relative}._5OaiBG_slot:has([data-harness-id]){width:14px;color:inherit}._5OaiBG_sessionRow:has([data-harness-id]) ._5OaiBG_title,._5OaiBG_searchResultHeading:has([data-harness-id]) ._5OaiBG_searchResultTitle{margin-left:8px}._5OaiBG_statusOverlay{display:contents}._5OaiBG_slot:has([data-harness-id]) ._5OaiBG_statusOverlay{transform-origin:100% 100%;display:inline-flex;position:absolute;bottom:-3px;right:-3px;transform:scale(.65)}._5OaiBG_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}._5OaiBG_projectRow>._5OaiBG_slot:not(._5OaiBG_folderExpanded){color:inherit}._5OaiBG_folderExpanded{color:var(--dsw-alias-state-business-primary)}._5OaiBG_projectText{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}._5OaiBG_title{text-overflow:ellipsis;white-space:nowrap;min-width:0;font-size:14px;line-height:20px;overflow:hidden}._5OaiBG_renameInput{border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-button-elevated-fill);min-width:0;color:inherit;outline:none;padding:0 2px;font-size:14px;line-height:20px}._5OaiBG_sessionRow ._5OaiBG_title{flex:1}._5OaiBG_meta{text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:20px;overflow:hidden}._5OaiBG_trailing{flex:none;place-items:center end;display:grid}._5OaiBG_trailing:empty{display:none}._5OaiBG_trailing>*{grid-area:1/1}._5OaiBG_time{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-tertiary);flex:none;font-size:10px;line-height:16px}._5OaiBG_timeStatus{justify-content:center;align-items:center;gap:6px;min-width:16px;height:20px;display:inline-flex}._5OaiBG_timeStatus [data-state=done]{color:var(--dsw-alias-state-business-primary)}._5OaiBG_timeStatus ._5OaiBG_visuallyHidden{visibility:visible}._5OaiBG_sessionRow._5OaiBG_archived ._5OaiBG_title,._5OaiBG_searchResultRow._5OaiBG_archived ._5OaiBG_searchResultTitle,._5OaiBG_searchResultRow._5OaiBG_archived ._5OaiBG_searchResultWorkspace,._5OaiBG_searchResultRow._5OaiBG_archived ._5OaiBG_searchResultSnippet{color:var(--dsw-alias-label-caption)}._5OaiBG_dot{flex:none}._5OaiBG_quickActions{align-items:center;gap:2px;display:inline-flex}._5OaiBG_rowActions{visibility:hidden;pointer-events:none;flex:none;align-items:center;gap:2px;display:inline-flex}._5OaiBG_projectRow:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen) ._5OaiBG_rowActions,._5OaiBG_sessionRow:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen) ._5OaiBG_rowActions,._5OaiBG_searchResultRow:is(:hover,:focus-visible,:has(:focus-visible)) ._5OaiBG_rowActions{visibility:visible;pointer-events:auto}._5OaiBG_searchResultHeading ._5OaiBG_rowActions{margin-left:auto}._5OaiBG_sessionRow:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen) ._5OaiBG_time{visibility:hidden}@media (hover:hover) and (pointer:fine){._5OaiBG_projectRow>._5OaiBG_rowActions,._5OaiBG_sessionRow ._5OaiBG_rowActions{inset-inline-end:8px;z-index:1;background:var(--dsh-row-surface);border-radius:var(--dsw-radius-sm);position:absolute;top:50%;transform:translateY(-50%)}._5OaiBG_projectRow>._5OaiBG_rowActions:before,._5OaiBG_sessionRow ._5OaiBG_rowActions:before{content:"";background:linear-gradient(to right, transparent, var(--dsh-row-surface));pointer-events:none;width:12px;position:absolute;inset-block:0;inset-inline-end:100%}}[data-phone-drawer] ._5OaiBG_sessionRow{height:48px;min-height:48px}._5OaiBG_phoneDetails{padding:8px 8px 16px}._5OaiBG_phoneDetails ._5OaiBG_hoverTitle{display:none}._5OaiBG_phoneDetails :is(._5OaiBG_hoverTitle,._5OaiBG_hoverTime,._5OaiBG_hoverStatus,._5OaiBG_hoverPath){color:inherit}._5OaiBG_sessionRow._5OaiBG_dropBefore,._5OaiBG_sessionRow._5OaiBG_dropAfter{position:relative}._5OaiBG_sessionRow._5OaiBG_dropBefore:before,._5OaiBG_sessionRow._5OaiBG_dropAfter:after{content:"";z-index:1;background:linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat, linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat, linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;pointer-events:none;height:12px;position:absolute;left:0;right:4px}._5OaiBG_sessionRow._5OaiBG_dropBefore:before{top:-7px}._5OaiBG_sessionRow._5OaiBG_dropAfter:after{bottom:-7px}._5OaiBG_hoverContent{flex-direction:column;gap:8px;display:flex}._5OaiBG_hoverTitle{color:#fff;overflow-wrap:break-word;font-size:14px;line-height:20px}._5OaiBG_hoverPath{color:#cfd3d6;word-break:break-all;font-size:12px;line-height:16px}._5OaiBG_hoverTime{color:#cfd3d6;font-size:12px;line-height:16px}._5OaiBG_hoverStatus{color:#adb2b8;align-items:center;gap:8px;font-size:12px;line-height:20px;display:flex}._5OaiBG_hoverArchived svg{flex-shrink:0;margin:0 -4px}._5OaiBG_iconButton{cursor:pointer;-webkit-tap-highlight-color:transparent;width:24px;height:24px;color:var(--dsw-alias-label-tertiary);background:0 0;border:none;border-radius:4px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}._5OaiBG_iconButton:hover{color:var(--dsw-alias-label-primary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent)}[data-phone-drawer] :is(._5OaiBG_projectRow,._5OaiBG_sessionRow){--dsh-row-surface:transparent;background:var(--dsh-row-surface)}[data-phone-drawer] :is(._5OaiBG_projectRow,._5OaiBG_sessionRow):is(:active,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen){--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 3%, transparent)}[data-phone-drawer] ._5OaiBG_sessionRow._5OaiBG_selected{--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}[data-phone-drawer] ._5OaiBG_rowActions,[data-phone-drawer] ._5OaiBG_rowActions:before{background:0 0}[data-phone-drawer] ._5OaiBG_iconButton{width:44px;height:44px;color:var(--dsw-alias-label-tertiary);background:0 0}[data-phone-drawer] ._5OaiBG_iconButton:active{color:var(--dsw-alias-label-primary)}@media (hover:none),(pointer:coarse){._5OaiBG_projectRow,._5OaiBG_sessionRow{min-height:44px}._5OaiBG_rowActions{visibility:visible;pointer-events:auto}._5OaiBG_sessionRow ._5OaiBG_quickActions{display:none}._5OaiBG_sessionRow ._5OaiBG_trailing{align-items:center;gap:4px;display:flex}._5OaiBG_sessionRow ._5OaiBG_time:not(._5OaiBG_timeStatus){display:none}._5OaiBG_sessionRow ._5OaiBG_timeStatus{visibility:visible;padding-inline-end:0}._5OaiBG_iconButton{width:44px;height:44px}}`,document.head.appendChild(e)}var W={archived:`_5OaiBG_archived`,dot:`_5OaiBG_dot`,dropAfter:`_5OaiBG_dropAfter`,dropBefore:`_5OaiBG_dropBefore`,folderExpanded:`_5OaiBG_folderExpanded`,hostBadge:`_5OaiBG_hostBadge`,hostDot:`_5OaiBG_hostDot`,hoverArchived:`_5OaiBG_hoverArchived`,hoverContent:`_5OaiBG_hoverContent`,hoverPath:`_5OaiBG_hoverPath`,hoverStatus:`_5OaiBG_hoverStatus`,hoverTime:`_5OaiBG_hoverTime`,hoverTitle:`_5OaiBG_hoverTitle`,iconButton:`_5OaiBG_iconButton`,menuOpen:`_5OaiBG_menuOpen`,meta:`_5OaiBG_meta`,phoneDetails:`_5OaiBG_phoneDetails`,projectRow:`_5OaiBG_projectRow`,projectText:`_5OaiBG_projectText`,quickActions:`_5OaiBG_quickActions`,renameInput:`_5OaiBG_renameInput`,rowActions:`_5OaiBG_rowActions`,searchResultHeading:`_5OaiBG_searchResultHeading`,searchResultMeta:`_5OaiBG_searchResultMeta`,searchResultRow:`_5OaiBG_searchResultRow`,searchResultSnippet:`_5OaiBG_searchResultSnippet`,searchResultTitle:`_5OaiBG_searchResultTitle`,searchResultWorkspace:`_5OaiBG_searchResultWorkspace`,selected:`_5OaiBG_selected`,sessionRow:`_5OaiBG_sessionRow`,slot:`_5OaiBG_slot`,statusOverlay:`_5OaiBG_statusOverlay`,time:`_5OaiBG_time`,timeStatus:`_5OaiBG_timeStatus`,title:`_5OaiBG_title`,trailing:`_5OaiBG_trailing`,visuallyHidden:`_5OaiBG_visuallyHidden`};function je(e,t){let n=e.runningSubagentCount===0?void 0:{state:`ongoing`,label:t(e.runningSubagentCount===1?`status.subagentsRunning.one`:`status.subagentsRunning.other`,{n:e.runningSubagentCount})},r;switch(e.pendingInteraction){case`approval`:r={state:`warning`,label:t(`status.waitingApproval`),trailingLabel:t(`status.compact.approval`)};break;case`plan-review`:r={state:`warning`,label:t(`status.planReview`),trailingLabel:t(`status.compact.planReview`)};break;case`question`:r={state:`warning`,label:t(`status.waitingAnswer`),trailingLabel:t(`status.compact.answer`)};break;case void 0:break;default:return Me(e.pendingInteraction)}if(r!==void 0)return n===void 0?[r]:[r,n];if(e.running){let e={state:`ongoing`,label:t(`status.running`)};return n===void 0?[e]:[e,n]}return n===void 0?e.completed?[{state:`done`,label:t(`status.completed`)}]:[{state:`idle`,label:t(`status.idle`)}]:[n]}function Me(e){throw Error(`unknown pending interaction: ${String(e)}`)}function Ne({statuses:e}){return/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.StateDot,{state:e[0].state,size:e[0].state===`ongoing`?16:void 0}),e.map(e=>/* @__PURE__ */ (0,s.jsx)(`span`,{className:W.visuallyHidden,children:e.label},e.label))]})}let G=`@deepseek-ai/dsh-client-ui-workspace/RecentNavigation.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(G)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=G,e.textContent=`.qXmkFa_trigger,.qXmkFa_shortcuts{display:none}[data-phone] .qXmkFa_trigger{width:44px;height:44px;color:var(--dsw-alias-label-primary);cursor:pointer;-webkit-app-region:no-drag;background:0 0;border:0;border-radius:8px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.qXmkFa_trigger[aria-disabled=true]{cursor:wait}.qXmkFa_trigger:active{background:color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent)}.qXmkFa_trigger:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:-2px}.qXmkFa_expanded{transform:rotate(180deg)}[data-phone] .qXmkFa_shortcuts{overflow-anchor:none;scroll-behavior:auto;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch;scrollbar-width:none;-webkit-app-region:no-drag;grid-column:1/-1;gap:6px;min-width:0;min-height:44px;margin-inline:-12px -20px;padding-inline-end:16px;scroll-padding-inline:8px 20px;display:flex;overflow-x:auto}.qXmkFa_clear{min-width:44px;min-height:44px;color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;background:0 0;border:0;border-radius:8px;flex:none;align-self:center;padding:0 6px;font-size:12px}.qXmkFa_clear:active{background:color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent)}.qXmkFa_clear:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:-2px}.qXmkFa_shortcuts::-webkit-scrollbar{width:0;height:0;display:none}`,document.head.appendChild(e)}var Pe={clear:`qXmkFa_clear`,expanded:`qXmkFa_expanded`,shortcuts:`qXmkFa_shortcuts`,trigger:`qXmkFa_trigger`};function Fe({useVisits:e,useSessions:t,useWorkspaces:n,useSessionStatus:r,t:i}){let a=e(e=>e),o=t(e=>e),s=n(e=>e.archivedSessionIds),c=r(e=>e);return a.flatMap(e=>{let t=o.byId[e.sessionId];return t===void 0||t.blank||s.includes(e.sessionId)?[]:[{visit:e,summary:t,statuses:je({...N(t,o,c),completed:!1},i)}]})}function Ie(e){let{useRecentNavigationSettings:t,open:n,close:r,closeAll:i,viewport:c,restoreNavigationFocus:l,renderSlot:u,t:d}=e,f=t(e=>e.value?.showRecentVisits??!0),p=Fe(e),m=f&&p.length>0,h=(0,a.useRef)(null),[g,_]=(0,a.useState)(!1),v=(0,a.useCallback)((e=h.current)=>{e?.isConnected&&e.clientWidth>0&&(c.scrollLeft=Math.max(0,Math.min(e.scrollLeft,e.scrollWidth-e.clientWidth)))},[c]);return(0,a.useLayoutEffect)(()=>{let e=h.current;if(e===null)return;e.scrollLeft=c.scrollLeft;let t=e.clientWidth,n=new ResizeObserver(()=>{e.clientWidth!==t&&(t=e.clientWidth,e.scrollLeft=c.scrollLeft)});return n.observe(e),()=>{v(e),n.disconnect()}},[m,c,v]),m?/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsxs)(`nav`,{ref:h,className:Pe.shortcuts,"aria-label":d(`recent.navigation`),onScroll:e=>v(e.currentTarget),children:[p.map(({visit:t,summary:i,statuses:a})=>/* @__PURE__ */ (0,s.jsx)(ke,{visit:t,summary:i,identity:u(`workspace.recent.shortcut.identity`,{sessionId:t.sessionId}),activityLabel:a[0].state===`idle`?void 0:a.map(e=>e.label).join(` · `),activity:a[0].state===`idle`?null:/* @__PURE__ */ (0,s.jsx)(Ne,{statuses:a}),active:e.sessionId===t.sessionId,closeLabel:d(`recent.close`,{name:i.displayTitle}),closeHint:d(`recent.closeHint`),open:e=>{v(),n(e)},close:e=>{v();try{r(e)}catch{_(!0)}},restoreNavigationFocus:l},t.sessionId)),p.length>=3&&/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:Pe.clear,"aria-label":d(`recent.clearAll`),title:d(`recent.clearAllHint`),onMouseDown:e=>e.preventDefault(),onClick:()=>{l();try{i()}catch{_(!0)}},children:d(`recent.clear`)})]}),g&&/* @__PURE__ */ (0,s.jsx)(o.Toast,{text:d(`recent.closeFailed`),onDone:()=>_(!1)})]}):null}function Le(e){let{useRecentNavigationSettings:t,setEnabled:n,t:r}=e,i=t(e=>e.value?.showRecentVisits??!0),c=Fe(e),[l,u]=(0,a.useState)(!1),[d,f]=(0,a.useState)(!1),p=(0,a.useRef)(!1);return/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[c.length>0&&/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,"data-navigation-focus-return":!0,className:Pe.trigger,"aria-label":r(i?`recent.collapse`:`recent.expand`),"aria-expanded":i,"aria-disabled":l||void 0,"aria-busy":l||void 0,onClick:()=>{p.current||(p.current=!0,u(!0),f(!1),n(!i).then(e=>f(!e)).catch(()=>f(!0)).finally(()=>{p.current=!1,u(!1)}))},children:/* @__PURE__ */ (0,s.jsx)(o.IconChevronDownOutlineRegular,{size:14,className:i?Pe.expanded:void 0})}),d&&/* @__PURE__ */ (0,s.jsx)(o.Toast,{text:r(`recent.settings.error`),onDone:()=>f(!1)})]})}function K(e){return e==null}function Re(e){return e&&typeof e==`object`&&!Array.isArray(e)}function ze(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function q(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function Be(e,t,n){if(!t)return{...e};let r={};for(let i of t)(n||e[i]!==void 0)&&(r[i]=e[i]);return r}let Ve=Symbol.for(`cosmokit.volatile.write`);function He(e,t=/* @__PURE__ */ new Set){if(typeof e==`function`)throw TypeError(`volatile config cannot contain functions`);if(typeof e!=`object`||!e)return e;if(t.has(e))throw TypeError(`volatile config cannot contain cycles`);t.add(e);try{if(Array.isArray(e))return Object.freeze(e.map(e=>He(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`volatile config objects must be plain objects or arrays`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,He(n,t)])))}finally{t.delete(e)}}function Ue(e){let t=He(e);return Object.freeze({get:()=>t,[Ve]:e=>{t=e}})}function We(e){return typeof e==`object`&&!!e&&Ve in e}function J(e,t){return arguments.length===1?t=>J(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function Ge(e){return J(`ArrayBuffer`,e)||J(`SharedArrayBuffer`,e)}function Ke(e){return Ge(e)||ArrayBuffer.isView(e)}let qe;(function(e){e.is=Ge,e.isSource=Ke;function t(e){return ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}e.fromSource=t;function n(e){if(e=t(e),typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let n=``,r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)n+=String.fromCharCode(r[e]);return btoa(n)}e.toBase64=n;function r(e){return typeof Buffer<`u`?t(Buffer.from(e,`base64`)):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}e.fromBase64=r;function i(e){return e=t(e),typeof Buffer<`u`?Buffer.from(e).toString(`hex`):Array.from(new Uint8Array(e),e=>e.toString(16).padStart(2,`0`)).join(``)}e.toHex=i;function a(e){if(typeof Buffer<`u`)return t(Buffer.from(e,`hex`));let n=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(`${n[e]}${n[e+1]}`,16));return Uint8Array.from(r).buffer}e.fromHex=a})(qe||={}),qe.fromBase64,qe.toBase64,qe.fromHex,qe.toHex;function Je(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(J(`Date`,e))return new Date(e.valueOf());if(J(`RegExp`,e))return new RegExp(e.source,e.flags);if(Ge(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let n=t.get(e);if(n)return n;if(Array.isArray(e)){let n=[];return t.set(e,n),e.forEach((e,r)=>{n[r]=Reflect.apply(Je,null,[e,t])}),n}let r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let n of Reflect.ownKeys(e)){let i={...Reflect.getOwnPropertyDescriptor(e,n)};`value`in i&&(i.value=Reflect.apply(Je,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function Ye(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(We(e)||We(t))return We(e)&&We(t);if(!n&&K(e)&&K(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function a(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return a(Array.isArray,(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0})??a(J(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(J(`URL`),(e,t)=>e.href===t.href)??a(J(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(Ge,(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0})??((!n||[e,t].every(e=>Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null))&&Object.keys({...e,...t}).every(n=>i(e[n],t[n])))}finally{r.delete(e)}}return i(e,t)}let Xe;(function(e){e.millisecond=1;let t=e.second=1e3,n=e.minute=t*60,r=e.hour=n*60,i=e.day=r*24,a=e.week=i*7,o=(/* @__PURE__ */ new Date()).getTimezoneOffset();function s(e){o=e}e.setTimezoneOffset=s;function c(){return o}e.getTimezoneOffset=c;function l(e=/* @__PURE__ */ new Date,t){return typeof e==`number`&&(e=new Date(e)),t===void 0&&(t=o),Math.floor((e.valueOf()/n-t)/1440)}e.getDateNumber=l;function u(e,t){let r=new Date(e*i);return t===void 0&&(t=o),new Date(+r+t*n)}e.fromDateNumber=u;let d=RegExp(`^${[`w(?:eek(?:s)?)?`,`d(?:ay(?:s)?)?`,`h(?:our(?:s)?)?`,`m(?:in(?:ute)?(?:s)?)?`,`s(?:ec(?:ond)?(?:s)?)?`].map(e=>`(\\d+(?:\\.\\d+)?${e})?`).join(``)}$`);function f(e){let o=d.exec(e);return o?(parseFloat(o[1])*a||0)+(parseFloat(o[2])*i||0)+(parseFloat(o[3])*r||0)+(parseFloat(o[4])*n||0)+(parseFloat(o[5])*t||0):0}e.parseTime=f;function p(e){let t=f(e);return t?e=Date.now()+t:/^\d{1,2}(:\d{1,2}){1,2}$/.test(e)?e=`${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${e}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(e)&&(e=`${(/* @__PURE__ */ new Date()).getFullYear()}-${e}`),e?new Date(e):/* @__PURE__ */ new Date}e.parseDate=p;function m(e){let a=Math.abs(e);return a>=i-r/2?Math.round(e/i)+`d`:a>=r-n/2?Math.round(e/r)+`h`:a>=n-t/2?Math.round(e/n)+`m`:a>=t?Math.round(e/t)+`s`:e+`ms`}e.format=m;function h(e,t=2){return e.toString().padStart(t,`0`)}e.toDigits=h;function g(e,t=/* @__PURE__ */ new Date){return e.replace(`yyyy`,t.getFullYear().toString()).replace(`yy`,t.getFullYear().toString().slice(2)).replace(`MM`,h(t.getMonth()+1)).replace(`dd`,h(t.getDate())).replace(`hh`,h(t.getHours())).replace(`mm`,h(t.getMinutes())).replace(`ss`,h(t.getSeconds())).replace(`SSS`,h(t.getMilliseconds(),3))}e.template=g})(Xe||={});let Ze=Symbol.for(`schemastery`),Qe=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var Y=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[Qe]}};Object.defineProperty(Y.prototype,Qe,{value:!0});let X=function(e){let t=function(e,n={}){return X.resolve(e,t,n)[0]};if(e.refs){let t=q(e.refs,e=>new X(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&q(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,X.prototype),t.meta||={},t.toString=t.toString.bind(t),t};X.prototype=Object.create(Function.prototype),X.prototype[Ze]=!0,Object.defineProperty(X.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:X.resolve(e,this,{})[0]}}catch(e){if(Y.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),X.ValidationError=Y,X.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},X.prototype.set=function(e,t){return this.dict[e]=t,this},X.prototype.push=function(e){return this.list.push(e),this};function $e(e,t){let n=typeof e==`string`?{"":e}:{...e};for(let e in t){let r=t[e];r?.$description||r?.$desc?n[e]=r.$description||r.$desc:typeof r==`string`&&(n[e]=r)}return n}function et(e){return e?.$value??e?.$inner}function tt(e){return ze(e??{},e=>!e.startsWith(`$`))}X.prototype.i18n=function(e){let t=X(this),n=$e(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=q(t.dict,(t,n)=>t.i18n(q(e,e=>et(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(q(e,(e={})=>Array.isArray(et(e))?et(e)[n]:Array.isArray(e)?e[n]:tt(e)))),t.inner&&=t.inner.i18n(q(e,e=>et(e)?et(e):tt(e))),t.sKey&&=t.sKey.i18n(q(e,e=>e?.$key)),t},X.prototype.extra=function(e,t){let n=X(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign(X.prototype,{[e](t=!0){let n=X(this);return n.meta={...n.meta,[e]:t},n}});X.prototype.deprecated=function(){let e=X(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},X.prototype.experimental=function(){let e=X(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},X.prototype.pattern=function(e){let t=X(this),n=Be(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},X.prototype.simplify=function(e){if(We(e)&&(e=e.get()),Ye(e,this.meta.default,this.type===`dict`))return null;if(K(e))return e;if(this.type===`object`||this.type===`dict`){let t={};for(let n in e){let r=(this.type===`object`?this.dict[n]:this.inner)?.simplify(e[n]);(this.type===`dict`||!K(r))&&(t[n]=r)}return Ye(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return X.resolve(e,t,{}),t.simplify(e)}catch{}return e},X.prototype.toString=function(e){return ut[this.type]?.(this,e)??`Schema<${this.type}>`},X.prototype.role=function(e,t){let n=X(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign(X.prototype,{[e](t){let n=X(this);return n.meta={...n.meta,[e]:t},n}});X.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let nt={},rt=Symbol(`checked-volatile-schema`);function it(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new Y(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))it(i,[...t,n],a,r);if(e.sKey&&it(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[Ze])&&it(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)it(e.list[n],[...t,String(n)],!0,r)}X.extend=function(e,t){nt[e]=t},X.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[rt]||(it(t,n.path),n={...n,[rt]:!0}),t.meta?.volatile){let i=X(t);i.meta={...t.meta,volatile:!1};let[a,o]=X.resolve(e,i,n,r);try{return[Ue(a),o]}catch(e){throw new Y(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(K(e)&&t.type!==`lazy`){if(t.meta.required)throw new Y(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&K(i);)r=r.list[0],i=r?.meta.default;if(K(i))return[e];e=Je(i)}let i=nt[t.type];if(!i)throw new Y(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},X.from=function(e){if(K(e))return X.any();if([`string`,`number`,`boolean`].includes(typeof e))return X.const(e).required();if(e[Ze])return e;if(typeof e==`function`)switch(e){case String:return X.string().required();case Number:return X.number().required();case Boolean:return X.boolean().required();case Function:return X.function().required();default:return X.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},X.lazy=function(e){let t=new X({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[Ze]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},X.natural=function(){return X.number().step(1).min(0)},X.percent=function(){return X.number().step(.01).min(0).max(1).role(`slider`)},X.date=function(){return X.union([X.is(Date),X.transform(X.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new Y(`invalid date "${e}"`,t);return n},!0)])},X.regExp=function(e=``){return X.union([X.is(RegExp),X.transform(X.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new Y(e.message,n)}},!0)])},X.arrayBuffer=function(e){return X.union([X.is(ArrayBuffer),X.is(SharedArrayBuffer),X.transform(X.any(),(e,t)=>{if(qe.isSource(e))return qe.fromSource(e);throw new Y(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[X.transform(X.string(),(t,n)=>{try{return e===`base64`?qe.fromBase64(t):qe.fromHex(t)}catch(e){throw new Y(e.message,n)}},!0)]:[]])},X.extend(`lazy`,(e,t,n,r)=>(t.inner[Ze]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},it(t.inner,n.path,!0)),X.resolve(e,t.inner,n,r))),X.extend(`any`,e=>[e]),X.extend(`never`,(e,t,n)=>{throw new Y(`expected nullable but got ${e}`,n)}),X.extend(`const`,(e,{value:t},n)=>{if(Ye(e,t))return[t];throw new Y(`expected ${t} but got ${e}`,n)});function at(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new Y(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new Y(`expected ${n} >= ${o} but got ${e}`,r)}X.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new Y(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new Y(`expect string to match regexp ${r}`,n)}return at(e.length,t,`string length`,n),[e]});function ot(e,t){let n=e.toString();if(n.includes(`e`))return e*10**t;let r=n.indexOf(`.`);if(r===-1)return e*10**t;let i=n.slice(r+1),a=n.slice(0,r);return i.length<=t?+(a+i.padEnd(t,`0`)):+(a+i.slice(0,t)+`.`+i.slice(t))}function st(e,t,n){if(n=Math.abs(n),!/^\d+\.\d+$/.test(n.toString()))return(e-t)%n===0;let r=n.toString().indexOf(`.`),i=n.toString().slice(r+1).length;return Math.abs(ot(e,i)-ot(t,i))%ot(n,i)===0}X.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new Y(`expected number but got ${e}`,n);at(e,t,`number`,n);let{step:r}=t;if(r&&!st(e,t.min??0,r))throw new Y(`expected number multiple of ${r} but got ${e}`,n);return[e]}),X.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new Y(`expected boolean but got ${e}`,n)}),X.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new Y(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new Y(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),X.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new Y(`expected function but got ${e}`,n)}),X.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new Y(`expected ${t.name} but got ${e}`,n)}{if(K(e))throw new Y(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new Y(`expected ${t} but got ${e}`,n)}});function ct(e,t,n,r){try{let[i,a]=X.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?Ue(n.meta.default):n.meta.default}}X.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new Y(`expected array but got ${e}`,r);return at(e.length,n,`array length`,r,!K(t.meta.default)),[e.map((n,i)=>ct(e,i,t,r))]}),X.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!Re(e))throw new Y(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=X.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=ct(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),X.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new Y(`expected array but got ${e}`,n);let i=t.map((t,r)=>ct(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function lt(e,t){for(let n in t)n in e||(e[n]=t[n])}X.extend(`object`,(e,{dict:t},n,r)=>{if(!Re(e))throw new Y(`expected object but got ${e}`,n);let i={};for(let r in t){let a=ct(e,r,t[r],n);(!K(a)||r in e)&&(i[r]=a)}return r||lt(i,e),[i]}),X.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return X.resolve(e,n,r,i)}catch(e){a.push(e)}throw new Y(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),X.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=X.resolve(e,i,r,!0)[0];if(!K(t)){if(K(a))a=t;else if(typeof a!=typeof t)throw new Y(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)lt(a??={},t);else if(a!==t)throw new Y(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&Re(e)&&lt(a,e),[a]}),X.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=X.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let ut={};function Z(e,t,n){ut[e]=n,Object.assign(X,{[e](...n){let r=new X({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??X.string();break;case`inner`:r.inner=X.from(n[t]);break;case`list`:r.list=n[t].map(X.from);break;case`dict`:r.dict=q(n[t],X.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}Z(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),Z(`any`,[],()=>`any`),Z(`never`,[],()=>`never`),Z(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),Z(`string`,[],()=>`string`),Z(`number`,[],()=>`number`),Z(`boolean`,[],()=>`boolean`),Z(`bitset`,[`bits`],()=>`bitset`),Z(`function`,[],()=>`function`),Z(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),Z(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),Z(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),Z(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),Z(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),Z(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),Z(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let dt=[0,15,30,60,120,240,1440],ft={showRecentVisits:!0,tabIdleTimeoutMinutes:60},pt=X.object({showRecentVisits:X.boolean().default(!0),tabIdleTimeoutMinutes:X.natural().max(1440).default(60)}),mt=`@deepseek-ai/dsh-client-ui-workspace/RecentNavigationRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(mt)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=mt,e.textContent=`._0lPQtW_row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px 16px;padding:16px 0;display:flex}._0lPQtW_text{flex:160px;min-width:0}._0lPQtW_timeoutRow{border-top:.5px solid var(--dsw-alias-border-l2)}._0lPQtW_menu{flex:none;margin-inline-start:auto}._0lPQtW_selector{background:var(--dsw-alias-bg-module-platform);min-width:96px;min-height:44px;color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;border:0;border-radius:8px;justify-content:space-between;align-items:center;gap:8px;padding:0 12px;font-size:14px;line-height:20px;display:inline-flex}._0lPQtW_selector:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:2px}._0lPQtW_selector:disabled{opacity:.5;cursor:not-allowed}@media (hover:hover){._0lPQtW_selector:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}}._0lPQtW_error{padding-bottom:12px;font-size:12px;line-height:18px}._0lPQtW_titleLine{flex-wrap:wrap;align-items:center;gap:8px;display:flex}._0lPQtW_title{font-size:14px;line-height:20px}._0lPQtW_description{color:var(--dsw-alias-label-secondary);margin-top:4px;font-size:12px;line-height:18px}`,document.head.appendChild(e)}var ht={description:`_0lPQtW_description`,error:`_0lPQtW_error`,menu:`_0lPQtW_menu`,row:`_0lPQtW_row`,selector:`_0lPQtW_selector`,text:`_0lPQtW_text`,timeoutRow:`_0lPQtW_timeoutRow`,title:`_0lPQtW_title`,titleLine:`_0lPQtW_titleLine`};function gt({usePreference:e,setEnabled:t,setIdleTimeout:n,t:r}){let i=e(e=>e.value),c=i?.showRecentVisits??!0,l=i?.tabIdleTimeoutMinutes??60,[u,d]=(0,a.useState)(!1),[f,p]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!1),g=(0,a.useRef)(!1),_=(0,a.useId)();(0,a.useEffect)(()=>{c||d(!1)},[c]);let v=e=>e===0?r(`recent.timeout.off`):e>=120&&e%60==0?r(`recent.timeout.hours`,{n:e/60}):r(`recent.timeout.minutes`,{n:e}),y=e=>{g.current||(g.current=!0,d(!1),p(!0),h(!1),Promise.resolve().then(e).then(e=>h(!e)).catch(()=>h(!0)).finally(()=>{g.current=!1,p(!1)}))};return/* @__PURE__ */ (0,s.jsxs)(`div`,{children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:ht.row,children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:ht.text,children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:ht.titleLine,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:ht.title,children:r(`recent.settings.title`)}),/* @__PURE__ */ (0,s.jsx)(o.Tag,{tone:`neutral`,children:r(`recent.settings.mobile`)})]}),/* @__PURE__ */ (0,s.jsx)(`div`,{className:ht.description,children:r(`recent.settings.description`)})]}),/* @__PURE__ */ (0,s.jsx)(o.Switch,{checked:c,disabled:f,label:`${r(`recent.settings.title`)} · ${r(`recent.settings.mobile`)}`,onChange:e=>y(()=>t(e))})]}),c&&/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`${ht.row} ${ht.timeoutRow}`,children:[/* @__PURE__ */ (0,s.jsx)(`div`,{className:ht.text,children:/* @__PURE__ */ (0,s.jsx)(`div`,{className:ht.title,id:`${_}-label`,children:r(`recent.timeout.title`)})}),/* @__PURE__ */ (0,s.jsx)(o.Menu,{className:ht.menu,open:u&&c&&!f,onClose:()=>d(!1),items:dt.map(e=>({id:String(e),label:e===60?r(`recent.timeout.default`,{value:v(e)}):v(e)})),selectedId:String(l),onSelect:e=>{let t=dt.find(t=>String(t)===e);t!==void 0&&y(()=>n(t))},align:`end`,portal:!0,anchor:/* @__PURE__ */ (0,s.jsxs)(`button`,{type:`button`,className:ht.selector,disabled:!c||f,"aria-labelledby":`${_}-label ${_}-value`,"aria-haspopup":`menu`,"aria-expanded":u&&c&&!f,onClick:()=>d(e=>!e),children:[/* @__PURE__ */ (0,s.jsx)(`span`,{id:`${_}-value`,children:v(l)}),/* @__PURE__ */ (0,s.jsx)(o.IconChevronDownOutlineRegular,{size:14})]})})]}),m&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:ht.error,role:`alert`,children:r(`recent.settings.error`)})]})}function _t(e,t){let n=e.configForms.registerBrowser(`ui-workspace`,pt.toJSON(),ft),r=e=>n.set(`showRecentVisits`,e),i=e=>n.set(`tabIdleTimeoutMinutes`,e),a={scrollLeft:0};e.inject([`uiSession`,`connection`],e=>{e.effect(()=>{let r,i=()=>{let r=n.getSnapshot().value;r!==void 0&&document.visibilityState===`visible`&&e.connection.state.getSnapshot()===`connected`&&r.showRecentVisits&&r.tabIdleTimeoutMinutes!==0&&t.opening.getSnapshot().state!==`loading`&&t.recentVisits.expireInactive(r.tabIdleTimeoutMinutes*6e4,e.uiSession.sessionStatus.getSnapshot())&&t.recentVisits.entries.getSnapshot().length===0&&(a.scrollLeft=0)},o=()=>{r!==void 0&&clearInterval(r),r=void 0;let e=n.getSnapshot().value;document.visibilityState===`visible`&&e?.showRecentVisits&&e.tabIdleTimeoutMinutes>0&&(r=setInterval(i,6e4))},s=n.subscribe(o);return document.addEventListener(`visibilitychange`,o),o(),()=>{s(),r!==void 0&&clearInterval(r),document.removeEventListener(`visibilitychange`,o)}},`ui-workspace: idle session tabs`)});let o=()=>({hooks:{visits:t.recentVisits.entries,recentNavigationSettings:n},open:e=>t.openSession(e),close:e=>{t.closeSessionTab(e),t.recentVisits.entries.getSnapshot().length===0&&(a.scrollLeft=0)},closeAll:()=>{t.closeAllSessionTabs(),a.scrollLeft=0},viewport:a,setEnabled:r});e.slots.inject(`conversation.header.navigation`,()=>e.slots.register({name:`conversation.header.navigation`,locale:`workspace`,inject:o},Le)),e.slots.inject(`conversation.header.shortcuts`,()=>e.slots.register({name:`conversation.header.shortcuts`,locale:`workspace`,inject:o,children:{"workspace.recent.shortcut.identity":{kind:`list`,scope:`root`}}},Ie)),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`workspace.recent-navigation`,order:12,locale:`workspace`,inject:()=>({hooks:{preference:n},setEnabled:r,setIdleTimeout:i})},gt))}function vt(e,t,n){let r=e.find(e=>e.workspaceId===t),i=e.find(e=>e.workspaceId===n);return r!==void 0&&i!==void 0&&!r.remote&&!i.remote}function yt(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=yt(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Q(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=yt(e))&&(r&&(r+=` `),r+=t);return r}function bt(e,t){return e===`default-workspace`?t:e}function xt({identity:e,ambient:t,title:n,onTitleDoubleClick:r,children:i}){return/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsxs)(`span`,{className:W.slot,children:[e,/* @__PURE__ */ (0,s.jsx)(`span`,{className:W.statusOverlay,children:t})]}),/* @__PURE__ */ (0,s.jsx)(`span`,{"data-session-title":!0,className:W.title,onDoubleClick:r,children:n}),i]})}function St({host:e,t}){let n=e?.displayName??t(`host.local`),r=e?.state===`connected`?t(`host.connected`):e?.state===`connecting`?t(`host.connecting`):t(`host.disconnected`),i=e?`${n} · ${r}`:n;return/* @__PURE__ */ (0,s.jsxs)(`span`,{className:W.hostBadge,"data-host-id":e?.hostId??`local`,"data-state":e?.state??`local`,role:`img`,"aria-label":i,title:i,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{children:n}),e&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:W.hostDot,"aria-hidden":`true`})]})}function Ct(e,t){return e.blank?t(`session.new`):e.title||t(`session.untitled`)}function wt(e,t,n){let{unit:r,n:i}=(0,o.relativeTime)(e,t);return r===`now`?n(`time.now`):n(`time.${r}`,{n:i})}function Tt(e,t,n){let{unit:r,n:i}=(0,o.relativeTime)(e,t);return r===`now`?n(`time.now`):n(`time.ago`,{t:n(`time.${r}`,{n:i})})}function Et(e,t){let n=new Date(e),r=e=>String(e).padStart(2,`0`);return t(`hover.created`,{time:`${t(`date.ymd`,{y:n.getFullYear(),m:n.getMonth()+1,d:n.getDate()})} ${r(n.getHours())}:${r(n.getMinutes())}`})}function Dt({label:e,cwd:t,createdAt:n,t:r}){return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:W.hoverContent,children:[/* @__PURE__ */ (0,s.jsx)(`div`,{className:W.hoverTitle,children:e}),/* @__PURE__ */ (0,s.jsx)(`div`,{className:W.hoverPath,children:t}),/* @__PURE__ */ (0,s.jsx)(`div`,{className:W.hoverTime,children:Et(n,r)})]})}function Ot(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function kt({group:e,onToggle:t,onCreate:n,actions:r,drag:i,home:c,newShortcut:l,t:u}){let d=e,f=e.remote?void 0:r,p=e.remote?void 0:i,m=d.workspaceId===void 0?u(`group.ungrouped`):d.label,[h,g]=(0,a.useState)(!1),[v,y]=(0,a.useState)(null),b=[{id:`rename`,label:u(`rename`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconEditOutlineRegular,{})},{id:`delete`,label:u(`delete.workspace`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconTrashOutlineRegular,{}),danger:!0}],x=/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q(W.projectRow,h&&W.menuOpen),"data-row-key":`workspace:${e.key}`,role:`treeitem`,"aria-expanded":d.expanded,tabIndex:-1,onContextMenu:e=>{f&&!e.target.closest(`button`)&&(e.preventDefault(),y(new DOMRect(e.clientX,e.clientY,0,0)),g(!0))},onKeyDown:e=>{e.target===e.currentTarget&&f&&(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`)&&(e.preventDefault(),y(null),g(!0))},onClick:t,draggable:p!==void 0,onDragStart:p===void 0?void 0:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,d.key),p.start()},onDragEnd:p?.end,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:Q(W.slot,d.expanded&&W.folderExpanded),children:d.expanded?/* @__PURE__ */ (0,s.jsx)(o.IconFolderOpenRegular,{}):/* @__PURE__ */ (0,s.jsx)(o.IconFolderCloseRegular,{})}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:W.projectText,children:/* @__PURE__ */ (0,s.jsx)(`span`,{className:W.title,children:m})}),d.workspaceId!==void 0&&d.remote&&/* @__PURE__ */ (0,s.jsx)(St,{host:d.remote,t:u}),/* @__PURE__ */ (0,s.jsxs)(`span`,{className:W.rowActions,children:[f!==void 0&&/* @__PURE__ */ (0,s.jsx)(o.Menu,{open:h,onClose:()=>{g(!1)},items:b,onSelect:e=>{
9
+ default:return _(n)}}function N(e,t,n){let r=[],i=[];for(let a of e)!n.has(a.id)&&t.has(a.id)?r.push(a):i.push(a);return[...r,...i]}function ee(e){return e.blank?``:e.title?.trim()??``}function P(e,t,n,r,i,a,o){return{key:e,workspaceId:t,cwd:n,createdAt:r,label:i,sessions:[...a],remote:o}}function te(e,t,n,r){let i=[];for(let a of t){let t=[];for(let i of a.sessionIds){let a=e.byId[i];a!==void 0&&M(a,n,r)&&t.push(a)}(r!==`only`||t.length!==0)&&i.push(P(a.workspaceId,a.workspaceId,a.path,Date.parse(a.createdAt),a.title,t,a.remote))}let a=k(e.ids,e.byId).map(t=>e.byId[t]).filter(e=>e!==void 0&&M(e,n,r));return a.length>0&&i.push(P(``,void 0,void 0,void 0,``,a)),i}function F(e){switch(e){case`approval`:case`plan-review`:case`question`:return e;default:return}}function ne(e,t,n){return e.projectionsBySession[t]?.values.subagentCatalog?.reduce((t,r)=>t+ +((n.get(r.id)?.running??e.byId[r.id]?.running)===!0),0)??0}function re(e,t,n){let r=n.get(e.id),i=F(r?.pendingInteraction?.kind);return{running:r?.running??e.running,runningSubagentCount:ne(t,e.id,n),completed:r?.completionUnread===!0,...i===void 0?{}:{pendingInteraction:i}}}function I(e,t,n,r,i){return{id:e.id,reference:x(e),remote:e.projectionValues?.remoteHost??void 0,title:ee(e),...e.cwd===void 0?{}:{cwd:e.cwd},blank:e.blank,...re(e,t,n),pinned:!i.has(e.id)&&r.has(e.id),archived:i.has(e.id),updatedAt:e.updatedAt}}function ie(e,t){if(e.projectionValues?.remoteHost)return null;let n=e.projectionValues?.threadTreeParent??null,r=n===null?void 0:t?.byId[f(n)];if(r?.projectionValues?.remoteHost)return null;let i=e.projectionValues?.threadReference?.hostId,a=r?.projectionValues?.threadReference?.hostId;return i!==void 0&&a!==void 0&&i!==a?null:n}function L(e,t,n){let r=new Set(t.archivedSessionIds),i=new Set(t.pinnedSessionIds);return w(ae(e,t.archivedSessionIds,t.archivedFilter).flatMap(t=>{let a=e.byId[t];return a===void 0?[]:[I(a,e,n,i,r)]}),t=>{let n=e.byId[t.id];return n===void 0?null:ie(n,e)})}function R(e,t,n,r,i){let a=new Set(n.archivedSessionIds),o=new Set(n.pinnedSessionIds),s=new Set(i.expandedGroups),c=D(e),l=new Map(L(e,n,r).map(e=>[e.id,e])),u=[];for(let r of te(e,t,a,n.archivedFilter)){let e=s.has(r.key),t=r.sessions.flatMap(e=>{let t=l.get(e.id);return t===void 0||i.excludePinned&&t.pinned?[]:[t]});r.key===``&&t.sort((e,t)=>(t.tree?.updatedAt??t.updatedAt)-(e.tree?.updatedAt??e.updatedAt)||e.id.localeCompare(t.id)),u.push({key:r.key,workspaceId:r.workspaceId,cwd:r.cwd,createdAt:r.createdAt,label:r.label,remote:r.remote,sessionCount:t.length,expanded:e,containsCurrent:t.some(e=>e.id===c||c!==void 0&&e.tree?.descendantIds.includes(c)),sessions:e?N(t,o,a):[]})}return u}function z(e,t=[]){return[...ae(e,[],`show`),...t.filter(t=>e.byId[t]===void 0)]}function ae(e,t,n){let r=new Set(t);return e.ids.filter(t=>{let i=e.byId[t];return i!==void 0&&M(i,r,n)})}function oe(e,t,n,r){let i=new Set(n.archivedSessionIds),a=new Set(n.pinnedSessionIds),o=new Map(L(e,n,r).map(e=>[e.id,e]));return N(t.flatMap(e=>{let t=o.get(e);return t===void 0?[]:[t]}),a,i)}function se(e,t,n,r,i,a,o,s){let c=n.trim().toLowerCase();if(c===``)return{items:[],hasMore:!1};let l=new Set(r),u=/* @__PURE__ */ new Map;for(let e of t)for(let t of e.sessionIds)u.has(t)||u.set(t,e.title);let d=e=>u.get(e.id)??O(e.cwd),p=/* @__PURE__ */ new Map;for(let e of o.items)p.has(e.sessionId)||p.set(e.sessionId,e);let m=[];for(let t of e.ids){let n=e.byId[t];n!==void 0&&!n.blank&&M(n,l,i)&&(ee(n).toLowerCase().includes(c)||d(n).toLowerCase().includes(c))&&m.push(n)}let h=new Map(m.map(e=>[e.id,e])),g=k(m.map(e=>e.id),e.byId).map(e=>h.get(e)),_=[],v=/* @__PURE__ */ new Set,y=e=>{v.has(e.id)||(v.add(e.id),_.push(e))};for(let e of g)y(e);for(let t of o.items){let n=e.byId[t.sessionId];n!==void 0&&!n.blank&&M(n,l,i)&&y(n)}return{items:_.slice(0,s).map(t=>{let n=p.get(t.id),r=a.get(t.id),i=F(r?.pendingInteraction?.kind),o=ie(t,e);return{id:t.id,title:ee(t),workspace:d(t),...o===null?{}:{parentTitle:e.byId[f(o)]?.title??``},remote:t.projectionValues?.remoteHost??void 0,running:r?.running??t.running,runningSubagentCount:ne(e,t.id,a),...i===void 0?{}:{pendingInteraction:i},completed:r?.completionUnread===!0,archived:l.has(t.id),...n===void 0?{}:{snippet:n.snippet}}}),hasMore:o.hasMore||_.length>s}}function B(e){return(/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)?e.replaceAll(`\\`,`/`):e).replace(/\/+$/,``)}function ce(e,t){let n=B(e),r,i=-1;for(let e of t){let t=B(e);t.length>i&&n!==t&&n.startsWith(`${t}/`)&&(r=e,i=t.length)}return r}let le=`__flat_session_order__`,ue=`pinned`,de=`workspaces`;function fe(e,t){return e?.[t]??!0}function V(e,t,n){let r=new Map(Object.entries(n.summaries)),i=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(n.members))if(e!==`__flat_session_order__`)for(let n of t)i.set(n,e);return Object.fromEntries(Object.entries(e).map(([e,n])=>{let a=[...n],o=n[0]===void 0?void 0:r.get(n[0]),s=o?.blank&&(o.retainedBy.mainView??0)>0?1:0;for(let n of t[e]??[]){let t=a.indexOf(n);t===-1?!r.has(n)&&(e===`__flat_session_order__`||!i.has(n)||i.get(n)===e)&&a.splice(s++,0,n):s=t+1}return[e,a]}))}function pe(){return(0,r.defineStore)({init:()=>({groupBy:`workspace`,orderBy:`updated`,groupExpansion:{},threadExpansion:{},sectionExpansion:{},sessionOrderByAccount:{},archivedFilter:`default`}),persist:`dsh.workspace.view.v5`,actions:{setGroupBy:(e,t)=>{e.groupBy=t},setOrderBy:(e,t,n,r)=>{t!==e.orderBy&&(e.sessionOrderByAccount=t===`manual`?V(n,e.sessionOrderByAccount,r):{},e.orderBy=t)},setGroupExpanded:(e,t,n)=>{e.groupExpansion[t]=n},setThreadsExpanded:(e,t,n)=>{e.threadExpansion??={};for(let r of t)e.threadExpansion[r]=n},setSectionExpanded:(e,t,n)=>{e.sectionExpansion={...e.sectionExpansion,[t]:n}},retainAccountKeys:(e,t)=>{let n=new Set(t);e.groupExpansion=Object.fromEntries(Object.entries(e.groupExpansion).filter(([e])=>n.has(e))),e.sessionOrderByAccount=Object.fromEntries(Object.entries(e.sessionOrderByAccount).filter(([e])=>n.has(e))),delete e.sessionUpdatedAtByAccount},syncSessionOrders:(e,t,n)=>{e.orderBy===`manual`&&Object.assign(e.sessionOrderByAccount,V(t,e.sessionOrderByAccount,n))},setSessionOrder:(e,t,n,r,i)=>{let a=V({...r,[t]:n},e.sessionOrderByAccount,i);e.orderBy===`updated`?e.sessionOrderByAccount=a:Object.assign(e.sessionOrderByAccount,a),e.orderBy=`manual`},pinSessionOrder:(e,t,n,r)=>{let i=new Set(n),a=V(Object.fromEntries(Object.entries(r.members).map(([t,n])=>[t,A(n,e.sessionOrderByAccount[t],r.summaries,r.rowState)])),e.sessionOrderByAccount,r);for(let e of i)a[e]!==void 0&&(a[e]=[t,...a[e].filter(e=>e!==t)]);Object.assign(e.sessionOrderByAccount,a)},setArchivedFilter:(e,t)=>{e.archivedFilter=t}}})}function me(e,t){let n=L(e,t,/* @__PURE__ */ new Map),r=new Set(ae(e,t.archivedSessionIds,t.archivedFilter)),i=/* @__PURE__ */ new Set([...n.map(e=>e.id),...z(e,t.archivedSessionIds).filter(e=>!r.has(e))]),a={...e.byId};for(let e of n){let t=a[e.id];t!==void 0&&(a[e.id]={...t,updatedAt:e.tree?.updatedAt??e.updatedAt})}return{rootIds:i,summaries:a}}function he(e,t,n){let r=me(t,{...n,archivedFilter:n.archivedFilter??`default`}),i=e=>e.filter(e=>t.byId[e]===void 0||r.rootIds.has(e)),a=new Set(e.flatMap(e=>e.sessionIds));return{members:Object.fromEntries([...e.map(e=>[e.workspaceId,i(e.sessionIds)]),[``,i([.../* @__PURE__ */ new Set([...t.ids,...n.archivedSessionIds])]).filter(e=>!a.has(e))],[le,i(z(t,n.archivedSessionIds))]]),summaries:r.summaries,rowState:n}}function H(e,t){return[E(e,t),le]}var ge=class{sessions;workspaces;held=/* @__PURE__ */ new Map;recent=/* @__PURE__ */ new Map;running=/* @__PURE__ */ new Set;failed=/* @__PURE__ */ new Set;active=!1;reconciling=!1;dirty=!1;constructor(e,t){this.sessions=e,this.workspaces=t}start(){this.active=!0;let e=this.sessions.list.subscribe(()=>this.reconcile()),t=this.workspaces.list.subscribe(()=>this.reconcile());return this.reconcile(),()=>{this.active=!1,e(),t();let n=[...this.held.values()];this.held.clear(),this.recent.clear(),this.running.clear(),this.failed.clear();for(let{reference:e}of n)e.release()}}visit(e,t){this.active&&(this.failed.delete(e.sessionId),this.remember(e.sessionId,typeof t==`string`?this.sessions.subagentAddress(e.sessionId)??t:t),this.reconcile())}remember(e,t){this.recent.delete(e),this.recent.set(e,t)}reconcile(){if(this.active&&(this.dirty=!0,!this.reconciling)){this.reconciling=!0;try{for(;this.dirty&&this.active;)this.dirty=!1,this.update()}finally{this.reconciling=!1}}}update(){let e=this.sessions.list.getSnapshot(),t=new Set(e.ids),n=new Set(e.summaryOnlyIds??[]),r=new Set(this.workspaces.list.getSnapshot().archivedSessionIds),i=/* @__PURE__ */ new Set;for(let t of e.ids){let a=e.byId[t];a?.running&&a.origin!==`subagent`&&!r.has(t)&&(!n.has(t)||this.recent.has(t))&&i.add(t)}if(e.phase===`pending`)for(let e of this.running)r.has(e)||i.add(e);else for(let e of this.running)!i.has(e)&&t.has(e)&&!r.has(e)&&this.remember(e,e);this.running=i;for(let[n,i]of this.recent)(r.has(n)||this.sessions.binding(n)?.session.getSnapshot().removed||e.phase===`ready`&&!t.has(n)&&typeof i==`string`)&&this.recent.delete(n);let a=[...this.recent.keys()].filter(e=>!i.has(e));for(let e of a.slice(0,Math.max(0,a.length-8)))this.recent.delete(e);let o=new Map(this.recent);for(let e of i)o.set(e,e);for(let e of this.failed)o.has(e)||this.failed.delete(e);for(let[e,t]of this.held){let n=this.sessions.binding(e)!==t.binding;(!o.has(e)||n)&&(this.held.delete(e),n&&(this.recent.delete(e),this.failed.add(e)),t.reference.release())}for(let[e,t]of o){if(this.held.has(e)||this.failed.has(e))continue;let n;try{n=this.sessions.retain(t,{source:`backgroundWarm`});let r={reference:n,binding:n.binding};this.held.set(e,r),n.ready.catch(()=>this.fail(e,r))}catch{this.failed.add(e),n?.release()}}}fail(e,t){this.active&&this.held.get(e)===t&&(this.failed.add(e),this.held.delete(e),t.reference.release())}};let _e=`codexhost.web.session-tabs.v2:local`,ve=`codexhost.web.session-tabs.v1:local`,ye=`codexhost.web.recent-visits.v1:local`,be=1048576;function xe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Se(e){return typeof e==`string`&&e.length>0&&e.length<=1024&&e.trim()===e&&!/[\u0000-\u001f\u007f]/u.test(e)?f(e):void 0}function Ce(e,t){if(typeof e==`string`)return e===t?t:void 0;if(!xe(e)||Object.keys(e).length!==3)return;let n=Se(e.parentSessionId),r=Se(e.childSessionId),i=e.mode;if(!(n===void 0||r!==t||n===r||i!==`one-shot`&&i!==`continuable`&&i!==`unknown`))return{parentSessionId:n,childSessionId:r,mode:i}}function we(e,t){if(e===null||e.length>be)return[];try{let n=JSON.parse(e);if(!xe(n)||Object.keys(n).length!==2||n.version!==t||!Array.isArray(n.entries))return[];let r=[],i=/* @__PURE__ */ new Set,a=Date.now();for(let e of n.entries){if(!xe(e))continue;let n=Object.keys(e);if(t===2&&n.length!==3||n.length!==2&&(n.length!==3||!Object.hasOwn(e,`lastVisitedAt`)))continue;let o=Se(e.sessionId);if(o===void 0||i.has(o))continue;let s=Object.hasOwn(e,`lastVisitedAt`)?e.lastVisitedAt:a;if(typeof s!=`number`||!Number.isSafeInteger(s)||s<0||s>a)continue;let c=Ce(e.target,o);c!==void 0&&(i.add(o),r.push({sessionId:o,target:c,lastVisitedAt:s}))}return r}catch{return[]}}var U=class{onFailure;enabled=typeof window<`u`&&/^https?:$/u.test(window.location.protocol);reported=!1;constructor(e){this.onFailure=e}read(){if(!this.enabled)return[];try{return this.latest()}catch{return this.failed(),[]}}update(e,t){if(this.enabled)try{let n=this.latest().filter(e=>t?.(e)!==!0),r=new Map(n.map((e,t)=>[e.sessionId,t]));for(let i of e){if(t?.(i)===!0)continue;let e=r.get(i.sessionId);e===void 0?(r.set(i.sessionId,n.length),n.push(i)):n[e]=i}let i=JSON.stringify({version:2,entries:n.map(e=>({sessionId:e.sessionId,lastVisitedAt:e.lastVisitedAt,target:typeof e.target==`string`?e.target:{parentSessionId:e.target.parentSessionId,childSessionId:e.target.childSessionId,mode:e.target.mode}}))});if(i.length>be){this.failed();return}localStorage.getItem(_e)!==i&&localStorage.setItem(_e,i),localStorage.removeItem(ve),localStorage.removeItem(ye)}catch{this.failed()}}latest(){let e=localStorage.getItem(_e);return e===null?we(localStorage.getItem(ve)??localStorage.getItem(ye),1):we(e,2)}failed(){if(!this.reported){this.reported=!0;try{this.onFailure()}catch{}}}},Te=class{sessions;workspaces;subscribeRemoved;entries=(0,r.createSnapshotStore)([]);records=[];current;awaitingFormalSession=!1;active=!1;headRevision=0;restoring=!1;cache;constructor(e,t,n,r=()=>{}){this.sessions=e,this.workspaces=t,this.subscribeRemoved=n,this.cache=new U(r)}start(e){this.active=!0,this.headRevision=this.sessions.list.getSnapshot().headRefreshRevision??0,this.records=this.cache.read(),this.cache.update([]);let t=this.sessions.list.subscribe(()=>{let t=this.sessions.list.getSnapshot().headRefreshRevision??0;t!==this.headRevision&&(this.headRevision=t,this.restoreSummaries(this.current?.sessionId??e)),this.reconcile()}),n=this.workspaces.list.subscribe(()=>this.reconcile()),r=this.subscribeRemoved?.(e=>{this.sessions.subagentAddress(e)!==void 0||this.sessions.list.getSnapshot().byId[e]?.origin===`subagent`||this.records.some(t=>t.sessionId===e&&typeof t.target!=`string`)||(this.records=this.records.filter(t=>!this.includesIdentity(t,e)),this.cache.update([],t=>this.includesIdentity(t,e)),this.publish())});return this.reconcile(),this.restoreSummaries(e),()=>{this.active=!1,t(),n(),r?.(),this.current=void 0,this.awaitingFormalSession=!1,this.records=[],this.entries.set([])}}visit(e,t){let n=Date.now(),r=this.depart(n);r!==void 0&&this.remember(r),this.current={sessionId:e,target:typeof t==`string`?this.sessions.subagentAddress(e)??t:t,lastVisitedAt:n},this.awaitingFormalSession=!0,this.reconcile(r===void 0?[]:[r])}clearCurrent(){let e=this.depart(Date.now());e!==void 0&&this.remember(e),this.current=void 0,this.awaitingFormalSession=!1,this.reconcile(e===void 0?[]:[e])}depart(e){let t=this.current;return t!==void 0&&this.records.some(e=>e.sessionId===t.sessionId)&&this.formal(t)?{...t,lastVisitedAt:e}:void 0}close(e){this.records=this.records.filter(t=>t.sessionId!==e),this.cache.update([],t=>t.sessionId===e),this.current?.sessionId===e&&(this.awaitingFormalSession=!1),this.publish()}closeAll(){let e=new Set(this.records.map(e=>e.sessionId));this.records=[],this.awaitingFormalSession=!1,this.cache.update([],t=>e.has(t.sessionId)),this.publish()}expireInactive(e,t,n=Date.now()){let r=this.sessions.list.getSnapshot();if(!this.active||!Number.isFinite(e)||e<=0||r.phase!==`ready`||r.loading===!0||r.listError!=null||this.workspaces.list.getSnapshot().phase!==`ready`)return!1;let i=new Set(this.entries.getSnapshot().map(e=>e.sessionId)),a=a=>{let o=r.byId[a.sessionId];if(a.sessionId===this.current?.sessionId||!i.has(a.sessionId)||o===void 0||o.blank||(o.retainedBy.mainView??0)>0||o.running||t.get(a.sessionId)?.pendingInteraction!==void 0||typeof a.target!=`string`&&t.get(a.sessionId)?.running===void 0||!Number.isFinite(o.updatedAt))return!1;let s=re(o,r,t);return s.running||s.runningSubagentCount>0?!1:n-Math.max(a.lastVisitedAt,o.updatedAt)>=e},o=new Set(this.records.filter(a).map(e=>e.sessionId));return o.size!==0&&(this.records=this.records.filter(e=>!o.has(e.sessionId)),this.cache.update([],e=>o.has(e.sessionId)&&a(e)),this.publish(),!0)}remember(e){let t=this.records.findIndex(t=>t.sessionId===e.sessionId);this.records=t===-1?[...this.records,e]:this.records.map((n,r)=>r===t?e:n)}formal(e){let t=this.sessions.list.getSnapshot();return t.byId[e.sessionId]?.blank===!1&&!this.invalid(e,t)}reconcile(e=[]){if(!this.active)return;let t=this.sessions.list.getSnapshot(),n=new Set(this.records.filter(e=>this.invalid(e,t)).map(e=>e.sessionId));this.records=this.records.filter(e=>!n.has(e.sessionId));let r=[...e],i=this.current;this.awaitingFormalSession&&i!==void 0&&this.formal(i)&&(this.awaitingFormalSession=!1,this.remember(i),r.push(i)),this.publish(),(r.length>0||n.size>0)&&this.cache.update(r,e=>n.has(e.sessionId))}publish(){let e=this.sessions.list.getSnapshot(),t=this.workspaces.list.getSnapshot().phase===`ready`,n=this.records.flatMap(n=>{if(!t||e.byId[n.sessionId]?.blank!==!1||this.invalid(n,e))return[];if(typeof n.target==`string`)return[n];let r=this.sessions.subagentAddress(n.sessionId);if(r===void 0||r.parentSessionId!==n.target.parentSessionId||r.childSessionId!==n.sessionId)return[];if(r.mode===n.target.mode)return[n];let i={...n,target:r};return this.records=this.records.map(e=>e===n?i:e),[i]}),r=this.entries.getSnapshot();(n.length!==r.length||n.some((e,t)=>e!==r[t]))&&this.entries.set(n)}restoreSummaries(e=this.current?.sessionId){if(this.restoring)return;let t=this.records.filter(t=>t.sessionId!==e&&this.sessions.list.getSnapshot().byId[t.sessionId]===void 0);if(t.length===0)return;this.restoring=!0;let n=0;Promise.all(Array.from({length:Math.min(4,t.length)},async()=>{for(;this.active;){let e=t[n++];if(e===void 0)return;let r=e.sessionId;if(this.records.some(e=>e.sessionId===r)&&this.sessions.list.getSnapshot().byId[r]===void 0){try{await this.sessions.loadSummary(r)}catch{}this.active&&this.reconcile()}}})).finally(()=>{this.restoring=!1})}includesIdentity(e,t){if(e.sessionId===t)return!0;if(typeof e.target==`string`)return!1;let n=/* @__PURE__ */ new Set,r=e.target.parentSessionId;for(;r!==void 0&&!n.has(r);){if(r===t)return!0;n.add(r),r=this.sessions.subagentAddress(r)?.parentSessionId}return!1}invalid(e,t){let n=this.workspaces.list.getSnapshot().archivedSessionIds,r=e=>n.includes(e)||this.sessions.binding(e)?.session.getSnapshot().removed===!0;if(r(e.sessionId))return!0;if(typeof e.target==`string`)return!1;let i=/* @__PURE__ */ new Set([e.sessionId]),a=e.target;for(;!i.has(a.parentSessionId);){if(r(a.parentSessionId)||Ee(t,a.parentSessionId,a.childSessionId))return!0;i.add(a.parentSessionId);let e=this.sessions.subagentAddress(a.parentSessionId);if(e===void 0)break;a=e}return!1}};function Ee(e,t,n){let r=e.projectionsBySession[t];return e.phase===`ready`&&r?.state!==`loading`&&r?.state!==`error`&&r?.values.subagentCatalog!==void 0&&!r.values.subagentCatalog.some(e=>e.id===n)}var De=class extends Error{rpcError;name=`DirectoryBrowseError`;constructor(e){super(`directory browse failed: ${e.code}: ${e.message}`),this.rpcError=e}},Oe=class extends i.Service{directoryPicker;workspaces;sessions;view;notify;connecting=/* @__PURE__ */ new Map;lifetime=new AbortController;selection=(0,r.createSnapshotStore)({},{persist:{name:`dsh.sessions.current`}});mainReference;opening=(0,r.createSnapshotStore)({state:`idle`});retryOpen;openingLoad;keepalive;recentVisits;constructor(e,t,n,r,i,a){super(e,`uiWorkspace`),this.directoryPicker=t,this.workspaces=n,this.sessions=r,this.view=i,this.notify=a,this.keepalive=new ge(r,n);let o=e.get(`remote`);this.recentVisits=new Te(r,n,o===void 0?void 0:e=>o.$on(`api-session/removed`,e),()=>a({kind:`recentVisitsStorageFailed`})),e.effect(()=>{let e=this.selection.getSnapshot(),t=this.recentVisits.start(e.subagentAddress?.childSessionId??e.sessionId),n=this.keepalive.start(),r=this.watchNavigation();return()=>{r(),this.lifetime.abort(),n(),t();let e=this.mainReference;this.mainReference=void 0,e?.release()}},`ui-workspace: Workspace navigation policy`)}async connectWorkspace(e){let t=this.workspaces.list.getSnapshot().items.find(t=>t.workspaceId===e);if(t===void 0)throw Error(`uiWorkspace.connectWorkspace: unknown workspace ${e}`);let n=this.connecting.get(e);if(n!==void 0)return n;let r=this.reuseOrCreateBlank(t).finally(()=>{this.connecting.delete(e)});return this.connecting.set(e,r),r}reuseOrCreateBlank(e){let t=this.workspaces.list.getSnapshot().archivedSessionIds,n=this.sessions.list.getSnapshot();for(let r of n.ids){let i=n.byId[r];if(i!==void 0&&i.blank&&i.cwd===e.path&&e.sessionIds.includes(r)&&!t.includes(r))return this.reuseBlank(e.workspaceId,r)}return this.sessions.create({workspaceId:e.workspaceId})}async reuseBlank(e,t){try{return await this.sessions.create({workspaceId:e,sessionId:t})}catch(t){if(W(t)?.rpcError.code!==`session/writer-held`)throw t;return this.sessions.create({workspaceId:e})}}openSession(e){let t=AbortSignal.any([this.ctx.layout.beginNavigation(),this.lifetime.signal]);this.opening.set({state:`idle`}),this.retryOpen=void 0,typeof e!=`string`||this.sessions.list.getSnapshot().byId[e]!==void 0?this.replaceMain(e,t,`reveal`):this.resolveSession(e,t,()=>{this.replaceMain(e,t,`reveal`)},()=>this.openSession(e))}closeSessionTab(e){this.recentVisits.close(e)}closeAllSessionTabs(){this.recentVisits.closeAll()}retryOpening(){this.retryOpen?.()}async resolveSession(e,t,n,r){if(t.aborted)return;this.openingLoad?.stop(),this.retryOpen=void 0;let i={stop:()=>t.removeEventListener(`abort`,a)},a=()=>{i.stop(),this.openingLoad===i&&(this.openingLoad=void 0,this.opening.set({state:`idle`}),this.retryOpen=void 0)};t.addEventListener(`abort`,a,{once:!0}),this.openingLoad=i,this.opening.set({state:`loading`,sessionId:e});try{if(t.aborted||this.openingLoad!==i||(await this.sessions.loadSummary(e),t.aborted||this.openingLoad!==i))return;if(this.sessions.list.getSnapshot().byId[e]===void 0)throw Error(`Session not found: ${e}`);n(),a()}catch(n){if(t.aborted||this.openingLoad!==i)return;this.retryOpen=r,this.opening.set({state:`error`,sessionId:e,message:ke(n)})}}async openWorkspace(e,t){let n=AbortSignal.any([this.ctx.layout.beginNavigation(),this.lifetime.signal]),r;try{if(e===null&&!this.workspaces.list.getSnapshot().canStartProjectless)throw Error(`This Host requires a Workspace.`);r=e===null?await this.sessions.create():await this.connectWorkspace(e)}catch(e){throw n.aborted||this.notify({kind:`createFailed`,message:ke(e)}),e}n.aborted||this.replaceMain(r,n,`reveal`,t)}async forkSession(e,t){return this.sessions.fork({sessionId:e,increaseTitle:!0,...t===void 0?{}:{onCreated:t}})}startSession(e,t){let n=t===void 0?void 0:{...t},r=n!==void 0&&(n.prompt!==void 0||n.clearPreviousDraft===!0),i=this.workspaces.list.getSnapshot(),a=this.sessions.list.getSnapshot(),o=this.mainReference?.sessionId,s=o===void 0?void 0:i.items.find(e=>e.sessionIds.includes(o))?.workspaceId,c=i.phase===`ready`&&a.phase===`ready`?Ae(i.items,a.byId):void 0,l=e??(i.canStartProjectless?null:s??c);if(l===void 0){if(this.ctx.layout.beginNavigation(),r){this.notify({kind:`createFailed`,message:this.ctx.locale.bind(`workspace`)(`draft.workspaceRequired`)});return}this.clearMain()}else this.openWorkspace(l,r?e=>{let t=this.sessions.binding(e);t===void 0&&this.draftPreparationFailed(),this.prepareDraft(t,n)}:void 0).catch(e=>{console.warn(`new session failed:`,e)})}prepareDraft(e,t){let n=this.ctx.get(`conversation`);n===void 0&&this.draftPreparationFailed(),n.input.requestDraftInitialization(e,t)===`blocked`&&this.draftPreparationFailed()}draftPreparationFailed(){let e=this.ctx.locale.bind(`workspace`)(`draft.initializationFailed`);throw this.notify({kind:`createFailed`,message:e}),Error(e)}async archiveSession(e,t={}){await this.workspaces.archiveSession(e,t),this.mainReference?.sessionId===e&&this.clearMain()}async unarchiveSession(e){await this.workspaces.unarchiveSession(e)}async pinSession(e){await this.workspaces.pinSession(e);let{items:t,pinnedSessionIds:n,archivedSessionIds:r}=this.workspaces.list.getSnapshot();this.view.pinSessionOrder(e,H(t,e),he(t,this.sessions.list.getSnapshot(),{pinnedSessionIds:n,archivedSessionIds:r}))}async unpinSession(e){await this.workspaces.unpinSession(e)}async pickDirectory(){let e=await this.directoryPicker.pick();if(!e.ok)throw Error(`directory picker failed: ${e.error.message}`);return e.value}async listDirectory(e,t){let n=await this.directoryPicker.list(e,t);if(!n.ok)throw new De(n.error);return n.value}async createDirectory(e,t){let n=await this.directoryPicker.createDirectory(e,t);if(!n.ok)throw new De(n.error);return n.value}watchNavigation(){let e=`waiting`,t=AbortSignal.any([this.ctx.layout.beginNavigation(),this.lifetime.signal]);t.addEventListener(`abort`,()=>{e=`done`},{once:!0});let n=()=>{if(this.lifetime.signal.aborted||this.clearArchivedCurrent()||e!==`waiting`)return;let n=this.workspaces.list.getSnapshot(),r=this.sessions.list.getSnapshot();this.mainReference===void 0?n.phase===`ready`&&r.phase===`ready`&&(e=`connecting`,this.restoreSelection(n,r,t).then(()=>{e=`done`},n=>{t.aborted||(e=`waiting`,console.warn(`initial Session restoration failed:`,n))})):e=`done`},r=this.workspaces.list.subscribe(n),i=this.sessions.list.subscribe(n),a=this.selection.getSnapshot();if(a.sessionId!==void 0||a.subagentAddress!==void 0){if(e=`connecting`,a.subagentAddress!==void 0)this.replaceMain(a.subagentAddress,t,`preserve`),e=`done`;else if(a.sessionId!==void 0){let r=a.sessionId,i=()=>{this.resolveSession(r,t,()=>{this.sessions.list.getSnapshot().byId[r]?.blank===!0?(e=`waiting`,n()):(this.replaceMain(r,t,`preserve`),e=`done`)},i)};i()}}return n(),()=>{this.lifetime.abort(),i(),r()}}async restoreSelection(e,t,n){let r=this.selection.getSnapshot();if(r.subagentAddress!==void 0){this.replaceMain(r.subagentAddress,n,`preserve`);return}let i=r.sessionId===void 0?void 0:t.byId[r.sessionId],a=i===void 0?void 0:e.items.find(e=>e.sessionIds.includes(i.id));if(i!==void 0&&(!i.blank||a===void 0)){this.replaceMain(i.id,n,`preserve`);return}let o;if(i!==void 0&&a!==void 0&&i.cwd===a.path&&!e.archivedSessionIds.includes(i.id)&&(o=await this.reuseBlank(a.workspaceId,i.id)),o===void 0&&e.canStartProjectless&&i===void 0){o=await this.sessions.create(),n.aborted||this.replaceMain(o,n,`preserve`);return}let s=a?.workspaceId??Ae(e.items,t.byId);if(s===void 0&&e.items.length===0&&t.ids.length===0){let e=await this.initializeDefaultWorkspace(n);if(n.aborted)return;s=e?.workspaceId}o===void 0&&s!==void 0&&(o=await this.connectWorkspace(s)),o!==void 0&&!n.aborted&&this.replaceMain(o,n,`preserve`)}async initializeDefaultWorkspace(e){try{return await this.workspaces.initializeDefault(e)}catch{e.aborted||this.notify({kind:`defaultWorkspaceFailed`});return}}clearArchivedCurrent(){let e=this.mainReference?.sessionId;return e===void 0||!this.workspaces.list.getSnapshot().archivedSessionIds.includes(e)?!1:(this.clearMain(),!0)}clearMain(){let e=this.mainReference;this.mainReference=void 0,this.recentVisits.clearCurrent(),this.selection.set({}),e?.release(),this.ctx.layout.selectPanel(null)}replaceMain(e,t,n,r){t.throwIfAborted();let i=this.sessions.retain(e,{source:`mainView`});try{if(t.throwIfAborted(),r?.(i.sessionId),t.aborted){i.release();return}let n=typeof e==`string`?this.sessions.subagentAddress(i.sessionId):e;this.selection.set({sessionId:i.sessionId,...n===void 0?{}:{subagentAddress:n}})}catch(e){throw i.release(),e}let a=this.mainReference;this.mainReference=i,this.keepalive.visit(i,e),this.recentVisits.visit(i.sessionId,e),a?.release(),n===`reveal`&&this.ctx.layout.selectPanel(null)}};function W(e){return e instanceof Error&&e.name===`SessionCreateError`?e:void 0}function ke(e){let t=W(e);return t===void 0?e instanceof Error?e.message:String(e):`${t.rpcError.code}: ${t.rpcError.message}`}function Ae(e,t){let n,r=-1/0;for(let i of e){let e=-1/0;for(let n of i.sessionIds){let r=t[n];r!==void 0&&(e=Math.max(e,r.updatedAt))}e===-1/0&&(e=Date.parse(i.createdAt)),(n===void 0||e>r)&&(n=i.workspaceId,r=e)}return n}let je=`@deepseek-ai/dsh-client-ui-workspace/RecentShortcut.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(je)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=je,e.textContent=`.oOF3UG_shortcut{isolation:isolate;box-sizing:border-box;width:max-content;min-width:0;max-width:min(164px,100% - 24px);min-height:44px;color:var(--dsw-alias-label-primary);background:0 0;border:0;border-radius:8px;flex:none;align-items:center;padding:0;font-size:13px;font-weight:500;line-height:20px;display:inline-flex;position:relative}.oOF3UG_select,.oOF3UG_close{border-radius:inherit;min-height:44px;color:inherit;font:inherit;cursor:pointer;background:0 0;border:0;align-items:center;padding:0;display:inline-flex}.oOF3UG_select{box-sizing:border-box;text-align:start;flex:1;align-self:stretch;gap:6px;min-width:44px;padding-inline-start:8px}.oOF3UG_close{width:44px;color:var(--dsw-alias-label-secondary);flex:0 0 44px;justify-content:center}.oOF3UG_close:active{color:var(--dsw-alias-label-primary)}.oOF3UG_shortcut:before{content:"";z-index:-1;box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l2);border-radius:inherit;background:var(--dsw-alias-bg-module-platform);box-shadow:inset 0 .5px 0 color-mix(in srgb, var(--dsw-alias-bg-layer-1) 65%, transparent), 0 1px 3px color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent);pointer-events:none;position:absolute;inset:6px 0}.oOF3UG_shortcut[data-active]:before{border-width:1px;border-color:color-mix(in srgb, var(--dsw-alias-label-primary) 34%, var(--dsw-alias-border-l2));background:color-mix(in srgb, var(--dsw-alias-bg-module-platform) 90%, var(--dsw-alias-label-primary))}.oOF3UG_shortcut:active:before{background:var(--dsw-alias-button-ghost-active-fill)}@supports (backdrop-filter:blur(8px)){.oOF3UG_shortcut:before{background:color-mix(in srgb, var(--dsw-alias-bg-module-platform) 64%, transparent);backdrop-filter:blur(8px)saturate(115%)}.oOF3UG_shortcut[data-active]:before{background:color-mix(in srgb, color-mix(in srgb, var(--dsw-alias-bg-module-platform) 90%, var(--dsw-alias-label-primary)) 82%, transparent)}.oOF3UG_shortcut:active:before{background:color-mix(in srgb, var(--dsw-alias-button-ghost-active-fill) 82%, transparent)}}.oOF3UG_select:focus-visible,.oOF3UG_close:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:-2px}.oOF3UG_identity{flex:0 0 14px;justify-content:center;align-items:center;width:14px;height:14px;display:inline-flex}.oOF3UG_title{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}.oOF3UG_activity{flex:none;justify-content:center;align-items:center;display:inline-flex}@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){.oOF3UG_shortcut:before,.oOF3UG_shortcut[data-active]:before{border-color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-module-platform);backdrop-filter:none;box-shadow:none}.oOF3UG_shortcut[data-active]:before{border-width:1px;border-color:var(--dsw-alias-label-primary)}.oOF3UG_shortcut:active:before{background:var(--dsw-alias-button-ghost-active-fill)}}@media (forced-colors:active){.oOF3UG_shortcut{color:buttontext}.oOF3UG_shortcut:before{backdrop-filter:none;box-shadow:none;background:buttonface;border:1px solid buttontext}.oOF3UG_shortcut[data-active],.oOF3UG_shortcut:active{color:highlighttext}.oOF3UG_shortcut[data-active]:before,.oOF3UG_shortcut:active:before{background:highlight;border-color:highlight}.oOF3UG_close,.oOF3UG_close:active{color:inherit}.oOF3UG_select:focus-visible,.oOF3UG_close:focus-visible{outline-color:highlight}.oOF3UG_shortcut[data-active] .oOF3UG_select:focus-visible,.oOF3UG_shortcut[data-active] .oOF3UG_close:focus-visible{outline-color:highlighttext}}`,document.head.appendChild(e)}var G={activity:`oOF3UG_activity`,close:`oOF3UG_close`,identity:`oOF3UG_identity`,select:`oOF3UG_select`,shortcut:`oOF3UG_shortcut`,title:`oOF3UG_title`};function Me({visit:e,summary:t,identity:n,activityLabel:r,activity:i,active:c,closeLabel:l,closeHint:u,open:d,close:f,restoreNavigationFocus:p}){let m=(0,a.useRef)(null),h=(0,a.useCallback)(e=>{e===null&&m.current?.contains(document.activeElement)&&p(),m.current=e},[p]);return/* @__PURE__ */ (0,s.jsxs)(`div`,{ref:h,className:G.shortcut,"data-active":c||void 0,children:[/* @__PURE__ */ (0,s.jsxs)(`button`,{type:`button`,className:G.select,onMouseDown:e=>e.preventDefault(),title:t.displayTitle,"aria-current":c?`page`:void 0,"aria-label":[t.displayTitle,t.id,r].filter(Boolean).join(` · `),onClick:()=>{c||(p(),d(e.target))},children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:G.identity,children:n}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:G.title,children:t.displayTitle}),i!=null&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:G.activity,title:r,children:i})]}),/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:G.close,onMouseDown:e=>e.preventDefault(),"aria-label":l,title:u,onClick:()=>{p(),f(e.sessionId)},children:/* @__PURE__ */ (0,s.jsx)(o.IconCloseOutlineRegular,{size:12})})]})}let Ne=`@deepseek-ai/dsh-client-ui-workspace/Rows.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ne)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Ne,e.textContent=`._5OaiBG_hostBadge{max-width:96px;color:var(--dsw-alias-label-secondary);flex-shrink:0;align-items:center;gap:6px;font-size:11px;display:inline-flex}._5OaiBG_hostBadge>span:first-child{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}._5OaiBG_hostDot{background:#92949a;border-radius:50%;flex-shrink:0;width:7px;height:7px}._5OaiBG_hostBadge[data-state=connected] ._5OaiBG_hostDot{background:#16a34a}._5OaiBG_hostBadge[data-state=connecting] ._5OaiBG_hostDot{background:#d97706}._5OaiBG_projectRow,._5OaiBG_sessionRow{--dsh-row-surface:var(--dsw-specific-sidebar-fill);border-radius:var(--dsw-radius-md);padding:0 8px;cursor:pointer;-webkit-tap-highlight-color:transparent;user-select:none;color:var(--dsw-alias-label-primary);align-items:center;gap:6px;padding-inline-start:calc(8px + var(--dsh-workspace-indent,0px));display:flex;position:relative}._5OaiBG_projectRow:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen),._5OaiBG_sessionRow:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen){--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 4%, var(--dsw-specific-sidebar-fill));background:var(--dsh-row-surface)}._5OaiBG_sessionRow._5OaiBG_selected{--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, var(--dsw-specific-sidebar-fill));background:var(--dsh-row-surface)}._5OaiBG_sessionRow._5OaiBG_selected:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen){--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 8%, var(--dsw-specific-sidebar-fill))}._5OaiBG_sessionRow,._5OaiBG_searchResultRow{--ch-sidebar-text-primary:#1a1c1f;letter-spacing:normal;color:color-mix(in oklab, var(--ch-sidebar-text-primary) 85%, transparent);font-family:-apple-system,"system-ui",Segoe UI,sans-serif;font-size:14px;font-weight:430;line-height:20px}body[data-ds-dark-theme] ._5OaiBG_sessionRow,body[data-ds-dark-theme] ._5OaiBG_searchResultRow{--ch-sidebar-text-primary:#fff}._5OaiBG_projectRow:focus-visible,._5OaiBG_sessionRow:focus-visible,._5OaiBG_iconButton:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}._5OaiBG_searchResultRow{box-sizing:border-box;border-radius:var(--dsw-radius-lg);cursor:pointer;text-align:left;background:0 0;border:none;flex-direction:column;align-items:stretch;width:100%;min-height:48px;padding:4px 8px;display:flex}._5OaiBG_searchResultRow:hover,._5OaiBG_searchResultRow._5OaiBG_selected{background:var(--dsw-alias-interactive-bg-hover)}._5OaiBG_searchResultHeading{align-items:center;min-width:0;display:flex}._5OaiBG_searchResultTitle{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;margin-left:4px;font-size:14px;line-height:20px;overflow:hidden}._5OaiBG_searchResultMeta{align-items:center;gap:6px;min-width:0;margin-left:20px;display:flex}._5OaiBG_searchResultWorkspace,._5OaiBG_searchResultSnippet{text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:17px;overflow:hidden}._5OaiBG_searchResultWorkspace{max-width:40%;color:var(--dsw-alias-label-tertiary);flex:none}._5OaiBG_searchResultWorkspace:only-child{max-width:100%}._5OaiBG_searchResultSnippet{min-width:0;color:var(--dsw-alias-label-secondary);flex:1}._5OaiBG_projectRow{box-sizing:border-box;align-items:center;height:34px}._5OaiBG_sessionRow{box-sizing:border-box;min-width:0;max-width:100%;flex-direction:column;align-items:stretch;gap:0;padding-inline-start:calc(8px + var(--dsh-workspace-indent,0px) + var(--dsh-thread-indent,0px))}._5OaiBG_sessionMain{min-width:0;height:var(--dsh-thread-row-height);flex:none;align-items:center;display:flex;position:relative}._5OaiBG_identityButton{appearance:none;cursor:pointer;background:0 0;border:0;border-radius:4px;padding:0}._5OaiBG_foldChevron{justify-content:center;align-items:center;display:none;position:absolute;inset:0}._5OaiBG_foldChevron:before{content:"";border-bottom:1.5px solid;border-right:1.5px solid;width:6px;height:6px;transform:translate(-1px)rotate(-45deg)}._5OaiBG_identityButton[aria-expanded=true] ._5OaiBG_foldChevron:before{transform:translateY(-1px)rotate(45deg)}._5OaiBG_identityButton[aria-expanded=true]>:not(._5OaiBG_foldChevron){visibility:hidden}._5OaiBG_identityButton[aria-expanded=true] ._5OaiBG_foldChevron{color:var(--dsw-alias-label-secondary,currentColor);display:flex}@media (hover:hover) and (pointer:fine){._5OaiBG_identityButton:hover>:not(._5OaiBG_foldChevron),._5OaiBG_identityButton:focus-visible>:not(._5OaiBG_foldChevron){visibility:hidden}._5OaiBG_identityButton:hover ._5OaiBG_foldChevron,._5OaiBG_identityButton:focus-visible ._5OaiBG_foldChevron{color:var(--dsw-alias-text-secondary,currentColor);display:flex}}._5OaiBG_identityButton:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}._5OaiBG_sessionRow ._5OaiBG_title{margin:0 6px 0 4px}._5OaiBG_slot{width:16px;height:20px;color:var(--dsw-alias-label-tertiary);flex:none;justify-content:center;align-items:center;display:inline-flex;position:relative}._5OaiBG_slot:has([data-harness-id]){width:14px;color:inherit}._5OaiBG_sessionRow:has([data-harness-id]) ._5OaiBG_title,._5OaiBG_searchResultHeading:has([data-harness-id]) ._5OaiBG_searchResultTitle{margin-left:8px}._5OaiBG_statusOverlay{display:contents}._5OaiBG_slot:has([data-harness-id]) ._5OaiBG_statusOverlay{transform-origin:100% 100%;display:inline-flex;position:absolute;bottom:-3px;right:-3px;transform:scale(.65)}._5OaiBG_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}._5OaiBG_projectRow>._5OaiBG_slot:not(._5OaiBG_folderExpanded){color:inherit}._5OaiBG_folderExpanded{color:var(--dsw-alias-state-business-primary)}._5OaiBG_projectText{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}._5OaiBG_title{text-overflow:ellipsis;white-space:nowrap;min-width:0;font-size:14px;line-height:20px;overflow:hidden}._5OaiBG_renameInput{border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-button-elevated-fill);min-width:0;color:inherit;outline:none;padding:0 2px;font-size:14px;line-height:20px}._5OaiBG_sessionRow ._5OaiBG_title{flex:1}._5OaiBG_meta{text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:20px;overflow:hidden}._5OaiBG_trailing{flex:none;place-items:center end;display:grid}._5OaiBG_trailing:empty{display:none}._5OaiBG_trailing>*{grid-area:1/1}._5OaiBG_time{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-tertiary);flex:none;font-size:10px;line-height:16px}._5OaiBG_timeStatus{justify-content:center;align-items:center;gap:6px;min-width:16px;height:20px;display:inline-flex}._5OaiBG_timeStatus [data-state=done]{color:var(--dsw-alias-state-business-primary)}._5OaiBG_timeStatus ._5OaiBG_visuallyHidden{visibility:visible}._5OaiBG_sessionRow._5OaiBG_archived ._5OaiBG_title,._5OaiBG_searchResultRow._5OaiBG_archived ._5OaiBG_searchResultTitle,._5OaiBG_searchResultRow._5OaiBG_archived ._5OaiBG_searchResultWorkspace,._5OaiBG_searchResultRow._5OaiBG_archived ._5OaiBG_searchResultSnippet{color:var(--dsw-alias-label-caption)}._5OaiBG_dot{flex:none}._5OaiBG_quickActions{align-items:center;gap:2px;display:inline-flex}._5OaiBG_rowActions{visibility:hidden;pointer-events:none;flex:none;align-items:center;gap:2px;display:inline-flex}._5OaiBG_projectRow:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen) ._5OaiBG_rowActions,._5OaiBG_sessionRow:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen) ._5OaiBG_rowActions,._5OaiBG_searchResultRow:is(:hover,:focus-visible,:has(:focus-visible)) ._5OaiBG_rowActions{visibility:visible;pointer-events:auto}._5OaiBG_searchResultHeading ._5OaiBG_rowActions{margin-left:auto}@media (hover:hover) and (pointer:fine){._5OaiBG_sessionRow:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen) ._5OaiBG_time{visibility:hidden}._5OaiBG_projectRow>._5OaiBG_rowActions,._5OaiBG_sessionRow ._5OaiBG_rowActions{inset-inline-end:0;z-index:1;background:var(--dsh-row-surface);border-radius:var(--dsw-radius-sm);position:absolute;top:50%;transform:translateY(-50%)}._5OaiBG_projectRow>._5OaiBG_rowActions{inset-inline-end:8px}._5OaiBG_projectRow>._5OaiBG_rowActions:before,._5OaiBG_sessionRow ._5OaiBG_rowActions:before{content:"";background:linear-gradient(to right, transparent, var(--dsh-row-surface));pointer-events:none;width:12px;position:absolute;inset-block:0;inset-inline-end:100%}}[data-phone-drawer] ._5OaiBG_sessionRow{min-height:44px}[data-phone-drawer] ._5OaiBG_sessionRow:has(>[data-thread-summary]){grid-template-columns:var(--dsh-thread-icon-size,16px) minmax(0, 1fr) auto;grid-template-rows:24px 24px;column-gap:8px;padding-block:2px;display:grid}[data-phone-drawer] ._5OaiBG_sessionRow:has(>[data-thread-summary]) ._5OaiBG_sessionMain{display:contents;position:static}[data-phone-drawer] ._5OaiBG_sessionRow:has(>[data-thread-summary]) ._5OaiBG_slot{grid-area:1/1;align-self:center}[data-phone-drawer] ._5OaiBG_sessionRow:has(>[data-thread-summary]) ._5OaiBG_title{grid-area:1/2;align-self:center;margin:0}[data-phone-drawer] ._5OaiBG_sessionRow:has(>[data-thread-summary]) ._5OaiBG_trailing{grid-area:1/3/span 2;align-self:center}[data-phone-drawer] ._5OaiBG_sessionRow>[data-thread-summary]{text-overflow:ellipsis;white-space:nowrap;grid-area:2/2;width:100%;margin:0;padding-inline:0;overflow:hidden}._5OaiBG_phoneDetails{padding:8px 8px 16px}._5OaiBG_phoneDetails ._5OaiBG_hoverTitle{display:none}._5OaiBG_phoneDetails :is(._5OaiBG_hoverTitle,._5OaiBG_hoverTime,._5OaiBG_hoverStatus,._5OaiBG_hoverPath){color:inherit}._5OaiBG_sessionRow._5OaiBG_dropBefore,._5OaiBG_sessionRow._5OaiBG_dropAfter{position:relative}._5OaiBG_sessionRow._5OaiBG_dropBefore:before,._5OaiBG_sessionRow._5OaiBG_dropAfter:after{content:"";z-index:1;background:linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat, linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat, linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;pointer-events:none;height:12px;position:absolute;left:0;right:4px}._5OaiBG_sessionRow._5OaiBG_dropBefore:before{top:-7px}._5OaiBG_sessionRow._5OaiBG_dropAfter:after{bottom:-7px}._5OaiBG_hoverContent{flex-direction:column;gap:8px;display:flex}._5OaiBG_hoverTitle{color:#fff;overflow-wrap:break-word;font-size:14px;line-height:20px}._5OaiBG_hoverPath{color:#cfd3d6;word-break:break-all;font-size:12px;line-height:16px}._5OaiBG_hoverTime{color:#cfd3d6;font-size:12px;line-height:16px}._5OaiBG_hoverStatus{color:#adb2b8;align-items:center;gap:8px;font-size:12px;line-height:20px;display:flex}._5OaiBG_hoverArchived svg{flex-shrink:0;margin:0 -4px}._5OaiBG_iconButton{cursor:pointer;-webkit-tap-highlight-color:transparent;width:24px;height:24px;color:var(--dsw-alias-label-tertiary);background:0 0;border:none;border-radius:4px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}._5OaiBG_iconButton:hover{color:var(--dsw-alias-label-primary);background:color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent)}[data-phone-drawer] :is(._5OaiBG_projectRow,._5OaiBG_sessionRow){--dsh-row-surface:transparent;background:var(--dsh-row-surface)}[data-phone-drawer] :is(._5OaiBG_projectRow,._5OaiBG_sessionRow):is(:active,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen){--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 3%, transparent)}[data-phone-drawer] ._5OaiBG_sessionRow._5OaiBG_selected{--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}[data-phone-drawer] ._5OaiBG_rowActions,[data-phone-drawer] ._5OaiBG_rowActions:before{background:0 0}[data-phone-drawer] ._5OaiBG_iconButton{width:44px;height:44px;color:var(--dsw-alias-label-tertiary);background:0 0}[data-phone-drawer] ._5OaiBG_iconButton:active{color:var(--dsw-alias-label-primary)}@media (hover:none),(pointer:coarse){._5OaiBG_projectRow,._5OaiBG_sessionRow{min-height:44px}._5OaiBG_rowActions{visibility:visible;pointer-events:auto}._5OaiBG_sessionRow ._5OaiBG_quickActions{display:none}._5OaiBG_sessionRow ._5OaiBG_trailing{align-items:center;gap:4px;display:flex}._5OaiBG_sessionRow ._5OaiBG_time:not(._5OaiBG_timeStatus){display:none}._5OaiBG_sessionRow ._5OaiBG_timeStatus{visibility:visible;padding-inline-end:0}._5OaiBG_iconButton{width:44px;height:44px}}`,document.head.appendChild(e)}var K={archived:`_5OaiBG_archived`,dot:`_5OaiBG_dot`,dropAfter:`_5OaiBG_dropAfter`,dropBefore:`_5OaiBG_dropBefore`,foldChevron:`_5OaiBG_foldChevron`,folderExpanded:`_5OaiBG_folderExpanded`,hostBadge:`_5OaiBG_hostBadge`,hostDot:`_5OaiBG_hostDot`,hoverArchived:`_5OaiBG_hoverArchived`,hoverContent:`_5OaiBG_hoverContent`,hoverPath:`_5OaiBG_hoverPath`,hoverStatus:`_5OaiBG_hoverStatus`,hoverTime:`_5OaiBG_hoverTime`,hoverTitle:`_5OaiBG_hoverTitle`,iconButton:`_5OaiBG_iconButton`,identityButton:`_5OaiBG_identityButton`,menuOpen:`_5OaiBG_menuOpen`,meta:`_5OaiBG_meta`,phoneDetails:`_5OaiBG_phoneDetails`,projectRow:`_5OaiBG_projectRow`,projectText:`_5OaiBG_projectText`,quickActions:`_5OaiBG_quickActions`,renameInput:`_5OaiBG_renameInput`,rowActions:`_5OaiBG_rowActions`,searchResultHeading:`_5OaiBG_searchResultHeading`,searchResultMeta:`_5OaiBG_searchResultMeta`,searchResultRow:`_5OaiBG_searchResultRow`,searchResultSnippet:`_5OaiBG_searchResultSnippet`,searchResultTitle:`_5OaiBG_searchResultTitle`,searchResultWorkspace:`_5OaiBG_searchResultWorkspace`,selected:`_5OaiBG_selected`,sessionMain:`_5OaiBG_sessionMain`,sessionRow:`_5OaiBG_sessionRow`,slot:`_5OaiBG_slot`,statusOverlay:`_5OaiBG_statusOverlay`,time:`_5OaiBG_time`,timeStatus:`_5OaiBG_timeStatus`,title:`_5OaiBG_title`,trailing:`_5OaiBG_trailing`,visuallyHidden:`_5OaiBG_visuallyHidden`};function Pe(e,t){let n=e.runningSubagentCount===0?void 0:{state:`ongoing`,label:t(e.runningSubagentCount===1?`status.subagentsRunning.one`:`status.subagentsRunning.other`,{n:e.runningSubagentCount})},r;switch(e.pendingInteraction){case`approval`:r={state:`warning`,label:t(`status.waitingApproval`),trailingLabel:t(`status.compact.approval`)};break;case`plan-review`:r={state:`warning`,label:t(`status.planReview`),trailingLabel:t(`status.compact.planReview`)};break;case`question`:r={state:`warning`,label:t(`status.waitingAnswer`),trailingLabel:t(`status.compact.answer`)};break;case void 0:break;default:return Fe(e.pendingInteraction)}if(r!==void 0)return n===void 0?[r]:[r,n];if(e.running){let e={state:`ongoing`,label:t(`status.running`)};return n===void 0?[e]:[e,n]}return n===void 0?e.completed?[{state:`done`,label:t(`status.completed`)}]:[{state:`idle`,label:t(`status.idle`)}]:[n]}function Fe(e){throw Error(`unknown pending interaction: ${String(e)}`)}function Ie({statuses:e}){return/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.StateDot,{state:e[0].state,size:e[0].state===`ongoing`?16:void 0}),e.map(e=>/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.visuallyHidden,children:e.label},e.label))]})}let Le=`@deepseek-ai/dsh-client-ui-workspace/RecentNavigation.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Le)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Le,e.textContent=`.qXmkFa_trigger,.qXmkFa_shortcuts{display:none}[data-phone] .qXmkFa_trigger{width:44px;height:44px;color:var(--dsw-alias-label-primary);cursor:pointer;-webkit-app-region:no-drag;background:0 0;border:0;border-radius:8px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.qXmkFa_trigger[aria-disabled=true]{cursor:wait}.qXmkFa_trigger:active{background:color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent)}.qXmkFa_trigger:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:-2px}.qXmkFa_expanded{transform:rotate(180deg)}[data-phone] .qXmkFa_shortcuts{overflow-anchor:none;scroll-behavior:auto;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch;scrollbar-width:none;-webkit-app-region:no-drag;grid-column:1/-1;gap:6px;min-width:0;min-height:44px;margin-inline:-12px -20px;padding-inline-end:16px;scroll-padding-inline:8px 20px;display:flex;overflow-x:auto}.qXmkFa_clear{min-width:44px;min-height:44px;color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;background:0 0;border:0;border-radius:8px;flex:none;align-self:center;padding:0 6px;font-size:12px}.qXmkFa_clear:active{background:color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent)}.qXmkFa_clear:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:-2px}.qXmkFa_shortcuts::-webkit-scrollbar{width:0;height:0;display:none}`,document.head.appendChild(e)}var Re={clear:`qXmkFa_clear`,expanded:`qXmkFa_expanded`,shortcuts:`qXmkFa_shortcuts`,trigger:`qXmkFa_trigger`};function ze({useVisits:e,useSessions:t,useWorkspaces:n,useSessionStatus:r,t:i}){let a=e(e=>e),o=t(e=>e),s=n(e=>e.archivedSessionIds),c=r(e=>e);return a.flatMap(e=>{let t=o.byId[e.sessionId];return t===void 0||t.blank||s.includes(e.sessionId)?[]:[{visit:e,summary:t,statuses:Pe({...re(t,o,c),completed:!1},i)}]})}function Be(e){let{useRecentNavigationSettings:t,open:n,close:r,closeAll:i,viewport:c,restoreNavigationFocus:l,renderSlot:u,t:d}=e,f=t(e=>e.value?.showRecentVisits??!0),p=ze(e),m=f&&p.length>0,h=(0,a.useRef)(null),[g,_]=(0,a.useState)(!1),v=(0,a.useCallback)((e=h.current)=>{e?.isConnected&&e.clientWidth>0&&(c.scrollLeft=Math.max(0,Math.min(e.scrollLeft,e.scrollWidth-e.clientWidth)))},[c]);return(0,a.useLayoutEffect)(()=>{let e=h.current;if(e===null)return;e.scrollLeft=c.scrollLeft;let t=e.clientWidth,n=new ResizeObserver(()=>{e.clientWidth!==t&&(t=e.clientWidth,e.scrollLeft=c.scrollLeft)});return n.observe(e),()=>{v(e),n.disconnect()}},[m,c,v]),m?/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsxs)(`nav`,{ref:h,className:Re.shortcuts,"aria-label":d(`recent.navigation`),onScroll:e=>v(e.currentTarget),children:[p.map(({visit:t,summary:i,statuses:a})=>/* @__PURE__ */ (0,s.jsx)(Me,{visit:t,summary:i,identity:u(`workspace.recent.shortcut.identity`,{sessionId:t.sessionId}),activityLabel:a[0].state===`idle`?void 0:a.map(e=>e.label).join(` · `),activity:a[0].state===`idle`?null:/* @__PURE__ */ (0,s.jsx)(Ie,{statuses:a}),active:e.sessionId===t.sessionId,closeLabel:d(`recent.close`,{name:i.displayTitle}),closeHint:d(`recent.closeHint`),open:e=>{v(),n(e)},close:e=>{v();try{r(e)}catch{_(!0)}},restoreNavigationFocus:l},t.sessionId)),p.length>=3&&/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:Re.clear,"aria-label":d(`recent.clearAll`),title:d(`recent.clearAllHint`),onMouseDown:e=>e.preventDefault(),onClick:()=>{l();try{i()}catch{_(!0)}},children:d(`recent.clear`)})]}),g&&/* @__PURE__ */ (0,s.jsx)(o.Toast,{text:d(`recent.closeFailed`),onDone:()=>_(!1)})]}):null}function Ve(e){let{useRecentNavigationSettings:t,setEnabled:n,t:r}=e,i=t(e=>e.value?.showRecentVisits??!0),c=ze(e),[l,u]=(0,a.useState)(!1),[d,f]=(0,a.useState)(!1),p=(0,a.useRef)(!1);return/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[c.length>0&&/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,"data-navigation-focus-return":!0,className:Re.trigger,"aria-label":r(i?`recent.collapse`:`recent.expand`),"aria-expanded":i,"aria-disabled":l||void 0,"aria-busy":l||void 0,onClick:()=>{p.current||(p.current=!0,u(!0),f(!1),n(!i).then(e=>f(!e)).catch(()=>f(!0)).finally(()=>{p.current=!1,u(!1)}))},children:/* @__PURE__ */ (0,s.jsx)(o.IconChevronDownOutlineRegular,{size:14,className:i?Re.expanded:void 0})}),d&&/* @__PURE__ */ (0,s.jsx)(o.Toast,{text:r(`recent.settings.error`),onDone:()=>f(!1)})]})}function q(e){return e==null}function He(e){return e&&typeof e==`object`&&!Array.isArray(e)}function Ue(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function We(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function Ge(e,t,n){if(!t)return{...e};let r={};for(let i of t)(n||e[i]!==void 0)&&(r[i]=e[i]);return r}let Ke=Symbol.for(`cosmokit.volatile.write`);function qe(e,t=/* @__PURE__ */ new Set){if(typeof e==`function`)throw TypeError(`volatile config cannot contain functions`);if(typeof e!=`object`||!e)return e;if(t.has(e))throw TypeError(`volatile config cannot contain cycles`);t.add(e);try{if(Array.isArray(e))return Object.freeze(e.map(e=>qe(e,t)));if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw TypeError(`volatile config objects must be plain objects or arrays`);return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,n])=>[e,qe(n,t)])))}finally{t.delete(e)}}function Je(e){let t=qe(e);return Object.freeze({get:()=>t,[Ke]:e=>{t=e}})}function Ye(e){return typeof e==`object`&&!!e&&Ke in e}function Xe(e,t){return arguments.length===1?t=>Xe(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function Ze(e){return Xe(`ArrayBuffer`,e)||Xe(`SharedArrayBuffer`,e)}function Qe(e){return Ze(e)||ArrayBuffer.isView(e)}let $e;(function(e){e.is=Ze,e.isSource=Qe;function t(e){return ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}e.fromSource=t;function n(e){if(e=t(e),typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let n=``,r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)n+=String.fromCharCode(r[e]);return btoa(n)}e.toBase64=n;function r(e){return typeof Buffer<`u`?t(Buffer.from(e,`base64`)):Uint8Array.from(atob(e),e=>e.charCodeAt(0))}e.fromBase64=r;function i(e){return e=t(e),typeof Buffer<`u`?Buffer.from(e).toString(`hex`):Array.from(new Uint8Array(e),e=>e.toString(16).padStart(2,`0`)).join(``)}e.toHex=i;function a(e){if(typeof Buffer<`u`)return t(Buffer.from(e,`hex`));let n=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(`${n[e]}${n[e+1]}`,16));return Uint8Array.from(r).buffer}e.fromHex=a})($e||={}),$e.fromBase64,$e.toBase64,$e.fromHex,$e.toHex;function et(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(Xe(`Date`,e))return new Date(e.valueOf());if(Xe(`RegExp`,e))return new RegExp(e.source,e.flags);if(Ze(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let n=t.get(e);if(n)return n;if(Array.isArray(e)){let n=[];return t.set(e,n),e.forEach((e,r)=>{n[r]=Reflect.apply(et,null,[e,t])}),n}let r=Object.create(Object.getPrototypeOf(e));t.set(e,r);for(let n of Reflect.ownKeys(e)){let i={...Reflect.getOwnPropertyDescriptor(e,n)};`value`in i&&(i.value=Reflect.apply(et,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function tt(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(Ye(e)||Ye(t))return Ye(e)&&Ye(t);if(!n&&q(e)&&q(t))return!0;if(typeof e!=typeof t||typeof e!=`object`||!e||!t||r.has(e))return!1;function a(n,r){return n(e)?n(t)?r(e,t):!1:!n(t)&&void 0}r.add(e);try{return a(Array.isArray,(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1;return!0})??a(Xe(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(Xe(`URL`),(e,t)=>e.href===t.href)??a(Xe(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(Ze,(e,t)=>{if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0})??((!n||[e,t].every(e=>Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null))&&Object.keys({...e,...t}).every(n=>i(e[n],t[n])))}finally{r.delete(e)}}return i(e,t)}let nt;(function(e){e.millisecond=1;let t=e.second=1e3,n=e.minute=t*60,r=e.hour=n*60,i=e.day=r*24,a=e.week=i*7,o=(/* @__PURE__ */ new Date()).getTimezoneOffset();function s(e){o=e}e.setTimezoneOffset=s;function c(){return o}e.getTimezoneOffset=c;function l(e=/* @__PURE__ */ new Date,t){return typeof e==`number`&&(e=new Date(e)),t===void 0&&(t=o),Math.floor((e.valueOf()/n-t)/1440)}e.getDateNumber=l;function u(e,t){let r=new Date(e*i);return t===void 0&&(t=o),new Date(+r+t*n)}e.fromDateNumber=u;let d=RegExp(`^${[`w(?:eek(?:s)?)?`,`d(?:ay(?:s)?)?`,`h(?:our(?:s)?)?`,`m(?:in(?:ute)?(?:s)?)?`,`s(?:ec(?:ond)?(?:s)?)?`].map(e=>`(\\d+(?:\\.\\d+)?${e})?`).join(``)}$`);function f(e){let o=d.exec(e);return o?(parseFloat(o[1])*a||0)+(parseFloat(o[2])*i||0)+(parseFloat(o[3])*r||0)+(parseFloat(o[4])*n||0)+(parseFloat(o[5])*t||0):0}e.parseTime=f;function p(e){let t=f(e);return t?e=Date.now()+t:/^\d{1,2}(:\d{1,2}){1,2}$/.test(e)?e=`${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${e}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(e)&&(e=`${(/* @__PURE__ */ new Date()).getFullYear()}-${e}`),e?new Date(e):/* @__PURE__ */ new Date}e.parseDate=p;function m(e){let a=Math.abs(e);return a>=i-r/2?Math.round(e/i)+`d`:a>=r-n/2?Math.round(e/r)+`h`:a>=n-t/2?Math.round(e/n)+`m`:a>=t?Math.round(e/t)+`s`:e+`ms`}e.format=m;function h(e,t=2){return e.toString().padStart(t,`0`)}e.toDigits=h;function g(e,t=/* @__PURE__ */ new Date){return e.replace(`yyyy`,t.getFullYear().toString()).replace(`yy`,t.getFullYear().toString().slice(2)).replace(`MM`,h(t.getMonth()+1)).replace(`dd`,h(t.getDate())).replace(`hh`,h(t.getHours())).replace(`mm`,h(t.getMinutes())).replace(`ss`,h(t.getSeconds())).replace(`SSS`,h(t.getMilliseconds(),3))}e.template=g})(nt||={});let rt=Symbol.for(`schemastery`),it=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var J=class extends TypeError{options;name=`ValidationError`;constructor(e,t){let n=`$`;for(let e of t.path||[])typeof e==`string`?n+=`.`+e:typeof e==`number`?n+=`[`+e+`]`:typeof e==`symbol`&&(n+=`[Symbol(${e.toString()})]`);n.startsWith(`.`)&&(n=n.slice(1)),super((n===`$`?``:`${n} `)+e),this.options=t}static is(e){return!!e?.[it]}};Object.defineProperty(J.prototype,it,{value:!0});let Y=function(e){let t=function(e,n={}){return Y.resolve(e,t,n)[0]};if(e.refs){let t=We(e.refs,e=>new Y(e)),n=e=>t[e];for(let e in t){let r=t[e];r.sKey=n(r.sKey),r.inner=n(r.inner),r.list=r.list&&r.list.map(n),r.dict=r.dict&&We(r.dict,n)}return t[e.uid]}if(Object.assign(t,e),typeof t.callback==`string`)try{t.callback=Function(`return `+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,Y.prototype),t.meta||={},t.toString=t.toString.bind(t),t};Y.prototype=Object.create(Function.prototype),Y.prototype[rt]=!0,Object.defineProperty(Y.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:Y.resolve(e,this,{})[0]}}catch(e){if(J.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),Y.ValidationError=J,Y.prototype.toJSON=function(){if(globalThis.__schemastery_refs__)return globalThis.__schemastery_refs__[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));let e={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,e},Y.prototype.set=function(e,t){return this.dict[e]=t,this},Y.prototype.push=function(e){return this.list.push(e),this};function at(e,t){let n=typeof e==`string`?{"":e}:{...e};for(let e in t){let r=t[e];r?.$description||r?.$desc?n[e]=r.$description||r.$desc:typeof r==`string`&&(n[e]=r)}return n}function ot(e){return e?.$value??e?.$inner}function st(e){return Ue(e??{},e=>!e.startsWith(`$`))}Y.prototype.i18n=function(e){let t=Y(this),n=at(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=We(t.dict,(t,n)=>t.i18n(We(e,e=>ot(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(We(e,(e={})=>Array.isArray(ot(e))?ot(e)[n]:Array.isArray(e)?e[n]:st(e)))),t.inner&&=t.inner.i18n(We(e,e=>ot(e)?ot(e):st(e))),t.sKey&&=t.sKey.i18n(We(e,e=>e?.$key)),t},Y.prototype.extra=function(e,t){let n=Y(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign(Y.prototype,{[e](t=!0){let n=Y(this);return n.meta={...n.meta,[e]:t},n}});Y.prototype.deprecated=function(){let e=Y(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},Y.prototype.experimental=function(){let e=Y(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},Y.prototype.pattern=function(e){let t=Y(this),n=Ge(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},Y.prototype.simplify=function(e){if(Ye(e)&&(e=e.get()),tt(e,this.meta.default,this.type===`dict`))return null;if(q(e))return e;if(this.type===`object`||this.type===`dict`){let t={};for(let n in e){let r=(this.type===`object`?this.dict[n]:this.inner)?.simplify(e[n]);(this.type===`dict`||!q(r))&&(t[n]=r)}return tt(t,this.meta.default,this.type===`dict`)?null:t}if(this.type===`array`||this.type===`tuple`){let t=[];return e.forEach((e,n)=>{let r=this.type===`array`?this.inner:this.list[n],i=r?r.simplify(e):e;t.push(i)}),t}if(this.type===`intersect`){let t={};for(let n of this.list)Object.assign(t,n.simplify(e));return t}if(this.type===`union`)for(let t of this.list)try{return Y.resolve(e,t,{}),t.simplify(e)}catch{}return e},Y.prototype.toString=function(e){return gt[this.type]?.(this,e)??`Schema<${this.type}>`},Y.prototype.role=function(e,t){let n=Y(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign(Y.prototype,{[e](t){let n=Y(this);return n.meta={...n.meta,[e]:t},n}});Y.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let ct={},lt=Symbol(`checked-volatile-schema`);function ut(e,t=[],n=!1,r=/* @__PURE__ */ new Map){let i=r.get(e)??/* @__PURE__ */ new Set;if(i.has(n))return;if(i.add(n),r.set(e,i),e.meta?.volatile&&n)throw new J(`volatile fields require a fixed object path without an enclosing volatile field`,{path:t});let a=n||!!e.meta?.volatile;if(e.dict)for(let[n,i]of Object.entries(e.dict))ut(i,[...t,n],a,r);if(e.sKey&&ut(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[rt])&&ut(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)ut(e.list[n],[...t,String(n)],!0,r)}Y.extend=function(e,t){ct[e]=t},Y.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[lt]||(ut(t,n.path),n={...n,[lt]:!0}),t.meta?.volatile){let i=Y(t);i.meta={...t.meta,volatile:!1};let[a,o]=Y.resolve(e,i,n,r);try{return[Je(a),o]}catch(e){throw new J(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(q(e)&&t.type!==`lazy`){if(t.meta.required)throw new J(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&q(i);)r=r.list[0],i=r?.meta.default;if(q(i))return[e];e=et(i)}let i=ct[t.type];if(!i)throw new J(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},Y.from=function(e){if(q(e))return Y.any();if([`string`,`number`,`boolean`].includes(typeof e))return Y.const(e).required();if(e[rt])return e;if(typeof e==`function`)switch(e){case String:return Y.string().required();case Number:return Y.number().required();case Boolean:return Y.boolean().required();case Function:return Y.function().required();default:return Y.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},Y.lazy=function(e){let t=new Y({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[rt]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},Y.natural=function(){return Y.number().step(1).min(0)},Y.percent=function(){return Y.number().step(.01).min(0).max(1).role(`slider`)},Y.date=function(){return Y.union([Y.is(Date),Y.transform(Y.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new J(`invalid date "${e}"`,t);return n},!0)])},Y.regExp=function(e=``){return Y.union([Y.is(RegExp),Y.transform(Y.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new J(e.message,n)}},!0)])},Y.arrayBuffer=function(e){return Y.union([Y.is(ArrayBuffer),Y.is(SharedArrayBuffer),Y.transform(Y.any(),(e,t)=>{if($e.isSource(e))return $e.fromSource(e);throw new J(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[Y.transform(Y.string(),(t,n)=>{try{return e===`base64`?$e.fromBase64(t):$e.fromHex(t)}catch(e){throw new J(e.message,n)}},!0)]:[]])},Y.extend(`lazy`,(e,t,n,r)=>(t.inner[rt]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},ut(t.inner,n.path,!0)),Y.resolve(e,t.inner,n,r))),Y.extend(`any`,e=>[e]),Y.extend(`never`,(e,t,n)=>{throw new J(`expected nullable but got ${e}`,n)}),Y.extend(`const`,(e,{value:t},n)=>{if(tt(e,t))return[t];throw new J(`expected ${t} but got ${e}`,n)});function dt(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new J(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new J(`expected ${n} >= ${o} but got ${e}`,r)}Y.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new J(`expected string but got ${e}`,n);if(t.pattern){let r=new RegExp(t.pattern.source,t.pattern.flags);if(!r.test(e))throw new J(`expect string to match regexp ${r}`,n)}return dt(e.length,t,`string length`,n),[e]});function ft(e,t){let n=e.toString();if(n.includes(`e`))return e*10**t;let r=n.indexOf(`.`);if(r===-1)return e*10**t;let i=n.slice(r+1),a=n.slice(0,r);return i.length<=t?+(a+i.padEnd(t,`0`)):+(a+i.slice(0,t)+`.`+i.slice(t))}function pt(e,t,n){if(n=Math.abs(n),!/^\d+\.\d+$/.test(n.toString()))return(e-t)%n===0;let r=n.toString().indexOf(`.`),i=n.toString().slice(r+1).length;return Math.abs(ft(e,i)-ft(t,i))%ft(n,i)===0}Y.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new J(`expected number but got ${e}`,n);dt(e,t,`number`,n);let{step:r}=t;if(r&&!pt(e,t.min??0,r))throw new J(`expected number multiple of ${r} but got ${e}`,n);return[e]}),Y.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new J(`expected boolean but got ${e}`,n)}),Y.extend(`bitset`,(e,{bits:t,meta:n},r)=>{let i=0,a=[];if(typeof e==`number`){i=e;for(let n in t)e&t[n]&&a.push(n)}else if(Array.isArray(e)){a=e;for(let e of a){if(typeof e!=`string`)throw new J(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new J(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),Y.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new J(`expected function but got ${e}`,n)}),Y.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new J(`expected ${t.name} but got ${e}`,n)}{if(q(e))throw new J(`expected ${t} but got ${e}`,n);let r=Object.getPrototypeOf(e);for(;r;){if(r.constructor?.name===t)return[e];r=Object.getPrototypeOf(r)}throw new J(`expected ${t} but got ${e}`,n)}});function mt(e,t,n,r){try{let[i,a]=Y.resolve(e[t],n,{...r,path:[...r.path||[],t]});return a!==void 0&&(e[t]=a),i}catch(i){if(!r?.autofix)throw i;return delete e[t],n.meta.volatile?Je(n.meta.default):n.meta.default}}Y.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new J(`expected array but got ${e}`,r);return dt(e.length,n,`array length`,r,!q(t.meta.default)),[e.map((n,i)=>mt(e,i,t,r))]}),Y.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!He(e))throw new J(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=Y.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=mt(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),Y.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new J(`expected array but got ${e}`,n);let i=t.map((t,r)=>mt(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function ht(e,t){for(let n in t)n in e||(e[n]=t[n])}Y.extend(`object`,(e,{dict:t},n,r)=>{if(!He(e))throw new J(`expected object but got ${e}`,n);let i={};for(let r in t){let a=mt(e,r,t[r],n);(!q(a)||r in e)&&(i[r]=a)}return r||ht(i,e),[i]}),Y.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return Y.resolve(e,n,r,i)}catch(e){a.push(e)}throw new J(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),Y.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=Y.resolve(e,i,r,!0)[0];if(!q(t)){if(q(a))a=t;else if(typeof a!=typeof t)throw new J(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)ht(a??={},t);else if(a!==t)throw new J(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&He(e)&&ht(a,e),[a]}),Y.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=Y.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let gt={};function X(e,t,n){gt[e]=n,Object.assign(Y,{[e](...n){let r=new Y({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??Y.string();break;case`inner`:r.inner=Y.from(n[t]);break;case`list`:r.list=n[t].map(Y.from);break;case`dict`:r.dict=We(n[t],Y.from);break;case`bits`:r.bits={};for(let e in n[t])typeof n[t][e]==`number`&&(r.bits[e]=n[t][e]);break;case`callback`:{let e=r.callback=n[t];e.toJSON||=()=>e.toString();break}case`constructor`:{let e=r.constructor=n[t];typeof e==`function`&&(e.toJSON||=()=>e.name);break}default:r[e]=n[t]}}),e===`object`||e===`dict`?r.meta.default={}:e===`array`||e===`tuple`?r.meta.default=[]:e===`bitset`&&(r.meta.default=0),r}})}X(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),X(`any`,[],()=>`any`),X(`never`,[],()=>`never`),X(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),X(`string`,[],()=>`string`),X(`number`,[],()=>`number`),X(`boolean`,[],()=>`boolean`),X(`bitset`,[`bits`],()=>`bitset`),X(`function`,[],()=>`function`),X(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),X(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),X(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),X(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),X(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),X(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),X(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let _t=[0,15,30,60,120,240,1440],vt={showRecentVisits:!0,tabIdleTimeoutMinutes:60},yt={showRecentVisits:Y.boolean().default(!0),tabIdleTimeoutMinutes:Y.natural().max(1440).default(60)},bt=`@deepseek-ai/dsh-client-ui-workspace/RecentNavigationRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(bt)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=bt,e.textContent=`._0lPQtW_row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px 16px;padding:16px 0;display:flex}._0lPQtW_text{flex:160px;min-width:0}._0lPQtW_timeoutRow{border-top:.5px solid var(--dsw-alias-border-l2)}._0lPQtW_menu{flex:none;margin-inline-start:auto}._0lPQtW_selector{background:var(--dsw-alias-bg-module-platform);min-width:96px;min-height:44px;color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;border:0;border-radius:8px;justify-content:space-between;align-items:center;gap:8px;padding:0 12px;font-size:14px;line-height:20px;display:inline-flex}._0lPQtW_selector:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:2px}._0lPQtW_selector:disabled{opacity:.5;cursor:not-allowed}@media (hover:hover){._0lPQtW_selector:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}}._0lPQtW_error{padding-bottom:12px;font-size:12px;line-height:18px}._0lPQtW_titleLine{flex-wrap:wrap;align-items:center;gap:8px;display:flex}._0lPQtW_title{font-size:14px;line-height:20px}._0lPQtW_description{color:var(--dsw-alias-label-secondary);margin-top:4px;font-size:12px;line-height:18px}`,document.head.appendChild(e)}var xt={description:`_0lPQtW_description`,error:`_0lPQtW_error`,menu:`_0lPQtW_menu`,row:`_0lPQtW_row`,selector:`_0lPQtW_selector`,text:`_0lPQtW_text`,timeoutRow:`_0lPQtW_timeoutRow`,title:`_0lPQtW_title`,titleLine:`_0lPQtW_titleLine`};function St({usePreference:e,setEnabled:t,setIdleTimeout:n,t:r}){let i=e(e=>e.value),c=i?.showRecentVisits??!0,l=i?.tabIdleTimeoutMinutes??60,[u,d]=(0,a.useState)(!1),[f,p]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!1),g=(0,a.useRef)(!1),_=(0,a.useId)();(0,a.useEffect)(()=>{c||d(!1)},[c]);let v=e=>e===0?r(`recent.timeout.off`):e>=120&&e%60==0?r(`recent.timeout.hours`,{n:e/60}):r(`recent.timeout.minutes`,{n:e}),y=e=>{g.current||(g.current=!0,d(!1),p(!0),h(!1),Promise.resolve().then(e).then(e=>h(!e)).catch(()=>h(!0)).finally(()=>{g.current=!1,p(!1)}))};return/* @__PURE__ */ (0,s.jsxs)(`div`,{children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:xt.row,children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:xt.text,children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:xt.titleLine,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:xt.title,children:r(`recent.settings.title`)}),/* @__PURE__ */ (0,s.jsx)(o.Tag,{tone:`neutral`,children:r(`recent.settings.mobile`)})]}),/* @__PURE__ */ (0,s.jsx)(`div`,{className:xt.description,children:r(`recent.settings.description`)})]}),/* @__PURE__ */ (0,s.jsx)(o.Switch,{checked:c,disabled:f,label:`${r(`recent.settings.title`)} · ${r(`recent.settings.mobile`)}`,onChange:e=>y(()=>t(e))})]}),c&&/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`${xt.row} ${xt.timeoutRow}`,children:[/* @__PURE__ */ (0,s.jsx)(`div`,{className:xt.text,children:/* @__PURE__ */ (0,s.jsx)(`div`,{className:xt.title,id:`${_}-label`,children:r(`recent.timeout.title`)})}),/* @__PURE__ */ (0,s.jsx)(o.Menu,{className:xt.menu,open:u&&c&&!f,onClose:()=>d(!1),items:_t.map(e=>({id:String(e),label:e===60?r(`recent.timeout.default`,{value:v(e)}):v(e)})),selectedId:String(l),onSelect:e=>{let t=_t.find(t=>String(t)===e);t!==void 0&&y(()=>n(t))},align:`end`,portal:!0,anchor:/* @__PURE__ */ (0,s.jsxs)(`button`,{type:`button`,className:xt.selector,disabled:!c||f,"aria-labelledby":`${_}-label ${_}-value`,"aria-haspopup":`menu`,"aria-expanded":u&&c&&!f,onClick:()=>d(e=>!e),children:[/* @__PURE__ */ (0,s.jsx)(`span`,{id:`${_}-value`,children:v(l)}),/* @__PURE__ */ (0,s.jsx)(o.IconChevronDownOutlineRegular,{size:14})]})})]}),m&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:xt.error,role:`alert`,children:r(`recent.settings.error`)})]})}function Ct(e,t,n){let r=e=>n.set(`showRecentVisits`,e),i=e=>n.set(`tabIdleTimeoutMinutes`,e),a={scrollLeft:0};e.inject([`uiSession`,`connection`],e=>{e.effect(()=>{let r,i=()=>{let r=n.getSnapshot().value;r!==void 0&&document.visibilityState===`visible`&&e.connection.state.getSnapshot()===`connected`&&r.showRecentVisits&&r.tabIdleTimeoutMinutes!==0&&t.opening.getSnapshot().state!==`loading`&&t.recentVisits.expireInactive(r.tabIdleTimeoutMinutes*6e4,e.uiSession.sessionStatus.getSnapshot())&&t.recentVisits.entries.getSnapshot().length===0&&(a.scrollLeft=0)},o=()=>{r!==void 0&&clearInterval(r),r=void 0;let e=n.getSnapshot().value;document.visibilityState===`visible`&&e?.showRecentVisits&&e.tabIdleTimeoutMinutes>0&&(r=setInterval(i,6e4))},s=n.subscribe(o);return document.addEventListener(`visibilitychange`,o),o(),()=>{s(),r!==void 0&&clearInterval(r),document.removeEventListener(`visibilitychange`,o)}},`ui-workspace: idle session tabs`)});let o=()=>({hooks:{visits:t.recentVisits.entries,recentNavigationSettings:n},open:e=>t.openSession(e),close:e=>{t.closeSessionTab(e),t.recentVisits.entries.getSnapshot().length===0&&(a.scrollLeft=0)},closeAll:()=>{t.closeAllSessionTabs(),a.scrollLeft=0},viewport:a,setEnabled:r});e.slots.inject(`conversation.header.navigation`,()=>e.slots.register({name:`conversation.header.navigation`,locale:`workspace`,inject:o},Ve)),e.slots.inject(`conversation.header.shortcuts`,()=>e.slots.register({name:`conversation.header.shortcuts`,locale:`workspace`,inject:o,children:{"workspace.recent.shortcut.identity":{kind:`list`,scope:`root`}}},Be)),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`workspace.recent-navigation`,order:12,locale:`workspace`,inject:()=>({hooks:{preference:n},setEnabled:r,setIdleTimeout:i})},St))}let wt=`@deepseek-ai/dsh-client-ui-workspace/ThreadTreeStyle.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(wt)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=wt,e.textContent=`.GyPSUW_options{min-width:0;color:var(--dsw-alias-label-primary);flex-direction:column;align-items:flex-start;gap:8px;padding-block:6px;display:flex}.GyPSUW_settingsText{flex:240px}.GyPSUW_prompt{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-specific-sidebar-fill);color:var(--dsw-alias-label-primary);overflow-wrap:anywhere;border-radius:8px;min-width:0;margin:6px 2px 8px;padding:8px;font-size:12px;line-height:16px}.GyPSUW_promptHeading{justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px;display:flex}.GyPSUW_promptHeading strong{font-weight:500}.GyPSUW_comparison{border:1px solid var(--dsw-alias-border-l2);border-radius:6px;grid-template-columns:repeat(2,minmax(0,1fr));display:grid}.GyPSUW_choice{appearance:none;min-width:0;color:inherit;font:inherit;text-align:start;cursor:pointer;background:0 0;border:0;border-radius:5px 0 0 5px;flex-direction:column;justify-content:flex-start;align-items:stretch;padding:8px 0 4px;display:flex;position:relative}.GyPSUW_choice+.GyPSUW_choice{border-inline-start:1px solid var(--dsw-alias-border-l2);border-radius:0 5px 5px 0}.GyPSUW_choice[aria-checked=true]{box-shadow:inset 0 0 0 1px var(--dsw-alias-state-business-primary)}.GyPSUW_choiceTitle{padding:0 8px 2px;font-size:12px;font-weight:500;display:block}.GyPSUW_choiceSubtitle{white-space:nowrap;text-overflow:ellipsis;color:var(--dsw-alias-label-secondary);padding:0 8px 6px;font-size:10px;line-height:16px;overflow:hidden}.GyPSUW_preview{pointer-events:none;user-select:none;grid-auto-rows:44px;min-width:0;display:grid;overflow:hidden}.GyPSUW_preview .GyPSUW_sampleRow{--dsh-thread-row-height:22px;--dsh-workspace-indent:0px;--dsh-thread-indent:0px;min-height:0;padding-inline:6px}.GyPSUW_preview [data-session-title]{margin-inline:7px 0;font-size:11px}.GyPSUW_preview .GyPSUW_sampleSummary{margin-block-end:0;padding:0 0 0 7px;font-size:9px;line-height:11px}.GyPSUW_sampleIcon{flex-shrink:0;width:14px;height:14px;display:inline-flex}.GyPSUW_hint{color:var(--dsw-alias-label-tertiary);margin:0 0 8px;font-size:11px;line-height:1.5}.GyPSUW_later{color:var(--dsw-alias-label-secondary);cursor:pointer;font:inherit;background:0 0;border:0;border-radius:4px;flex-shrink:0;padding:4px}.GyPSUW_choice:focus-visible,.GyPSUW_later:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.GyPSUW_error{color:var(--dsw-alias-state-warn-primary);overflow-wrap:anywhere;flex-basis:100%;margin-top:6px;font-size:12px}@media (width<=639px){.GyPSUW_choiceTitle,.GyPSUW_choiceSubtitle{padding-inline:6px}.GyPSUW_preview [data-session-title]{font-size:10px}}@media (hover:none),(pointer:coarse){.GyPSUW_later{min-height:44px}}`,document.head.appendChild(e)}var Z={choice:`GyPSUW_choice`,choiceSubtitle:`GyPSUW_choiceSubtitle`,choiceTitle:`GyPSUW_choiceTitle`,comparison:`GyPSUW_comparison`,error:`GyPSUW_error`,hint:`GyPSUW_hint`,later:`GyPSUW_later`,options:`GyPSUW_options`,preview:`GyPSUW_preview`,prompt:`GyPSUW_prompt`,promptHeading:`GyPSUW_promptHeading`,sampleIcon:`GyPSUW_sampleIcon`,sampleRow:`GyPSUW_sampleRow`,sampleSummary:`GyPSUW_sampleSummary`,settingsText:`GyPSUW_settingsText`};let Tt=[`summary`,`ring`];function Et(e){let[t,n]=(0,a.useState)(!1),[r,i]=(0,a.useState)(!1),o=(0,a.useRef)(!1);return{busy:t,failed:r,save:async t=>{if(o.current)return!1;o.current=!0,n(!0),i(!1);try{let n=await e(t);return i(!n),n}catch{return i(!0),!1}finally{o.current=!1,n(!1)}}}}function Dt({style:e,setStyle:t,t:n,settings:r=!1}){let i=(0,a.useId)(),{busy:c,failed:l,save:u}=Et(t);return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:r?o.preferenceRowStyles.row:Z.options,children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`${o.preferenceRowStyles.rowText} ${r?Z.settingsText:``}`,children:[/* @__PURE__ */ (0,s.jsx)(`div`,{className:o.preferenceRowStyles.title,id:i,children:n(`threadTree.style.title`)}),r&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:o.preferenceRowStyles.description,id:`${i}-description`,children:n(`threadTree.style.description`)})]}),/* @__PURE__ */ (0,s.jsx)(`div`,{className:o.preferenceRowStyles.choices,role:`radiogroup`,"aria-labelledby":i,"aria-describedby":r?`${i}-description`:void 0,"aria-busy":c,onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key))return;e.preventDefault(),e.stopPropagation();let t=[...e.currentTarget.querySelectorAll(`[role="radio"]`)],n=t.indexOf(e.target),r=e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:1)+t.length)%t.length;t[r]?.focus(),t[r]?.click()},children:Tt.map(t=>/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,role:`radio`,className:o.preferenceRowStyles.choice,"aria-checked":e===t,"aria-disabled":c,tabIndex:e===t?0:-1,onClick:()=>void u(t),children:n(`threadTree.style.${t}`)},t))}),l&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:Z.error,role:`alert`,children:n(`threadTree.style.error`)})]})}function Ot({usePreference:e,setStyle:t,t:n}){let r=e(e=>e.value?.threadTreeCollapseStyle??`summary`);return/* @__PURE__ */ (0,s.jsx)(Dt,{style:r,setStyle:t,t:n,settings:!0})}let kt={...vt,threadTreeCollapseStyle:`summary`},At=Y.object({...yt,threadTreeCollapseStyle:Y.union([`summary`,`ring`]).default(`summary`)});function jt(e){return typeof e==`object`&&!!e&&Object.hasOwn(e,`threadTreeCollapseStyle`)}function Mt(e){let t=e.configForms.registerBrowser(`ui-workspace`,At.toJSON(),{...kt});return e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`workspace.thread-tree-style`,order:11.5,locale:`workspace`,inject:()=>({hooks:{preference:t},setStyle:e=>t.set(`threadTreeCollapseStyle`,e)})},Ot)),t}function Nt(e,t,n){let r=e.find(e=>e.workspaceId===t),i=e.find(e=>e.workspaceId===n);return r!==void 0&&i!==void 0&&!r.remote&&!i.remote}function Pt(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Pt(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Q(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Pt(e))&&(r&&(r+=` `),r+=t);return r}function Ft(e,t){return e===`default-workspace`?t:e}let It={},Lt=(0,a.createContext)({t:e=>e,expansion:It,rows:e=>T(e,It),toggle:()=>{},collapseStyle:`summary`,stylePrompt:void 0,dismissStylePrompt:()=>{},setCollapseStyle:async()=>!1,rootId:e=>e,reveal:()=>{},selectSidebarRow:()=>{},isSidebarSelection:()=>!1});function Rt(){return(0,a.useContext)(Lt)}function zt({browser:e,children:t}){let{useSessions:n,useStore:r,useWorkspaces:i,actions:o,useWorkspacePreferences:c,setThreadTreeCollapseStyle:l}=e,u=c(e=>e),d=jt(u.user),f=u.value?.threadTreeCollapseStyle??`summary`,[p,m]=(0,a.useState)(),h=(0,a.useCallback)(()=>m(void 0),[]),g=n(e=>e),_=i(e=>e),v=r(e=>e.threadExpansion??It),y=r(e=>e.archivedFilter??`default`),b=(0,a.useMemo)(()=>L(g,{pinnedSessionIds:_.pinnedSessionIds,archivedSessionIds:_.archivedSessionIds,archivedFilter:y},/* @__PURE__ */ new Map),[g,_,y]),x=(0,a.useMemo)(()=>{let e=/* @__PURE__ */ new Map;for(let t of b){let n=[{node:t,ancestors:[]}];for(let r=n.pop();r!==void 0;r=n.pop()){e.set(r.node.id,{root:t,ancestors:r.ancestors});for(let e of r.node.tree?.children??[])n.push({node:e,ancestors:[...r.ancestors,r.node.id]})}}return e},[b]),S=(0,a.useRef)(void 0),C=(0,a.useCallback)(e=>S.current===e,[]),w=(0,a.useCallback)(e=>{S.current=e,o.setThreadsExpanded(x.get(e)?.ancestors??[],!0)},[o,x]),E=(0,a.useCallback)(e=>{S.current=void 0;let t=x.get(e);t!==void 0&&o.setThreadsExpanded(t.ancestors,!0)},[o,x]),D=Object.values(g.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,O=(0,a.useRef)(``);(0,a.useEffect)(()=>{D===void 0?O.current=``:x.get(D)!==void 0&&O.current!==D&&(O.current=D,C(D)||E(D))},[D,C,E,x]);let k=(0,a.useMemo)(()=>({t:e.t,expansion:v,rows:e=>T(e,v),toggle:(e,t,n)=>{o.setThreadsExpanded([e],t),t&&n!==void 0&&!d&&m(n)},collapseStyle:f,stylePrompt:d?void 0:p,dismissStylePrompt:h,setCollapseStyle:l,rootId:e=>x.get(e)?.root.id??e,reveal:E,selectSidebarRow:w,isSidebarSelection:C}),[e.t,o,v,x,E,w,C,f,d,p,h,l]);return/* @__PURE__ */ (0,s.jsx)(Lt.Provider,{value:k,children:t})}function Bt({identity:e,ambient:t,title:n,onTitleDoubleClick:r,onIdentityClick:i,identityLabel:a,identityControls:o,identityExpanded:c,children:l}){let u=/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[e,/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.statusOverlay,children:t})]});return/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[i?/* @__PURE__ */ (0,s.jsxs)(`button`,{type:`button`,className:`${K.slot} ${K.identityButton}`,onClick:i,"data-thread-icon-toggle":!0,"aria-label":a,title:a,"aria-expanded":c,"aria-controls":o,children:[u,/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.foldChevron,"aria-hidden":`true`})]}):/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.slot,children:u}),/* @__PURE__ */ (0,s.jsx)(`span`,{"data-session-title":!0,className:K.title,onDoubleClick:r,children:n}),l]})}function Vt({host:e,t}){let n=e?.displayName??t(`host.local`),r=e?.state===`connected`?t(`host.connected`):e?.state===`connecting`?t(`host.connecting`):t(`host.disconnected`),i=e?`${n} · ${r}`:n;return/* @__PURE__ */ (0,s.jsxs)(`span`,{className:K.hostBadge,"data-host-id":e?.hostId??`local`,"data-state":e?.state??`local`,role:`img`,"aria-label":i,title:i,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{children:n}),e&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.hostDot,"aria-hidden":`true`})]})}let Ht=`@deepseek-ai/dsh-client-ui-workspace/ThreadTreeControls.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ht)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Ht,e.textContent=`.jGgv6G_branch{--dsh-thread-row-height:32px;--dsh-thread-icon-size:16px;--dsh-thread-icon-center-y:calc(var(--dsh-thread-row-height) / 2);--dsh-thread-row-gap:2px;min-width:0;position:relative}.jGgv6G_branch:has(>:first-child [data-harness-id]){--dsh-thread-icon-size:14px}.jGgv6G_branch:has(>:first-child [data-harness-id])>.jGgv6G_children{--dsh-thread-parent-icon-size:14px}.jGgv6G_children{gap:var(--dsh-thread-row-gap);margin-top:var(--dsh-thread-row-gap);--dsh-thread-parent-icon-size:16px;--dsh-thread-guide-parent-gap:12px;--dsh-thread-guide-start:calc(var(--dsh-thread-guide-parent-gap) - (var(--dsh-thread-row-height) - var(--dsh-thread-parent-icon-size)) / 2 - var(--dsh-thread-row-gap));--dsh-thread-guide-axis:calc(8px + var(--dsh-workspace-indent,0px) + var(--dsh-thread-guide-indent) + var(--dsh-thread-parent-icon-size) / 2 + .5px);flex-direction:column;display:flex;position:relative}.jGgv6G_children .jGgv6G_children{--dsh-thread-guide-parent-gap:10px}.jGgv6G_children[hidden]{display:none}.jGgv6G_children[data-thread-guide]:before,.jGgv6G_children[data-thread-guide]>.jGgv6G_branch:before{content:"";pointer-events:none;z-index:1;position:absolute;inset-inline-start:var(--dsh-thread-guide-axis)}.jGgv6G_children[data-thread-guide]:before{top:var(--dsh-thread-guide-start);height:max(0px, calc(-1 * var(--dsh-thread-guide-start)));background:var(--dsw-alias-border-l2);width:1px}.jGgv6G_children[data-thread-guide]>.jGgv6G_branch:before{--dsh-thread-guide-stem-start:0px;--dsh-thread-guide-stem-end:0px;top:0;bottom:calc(-1 * var(--dsh-thread-row-gap));width:calc(24px - var(--dsh-thread-parent-icon-size) / 2 - 6.5px);background:var(--dsw-alias-border-l2);mask:linear-gradient(transparent var(--dsh-thread-guide-stem-start), black 0) 0 0 / 1px calc(100% - var(--dsh-thread-guide-stem-end)) no-repeat, url("data:image/svg+xml,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 11 8\\" preserveAspectRatio=\\"none\\"><path d=\\"M.5 0V1Q.5 3.3 2.5 4.5L10.5 7.5\\" fill=\\"none\\" stroke=\\"black\\" stroke-width=\\"1\\" vector-effect=\\"non-scaling-stroke\\"/></svg>") 0 calc(var(--dsh-thread-icon-center-y) - 8px) / 100% 8px no-repeat}.jGgv6G_children[data-thread-guide]>.jGgv6G_branch:first-child:before{--dsh-thread-guide-stem-start:max(0px, var(--dsh-thread-guide-start))}.jGgv6G_children[data-thread-guide]>.jGgv6G_branch:last-child:before{--dsh-thread-guide-stem-end:8px;bottom:calc(100% - var(--dsh-thread-icon-center-y))}.jGgv6G_summary{appearance:none;width:calc(100% - var(--dsh-thread-icon-size));min-width:0;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:start;overflow-wrap:anywhere;cursor:pointer;-webkit-tap-highlight-color:transparent;background:0 0;border:0;border-radius:6px;margin-block-end:2px;margin-inline-start:var(--dsh-thread-icon-size);padding:2px 8px;font-size:11px;line-height:18px;display:block}.jGgv6G_summary [data-thread-tree-activity=running]{color:color-mix(in srgb, var(--dsw-alias-state-business-primary), var(--dsw-alias-state-success-primary))}.jGgv6G_summary [data-thread-tree-activity=pending]{color:var(--dsw-alias-state-warn-primary)}.jGgv6G_summary [data-thread-tree-activity=completed]{color:var(--dsw-alias-state-business-primary)}@media (hover:hover) and (pointer:fine){.jGgv6G_summary:hover{background:color-mix(in srgb, var(--dsw-alias-label-primary) 4%, transparent)}}.jGgv6G_summary:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}@media (hover:none),(pointer:coarse){.jGgv6G_branch{--dsh-thread-row-height:44px}.jGgv6G_summary{min-height:24px;padding-block:3px}}[data-phone-drawer] .jGgv6G_branch{--dsh-thread-row-height:44px}[data-phone-drawer] .jGgv6G_branch:has(>:first-child>[data-thread-summary]){--dsh-thread-icon-center-y:14px}`,document.head.appendChild(e)}var Ut={branch:`jGgv6G_branch`,children:`jGgv6G_children`,summary:`jGgv6G_summary`};function Wt(e){return[{state:`running`,count:e.running},{state:`pending`,count:e.pendingInteraction},{state:`completed`,count:e.completed}]}function Gt(e){return e.pendingInteraction>0?`pending`:e.running>0?`running`:e.completed>0?`completed`:`idle`}function Kt(e,t,n){return[n(`threadTree.children`,{n:e}),...Wt(t).filter(e=>e.count>0).map(e=>n(`threadTree.${e.state}`,{n:e.count}))].join(` · `)}function qt({count:e,activity:t,t:n}){return/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[n(`threadTree.children`,{n:e}),Wt(t).filter(e=>e.count>0).map(e=>/* @__PURE__ */ (0,s.jsx)(`span`,{"data-thread-tree-activity":e.state,children:` · ${n(`threadTree.${e.state}`,{n:e.count})}`},e.state))]})}let Jt=`@deepseek-ai/dsh-client-ui-workspace/ThreadTreeRing.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Jt)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Jt,e.textContent=`.yY-O0a_ring{inset-inline-start:50%;margin-inline-start:-11px;pointer-events:none;width:22px;height:22px;color:var(--dsw-alias-state-business-primary);margin-top:-11px;position:absolute;top:50%}.yY-O0a_ring svg{width:100%;height:100%;display:block}.yY-O0a_ring circle{stroke:currentColor;stroke-width:1.5px}.yY-O0a_ring[data-thread-ring=pending]{color:var(--dsw-alias-state-warn-primary)}.yY-O0a_ring[data-thread-ring=running]{color:color-mix(in srgb, var(--dsw-alias-state-business-primary), var(--dsw-alias-state-success-primary))}.yY-O0a_ring[data-thread-ring=running] svg{animation:1.8s linear infinite yY-O0a_spin}.yY-O0a_ring[data-thread-ring=running] circle{stroke-dasharray:48 16.4}.yY-O0a_ring[data-thread-ring=idle]{color:var(--dsw-alias-label-tertiary);opacity:.55}.yY-O0a_ring[data-thread-ring=idle] circle{stroke-width:1px;stroke-dasharray:1.5 3}@keyframes yY-O0a_spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.yY-O0a_ring[data-thread-ring=running] svg{animation:none}}`,document.head.appendChild(e)}var Yt={ring:`yY-O0a_ring`,spin:`yY-O0a_spin`};function Xt({activity:e}){return/* @__PURE__ */ (0,s.jsx)(`span`,{className:Yt.ring,"data-thread-ring":Gt(e),"aria-hidden":`true`,children:/* @__PURE__ */ (0,s.jsx)(`svg`,{viewBox:`0 0 22 22`,fill:`none`,children:/* @__PURE__ */ (0,s.jsx)(`circle`,{cx:`11`,cy:`11`,r:`10.25`})})})}let Zt=[{title:`threadTree.style.samplePending`,activity:{pendingInteraction:1,running:0,completed:0}},{title:`threadTree.style.sampleRunning`,activity:{pendingInteraction:0,running:1,completed:0}},{title:`threadTree.style.sampleUnread`,activity:{pendingInteraction:0,running:0,completed:1}},{title:`threadTree.style.sampleRead`,activity:{pendingInteraction:0,running:0,completed:0}}];function Qt({style:e,t}){return/* @__PURE__ */ (0,s.jsx)(`div`,{className:Z.preview,"aria-hidden":`true`,children:Zt.map(({title:n,activity:r})=>/* @__PURE__ */ (0,s.jsx)(`div`,{className:Ut.branch,children:/* @__PURE__ */ (0,s.jsxs)(`div`,{className:`${K.sessionRow} ${Z.sampleRow}`,children:[/* @__PURE__ */ (0,s.jsx)(`div`,{className:K.sessionMain,children:/* @__PURE__ */ (0,s.jsx)(Bt,{title:t(n),identity:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(`span`,{"data-harness-id":`codex`,className:Z.sampleIcon,children:/* @__PURE__ */ (0,s.jsx)(`img`,{src:`/harness-icons/codex`,width:14,height:14,alt:``})}),e===`ring`&&/* @__PURE__ */ (0,s.jsx)(Xt,{activity:r})]})})}),e===`summary`&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:`${Ut.summary} ${Z.sampleSummary}`,children:/* @__PURE__ */ (0,s.jsx)(qt,{count:2,activity:r,t})})]})},n))})}function $t({style:e,setStyle:t,onLater:n,onExit:r,t:i}){let o=(0,a.useId)(),[c,l]=(0,a.useState)(e),u=(0,a.useRef)(null),d=(0,a.useRef)(r);d.current=r,(0,a.useLayoutEffect)(()=>{let e=u.current;return e?.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:`instant`}),()=>{e?.contains(document.activeElement)&&d.current()}},[]);let{busy:f,failed:p,save:m}=Et(t);return/* @__PURE__ */ (0,s.jsxs)(`div`,{ref:u,className:Z.prompt,"data-thread-style-prompt":!0,role:`region`,"aria-labelledby":o,children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Z.promptHeading,children:[/* @__PURE__ */ (0,s.jsx)(`strong`,{id:o,children:i(`threadTree.style.promptTitle`)}),/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:Z.later,disabled:f,onClick:n,children:i(`threadTree.style.later`)})]}),/* @__PURE__ */ (0,s.jsx)(`p`,{className:Z.hint,children:i(`threadTree.style.hint`)}),/* @__PURE__ */ (0,s.jsx)(`div`,{className:Z.comparison,role:`radiogroup`,"aria-labelledby":o,"aria-busy":f,onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault(),e.stopPropagation();let t=e.key===`Home`||e.key===`End`?Tt[e.key===`Home`?0:1]:Tt[+(c===`summary`)];e.currentTarget.querySelector(`[data-thread-style-choice="${t}"]`)?.focus()},children:Tt.map(t=>/* @__PURE__ */ (0,s.jsxs)(`button`,{type:`button`,role:`radio`,className:Z.choice,"data-thread-style-choice":t,"aria-disabled":f,"aria-checked":e===t,"aria-labelledby":`${o}-${t}`,"aria-describedby":`${o}-${t}-description`,tabIndex:c===t?0:-1,onFocus:()=>l(t),onClick:()=>void m(t),children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:Z.choiceTitle,id:`${o}-${t}`,children:i(`threadTree.style.${t}`)}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:Z.choiceSubtitle,id:`${o}-${t}-description`,children:i(`threadTree.style.${t}Subtitle`)}),/* @__PURE__ */ (0,s.jsx)(Qt,{style:t,t:i})]},t))}),p&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:Z.error,role:`alert`,children:i(`threadTree.style.error`)})]})}let en=(0,a.createContext)(void 0),tn=()=>(0,a.useContext)(en);function nn({roots:e,children:t}){return e.map(e=>/* @__PURE__ */ (0,s.jsx)(rn,{node:e,renderRow:t},e.id))}function rn({node:e,renderRow:t}){let n=(0,a.useId)(),{expansion:r,stylePrompt:i,dismissStylePrompt:o,collapseStyle:c,setCollapseStyle:l,t:u}=Rt(),d=r[e.id]===!0,f=e.tree?.depth??0,p=e.tree?.children??[];return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Ut.branch,"data-thread-branch":!0,children:[/* @__PURE__ */ (0,s.jsx)(en.Provider,{value:n,children:t(e)}),d&&i===n&&/* @__PURE__ */ (0,s.jsx)($t,{style:c,setStyle:l,onLater:o,onExit:()=>document.querySelector(`[data-thread-icon-toggle][aria-controls="${CSS.escape(n)}"]`)?.focus({preventScroll:!0}),t:u}),p.length>0&&/* @__PURE__ */ (0,s.jsx)(`div`,{id:n,role:`group`,hidden:!d,"data-thread-guide":d&&f<3?``:void 0,className:Ut.children,style:{"--dsh-thread-guide-indent":`${Math.min(f,3)*24}px`},children:d&&/* @__PURE__ */ (0,s.jsx)(nn,{roots:p,children:t})})]})}function an({node:e,title:t,toggle:n,t:r}){let i=tn(),o=(0,a.useRef)(null);(0,a.useLayoutEffect)(()=>{let e=o.current;return()=>{e!==null&&document.activeElement===e&&e.closest(`[data-row-key]`)?.querySelector(`[data-thread-icon-toggle]`)?.focus({preventScroll:!0})}},[]);let c=e.tree;if(!c||c.descendantCount===0)return null;let l=Kt(c.descendantCount,c.activity,r);return/* @__PURE__ */ (0,s.jsx)(`button`,{ref:o,type:`button`,"data-thread-summary":!0,className:Ut.summary,"aria-label":r(`threadTree.expandSummary`,{title:t,summary:l}),"aria-expanded":!1,"aria-controls":i,onClick:e=>{e.stopPropagation(),e.currentTarget.closest(`[data-row-key]`)?.querySelector(`[data-thread-icon-toggle]`)?.focus({preventScroll:!0}),n()},children:/* @__PURE__ */ (0,s.jsx)(qt,{count:c.descendantCount,activity:c.activity,t:r})})}function on(e,t){return e.blank?t(`session.new`):e.title||t(`session.untitled`)}function sn(e,t,n){let{unit:r,n:i}=(0,o.relativeTime)(e,t);return r===`now`?n(`time.now`):n(`time.${r}`,{n:i})}function cn(e,t,n){let{unit:r,n:i}=(0,o.relativeTime)(e,t);return r===`now`?n(`time.now`):n(`time.ago`,{t:n(`time.${r}`,{n:i})})}function ln(e,t){let n=new Date(e),r=e=>String(e).padStart(2,`0`);return t(`hover.created`,{time:`${t(`date.ymd`,{y:n.getFullYear(),m:n.getMonth()+1,d:n.getDate()})} ${r(n.getHours())}:${r(n.getMinutes())}`})}function un({label:e,cwd:t,createdAt:n,t:r}){return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:K.hoverContent,children:[/* @__PURE__ */ (0,s.jsx)(`div`,{className:K.hoverTitle,children:e}),/* @__PURE__ */ (0,s.jsx)(`div`,{className:K.hoverPath,children:t}),/* @__PURE__ */ (0,s.jsx)(`div`,{className:K.hoverTime,children:ln(n,r)})]})}function dn(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function fn({group:e,onToggle:t,onCreate:n,actions:r,drag:i,home:c,newShortcut:l,t:u}){let d=e,f=e.remote?void 0:r,p=e.remote?void 0:i,m=d.workspaceId===void 0?u(`group.ungrouped`):d.label,[h,g]=(0,a.useState)(!1),[_,v]=(0,a.useState)(null),b=[{id:`rename`,label:u(`rename`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconEditOutlineRegular,{})},{id:`delete`,label:u(`delete.workspace`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconTrashOutlineRegular,{}),danger:!0}],x=/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q(K.projectRow,h&&K.menuOpen),"data-row-key":`workspace:${e.key}`,role:`treeitem`,"aria-expanded":d.expanded,tabIndex:-1,onContextMenu:e=>{f&&!e.target.closest(`button`)&&(e.preventDefault(),v(new DOMRect(e.clientX,e.clientY,0,0)),g(!0))},onKeyDown:e=>{e.target===e.currentTarget&&f&&(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`)&&(e.preventDefault(),v(null),g(!0))},onClick:t,draggable:p!==void 0,onDragStart:p===void 0?void 0:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,d.key),p.start()},onDragEnd:p?.end,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:Q(K.slot,d.expanded&&K.folderExpanded),children:d.expanded?/* @__PURE__ */ (0,s.jsx)(o.IconFolderOpenRegular,{}):/* @__PURE__ */ (0,s.jsx)(o.IconFolderCloseRegular,{})}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.projectText,children:/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.title,children:m})}),d.workspaceId!==void 0&&d.remote&&/* @__PURE__ */ (0,s.jsx)(Vt,{host:d.remote,t:u}),/* @__PURE__ */ (0,s.jsxs)(`span`,{className:K.rowActions,children:[f!==void 0&&/* @__PURE__ */ (0,s.jsx)(o.Menu,{open:h,onClose:()=>{g(!1)},items:b,onSelect:e=>{
10
10
  /* v8 ignore next -- Menu can emit only the rename and delete rows supplied above. */
11
- g(!1),(e===`rename`||e===`delete`)&&(e===`rename`?f.rename():f.delete())},portal:!0,autoFocus:!0,getAnchorRect:v===null?void 0:()=>v,anchor:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:W.iconButton,"aria-label":u(`actions.workspace.aria`,{name:m}),"aria-haspopup":`menu`,"aria-expanded":h,onClick:e=>{e.stopPropagation(),y(null),g(e=>!e)},children:/* @__PURE__ */ (0,s.jsx)(o.IconEllipsisOutlineRegular,{})})}),!d.remote&&/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:u(`actions.newSession`),shortcutKeys:l?.keys,side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:W.iconButton,"aria-keyshortcuts":l?.aria,"aria-label":u(`actions.newSession.aria`,{name:m}),onClick:e=>{e.stopPropagation(),n()},children:/* @__PURE__ */ (0,s.jsx)(o.IconNewChatOutlineRegular,{})})})]})]});return d.createdAt===void 0?x:/* @__PURE__ */ (0,s.jsx)(o.HoverCard,{anchor:x,content:/* @__PURE__ */ (0,s.jsx)(Dt,{label:d.label,cwd:d.cwd===void 0?void 0:_(d.cwd,c),createdAt:d.createdAt,t:u}),openDelayMs:800,disabled:h,copyText:d.cwd,copyLabel:u(`copy`),copiedLabel:u(`hover.copied`)})}function At({node:e,now:t,renderSlot:n,t:r}){let i=je(e,r).filter(t=>!e.archived||t.state!==`done`&&t.state!==`idle`);return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:W.hoverContent,children:[/* @__PURE__ */ (0,s.jsx)(`div`,{className:W.hoverTitle,children:Ct(e,r)}),!e.blank&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:W.hoverTime,children:Tt(e.updatedAt,t,r)}),n(`sidebar.session.row.hover`,{sessionId:e.id}),i.map(e=>/* @__PURE__ */ (0,s.jsxs)(`div`,{className:W.hoverStatus,children:[/* @__PURE__ */ (0,s.jsx)(o.StateDot,{state:e.state}),/* @__PURE__ */ (0,s.jsx)(`span`,{children:e.label})]},e.label)),e.archived&&/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q(W.hoverStatus,W.hoverArchived),children:[/* @__PURE__ */ (0,s.jsx)(o.IconArchiveOutlineRegular,{size:16}),/* @__PURE__ */ (0,s.jsx)(`span`,{children:r(`row.archived`)})]})]})}function jt({result:e,currentId:t,onOpen:n,onUnarchive:r,t:i}){let a=e.id===t,c=je(e,i),l=c[0];return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q(W.searchResultRow,a&&W.selected,e.archived&&W.archived),role:`treeitem`,"aria-selected":a,"aria-description":e.archived?i(`toast.archivedNotOpenable`):void 0,onClick:()=>{n(e.id)},children:[/* @__PURE__ */ (0,s.jsxs)(`span`,{className:W.searchResultHeading,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:W.slot}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:W.searchResultTitle,children:e.title||i(`session.untitled`)}),e.remote&&/* @__PURE__ */ (0,s.jsx)(St,{host:e.remote,t:i}),!e.archived&&l.state!==`idle`&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:W.timeStatus,"data-session-status":l.state,children:/* @__PURE__ */ (0,s.jsx)(Ne,{statuses:c})}),e.archived&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:W.rowActions,children:/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:i(`actions.unarchive`),side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:W.iconButton,"aria-label":i(`menu.unarchiveSession`),onClick:t=>{t.stopPropagation(),r(e.id)},children:/* @__PURE__ */ (0,s.jsx)(o.IconUnarchiveOutlineRegular,{size:16})})})})]}),/* @__PURE__ */ (0,s.jsxs)(`span`,{className:W.searchResultMeta,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:W.searchResultWorkspace,children:e.workspace||i(`group.ungrouped`)}),e.snippet!==void 0&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:W.searchResultSnippet,children:e.snippet})]})]})}function Mt({node:e,rowKey:t=`session:${e.id}`,currentId:n,now:r,onOpen:i,onRenameRequest:c,renderSlot:l,onReveal:u,drag:d,showHost:f=!0,t:p}){let m=e,h=Ct(e,p),g=e.id===n,_=je(e,p),v=_[0],y=!m.archived&&v.state!==`idle`,b=d!==void 0&&!m.blank&&!m.archived,S=m.blank?void 0:m.reference,C=b||S!==void 0,w=(0,a.useRef)(!1),[T,E]=(0,a.useState)(!1),[D,O]=(0,a.useState)(null),k=(0,a.useMemo)(()=>[T,E],[T]),A=(0,a.useRef)(null);(0,a.useEffect)(()=>{u!==void 0&&(A.current?.scrollIntoView({block:`nearest`}),u())},[u]);let j=/* @__PURE__ */ (0,s.jsx)(`div`,{ref:A,"data-row-key":t,className:Q(W.sessionRow,g&&W.selected,T&&W.menuOpen,m.archived&&W.archived,d?.marker===`before`&&W.dropBefore,d?.marker===`after`&&W.dropAfter),role:`treeitem`,"aria-selected":g,"aria-current":g?`page`:void 0,tabIndex:-1,onContextMenu:e=>{m.blank||e.target.closest(`button`)||(e.preventDefault(),O(new DOMRect(e.clientX,e.clientY,0,0)),E(!0))},onKeyDown:t=>{t.target!==t.currentTarget||m.blank||(w.current=!1,t.key===`ContextMenu`||t.shiftKey&&t.key===`F10`?(t.preventDefault(),O(null),E(!0)):t.key===`F2`&&!m.archived&&(t.preventDefault(),c(e.id,m.title)))},"aria-description":m.archived?p(`toast.archivedNotOpenable`):void 0,onPointerDown:()=>{w.current=!1},onClick:()=>{w.current||i(e.id)},draggable:C,onDragStart:C?t=>{w.current=!0,t.dataTransfer.effectAllowed=S===void 0?`move`:b?`copyMove`:`copy`,t.dataTransfer.setData(`text/plain`,S===void 0?e.id:x(S).clipboardText),S!==void 0&&t.dataTransfer.setData(`application/x-codexhost-thread-reference`,JSON.stringify(S)),b&&d?.start()}:void 0,onDragEnd:C?e=>d?.end(e.dataTransfer.dropEffect===`copy`):void 0,onDragOver:d===void 0?void 0:e=>{d.active&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,d.hover(Ot(e)))},onDrop:d===void 0?void 0:e=>{d.active&&(e.preventDefault(),d.drop(Ot(e)))},children:/* @__PURE__ */ (0,s.jsxs)(xt,{identity:l(`sidebar.session.row.identity`,{sessionId:e.id}),ambient:!m.archived&&!m.blank&&!y&&l(`sidebar.session.row.leading`,{sessionId:e.id}),title:h,onTitleDoubleClick:m.blank?void 0:t=>{t.stopPropagation(),c(e.id,m.title)},children:[f&&m.remote&&/* @__PURE__ */ (0,s.jsx)(St,{host:m.remote,t:p}),/* @__PURE__ */ (0,s.jsxs)(`span`,{className:W.trailing,children:[!m.blank&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:Q(W.time,y&&W.timeStatus),"data-session-status":y?v.state:void 0,children:y?/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(Ne,{statuses:_}),v.trailingLabel!==void 0&&/* @__PURE__ */ (0,s.jsx)(`span`,{"aria-hidden":`true`,children:v.trailingLabel})]}):wt(m.updatedAt,r,p)}),!m.blank&&/* @__PURE__ */ (0,s.jsxs)(`span`,{className:W.rowActions,onClick:e=>{e.stopPropagation()},children:[/* @__PURE__ */ (0,s.jsx)(o.Menu,{open:T,onClose:()=>{E(!1)},portal:!0,autoFocus:!0,phoneSidebarTitle:h,phoneSidebarFooterBackLabel:p(`session.backToList`),phoneSidebarDetails:/* @__PURE__ */ (0,s.jsx)(`div`,{className:W.phoneDetails,children:/* @__PURE__ */ (0,s.jsx)(At,{node:e,now:r,renderSlot:l,t:p})}),getAnchorRect:D===null?void 0:()=>D,anchor:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:W.iconButton,"aria-label":p(`actions.session.aria`,{name:h}),"aria-haspopup":`menu`,"aria-expanded":T,onClick:()=>{O(null),E(e=>!e)},children:/* @__PURE__ */ (0,s.jsx)(o.IconEllipsisOutlineRegular,{})}),children:l(`sidebar.workspaces.session.menu.item`,{sessionId:e.id,displayTitle:m.title},{hookContext:k})}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:W.quickActions,children:l(`sidebar.workspaces.session.row.action`,{sessionId:e.id,displayTitle:m.title})})]})]})]})});return/* @__PURE__ */ (0,s.jsx)(o.HoverCard,{anchor:j,content:/* @__PURE__ */ (0,s.jsx)(At,{node:e,now:r,renderSlot:l,t:p}),openDelayMs:800,disabled:T||d?.active===!0,copyText:m.blank||m.title===``?void 0:m.title,copyLabel:p(`copy`),copiedLabel:p(`hover.copied`)})}let Nt=`@deepseek-ai/dsh-client-ui-workspace/AnimatedRows.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Nt)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Nt,e.textContent=`.Jek-Ha_exits{contain:strict;pointer-events:none;position:absolute;inset:0;overflow:clip}`,document.head.appendChild(e)}var Pt={exits:`Jek-Ha_exits`};function Ft(e){return[...e.querySelectorAll(`[data-row-key]`)].filter(e=>e.offsetHeight>0&&!e.closest(`[inert]`))}function It(e){if(!e)return;let t=Ft(e),n=document.activeElement?.closest(`[data-row-key]`),r=t.find(e=>e===n)??t.find(e=>e.getAttribute(`aria-selected`)===`true`)??t[0];for(let e of t)e.tabIndex=e===r?0:-1}function Lt(e){if(e.defaultPrevented||e.nativeEvent.isComposing||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=e.currentTarget,n=e.target;if(!(n instanceof HTMLElement)||!n.matches(`[data-row-key]`)||!t.contains(n))return;let r=Ft(t),i=r.indexOf(n);if(i<0)return;let a=n.matches(`[role="treeitem"][aria-expanded]`),o;switch(e.key){case`ArrowDown`:o=r[i+1];break;case`ArrowUp`:o=r[i-1];break;case`Home`:o=r[0];break;case`End`:o=r.at(-1);break;case`ArrowRight`:a&&n.getAttribute(`aria-expanded`)===`false`?n.click():a&&(o=r[i+1]);break;case`ArrowLeft`:if(a&&n.getAttribute(`aria-expanded`)===`true`)n.click();else{let e=n.closest(`[data-sidebar-group]`),t=e?.querySelector(`[data-row-key^="workspace:"]`);t===n&&(e=e?.parentElement?.closest(`[data-sidebar-group]`)??null,t=e?.querySelector(`[data-row-key^="workspace:"]`)),o=t??void 0}break;case`Enter`:case` `:n.click();break;default:return}e.preventDefault(),o&&(o.focus({preventScroll:!0}),o.scrollIntoView({block:`nearest`}),It(t))}function Rt(e,t){return e.rowKeys.length===t.rowKeys.length&&e.rowKeys.every((e,n)=>e===t.rowKeys[n])}function zt(e,t){return e.bottom>t.top&&e.top<t.bottom&&e.right>t.left&&e.left<t.right}var Bt=class extends a.Component{armed=!1;list=(0,a.createRef)();overlay=(0,a.createRef)();movements=/* @__PURE__ */ new Map;exits=/* @__PURE__ */ new Map;componentDidMount(){It(this.list.current)}getSnapshotBeforeUpdate(e){let t=this.list.current;if(!this.armed||Rt(e,this.props)||e.resetKey!==this.props.resetKey||!e.ready||!this.props.ready||t===null||typeof t.animate!=`function`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return null;let n=t.getBoundingClientRect(),r=this.readPositions(),i=new Set(this.props.rowKeys),a=/* @__PURE__ */ new Map;for(let[e,t]of r){if(i.has(e)||!zt(t.rect,n))continue;let r=t.element.cloneNode(!0);r.removeAttribute(`data-row-key`),r.inert=!0,r.style.setProperty(`--dsh-workspace-indent`,getComputedStyle(t.element).getPropertyValue(`--dsh-workspace-indent`)),a.set(e,{...t,element:r})}return{positions:r,removed:a}}componentDidUpdate(e,t,n){if(It(this.list.current),n===null){(!Rt(e,this.props)||e.resetKey!==this.props.resetKey||e.ready!==this.props.ready)&&this.clear();return}this.cancelMovements();let r=this.list.current,i=this.overlay.current,a=r.getBoundingClientRect(),o=i.getBoundingClientRect(),s=this.readPositions();for(let[e,t]of s){this.removeExit(e);let r=n.positions.get(e);if(!zt(t.rect,a)&&(r===void 0||!zt(r.rect,a)))continue;if(r===void 0){this.move(t.element,[{opacity:0},{opacity:1}],100);continue}let i=r.rect.left-t.rect.left,o=r.rect.top-t.rect.top;(i!==0||o!==0||r.opacity!==1)&&this.move(t.element,[{transform:`translate(${String(i)}px, ${String(o)}px)`,opacity:r.opacity},{transform:`translate(0, 0)`,opacity:1}],200)}for(let[e,t]of n.removed){let{element:n}=t;this.removeExit(e),Object.assign(n.style,{position:`absolute`,margin:`0`,transform:`none`,boxSizing:`border-box`,left:`${String(t.rect.left-o.left)}px`,top:`${String(t.rect.top-o.top)}px`,width:`${String(t.rect.width)}px`,height:`${String(t.rect.height)}px`}),i.append(n);let r=n.animate([{opacity:t.opacity},{opacity:0}],{duration:100,easing:`ease-out`,fill:`forwards`});this.exits.set(e,{element:n,animation:r}),r.onfinish=()=>{this.removeExit(e)}}}componentWillUnmount(){this.clear()}readPositions(){let e=this.list.current.querySelectorAll(`[data-row-key]`);return new Map(Array.from(e,e=>[e.dataset.rowKey,{element:e,rect:e.getBoundingClientRect(),opacity:this.movements.has(e)?Number(getComputedStyle(e).opacity):1}]))}move(e,t,n){let r=e.animate(t,{duration:n,easing:`ease-out`});this.movements.set(e,r),r.onfinish=()=>{this.movements.delete(e),r.cancel()}}cancelMovements(){for(let e of this.movements.values())e.onfinish=null,e.cancel();this.movements.clear()}removeExit(e){let t=this.exits.get(e);t!==void 0&&(t.animation.onfinish=null,t.animation.cancel(),t.element.remove(),this.exits.delete(e))}clear(){this.cancelMovements();for(let e of this.exits.keys())this.removeExit(e)}render(){return/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(`div`,{ref:this.list,className:this.props.className,role:`tree`,"aria-label":this.props.label,onKeyDown:Lt,onFocusCapture:()=>It(this.list.current),onPointerDownCapture:()=>{this.armed=!0},onKeyDownCapture:()=>{this.armed=!0},children:this.props.children}),/* @__PURE__ */ (0,s.jsx)(`div`,{ref:this.overlay,className:Pt.exits,"aria-hidden":`true`})]})}};let Vt=`@deepseek-ai/dsh-client-ui-workspace/SectionHeading.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Vt)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Vt,e.textContent=`.Z54rEq_heading{border-radius:var(--dsw-radius-sm);min-height:30px;color:var(--dsw-alias-label-tertiary);align-items:center;gap:6px;padding:0 8px;font-size:14px;font-weight:500;line-height:21px;display:flex}.Z54rEq_heading[data-row-key]{cursor:pointer}.Z54rEq_heading[data-row-key]:hover{background:var(--dsw-alias-interactive-bg-hover)}.Z54rEq_heading[data-row-key]:focus-visible,.Z54rEq_action:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.Z54rEq_title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.Z54rEq_chevron,.Z54rEq_collapsed{flex-shrink:0}.Z54rEq_collapsed{transform:rotate(-90deg)}.Z54rEq_action{border-radius:var(--dsw-radius-sm);width:24px;height:24px;color:inherit;cursor:pointer;background:0 0;border:none;place-items:center;margin-inline-start:auto;padding:0;display:grid}.Z54rEq_action:hover{background:var(--dsw-alias-interactive-bg-hover)}@media (pointer:coarse){.Z54rEq_heading{min-height:44px}.Z54rEq_action{width:44px;height:44px}}`,document.head.appendChild(e)}var Ht={action:`Z54rEq_action`,chevron:`Z54rEq_chevron`,collapsed:`Z54rEq_collapsed`,heading:`Z54rEq_heading`,title:`Z54rEq_title`};function Ut({label:e,icon:t,expanded:n,onToggle:r,rowKey:i,action:a}){let c=n!==void 0&&r!==void 0&&i!==void 0,l=/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[t,/* @__PURE__ */ (0,s.jsx)(`span`,{className:Ht.title,children:e}),c&&/* @__PURE__ */ (0,s.jsx)(o.IconChevronDownOutlineRegular,{className:n?Ht.chevron:Ht.collapsed,size:12}),a!==void 0&&/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:a.label,portal:!0,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:Ht.action,"aria-label":a.label,onClick:e=>{e.stopPropagation(),a.onActivate()},children:a.icon})})]});return c?/* @__PURE__ */ (0,s.jsx)(`div`,{className:Ht.heading,role:`treeitem`,tabIndex:-1,"data-row-key":i,"aria-label":e,"aria-expanded":n,onClick:r,children:l}):/* @__PURE__ */ (0,s.jsx)(`div`,{className:Ht.heading,children:l})}let Wt=`@deepseek-ai/dsh-client-ui-workspace/PinnedSection.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Wt)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Wt,e.textContent=`.t4p6JG_section{margin-bottom:8px}.t4p6JG_section>[data-row-key]+[data-row-key]{margin-top:2px}`,document.head.appendChild(e)}var Gt={section:`t4p6JG_section`};function Kt({rows:e,currentId:t,onOpen:n,onRenameRequest:r,renderSlot:i,t:a,revealSessionId:c,onSessionRevealed:l,expanded:u,onToggle:d}){return e.length===0?null:/* @__PURE__ */ (0,s.jsxs)(`div`,{role:`group`,"aria-label":a(`section.pinned`),className:Gt.section,"data-sidebar-pinned":!0,children:[/* @__PURE__ */ (0,s.jsx)(Ut,{label:a(`section.pinned`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconPinOutlineRegular,{size:14}),expanded:u,onToggle:d,rowKey:`section:${L}`}),u&&e.map(e=>/* @__PURE__ */ (0,s.jsx)(Mt,{node:e,currentId:t,now:Date.now(),onOpen:n,onRenameRequest:r,renderSlot:i,onReveal:e.id===c?()=>l(e.id):void 0,t:a},e.id))]})}let qt=`@deepseek-ai/dsh-client-ui-workspace/WorkspaceBrowser.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(qt)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=qt,e.textContent=`._14DcuW_root{--dsh-session-list-edge-inset:var(--dsh-sidebar-inline-padding);--dsh-session-list-scrollbar-width:5px;--dsh-session-list-scrollbar-offset:2px;box-sizing:border-box;min-height:0;padding-right:var(--dsh-session-list-edge-inset);flex-direction:column;flex:1;display:flex}[data-phone-drawer] ._14DcuW_root{--dsh-session-list-scrollbar-width:0px}[data-phone-drawer] ._14DcuW_list{scrollbar-gutter:auto}._14DcuW_root._14DcuW_rail{padding-right:0}._14DcuW_iconButton{border-radius:var(--dsw-radius-sm);cursor:pointer;width:28px;height:28px;color:var(--dsw-alias-label-secondary);background:0 0;border:none;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}._14DcuW_iconButton:focus-visible,._14DcuW_searchButton:focus-visible,._14DcuW_clearButton:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}._14DcuW_iconButton:hover{background:var(--dsw-alias-interactive-bg-hover)}._14DcuW_viewOptionsMenu{min-width:200px}._14DcuW_sectionHeader{box-sizing:border-box;height:36px;color:var(--dsw-alias-label-tertiary);border-radius:6px;flex:none;justify-content:flex-end;align-items:center;gap:4px;margin-bottom:6px;padding-left:4px;display:flex;overflow:hidden}._14DcuW_root:not(._14DcuW_rail) ._14DcuW_sectionHeader{margin-top:2px;margin-right:-4px}._14DcuW_sectionLabel{white-space:nowrap;opacity:1;visibility:visible;min-width:0;max-width:45%;transition:max-width .18s var(--ds-ease-in-out), margin-right .18s var(--ds-ease-in-out), opacity .12s var(--ds-ease-in-out), transform .18s var(--ds-ease-in-out), visibility 0s linear;flex:none;font-size:14px;font-weight:500;line-height:21px;overflow:hidden}._14DcuW_sectionLabelHidden{opacity:0;visibility:hidden;max-width:0;margin-right:-4px;transition-delay:0s,0s,0s,0s,.18s;transform:translate(-4px)}._14DcuW_searchSlot{box-sizing:border-box;min-width:0;max-width:28px;transition:max-width .18s var(--ds-ease-in-out), padding-left .18s var(--ds-ease-in-out);flex:1;align-items:center;margin-left:auto;padding-left:0;display:flex}._14DcuW_searchSlotExpanded{max-width:100%;padding-left:0}._14DcuW_headerActions{opacity:1;visibility:visible;max-width:60px;transition:max-width .18s var(--ds-ease-in-out), opacity .12s var(--ds-ease-in-out), transform .18s var(--ds-ease-in-out), visibility 0s linear;flex:none;align-items:center;gap:4px;display:flex;overflow:hidden}._14DcuW_headerActionsHidden{opacity:0;visibility:hidden;pointer-events:none;max-width:0;transition-delay:0s,0s,0s,.18s;transform:translate(4px)}._14DcuW_search{box-sizing:border-box;border-radius:var(--dsw-radius-sm);cursor:text;width:100%;height:28px;color:var(--dsw-alias-label-secondary);transition:width .18s var(--ds-ease-in-out), padding .18s var(--ds-ease-in-out), border-color .18s var(--ds-ease-in-out), background-color .18s var(--ds-ease-in-out);background:0 0;border:none;flex:none;align-items:center;gap:0;margin:0;padding:0;display:flex;overflow:hidden}._14DcuW_searchExpanded{border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);width:calc(100% + 4px);height:30px;color:var(--dsw-alias-label-caption);background:0 0;margin-inline:-2px;padding:0 4px 0 0}._14DcuW_searchButton{border-radius:var(--dsw-radius-sm);cursor:pointer;width:28px;height:28px;color:inherit;background:0 0;border:none;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}._14DcuW_searchExpanded ._14DcuW_searchButton{width:28px;height:30px}._14DcuW_searchButton:hover{background:var(--dsw-alias-interactive-bg-hover)}._14DcuW_searchExpanded ._14DcuW_searchButton:hover{background:0 0}._14DcuW_searchInput{opacity:0;pointer-events:none;width:0;min-width:0;color:var(--dsw-alias-label-primary);transition:opacity .12s var(--ds-ease-in-out);background:0 0;border:none;outline:none;flex:1;font-size:13px;line-height:18px}._14DcuW_searchExpanded ._14DcuW_searchInput{opacity:1;pointer-events:auto;margin-left:-2px}._14DcuW_searchInput::placeholder{color:var(--dsw-alias-label-tertiary)}._14DcuW_clearButton{border-radius:var(--dsw-radius-sm);cursor:pointer;width:24px;height:24px;color:var(--dsw-alias-label-secondary);background:0 0;border:none;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}._14DcuW_clearButton:hover{background:var(--dsw-alias-interactive-bg-hover)}._14DcuW_rail ._14DcuW_sectionHeader{justify-content:flex-start;gap:0;margin-bottom:12px;padding-left:0}._14DcuW_rail ._14DcuW_headerActions{max-width:none}._14DcuW_rail ._14DcuW_iconButton{border-radius:var(--dsw-radius-md);width:36px;height:36px;color:var(--dsw-alias-label-primary)}._14DcuW_rail ._14DcuW_search{border-radius:var(--dsw-radius-md);background:0 0;border-color:#0000;gap:0;width:36px;height:36px;margin:0 0 12px;padding:0}._14DcuW_rail ._14DcuW_searchButton{border-radius:var(--dsw-radius-md);width:36px;height:36px;color:var(--dsw-alias-label-primary)}._14DcuW_rail ._14DcuW_searchButton:hover{background:var(--dsw-alias-interactive-bg-hover)}._14DcuW_listArea{min-height:0;margin-left:-4px;margin-right:calc(-1 * var(--dsh-session-list-edge-inset));flex-direction:column;flex:1;padding-left:4px;display:flex;overflow:visible}._14DcuW_rail ._14DcuW_listArea{margin-left:0;margin-right:0;padding-left:0}._14DcuW_treeBody{flex-direction:column;flex:1;min-height:0;display:flex;position:relative}._14DcuW_fade{left:0;right:var(--dsh-session-list-edge-inset);background:linear-gradient(to bottom, transparent, var(--dsw-specific-sidebar-fill));pointer-events:none;height:24px;position:absolute;bottom:0}[data-platform=darwin] ._14DcuW_fade,[data-phone-drawer] ._14DcuW_fade{display:none}._14DcuW_wide{animation:_14DcuW_wide-in .2s var(--ds-ease-in-out)}@keyframes _14DcuW_wide-in{0%{opacity:0}}._14DcuW_list{overscroll-behavior-y:contain;min-height:0;margin-left:-4px;margin-right:var(--dsh-session-list-scrollbar-offset);padding-left:4px;padding-right:calc(var(--dsh-session-list-edge-inset) - var(--dsh-session-list-scrollbar-width) - var(--dsh-session-list-scrollbar-offset));scrollbar-gutter:stable;flex:1;padding-bottom:16px;scroll-padding-block:8px;overflow-y:auto}._14DcuW_flatList>*+*,._14DcuW_searchTree>[role=treeitem]+[role=treeitem],._14DcuW_groupSection>*+*,._14DcuW_groupSessions>*+*{margin-top:2px}._14DcuW_searchStatus{color:var(--dsw-alias-label-tertiary);padding:10px 12px;font-size:12px;line-height:18px}._14DcuW_skeletonRow{box-sizing:border-box;align-items:flex-start;gap:8px;min-height:48px;padding:6px 8px 7px;display:flex}._14DcuW_skeletonDot{corner-shape:round;border-radius:50%;flex:none;width:16px;height:16px}._14DcuW_skeletonBars{flex-direction:column;flex:1;gap:6px;min-width:0;display:flex}._14DcuW_skeletonDot,._14DcuW_skeletonBar{background:var(--dsw-alias-bg-skeleton);animation:2s cubic-bezier(.36,0,.64,1) infinite _14DcuW_search-skeleton}._14DcuW_skeletonBar{border-radius:var(--dsw-radius-xs);width:65%;height:16px}._14DcuW_skeletonBarWide{width:90%;height:13px}@keyframes _14DcuW_search-skeleton{0%{opacity:1}40%{opacity:.6}80%,to{opacity:1}}._14DcuW_groupSection{position:relative}._14DcuW_groupSection+._14DcuW_groupSection{margin-top:4px}._14DcuW_listTopDropIndicator,._14DcuW_workspaceDropBefore:before,._14DcuW_workspaceDropAfter:after{content:"";z-index:1;background:linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat, linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat, linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;pointer-events:none;height:12px;position:absolute;left:0;right:0}._14DcuW_listTopDropIndicator{top:-8px;left:0;right:var(--dsh-session-list-edge-inset)}._14DcuW_listTopDropActive>._14DcuW_workspaceDropBefore:first-child:before{display:none}._14DcuW_workspaceDropBefore:before{top:-8px}._14DcuW_workspaceDropAfter:after{bottom:-8px}._14DcuW_sessionOverflowButton{width:100%;height:32px;padding:0 12px 0 calc(32px + var(--dsh-workspace-indent,0px));cursor:pointer;text-align:left;color:var(--dsw-alias-label-tertiary);background:0 0;border:none;border-radius:6px;font-size:12px}._14DcuW_sessionOverflowButton[data-row-key=overflow\\:workspaces]{padding-inline-start:8px}._14DcuW_groupSessions>._14DcuW_sessionOverflowButton{margin-top:0;padding-inline-start:calc(8px + var(--dsh-workspace-indent,0px))}._14DcuW_sessionOverflowButton:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}._14DcuW_sessionOverflowButton:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}@media (hover:none),(pointer:coarse){._14DcuW_sessionOverflowButton,._14DcuW_root:not(._14DcuW_rail) ._14DcuW_iconButton{min-height:44px}._14DcuW_root:not(._14DcuW_rail) ._14DcuW_sectionHeader{height:44px}}._14DcuW_empty{color:var(--dsw-alias-label-tertiary);padding:16px 12px;font-size:13px}._14DcuW_emptyState{color:var(--dsw-alias-label-tertiary);flex-direction:column;align-items:center;gap:8px;margin-top:80px;padding:0 12px;font-size:13px;line-height:20px;display:flex}._14DcuW_emptyState>svg{color:var(--dsw-alias-label-caption);margin-bottom:4px}._14DcuW_emptyAction{cursor:pointer;color:var(--dsw-alias-link);background:0 0;border:none;padding:0;font-size:13px;line-height:20px}._14DcuW_renameInput{box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-lg);width:100%;height:44px;color:var(--dsw-alias-label-primary);background:0 0;outline:none;padding:7px 14px;font-size:14px;font-weight:400;line-height:22px}._14DcuW_renameInput:disabled{color:var(--dsw-alias-label-dimmed)}._14DcuW_renameError{color:var(--dsw-alias-state-error-primary);margin-top:8px;font-size:12px;line-height:18px}._14DcuW_deleteAction:not(:disabled){color:var(--dsw-alias-state-error-primary)}._14DcuW_deleteStatus{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}._14DcuW_archiveActivity{color:var(--dsw-alias-label-primary);margin:0 0 8px;padding-left:18px;font-size:13px;line-height:20px}._14DcuW_archiveActivity li{overflow-wrap:anywhere}@media (prefers-reduced-motion:reduce){._14DcuW_wide,._14DcuW_skeletonDot,._14DcuW_skeletonBar{animation:none}._14DcuW_search,._14DcuW_sectionLabel,._14DcuW_searchSlot,._14DcuW_searchInput,._14DcuW_headerActions{transition:none}}`,document.head.appendChild(e)}var $={archiveActivity:`_14DcuW_archiveActivity`,clearButton:`_14DcuW_clearButton`,deleteAction:`_14DcuW_deleteAction`,deleteStatus:`_14DcuW_deleteStatus`,empty:`_14DcuW_empty`,emptyAction:`_14DcuW_emptyAction`,emptyState:`_14DcuW_emptyState`,fade:`_14DcuW_fade`,flatList:`_14DcuW_flatList`,groupSection:`_14DcuW_groupSection`,groupSessions:`_14DcuW_groupSessions`,headerActions:`_14DcuW_headerActions`,headerActionsHidden:`_14DcuW_headerActionsHidden`,iconButton:`_14DcuW_iconButton`,list:`_14DcuW_list`,listArea:`_14DcuW_listArea`,listTopDropActive:`_14DcuW_listTopDropActive`,listTopDropIndicator:`_14DcuW_listTopDropIndicator`,rail:`_14DcuW_rail`,renameError:`_14DcuW_renameError`,renameInput:`_14DcuW_renameInput`,root:`_14DcuW_root`,search:`_14DcuW_search`,"search-skeleton":`_14DcuW_search-skeleton`,searchButton:`_14DcuW_searchButton`,searchExpanded:`_14DcuW_searchExpanded`,searchInput:`_14DcuW_searchInput`,searchSlot:`_14DcuW_searchSlot`,searchSlotExpanded:`_14DcuW_searchSlotExpanded`,searchStatus:`_14DcuW_searchStatus`,searchTree:`_14DcuW_searchTree`,sectionHeader:`_14DcuW_sectionHeader`,sectionLabel:`_14DcuW_sectionLabel`,sectionLabelHidden:`_14DcuW_sectionLabelHidden`,sessionOverflowButton:`_14DcuW_sessionOverflowButton`,skeletonBar:`_14DcuW_skeletonBar`,skeletonBarWide:`_14DcuW_skeletonBarWide`,skeletonBars:`_14DcuW_skeletonBars`,skeletonDot:`_14DcuW_skeletonDot`,skeletonRow:`_14DcuW_skeletonRow`,treeBody:`_14DcuW_treeBody`,viewOptionsMenu:`_14DcuW_viewOptionsMenu`,wide:`_14DcuW_wide`,"wide-in":`_14DcuW_wide-in`,workspaceDropAfter:`_14DcuW_workspaceDropAfter`,workspaceDropBefore:`_14DcuW_workspaceDropBefore`};function Jt({list:e,refreshSessions:t,loadMoreSessions:n,t:r}){return e.listError?/* @__PURE__ */ (0,s.jsxs)(`div`,{role:`alert`,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{children:e.listError}),/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:$.sessionOverflowButton,disabled:e.loading,onClick:e.listErrorPage===`more`?n:t,children:r(`sessions.retry`)})]}):null}function Yt(e,t,n,r){let i=0,a=e.filter(e=>e.blank||e.pinned||e.running||e.runningSubagentCount>0?!0:i++<t||e.id===n||e.id===r);return{rows:a,hiddenCount:e.length-a.length}}function Xt(e,t,n){let r=e.filter((e,r)=>r<t||n.has(e.key));return{rows:r,hiddenCount:e.length-r.length}}function Zt({rowKey:e,hiddenCount:t,hasMore:n,loading:r,expanded:i,expand:a,collapse:o,loadMoreSessions:c,t:l}){if(t===0&&!n&&!o)return null;let u=t===0&&n&&r;return/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,"data-row-key":e,className:$.sessionOverflowButton,"aria-expanded":i,disabled:u,onClick:()=>{t>0?a():n?(a(),c()):o?.()},children:u?l(`sessions.loading`):t>0?l(`sessions.expand`,{n:Math.min(10,t)}):l(n?`sessions.expandMore`:`sessions.collapse`)})}let Qt=`@deepseek-ai/dsh-client-ui-workspace/WorkspacePicker.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Qt)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Qt,e.textContent=`.s4nt4G_modalAction{min-width:72px}.s4nt4G_modalError,.s4nt4G_menuStatus{margin-top:8px;font-size:12px;line-height:18px}.s4nt4G_modalError{color:var(--dsw-alias-state-error-primary)}.s4nt4G_menuStatus{color:var(--dsw-alias-label-secondary)}`,document.head.appendChild(e)}var $t={menuStatus:`s4nt4G_menuStatus`,modalAction:`s4nt4G_modalAction`,modalError:`s4nt4G_modalError`};let en=`::add-workspace`,tn=`::no-workspace`;function nn({t:e,open:t,anchorRef:n,useWorkspaces:r,createWorkspace:i,useDirectoryFlow:c,renderDirectoryFlow:l,onPick:u,onPickNone:d,onClose:f,addOnly:p=!1,onBusyChange:m,side:h=`bottom`,selectedId:g}){let _=r(e=>e),v=_.items,y=(0,a.useCallback)(()=>n?.current?.getBoundingClientRect()??null,[n]),[b,x]=(0,a.useState)(!1),[S,C]=(0,a.useState)(null),[w,T]=(0,a.useState)(!1),E=(0,o.usePhoneSidebar)(),D=(0,a.useRef)(!1),[O,k]=(0,a.useState)(!1),A=w||O;(0,a.useEffect)(()=>{m?.(A)},[A,m]);let j=c(e=>e);(0,a.useEffect)(()=>{w&&!j&&T(!1)},[w,j]);let ee=j?[{id:en,label:e(`menu.addWorkspace`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconPlusOutlineRegular,{size:16}),disabled:A}]:[],te=!p&&v.length>0,M=d!==void 0&&!p,N=M?[{id:tn,label:e(`menu.noWorkspace`),disabled:A}]:[],P=te?[...N,...v.map(t=>({id:t.workspaceId,label:bt(t.title,e(`workspace.defaultName`)),icon:/* @__PURE__ */ (0,s.jsx)(o.IconFolderCloseRegular,{size:16}),disabled:A}))]:[...N,...ee],F=P.length===0,ne=()=>{x(!1),C(null)},re=e=>i({path:e}).then(e=>{T(!1),u(e.workspaceId)}).catch(e=>{C(e instanceof Error?e.message:String(e)),T(!1),x(!0)}),ie=(0,a.useCallback)(()=>{D.current=E?.open===!0,f(),x(!1),C(null),T(!0)},[f,E?.open]),I=p||_.phase===`ready`,ae=!M&&!te&&I&&ee.length===1;(0,a.useEffect)(()=>{t&&ae&&!A&&ie()},[t,ae,A,ie]);let oe={open:w,busy:O,onPicked:e=>{k(!0),re(e).finally(()=>{k(!1)})},onCancel:()=>{T(!1)},onError:e=>{T(!1),C(e),x(!0)}},se=e=>{e===tn?d?.():e===en?ie():u(e)};return/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.Menu,{open:t&&!ae&&!F,anchor:null,items:P,...te?{footer:ee}:{},selectedId:g??(M?tn:void 0),onSelect:se,onClose:f,side:h,portal:!0,getAnchorRect:y}),t&&!ae&&!F&&_.phase===`pending`&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$t.menuStatus,role:`status`,children:e(`picker.loading`)}),l(oe),/* @__PURE__ */ (0,s.jsx)(o.Modal,{phoneSidebar:!0,phoneSidebarOrigin:D.current,open:b,onClose:ne,closeLabel:e(`close`),title:e(`folderError.title`),footer:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,className:$t.modalAction,onClick:ne,children:e(`cancel`)}),/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`primary`,className:$t.modalAction,disabled:!j,onClick:ie,children:e(`folderError.retry`)})]}),children:/* @__PURE__ */ (0,s.jsx)(`div`,{className:$t.modalError,role:`alert`,children:S})})]})}function rn({open:e,anchorRef:t,useWorkspaces:n,selectedId:r,onPick:i,onClose:a,createWorkspace:o,useDirectoryFlow:c,renderSlot:l,t:u}){let d=n(e=>e.canStartProjectless);return/* @__PURE__ */ (0,s.jsx)(nn,{t:u,open:e,anchorRef:t,useWorkspaces:n,createWorkspace:o,useDirectoryFlow:c,renderDirectoryFlow:e=>l(`conversation.hero.workspace.directoryFlow`,e),selectedId:r,onPick:i,...d?{onPickNone:()=>i(null)}:{},onClose:a})}function an(e){let t=e.replaceAll(`\0`,``);if(t.length<=500)return t;let n=500,r=t.charCodeAt(n-1),i=t.charCodeAt(n);return r>=55296&&r<=56319&&i>=56320&&i<=57343&&n--,t.slice(0,n)}function on(e){(0,a.useEffect)(()=>{if(!e)return;let t=e=>{e.defaultPrevented||(e.preventDefault(),e.dataTransfer!==null&&(e.dataTransfer.dropEffect=`move`))},n=e=>{e.preventDefault()};return document.addEventListener(`dragover`,t),document.addEventListener(`drop`,n),()=>{document.removeEventListener(`dragover`,t),document.removeEventListener(`drop`,n)}},[e])}function sn({groupBy:e,orderBy:t,archivedFilter:n,onGroupPick:r,onOrderPick:i,onArchivedFilterPick:c,t:l}){let[u,d]=(0,a.useState)(!1),f=(0,o.usePhoneSidebar)();return/* @__PURE__ */ (0,s.jsx)(o.Menu,{phoneSidebarTitle:l(`viewOptions.label`),open:u,onClose:()=>{d(!1)},items:[{type:`label`,id:`group-by`,text:l(`groupBy.label`)},{id:`workspace`,label:l(`groupBy.workspace`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconFolderCloseRegular,{})},{id:`workspace-tree`,label:l(`groupBy.workspaceTree`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconWorkspaceTreeOutlineRegular,{})},{id:`flat`,label:l(`groupBy.flat`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconFlatListOutlineRegular,{})},{type:`separator`,id:`order-by-separator`},{type:`label`,id:`order-by`,text:l(`orderBy.label`)},{id:`manual`,label:l(`orderBy.manual`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconChevronsUpDownOutlineRegular,{})},{id:`updated`,label:l(`orderBy.updated`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconClockOutlineRegular,{})},{type:`separator`,id:`archived-filter-separator`},{type:`label`,id:`filter-by`,text:l(`filterBy.label`)},{id:`hide-archived`,label:l(`viewOptions.hideArchived`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconArchiveOffOutlineRegular,{})},{id:`show-archived`,label:l(`viewOptions.showArchived`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconQueueOutlineRegular,{})},{id:`only-archived`,label:l(`viewOptions.onlyArchived`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconArchiveCheckOutlineRegular,{})}],selectedIds:[e,t,{default:`hide-archived`,show:`show-archived`,only:`only-archived`}[n]],onSelect:e=>{e===`workspace`||e===`workspace-tree`||e===`flat`?r(e):e===`manual`||e===`updated`?i(e):e===`hide-archived`?c(`default`):e===`show-archived`?c(`show`):e===`only-archived`&&c(`only`),d(!1)},align:`end`,dense:!0,listClassName:$.viewOptionsMenu,portal:!0,anchor:/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:l(`viewOptions.label`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:Q($.iconButton,$.wide),"aria-label":l(`viewOptions.label`),"data-phone-sidebar-return":f!==null||void 0,onClick:()=>{d(e=>!e)},children:/* @__PURE__ */ (0,s.jsx)(o.IconSlidersTwoOutlineRegular,{})})})})}function cn(e,t,n,r){let i=t.find(e=>e.id===n.sessionId),a=t.find(e=>e.id===r.id);if(i===void 0||a===void 0||i.blank||i.pinned!==n.pinned||a.pinned!==n.pinned||i.id===a.id||!e.includes(i.id))return;let o=t.filter(e=>e.pinned===n.pinned),s=o.findIndex(e=>e.id===i.id);if(o.filter(e=>e.id!==i.id).findIndex(e=>e.id===a.id)+ +(r.half===`after`)===s)return;let c=e.filter(e=>e!==i.id),l=c.indexOf(a.id);if(l!==-1)return c.splice(l+ +(r.half===`after`),0,i.id),D(c,t.find(e=>e.blank)?.id)}function ln(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function un({rowState:e,onLeaveArchivedOnly:t,partial:n,t:r}){let i=e.archivedFilter===`only`;return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:$.emptyState,"data-row-key":`empty`,children:[i?/* @__PURE__ */ (0,s.jsx)(o.IconArchiveOutlineRegular,{size:24}):/* @__PURE__ */ (0,s.jsx)(o.IconQueueOutlineRegular,{size:24}),/* @__PURE__ */ (0,s.jsx)(`div`,{children:r(n?`sessions.notLoaded`:i?`empty.noneArchived`:`empty.none`)}),i&&/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:$.emptyAction,onClick:t,children:r(`empty.viewOthers`)})]})}function dn({list:e,useSessionStatus:t,startSession:n,open:r,workspaces:i,ungroupedSessionIds:c,rowState:l,onLeaveArchivedOnly:u,workspaceReady:d,canStartProjectless:f,animationResetKey:p,usePanelInfo:m,onRenameRequest:h,onDeleteRequest:g,onSessionRenameRequest:_,renderSlot:v,insertWorkspaceBefore:y,nestWorkspaces:b,groupExpansion:x,setGroupExpanded:C,sectionExpansion:w,setSectionExpanded:T,setSessionOrder:E,home:D,t:O,revealSessionId:k,onSessionRevealed:A,shortcuts:j,loadMoreSessions:ee}){let te=m(e=>e.activePanelId!==null),M=t(e=>e),N=te?void 0:Object.values(e.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,P=k===void 0||!d?void 0:S(i,k),[ne,re]=(0,a.useState)({}),[I,ae]=(0,a.useState)(null),se=(0,a.useRef)(!1),[R,z]=(0,a.useState)(null),ue=(0,a.useRef)(!1),de=I!==null||R!==null;on(de);let fe=N===void 0||!d?void 0:S(i,N);(0,a.useEffect)(()=>{N===void 0||fe===void 0||Object.hasOwn(x,fe)||C(fe,!0)},[N,fe,C,x]);let B=(0,a.useMemo)(()=>{if(!b)return/* @__PURE__ */ new Map;let e=/* @__PURE__ */ new Map;for(let t of i){let n=t.remote?.hostId??`local`,r=e.get(n)??/* @__PURE__ */ new Map;t.path&&r.set(t.path,t.workspaceId),e.set(n,r)}return new Map(i.map(t=>{let n=e.get(t.remote?.hostId??`local`),r=oe(t.path,[...n?.keys()??[]]);return[t.workspaceId,r===void 0?void 0:n?.get(r)]}))},[b,i]),pe=(0,a.useMemo)(()=>{let e=new Set(B.values());return[...i.map(e=>e.workspaceId),``].filter(t=>x[t]??(t===``||e.has(t)))},[x,B,i]),me=(0,a.useMemo)(()=>{let t=F(e,i,l,M,{expandedGroups:pe,excludePinned:!0});return(f||e.hasMore&&t.length===0)&&!t.some(e=>e.key===``)&&t.push({key:``,workspaceId:void 0,cwd:void 0,createdAt:void 0,label:``,sessionCount:0,expanded:pe.includes(``),containsCurrent:!1,sessions:[]}),t},[e,i,l,M,pe,f]);(0,a.useEffect)(()=>{for(let e=P;e!==void 0;e=B.get(e))(x[e]===!1||e===P&&x[e]!==!0)&&C(e,!0)},[x,B,P,C]);let he=Date.now(),V=(e,t)=>{if(se.current)return;se.current=!0,ae(null);let n=me.find(t=>t.key===e.accountKey);if(n===void 0||t.id===e.sessionId)return;let r=e.accountKey===``?c:i.find(t=>t.workspaceId===e.accountKey)?.sessionIds;if(r===void 0)return;let a=Yt(n.sessions,ne[n.key]??5,N,k).rows,o=cn(r,a,e,t);o!==void 0&&E(e.accountKey,o)},ge=(e,t)=>{if(ue.current||(ue.current=!0,z(null),!vt(i,e.workspaceId,t.id)))return;let n=B.get(e.workspaceId),r=i.filter(e=>!e.remote&&B.get(e.workspaceId)===n),a=r.findIndex(e=>e.workspaceId===t.id);if(a===-1)return;let o=t.half===`before`?t.id:r[a+1]?.workspaceId;if(o===e.workspaceId)return;let s=r.findIndex(t=>t.workspaceId===e.workspaceId),c=o===void 0?r.length:r.findIndex(e=>e.workspaceId===o);(s===-1||c!==s&&c!==s+1)&&y(e.workspaceId,o).catch(e=>{console.warn(`workspace reorder rejected:`,e)})},_e=(0,a.useMemo)(()=>{let e=new Set(me.map(e=>e.key)),t=/* @__PURE__ */ new Map;for(let n of me){let r=B.get(n.key);for(;r!==void 0&&!e.has(r);)r=B.get(r);let i=t.get(r);i===void 0?t.set(r,[n]):i.push(n)}return t},[me,B]),ve=_e.get(void 0)??[],ye=ve[0]?.workspaceId!==void 0&&R?.over?.id===ve[0].workspaceId&&R.over.half===`before`,be=(0,a.useMemo)(()=>{let e=/* @__PURE__ */ new Map,t=(n,r)=>{e.set(n.key,r);for(let e of _e.get(n.key)??[])t(e,r)};for(let e of ve)t(e,e.key);return e},[_e,ve]),xe=(0,a.useMemo)(()=>{let e=/* @__PURE__ */ new Set;for(let t of[fe,P]){let n=t===void 0?void 0:be.get(t);n!==void 0&&n!==``&&e.add(n)}return e},[fe,P,be]),[Se,Ce]=(0,a.useState)(!1),H=ve.filter(e=>e.key!==``),we=Xt(H,5,xe),Te=Se?H:we.rows,Ee=le(w,L),De=le(w,ce),Oe=e=>{e.expanded&&re(t=>({...t,[e.key]:5})),C(e.key,!e.expanded)},U=ie(e,l.pinnedSessionIds,l,M).filter(e=>e.pinned),ke=[];if(U.length>0&&(ke.push(`section:${L}`),Ee))for(let e of U)ke.push(`session:${e.id}`);me.length===0&&U.length===0&&ke.push(`empty`);let Ae=(t,a)=>{let c=t.workspaceId,l=_e.get(t.key)??[],u=R!==null&&vt(i,R.workspaceId,c)&&B.get(R.workspaceId)===B.get(t.key),d=Yt(t.sessions,ne[t.key]??5,N,k);ke.push(`workspace:${t.key}`);let p=t.expanded?l.map(e=>Ae(e,a+1)):[],m=d.rows;for(let e of m)ke.push(`${c===void 0?`recent`:`session`}:${e.id}`);let y=t.expanded&&(d.hiddenCount>0||e.hasMore);y&&ke.push(`overflow:${t.key}`);let b=c!==void 0&&R?.over?.id===c?R.over.half:null,x=c===void 0||t.remote?void 0:{start:()=>{ue.current=!1,z({workspaceId:c,over:null})},end:()=>{R?.over!==null&&R?.over!==void 0?ge(R,R.over):z(null),ue.current=!1}},S=c===void 0||!u?void 0:e=>{z(t=>t===null?t:{...t,over:{id:c,half:e}})},w=c===void 0||!u?void 0:e=>{ge(R,{id:c,half:e})};return/* @__PURE__ */ (0,s.jsxs)(`div`,{"data-sidebar-group":t.key,style:{"--dsh-workspace-indent":`${a*12}px`},className:Q($.groupSection,b===`before`&&$.workspaceDropBefore,b===`after`&&$.workspaceDropAfter),onDragOver:R===null?void 0:e=>{e.preventDefault(),(S!==void 0||B.get(t.key)===void 0)&&(e.stopPropagation(),S===void 0?(e.dataTransfer.dropEffect=`none`,R.over!==null&&z({...R,over:null})):(e.dataTransfer.dropEffect=`move`,S(ln(e))))},onDrop:R===null?void 0:e=>{e.preventDefault(),(w!==void 0||B.get(t.key)===void 0)&&(e.stopPropagation(),w===void 0?(ue.current=!0,z(null)):w(ln(e)))},children:[c===void 0?/* @__PURE__ */ (0,s.jsx)(Ut,{label:O(`group.ungrouped`),expanded:t.expanded,onToggle:()=>{Oe(t)},rowKey:`workspace:${t.key}`,action:f?{label:O(`actions.newSession`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconNewChatOutlineRegular,{size:16}),onActivate:()=>{C(t.key,!0),n()}}:void 0}):/* @__PURE__ */ (0,s.jsx)(kt,{newShortcut:j.find(e=>e.id===`session.new`),group:t,home:D,t:O,onToggle:()=>{Oe(t)},onCreate:()=>{t.workspaceId!==void 0&&(C(t.key,t.expanded),n(t.workspaceId))},drag:x,actions:t.workspaceId===void 0?void 0:{rename:()=>{
11
+ g(!1),(e===`rename`||e===`delete`)&&(e===`rename`?f.rename():f.delete())},portal:!0,autoFocus:!0,getAnchorRect:_===null?void 0:()=>_,anchor:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:K.iconButton,"aria-label":u(`actions.workspace.aria`,{name:m}),"aria-haspopup":`menu`,"aria-expanded":h,onClick:e=>{e.stopPropagation(),v(null),g(e=>!e)},children:/* @__PURE__ */ (0,s.jsx)(o.IconEllipsisOutlineRegular,{})})}),!d.remote&&/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:u(`actions.newSession`),shortcutKeys:l?.keys,side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:K.iconButton,"aria-keyshortcuts":l?.aria,"aria-label":u(`actions.newSession.aria`,{name:m}),onClick:e=>{e.stopPropagation(),n()},children:/* @__PURE__ */ (0,s.jsx)(o.IconNewChatOutlineRegular,{})})})]})]});return d.createdAt===void 0?x:/* @__PURE__ */ (0,s.jsx)(o.HoverCard,{anchor:x,content:/* @__PURE__ */ (0,s.jsx)(un,{label:d.label,cwd:d.cwd===void 0?void 0:y(d.cwd,c),createdAt:d.createdAt,t:u}),openDelayMs:800,disabled:h,copyText:d.cwd,copyLabel:u(`copy`),copiedLabel:u(`hover.copied`)})}function pn({node:e,now:t,renderSlot:n,t:r}){let i=Pe(e,r).filter(t=>!e.archived||t.state!==`done`&&t.state!==`idle`);return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:K.hoverContent,children:[/* @__PURE__ */ (0,s.jsx)(`div`,{className:K.hoverTitle,children:on(e,r)}),e.cwd&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:K.hoverPath,children:e.cwd}),!e.blank&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:K.hoverTime,children:cn(e.updatedAt,t,r)}),n(`sidebar.session.row.hover`,{sessionId:e.id}),i.map(e=>/* @__PURE__ */ (0,s.jsxs)(`div`,{className:K.hoverStatus,children:[/* @__PURE__ */ (0,s.jsx)(o.StateDot,{state:e.state}),/* @__PURE__ */ (0,s.jsx)(`span`,{children:e.label})]},e.label)),e.archived&&/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q(K.hoverStatus,K.hoverArchived),children:[/* @__PURE__ */ (0,s.jsx)(o.IconArchiveOutlineRegular,{size:16}),/* @__PURE__ */ (0,s.jsx)(`span`,{children:r(`row.archived`)})]})]})}function mn({result:e,currentId:t,onOpen:n,onUnarchive:r,t:i}){let a=e.id===t,c=Pe(e,i),l=c[0];return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q(K.searchResultRow,a&&K.selected,e.archived&&K.archived),role:`treeitem`,"aria-selected":a,"aria-description":e.archived?i(`toast.archivedNotOpenable`):void 0,onClick:()=>{n(e.id)},children:[/* @__PURE__ */ (0,s.jsxs)(`span`,{className:K.searchResultHeading,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.slot}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.searchResultTitle,children:e.title||i(`session.untitled`)}),e.remote&&/* @__PURE__ */ (0,s.jsx)(Vt,{host:e.remote,t:i}),!e.archived&&l.state!==`idle`&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.timeStatus,"data-session-status":l.state,children:/* @__PURE__ */ (0,s.jsx)(Ie,{statuses:c})}),e.archived&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.rowActions,children:/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:i(`actions.unarchive`),side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:K.iconButton,"aria-label":i(`menu.unarchiveSession`),onClick:t=>{t.stopPropagation(),r(e.id)},children:/* @__PURE__ */ (0,s.jsx)(o.IconUnarchiveOutlineRegular,{size:16})})})})]}),/* @__PURE__ */ (0,s.jsxs)(`span`,{className:K.searchResultMeta,children:[/* @__PURE__ */ (0,s.jsxs)(`span`,{className:K.searchResultWorkspace,children:[e.workspace||i(`group.ungrouped`),e.parentTitle!==void 0&&` · ${e.parentTitle||i(`session.untitled`)}`]}),e.snippet!==void 0&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.searchResultSnippet,children:e.snippet})]})]})}function hn({node:e,rowKey:t=`session:${e.id}`,currentId:n,now:r,onOpen:i,onRenameRequest:c,renderSlot:l,onReveal:u,drag:d,showHost:f=!0,t:p}){let m=e,{expansion:h,toggle:g,collapseStyle:_}=Rt(),v=tn(),y=e.tree?.depth??0,b=h[e.id]===!0,x=y===0?d:void 0,S=on(e,p),w=e.id===n,T=Pe(e,p),E=T[0],D=!m.archived&&E.state!==`idle`,O=x!==void 0&&!m.blank&&!m.archived,k=m.blank?void 0:m.reference,A=O||k!==void 0,j=(0,a.useRef)(!1),[M,N]=(0,a.useState)(!1),[ee,P]=(0,a.useState)(null),te=(0,a.useMemo)(()=>[M,N],[M]),F=(0,a.useRef)(null);(0,a.useEffect)(()=>{u!==void 0&&(F.current?.scrollIntoView({block:`nearest`}),u())},[u]);let ne=/* @__PURE__ */ (0,s.jsxs)(`div`,{ref:F,"data-row-key":t,"data-thread-parent":e.tree?.parentId??void 0,"data-thread-depth":y,"data-thread-sortable":String(O),"data-thread-pinned":String(e.pinned),style:{"--dsh-thread-indent":`${Math.min(y,3)*24}px`},className:Q(K.sessionRow,w&&K.selected,M&&K.menuOpen,m.archived&&K.archived,x?.marker===`before`&&K.dropBefore,x?.marker===`after`&&K.dropAfter),role:`treeitem`,"aria-selected":w,"aria-current":w?`page`:void 0,"aria-level":y+1,"aria-expanded":e.tree?.descendantCount?b:void 0,tabIndex:-1,onContextMenu:e=>{m.blank||e.target.closest(`button`)||(e.preventDefault(),P(new DOMRect(e.clientX,e.clientY,0,0)),N(!0))},onKeyDown:t=>{t.target!==t.currentTarget||m.blank||(j.current=!1,t.key===`ContextMenu`||t.shiftKey&&t.key===`F10`?(t.preventDefault(),P(null),N(!0)):t.key===`F2`&&!m.archived&&(t.preventDefault(),c(e.id,m.title)))},"aria-description":m.archived?p(`toast.archivedNotOpenable`):void 0,onPointerDown:()=>{j.current=!1},onClick:()=>{j.current||i(e.id)},draggable:A,onDragStart:A?t=>{j.current=!0,t.dataTransfer.effectAllowed=k===void 0?`move`:O?`copyMove`:`copy`,t.dataTransfer.setData(`text/plain`,k===void 0?e.id:C(k).clipboardText),k!==void 0&&t.dataTransfer.setData(`application/x-codexhost-thread-reference`,JSON.stringify(k)),O&&x?.start()}:void 0,onDragEnd:A?e=>x?.end(e.dataTransfer.dropEffect===`copy`):void 0,onDragOver:x===void 0?void 0:e=>{x.active&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,x.hover(dn(e)))},onDrop:x===void 0?void 0:e=>{x.active&&(e.preventDefault(),x.drop(dn(e)))},children:[/* @__PURE__ */ (0,s.jsx)(`div`,{className:K.sessionMain,children:/* @__PURE__ */ (0,s.jsxs)(Bt,{identityLabel:e.tree?.descendantCount?!b&&_===`ring`?p(`threadTree.expandSummary`,{title:S,summary:Kt(e.tree.descendantCount,e.tree.activity,p)}):p(b?`threadTree.collapse`:`threadTree.expand`,{n:e.tree.descendantCount}):void 0,identityExpanded:e.tree?.descendantCount?b:void 0,identityControls:v,identity:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[l(`sidebar.session.row.identity`,{sessionId:e.id}),!b&&_===`ring`&&!!e.tree?.descendantCount&&/* @__PURE__ */ (0,s.jsx)(Xt,{activity:e.tree.activity})]}),ambient:!m.archived&&!m.blank&&!D&&l(`sidebar.session.row.leading`,{sessionId:e.id}),title:S,onIdentityClick:e.tree?.descendantCount?t=>{t.stopPropagation(),g(e.id,!b,v)}:void 0,onTitleDoubleClick:m.blank?void 0:t=>{t.stopPropagation(),c(e.id,m.title)},children:[f&&m.remote&&/* @__PURE__ */ (0,s.jsx)(Vt,{host:m.remote,t:p}),/* @__PURE__ */ (0,s.jsxs)(`span`,{className:K.trailing,children:[!m.blank&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:Q(K.time,D&&K.timeStatus),"data-session-status":D?E.state:void 0,children:D?/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(Ie,{statuses:T}),E.trailingLabel!==void 0&&/* @__PURE__ */ (0,s.jsx)(`span`,{"aria-hidden":`true`,children:E.trailingLabel})]}):sn(m.updatedAt,r,p)}),!m.blank&&/* @__PURE__ */ (0,s.jsxs)(`span`,{className:K.rowActions,onClick:e=>{e.stopPropagation()},children:[/* @__PURE__ */ (0,s.jsx)(o.Menu,{open:M,onClose:()=>{N(!1)},portal:!0,autoFocus:!0,phoneSidebarTitle:S,phoneSidebarFooterBackLabel:p(`session.backToList`),phoneSidebarDetails:/* @__PURE__ */ (0,s.jsx)(`div`,{className:K.phoneDetails,children:/* @__PURE__ */ (0,s.jsx)(pn,{node:e,now:r,renderSlot:l,t:p})}),getAnchorRect:ee===null?void 0:()=>ee,anchor:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:K.iconButton,"aria-label":p(`actions.session.aria`,{name:S}),"aria-haspopup":`menu`,"aria-expanded":M,onClick:()=>{P(null),N(e=>!e)},children:/* @__PURE__ */ (0,s.jsx)(o.IconEllipsisOutlineRegular,{})}),children:l(`sidebar.workspaces.session.menu.item`,{sessionId:e.id,displayTitle:m.title,threadTreeChild:y>0},{hookContext:te})}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:K.quickActions,children:l(`sidebar.workspaces.session.row.action`,{sessionId:e.id,displayTitle:m.title,threadTreeChild:y>0})})]})]})]})}),!b&&_===`summary`&&/* @__PURE__ */ (0,s.jsx)(an,{node:e,title:S,toggle:()=>g(e.id,!0,v),t:p})]});return/* @__PURE__ */ (0,s.jsx)(o.HoverCard,{anchor:ne,content:/* @__PURE__ */ (0,s.jsx)(pn,{node:e,now:r,renderSlot:l,t:p}),openDelayMs:800,disabled:M||x?.active===!0,copyText:m.blank||m.title===``?void 0:m.title,copyLabel:p(`copy`),copiedLabel:p(`hover.copied`)})}let gn=`@deepseek-ai/dsh-client-ui-workspace/AnimatedRows.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(gn)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=gn,e.textContent=`.Jek-Ha_exits{contain:strict;pointer-events:none;position:absolute;inset:0;overflow:clip}`,document.head.appendChild(e)}var _n={exits:`Jek-Ha_exits`};function vn(e){return[...e.querySelectorAll(`[data-row-key]`)].filter(e=>e.offsetHeight>0&&!e.closest(`[inert]`))}function yn(e){if(!e)return;let t=vn(e),n=document.activeElement?.closest(`[data-row-key]`),r=t.find(e=>e===n)??t.find(e=>e.getAttribute(`aria-selected`)===`true`)??t[0];for(let e of t)e.tabIndex=e===r?0:-1}function bn(e){if(e.defaultPrevented||e.nativeEvent.isComposing||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=e.currentTarget,n=e.target;if(!(n instanceof HTMLElement)||!n.matches(`[data-row-key]`)||!t.contains(n))return;let r=vn(t),i=r.indexOf(n);if(i<0)return;let a=n.matches(`[role="treeitem"][aria-expanded]`),o=n.querySelector(`[data-thread-icon-toggle]`),s=()=>{o?o.click():n.click()},c;switch(e.key){case`ArrowDown`:c=r[i+1];break;case`ArrowUp`:c=r[i-1];break;case`Home`:c=r[0];break;case`End`:c=r.at(-1);break;case`ArrowRight`:a&&n.getAttribute(`aria-expanded`)===`false`?s():a&&(c=r[i+1]);break;case`ArrowLeft`:if(a&&n.getAttribute(`aria-expanded`)===`true`)s();else{let e=n.dataset.threadParent;if(e!==void 0){let t=n.dataset.rowKey?.startsWith(`recent:`)?`recent:`:`session:`;c=r.find(n=>n.dataset.rowKey===`${t}${e}`);break}let t=n.closest(`[data-sidebar-group]`),i=t?.querySelector(`[data-row-key^="workspace:"]`);i===n&&(t=t?.parentElement?.closest(`[data-sidebar-group]`)??null,i=t?.querySelector(`[data-row-key^="workspace:"]`)),c=i??void 0}break;case`Enter`:case` `:n.click();break;default:return}e.preventDefault(),c&&(c.focus({preventScroll:!0}),c.scrollIntoView({block:`nearest`}),yn(t))}function xn(e,t){return e.rowKeys.length===t.rowKeys.length&&e.rowKeys.every((e,n)=>e===t.rowKeys[n])}function Sn(e,t){return e.bottom>t.top&&e.top<t.bottom&&e.right>t.left&&e.left<t.right}var Cn=class extends a.Component{armed=!1;list=(0,a.createRef)();overlay=(0,a.createRef)();movements=/* @__PURE__ */ new Map;exits=/* @__PURE__ */ new Map;componentDidMount(){yn(this.list.current)}getSnapshotBeforeUpdate(e){let t=this.list.current;if(!this.armed||xn(e,this.props)||e.resetKey!==this.props.resetKey||!e.ready||!this.props.ready||t===null||typeof t.animate!=`function`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return null;let n=t.getBoundingClientRect(),r=this.readPositions(),i=new Set(this.props.rowKeys),a=/* @__PURE__ */ new Map;for(let[e,t]of r){if(i.has(e)||!Sn(t.rect,n))continue;let r=t.element.cloneNode(!0);r.removeAttribute(`data-row-key`),r.inert=!0,r.style.setProperty(`--dsh-workspace-indent`,getComputedStyle(t.element).getPropertyValue(`--dsh-workspace-indent`)),a.set(e,{...t,element:r})}return{positions:r,removed:a}}componentDidUpdate(e,t,n){if(yn(this.list.current),n===null){(!xn(e,this.props)||e.resetKey!==this.props.resetKey||e.ready!==this.props.ready)&&this.clear();return}this.cancelMovements();let r=this.list.current,i=this.overlay.current,a=r.getBoundingClientRect(),o=i.getBoundingClientRect(),s=this.readPositions();for(let[e,t]of s){this.removeExit(e);let r=n.positions.get(e);if(!Sn(t.rect,a)&&(r===void 0||!Sn(r.rect,a)))continue;if(r===void 0){this.move(t.element,[{opacity:0},{opacity:1}],100);continue}let i=r.rect.left-t.rect.left,o=r.rect.top-t.rect.top;(i!==0||o!==0||r.opacity!==1)&&this.move(t.element,[{transform:`translate(${String(i)}px, ${String(o)}px)`,opacity:r.opacity},{transform:`translate(0, 0)`,opacity:1}],200)}for(let[e,t]of n.removed){let{element:n}=t;this.removeExit(e),Object.assign(n.style,{position:`absolute`,margin:`0`,transform:`none`,boxSizing:`border-box`,left:`${String(t.rect.left-o.left)}px`,top:`${String(t.rect.top-o.top)}px`,width:`${String(t.rect.width)}px`,height:`${String(t.rect.height)}px`}),i.append(n);let r=n.animate([{opacity:t.opacity},{opacity:0}],{duration:100,easing:`ease-out`,fill:`forwards`});this.exits.set(e,{element:n,animation:r}),r.onfinish=()=>{this.removeExit(e)}}}componentWillUnmount(){this.clear()}readPositions(){let e=this.list.current.querySelectorAll(`[data-row-key]`);return new Map(Array.from(e,e=>[e.dataset.rowKey,{element:e,rect:e.getBoundingClientRect(),opacity:this.movements.has(e)?Number(getComputedStyle(e).opacity):1}]))}move(e,t,n){let r=e.animate(t,{duration:n,easing:`ease-out`});this.movements.set(e,r),r.onfinish=()=>{this.movements.delete(e),r.cancel()}}cancelMovements(){for(let e of this.movements.values())e.onfinish=null,e.cancel();this.movements.clear()}removeExit(e){let t=this.exits.get(e);t!==void 0&&(t.animation.onfinish=null,t.animation.cancel(),t.element.remove(),this.exits.delete(e))}clear(){this.cancelMovements();for(let e of this.exits.keys())this.removeExit(e)}render(){return/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(`div`,{ref:this.list,className:this.props.className,role:`tree`,"aria-label":this.props.label,onKeyDown:bn,onFocusCapture:()=>yn(this.list.current),onPointerDownCapture:()=>{this.armed=!0},onKeyDownCapture:()=>{this.armed=!0},children:this.props.children}),/* @__PURE__ */ (0,s.jsx)(`div`,{ref:this.overlay,className:_n.exits,"aria-hidden":`true`})]})}};let wn=`@deepseek-ai/dsh-client-ui-workspace/SectionHeading.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(wn)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=wn,e.textContent=`.Z54rEq_heading{border-radius:var(--dsw-radius-sm);min-height:30px;color:var(--dsw-alias-label-tertiary);align-items:center;gap:6px;padding:0 8px;font-size:14px;font-weight:500;line-height:21px;display:flex}.Z54rEq_heading[data-row-key]{cursor:pointer}.Z54rEq_heading[data-row-key]:hover{background:var(--dsw-alias-interactive-bg-hover)}.Z54rEq_heading[data-row-key]:focus-visible,.Z54rEq_action:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.Z54rEq_title{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.Z54rEq_chevron,.Z54rEq_collapsed{flex-shrink:0}.Z54rEq_collapsed{transform:rotate(-90deg)}.Z54rEq_action{border-radius:var(--dsw-radius-sm);width:24px;height:24px;color:inherit;cursor:pointer;background:0 0;border:none;place-items:center;margin-inline-start:auto;padding:0;display:grid}.Z54rEq_action:hover{background:var(--dsw-alias-interactive-bg-hover)}@media (pointer:coarse){.Z54rEq_heading{min-height:44px}.Z54rEq_action{width:44px;height:44px}}`,document.head.appendChild(e)}var Tn={action:`Z54rEq_action`,chevron:`Z54rEq_chevron`,collapsed:`Z54rEq_collapsed`,heading:`Z54rEq_heading`,title:`Z54rEq_title`};function En({label:e,icon:t,expanded:n,onToggle:r,rowKey:i,action:a}){let c=n!==void 0&&r!==void 0&&i!==void 0,l=/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[t,/* @__PURE__ */ (0,s.jsx)(`span`,{className:Tn.title,children:e}),c&&/* @__PURE__ */ (0,s.jsx)(o.IconChevronDownOutlineRegular,{className:n?Tn.chevron:Tn.collapsed,size:12}),a!==void 0&&/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:a.label,portal:!0,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:Tn.action,"aria-label":a.label,onClick:e=>{e.stopPropagation(),a.onActivate()},children:a.icon})})]});return c?/* @__PURE__ */ (0,s.jsx)(`div`,{className:Tn.heading,role:`treeitem`,tabIndex:-1,"data-row-key":i,"aria-label":e,"aria-expanded":n,onClick:r,children:l}):/* @__PURE__ */ (0,s.jsx)(`div`,{className:Tn.heading,children:l})}let Dn=`@deepseek-ai/dsh-client-ui-workspace/PinnedSection.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Dn)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Dn,e.textContent=`.t4p6JG_section{margin-bottom:8px}.t4p6JG_section>*+[data-thread-branch]{margin-top:2px}`,document.head.appendChild(e)}var On={section:`t4p6JG_section`};function kn({rows:e,currentId:t,onOpen:n,onRenameRequest:r,renderSlot:i,t:a,revealSessionId:c,onSessionRevealed:l,expanded:u,onToggle:d}){return e.length===0?null:/* @__PURE__ */ (0,s.jsxs)(`div`,{role:`group`,"aria-label":a(`section.pinned`),className:On.section,"data-sidebar-pinned":!0,children:[/* @__PURE__ */ (0,s.jsx)(En,{label:a(`section.pinned`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconPinOutlineRegular,{size:14}),expanded:u,onToggle:d,rowKey:`section:${ue}`}),u&&/* @__PURE__ */ (0,s.jsx)(nn,{roots:e,children:e=>/* @__PURE__ */ (0,s.jsx)(hn,{node:e,currentId:t,now:Date.now(),onOpen:n,onRenameRequest:r,renderSlot:i,onReveal:e.id===c?()=>l(e.id):void 0,t:a},e.id)})]})}let An=`@deepseek-ai/dsh-client-ui-workspace/WorkspaceBrowser.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(An)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=An,e.textContent=`._14DcuW_root{--dsh-session-list-edge-inset:var(--dsh-sidebar-inline-padding);--dsh-session-list-scrollbar-width:5px;--dsh-session-list-scrollbar-offset:2px;box-sizing:border-box;min-height:0;padding-right:var(--dsh-session-list-edge-inset);flex-direction:column;flex:1;display:flex}[data-phone-drawer] ._14DcuW_root{--dsh-session-list-scrollbar-width:0px}[data-phone-drawer] ._14DcuW_list{scrollbar-gutter:auto}._14DcuW_root._14DcuW_rail{padding-right:0}._14DcuW_iconButton{border-radius:var(--dsw-radius-sm);cursor:pointer;width:28px;height:28px;color:var(--dsw-alias-label-secondary);background:0 0;border:none;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}._14DcuW_iconButton:focus-visible,._14DcuW_searchButton:focus-visible,._14DcuW_clearButton:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}._14DcuW_iconButton:hover{background:var(--dsw-alias-interactive-bg-hover)}._14DcuW_viewOptionsMenu{min-width:200px}._14DcuW_sectionHeader{box-sizing:border-box;height:36px;color:var(--dsw-alias-label-tertiary);border-radius:6px;flex:none;justify-content:flex-end;align-items:center;gap:4px;margin-bottom:6px;padding-left:4px;display:flex;overflow:hidden}._14DcuW_root:not(._14DcuW_rail) ._14DcuW_sectionHeader{margin-top:2px;margin-right:-4px}._14DcuW_sectionLabel{white-space:nowrap;opacity:1;visibility:visible;min-width:0;max-width:45%;transition:max-width .18s var(--ds-ease-in-out), margin-right .18s var(--ds-ease-in-out), opacity .12s var(--ds-ease-in-out), transform .18s var(--ds-ease-in-out), visibility 0s linear;flex:none;font-size:14px;font-weight:500;line-height:21px;overflow:hidden}._14DcuW_sectionLabelHidden{opacity:0;visibility:hidden;max-width:0;margin-right:-4px;transition-delay:0s,0s,0s,0s,.18s;transform:translate(-4px)}._14DcuW_searchSlot{box-sizing:border-box;min-width:0;max-width:28px;transition:max-width .18s var(--ds-ease-in-out), padding-left .18s var(--ds-ease-in-out);flex:1;align-items:center;margin-left:auto;padding-left:0;display:flex}._14DcuW_searchSlotExpanded{max-width:100%;padding-left:0}._14DcuW_headerActions{opacity:1;visibility:visible;max-width:60px;transition:max-width .18s var(--ds-ease-in-out), opacity .12s var(--ds-ease-in-out), transform .18s var(--ds-ease-in-out), visibility 0s linear;flex:none;align-items:center;gap:4px;display:flex;overflow:hidden}._14DcuW_headerActionsHidden{opacity:0;visibility:hidden;pointer-events:none;max-width:0;transition-delay:0s,0s,0s,.18s;transform:translate(4px)}._14DcuW_search{box-sizing:border-box;border-radius:var(--dsw-radius-sm);cursor:text;width:100%;height:28px;color:var(--dsw-alias-label-secondary);transition:width .18s var(--ds-ease-in-out), padding .18s var(--ds-ease-in-out), border-color .18s var(--ds-ease-in-out), background-color .18s var(--ds-ease-in-out);background:0 0;border:none;flex:none;align-items:center;gap:0;margin:0;padding:0;display:flex;overflow:hidden}._14DcuW_searchExpanded{border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);width:calc(100% + 4px);height:30px;color:var(--dsw-alias-label-caption);background:0 0;margin-inline:-2px;padding:0 4px 0 0}._14DcuW_searchButton{border-radius:var(--dsw-radius-sm);cursor:pointer;width:28px;height:28px;color:inherit;background:0 0;border:none;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}._14DcuW_searchExpanded ._14DcuW_searchButton{width:28px;height:30px}._14DcuW_searchButton:hover{background:var(--dsw-alias-interactive-bg-hover)}._14DcuW_searchExpanded ._14DcuW_searchButton:hover{background:0 0}._14DcuW_searchInput{opacity:0;pointer-events:none;width:0;min-width:0;color:var(--dsw-alias-label-primary);transition:opacity .12s var(--ds-ease-in-out);background:0 0;border:none;outline:none;flex:1;font-size:13px;line-height:18px}._14DcuW_searchExpanded ._14DcuW_searchInput{opacity:1;pointer-events:auto;margin-left:-2px}._14DcuW_searchInput::placeholder{color:var(--dsw-alias-label-tertiary)}._14DcuW_clearButton{border-radius:var(--dsw-radius-sm);cursor:pointer;width:24px;height:24px;color:var(--dsw-alias-label-secondary);background:0 0;border:none;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}._14DcuW_clearButton:hover{background:var(--dsw-alias-interactive-bg-hover)}._14DcuW_rail ._14DcuW_sectionHeader{justify-content:flex-start;gap:0;margin-bottom:12px;padding-left:0}._14DcuW_rail ._14DcuW_headerActions{max-width:none}._14DcuW_rail ._14DcuW_iconButton{border-radius:var(--dsw-radius-md);width:36px;height:36px;color:var(--dsw-alias-label-primary)}._14DcuW_rail ._14DcuW_search{border-radius:var(--dsw-radius-md);background:0 0;border-color:#0000;gap:0;width:36px;height:36px;margin:0 0 12px;padding:0}._14DcuW_rail ._14DcuW_searchButton{border-radius:var(--dsw-radius-md);width:36px;height:36px;color:var(--dsw-alias-label-primary)}._14DcuW_rail ._14DcuW_searchButton:hover{background:var(--dsw-alias-interactive-bg-hover)}._14DcuW_listArea{min-height:0;margin-left:-4px;margin-right:calc(-1 * var(--dsh-session-list-edge-inset));flex-direction:column;flex:1;padding-left:4px;display:flex;overflow:visible}._14DcuW_rail ._14DcuW_listArea{margin-left:0;margin-right:0;padding-left:0}._14DcuW_treeBody{flex-direction:column;flex:1;min-height:0;display:flex;position:relative}._14DcuW_fade{left:0;right:var(--dsh-session-list-edge-inset);background:linear-gradient(to bottom, transparent, var(--dsw-specific-sidebar-fill));pointer-events:none;height:24px;position:absolute;bottom:0}[data-platform=darwin] ._14DcuW_fade,[data-phone-drawer] ._14DcuW_fade{display:none}._14DcuW_wide{animation:_14DcuW_wide-in .2s var(--ds-ease-in-out)}@keyframes _14DcuW_wide-in{0%{opacity:0}}._14DcuW_list{overscroll-behavior-y:contain;min-height:0;margin-left:-4px;margin-right:var(--dsh-session-list-scrollbar-offset);padding-left:4px;padding-right:calc(var(--dsh-session-list-edge-inset) - var(--dsh-session-list-scrollbar-width) - var(--dsh-session-list-scrollbar-offset));scrollbar-gutter:stable;flex:1;padding-bottom:16px;scroll-padding-block:8px;overflow-y:auto}._14DcuW_flatList>*+*,._14DcuW_searchTree>[role=treeitem]+[role=treeitem],._14DcuW_groupSection>*+*,._14DcuW_groupSessions>*+*{margin-top:2px}._14DcuW_searchStatus{color:var(--dsw-alias-label-tertiary);padding:10px 12px;font-size:12px;line-height:18px}._14DcuW_skeletonRow{box-sizing:border-box;align-items:flex-start;gap:8px;min-height:48px;padding:6px 8px 7px;display:flex}._14DcuW_skeletonDot{corner-shape:round;border-radius:50%;flex:none;width:16px;height:16px}._14DcuW_skeletonBars{flex-direction:column;flex:1;gap:6px;min-width:0;display:flex}._14DcuW_skeletonDot,._14DcuW_skeletonBar{background:var(--dsw-alias-bg-skeleton);animation:2s cubic-bezier(.36,0,.64,1) infinite _14DcuW_search-skeleton}._14DcuW_skeletonBar{border-radius:var(--dsw-radius-xs);width:65%;height:16px}._14DcuW_skeletonBarWide{width:90%;height:13px}@keyframes _14DcuW_search-skeleton{0%{opacity:1}40%{opacity:.6}80%,to{opacity:1}}._14DcuW_groupSection{position:relative}._14DcuW_groupSection+._14DcuW_groupSection{margin-top:4px}._14DcuW_listTopDropIndicator,._14DcuW_workspaceDropBefore:before,._14DcuW_workspaceDropAfter:after{content:"";z-index:1;background:linear-gradient(55deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 5px 7px no-repeat, linear-gradient(125deg, transparent calc(50% - 1px), var(--dsw-alias-state-business-primary) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) 0 5px / 5px 7px no-repeat, linear-gradient(var(--dsw-alias-state-business-primary) 0 0) 4px 5px / calc(100% - 4px) 2px no-repeat;pointer-events:none;height:12px;position:absolute;left:0;right:0}._14DcuW_listTopDropIndicator{top:-8px;left:0;right:var(--dsh-session-list-edge-inset)}._14DcuW_listTopDropActive>._14DcuW_workspaceDropBefore:first-child:before{display:none}._14DcuW_workspaceDropBefore:before{top:-8px}._14DcuW_workspaceDropAfter:after{bottom:-8px}._14DcuW_sessionOverflowButton{width:100%;height:32px;padding:0 12px 0 calc(32px + var(--dsh-workspace-indent,0px));cursor:pointer;text-align:left;color:var(--dsw-alias-label-tertiary);background:0 0;border:none;border-radius:6px;font-size:12px}._14DcuW_sessionOverflowButton[data-row-key=overflow\\:workspaces]{padding-inline-start:8px}._14DcuW_groupSessions>._14DcuW_sessionOverflowButton{margin-top:0;padding-inline-start:calc(8px + var(--dsh-workspace-indent,0px))}._14DcuW_sessionOverflowButton:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}._14DcuW_sessionOverflowButton:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}@media (hover:none),(pointer:coarse){._14DcuW_sessionOverflowButton,._14DcuW_root:not(._14DcuW_rail) ._14DcuW_iconButton{min-height:44px}._14DcuW_root:not(._14DcuW_rail) ._14DcuW_sectionHeader{height:44px}}._14DcuW_empty{color:var(--dsw-alias-label-tertiary);padding:16px 12px;font-size:13px}._14DcuW_emptyState{color:var(--dsw-alias-label-tertiary);flex-direction:column;align-items:center;gap:8px;margin-top:80px;padding:0 12px;font-size:13px;line-height:20px;display:flex}._14DcuW_emptyState>svg{color:var(--dsw-alias-label-caption);margin-bottom:4px}._14DcuW_emptyAction{cursor:pointer;color:var(--dsw-alias-link);background:0 0;border:none;padding:0;font-size:13px;line-height:20px}._14DcuW_renameInput{box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-lg);width:100%;height:44px;color:var(--dsw-alias-label-primary);background:0 0;outline:none;padding:7px 14px;font-size:14px;font-weight:400;line-height:22px}._14DcuW_renameInput:disabled{color:var(--dsw-alias-label-dimmed)}._14DcuW_renameError{color:var(--dsw-alias-state-error-primary);margin-top:8px;font-size:12px;line-height:18px}._14DcuW_deleteAction:not(:disabled){color:var(--dsw-alias-state-error-primary)}._14DcuW_deleteStatus{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}._14DcuW_archiveActivity{color:var(--dsw-alias-label-primary);margin:0 0 8px;padding-left:18px;font-size:13px;line-height:20px}._14DcuW_archiveActivity li{overflow-wrap:anywhere}@media (prefers-reduced-motion:reduce){._14DcuW_wide,._14DcuW_skeletonDot,._14DcuW_skeletonBar{animation:none}._14DcuW_search,._14DcuW_sectionLabel,._14DcuW_searchSlot,._14DcuW_searchInput,._14DcuW_headerActions{transition:none}}`,document.head.appendChild(e)}var $={archiveActivity:`_14DcuW_archiveActivity`,clearButton:`_14DcuW_clearButton`,deleteAction:`_14DcuW_deleteAction`,deleteStatus:`_14DcuW_deleteStatus`,empty:`_14DcuW_empty`,emptyAction:`_14DcuW_emptyAction`,emptyState:`_14DcuW_emptyState`,fade:`_14DcuW_fade`,flatList:`_14DcuW_flatList`,groupSection:`_14DcuW_groupSection`,groupSessions:`_14DcuW_groupSessions`,headerActions:`_14DcuW_headerActions`,headerActionsHidden:`_14DcuW_headerActionsHidden`,iconButton:`_14DcuW_iconButton`,list:`_14DcuW_list`,listArea:`_14DcuW_listArea`,listTopDropActive:`_14DcuW_listTopDropActive`,listTopDropIndicator:`_14DcuW_listTopDropIndicator`,rail:`_14DcuW_rail`,renameError:`_14DcuW_renameError`,renameInput:`_14DcuW_renameInput`,root:`_14DcuW_root`,search:`_14DcuW_search`,"search-skeleton":`_14DcuW_search-skeleton`,searchButton:`_14DcuW_searchButton`,searchExpanded:`_14DcuW_searchExpanded`,searchInput:`_14DcuW_searchInput`,searchSlot:`_14DcuW_searchSlot`,searchSlotExpanded:`_14DcuW_searchSlotExpanded`,searchStatus:`_14DcuW_searchStatus`,searchTree:`_14DcuW_searchTree`,sectionHeader:`_14DcuW_sectionHeader`,sectionLabel:`_14DcuW_sectionLabel`,sectionLabelHidden:`_14DcuW_sectionLabelHidden`,sessionOverflowButton:`_14DcuW_sessionOverflowButton`,skeletonBar:`_14DcuW_skeletonBar`,skeletonBarWide:`_14DcuW_skeletonBarWide`,skeletonBars:`_14DcuW_skeletonBars`,skeletonDot:`_14DcuW_skeletonDot`,skeletonRow:`_14DcuW_skeletonRow`,treeBody:`_14DcuW_treeBody`,viewOptionsMenu:`_14DcuW_viewOptionsMenu`,wide:`_14DcuW_wide`,"wide-in":`_14DcuW_wide-in`,workspaceDropAfter:`_14DcuW_workspaceDropAfter`,workspaceDropBefore:`_14DcuW_workspaceDropBefore`};function jn({list:e,refreshSessions:t,loadMoreSessions:n,t:r}){return e.listError?/* @__PURE__ */ (0,s.jsxs)(`div`,{role:`alert`,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{children:e.listError}),/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:$.sessionOverflowButton,disabled:e.loading,onClick:e.listErrorPage===`more`?n:t,children:r(`sessions.retry`)})]}):null}function Mn(e,t,n,r){let i=0,a=e.filter(e=>e.blank||e.pinned||e.running||e.runningSubagentCount>0||e.pendingInteraction!==void 0||e.tree?.activity.running||e.tree?.activity.pendingInteraction?!0:i++<t||e.id===n||e.id===r||e.tree?.descendantIds.some(e=>e===n||e===r)===!0);return{rows:a,hiddenCount:e.length-a.length}}function Nn(e,t,n){let r=e.filter((e,r)=>r<t||n.has(e.key));return{rows:r,hiddenCount:e.length-r.length}}function Pn({rowKey:e,hiddenCount:t,hasMore:n,loading:r,expanded:i,expand:a,collapse:o,loadMoreSessions:c,t:l}){if(t===0&&!n&&!o)return null;let u=t===0&&n&&r;return/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,"data-row-key":e,className:$.sessionOverflowButton,"aria-expanded":i,disabled:u,onClick:()=>{t>0?a():n?(a(),c()):o?.()},children:u?l(`sessions.loading`):t>0?l(`sessions.expand`,{n:Math.min(10,t)}):l(n?`sessions.expandMore`:`sessions.collapse`)})}let Fn=`@deepseek-ai/dsh-client-ui-workspace/WorkspacePicker.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Fn)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Fn,e.textContent=`.s4nt4G_modalAction{min-width:72px}.s4nt4G_modalError,.s4nt4G_menuStatus{margin-top:8px;font-size:12px;line-height:18px}.s4nt4G_modalError{color:var(--dsw-alias-state-error-primary)}.s4nt4G_menuStatus{color:var(--dsw-alias-label-secondary)}`,document.head.appendChild(e)}var In={menuStatus:`s4nt4G_menuStatus`,modalAction:`s4nt4G_modalAction`,modalError:`s4nt4G_modalError`};let Ln=`::add-workspace`,Rn=`::no-workspace`;function zn({t:e,open:t,anchorRef:n,useWorkspaces:r,createWorkspace:i,useDirectoryFlow:c,renderDirectoryFlow:l,onPick:u,onPickNone:d,onClose:f,addOnly:p=!1,onBusyChange:m,side:h=`bottom`,selectedId:g}){let _=r(e=>e),v=_.items,y=(0,a.useCallback)(()=>n?.current?.getBoundingClientRect()??null,[n]),[b,x]=(0,a.useState)(!1),[S,C]=(0,a.useState)(null),[w,T]=(0,a.useState)(!1),E=(0,o.usePhoneSidebar)(),D=(0,a.useRef)(!1),[O,k]=(0,a.useState)(!1),A=w||O;(0,a.useEffect)(()=>{m?.(A)},[A,m]);let j=c(e=>e);(0,a.useEffect)(()=>{w&&!j&&T(!1)},[w,j]);let M=j?[{id:Ln,label:e(`menu.addWorkspace`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconPlusOutlineRegular,{size:16}),disabled:A}]:[],N=!p&&v.length>0,ee=d!==void 0&&!p,P=ee?[{id:Rn,label:e(`menu.noWorkspace`),disabled:A}]:[],te=N?[...P,...v.map(t=>({id:t.workspaceId,label:Ft(t.title,e(`workspace.defaultName`)),icon:/* @__PURE__ */ (0,s.jsx)(o.IconFolderCloseRegular,{size:16}),disabled:A}))]:[...P,...M],F=te.length===0,ne=()=>{x(!1),C(null)},re=e=>i({path:e}).then(e=>{T(!1),u(e.workspaceId)}).catch(e=>{C(e instanceof Error?e.message:String(e)),T(!1),x(!0)}),I=(0,a.useCallback)(()=>{D.current=E?.open===!0,f(),x(!1),C(null),T(!0)},[f,E?.open]),ie=p||_.phase===`ready`,L=!ee&&!N&&ie&&M.length===1;(0,a.useEffect)(()=>{t&&L&&!A&&I()},[t,L,A,I]);let R={open:w,busy:O,onPicked:e=>{k(!0),re(e).finally(()=>{k(!1)})},onCancel:()=>{T(!1)},onError:e=>{T(!1),C(e),x(!0)}},z=e=>{e===Rn?d?.():e===Ln?I():u(e)};return/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.Menu,{open:t&&!L&&!F,anchor:null,items:te,...N?{footer:M}:{},selectedId:g??(ee?Rn:void 0),onSelect:z,onClose:f,side:h,portal:!0,getAnchorRect:y}),t&&!L&&!F&&_.phase===`pending`&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:In.menuStatus,role:`status`,children:e(`picker.loading`)}),l(R),/* @__PURE__ */ (0,s.jsx)(o.Modal,{phoneSidebar:!0,phoneSidebarOrigin:D.current,open:b,onClose:ne,closeLabel:e(`close`),title:e(`folderError.title`),footer:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,className:In.modalAction,onClick:ne,children:e(`cancel`)}),/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`primary`,className:In.modalAction,disabled:!j,onClick:I,children:e(`folderError.retry`)})]}),children:/* @__PURE__ */ (0,s.jsx)(`div`,{className:In.modalError,role:`alert`,children:S})})]})}function Bn({open:e,anchorRef:t,useWorkspaces:n,selectedId:r,onPick:i,onClose:a,createWorkspace:o,useDirectoryFlow:c,renderSlot:l,t:u}){let d=n(e=>e.canStartProjectless);return/* @__PURE__ */ (0,s.jsx)(zn,{t:u,open:e,anchorRef:t,useWorkspaces:n,createWorkspace:o,useDirectoryFlow:c,renderDirectoryFlow:e=>l(`conversation.hero.workspace.directoryFlow`,e),selectedId:r,onPick:i,...d?{onPickNone:()=>i(null)}:{},onClose:a})}function Vn(e){let t=e.replaceAll(`\0`,``);if(t.length<=500)return t;let n=500,r=t.charCodeAt(n-1),i=t.charCodeAt(n);return r>=55296&&r<=56319&&i>=56320&&i<=57343&&n--,t.slice(0,n)}function Hn(e){(0,a.useEffect)(()=>{if(!e)return;let t=e=>{e.defaultPrevented||(e.preventDefault(),e.dataTransfer!==null&&(e.dataTransfer.dropEffect=`move`))},n=e=>{e.preventDefault()};return document.addEventListener(`dragover`,t),document.addEventListener(`drop`,n),()=>{document.removeEventListener(`dragover`,t),document.removeEventListener(`drop`,n)}},[e])}function Un({groupBy:e,orderBy:t,archivedFilter:n,onGroupPick:r,onOrderPick:i,onArchivedFilterPick:c,t:l}){let[u,d]=(0,a.useState)(!1),f=(0,a.useRef)(null),p=(0,o.usePhoneSidebar)(),{collapseStyle:m,setCollapseStyle:h}=Rt(),{busy:g,failed:_,save:v}=Et(h);return/* @__PURE__ */ (0,s.jsx)(o.Menu,{phoneSidebarTitle:l(`viewOptions.label`),open:u,onClose:()=>{d(!1)},items:[{type:`label`,id:`group-by`,text:l(`groupBy.label`)},{id:`workspace`,label:l(`groupBy.workspace`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconFolderCloseRegular,{})},{id:`workspace-tree`,label:l(`groupBy.workspaceTree`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconWorkspaceTreeOutlineRegular,{})},{id:`flat`,label:l(`groupBy.flat`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconFlatListOutlineRegular,{})},{type:`separator`,id:`order-by-separator`},{type:`label`,id:`order-by`,text:l(`orderBy.label`)},{id:`manual`,label:l(`orderBy.manual`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconChevronsUpDownOutlineRegular,{})},{id:`updated`,label:l(`orderBy.updated`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconClockOutlineRegular,{})},{type:`separator`,id:`archived-filter-separator`},{type:`label`,id:`filter-by`,text:l(`filterBy.label`)},{id:`hide-archived`,label:l(`viewOptions.hideArchived`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconArchiveOffOutlineRegular,{})},{id:`show-archived`,label:l(`viewOptions.showArchived`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconQueueOutlineRegular,{})},{id:`only-archived`,label:l(`viewOptions.onlyArchived`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconArchiveCheckOutlineRegular,{})},{type:`separator`,id:`thread-tree-style-separator`},{type:`label`,id:`thread-tree-style`,text:l(`threadTree.style.title`)},{id:`summary`,label:l(`threadTree.style.summary`),disabled:g},{id:`ring`,label:l(`threadTree.style.ring`),disabled:g}],selectedIds:[e,t,{default:`hide-archived`,show:`show-archived`,only:`only-archived`}[n],m],onSelect:e=>{e===`summary`||e===`ring`?v(e).then(e=>{e&&(d(!1),f.current&&(0,o.focusWithoutRing)(f.current))}):(e===`workspace`||e===`workspace-tree`||e===`flat`?r(e):e===`manual`||e===`updated`?i(e):e===`hide-archived`?c(`default`):e===`show-archived`?c(`show`):e===`only-archived`&&c(`only`),d(!1))},align:`end`,dense:!0,listClassName:$.viewOptionsMenu,portal:!0,anchor:/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:l(`viewOptions.label`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,ref:f,className:Q($.iconButton,$.wide),"aria-label":l(`viewOptions.label`),"data-phone-sidebar-return":p!==null||void 0,onClick:()=>{d(e=>!e)},children:/* @__PURE__ */ (0,s.jsx)(o.IconSlidersTwoOutlineRegular,{})})}),children:_&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:Z.error,role:`alert`,children:l(`threadTree.style.error`)})})}function Wn(e,t,n,r){let i=t.find(e=>e.id===n.sessionId),a=t.find(e=>e.id===r.id);if(i===void 0||a===void 0||i.blank||i.pinned!==n.pinned||a.pinned!==n.pinned||i.id===a.id||!e.includes(i.id))return;let o=t.filter(e=>e.pinned===n.pinned),s=o.findIndex(e=>e.id===i.id);if(o.filter(e=>e.id!==i.id).findIndex(e=>e.id===a.id)+ +(r.half===`after`)===s)return;let c=e.filter(e=>e!==i.id),l=c.indexOf(a.id);if(l!==-1)return c.splice(l+ +(r.half===`after`),0,i.id),j(c,t.find(e=>e.blank)?.id)}function Gn(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function Kn({rowState:e,onLeaveArchivedOnly:t,partial:n,t:r}){let i=e.archivedFilter===`only`;return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:$.emptyState,"data-row-key":`empty`,children:[i?/* @__PURE__ */ (0,s.jsx)(o.IconArchiveOutlineRegular,{size:24}):/* @__PURE__ */ (0,s.jsx)(o.IconQueueOutlineRegular,{size:24}),/* @__PURE__ */ (0,s.jsx)(`div`,{children:r(n?`sessions.notLoaded`:i?`empty.noneArchived`:`empty.none`)}),i&&/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:$.emptyAction,onClick:t,children:r(`empty.viewOthers`)})]})}function qn({list:e,useSessionStatus:t,startSession:n,open:r,workspaces:i,ungroupedSessionIds:c,rowState:l,onLeaveArchivedOnly:u,workspaceReady:d,canStartProjectless:f,animationResetKey:p,usePanelInfo:m,onRenameRequest:h,onDeleteRequest:g,onSessionRenameRequest:_,renderSlot:v,insertWorkspaceBefore:y,nestWorkspaces:b,groupExpansion:x,setGroupExpanded:S,sectionExpansion:C,setSectionExpanded:w,setSessionOrder:T,home:D,t:O,revealSessionId:k,onSessionRevealed:A,shortcuts:j,loadMoreSessions:M}){let N=Rt(),ee=m(e=>e.activePanelId!==null),P=t(e=>e),te=ee?void 0:Object.values(e.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,F=k===void 0||!d?void 0:E(i,N.rootId(k)),[ne,re]=(0,a.useState)({}),[I,ie]=(0,a.useState)(null),L=(0,a.useRef)(!1),[z,ae]=(0,a.useState)(null),se=(0,a.useRef)(!1),B=I!==null||z!==null;Hn(B);let le=te===void 0||!d?void 0:E(i,N.rootId(te)),V=(0,a.useMemo)(()=>{if(!b)return/* @__PURE__ */ new Map;let e=/* @__PURE__ */ new Map;for(let t of i){let n=t.remote?.hostId??`local`,r=e.get(n)??/* @__PURE__ */ new Map;t.path&&r.set(t.path,t.workspaceId),e.set(n,r)}return new Map(i.map(t=>{let n=e.get(t.remote?.hostId??`local`),r=ce(t.path,[...n?.keys()??[]]);return[t.workspaceId,r===void 0?void 0:n?.get(r)]}))},[b,i]),pe=(0,a.useMemo)(()=>{let e=new Set(V.values());return[...i.map(e=>e.workspaceId),``].filter(t=>x[t]??(t===``||e.has(t)))},[x,V,i]),me=(0,a.useMemo)(()=>{let t=R(e,i,l,P,{expandedGroups:pe,excludePinned:!0});return(f||e.hasMore&&t.length===0)&&!t.some(e=>e.key===``)&&t.push({key:``,workspaceId:void 0,cwd:void 0,createdAt:void 0,label:``,sessionCount:0,expanded:pe.includes(``),containsCurrent:!1,sessions:[]}),t},[e,i,l,P,pe,f]),he=Date.now(),H=(e,t)=>{if(L.current)return;L.current=!0,ie(null);let n=me.find(t=>t.key===e.accountKey);if(n===void 0||t.id===e.sessionId)return;let r=e.accountKey===``?c:i.find(t=>t.workspaceId===e.accountKey)?.sessionIds;if(r===void 0)return;let a=Mn(n.sessions,ne[n.key]??5,te,k).rows,o=Wn(r,a,e,t);o!==void 0&&T(e.accountKey,o)},ge=(e,t)=>{if(se.current||(se.current=!0,ae(null),!Nt(i,e.workspaceId,t.id)))return;let n=V.get(e.workspaceId),r=i.filter(e=>!e.remote&&V.get(e.workspaceId)===n),a=r.findIndex(e=>e.workspaceId===t.id);if(a===-1)return;let o=t.half===`before`?t.id:r[a+1]?.workspaceId;if(o===e.workspaceId)return;let s=r.findIndex(t=>t.workspaceId===e.workspaceId),c=o===void 0?r.length:r.findIndex(e=>e.workspaceId===o);(s===-1||c!==s&&c!==s+1)&&y(e.workspaceId,o).catch(e=>{console.warn(`workspace reorder rejected:`,e)})},_e=(0,a.useMemo)(()=>{let e=new Set(me.map(e=>e.key)),t=/* @__PURE__ */ new Map;for(let n of me){let r=V.get(n.key);for(;r!==void 0&&!e.has(r);)r=V.get(r);let i=t.get(r);i===void 0?t.set(r,[n]):i.push(n)}return t},[me,V]),ve=_e.get(void 0)??[],ye=ve[0]?.workspaceId!==void 0&&z?.over?.id===ve[0].workspaceId&&z.over.half===`before`,be=(0,a.useMemo)(()=>{let e=/* @__PURE__ */ new Map,t=(n,r)=>{e.set(n.key,r);for(let e of _e.get(n.key)??[])t(e,r)};for(let e of ve)t(e,e.key);return e},[_e,ve]),xe=(0,a.useMemo)(()=>{let e=/* @__PURE__ */ new Set;for(let t of[le,F]){let n=t===void 0?void 0:be.get(t);n!==void 0&&n!==``&&e.add(n)}return e},[le,F,be]),[Se,Ce]=(0,a.useState)(!1),we=ve.filter(e=>e.key!==``),U=Nn(we,5,xe),Te=Se?we:U.rows,Ee=fe(C,ue),De=fe(C,de),Oe=e=>{e.expanded&&re(t=>({...t,[e.key]:5})),S(e.key,!e.expanded)},W=oe(e,l.pinnedSessionIds,l,P).filter(e=>e.pinned),ke=[];if(W.length>0&&(ke.push(`section:${ue}`),Ee))for(let e of N.rows(W))ke.push(`session:${e.id}`);me.length===0&&W.length===0&&ke.push(`empty`);let Ae=(t,a)=>{let c=t.workspaceId,l=_e.get(t.key)??[],u=z!==null&&Nt(i,z.workspaceId,c)&&V.get(z.workspaceId)===V.get(t.key),d=Mn(t.sessions,ne[t.key]??5,te,k);ke.push(`workspace:${t.key}`);let p=t.expanded?l.map(e=>Ae(e,a+1)):[],m=N.rows(d.rows);for(let e of m)ke.push(`${c===void 0?`recent`:`session`}:${e.id}`);let y=t.expanded&&(d.hiddenCount>0||e.hasMore);y&&ke.push(`overflow:${t.key}`);let b=c!==void 0&&z?.over?.id===c?z.over.half:null,x=c===void 0||t.remote?void 0:{start:()=>{se.current=!1,ae({workspaceId:c,over:null})},end:()=>{z?.over!==null&&z?.over!==void 0?ge(z,z.over):ae(null),se.current=!1}},C=c===void 0||!u?void 0:e=>{ae(t=>t===null?t:{...t,over:{id:c,half:e}})},w=c===void 0||!u?void 0:e=>{ge(z,{id:c,half:e})};return/* @__PURE__ */ (0,s.jsxs)(`div`,{"data-sidebar-group":t.key,style:{"--dsh-workspace-indent":`${a*12}px`},className:Q($.groupSection,b===`before`&&$.workspaceDropBefore,b===`after`&&$.workspaceDropAfter),onDragOver:z===null?void 0:e=>{e.preventDefault(),(C!==void 0||V.get(t.key)===void 0)&&(e.stopPropagation(),C===void 0?(e.dataTransfer.dropEffect=`none`,z.over!==null&&ae({...z,over:null})):(e.dataTransfer.dropEffect=`move`,C(Gn(e))))},onDrop:z===null?void 0:e=>{e.preventDefault(),(w!==void 0||V.get(t.key)===void 0)&&(e.stopPropagation(),w===void 0?(se.current=!0,ae(null)):w(Gn(e)))},children:[c===void 0?/* @__PURE__ */ (0,s.jsx)(En,{label:O(`group.ungrouped`),expanded:t.expanded,onToggle:()=>{Oe(t)},rowKey:`workspace:${t.key}`,action:f?{label:O(`actions.newSession`),icon:/* @__PURE__ */ (0,s.jsx)(o.IconNewChatOutlineRegular,{size:16}),onActivate:()=>{S(t.key,!0),n()}}:void 0}):/* @__PURE__ */ (0,s.jsx)(fn,{newShortcut:j.find(e=>e.id===`session.new`),group:t,home:D,t:O,onToggle:()=>{Oe(t)},onCreate:()=>{t.workspaceId!==void 0&&(S(t.key,t.expanded),n(t.workspaceId))},drag:x,actions:t.workspaceId===void 0?void 0:{rename:()=>{
12
12
  /* v8 ignore next -- narrowing guard: the actions object exists only for real-workspace groups. */
13
13
  t.workspaceId!==void 0&&h(t.workspaceId,t.label)},delete:()=>{
14
14
  /* v8 ignore next -- narrowing guard: the actions object exists only for real-workspace groups. */
15
- t.workspaceId!==void 0&&g(t.workspaceId,t.label)}}}),p.length>0&&/* @__PURE__ */ (0,s.jsx)(`div`,{role:`group`,children:p}),(m.length>0||y)&&/* @__PURE__ */ (0,s.jsxs)(`div`,{role:`group`,className:$.groupSessions,style:{"--dsh-workspace-indent":`${c===void 0?0:a*12+22}px`},children:[m.map(e=>{let n=I!==null&&I.accountKey===t.key,i=n&&I.pinned===e.pinned,a=t=>e.blank?`after`:t,o={start:()=>{se.current=!1,ae({accountKey:t.key,sessionId:e.id,pinned:e.pinned,over:null})},active:i,marker:n&&I.over?.id===e.id?I.over.half:null,hover:t=>{
15
+ t.workspaceId!==void 0&&g(t.workspaceId,t.label)}}}),p.length>0&&/* @__PURE__ */ (0,s.jsx)(`div`,{role:`group`,children:p}),(m.length>0||y)&&/* @__PURE__ */ (0,s.jsxs)(`div`,{role:`group`,className:$.groupSessions,style:{"--dsh-workspace-indent":`${c===void 0?0:a*12+22}px`},children:[/* @__PURE__ */ (0,s.jsx)(nn,{roots:d.rows,children:e=>{let n=I!==null&&I.accountKey===t.key,i=n&&I.pinned===e.pinned,a=t=>e.blank?`after`:t,o={start:()=>{L.current=!1,ie({accountKey:t.key,sessionId:e.id,pinned:e.pinned,over:null})},active:i,marker:n&&I.over?.id===e.id?I.over.half:null,hover:t=>{
16
16
  /* v8 ignore next -- narrowing guard: Rows gates hover on `active`, which is false while the drag state is null. */
17
- ae(n=>n===null?n:{...n,over:{id:e.id,half:a(t)}})},drop:t=>{
17
+ ie(n=>n===null?n:{...n,over:{id:e.id,half:a(t)}})},drop:t=>{
18
18
  /* v8 ignore next -- narrowing guard: Rows gates drop on `active`, which is false while the drag state is null. */
19
- I!==null&&V(I,{id:e.id,half:a(t)})},end:e=>{!e&&I?.over!==null&&I?.over!==void 0?V(I,I.over):ae(null),se.current=!1}};return/* @__PURE__ */ (0,s.jsx)(Mt,{rowKey:c===void 0?`recent:${e.id}`:void 0,showHost:!t.remote,node:e,currentId:N,now:he,onOpen:r,onRenameRequest:_,renderSlot:v,onReveal:e.id===k&&t.key===P?()=>{A(e.id)}:void 0,drag:c===void 0||t.remote?void 0:o,t:O},e.id)}),y&&/* @__PURE__ */ (0,s.jsx)(Zt,{rowKey:`overflow:${t.key}`,hiddenCount:d.hiddenCount,hasMore:e.hasMore,loading:e.loading,expand:()=>{re(e=>({...e,[t.key]:(e[t.key]??5)+10}))},loadMoreSessions:ee,t:O})]})]},t.key)},W=[];if(H.length>0&&ke.push(`section:${ce}`),De){for(let e of Te)W.push(Ae(e,0));!Se&&we.hiddenCount>0&&(ke.push(`overflow:workspaces`),W.push(/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:$.sessionOverflowButton,"data-row-key":`overflow:workspaces`,onClick:()=>{Ce(!0)},children:O(`workspaces.expand`)},`overflow:workspaces`)))}let je=ve.find(e=>e.key===``);return je!==void 0&&W.push(Ae(je,0)),/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q($.treeBody,$.wide),children:[ye&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:$.listTopDropIndicator,"aria-hidden":`true`}),/* @__PURE__ */ (0,s.jsxs)(Bt,{className:Q($.list,ye&&$.listTopDropActive),label:O(`section.sessions`),rowKeys:ke,ready:e.phase===`ready`&&d&&!de,resetKey:JSON.stringify([p,ne,Se,Ee,De]),children:[/* @__PURE__ */ (0,s.jsx)(Kt,{rows:U,currentId:N,onOpen:r,onRenameRequest:_,renderSlot:v,revealSessionId:k,onSessionRevealed:A,expanded:Ee,onToggle:()=>{T(L,!Ee)},t:O}),me.length===0&&U.length===0&&/* @__PURE__ */ (0,s.jsx)(un,{rowState:l,onLeaveArchivedOnly:u,partial:e.hasMore,t:O}),H.length>0&&/* @__PURE__ */ (0,s.jsx)(Ut,{label:O(`section.workspaces`),expanded:De,onToggle:()=>{De&&Ce(!1),T(`workspaces`,!De)},rowKey:`section:workspaces`}),W]}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:$.fade})]})}function fn({list:e,sessionIds:t,rowState:n,onLeaveArchivedOnly:r,useSessionStatus:i,open:o,onSessionRenameRequest:c,usePanelInfo:l,setSessionOrder:u,sectionExpansion:d,setSectionExpanded:f,workspaceReady:p,animationResetKey:m,revealSessionId:h,onSessionRevealed:g,renderSlot:_,loadMoreSessions:v,t:y}){let b=l(e=>e.activePanelId!==null),x=i(e=>e),S=(0,a.useMemo)(()=>ie(e,t,n,x).filter(e=>!e.pinned),[e,t,n,x]),C=ie(e,n.pinnedSessionIds,n,x).filter(e=>e.pinned),[w,T]=(0,a.useState)(null),E=(0,a.useRef)(!1),[D,O]=(0,a.useState)(10);on(w!==null);let k=b?void 0:Object.values(e.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,A=Yt(S,D,k,h),j=Yt(S,10,k,h).hiddenCount>0,ee=(e,n)=>{if(E.current)return;E.current=!0,T(null);let r=cn(t,S,e,n);r!==void 0&&u(se,r)},te=Date.now(),M=le(d,L);return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q($.treeBody,$.wide),children:[/* @__PURE__ */ (0,s.jsxs)(Bt,{className:Q($.list,$.flatList),label:y(`section.sessions`),rowKeys:[...C.length===0?[]:[`section:${L}`],...M?C.map(e=>`session:${e.id}`):[],...S.length===0&&C.length===0?[`empty`]:[],...A.rows.map(e=>`session:${e.id}`),...j||e.hasMore?[`overflow:flat`]:[]],ready:e.phase===`ready`&&p&&w===null,resetKey:`${m}/${D}/${String(M)}`,children:[/* @__PURE__ */ (0,s.jsx)(Kt,{rows:C,currentId:k,onOpen:o,onRenameRequest:c,renderSlot:_,revealSessionId:h,onSessionRevealed:g,expanded:M,onToggle:()=>{f(L,!M)},t:y}),C.length>0&&/* @__PURE__ */ (0,s.jsx)(Ut,{label:y(`section.sessions`)}),S.length===0&&C.length===0&&/* @__PURE__ */ (0,s.jsx)(un,{rowState:n,onLeaveArchivedOnly:r,partial:e.hasMore,t:y}),A.rows.map(e=>{let t=w!==null&&w.pinned===e.pinned,n=t=>e.blank?`after`:t;return/* @__PURE__ */ (0,s.jsx)(Mt,{node:e,currentId:k,now:te,onOpen:o,onRenameRequest:c,renderSlot:_,onReveal:e.id===h?()=>{g(e.id)}:void 0,drag:{start:()=>{E.current=!1,T({accountKey:se,sessionId:e.id,pinned:e.pinned,over:null})},active:t,marker:t&&w.over?.id===e.id?w.over.half:null,hover:t=>{T(r=>r===null?r:{...r,over:{id:e.id,half:n(t)}})},drop:t=>{w!==null&&ee(w,{id:e.id,half:n(t)})},end:e=>{!e&&w?.over!==null&&w?.over!==void 0?ee(w,w.over):T(null),E.current=!1}},t:y},e.id)}),/* @__PURE__ */ (0,s.jsx)(Zt,{rowKey:`overflow:flat`,hiddenCount:A.hiddenCount,hasMore:e.hasMore,loading:e.loading,expanded:D>10,expand:()=>O(D+10),collapse:j?()=>O(10):void 0,loadMoreSessions:v,t:y})]}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:$.fade})]})}function pn({useSessions:e,useSessionStatus:t,open:n,onUnarchive:r,workspaces:i,archivedSessionIds:o,archivedFilter:c,query:l,remote:u,resultLimit:d,usePanelInfo:f,t:p}){let m=f(e=>e.activePanelId!==null),h=e(e=>e),g=t(e=>e),_=u.query===l?u:{query:l,status:`loading`,items:[],hasMore:!1},v=(0,a.useMemo)(()=>I(h,i,l,o,c,g,_,d),[h,i,l,o,c,g,_,d]),y=_.status===`loading`,b=m?void 0:Object.values(h.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id;return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q($.treeBody,$.wide),children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:$.list,children:[/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.searchTree,role:`tree`,"aria-label":p(`search.results.aria`),children:v.items.map(e=>/* @__PURE__ */ (0,s.jsx)(jt,{result:e,currentId:b,onOpen:n,onUnarchive:r,t:p},e.id))}),y&&/* @__PURE__ */ (0,s.jsx)(`div`,{role:`status`,"aria-label":p(`search.pending`),children:(v.items.length===0?[0,1]:[0]).map(e=>/* @__PURE__ */ (0,s.jsxs)(`div`,{className:$.skeletonRow,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:$.skeletonDot}),/* @__PURE__ */ (0,s.jsxs)(`span`,{className:$.skeletonBars,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:$.skeletonBar}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:Q($.skeletonBar,$.skeletonBarWide)})]})]},e))}),!y&&v.items.length===0&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.empty,children:p(`search.noMatches`)}),v.hasMore&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.searchStatus,children:p(`search.hasMore`,{n:d})})]}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:$.fade})]})}function mn({wide:e,usePanelInfo:t,expandSidebar:n,useSessions:r,useSessionStatus:i,useWorkspaces:c,useStore:l,actions:u,startSession:d,open:f,requestSessionRename:p,notifyArchivedNotOpenable:m,renameWorkspace:h,deleteWorkspace:g,insertWorkspaceBefore:_,unarchiveSession:v,createWorkspace:y,searchSessions:b,searchResultLimit:x,useDirectoryFlow:S,useHostInfo:C,useShortcuts:w,useWorkspaceShortcuts:O,requestSearch:k,requestAddWorkspace:A,closeAddWorkspace:j,setDirectoryBusy:ee,dismissForkError:te,refreshSessions:M,loadMoreSessions:N,renderSlot:P,t:F}){let re=C(e=>e.home),ie=w(e=>e),I=ie.find(e=>e.id===`session.search`),ae=ie.find(e=>e.id===`workspace.add`),oe=O(e=>e),L=r(e=>e),ce=c(e=>e.items),le=c(e=>e.canStartProjectless===!0),R=F(`workspace.defaultName`),z=(0,a.useMemo)(()=>ce.map(e=>({...e,title:bt(e.title,R)})),[ce,R]),de=c(e=>e.phase),fe=c(e=>e.state),B=c(e=>e.archivedSessionIds),pe=c(e=>e.pinnedSessionIds),me=S(e=>e),he=l(e=>e.groupBy),V=l(e=>e.orderBy),ge=l(e=>e.archivedFilter??`default`),_e=l(e=>e.groupExpansion),ve=l(e=>e.sectionExpansion),ye=l(e=>e.sessionOrderByAccount),be=e=>{B.includes(e)?m():f(e)},xe=()=>{u.setArchivedFilter(`default`)},Se=de===`ready`&&fe!==`loading`,Ce=Object.values(L.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,H=Ce!==void 0&&L.byId[Ce]?.blank===!0?Ce:void 0,we=(0,a.useMemo)(()=>{let e=new Set(z.flatMap(e=>e.sessionIds));return[.../* @__PURE__ */ new Set([...L.ids,...B])].filter(t=>!e.has(t))},[B,L.ids,z]),Te=(0,a.useMemo)(()=>({pinnedSessionIds:pe,archivedSessionIds:B}),[B,pe]),Ee=(0,a.useMemo)(()=>({...Te,archivedFilter:ge}),[Te,ge]),De=(0,a.useMemo)(()=>ne(L,B),[B,L]),Oe=(0,a.useMemo)(()=>z.map(e=>{let t=e.sessionIds,n=V===`updated`?T(t,L.byId):E(t,ye[e.workspaceId],L.byId,Te);return{...e,sessionIds:D(n,H!==void 0&&t.includes(H)?H:void 0)}}),[H,L.byId,V,Te,ye,z]),U=(0,a.useMemo)(()=>T(we,L.byId),[L.byId,we]),ke=(0,a.useMemo)(()=>D(V===`updated`?T(De,L.byId):E(De,ye[se],L.byId,Te),H!==void 0&&De.includes(H)?H:void 0),[H,De,L.byId,V,Te,ye]),Ae=(0,a.useMemo)(()=>ue(z,L,Te),[L,Te,z]),W=(0,a.useMemo)(()=>Object.fromEntries([...Oe.map(e=>[e.workspaceId,e.sessionIds]),[``,U],[se,ke]]),[ke,U,Oe]);(0,a.useEffect)(()=>{de===`ready`&&u.retainAccountKeys([``,se,...z.map(e=>e.workspaceId)])},[u.retainAccountKeys,de,z]),(0,a.useEffect)(()=>{if(L.phase!==`ready`||Se||V!==`manual`||H===void 0)return;let e={};for(let[t,n]of Object.entries(W)){if(t!==`__flat_session_order__`&&de!==`ready`)continue;let r=ye[t]??[];n[0]===H&&r[0]!==H&&(e[t]=[H,...r.filter(e=>e!==H)])}Object.keys(e).length>0&&u.syncSessionOrders(e,Ae)},[u.syncSessionOrders,W,H,L.phase,V,ye,Ae,de,Se]),(0,a.useEffect)(()=>{L.phase===`ready`&&Se&&V===`manual`&&H!==void 0&&Object.entries(W).some(([e,t])=>t[0]===H&&ye[e]?.[0]!==H)&&u.syncSessionOrders(W,Ae)},[u.syncSessionOrders,W,H,L.phase,V,ye,Ae,Se]);let je=(e,t)=>{u.setSessionOrder(e,t,W,Ae)},[Me,Ne]=(0,a.useState)(``),[G,Pe]=(0,a.useState)(!1),[Fe,Ie]=(0,a.useState)(void 0),Le=an(Me).trim(),[K,Re]=(0,a.useState)({query:``,status:`idle`,items:[],hasMore:!1}),ze=(0,a.useRef)(null),q=(0,a.useRef)(null),Be=oe.addRequested,Ve=(0,a.useRef)(null),He=(0,a.useRef)(!1),Ue=e=>{B.includes(e)?m():(Ie(e),Ne(``),Pe(!1),f(e))},We=e=>{Ie(t=>t===e?void 0:t)};(0,a.useEffect)(()=>{Le!==``&&Ie(void 0)},[Le]);let[J,Ge]=(0,a.useState)(!1);(0,a.useEffect)(()=>{if(e&&J){let e=window.setTimeout(()=>{q.current?.focus({preventScroll:!0}),Ge(!1)},300);return()=>{window.clearTimeout(e)}}},[e,J]),(0,a.useEffect)(()=>{oe.searchRequest!==0&&(j(),Pe(!0),e?q.current?.focus({preventScroll:!0}):(Ge(!0),n()))},[oe.searchRequest]),(0,a.useEffect)(()=>{e&&G&&!J&&q.current?.focus({preventScroll:!0})},[e,G,J]),(0,a.useEffect)(()=>{if(!e||!G||J)return;let t=e=>{e.target instanceof Node&&ze.current?.contains(e.target)!==!0&&(q.current?.blur(),Le===``&&Pe(!1))};return document.addEventListener(`click`,t),()=>{document.removeEventListener(`click`,t)}},[Le,e,G,J]),(0,a.useEffect)(()=>{if(Le===``){Re({query:``,status:`idle`,items:[],hasMore:!1});return}let e=new AbortController;Re({query:Le,status:`loading`,items:[],hasMore:!1});let t=window.setTimeout(()=>{b(Le,e.signal).then(t=>{e.signal.aborted||Re({query:Le,status:`ready`,items:t.items,hasMore:t.hasMore})}).catch(()=>{e.signal.aborted||Re({query:Le,status:`error`,items:[],hasMore:!1})})},250);return()=>{window.clearTimeout(t),e.abort()}},[Le,b]);let[Ke,qe]=(0,a.useState)(null),[Je,Ye]=(0,a.useState)(``),[Xe,Ze]=(0,a.useState)(!1),[Qe,Y]=(0,a.useState)(null),X=Je.trim(),$e=Ke!==null&&X!==``&&z.some(e=>e.workspaceId!==Ke.workspaceId&&e.title===X),et=Xe||X===``||Ke===null||X===Ke.storedTitle||$e,tt=()=>{Xe||(qe(null),Y(null))},nt=()=>{et||(Ze(!0),Y(null),h(Ke.workspaceId,X).then(()=>{Ze(!1),qe(null)}).catch(e=>{Ze(!1),Y(e instanceof Error?e.message:String(e))}))},rt=e=>{v(e).catch(e=>{console.warn(`session unarchive rejected:`,e)})},[it,at]=(0,a.useState)(null),[ot,st]=(0,a.useState)(!1),[ct,lt]=(0,a.useState)(null),[ut,Z]=(0,a.useState)(null);(0,a.useEffect)(()=>{ct===null||z.some(e=>e.workspaceId===ct)||(st(!1),lt(null),at(null))},[ct,z]);let dt=()=>{ot||(at(null),Z(null))},ft=()=>{
19
+ I!==null&&H(I,{id:e.id,half:a(t)})},end:e=>{!e&&I?.over!==null&&I?.over!==void 0?H(I,I.over):ie(null),L.current=!1}};return/* @__PURE__ */ (0,s.jsx)(hn,{rowKey:c===void 0?`recent:${e.id}`:void 0,showHost:!t.remote,node:e,currentId:te,now:he,onOpen:r,onRenameRequest:_,renderSlot:v,onReveal:e.id===k&&t.key===F?()=>{A(e.id)}:void 0,drag:c===void 0||t.remote||(e.tree?.depth??0)>0?void 0:o,t:O},e.id)}}),y&&/* @__PURE__ */ (0,s.jsx)(Pn,{rowKey:`overflow:${t.key}`,hiddenCount:d.hiddenCount,hasMore:e.hasMore,loading:e.loading,expand:()=>{re(e=>({...e,[t.key]:(e[t.key]??5)+10}))},loadMoreSessions:M,t:O})]})]},t.key)},je=[];if(we.length>0&&ke.push(`section:${de}`),De){for(let e of Te)je.push(Ae(e,0));!Se&&U.hiddenCount>0&&(ke.push(`overflow:workspaces`),je.push(/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:$.sessionOverflowButton,"data-row-key":`overflow:workspaces`,onClick:()=>{Ce(!0)},children:O(`workspaces.expand`)},`overflow:workspaces`)))}let G=ve.find(e=>e.key===``);return G!==void 0&&je.push(Ae(G,0)),/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q($.treeBody,$.wide),children:[ye&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:$.listTopDropIndicator,"aria-hidden":`true`}),/* @__PURE__ */ (0,s.jsxs)(Cn,{className:Q($.list,ye&&$.listTopDropActive),label:O(`section.sessions`),rowKeys:ke,ready:e.phase===`ready`&&d&&!B,resetKey:JSON.stringify([p,ne,Se,Ee,De]),children:[/* @__PURE__ */ (0,s.jsx)(kn,{rows:W,currentId:te,onOpen:r,onRenameRequest:_,renderSlot:v,revealSessionId:k,onSessionRevealed:A,expanded:Ee,onToggle:()=>{w(ue,!Ee)},t:O}),me.length===0&&W.length===0&&/* @__PURE__ */ (0,s.jsx)(Kn,{rowState:l,onLeaveArchivedOnly:u,partial:e.hasMore,t:O}),we.length>0&&/* @__PURE__ */ (0,s.jsx)(En,{label:O(`section.workspaces`),expanded:De,onToggle:()=>{De&&Ce(!1),w(`workspaces`,!De)},rowKey:`section:workspaces`}),je]}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:$.fade})]})}function Jn({list:e,sessionIds:t,rowState:n,onLeaveArchivedOnly:r,useSessionStatus:i,open:o,onSessionRenameRequest:c,usePanelInfo:l,setSessionOrder:u,sectionExpansion:d,setSectionExpanded:f,workspaceReady:p,animationResetKey:m,revealSessionId:h,onSessionRevealed:g,renderSlot:_,loadMoreSessions:v,t:y}){let b=l(e=>e.activePanelId!==null),x=i(e=>e),S=Rt(),C=(0,a.useMemo)(()=>oe(e,t,n,x).filter(e=>!e.pinned),[e,t,n,x]),w=oe(e,n.pinnedSessionIds,n,x).filter(e=>e.pinned),[T,E]=(0,a.useState)(null),D=(0,a.useRef)(!1),[O,k]=(0,a.useState)(10);Hn(T!==null);let A=b?void 0:Object.values(e.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,j=Mn(C,O,A,h),M=Mn(C,10,A,h).hiddenCount>0,N=(e,n)=>{if(D.current)return;D.current=!0,E(null);let r=Wn(t,C,e,n);r!==void 0&&u(le,r)},ee=Date.now(),P=fe(d,ue);return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q($.treeBody,$.wide),children:[/* @__PURE__ */ (0,s.jsxs)(Cn,{className:Q($.list,$.flatList),label:y(`section.sessions`),rowKeys:[...w.length===0?[]:[`section:${ue}`],...P?S.rows(w).map(e=>`session:${e.id}`):[],...C.length===0&&w.length===0?[`empty`]:[],...S.rows(j.rows).map(e=>`session:${e.id}`),...M||e.hasMore?[`overflow:flat`]:[]],ready:e.phase===`ready`&&p&&T===null,resetKey:`${m}/${O}/${String(P)}`,children:[/* @__PURE__ */ (0,s.jsx)(kn,{rows:w,currentId:A,onOpen:o,onRenameRequest:c,renderSlot:_,revealSessionId:h,onSessionRevealed:g,expanded:P,onToggle:()=>{f(ue,!P)},t:y}),w.length>0&&/* @__PURE__ */ (0,s.jsx)(En,{label:y(`section.sessions`)}),C.length===0&&w.length===0&&/* @__PURE__ */ (0,s.jsx)(Kn,{rowState:n,onLeaveArchivedOnly:r,partial:e.hasMore,t:y}),/* @__PURE__ */ (0,s.jsx)(nn,{roots:j.rows,children:e=>{let t=T!==null&&T.pinned===e.pinned,n=t=>e.blank?`after`:t;return/* @__PURE__ */ (0,s.jsx)(hn,{node:e,currentId:A,now:ee,onOpen:o,onRenameRequest:c,renderSlot:_,onReveal:e.id===h?()=>{g(e.id)}:void 0,drag:{start:()=>{D.current=!1,E({accountKey:le,sessionId:e.id,pinned:e.pinned,over:null})},active:t,marker:t&&T.over?.id===e.id?T.over.half:null,hover:t=>{E(r=>r===null?r:{...r,over:{id:e.id,half:n(t)}})},drop:t=>{T!==null&&N(T,{id:e.id,half:n(t)})},end:e=>{!e&&T?.over!==null&&T?.over!==void 0?N(T,T.over):E(null),D.current=!1}},t:y},e.id)}}),/* @__PURE__ */ (0,s.jsx)(Pn,{rowKey:`overflow:flat`,hiddenCount:j.hiddenCount,hasMore:e.hasMore,loading:e.loading,expanded:O>10,expand:()=>k(O+10),collapse:M?()=>k(10):void 0,loadMoreSessions:v,t:y})]}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:$.fade})]})}function Yn({useSessions:e,useSessionStatus:t,open:n,onUnarchive:r,workspaces:i,archivedSessionIds:o,archivedFilter:c,query:l,remote:u,resultLimit:d,usePanelInfo:f,t:p}){let m=f(e=>e.activePanelId!==null),h=e(e=>e),g=t(e=>e),_=u.query===l?u:{query:l,status:`loading`,items:[],hasMore:!1},v=(0,a.useMemo)(()=>se(h,i,l,o,c,g,_,d),[h,i,l,o,c,g,_,d]),y=_.status===`loading`,b=m?void 0:Object.values(h.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id;return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q($.treeBody,$.wide),children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:$.list,children:[/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.searchTree,role:`tree`,"aria-label":p(`search.results.aria`),children:v.items.map(e=>/* @__PURE__ */ (0,s.jsx)(mn,{result:e,currentId:b,onOpen:n,onUnarchive:r,t:p},e.id))}),y&&/* @__PURE__ */ (0,s.jsx)(`div`,{role:`status`,"aria-label":p(`search.pending`),children:(v.items.length===0?[0,1]:[0]).map(e=>/* @__PURE__ */ (0,s.jsxs)(`div`,{className:$.skeletonRow,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:$.skeletonDot}),/* @__PURE__ */ (0,s.jsxs)(`span`,{className:$.skeletonBars,children:[/* @__PURE__ */ (0,s.jsx)(`span`,{className:$.skeletonBar}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:Q($.skeletonBar,$.skeletonBarWide)})]})]},e))}),!y&&v.items.length===0&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.empty,children:p(`search.noMatches`)}),v.hasMore&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.searchStatus,children:p(`search.hasMore`,{n:d})})]}),/* @__PURE__ */ (0,s.jsx)(`span`,{className:$.fade})]})}function Xn(e){return/* @__PURE__ */ (0,s.jsx)(zt,{browser:e,children:/* @__PURE__ */ (0,s.jsx)(Zn,{...e})})}function Zn({wide:e,usePanelInfo:t,expandSidebar:n,useSessions:r,useSessionStatus:i,useWorkspaces:c,useStore:l,actions:u,startSession:d,open:f,requestSessionRename:p,notifyArchivedNotOpenable:m,renameWorkspace:h,deleteWorkspace:g,insertWorkspaceBefore:_,unarchiveSession:v,createWorkspace:y,searchSessions:b,searchResultLimit:x,useDirectoryFlow:S,useHostInfo:C,useShortcuts:w,useWorkspaceShortcuts:T,requestSearch:E,requestAddWorkspace:D,closeAddWorkspace:O,setDirectoryBusy:M,dismissForkError:N,refreshSessions:ee,loadMoreSessions:P,renderSlot:te,t:F}){let ne=C(e=>e.home),re=w(e=>e),I=re.find(e=>e.id===`session.search`),ie=re.find(e=>e.id===`workspace.add`),L=T(e=>e),R=r(e=>e),ae=c(e=>e.items),oe=c(e=>e.canStartProjectless===!0),se=F(`workspace.defaultName`),B=(0,a.useMemo)(()=>ae.map(e=>({...e,title:Ft(e.title,se)})),[ae,se]),ce=c(e=>e.phase),ue=c(e=>e.state),de=c(e=>e.archivedSessionIds),fe=c(e=>e.pinnedSessionIds),V=S(e=>e),pe=l(e=>e.groupBy),H=l(e=>e.orderBy),ge=l(e=>e.archivedFilter??`default`),_e=l(e=>e.groupExpansion),ve=Rt(),ye=l(e=>e.sectionExpansion),be=l(e=>e.sessionOrderByAccount),xe=e=>{de.includes(e)?m():(ve.selectSidebarRow(e),f(e))},Se=()=>{u.setArchivedFilter(`default`)},Ce=ce===`ready`&&ue!==`loading`,we=Object.values(R.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,U=we!==void 0&&R.byId[we]?.blank===!0?we:void 0,Te=(0,a.useMemo)(()=>{let e=new Set(B.flatMap(e=>e.sessionIds));return[.../* @__PURE__ */ new Set([...R.ids,...de])].filter(t=>!e.has(t))},[de,R.ids,B]),Ee=(0,a.useMemo)(()=>({pinnedSessionIds:fe,archivedSessionIds:de}),[de,fe]),De=(0,a.useMemo)(()=>({...Ee,archivedFilter:ge}),[Ee,ge]),Oe=(0,a.useMemo)(()=>z(R,de),[de,R]),W=(0,a.useMemo)(()=>me(R,De),[R,De]),ke=(0,a.useMemo)(()=>B.map(e=>{let t=e.sessionIds.filter(e=>R.byId[e]===void 0||W.rootIds.has(e)),n=H===`updated`?k(t,W.summaries):A(t,be[e.workspaceId],W.summaries,Ee);return{...e,sessionIds:j(n,U!==void 0&&t.includes(U)?U:void 0)}}),[U,R.byId,W,H,Ee,be,B]),Ae=(0,a.useMemo)(()=>k(Te.filter(e=>W.rootIds.has(e)),W.summaries),[W,Te]),je=(0,a.useMemo)(()=>{let e=Oe.filter(e=>W.rootIds.has(e));return j(H===`updated`?k(e,W.summaries):A(e,be[le],W.summaries,Ee),U!==void 0&&Oe.includes(U)?U:void 0)},[U,Oe,W,H,Ee,be]),G=(0,a.useMemo)(()=>he(B,R,De),[R,De,B]),Me=(0,a.useMemo)(()=>Object.fromEntries([...ke.map(e=>[e.workspaceId,e.sessionIds]),[``,Ae],[le,je]]),[je,Ae,ke]);(0,a.useEffect)(()=>{ce===`ready`&&u.retainAccountKeys([``,le,...B.map(e=>e.workspaceId)])},[u.retainAccountKeys,ce,B]),(0,a.useEffect)(()=>{if(R.phase!==`ready`||Ce||H!==`manual`||U===void 0)return;let e={};for(let[t,n]of Object.entries(Me)){if(t!==`__flat_session_order__`&&ce!==`ready`)continue;let r=be[t]??[];n[0]===U&&r[0]!==U&&(e[t]=[U,...r.filter(e=>e!==U)])}Object.keys(e).length>0&&u.syncSessionOrders(e,G)},[u.syncSessionOrders,Me,U,R.phase,H,be,G,ce,Ce]),(0,a.useEffect)(()=>{R.phase===`ready`&&Ce&&H===`manual`&&U!==void 0&&Object.entries(Me).some(([e,t])=>t[0]===U&&be[e]?.[0]!==U)&&u.syncSessionOrders(Me,G)},[u.syncSessionOrders,Me,U,R.phase,H,be,G,Ce]);let Ne=(e,t)=>{u.setSessionOrder(e,t,Me,G)},[K,Pe]=(0,a.useState)(``),[Fe,Ie]=(0,a.useState)(!1),[Le,Re]=(0,a.useState)(void 0),ze=Vn(K).trim(),[Be,Ve]=(0,a.useState)({query:``,status:`idle`,items:[],hasMore:!1}),q=(0,a.useRef)(null),He=(0,a.useRef)(null),Ue=L.addRequested,We=(0,a.useRef)(null),Ge=(0,a.useRef)(!1),Ke=e=>{de.includes(e)?m():(Re(e),Pe(``),Ie(!1),ve.reveal(e),f(e))},qe=e=>{Re(t=>t===e?void 0:t)};(0,a.useEffect)(()=>{ze!==``&&Re(void 0)},[ze]);let[Je,Ye]=(0,a.useState)(!1);(0,a.useEffect)(()=>{if(e&&Je){let e=window.setTimeout(()=>{He.current?.focus({preventScroll:!0}),Ye(!1)},300);return()=>{window.clearTimeout(e)}}},[e,Je]),(0,a.useEffect)(()=>{L.searchRequest!==0&&(O(),Ie(!0),e?He.current?.focus({preventScroll:!0}):(Ye(!0),n()))},[L.searchRequest]),(0,a.useEffect)(()=>{e&&Fe&&!Je&&He.current?.focus({preventScroll:!0})},[e,Fe,Je]),(0,a.useEffect)(()=>{if(!e||!Fe||Je)return;let t=e=>{e.target instanceof Node&&q.current?.contains(e.target)!==!0&&(He.current?.blur(),ze===``&&Ie(!1))};return document.addEventListener(`click`,t),()=>{document.removeEventListener(`click`,t)}},[ze,e,Fe,Je]),(0,a.useEffect)(()=>{if(ze===``){Ve({query:``,status:`idle`,items:[],hasMore:!1});return}let e=new AbortController;Ve({query:ze,status:`loading`,items:[],hasMore:!1});let t=window.setTimeout(()=>{b(ze,e.signal).then(t=>{e.signal.aborted||Ve({query:ze,status:`ready`,items:t.items,hasMore:t.hasMore})}).catch(()=>{e.signal.aborted||Ve({query:ze,status:`error`,items:[],hasMore:!1})})},250);return()=>{window.clearTimeout(t),e.abort()}},[ze,b]);let[Xe,Ze]=(0,a.useState)(null),[Qe,$e]=(0,a.useState)(``),[et,tt]=(0,a.useState)(!1),[nt,rt]=(0,a.useState)(null),it=Qe.trim(),J=Xe!==null&&it!==``&&B.some(e=>e.workspaceId!==Xe.workspaceId&&e.title===it),Y=et||it===``||Xe===null||it===Xe.storedTitle||J,at=()=>{et||(Ze(null),rt(null))},ot=()=>{Y||(tt(!0),rt(null),h(Xe.workspaceId,it).then(()=>{tt(!1),Ze(null)}).catch(e=>{tt(!1),rt(e instanceof Error?e.message:String(e))}))},st=e=>{v(e).catch(e=>{console.warn(`session unarchive rejected:`,e)})},[ct,lt]=(0,a.useState)(null),[ut,dt]=(0,a.useState)(!1),[ft,pt]=(0,a.useState)(null),[mt,ht]=(0,a.useState)(null);(0,a.useEffect)(()=>{ft===null||B.some(e=>e.workspaceId===ft)||(dt(!1),pt(null),lt(null))},[ft,B]);let gt=()=>{ut||(lt(null),ht(null))},X=()=>{
20
20
  /* v8 ignore next -- the Modal is absent without a target and its button is disabled while deleting. */
21
- ot||it===null||(st(!0),lt(null),Z(null),g(it.workspaceId).then(()=>{lt(it.workspaceId)}).catch(e=>{st(!1),Z(e instanceof Error?e.message:String(e))}))};return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q($.root,!e&&$.rail),children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:$.sectionHeader,children:[e&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:Q($.sectionLabel,$.wide,G&&$.sectionLabelHidden),children:F(`section.sessions`)}),e&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:Q($.searchSlot,G&&$.searchSlotExpanded),children:/* @__PURE__ */ (0,s.jsxs)(`div`,{ref:ze,className:Q($.search,G&&$.searchExpanded),onClick:()=>{j(),Pe(!0),q.current?.focus()},children:[/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:F(`search`),shortcutKeys:I?.keys,side:`bottom`,delayMs:500,disabled:G,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:$.searchButton,"aria-label":F(`search.sessions.aria`),"aria-keyshortcuts":I?.aria,"aria-expanded":G,onClick:()=>{k()},children:/* @__PURE__ */ (0,s.jsx)(o.IconSearchOutlineRegular,{size:16})})}),/* @__PURE__ */ (0,s.jsx)(`input`,{ref:q,className:$.searchInput,type:`text`,placeholder:F(`search.placeholder`),maxLength:500,value:Me,tabIndex:G?0:-1,onChange:e=>{Ne(an(e.target.value))},onKeyDown:e=>{e.key===`Escape`&&(e.currentTarget.closest(`[data-phone-drawer]`)&&(e.preventDefault(),e.stopPropagation()),Ne(``),Pe(!1))}}),G&&/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:$.clearButton,"aria-label":F(`search.clear`),onClick:e=>{e.stopPropagation(),Ne(``),Pe(!1)},children:/* @__PURE__ */ (0,s.jsx)(o.IconCloseFillRegular,{})})]})}),/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q($.headerActions,e&&G&&$.headerActionsHidden),children:[e&&/* @__PURE__ */ (0,s.jsx)(sn,{groupBy:he,orderBy:V,archivedFilter:ge,onGroupPick:u.setGroupBy,onOrderPick:e=>{u.setOrderBy(e,W,Ae)},onArchivedFilterPick:u.setArchivedFilter,t:F}),me&&/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:F(`workspace.add`),shortcutKeys:ae?.keys,side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,s.jsx)(`button`,{ref:Ve,type:`button`,className:$.iconButton,"aria-label":F(`workspace.add`),"aria-keyshortcuts":ae?.aria,onClick:()=>{A()},children:/* @__PURE__ */ (0,s.jsx)(o.IconProjectAddOutlineRegular,{size:e?16:18})})})]}),/* @__PURE__ */ (0,s.jsx)(nn,{t:F,open:Be,anchorRef:Ve,useWorkspaces:c,createWorkspace:y,useDirectoryFlow:S,renderDirectoryFlow:e=>P(`sidebar.workspaces.directoryFlow`,e),addOnly:!0,onBusyChange:ee,side:`right`,onPick:e=>{j(),d(e)},onClose:()=>{j()}})]}),!e&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.search,children:/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:F(`search`),shortcutKeys:I?.keys,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:$.searchButton,"aria-label":F(`search.sessions.aria`),"aria-keyshortcuts":I?.aria,onClick:()=>{k()},children:/* @__PURE__ */ (0,s.jsx)(o.IconSearchOutlineRegular,{size:18})})})}),/* @__PURE__ */ (0,s.jsxs)(`div`,{className:$.listArea,children:[e&&L.phase===`pending`&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.empty,role:`status`,children:F(`sessions.loading`)}),e&&(Le===``?he===`flat`?/* @__PURE__ */ (0,s.jsx)(fn,{loadMoreSessions:N,usePanelInfo:t,list:L,sessionIds:ke,rowState:Ee,onLeaveArchivedOnly:xe,workspaceReady:Se,animationResetKey:`${he}/${V}/${ge}`,useSessionStatus:i,open:be,onSessionRenameRequest:p,renderSlot:P,setSessionOrder:je,sectionExpansion:ve,setSectionExpanded:u.setSectionExpanded,revealSessionId:Fe,onSessionRevealed:We,t:F}):/* @__PURE__ */ (0,s.jsx)(dn,{loadMoreSessions:N,usePanelInfo:t,list:L,shortcuts:ie,useSessionStatus:i,onSessionRenameRequest:p,renderSlot:P,workspaces:Oe,ungroupedSessionIds:U,canStartProjectless:le,workspaceReady:Se,nestWorkspaces:he===`workspace-tree`,animationResetKey:`${he}/${V}/${ge}`,groupExpansion:_e,setGroupExpanded:u.setGroupExpanded,sectionExpansion:ve,setSectionExpanded:u.setSectionExpanded,setSessionOrder:je,rowState:Ee,onLeaveArchivedOnly:xe,startSession:d,open:be,insertWorkspaceBefore:_,revealSessionId:Fe,onSessionRevealed:We,home:re,t:F,onRenameRequest:(e,t)=>{qe({workspaceId:e,storedTitle:ce.find(t=>t.workspaceId===e)?.title??t}),Ye(t),Y(null)},onDeleteRequest:(e,t)=>{at({workspaceId:e,title:t}),Z(null)}}):/* @__PURE__ */ (0,s.jsx)(pn,{usePanelInfo:t,useSessions:r,useSessionStatus:i,open:Ue,onUnarchive:rt,workspaces:z,archivedSessionIds:B,archivedFilter:ge,query:Le,remote:K,resultLimit:x,t:F}))]}),e&&/* @__PURE__ */ (0,s.jsx)(Jt,{list:L,refreshSessions:M,loadMoreSessions:N,t:F}),/* @__PURE__ */ (0,s.jsxs)(o.Modal,{open:Ke!==null,onClose:tt,closeLabel:F(`close`),title:F(`rename.workspace.title`),footer:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,disabled:Xe,onClick:tt,children:F(`cancel`)}),/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`primary`,disabled:et,onClick:nt,children:F(`rename`)})]}),children:[/* @__PURE__ */ (0,s.jsx)(`input`,{className:$.renameInput,value:Je,"aria-label":F(`field.workspaceName`),"data-modal-autofocus":!0,disabled:Xe,onFocus:e=>{e.target.select()},onChange:e=>{Ye(e.target.value),Y(null)},onCompositionStart:()=>{He.current=!0},onCompositionEnd:()=>{He.current=!1},onKeyDown:e=>{e.key===`Enter`&&!He.current&&(e.preventDefault(),nt())}}),$e&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.renameError,role:`alert`,children:F(`conflict.named`,{name:X})}),Qe!==null&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.renameError,role:`alert`,children:Qe})]}),/* @__PURE__ */ (0,s.jsxs)(o.Modal,{open:it!==null,onClose:dt,closeLabel:F(`close`),title:F(`delete.workspace`),...it===null?{}:{description:F(`delete.desc`,{name:it.title})},footer:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,disabled:ot,onClick:dt,children:F(`cancel`)}),/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,className:$.deleteAction,disabled:ot,onClick:ft,children:F(`delete.workspace`)})]}),children:[ot&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.deleteStatus,role:`status`,children:F(`delete.pending`)}),ut!==null&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.renameError,role:`alert`,children:ut})]}),oe.forkError!==null&&/* @__PURE__ */ (0,s.jsx)(o.Toast,{text:F(oe.forkError.reason===`unavailable`?`shortcut.noCompletedTurn`:`shortcut.forkFailed`),onDone:te},oe.forkError.seq)]})}function hn({sessionId:e,useArchived:t,useMenuOpenState:n,useShortcuts:r,archiveSession:i,unarchiveSession:a,t:c}){let[,l]=n(),u=r(e=>e.find(e=>e.id===`session.archive`)),d=t(t=>t.has(e));return/* @__PURE__ */ (0,s.jsx)(o.MenuItemButton,{shortcut:d?void 0:u,icon:d?/* @__PURE__ */ (0,s.jsx)(o.IconUnarchiveOutlineRegular,{size:16}):/* @__PURE__ */ (0,s.jsx)(o.IconArchiveOutlineRegular,{size:16}),onSelect:()=>{l(!1),(d?a:i)(e)},children:c(d?`menu.unarchiveSession`:`menu.archiveSession`)})}function gn({sessionId:e,useArchived:t,archiveSession:n,unarchiveSession:r,t:i}){let a=t(t=>t.has(e));return/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:i(a?`actions.unarchive`:`actions.archive`),side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:W.iconButton,"aria-label":i(a?`menu.unarchiveSession`:`menu.archiveSession`),onClick:()=>{(a?r:n)(e)},children:a?/* @__PURE__ */ (0,s.jsx)(o.IconUnarchiveOutlineRegular,{size:16}):/* @__PURE__ */ (0,s.jsx)(o.IconArchiveOutlineRegular,{size:16})})})}function _n({useArchiveRequest:e,settleSessionArchive:t,stopAndArchiveSession:n,t:r}){let i=e(e=>e);return i===null?null:/* @__PURE__ */ (0,s.jsx)(vn,{request:i,stopAndArchiveSession:n,onSettle:t,t:r},i.sessionId)}function vn({request:e,stopAndArchiveSession:t,onSettle:n,t:r}){let[i,c]=(0,a.useState)(!1),[l,u]=(0,a.useState)(null),d=()=>{i||n()};return/* @__PURE__ */ (0,s.jsxs)(o.Modal,{phoneSidebar:!0,open:!0,onClose:d,closeLabel:r(`close`),title:r(`archive.confirm.title`),description:r(`archive.confirm.desc`,{title:e.displayTitle}),footer:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,disabled:i,onClick:d,children:r(`cancel`)}),/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,className:$.deleteAction,disabled:i,onClick:()=>{c(!0),u(null),t(e.sessionId).then(()=>{c(!1),n()}).catch(e=>{c(!1),u(e instanceof Error?e.message:String(e))})},children:r(`archive.confirm.action`)})]}),children:[/* @__PURE__ */ (0,s.jsx)(`ul`,{className:$.archiveActivity,"aria-label":r(`archive.confirm.activity`),children:e.activity.map((e,t)=>/* @__PURE__ */ (0,s.jsx)(`li`,{children:yn(e,r)},`${e.kind}-${String(t)}`))}),i&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.deleteStatus,role:`status`,children:r(`archive.confirm.pending`)}),l!==null&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.renameError,role:`alert`,children:l})]})}function yn(e,t){let n=e.items??[],r=n.length,i=n.map(e=>e.label??e.id).join(t(`archive.confirm.listSeparator`)),a=r===1?`one`:`other`;switch(e.kind){case`turn`:return t(`archive.confirm.turn`);case`subagent`:return t(`archive.confirm.subagents.${a}`,{n:r,names:i});case`job`:return t(`archive.confirm.jobs.${a}`,{n:r,names:i});case`schedule`:return t(`archive.confirm.schedules.${a}`,{n:r,names:i});default:return t(`archive.confirm.other.${a}`,{kind:e.kind,n:r})}}function bn(e,t){let n,r;return{getSnapshot:()=>{let i=e.getSnapshot();return(r===void 0||i!==n)&&(n=i,r=t(i)),r},subscribe:t=>e.subscribe(t)}}function xn({sessionId:e,useMenuOpenState:t,useShortcuts:n,forkSession:r,t:i}){let[,a]=t(),c=n(e=>e.find(e=>e.id===`session.fork`));return/* @__PURE__ */ (0,s.jsx)(o.MenuItemButton,{shortcut:c,icon:/* @__PURE__ */ (0,s.jsx)(o.IconBranchOutlineRegular,{}),onSelect:()=>{a(!1),r(e)},children:i(`menu.fork`)})}function Sn({sessionId:e,useSessions:t,useMenuOpenState:n,copySessionLink:r,t:i}){let a=t(t=>{let n=t.byId[e];return n!==void 0&&y(n)!==void 0}),[,c]=n();return a?/* @__PURE__ */ (0,s.jsx)(o.MenuItemButton,{icon:/* @__PURE__ */ (0,s.jsx)(o.IconCopyOutlineRegular,{}),onSelect:()=>{c(!1),r(e)},children:i(`menu.copySessionLink`)}):null}function Cn({sessionId:e,usePinned:t,useArchived:n}){return{pinned:t(t=>t.has(e)),archived:n(t=>t.has(e))}}function wn(e){let{sessionId:t,useMenuOpenState:n,pinSession:r,unpinSession:i,t:a}=e,[,c]=n(),{pinned:l,archived:u}=Cn(e);return u?null:/* @__PURE__ */ (0,s.jsx)(o.MenuItemButton,{icon:l?/* @__PURE__ */ (0,s.jsx)(o.IconPinFillRegular,{}):/* @__PURE__ */ (0,s.jsx)(o.IconPinOutlineRegular,{}),onSelect:()=>{c(!1),(l?i:r)(t)},children:a(l?`menu.unpinSession`:`menu.pinSession`)})}function Tn(e){let{sessionId:t,pinSession:n,unpinSession:r,t:i}=e,{pinned:a,archived:c}=Cn(e);return c?null:/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:i(a?`actions.unpin`:`actions.pin`),side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:W.iconButton,"aria-label":i(a?`menu.unpinSession`:`menu.pinSession`),onClick:()=>{(a?r:n)(t)},children:a?/* @__PURE__ */ (0,s.jsx)(o.IconPinFillRegular,{size:16}):/* @__PURE__ */ (0,s.jsx)(o.IconPinOutlineRegular,{size:16})})})}function En({sessionId:e,displayTitle:t,useMenuOpenState:n,useShortcuts:r,requestSessionRename:i,t:a}){let[,c]=n(),l=r(e=>e.find(e=>e.id===`session.rename`));return/* @__PURE__ */ (0,s.jsx)(o.MenuItemButton,{shortcut:l,icon:/* @__PURE__ */ (0,s.jsx)(o.IconEditOutlineRegular,{}),onSelect:()=>{c(!1),i(e,t)},children:a(`rename`)})}function Dn({useRenameRequest:e,settleSessionRename:t,renameSession:n,t:r}){let i=e(e=>e);return i===null?null:/* @__PURE__ */ (0,s.jsx)(On,{request:i,renameSession:n,onSettle:t,t:r},i.sessionId)}function On({request:e,renameSession:t,onSettle:n,t:r}){let[i,c]=(0,a.useState)(e.currentTitle),[l,u]=(0,a.useState)(!1),[d,f]=(0,a.useState)(null),p=(0,a.useRef)(!1),m=i.trim(),h=l||m===``,g=()=>{l||n()},_=()=>{h||(u(!0),f(null),t(e.sessionId,m).then(()=>{u(!1),n()}).catch(e=>{u(!1),f(e instanceof Error?e.message:String(e))}))};return/* @__PURE__ */ (0,s.jsxs)(o.Modal,{phoneSidebar:!0,open:!0,onClose:g,closeLabel:r(`close`),title:r(`rename.session.title`),footer:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,disabled:l,onClick:g,children:r(`cancel`)}),/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`primary`,disabled:h,onClick:_,children:r(`rename`)})]}),children:[/* @__PURE__ */ (0,s.jsx)(`input`,{className:$.renameInput,value:i,"aria-label":r(`field.sessionName`),"data-modal-autofocus":!0,disabled:l,onFocus:e=>{e.target.select()},onChange:e=>{c(e.target.value),f(null)},onCompositionStart:()=>{p.current=!0},onCompositionEnd:()=>{p.current=!1},onKeyDown:e=>{e.key===`Enter`&&!p.current&&(e.preventDefault(),_())}}),d!==null&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.renameError,role:`alert`,children:d})]})}let kn=6e3;function An({useToast:e,useStore:t,dismissToast:n,undoArchive:r,showArchived:i,t:a}){let c=e(e=>e),l=t(e=>(e.archivedFilter??`default`)!=="default");if(c===null)return null;if(c.kind===`archived`||c.kind===`stoppedAndArchived`){let{sessionId:e}=c;return/* @__PURE__ */ (0,s.jsx)(o.Toast,{text:a(c.kind===`archived`?`toast.archived`:`toast.stoppedAndArchived`),tone:`success`,holdMs:kn,actions:[{label:a(`toast.archivedUndo`),onClick:()=>{n(),r(e)}},...l?[]:[{prefix:a(`toast.archivedOr`),label:a(`toast.archivedFilter`),onClick:()=>{n(),i()}}]],onDone:n},`toast-${String(c.seq)}`)}return c.kind===`createFailed`||c.kind===`forkFailed`?/* @__PURE__ */ (0,s.jsx)(o.Toast,{text:a(c.kind===`forkFailed`?`toast.forkFailed`:`toast.createFailed`,{message:c.message}),icon:/* @__PURE__ */ (0,s.jsx)(o.IconWarningOutlineRegular,{}),holdMs:kn,onDone:n},`toast-${String(c.seq)}`):/* @__PURE__ */ (0,s.jsx)(o.Toast,{text:jn(c,a),icon:/* @__PURE__ */ (0,s.jsx)(o.IconWarningOutlineRegular,{}),onDone:n},`toast-${String(c.seq)}`)}function jn(e,t){switch(e.kind){case`archiveFailed`:return t(`toast.archiveFailed`,{message:e.message});case`unarchiveFailed`:return t(`toast.unarchiveFailed`,{message:e.message});case`pinFailed`:return t(`toast.pinFailed`,{message:e.message});case`unpinFailed`:return t(`toast.unpinFailed`,{message:e.message});case`defaultWorkspaceFailed`:return t(`defaultWorkspace.failed`);case`archivedNotOpenable`:return t(`toast.archivedNotOpenable`);case`sessionLinkCopied`:return t(`toast.sessionLinkCopied`);case`sessionLinkCopyFailed`:return t(`toast.sessionLinkCopyFailed`);case`recentVisitsStorageFailed`:return t(`recent.cache.error`);
21
+ ut||ct===null||(dt(!0),pt(null),ht(null),g(ct.workspaceId).then(()=>{pt(ct.workspaceId)}).catch(e=>{dt(!1),ht(e instanceof Error?e.message:String(e))}))};return/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q($.root,!e&&$.rail),children:[/* @__PURE__ */ (0,s.jsxs)(`div`,{className:$.sectionHeader,children:[e&&/* @__PURE__ */ (0,s.jsx)(`span`,{className:Q($.sectionLabel,$.wide,Fe&&$.sectionLabelHidden),children:F(`section.sessions`)}),e&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:Q($.searchSlot,Fe&&$.searchSlotExpanded),children:/* @__PURE__ */ (0,s.jsxs)(`div`,{ref:q,className:Q($.search,Fe&&$.searchExpanded),onClick:()=>{O(),Ie(!0),He.current?.focus()},children:[/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:F(`search`),shortcutKeys:I?.keys,side:`bottom`,delayMs:500,disabled:Fe,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:$.searchButton,"aria-label":F(`search.sessions.aria`),"aria-keyshortcuts":I?.aria,"aria-expanded":Fe,onClick:()=>{E()},children:/* @__PURE__ */ (0,s.jsx)(o.IconSearchOutlineRegular,{size:16})})}),/* @__PURE__ */ (0,s.jsx)(`input`,{ref:He,className:$.searchInput,type:`text`,placeholder:F(`search.placeholder`),maxLength:500,value:K,tabIndex:Fe?0:-1,onChange:e=>{Pe(Vn(e.target.value))},onKeyDown:e=>{e.key===`Escape`&&(e.currentTarget.closest(`[data-phone-drawer]`)&&(e.preventDefault(),e.stopPropagation()),Pe(``),Ie(!1))}}),Fe&&/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:$.clearButton,"aria-label":F(`search.clear`),onClick:e=>{e.stopPropagation(),Pe(``),Ie(!1)},children:/* @__PURE__ */ (0,s.jsx)(o.IconCloseFillRegular,{})})]})}),/* @__PURE__ */ (0,s.jsxs)(`div`,{className:Q($.headerActions,e&&Fe&&$.headerActionsHidden),children:[e&&/* @__PURE__ */ (0,s.jsx)(Un,{groupBy:pe,orderBy:H,archivedFilter:ge,onGroupPick:u.setGroupBy,onOrderPick:e=>{u.setOrderBy(e,Me,G)},onArchivedFilterPick:u.setArchivedFilter,t:F}),V&&/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:F(`workspace.add`),shortcutKeys:ie?.keys,side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,s.jsx)(`button`,{ref:We,type:`button`,className:$.iconButton,"aria-label":F(`workspace.add`),"aria-keyshortcuts":ie?.aria,onClick:()=>{D()},children:/* @__PURE__ */ (0,s.jsx)(o.IconProjectAddOutlineRegular,{size:e?16:18})})})]}),/* @__PURE__ */ (0,s.jsx)(zn,{t:F,open:Ue,anchorRef:We,useWorkspaces:c,createWorkspace:y,useDirectoryFlow:S,renderDirectoryFlow:e=>te(`sidebar.workspaces.directoryFlow`,e),addOnly:!0,onBusyChange:M,side:`right`,onPick:e=>{O(),d(e)},onClose:()=>{O()}})]}),!e&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.search,children:/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:F(`search`),shortcutKeys:I?.keys,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:$.searchButton,"aria-label":F(`search.sessions.aria`),"aria-keyshortcuts":I?.aria,onClick:()=>{E()},children:/* @__PURE__ */ (0,s.jsx)(o.IconSearchOutlineRegular,{size:18})})})}),/* @__PURE__ */ (0,s.jsxs)(`div`,{className:$.listArea,children:[e&&R.phase===`pending`&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.empty,role:`status`,children:F(`sessions.loading`)}),e&&(ze===``?pe===`flat`?/* @__PURE__ */ (0,s.jsx)(Jn,{loadMoreSessions:P,usePanelInfo:t,list:R,sessionIds:je,rowState:De,onLeaveArchivedOnly:Se,workspaceReady:Ce,animationResetKey:`${pe}/${H}/${ge}`,useSessionStatus:i,open:xe,onSessionRenameRequest:p,renderSlot:te,setSessionOrder:Ne,sectionExpansion:ye,setSectionExpanded:u.setSectionExpanded,revealSessionId:Le,onSessionRevealed:qe,t:F}):/* @__PURE__ */ (0,s.jsx)(qn,{loadMoreSessions:P,usePanelInfo:t,list:R,shortcuts:re,useSessionStatus:i,onSessionRenameRequest:p,renderSlot:te,workspaces:ke,ungroupedSessionIds:Ae,canStartProjectless:oe,workspaceReady:Ce,nestWorkspaces:pe===`workspace-tree`,animationResetKey:`${pe}/${H}/${ge}`,groupExpansion:_e,setGroupExpanded:u.setGroupExpanded,sectionExpansion:ye,setSectionExpanded:u.setSectionExpanded,setSessionOrder:Ne,rowState:De,onLeaveArchivedOnly:Se,startSession:d,open:xe,insertWorkspaceBefore:_,revealSessionId:Le,onSessionRevealed:qe,home:ne,t:F,onRenameRequest:(e,t)=>{Ze({workspaceId:e,storedTitle:ae.find(t=>t.workspaceId===e)?.title??t}),$e(t),rt(null)},onDeleteRequest:(e,t)=>{lt({workspaceId:e,title:t}),ht(null)}}):/* @__PURE__ */ (0,s.jsx)(Yn,{usePanelInfo:t,useSessions:r,useSessionStatus:i,open:Ke,onUnarchive:st,workspaces:B,archivedSessionIds:de,archivedFilter:ge,query:ze,remote:Be,resultLimit:x,t:F}))]}),e&&/* @__PURE__ */ (0,s.jsx)(jn,{list:R,refreshSessions:ee,loadMoreSessions:P,t:F}),/* @__PURE__ */ (0,s.jsxs)(o.Modal,{open:Xe!==null,onClose:at,closeLabel:F(`close`),title:F(`rename.workspace.title`),footer:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,disabled:et,onClick:at,children:F(`cancel`)}),/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`primary`,disabled:Y,onClick:ot,children:F(`rename`)})]}),children:[/* @__PURE__ */ (0,s.jsx)(`input`,{className:$.renameInput,value:Qe,"aria-label":F(`field.workspaceName`),"data-modal-autofocus":!0,disabled:et,onFocus:e=>{e.target.select()},onChange:e=>{$e(e.target.value),rt(null)},onCompositionStart:()=>{Ge.current=!0},onCompositionEnd:()=>{Ge.current=!1},onKeyDown:e=>{e.key===`Enter`&&!Ge.current&&(e.preventDefault(),ot())}}),J&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.renameError,role:`alert`,children:F(`conflict.named`,{name:it})}),nt!==null&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.renameError,role:`alert`,children:nt})]}),/* @__PURE__ */ (0,s.jsxs)(o.Modal,{open:ct!==null,onClose:gt,closeLabel:F(`close`),title:F(`delete.workspace`),...ct===null?{}:{description:F(`delete.desc`,{name:ct.title})},footer:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,disabled:ut,onClick:gt,children:F(`cancel`)}),/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,className:$.deleteAction,disabled:ut,onClick:X,children:F(`delete.workspace`)})]}),children:[ut&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.deleteStatus,role:`status`,children:F(`delete.pending`)}),mt!==null&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.renameError,role:`alert`,children:mt})]}),L.forkError!==null&&/* @__PURE__ */ (0,s.jsx)(o.Toast,{text:F(L.forkError.reason===`unavailable`?`shortcut.noCompletedTurn`:`shortcut.forkFailed`),onDone:N},L.forkError.seq)]})}function Qn({sessionId:e,useArchived:t,useMenuOpenState:n,useShortcuts:r,archiveSession:i,unarchiveSession:a,t:c}){let[,l]=n(),u=r(e=>e.find(e=>e.id===`session.archive`)),d=t(t=>t.has(e));return/* @__PURE__ */ (0,s.jsx)(o.MenuItemButton,{shortcut:d?void 0:u,icon:d?/* @__PURE__ */ (0,s.jsx)(o.IconUnarchiveOutlineRegular,{size:16}):/* @__PURE__ */ (0,s.jsx)(o.IconArchiveOutlineRegular,{size:16}),onSelect:()=>{l(!1),(d?a:i)(e)},children:c(d?`menu.unarchiveSession`:`menu.archiveSession`)})}function $n({sessionId:e,useArchived:t,archiveSession:n,unarchiveSession:r,t:i}){let a=t(t=>t.has(e));return/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:i(a?`actions.unarchive`:`actions.archive`),side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:K.iconButton,"aria-label":i(a?`menu.unarchiveSession`:`menu.archiveSession`),onClick:()=>{(a?r:n)(e)},children:a?/* @__PURE__ */ (0,s.jsx)(o.IconUnarchiveOutlineRegular,{size:16}):/* @__PURE__ */ (0,s.jsx)(o.IconArchiveOutlineRegular,{size:16})})})}function er({useArchiveRequest:e,settleSessionArchive:t,stopAndArchiveSession:n,t:r}){let i=e(e=>e);return i===null?null:/* @__PURE__ */ (0,s.jsx)(tr,{request:i,stopAndArchiveSession:n,onSettle:t,t:r},i.sessionId)}function tr({request:e,stopAndArchiveSession:t,onSettle:n,t:r}){let[i,c]=(0,a.useState)(!1),[l,u]=(0,a.useState)(null),d=()=>{i||n()};return/* @__PURE__ */ (0,s.jsxs)(o.Modal,{phoneSidebar:!0,open:!0,onClose:d,closeLabel:r(`close`),title:r(`archive.confirm.title`),description:r(`archive.confirm.desc`,{title:e.displayTitle}),footer:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,disabled:i,onClick:d,children:r(`cancel`)}),/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,className:$.deleteAction,disabled:i,onClick:()=>{c(!0),u(null),t(e.sessionId).then(()=>{c(!1),n()}).catch(e=>{c(!1),u(e instanceof Error?e.message:String(e))})},children:r(`archive.confirm.action`)})]}),children:[/* @__PURE__ */ (0,s.jsxs)(`ul`,{className:$.archiveActivity,"aria-label":r(`archive.confirm.activity`),children:[e.runningThreads?.map(e=>/* @__PURE__ */ (0,s.jsx)(`li`,{children:r(`archive.confirm.thread`,{title:e.title})},e.id)),e.activity.map((e,t)=>/* @__PURE__ */ (0,s.jsx)(`li`,{children:nr(e,r)},`${e.kind}-${String(t)}`))]}),i&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.deleteStatus,role:`status`,children:r(`archive.confirm.pending`)}),l!==null&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.renameError,role:`alert`,children:l})]})}function nr(e,t){let n=e.items??[],r=n.length,i=n.map(e=>e.label??e.id).join(t(`archive.confirm.listSeparator`)),a=r===1?`one`:`other`;switch(e.kind){case`turn`:return t(`archive.confirm.turn`);case`subagent`:return t(`archive.confirm.subagents.${a}`,{n:r,names:i});case`job`:return t(`archive.confirm.jobs.${a}`,{n:r,names:i});case`schedule`:return t(`archive.confirm.schedules.${a}`,{n:r,names:i});default:return t(`archive.confirm.other.${a}`,{kind:e.kind,n:r})}}function rr(e,t){let n,r;return{getSnapshot:()=>{let i=e.getSnapshot();return(r===void 0||i!==n)&&(n=i,r=t(i)),r},subscribe:t=>e.subscribe(t)}}function ir({sessionId:e,useMenuOpenState:t,useShortcuts:n,forkSession:r,t:i}){let[,a]=t(),c=n(e=>e.find(e=>e.id===`session.fork`));return/* @__PURE__ */ (0,s.jsx)(o.MenuItemButton,{shortcut:c,icon:/* @__PURE__ */ (0,s.jsx)(o.IconBranchOutlineRegular,{}),onSelect:()=>{a(!1),r(e)},children:i(`menu.fork`)})}function ar({sessionId:e,useSessions:t,useMenuOpenState:n,copySessionLink:r,t:i}){let a=t(t=>{let n=t.byId[e];return n!==void 0&&x(n)!==void 0}),[,c]=n();return a?/* @__PURE__ */ (0,s.jsx)(o.MenuItemButton,{icon:/* @__PURE__ */ (0,s.jsx)(o.IconCopyOutlineRegular,{}),onSelect:()=>{c(!1),r(e)},children:i(`menu.copySessionLink`)}):null}function or({sessionId:e,usePinned:t,useArchived:n}){return{pinned:t(t=>t.has(e)),archived:n(t=>t.has(e))}}function sr(e){let{sessionId:t,useMenuOpenState:n,pinSession:r,unpinSession:i,t:a}=e,[,c]=n(),{pinned:l,archived:u}=or(e);return u?null:/* @__PURE__ */ (0,s.jsx)(o.MenuItemButton,{icon:l?/* @__PURE__ */ (0,s.jsx)(o.IconPinFillRegular,{}):/* @__PURE__ */ (0,s.jsx)(o.IconPinOutlineRegular,{}),onSelect:()=>{c(!1),(l?i:r)(t)},children:a(l?`menu.unpinSession`:`menu.pinSession`)})}function cr(e){let{sessionId:t,pinSession:n,unpinSession:r,t:i}=e,{pinned:a,archived:c}=or(e);return c?null:/* @__PURE__ */ (0,s.jsx)(o.Tooltip,{label:i(a?`actions.unpin`:`actions.pin`),side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,s.jsx)(`button`,{type:`button`,className:K.iconButton,"aria-label":i(a?`menu.unpinSession`:`menu.pinSession`),onClick:()=>{(a?r:n)(t)},children:a?/* @__PURE__ */ (0,s.jsx)(o.IconPinFillRegular,{size:16}):/* @__PURE__ */ (0,s.jsx)(o.IconPinOutlineRegular,{size:16})})})}function lr({sessionId:e,displayTitle:t,useMenuOpenState:n,useShortcuts:r,requestSessionRename:i,t:a}){let[,c]=n(),l=r(e=>e.find(e=>e.id===`session.rename`));return/* @__PURE__ */ (0,s.jsx)(o.MenuItemButton,{shortcut:l,icon:/* @__PURE__ */ (0,s.jsx)(o.IconEditOutlineRegular,{}),onSelect:()=>{c(!1),i(e,t)},children:a(`rename`)})}function ur({useRenameRequest:e,settleSessionRename:t,renameSession:n,t:r}){let i=e(e=>e);return i===null?null:/* @__PURE__ */ (0,s.jsx)(dr,{request:i,renameSession:n,onSettle:t,t:r},i.sessionId)}function dr({request:e,renameSession:t,onSettle:n,t:r}){let[i,c]=(0,a.useState)(e.currentTitle),[l,u]=(0,a.useState)(!1),[d,f]=(0,a.useState)(null),p=(0,a.useRef)(!1),m=i.trim(),h=l||m===``,g=()=>{l||n()},_=()=>{h||(u(!0),f(null),t(e.sessionId,m).then(()=>{u(!1),n()}).catch(e=>{u(!1),f(e instanceof Error?e.message:String(e))}))};return/* @__PURE__ */ (0,s.jsxs)(o.Modal,{phoneSidebar:!0,open:!0,onClose:g,closeLabel:r(`close`),title:r(`rename.session.title`),footer:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`outline`,disabled:l,onClick:g,children:r(`cancel`)}),/* @__PURE__ */ (0,s.jsx)(o.Button,{variant:`primary`,disabled:h,onClick:_,children:r(`rename`)})]}),children:[/* @__PURE__ */ (0,s.jsx)(`input`,{className:$.renameInput,value:i,"aria-label":r(`field.sessionName`),"data-modal-autofocus":!0,disabled:l,onFocus:e=>{e.target.select()},onChange:e=>{c(e.target.value),f(null)},onCompositionStart:()=>{p.current=!0},onCompositionEnd:()=>{p.current=!1},onKeyDown:e=>{e.key===`Enter`&&!p.current&&(e.preventDefault(),_())}}),d!==null&&/* @__PURE__ */ (0,s.jsx)(`div`,{className:$.renameError,role:`alert`,children:d})]})}let fr=6e3;function pr({useToast:e,useStore:t,dismissToast:n,undoArchive:r,showArchived:i,t:a}){let c=e(e=>e),l=t(e=>(e.archivedFilter??`default`)!=="default");if(c===null)return null;if(c.kind===`archived`||c.kind===`stoppedAndArchived`){let{sessionId:e}=c;return/* @__PURE__ */ (0,s.jsx)(o.Toast,{text:a(c.kind===`archived`?`toast.archived`:`toast.stoppedAndArchived`),tone:`success`,holdMs:fr,actions:[{label:a(`toast.archivedUndo`),onClick:()=>{n(),r(e)}},...l?[]:[{prefix:a(`toast.archivedOr`),label:a(`toast.archivedFilter`),onClick:()=>{n(),i()}}]],onDone:n},`toast-${String(c.seq)}`)}return c.kind===`createFailed`||c.kind===`forkFailed`?/* @__PURE__ */ (0,s.jsx)(o.Toast,{text:a(c.kind===`forkFailed`?`toast.forkFailed`:`toast.createFailed`,{message:c.message}),icon:/* @__PURE__ */ (0,s.jsx)(o.IconWarningOutlineRegular,{}),holdMs:fr,onDone:n},`toast-${String(c.seq)}`):/* @__PURE__ */ (0,s.jsx)(o.Toast,{text:mr(c,a),icon:/* @__PURE__ */ (0,s.jsx)(o.IconWarningOutlineRegular,{}),onDone:n},`toast-${String(c.seq)}`)}function mr(e,t){switch(e.kind){case`archiveFailed`:return t(`toast.archiveFailed`,{message:e.message});case`unarchiveFailed`:return t(`toast.unarchiveFailed`,{message:e.message});case`pinFailed`:return t(`toast.pinFailed`,{message:e.message});case`unpinFailed`:return t(`toast.unpinFailed`,{message:e.message});case`defaultWorkspaceFailed`:return t(`defaultWorkspace.failed`);case`archivedNotOpenable`:return t(`toast.archivedNotOpenable`);case`sessionLinkCopied`:return t(`toast.sessionLinkCopied`);case`sessionLinkCopyFailed`:return t(`toast.sessionLinkCopyFailed`);case`recentVisitsStorageFailed`:return t(`recent.cache.error`);
22
22
  /* v8 ignore next 2 -- closed-union backstop; only reached if a notice kind is forged */
23
- default:return h(e)}}let Mn={"host.local":`本机`,"host.connected":`已连接`,"host.connecting":`连接中`,"host.disconnected":`未连接`,"defaultWorkspace.failed":`无法创建默认工作区,请通过“选择工作区”选择文件夹`,"draft.workspaceRequired":`请先选择工作区`,"draft.initializationFailed":`暂时无法填入草稿,请稍后重试`,"recent.navigation":`会话标签`,"recent.expand":`展开会话标签栏`,"recent.collapse":`收起会话标签栏`,"recent.settings.title":`显示会话标签`,"recent.settings.mobile":`移动端`,"recent.settings.description":`在手机会话顶部显示可关闭的标签栏。`,"recent.settings.error":`无法在此浏览器中保存设置,已保留原设置。`,"recent.timeout.title":`自动关闭闲置标签`,"recent.timeout.off":`不自动关闭`,"recent.timeout.minutes":`{n} 分钟`,"recent.timeout.hours":`{n} 小时`,"recent.timeout.default":`{value}(默认)`,"recent.close":`关闭标签“{name}”`,"recent.closeHint":`仅关闭标签,不删除会话或停止任务`,"recent.closeFailed":`未能关闭标签,请重试。`,"recent.clear":`清空`,"recent.clearAll":`清空所有会话标签`,"recent.clearAllHint":`关闭所有标签,不删除会话或停止任务`,"recent.cache.error":`无法读取或保存会话标签。仍可在本页切换会话,刷新后标签可能丢失。`,"group.ungrouped":`最近`,"session.new":`新会话`,"session.untitled":`未命名`,"session.backToList":`返回会话列表`,"shortcut.noSession":`请先选择一个会话`,"shortcut.noPicker":`目录选择器不可用`,"shortcut.directoryBusy":`正在选择或添加工作区`,"shortcut.noCompletedTurn":`当前会话没有已结束的轮次`,"shortcut.forkFailed":`无法分叉会话,请重试`,"section.workspaces":`工作区`,"section.sessions":`会话`,"section.pinned":`置顶`,"viewOptions.label":`视图选项`,"groupBy.label":`分组方式`,"groupBy.workspace":`按工作区`,"groupBy.workspaceTree":`按工作区树`,"groupBy.flat":`单列表`,"orderBy.label":`排序方式`,"orderBy.manual":`手动排序`,"orderBy.updated":`最近更新`,"filterBy.label":`筛选会话`,"viewOptions.hideArchived":`隐藏已归档`,"viewOptions.showArchived":`全部对话(显示已归档)`,"viewOptions.onlyArchived":`仅显示已归档`,"sessions.expand":`展开显示`,"sessions.collapse":`收起`,"sessions.loading":`正在加载历史会话…`,"sessions.expandMore":`展开显示`,"sessions.retry":`重试`,"sessions.notLoaded":`已加载的会话中暂无匹配项,可按需加载更早会话`,"workspaces.expand":`展开显示`,"empty.none":`暂无会话`,"empty.noneArchived":`暂无已归档会话`,"empty.viewOthers":`查看其他会话`,"empty.noMatches":`无匹配结果`,"workspace.add":`添加工作区`,"search.sessions.aria":`搜索会话`,"search.placeholder":`搜索会话名称`,"search.clear":`清除搜索`,"search.results.aria":`搜索结果`,"search.pending":`正在搜索会话历史…`,"search.noMatches":`无匹配会话`,"search.hasMore":`仅显示前 {n} 条结果,请缩小搜索范围。`,"menu.addWorkspace":`添加工作区…`,"menu.noWorkspace":`不选择工作区`,"picker.loading":`正在加载工作区…`,"conflict.named":`已存在名为“{name}”的工作区。`,"folderError.title":`无法打开文件夹`,"folderError.retry":`重新选择`,rename:`重命名`,"rename.workspace.title":`重命名工作区`,"rename.session.title":`重命名会话`,"field.workspaceName":`工作区名称`,"field.sessionName":`会话名称`,"delete.workspace":`删除工作区`,"delete.desc":`将把“{name}”从工作区列表中移除。文件夹与会话记录会保留,其会话将显示在“未分组”下。`,"delete.pending":`正在删除工作区…`,"menu.copySessionLink":`复制会话链接`,"menu.referenceSession":`引用会话`,"menu.referenceSessionFailed":`未加入草稿:编辑位置或会话已失效`,"toast.sessionLinkCopied":`已复制`,"toast.sessionLinkCopyFailed":`复制会话链接失败`,"menu.fork":`分叉会话`,"menu.archiveSession":`归档会话`,"menu.unarchiveSession":`取消归档`,"menu.pinSession":`置顶会话`,"menu.unpinSession":`取消置顶`,"row.archived":`已归档`,"row.pinned":`已置顶`,"toast.archivedNotOpenable":`已归档对话暂时无法查看,请取消归档后查看`,"toast.archived":`会话已归档,可`,"toast.stoppedAndArchived":`已停止并归档,可`,"archive.confirm.title":`停止并归档此会话?`,"archive.confirm.desc":`“{title}”仍有正在进行的工作。归档会先停止这些工作;之后可在侧栏筛选“全部对话(显示已归档)”中恢复会话,被停止的工作不会自动继续。`,"archive.confirm.activity":`将被停止的工作`,"archive.confirm.turn":`进行中的回合`,"archive.confirm.subagents.one":`{n} 个运行中的子智能体:{names}`,"archive.confirm.subagents.other":`{n} 个运行中的子智能体:{names}`,"archive.confirm.jobs.one":`{n} 个后台任务:{names}`,"archive.confirm.jobs.other":`{n} 个后台任务:{names}`,"archive.confirm.schedules.one":`{n} 条定时提醒:{names}`,"archive.confirm.schedules.other":`{n} 条定时提醒:{names}`,"archive.confirm.other.one":`{n} 项其他工作({kind})`,"archive.confirm.other.other":`{n} 项其他工作({kind})`,"archive.confirm.listSeparator":`、`,"archive.confirm.action":`停止并归档`,"archive.confirm.pending":`正在停止并归档…`,"toast.archivedUndo":`撤销`,"toast.archivedOr":`或`,"toast.archivedFilter":`筛选已归档会话`,"toast.archiveFailed":`归档未确认,请检查会话状态:{message}`,"toast.unarchiveFailed":`取消归档未确认,请刷新后检查:{message}`,"toast.pinFailed":`置顶未确认,请刷新后检查:{message}`,"toast.unpinFailed":`取消置顶未确认,请刷新后检查:{message}`,"toast.createFailed":`新建会话失败:{message}`,"toast.forkFailed":`分叉未完成:{message}`,"sessions.count.one":`{n} 个会话`,"sessions.count.other":`{n} 个会话`,"actions.workspace.aria":`工作区“{name}”的操作`,"actions.session.aria":`会话“{name}”的操作`,"actions.archive":`归档会话`,"actions.unarchive":`取消归档`,"actions.pin":`置顶会话`,"actions.unpin":`取消置顶`,"actions.newSession":`新会话`,"actions.newSession.aria":`在“{name}”中新建会话`,"status.running":`进行中`,"status.subagentsRunning.one":`{n} 个子智能体运行中`,"status.subagentsRunning.other":`{n} 个子智能体运行中`,"status.idle":`空闲`,"status.waitingApproval":`等待审批`,"status.planReview":`计划待审`,"status.waitingAnswer":`等待回答`,"status.compact.approval":`待审批`,"status.compact.planReview":`计划待审`,"status.compact.answer":`待回答`,"status.completed":`已完成`,"hover.created":`创建于 {time}`,"hover.copied":`已复制`,"date.ymd":`{y}年{m}月{d}日`,"time.now":`刚刚`,"time.minutes":`{n}分钟`,"time.hours":`{n}小时`,"time.days":`{n}天`,"time.months":`{n}个月`,"time.years":`{n}年`,"time.ago":`{t}前`},Nn={"host.local":`Local`,"host.connected":`Connected`,"host.connecting":`Connecting`,"host.disconnected":`Disconnected`,"defaultWorkspace.failed":`Unable to create default workspace. Use Choose workspace to select a folder.`,"draft.workspaceRequired":`Choose a workspace first.`,"draft.initializationFailed":`Could not fill the draft. Please try again shortly.`,"recent.navigation":`Session tabs`,"recent.expand":`Expand session tabs`,"recent.collapse":`Collapse session tabs`,"recent.settings.title":`Show session tabs`,"recent.settings.mobile":`Mobile`,"recent.settings.description":`Show closable tabs above phone conversations.`,"recent.settings.error":`Could not save in this browser. The previous setting is unchanged.`,"recent.timeout.title":`Automatically close idle tabs`,"recent.timeout.off":`Never`,"recent.timeout.minutes":`{n} minutes`,"recent.timeout.hours":`{n} hours`,"recent.timeout.default":`{value} (default)`,"recent.close":`Close tab “{name}”`,"recent.closeHint":`Close only this tab, without deleting the session or stopping tasks`,"recent.closeFailed":`Could not close the tab. Please try again.`,"recent.clear":`Clear`,"recent.clearAll":`Clear all session tabs`,"recent.clearAllHint":`Close all tabs without deleting sessions or stopping tasks`,"recent.cache.error":`Could not read or save session tabs. Switching still works in this page; tabs may be lost on reload.`,"group.ungrouped":`Recents`,"session.new":`New Session`,"session.untitled":`Untitled`,"session.backToList":`Back to session list`,"shortcut.noSession":`Select a session first`,"shortcut.noPicker":`Directory picker unavailable`,"shortcut.directoryBusy":`Selecting or adding a workspace`,"shortcut.noCompletedTurn":`This session has no completed turn`,"shortcut.forkFailed":`Could not fork the session. Try again.`,"section.workspaces":`Workspaces`,"section.sessions":`Sessions`,"section.pinned":`Pinned`,"viewOptions.label":`View options`,"groupBy.label":`Group by`,"groupBy.workspace":`WorkSpace`,"groupBy.workspaceTree":`Workspace Tree`,"groupBy.flat":`In one list`,"orderBy.label":`Order by`,"orderBy.manual":`Manual`,"orderBy.updated":`Last updated`,"filterBy.label":`Filter sessions`,"viewOptions.hideArchived":`Hide archived`,"viewOptions.showArchived":`All conversations (show archived)`,"viewOptions.onlyArchived":`Archived only`,"sessions.expand":`Show {n} more`,"sessions.collapse":`Show less`,"sessions.loading":`Loading conversation history…`,"sessions.expandMore":`Show more`,"sessions.retry":`Retry`,"sessions.notLoaded":`No matching loaded conversations. Older conversations can be loaded on demand.`,"workspaces.expand":`Show all workspaces`,"empty.none":`No sessions yet`,"empty.noneArchived":`No archived sessions yet`,"empty.viewOthers":`View other sessions`,"empty.noMatches":`No matches`,"workspace.add":`Add workspace`,"search.sessions.aria":`Search sessions`,"search.placeholder":`Search session names`,"search.clear":`Clear search`,"search.results.aria":`Search results`,"search.pending":`Searching session history…`,"search.noMatches":`No matching sessions`,"search.hasMore":`Showing the first {n} results. Narrow your search.`,"menu.addWorkspace":`Add workspace…`,"menu.noWorkspace":`No workspace`,"picker.loading":`Loading workspaces…`,"conflict.named":`A workspace named “{name}” already exists.`,"folderError.title":`Couldn’t open folder`,"folderError.retry":`Choose again`,rename:`Rename`,"rename.workspace.title":`Rename workspace`,"rename.session.title":`Rename session`,"field.workspaceName":`Workspace name`,"field.sessionName":`Session name`,"delete.workspace":`Delete workspace`,"delete.desc":`This removes “{name}” from the workspace list. The folder and session logs will be kept. Its sessions will appear under Ungrouped.`,"delete.pending":`Deleting workspace…`,"menu.copySessionLink":`Copy session link`,"menu.referenceSession":`Reference session`,"menu.referenceSessionFailed":`Not added: the editing position or session is no longer available`,"toast.sessionLinkCopied":`Copied`,"toast.sessionLinkCopyFailed":`Could not copy session link`,"menu.fork":`Fork session`,"menu.archiveSession":`Archive session`,"menu.unarchiveSession":`Unarchive session`,"menu.pinSession":`Pin session`,"menu.unpinSession":`Unpin session`,"row.archived":`Archived`,"row.pinned":`Pinned`,"toast.archivedNotOpenable":`Archived sessions cannot be opened. Unarchive it to view.`,"toast.archived":`Session archived. You can `,"toast.stoppedAndArchived":`Session stopped and archived. You can `,"archive.confirm.title":`Stop and archive this session?`,"archive.confirm.desc":`“{title}” still has work in progress. Archiving stops it first; you can restore the session later from the “All conversations (show archived)” filter in the sidebar, and the stopped work will not resume on its own.`,"archive.confirm.activity":`Work that will be stopped`,"archive.confirm.turn":`The turn in progress`,"archive.confirm.subagents.one":`{n} running subagent: {names}`,"archive.confirm.subagents.other":`{n} running subagents: {names}`,"archive.confirm.jobs.one":`{n} background job: {names}`,"archive.confirm.jobs.other":`{n} background jobs: {names}`,"archive.confirm.schedules.one":`{n} scheduled reminder: {names}`,"archive.confirm.schedules.other":`{n} scheduled reminders: {names}`,"archive.confirm.other.one":`{n} other item of work ({kind})`,"archive.confirm.other.other":`{n} other items of work ({kind})`,"archive.confirm.listSeparator":`, `,"archive.confirm.action":`Stop and archive`,"archive.confirm.pending":`Stopping and archiving…`,"toast.archivedUndo":`undo`,"toast.archivedOr":` or `,"toast.archivedFilter":`filter archived sessions`,"toast.archiveFailed":`Archive not confirmed. Check session status: {message}`,"toast.unarchiveFailed":`Unarchive not confirmed. Refresh to check: {message}`,"toast.pinFailed":`Pin not confirmed. Refresh to check: {message}`,"toast.unpinFailed":`Unpin not confirmed. Refresh to check: {message}`,"toast.createFailed":`New session failed: {message}`,"toast.forkFailed":`Fork did not complete: {message}`,"sessions.count.one":`{n} session`,"sessions.count.other":`{n} sessions`,"actions.workspace.aria":`Workspace actions for {name}`,"actions.session.aria":`Session actions for {name}`,"actions.archive":`Archive`,"actions.unarchive":`Unarchive`,"actions.pin":`Pin`,"actions.unpin":`Unpin`,"actions.newSession":`New session`,"actions.newSession.aria":`New session in {name}`,"status.running":`Running`,"status.subagentsRunning.one":`{n} subagent running`,"status.subagentsRunning.other":`{n} subagents running`,"status.idle":`Idle`,"status.waitingApproval":`Waiting for approval`,"status.planReview":`Plan awaiting review`,"status.waitingAnswer":`Waiting for answer`,"status.compact.approval":`Approval`,"status.compact.planReview":`Plan review`,"status.compact.answer":`Answer`,"status.completed":`Completed`,"hover.created":`Created {time}`,"hover.copied":`Copied`,"date.ymd":`{y}-{m}-{d}`,"time.now":`now`,"time.minutes":`{n}min`,"time.hours":`{n}h`,"time.days":`{n}d`,"time.months":`{n}mo`,"time.years":`{n}y`,"time.ago":`{t} ago`},Pn=()=>!1,Fn=()=>()=>{};function In(e){let t=(0,o.usePhoneSidebar)();return t!==null&&!t.open?null:/* @__PURE__ */ (0,s.jsx)(Ln,{...e,closeDrawer:t?.close},e.sessionId)}function Ln({sessionId:e,prepareDraftReference:t,closeDrawer:n,useMenuOpenState:r,t:i}){let[c]=(0,a.useState)(()=>t(e)),l=(0,a.useSyncExternalStore)(c?.subscribe??Fn,c?.getSnapshot??Pn),u=(0,a.useRef)(!1),[d,f]=(0,a.useState)(!1),[,p]=r();return c===void 0?null:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.MenuItemButton,{icon:/* @__PURE__ */ (0,s.jsx)(o.IconLinkOutlineRegular,{}),disabled:d||!l,onSelect:()=>{if(!u.current){u.current=!0;try{if(c?.insert()===!0){p(!1),n?.();return}}catch{}f(!0)}},children:i(`menu.referenceSession`)}),d&&/* @__PURE__ */ (0,s.jsx)(`div`,{role:`status`,children:i(`menu.referenceSessionFailed`)})]})}let Rn=`workspace`,zn=[`slots`,`sessions`,`workspaces`,`locale`,`remote`,`remote.directoryPicker`,`layout`,`shortcuts`,`configForms`];function Bn(e){let t=e.get(`sessions`),n=e.get(`workspaces`),i=z(),a=i.create();a.actions.setArchivedFilter(`default`),e.effect(()=>{let e=()=>{t.setIncludeArchived((a.getSnapshot().archivedFilter??`default`)!=="default")},n=a.subscribe(e);return e(),n},`ui-workspace: browser-local archive query scope`);let o={...i,create:()=>a},s=(0,r.createSnapshotStore)(null),d=0,f=e=>{s.set({...e,seq:++d})},p=new we(e,e.remote.directoryPicker,n,t,a.actions,f);_t(e,p),e.slots.provideRoot({hooks:{workspaces:n.list}}),e.effect(()=>e.locale.register(Rn,{zh:Mn,en:Nn}),`ui-workspace: dictionaries`);let m=l(),h=async(e,n)=>{let r=await t.search(e,n);if(!r.ok)throw Error(r.error.message);return r.value},g=t=>({getSnapshot:()=>e.slots.entries(t).length>0,subscribe:n=>e.slots.subscribe(t,n)}),_=g(`sidebar.workspaces.directoryFlow`),v={getSnapshot:()=>e.remote.$host,subscribe:t=>e.on(`connection/reset`,t)},x=g(`conversation.hero.workspace.directoryFlow`),S=e=>{p.openSession(e)},C=bn(n.list,e=>new Set(e.pinnedSessionIds)),w=bn(n.list,e=>new Set(e.archivedSessionIds)),T=bn(m.state,e=>e.renameTarget),E=(0,r.createSnapshotStore)(null),D=m.rename,O=e=>{p.unarchiveSession(e).catch(e=>{f({kind:`unarchiveFailed`,message:e instanceof Error?e.message:String(e)})})},k=async(e,n)=>{let r=await t.using(e,{source:`workspaceOperation`},e=>e.binding.session.rename(n));if(!r.ok)throw Error(r.error.message)},A=()=>({hooks:{pinned:C,archived:w},pinSession:e=>{p.pinSession(e).catch(e=>{f({kind:`pinFailed`,message:e instanceof Error?e.message:String(e)})})},unpinSession:e=>{p.unpinSession(e).catch(e=>{f({kind:`unpinFailed`,message:e instanceof Error?e.message:String(e)})})}}),j=()=>({hooks:{archived:w},archiveSession:e=>{p.archiveSession(e).then(()=>{f({kind:`archived`,sessionId:e})}).catch(n=>{let r=Vn(n);if(r===void 0){f({kind:`archiveFailed`,message:n instanceof Error?n.message:String(n)});return}let i=t.list.getSnapshot().byId[e]?.displayTitle??e;E.set({sessionId:e,displayTitle:i,activity:r})})},unarchiveSession:O});u(e,p,m,j().archiveSession);let ee=()=>({hooks:{archiveRequest:E},settleSessionArchive:()=>{E.set(null)},stopAndArchiveSession:async e=>{await p.archiveSession(e,{stopActivity:!0}),f({kind:`stoppedAndArchived`,sessionId:e})}}),te=()=>({forkSession:t=>{p.forkSession(t,n=>{e.get(`productAnalytics`)?.track(`branch_session_click`,{session_id:n,parent_session_id:t,click_position:`sidebar`})}).then(e=>p.openSession(e)).catch(e=>{f({kind:`forkFailed`,message:e instanceof Error?e.message:String(e)})})}}),M=()=>({copySessionLink:e=>{let n=t.list.getSnapshot().byId[e],r=n===void 0?void 0:y(n);r!==void 0&&(async()=>{try{await navigator.clipboard.writeText(b(r)),f({kind:`sessionLinkCopied`})}catch{f({kind:`sessionLinkCopyFailed`})}})()}}),N=()=>({requestSessionRename:D}),P=()=>({hooks:{renameRequest:T},settleSessionRename:m.closeRename,renameSession:k}),F=()=>({hooks:{toast:s},dismissToast:()=>{s.set(null)},undoArchive:O,showArchived:()=>{a.actions.setArchivedFilter(`show`)}}),ne=()=>({startSession:e=>{p.startSession(e)},open:S,searchSessions:h,refreshSessions:()=>{t.refresh()},loadMoreSessions:()=>{t.loadMore()},searchResultLimit:t.searchResultLimit,requestSessionRename:D,notifyArchivedNotOpenable:()=>{f({kind:`archivedNotOpenable`})},renameWorkspace:async(e,t)=>{await n.rename(e,t)},deleteWorkspace:async e=>{await n.delete(e)},insertWorkspaceBefore:async(e,t)=>{await n.insertBefore(e,t)},unarchiveSession:async e=>{await p.unarchiveSession(e)},createWorkspace:e=>n.create(e),requestSearch:m.search,requestAddWorkspace:m.add,closeAddWorkspace:m.closeAdd,setDirectoryBusy:m.directoryBusy,dismissForkError:m.dismissForkError,hooks:{directoryFlow:_,hostInfo:v,workspaceShortcuts:m.state,shortcuts:e.shortcuts.catalog}}),re=()=>({createWorkspace:e=>n.create(e),hooks:{directoryFlow:x}});e.slots.inject(`sidebar.workspaces`,()=>e.slots.register({name:`sidebar.workspaces`,children:{"sidebar.workspaces.directoryFlow":{kind:`single`,scope:`root`},"sidebar.workspaces.session.menu.item":{kind:`list`,scope:`root`,inject:{hooks:{menuOpenState:c,shortcuts:e.shortcuts.catalog}}},"sidebar.workspaces.session.row.action":{kind:`list`,scope:`root`},"sidebar.session.row.identity":{kind:`list`,scope:`root`},"sidebar.session.row.leading":{kind:`list`,scope:`root`},"sidebar.session.row.hover":{kind:`list`,scope:`root`}},store:o,inject:ne,locale:Rn},mn)),e.slots.inject(`sidebar.workspaces.session.menu.item`,function*(){yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`pin`,order:100,locale:Rn,inject:A},wn),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`rename`,order:200,locale:Rn,inject:N},En),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`fork`,order:300,locale:Rn,inject:te},xn),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`copy-session-link`,order:350,locale:Rn,inject:M},Sn),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`archive`,order:400,locale:Rn,inject:j},hn)}),e.slots.inject(`sidebar.workspaces.session.row.action`,function*(){yield e.slots.register({name:`sidebar.workspaces.session.row.action`,id:`archive`,order:100,locale:Rn,inject:j},gn),yield e.slots.register({name:`sidebar.workspaces.session.row.action`,id:`pin`,order:200,locale:Rn,inject:A},Tn)}),e.slots.inject(`shell.overlay`,function*(){yield e.slots.register({name:`shell.overlay`,id:`workspace.session-rename`,locale:Rn,inject:P},Dn),yield e.slots.register({name:`shell.overlay`,id:`workspace.session-archive`,locale:Rn,inject:ee},_n),yield e.slots.register({name:`shell.overlay`,id:`workspace.row-toast`,locale:Rn,store:o,inject:F},An)}),e.slots.inject(`conversation.hero.workspace`,()=>e.slots.register({name:`conversation.hero.workspace`,children:{"conversation.hero.workspace.directoryFlow":{kind:`single`,scope:`root`}},inject:re,locale:Rn},rn))}function Vn(e){if(!(e instanceof Error)||e.name!==`WorkspaceArchiveError`)return;let{rpcError:t}=e;return t.code===`workspace/session-active`?t.details.activity:void 0}return n.ReferenceSessionMenuItem=In,n.apply=Bn,n.inject=zn,t.exports}});
23
+ default:return _(e)}}let hr={"host.local":`本机`,"host.connected":`已连接`,"host.connecting":`连接中`,"host.disconnected":`未连接`,"defaultWorkspace.failed":`无法创建默认工作区,请通过“选择工作区”选择文件夹`,"draft.workspaceRequired":`请先选择工作区`,"draft.initializationFailed":`暂时无法填入草稿,请稍后重试`,"recent.navigation":`会话标签`,"recent.expand":`展开会话标签栏`,"recent.collapse":`收起会话标签栏`,"recent.settings.title":`显示会话标签`,"recent.settings.mobile":`移动端`,"recent.settings.description":`在手机会话顶部显示可关闭的标签栏。`,"recent.settings.error":`无法在此浏览器中保存设置,已保留原设置。`,"recent.timeout.title":`自动关闭闲置标签`,"recent.timeout.off":`不自动关闭`,"recent.timeout.minutes":`{n} 分钟`,"recent.timeout.hours":`{n} 小时`,"recent.timeout.default":`{value}(默认)`,"recent.close":`关闭标签“{name}”`,"recent.closeHint":`仅关闭标签,不删除会话或停止任务`,"recent.closeFailed":`未能关闭标签,请重试。`,"recent.clear":`清空`,"recent.clearAll":`清空所有会话标签`,"recent.clearAllHint":`关闭所有标签,不删除会话或停止任务`,"recent.cache.error":`无法读取或保存会话标签。仍可在本页切换会话,刷新后标签可能丢失。`,"group.ungrouped":`最近`,"session.new":`新会话`,"session.untitled":`未命名`,"session.backToList":`返回会话列表`,"shortcut.noSession":`请先选择一个会话`,"shortcut.noPicker":`目录选择器不可用`,"shortcut.directoryBusy":`正在选择或添加工作区`,"shortcut.noCompletedTurn":`当前会话没有已结束的轮次`,"shortcut.forkFailed":`无法分叉会话,请重试`,"section.workspaces":`工作区`,"section.sessions":`会话`,"section.pinned":`置顶`,"viewOptions.label":`视图选项`,"groupBy.label":`分组方式`,"groupBy.workspace":`按工作区`,"groupBy.workspaceTree":`按工作区树`,"groupBy.flat":`单列表`,"orderBy.label":`排序方式`,"orderBy.manual":`手动排序`,"orderBy.updated":`最近更新`,"filterBy.label":`筛选会话`,"viewOptions.hideArchived":`隐藏已归档`,"viewOptions.showArchived":`全部对话(显示已归档)`,"viewOptions.onlyArchived":`仅显示已归档`,"sessions.expand":`展开显示`,"sessions.collapse":`收起`,"sessions.loading":`正在加载历史会话…`,"sessions.expandMore":`展开显示`,"sessions.retry":`重试`,"sessions.notLoaded":`已加载的会话中暂无匹配项,可按需加载更早会话`,"workspaces.expand":`展开显示`,"empty.none":`暂无会话`,"empty.noneArchived":`暂无已归档会话`,"empty.viewOthers":`查看其他会话`,"empty.noMatches":`无匹配结果`,"workspace.add":`添加工作区`,"search.sessions.aria":`搜索会话`,"search.placeholder":`搜索会话名称`,"search.clear":`清除搜索`,"search.results.aria":`搜索结果`,"search.pending":`正在搜索会话历史…`,"search.noMatches":`无匹配会话`,"search.hasMore":`仅显示前 {n} 条结果,请缩小搜索范围。`,"menu.addWorkspace":`添加工作区…`,"menu.noWorkspace":`不选择工作区`,"picker.loading":`正在加载工作区…`,"conflict.named":`已存在名为“{name}”的工作区。`,"folderError.title":`无法打开文件夹`,"folderError.retry":`重新选择`,rename:`重命名`,"rename.workspace.title":`重命名工作区`,"rename.session.title":`重命名会话`,"field.workspaceName":`工作区名称`,"field.sessionName":`会话名称`,"delete.workspace":`删除工作区`,"delete.desc":`将把“{name}”从工作区列表中移除。文件夹与会话记录会保留,其会话将显示在“未分组”下。`,"delete.pending":`正在删除工作区…`,"menu.copySessionLink":`复制会话链接`,"menu.referenceSession":`引用会话`,"menu.referenceSessionFailed":`未加入草稿:编辑位置或会话已失效`,"toast.sessionLinkCopied":`已复制`,"toast.sessionLinkCopyFailed":`复制会话链接失败`,"menu.fork":`分叉会话`,"menu.archiveSession":`归档会话`,"menu.unarchiveSession":`取消归档`,"threadTree.style.title":`会话数的展示方式`,"threadTree.style.promptTitle":`选择会话数的展示方式`,"threadTree.style.description":`父会话收起时,如何显示子会话的状态。`,"threadTree.style.summary":`详细`,"threadTree.style.ring":`简洁`,"threadTree.style.summarySubtitle":`显示数量与状态`,"threadTree.style.ringSubtitle":`图标外圈显示状态`,"threadTree.style.hint":`可随时在“视图选项”或“设置”中修改。`,"threadTree.style.later":`稍后`,"threadTree.style.error":`无法保存样式,请重试;已保留原设置。`,"threadTree.style.samplePending":`有子会话等待批准`,"threadTree.style.sampleRunning":`有子会话正在运行`,"threadTree.style.sampleUnread":`有子会话未读完成`,"threadTree.style.sampleRead":`子会话都已读`,"threadTree.expand":`展开 {n} 个子会话`,"threadTree.collapse":`收起 {n} 个子会话`,"threadTree.children":`{n} 个子会话`,"threadTree.expandSummary":`{title},{summary},展开`,"threadTree.running":`{n} 运行中`,"threadTree.pending":`{n} 待批准`,"threadTree.completed":`{n} 未读`,"archive.confirm.thread":`正在运行的会话:{title}`,"menu.pinSession":`置顶会话`,"menu.unpinSession":`取消置顶`,"row.archived":`已归档`,"row.pinned":`已置顶`,"toast.archivedNotOpenable":`已归档对话暂时无法查看,请取消归档后查看`,"toast.archived":`会话已归档,可`,"toast.stoppedAndArchived":`已停止并归档,可`,"archive.confirm.title":`停止并归档此会话?`,"archive.confirm.desc":`“{title}”仍有正在进行的工作。归档会先停止这些工作;之后可在侧栏筛选“全部对话(显示已归档)”中恢复会话,被停止的工作不会自动继续。`,"archive.confirm.activity":`将被停止的工作`,"archive.confirm.turn":`进行中的回合`,"archive.confirm.subagents.one":`{n} 个运行中的子智能体:{names}`,"archive.confirm.subagents.other":`{n} 个运行中的子智能体:{names}`,"archive.confirm.jobs.one":`{n} 个后台任务:{names}`,"archive.confirm.jobs.other":`{n} 个后台任务:{names}`,"archive.confirm.schedules.one":`{n} 条定时提醒:{names}`,"archive.confirm.schedules.other":`{n} 条定时提醒:{names}`,"archive.confirm.other.one":`{n} 项其他工作({kind})`,"archive.confirm.other.other":`{n} 项其他工作({kind})`,"archive.confirm.listSeparator":`、`,"archive.confirm.action":`停止并归档`,"archive.confirm.pending":`正在停止并归档…`,"toast.archivedUndo":`撤销`,"toast.archivedOr":`或`,"toast.archivedFilter":`筛选已归档会话`,"toast.archiveFailed":`归档未确认,请检查会话状态:{message}`,"toast.unarchiveFailed":`取消归档未确认,请刷新后检查:{message}`,"toast.pinFailed":`置顶未确认,请刷新后检查:{message}`,"toast.unpinFailed":`取消置顶未确认,请刷新后检查:{message}`,"toast.createFailed":`新建会话失败:{message}`,"toast.forkFailed":`分叉未完成:{message}`,"sessions.count.one":`{n} 个会话`,"sessions.count.other":`{n} 个会话`,"actions.workspace.aria":`工作区“{name}”的操作`,"actions.session.aria":`会话“{name}”的操作`,"actions.archive":`归档会话`,"actions.unarchive":`取消归档`,"actions.pin":`置顶会话`,"actions.unpin":`取消置顶`,"actions.newSession":`新会话`,"actions.newSession.aria":`在“{name}”中新建会话`,"status.running":`进行中`,"status.subagentsRunning.one":`{n} 个子智能体运行中`,"status.subagentsRunning.other":`{n} 个子智能体运行中`,"status.idle":`空闲`,"status.waitingApproval":`等待审批`,"status.planReview":`计划待审`,"status.waitingAnswer":`等待回答`,"status.compact.approval":`待审批`,"status.compact.planReview":`计划待审`,"status.compact.answer":`待回答`,"status.completed":`已完成`,"hover.created":`创建于 {time}`,"hover.copied":`已复制`,"date.ymd":`{y}年{m}月{d}日`,"time.now":`刚刚`,"time.minutes":`{n}分钟`,"time.hours":`{n}小时`,"time.days":`{n}天`,"time.months":`{n}个月`,"time.years":`{n}年`,"time.ago":`{t}前`},gr={"host.local":`Local`,"host.connected":`Connected`,"host.connecting":`Connecting`,"host.disconnected":`Disconnected`,"defaultWorkspace.failed":`Unable to create default workspace. Use Choose workspace to select a folder.`,"draft.workspaceRequired":`Choose a workspace first.`,"draft.initializationFailed":`Could not fill the draft. Please try again shortly.`,"recent.navigation":`Session tabs`,"recent.expand":`Expand session tabs`,"recent.collapse":`Collapse session tabs`,"recent.settings.title":`Show session tabs`,"recent.settings.mobile":`Mobile`,"recent.settings.description":`Show closable tabs above phone conversations.`,"recent.settings.error":`Could not save in this browser. The previous setting is unchanged.`,"recent.timeout.title":`Automatically close idle tabs`,"recent.timeout.off":`Never`,"recent.timeout.minutes":`{n} minutes`,"recent.timeout.hours":`{n} hours`,"recent.timeout.default":`{value} (default)`,"recent.close":`Close tab “{name}”`,"recent.closeHint":`Close only this tab, without deleting the session or stopping tasks`,"recent.closeFailed":`Could not close the tab. Please try again.`,"recent.clear":`Clear`,"recent.clearAll":`Clear all session tabs`,"recent.clearAllHint":`Close all tabs without deleting sessions or stopping tasks`,"recent.cache.error":`Could not read or save session tabs. Switching still works in this page; tabs may be lost on reload.`,"group.ungrouped":`Recents`,"session.new":`New Session`,"session.untitled":`Untitled`,"session.backToList":`Back to session list`,"shortcut.noSession":`Select a session first`,"shortcut.noPicker":`Directory picker unavailable`,"shortcut.directoryBusy":`Selecting or adding a workspace`,"shortcut.noCompletedTurn":`This session has no completed turn`,"shortcut.forkFailed":`Could not fork the session. Try again.`,"section.workspaces":`Workspaces`,"section.sessions":`Sessions`,"section.pinned":`Pinned`,"viewOptions.label":`View options`,"groupBy.label":`Group by`,"groupBy.workspace":`WorkSpace`,"groupBy.workspaceTree":`Workspace Tree`,"groupBy.flat":`In one list`,"orderBy.label":`Order by`,"orderBy.manual":`Manual`,"orderBy.updated":`Last updated`,"filterBy.label":`Filter sessions`,"viewOptions.hideArchived":`Hide archived`,"viewOptions.showArchived":`All conversations (show archived)`,"viewOptions.onlyArchived":`Archived only`,"sessions.expand":`Show {n} more`,"sessions.collapse":`Show less`,"sessions.loading":`Loading conversation history…`,"sessions.expandMore":`Show more`,"sessions.retry":`Retry`,"sessions.notLoaded":`No matching loaded conversations. Older conversations can be loaded on demand.`,"workspaces.expand":`Show all workspaces`,"empty.none":`No sessions yet`,"empty.noneArchived":`No archived sessions yet`,"empty.viewOthers":`View other sessions`,"empty.noMatches":`No matches`,"workspace.add":`Add workspace`,"search.sessions.aria":`Search sessions`,"search.placeholder":`Search session names`,"search.clear":`Clear search`,"search.results.aria":`Search results`,"search.pending":`Searching session history…`,"search.noMatches":`No matching sessions`,"search.hasMore":`Showing the first {n} results. Narrow your search.`,"menu.addWorkspace":`Add workspace…`,"menu.noWorkspace":`No workspace`,"picker.loading":`Loading workspaces…`,"conflict.named":`A workspace named “{name}” already exists.`,"folderError.title":`Couldn’t open folder`,"folderError.retry":`Choose again`,rename:`Rename`,"rename.workspace.title":`Rename workspace`,"rename.session.title":`Rename session`,"field.workspaceName":`Workspace name`,"field.sessionName":`Session name`,"delete.workspace":`Delete workspace`,"delete.desc":`This removes “{name}” from the workspace list. The folder and session logs will be kept. Its sessions will appear under Ungrouped.`,"delete.pending":`Deleting workspace…`,"menu.copySessionLink":`Copy session link`,"menu.referenceSession":`Reference session`,"menu.referenceSessionFailed":`Not added: the editing position or session is no longer available`,"toast.sessionLinkCopied":`Copied`,"toast.sessionLinkCopyFailed":`Could not copy session link`,"menu.fork":`Fork session`,"menu.archiveSession":`Archive session`,"menu.unarchiveSession":`Unarchive session`,"threadTree.style.title":`Session count display`,"threadTree.style.promptTitle":`Choose how to display session counts`,"threadTree.style.description":`How a collapsed parent shows its child sessions' status.`,"threadTree.style.summary":`Detailed`,"threadTree.style.ring":`Compact`,"threadTree.style.summarySubtitle":`Count and status`,"threadTree.style.ringSubtitle":`Icon status ring`,"threadTree.style.hint":`Change this anytime in View options or Settings.`,"threadTree.style.later":`Later`,"threadTree.style.error":`Could not save the style. Previous setting kept; please retry.`,"threadTree.style.samplePending":`Child awaiting approval`,"threadTree.style.sampleRunning":`Child running`,"threadTree.style.sampleUnread":`Child finished, unread`,"threadTree.style.sampleRead":`All read`,"threadTree.expand":`Expand {n} child sessions`,"threadTree.collapse":`Collapse {n} child sessions`,"threadTree.children":`{n} child sessions`,"threadTree.expandSummary":`{title}, {summary}, expand`,"threadTree.running":`{n} running`,"threadTree.pending":`{n} needs approval`,"threadTree.completed":`{n} unread`,"archive.confirm.thread":`Running session: {title}`,"menu.pinSession":`Pin session`,"menu.unpinSession":`Unpin session`,"row.archived":`Archived`,"row.pinned":`Pinned`,"toast.archivedNotOpenable":`Archived sessions cannot be opened. Unarchive it to view.`,"toast.archived":`Session archived. You can `,"toast.stoppedAndArchived":`Session stopped and archived. You can `,"archive.confirm.title":`Stop and archive this session?`,"archive.confirm.desc":`“{title}” still has work in progress. Archiving stops it first; you can restore the session later from the “All conversations (show archived)” filter in the sidebar, and the stopped work will not resume on its own.`,"archive.confirm.activity":`Work that will be stopped`,"archive.confirm.turn":`The turn in progress`,"archive.confirm.subagents.one":`{n} running subagent: {names}`,"archive.confirm.subagents.other":`{n} running subagents: {names}`,"archive.confirm.jobs.one":`{n} background job: {names}`,"archive.confirm.jobs.other":`{n} background jobs: {names}`,"archive.confirm.schedules.one":`{n} scheduled reminder: {names}`,"archive.confirm.schedules.other":`{n} scheduled reminders: {names}`,"archive.confirm.other.one":`{n} other item of work ({kind})`,"archive.confirm.other.other":`{n} other items of work ({kind})`,"archive.confirm.listSeparator":`, `,"archive.confirm.action":`Stop and archive`,"archive.confirm.pending":`Stopping and archiving…`,"toast.archivedUndo":`undo`,"toast.archivedOr":` or `,"toast.archivedFilter":`filter archived sessions`,"toast.archiveFailed":`Archive not confirmed. Check session status: {message}`,"toast.unarchiveFailed":`Unarchive not confirmed. Refresh to check: {message}`,"toast.pinFailed":`Pin not confirmed. Refresh to check: {message}`,"toast.unpinFailed":`Unpin not confirmed. Refresh to check: {message}`,"toast.createFailed":`New session failed: {message}`,"toast.forkFailed":`Fork did not complete: {message}`,"sessions.count.one":`{n} session`,"sessions.count.other":`{n} sessions`,"actions.workspace.aria":`Workspace actions for {name}`,"actions.session.aria":`Session actions for {name}`,"actions.archive":`Archive`,"actions.unarchive":`Unarchive`,"actions.pin":`Pin`,"actions.unpin":`Unpin`,"actions.newSession":`New session`,"actions.newSession.aria":`New session in {name}`,"status.running":`Running`,"status.subagentsRunning.one":`{n} subagent running`,"status.subagentsRunning.other":`{n} subagents running`,"status.idle":`Idle`,"status.waitingApproval":`Waiting for approval`,"status.planReview":`Plan awaiting review`,"status.waitingAnswer":`Waiting for answer`,"status.compact.approval":`Approval`,"status.compact.planReview":`Plan review`,"status.compact.answer":`Answer`,"status.completed":`Completed`,"hover.created":`Created {time}`,"hover.copied":`Copied`,"date.ymd":`{y}-{m}-{d}`,"time.now":`now`,"time.minutes":`{n}min`,"time.hours":`{n}h`,"time.days":`{n}d`,"time.months":`{n}mo`,"time.years":`{n}y`,"time.ago":`{t} ago`};function _r(e,t){let n=/* @__PURE__ */ new Map;for(let t of Object.values(e.byId)){let r=ie(t,e);if(r===null)continue;let i=n.get(r)??[];i.push(t.id),n.set(r,i)}let r=/* @__PURE__ */ new Set([t]),i=[...n.get(t)??[]];for(let e=i.pop();e!==void 0;e=i.pop())r.has(e)||(r.add(e),i.push(...n.get(e)??[]));return r.delete(t),r}function vr(e){return e!==void 0&&!e.blank&&e.origin!==`subagent`&&!e.projectionValues?.remoteHost&&e.projectionValues?.threadTreeParent!==void 0}function yr(e,t){let n=[t,..._r(e,t)],r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Map;for(let t=n.pop();t!==void 0;t=n.pop()){if(r.has(t))continue;r.add(t);let a=e.projectionsBySession[f(t)]?.values.subagentCatalog??[];for(let t of a)e.byId[t.id]?.running&&i.set(t.id,{id:t.id,...t.label===void 0?{}:{label:t.label}}),n.push(t.id)}return[...i.values()]}function br(e,t){let n=/* @__PURE__ */ new Set([t,..._r(e,t)]);return Object.values(e.byId).filter(e=>n.has(e.id)&&e.running).map(e=>({id:e.id,title:e.title?.trim()||e.displayTitle}))}let xr=()=>!1,Sr=()=>()=>{};function Cr(e){let t=(0,o.usePhoneSidebar)();return t!==null&&!t.open?null:/* @__PURE__ */ (0,s.jsx)(wr,{...e,closeDrawer:t?.close},e.sessionId)}function wr({sessionId:e,prepareDraftReference:t,closeDrawer:n,useMenuOpenState:r,t:i}){let[c]=(0,a.useState)(()=>t(e)),l=(0,a.useSyncExternalStore)(c?.subscribe??Sr,c?.getSnapshot??xr),u=(0,a.useRef)(!1),[d,f]=(0,a.useState)(!1),[,p]=r();return c===void 0?null:/* @__PURE__ */ (0,s.jsxs)(s.Fragment,{children:[/* @__PURE__ */ (0,s.jsx)(o.MenuItemButton,{icon:/* @__PURE__ */ (0,s.jsx)(o.IconLinkOutlineRegular,{}),disabled:d||!l,onSelect:()=>{if(!u.current){u.current=!0;try{if(c?.insert()===!0){p(!1),n?.();return}}catch{}f(!0)}},children:i(`menu.referenceSession`)}),d&&/* @__PURE__ */ (0,s.jsx)(`div`,{role:`status`,children:i(`menu.referenceSessionFailed`)})]})}let Tr=`workspace`,Er=[`slots`,`sessions`,`workspaces`,`locale`,`remote`,`remote.directoryPicker`,`layout`,`shortcuts`,`configForms`];function Dr(e){let t=e.get(`sessions`),n=e.get(`workspaces`),i=pe(),a=i.create();a.actions.setArchivedFilter(`default`),e.effect(()=>{let e=()=>{t.setIncludeArchived((a.getSnapshot().archivedFilter??`default`)!=="default")},n=a.subscribe(e);return e(),n},`ui-workspace: browser-local archive query scope`);let o={...i,create:()=>a},s=(0,r.createSnapshotStore)(null),d=0,f=e=>{s.set({...e,seq:++d})},p=new Oe(e,e.remote.directoryPicker,n,t,a.actions,f),m=Mt(e);Ct(e,p,m),e.slots.provideRoot({hooks:{workspaces:n.list}}),e.effect(()=>e.locale.register(Tr,{zh:hr,en:gr}),`ui-workspace: dictionaries`);let h=l(),g=async(e,n)=>{let r=await t.search(e,n);if(!r.ok)throw Error(r.error.message);return r.value},_=t=>({getSnapshot:()=>e.slots.entries(t).length>0,subscribe:n=>e.slots.subscribe(t,n)}),v=_(`sidebar.workspaces.directoryFlow`),y={getSnapshot:()=>e.remote.$host,subscribe:t=>e.on(`connection/reset`,t)},b=_(`conversation.hero.workspace.directoryFlow`),C=e=>{p.openSession(e)},w=rr(n.list,e=>new Set(e.pinnedSessionIds)),T=rr(n.list,e=>new Set(e.archivedSessionIds)),E=rr(h.state,e=>e.renameTarget),D=(0,r.createSnapshotStore)(null),O=h.rename,k=e=>{p.unarchiveSession(e).catch(e=>{f({kind:`unarchiveFailed`,message:e instanceof Error?e.message:String(e)})})},A=async(e,n)=>{let r=await t.using(e,{source:`workspaceOperation`},e=>e.binding.session.rename(n));if(!r.ok)throw Error(r.error.message)},j=()=>({hooks:{pinned:w,archived:T},pinSession:e=>{p.pinSession(e).catch(e=>{f({kind:`pinFailed`,message:e instanceof Error?e.message:String(e)})})},unpinSession:e=>{p.unpinSession(e).catch(e=>{f({kind:`unpinFailed`,message:e instanceof Error?e.message:String(e)})})}}),M=()=>({hooks:{archived:T},archiveSession:e=>{let n=t.list.getSnapshot(),r=n.byId[e],i=br(n,e),a=yr(n,e);vr(r)&&(i.length>0||a.length>0)?D.set({sessionId:e,displayTitle:r?.displayTitle??e,activity:a.length===0?[]:[{kind:`subagent`,items:a}],runningThreads:i}):p.archiveSession(e).then(()=>{f({kind:`archived`,sessionId:e})}).catch(n=>{let r=Or(n);if(r===void 0){f({kind:`archiveFailed`,message:n instanceof Error?n.message:String(n)});return}let i=t.list.getSnapshot().byId[e]?.displayTitle??e;D.set({sessionId:e,displayTitle:i,activity:r})})},unarchiveSession:k});u(e,p,h,M().archiveSession);let N=()=>({hooks:{archiveRequest:D},settleSessionArchive:()=>{D.set(null)},stopAndArchiveSession:async e=>{await p.archiveSession(e,{stopActivity:!0}),f({kind:`stoppedAndArchived`,sessionId:e})}}),ee=()=>({forkSession:t=>{p.forkSession(t,n=>{e.get(`productAnalytics`)?.track(`branch_session_click`,{session_id:n,parent_session_id:t,click_position:`sidebar`})}).then(e=>p.openSession(e)).catch(e=>{f({kind:`forkFailed`,message:e instanceof Error?e.message:String(e)})})}}),P=()=>({copySessionLink:e=>{let n=t.list.getSnapshot().byId[e],r=n===void 0?void 0:x(n);r!==void 0&&(async()=>{try{await navigator.clipboard.writeText(S(r)),f({kind:`sessionLinkCopied`})}catch{f({kind:`sessionLinkCopyFailed`})}})()}}),te=()=>({requestSessionRename:O}),F=()=>({hooks:{renameRequest:E},settleSessionRename:h.closeRename,renameSession:A}),ne=()=>({hooks:{toast:s},dismissToast:()=>{s.set(null)},undoArchive:k,showArchived:()=>{a.actions.setArchivedFilter(`show`)}}),re=()=>({startSession:e=>{p.startSession(e)},open:C,searchSessions:g,refreshSessions:()=>{t.refresh()},loadMoreSessions:()=>{t.loadMore()},searchResultLimit:t.searchResultLimit,requestSessionRename:O,notifyArchivedNotOpenable:()=>{f({kind:`archivedNotOpenable`})},renameWorkspace:async(e,t)=>{await n.rename(e,t)},deleteWorkspace:async e=>{await n.delete(e)},insertWorkspaceBefore:async(e,t)=>{await n.insertBefore(e,t)},unarchiveSession:async e=>{await p.unarchiveSession(e)},createWorkspace:e=>n.create(e),requestSearch:h.search,requestAddWorkspace:h.add,closeAddWorkspace:h.closeAdd,setDirectoryBusy:h.directoryBusy,dismissForkError:h.dismissForkError,setThreadTreeCollapseStyle:e=>m.set(`threadTreeCollapseStyle`,e),hooks:{workspacePreferences:m,directoryFlow:v,hostInfo:y,workspaceShortcuts:h.state,shortcuts:e.shortcuts.catalog}}),I=()=>({createWorkspace:e=>n.create(e),hooks:{directoryFlow:b}});e.slots.inject(`sidebar.workspaces`,()=>e.slots.register({name:`sidebar.workspaces`,children:{"sidebar.workspaces.directoryFlow":{kind:`single`,scope:`root`},"sidebar.workspaces.session.menu.item":{kind:`list`,scope:`root`,inject:{hooks:{menuOpenState:c,shortcuts:e.shortcuts.catalog}}},"sidebar.workspaces.session.row.action":{kind:`list`,scope:`root`},"sidebar.session.row.identity":{kind:`list`,scope:`root`},"sidebar.session.row.leading":{kind:`list`,scope:`root`},"sidebar.session.row.hover":{kind:`list`,scope:`root`}},store:o,inject:re,locale:Tr},Xn)),e.slots.inject(`sidebar.workspaces.session.menu.item`,function*(){yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`pin`,order:100,locale:Tr,inject:j},sr),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`rename`,order:200,locale:Tr,inject:te},lr),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`fork`,order:300,locale:Tr,inject:ee},ir),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`copy-session-link`,order:350,locale:Tr,inject:P},ar),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`archive`,order:400,locale:Tr,inject:M},Qn)}),e.slots.inject(`sidebar.workspaces.session.row.action`,function*(){yield e.slots.register({name:`sidebar.workspaces.session.row.action`,id:`archive`,order:100,locale:Tr,inject:M},$n),yield e.slots.register({name:`sidebar.workspaces.session.row.action`,id:`pin`,order:200,locale:Tr,inject:j},cr)}),e.slots.inject(`shell.overlay`,function*(){yield e.slots.register({name:`shell.overlay`,id:`workspace.session-rename`,locale:Tr,inject:F},ur),yield e.slots.register({name:`shell.overlay`,id:`workspace.session-archive`,locale:Tr,inject:N},er),yield e.slots.register({name:`shell.overlay`,id:`workspace.row-toast`,locale:Tr,store:o,inject:ne},pr)}),e.slots.inject(`conversation.hero.workspace`,()=>e.slots.register({name:`conversation.hero.workspace`,children:{"conversation.hero.workspace.directoryFlow":{kind:`single`,scope:`root`}},inject:I,locale:Tr},Bn))}function Or(e){if(!(e instanceof Error)||e.name!==`WorkspaceArchiveError`)return;let{rpcError:t}=e;return t.code===`workspace/session-active`?t.details.activity:void 0}return n.ReferenceSessionMenuItem=Cr,n.apply=Dr,n.inject=Er,t.exports}});