@codexhost/cli-win32-arm64 0.25.1 → 0.26.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 (56) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +307 -19
  4. package/app/console-web.js +613 -230
  5. package/app/desktop-controller.mjs +225 -5
  6. package/app/host-runtime.mjs +1189 -647
  7. package/app/plugins/antigravity/plugin.mjs +272 -19
  8. package/app/plugins/claude-code/plugin.mjs +265 -10
  9. package/app/plugins/codebuddy/plugin.mjs +224 -5
  10. package/app/plugins/codex-usage/plugin.mjs +224 -5
  11. package/app/plugins/copilot/plugin.mjs +224 -5
  12. package/app/plugins/cursor-cli/plugin.mjs +224 -5
  13. package/app/plugins/deepseek-harness/plugin.mjs +252 -36
  14. package/app/plugins/devin/plugin.mjs +224 -5
  15. package/app/plugins/grok/plugin.mjs +224 -5
  16. package/app/plugins/hermes/plugin.mjs +268 -20
  17. package/app/plugins/kimi-code/plugin.mjs +224 -5
  18. package/app/plugins/kiro-cli/plugin.mjs +224 -5
  19. package/app/plugins/omp/plugin.mjs +224 -5
  20. package/app/plugins/opencode/plugin.mjs +225 -9
  21. package/app/plugins/pi/plugin.mjs +366 -33
  22. package/app/plugins/qoder/plugin.mjs +224 -5
  23. package/app/plugins/qoder-cn/plugin.mjs +224 -5
  24. package/app/plugins/qwen-code/plugin.mjs +224 -5
  25. package/app/plugins/workbuddy/plugin.mjs +224 -5
  26. package/app/plugins/zcode/plugin.mjs +224 -5
  27. package/app/renderer-extension.js +1202 -330
  28. package/app/web/assets/index-BDWdtbFT.js +203 -0
  29. package/app/web/assets/index-jLAmV7OU.css +1 -0
  30. package/app/web/codexhost-settings.js +230 -140
  31. package/app/web/index.html +2 -2
  32. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  33. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -10
  34. package/app/web/plugins/deepseek-ai__dsh-api-workspace-controller/client.js +3 -3
  35. package/app/web/plugins/deepseek-ai__dsh-client-ui-brand-official/client.js +1 -1
  36. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -74
  37. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +74 -74
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +96 -96
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  40. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +1 -1
  41. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
  42. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
  43. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +132 -11
  48. package/app/web-modules/server.mjs +71157 -65816
  49. package/bin/codexhost.exe +0 -0
  50. package/libexec/codexhost-node-repl.exe +0 -0
  51. package/libexec/codexhost-shell.exe +0 -0
  52. package/libexec/codexhost-shim.exe +0 -0
  53. package/libexec/codexhost-updater.exe +0 -0
  54. package/package.json +1 -1
  55. package/app/web/assets/index-CTCFIQbU.css +0 -1
  56. package/app/web/assets/index-DUOvhHbV.js +0 -203
@@ -1,23 +1,144 @@
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("@deepseek-ai/dsh-client-ui-primitives"),o=e("react/jsx-runtime"),s=e("react"),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;
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("@deepseek-ai/dsh-client-ui-primitives"),o=e("react/jsx-runtime"),s=e("react"),c=e("react-dom"),l=(e,t)=>()=>t;function u(){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 d(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 f(e){return e}function p(e){return f(e)}let m={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
2
+ `,r:`\r`,t:` `},h=/[\\\u0000-\u001f]/u;function g(e){return e===` `||e===`
3
+ `||e===`\r`||e===` `}function _(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(h),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,p=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++)_(n[e])||(r=!1);if(r){if(n.length<4&&e.end<0)return;n.length===4&&(f=String.fromCharCode(Number.parseInt(n,16)))}p=6}else c[0]===`\\`&&d!==void 0&&(f=m[d]);if(f===void 0){e.invalidAt=t.at,this.#f=!0;return}for(r&&(t.text+=f),t.length++,t.at+=p;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&&h.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(g(e))return;if(e===`{`){this.#r=`key-or-end`;return}this.fail();return;case`key-or-end`:if(g(e))return;if(e===`}`){this.#r=`closed`;return}if(e===`"`){this.beginKey(t);return}this.fail();return;case`key-only`:if(g(e))return;if(e===`"`){this.beginKey(t);return}this.fail();return;case`key`:this.stepKey(e,t);return;case`colon`:if(g(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(g(e))return;if(e===`,`){this.#r=`key-only`;return}if(e===`}`){this.#r=`closed`;return}this.fail();return;case`closed`:if(g(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:_(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);
7
+ default:v(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){g(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===`}`||g(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 v(e,t){let n=JSON.stringify(e)??String(e);throw Error(`unreachable variant${t?` in ${t}`:``}: ${n}`)}function y(e){return/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)}function b(e,t){if(t===void 0||t===``||y(e)||y(t))return e;let n=t.replace(/\/+$/,``);return n===``||n===`/`?e:e.replace(/\/+$/,``)===n?`~`:e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function x(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return t.slice(n+1)}function S(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 C(e){return`thread://${encodeURIComponent(e.threadId).replace(/[!'()*]/gu,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}?hostId=${encodeURIComponent(e.hostId)}`}function ee(e){let t=`[@${e.title.replace(/[\\`*{}[\]()#+.!_<>|~-]/gu,e=>`\\${e}`)}](${C(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 te(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 T(e,t){return e.find(e=>e.sessionIds.includes(t))?.workspaceId??``}function E(e){return Object.values(e.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id}function D(e){if(e===void 0||e===``)return``;let t=x(e);return t===``?e:t}function O(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 ne(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 O([...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 re(e,t){return t===void 0?[...e]:[t,...e.filter(e=>e!==t)]}function ie(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 _(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 P(e){return e.blank?``:e.title?.trim()??``}function ee(e,t,n,r,i,a,o){return{key:e,workspaceId:t,cwd:n,createdAt:r,label:i,sessions:[...a],remote:o}}function F(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(ee(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(ee(``,void 0,void 0,void 0,``,a)),i}function I(e){switch(e){case`approval`:case`plan-review`:case`question`:return e;default:return}}function te(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 L(e,t,n){let r=n.get(e.id),i=I(r?.pendingInteraction?.kind);return{running:r?.running??e.running,runningSubagentCount:te(t,e.id,n),completed:r?.completionUnread===!0,...i===void 0?{}:{pendingInteraction:i}}}function ne(e,t,n,r,i){return{id:e.id,reference:x(e),remote:e.projectionValues?.remoteHost??void 0,title:P(e),...e.cwd===void 0?{}:{cwd:e.cwd},blank:e.blank,...L(e,t,n),pinned:!i.has(e.id)&&r.has(e.id),archived:i.has(e.id),updatedAt:e.updatedAt}}function re(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 R(e,t,n){let r=new Set(t.archivedSessionIds),i=new Set(t.pinnedSessionIds);return w(B(e,t.archivedSessionIds,t.archivedFilter).flatMap(t=>{let a=e.byId[t];return a===void 0?[]:[ne(a,e,n,i,r)]}),n=>{if(t.sectionedSessionIds?.has(n.id))return null;let r=e.byId[n.id];return r===void 0?null:re(r,e)})}function z(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(R(e,n,r).map(e=>[e.id,e])),u=[];for(let r of F(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||n.sectionedSessionIds?.has(t.id))?[]:[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 ie(e,t=[]){return[...B(e,[],`show`),...t.filter(t=>e.byId[t]===void 0)]}function B(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 ae(e,t,n,r){let i=new Set(n.archivedSessionIds),a=new Set(n.pinnedSessionIds),o=new Map(R(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 oe(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)&&(P(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=I(r?.pendingInteraction?.kind),o=re(t,e);return{id:t.id,title:P(t),workspace:d(t),...o===null?{}:{parentTitle:e.byId[f(o)]?.title??``},remote:t.projectionValues?.remoteHost??void 0,running:r?.running??t.running,runningSubagentCount:te(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 V(e){return(/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)?e.replaceAll(`\\`,`/`):e).replace(/\/+$/,``)}function se(e,t){let n=V(e),r,i=-1;for(let e of t){let t=V(e);t.length>i&&n!==t&&n.startsWith(`${t}/`)&&(r=e,i=t.length)}return r}let H=`__flat_session_order__`,ce=`pinned`,le=`workspaces`;function ue(e,t){return e?.[t]??!0}function de(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 fe(){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`?de(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,de(t,e.sessionOrderByAccount,n))},setSessionOrder:(e,t,n,r,i)=>{let a=de({...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=de(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 pe(e,t){let n=R(e,t,/* @__PURE__ */ new Map),r=new Set(B(e,t.archivedSessionIds,t.archivedFilter)),i=/* @__PURE__ */ new Set([...n.map(e=>e.id),...ie(e,t.archivedSessionIds).filter(e=>!r.has(e))]),a=/* @__PURE__ */ new Map,o={...e.byId};for(let e of n){for(let t of e.tree?.descendantIds??[])a.set(f(t),e.id);let t=o[e.id];t!==void 0&&(o[e.id]={...t,updatedAt:e.tree?.updatedAt??e.updatedAt})}return{rootIds:i,rootOf:a,summaries:o}}function me(e,t){let n=new Set(e),r=[],i=/* @__PURE__ */ new Set;for(let a of e){if(t.summaries[a]===void 0||t.rootIds.has(a)){r.push(a);continue}let e=t.rootOf.get(a);e===void 0||n.has(e)||i.has(e)||(i.add(e),r.push(e))}return{memberIds:r,linkedRootIds:i}}function he(e,t,n){let r=pe(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,me(e.sessionIds,r).memberIds]),[``,i([.../* @__PURE__ */ new Set([...t.ids,...n.archivedSessionIds])]).filter(e=>!a.has(e))],[H,i(ie(t,n.archivedSessionIds))]]),summaries:r.summaries,rowState:n}}function ge(e,t){return[E(e,t),H]}var U=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 W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xe(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 Se(e,t){if(typeof e==`string`)return e===t?t:void 0;if(!W(e)||Object.keys(e).length!==3)return;let n=xe(e.parentSessionId),r=xe(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 Ce(e,t){if(e===null||e.length>be)return[];try{let n=JSON.parse(e);if(!W(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(!W(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=xe(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=Se(e.target,o);c!==void 0&&(i.add(o),r.push({sessionId:o,target:c,lastVisitedAt:s}))}return r}catch{return[]}}var we=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?Ce(localStorage.getItem(ve)??localStorage.getItem(ye),1):Ce(e,2)}failed(){if(!this.reported){this.reported=!0;try{this.onFailure()}catch{}}}},G=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 we(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=L(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)||Te(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 Te(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 Ee=class extends Error{rpcError;name=`DirectoryBrowseError`;constructor(e){super(`directory browse failed: ${e.code}: ${e.message}`),this.rpcError=e}},De=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;creating=(0,r.createSnapshotStore)({state:`idle`});retryCreate;creatingLoad;creationToken=0;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 U(r,n);let o=e.get(`remote`);this.recentVisits=new G(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(Oe(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?.()}retryCreating(){this.retryCreate?.()}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:je(n)})}}async openWorkspace(e,t){if(this.mainReference===void 0){let n=this.creating.getSnapshot(),r=n.state===`idle`?++this.creationToken:n.token,i=n.state===`idle`?void 0:n.initialPrompt;await this.runCreation({workspaceId:e,token:r,...i===void 0?{}:{initialPrompt:i},...t===void 0?{}:{beforeOpen:t}});return}let n=AbortSignal.any([this.ctx.layout.beginNavigation(),this.lifetime.signal]),r;try{if(e===null&&!this.workspaces.list.getSnapshot().canStartProjectless)throw new ke;r=e===null?await this.sessions.create():await this.connectWorkspace(e)}catch(e){throw n.aborted||this.notify({kind:`createFailed`,message:je(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`?Me(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();return}this.ctx.layout.selectPanel(null),this.releaseMainSelection();let u=++this.creationToken;this.runCreation({workspaceId:l,token:u,...n?.prompt===void 0?{}:{initialPrompt:n.prompt},...r?{draftOptions:n}:{}}).catch(e=>{console.warn(`new session failed:`,e)})}async runCreation(e){this.creatingLoad?.stop(),this.creatingLoad=void 0,this.retryCreate=void 0;let t=AbortSignal.any([this.ctx.layout.beginNavigation(),this.lifetime.signal]);this.openingLoad?.stop(),this.openingLoad=void 0,this.opening.set({state:`idle`}),this.retryOpen=void 0;let n={stop:()=>t.removeEventListener(`abort`,r)},r=()=>{n.stop(),this.creatingLoad===n&&(this.creatingLoad=void 0,this.retryCreate=void 0,this.creating.set({state:`idle`}))};t.addEventListener(`abort`,r,{once:!0}),this.creatingLoad=n,this.creating.set({state:`creating`,workspaceId:e.workspaceId,token:e.token,...e.initialPrompt===void 0?{}:{initialPrompt:e.initialPrompt}});try{if(e.workspaceId===null&&!this.workspaces.list.getSnapshot().canStartProjectless)throw new ke;let i=e.workspaceId===null?await this.sessions.create():await this.connectWorkspace(e.workspaceId);if(t.aborted||this.creatingLoad!==n)return;this.replaceMain(i,t,`preserve`,t=>{e.beforeOpen?.(t),this.handoffPendingDraft(t,e.draftOptions)}),r()}catch(r){if(t.aborted||this.creatingLoad!==n)return;this.retryCreate=()=>{this.runCreation(e).catch(e=>{console.warn(`new session retry failed:`,e)})};let i=K(r),a=i===`unknown`?Ae(r):void 0;throw this.creating.set({state:`error`,workspaceId:e.workspaceId,reason:i,...a===void 0?{}:{message:a},token:e.token,...e.initialPrompt===void 0?{}:{initialPrompt:e.initialPrompt}}),r}}handoffPendingDraft(e,t){let n=this.sessions.binding(e),r=this.ctx.get(`conversation`);t===void 0?n!==void 0&&r!==void 0&&r.input.adoptPendingDraft(n):((n===void 0||r===void 0)&&this.draftPreparationFailed(),r.input.adoptPendingDraft(n,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,ge(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 Ee(n.error);return n.value}async createDirectory(e,t){let n=await this.directoryPicker.createDirectory(e,t);if(!n.ok)throw new Ee(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??Me(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)}releaseMainSelection(){let e=this.mainReference;this.mainReference=void 0,this.recentVisits.clearCurrent(),this.selection.set({}),e?.release()}clearMain(){this.releaseMainSelection(),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 Oe(e){return e instanceof Error&&e.name===`SessionCreateError`?e:void 0}var ke=class extends Error{name=`WorkspaceRequiredError`;constructor(){super(`This Host requires a Workspace.`)}};function K(e){return Oe(e)?.rpcError.code===`host/no-harness`?`no-harness`:e instanceof ke?`workspace-required`:`unknown`}function Ae(e){let t=Oe(e),n=(t===void 0?e instanceof Error?e.message:String(e):t.rpcError.message).trim();return n===``?void 0:n}function je(e){let t=Oe(e);return t===void 0?e instanceof Error?e.message:String(e):`${t.rpcError.code}: ${t.rpcError.message}`}function Me(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 Ne=`@deepseek-ai/dsh-client-ui-workspace/PhoneHeaderNewSession.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=`.--73Qq_button{display:none}[data-phone] .--73Qq_button{corner-shape:round;width:34px;height:34px;color:var(--dsw-alias-label-primary);cursor:pointer;-webkit-app-region:no-drag;-webkit-tap-highlight-color:transparent;background:0 0;border:0;border-radius:9999px;flex:none;justify-content:center;align-items:center;padding:0;transition:transform .14s,background-color .14s;display:inline-flex;position:relative}[data-phone] .--73Qq_button:after{content:"";position:absolute;inset:-5px -1px}[data-phone] .--73Qq_icon{width:17px;height:17px}[data-phone] .--73Qq_button:active{background:color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent);transform:scale(.92)}[data-phone] .--73Qq_button:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:-2px}@media (prefers-reduced-motion:reduce){[data-phone] .--73Qq_button{transition:none}[data-phone] .--73Qq_button:active{transform:none}}@media (forced-colors:active){[data-phone] .--73Qq_button{color:buttontext}[data-phone] .--73Qq_button:focus-visible{outline-color:highlight}}`,document.head.appendChild(e)}var Pe={button:`--73Qq_button`,icon:`--73Qq_icon`};function Fe({startSession:e,useShortcuts:t,t:n}){let r=t(e=>e.find(e=>e.id===`session.new`));return/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:n(`actions.newSession`),shortcutKeys:r?.keys,side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Pe.button,"aria-label":n(`actions.newSession`),"aria-keyshortcuts":r?.aria,"data-phone-new-session":!0,onClick:()=>{e()},children:/* @__PURE__ */ (0,o.jsx)(a.IconNewChatOutlineRegular,{size:17,className:Pe.icon})})})}let Ie=`@deepseek-ai/dsh-client-ui-workspace/RecentShortcut.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ie)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Ie,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;-webkit-tap-highlight-color:transparent;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:28px;color:var(--dsw-alias-label-secondary);flex:0 0 28px;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:none}@media (hover:hover) and (pointer:fine){.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 Le={activity:`oOF3UG_activity`,close:`oOF3UG_close`,identity:`oOF3UG_identity`,select:`oOF3UG_select`,shortcut:`oOF3UG_shortcut`,title:`oOF3UG_title`};function Re({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,s.useRef)(null),h=(0,s.useCallback)(e=>{e===null&&m.current?.contains(document.activeElement)&&p(),m.current=e},[p]);return/* @__PURE__ */ (0,o.jsxs)(`div`,{ref:h,className:Le.shortcut,"data-active":c||void 0,children:[/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,className:Le.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,o.jsx)(`span`,{className:Le.identity,children:n}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Le.title,children:t.displayTitle}),i!=null&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:Le.activity,title:r,children:i})]}),/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Le.close,onMouseDown:e=>e.preventDefault(),"aria-label":l,title:u,onClick:()=>{p(),f(e.sessionId)},children:/* @__PURE__ */ (0,o.jsx)(a.IconCloseOutlineRegular,{size:12})})]})}let ze=`@deepseek-ai/dsh-client-ui-workspace/Rows.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(ze)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=ze,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(:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen),._5OaiBG_sessionRow:is(: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(: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))}@media (hover:hover){._5OaiBG_projectRow:hover,._5OaiBG_sessionRow:hover{--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:hover{--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_identityButton:after{content:"";position:absolute;inset:-6px -4px -6px -8px}@media (hover:none),(pointer:coarse){._5OaiBG_sessionRow:not(:has(>[data-thread-summary])) ._5OaiBG_identityButton:after{inset:-12px -6px -12px -8px}}._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}@media (hover:hover){._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}body[data-codexhost-wallpaper] :is(._5OaiBG_projectRow,._5OaiBG_sessionRow){--dsh-row-surface:transparent}body[data-codexhost-wallpaper] :is(._5OaiBG_projectRow,._5OaiBG_sessionRow):is(:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen){--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}body[data-codexhost-wallpaper] ._5OaiBG_sessionRow._5OaiBG_selected{--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent)}body[data-codexhost-wallpaper] ._5OaiBG_sessionRow._5OaiBG_selected:is(:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen){--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent)}@media (hover:hover){body[data-codexhost-wallpaper] :is(._5OaiBG_projectRow,._5OaiBG_sessionRow):hover{--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}body[data-codexhost-wallpaper] ._5OaiBG_sessionRow._5OaiBG_selected:hover{--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent)}}@media (hover:hover) and (pointer:fine){body[data-codexhost-wallpaper] :is(._5OaiBG_projectRow>._5OaiBG_rowActions,._5OaiBG_sessionRow ._5OaiBG_rowActions){background:color-mix(in srgb, var(--dsw-specific-sidebar-fill) 82%, transparent);backdrop-filter:blur(10px)}body[data-codexhost-wallpaper] :is(){display:none}}[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 q={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 Be(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 Ve(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 Ve(e){throw Error(`unknown pending interaction: ${String(e)}`)}function He({statuses:e}){return/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.StateDot,{state:e[0].state,size:e[0].state===`ongoing`?16:void 0}),e.map(e=>/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.visuallyHidden,children:e.label},e.label))]})}let Ue=`@deepseek-ai/dsh-client-ui-workspace/RecentNavigation.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ue)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Ue,e.textContent=`.qXmkFa_trigger,.qXmkFa_shortcuts{display:none}[data-phone] .qXmkFa_trigger{width:auto;height:auto;color:var(--dsw-alias-label-secondary);cursor:pointer;-webkit-tap-highlight-color:transparent;-webkit-app-region:no-drag;-webkit-tap-highlight-color:transparent;background:0 0;border:0;border-radius:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[data-phone] .qXmkFa_trigger:after{content:"";position:absolute;inset:-12px -10px}[data-phone] .qXmkFa_trigger>svg{transition:transform .18s;display:block}.qXmkFa_trigger[aria-disabled=true]{cursor:wait}.qXmkFa_trigger:focus-visible{outline:none}.qXmkFa_expanded{transform:rotate(180deg)}@media (prefers-reduced-motion:reduce){[data-phone] .qXmkFa_trigger>svg{transition:none}}[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;-webkit-tap-highlight-color:transparent;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:none}@media (hover:hover) and (pointer:fine){.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 We={clear:`qXmkFa_clear`,expanded:`qXmkFa_expanded`,shortcuts:`qXmkFa_shortcuts`,trigger:`qXmkFa_trigger`};function Ge({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:Be(L(t,o,c),i)}]})}function Ke(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=Ge(e),m=f&&p.length>0,h=(0,s.useRef)(null),[g,_]=(0,s.useState)(!1),v=(0,s.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,s.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,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsxs)(`nav`,{ref:h,className:We.shortcuts,"aria-label":d(`recent.navigation`),onScroll:e=>v(e.currentTarget),children:[p.map(({visit:t,summary:i,statuses:a})=>/* @__PURE__ */ (0,o.jsx)(Re,{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,o.jsx)(He,{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,o.jsx)(`button`,{type:`button`,className:We.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,o.jsx)(a.Toast,{text:d(`recent.closeFailed`),onDone:()=>_(!1)})]}):null}function qe(e){let{useRecentNavigationSettings:t,setEnabled:n,t:r}=e,i=t(e=>e.value?.showRecentVisits??!0),c=Ge(e),[l,u]=(0,s.useState)(!1),[d,f]=(0,s.useState)(!1),p=(0,s.useRef)(!1);return/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[c.length>0&&/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,"data-navigation-focus-return":!0,className:We.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,o.jsx)(a.IconChevronDownOutlineRegular,{size:14,className:i?We.expanded:void 0})}),d&&/* @__PURE__ */ (0,o.jsx)(a.Toast,{text:r(`recent.settings.error`),onDone:()=>f(!1)})]})}function Je(e){return e==null}function Ye(e){return e&&typeof e==`object`&&!Array.isArray(e)}function Xe(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function Ze(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function Qe(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 $e=Symbol.for(`cosmokit.volatile.write`);function et(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=>et(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,et(n,t)])))}finally{t.delete(e)}}function tt(e){let t=et(e);return Object.freeze({get:()=>t,[$e]:e=>{t=e}})}function nt(e){return typeof e==`object`&&!!e&&$e in e}function rt(e,t){return arguments.length===1?t=>rt(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function it(e){return rt(`ArrayBuffer`,e)||rt(`SharedArrayBuffer`,e)}function at(e){return it(e)||ArrayBuffer.isView(e)}let ot;(function(e){e.is=it,e.isSource=at;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})(ot||={}),ot.fromBase64,ot.toBase64,ot.fromHex,ot.toHex;function st(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(rt(`Date`,e))return new Date(e.valueOf());if(rt(`RegExp`,e))return new RegExp(e.source,e.flags);if(it(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(st,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(st,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function ct(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(nt(e)||nt(t))return nt(e)&&nt(t);if(!n&&Je(e)&&Je(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(rt(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(rt(`URL`),(e,t)=>e.href===t.href)??a(rt(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(it,(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 lt;(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})(lt||={});let ut=Symbol.for(`schemastery`),dt=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?.[dt]}};Object.defineProperty(J.prototype,dt,{value:!0});let Y=function(e){let t=function(e,n={}){return Y.resolve(e,t,n)[0]};if(e.refs){let t=Ze(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&&Ze(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[ut]=!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 ft(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 pt(e){return e?.$value??e?.$inner}function mt(e){return Xe(e??{},e=>!e.startsWith(`$`))}Y.prototype.i18n=function(e){let t=Y(this),n=ft(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=Ze(t.dict,(t,n)=>t.i18n(Ze(e,e=>pt(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(Ze(e,(e={})=>Array.isArray(pt(e))?pt(e)[n]:Array.isArray(e)?e[n]:mt(e)))),t.inner&&=t.inner.i18n(Ze(e,e=>pt(e)?pt(e):mt(e))),t.sKey&&=t.sKey.i18n(Ze(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=Qe(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},Y.prototype.simplify=function(e){if(nt(e)&&(e=e.get()),ct(e,this.meta.default,this.type===`dict`))return null;if(Je(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`||!Je(r))&&(t[n]=r)}return ct(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 Ct[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 ht={},gt=Symbol(`checked-volatile-schema`);function _t(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))_t(i,[...t,n],a,r);if(e.sKey&&_t(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[ut])&&_t(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)_t(e.list[n],[...t,String(n)],!0,r)}Y.extend=function(e,t){ht[e]=t},Y.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[gt]||(_t(t,n.path),n={...n,[gt]:!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[tt(a),o]}catch(e){throw new J(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(Je(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`&&Je(i);)r=r.list[0],i=r?.meta.default;if(Je(i))return[e];e=st(i)}let i=ht[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(Je(e))return Y.any();if([`string`,`number`,`boolean`].includes(typeof e))return Y.const(e).required();if(e[ut])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[ut]||(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(ot.isSource(e))return ot.fromSource(e);throw new J(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[Y.transform(Y.string(),(t,n)=>{try{return e===`base64`?ot.fromBase64(t):ot.fromHex(t)}catch(e){throw new J(e.message,n)}},!0)]:[]])},Y.extend(`lazy`,(e,t,n,r)=>(t.inner[ut]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},_t(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(ct(e,t))return[t];throw new J(`expected ${t} but got ${e}`,n)});function vt(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 vt(e.length,t,`string length`,n),[e]});function yt(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 bt(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(yt(e,i)-yt(t,i))%yt(n,i)===0}Y.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new J(`expected number but got ${e}`,n);vt(e,t,`number`,n);let{step:r}=t;if(r&&!bt(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(Je(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 xt(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?tt(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 vt(e.length,n,`array length`,r,!Je(t.meta.default)),[e.map((n,i)=>xt(e,i,t,r))]}),Y.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!Ye(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]=xt(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)=>xt(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function St(e,t){for(let n in t)n in e||(e[n]=t[n])}Y.extend(`object`,(e,{dict:t},n,r)=>{if(!Ye(e))throw new J(`expected object but got ${e}`,n);let i={};for(let r in t){let a=xt(e,r,t[r],n);(!Je(a)||r in e)&&(i[r]=a)}return r||St(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(!Je(t)){if(Je(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`)St(a??={},t);else if(a!==t)throw new J(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&Ye(e)&&St(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 Ct={};function X(e,t,n){Ct[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=Ze(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 wt=[0,15,30,60,120,240,1440],Tt={showRecentVisits:!0,tabIdleTimeoutMinutes:60},Et={showRecentVisits:Y.boolean().default(!0),tabIdleTimeoutMinutes:Y.natural().max(1440).default(60)},Dt=`@deepseek-ai/dsh-client-ui-workspace/RecentNavigationRow.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Dt)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Dt,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 Ot={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 kt({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,s.useState)(!1),[f,p]=(0,s.useState)(!1),[m,h]=(0,s.useState)(!1),g=(0,s.useRef)(!1),_=(0,s.useId)();(0,s.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,o.jsxs)(`div`,{children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Ot.row,children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Ot.text,children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Ot.titleLine,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:Ot.title,children:r(`recent.settings.title`)}),/* @__PURE__ */ (0,o.jsx)(a.Tag,{tone:`neutral`,children:r(`recent.settings.mobile`)})]}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:Ot.description,children:r(`recent.settings.description`)})]}),/* @__PURE__ */ (0,o.jsx)(a.Switch,{checked:c,disabled:f,label:`${r(`recent.settings.title`)} · ${r(`recent.settings.mobile`)}`,onChange:e=>y(()=>t(e))})]}),c&&/* @__PURE__ */ (0,o.jsxs)(`div`,{className:`${Ot.row} ${Ot.timeoutRow}`,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:Ot.text,children:/* @__PURE__ */ (0,o.jsx)(`div`,{className:Ot.title,id:`${_}-label`,children:r(`recent.timeout.title`)})}),/* @__PURE__ */ (0,o.jsx)(a.Menu,{className:Ot.menu,open:u&&c&&!f,onClose:()=>d(!1),items:wt.map(e=>({id:String(e),label:e===60?r(`recent.timeout.default`,{value:v(e)}):v(e)})),selectedId:String(l),onSelect:e=>{let t=wt.find(t=>String(t)===e);t!==void 0&&y(()=>n(t))},align:`end`,portal:!0,anchor:/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,className:Ot.selector,disabled:!c||f,"aria-labelledby":`${_}-label ${_}-value`,"aria-haspopup":`menu`,"aria-expanded":u&&c&&!f,onClick:()=>d(e=>!e),children:[/* @__PURE__ */ (0,o.jsx)(`span`,{id:`${_}-value`,children:v(l)}),/* @__PURE__ */ (0,o.jsx)(a.IconChevronDownOutlineRegular,{size:14})]})})]}),m&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Ot.error,role:`alert`,children:r(`recent.settings.error`)})]})}function At(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.trailing`,()=>e.slots.register({name:`conversation.header.trailing`,locale:`workspace`,inject:()=>({startSession:()=>t.startSession(),hooks:{shortcuts:e.shortcuts.catalog}})},Fe)),e.slots.inject(`conversation.header.navigation`,()=>e.slots.register({name:`conversation.header.navigation`,locale:`workspace`,inject:o},qe)),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`}}},Ke)),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})},kt))}let jt=`@deepseek-ai/dsh-client-ui-workspace/ThreadTreeStyle.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=`.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 Mt=[`summary`,`ring`];function Nt(e){let[t,n]=(0,s.useState)(!1),[r,i]=(0,s.useState)(!1),a=(0,s.useRef)(!1);return{busy:t,failed:r,save:async t=>{if(a.current)return!1;a.current=!0,n(!0),i(!1);try{let n=await e(t);return i(!n),n}catch{return i(!0),!1}finally{a.current=!1,n(!1)}}}}function Pt({style:e,setStyle:t,t:n,settings:r=!1}){let i=(0,s.useId)(),{busy:c,failed:l,save:u}=Nt(t);return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:r?a.preferenceRowStyles.row:Z.options,children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:`${a.preferenceRowStyles.rowText} ${r?Z.settingsText:``}`,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:a.preferenceRowStyles.title,id:i,children:n(`threadTree.style.title`)}),r&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:a.preferenceRowStyles.description,id:`${i}-description`,children:n(`threadTree.style.description`)})]}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:a.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:Mt.map(t=>/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,role:`radio`,className:a.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,o.jsx)(`div`,{className:Z.error,role:`alert`,children:n(`threadTree.style.error`)})]})}function Ft({usePreference:e,setStyle:t,t:n}){let r=e(e=>e.value?.threadTreeCollapseStyle??`summary`);return/* @__PURE__ */ (0,o.jsx)(Pt,{style:r,setStyle:t,t:n,settings:!0})}function It({usePreference:e,setMode:t,t:n}){let r=e(e=>e.value?.archiveChildren??`ask`),[i,c]=(0,s.useState)(!1),[l,u]=(0,s.useState)(!1);return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:a.preferenceRowStyles.row,children:[/* @__PURE__ */ (0,o.jsxs)(`label`,{className:a.preferenceRowStyles.rowText,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:a.preferenceRowStyles.title,children:n(`archive.children.preference`)}),/* @__PURE__ */ (0,o.jsx)(`select`,{value:r,disabled:i,onChange:async({target:e})=>{let n=Lt.find(t=>t===e.value);if(n&&n!==r){c(!0),u(!1);try{u(!await t(n))}catch{u(!0)}finally{c(!1)}}},children:Lt.map(e=>/* @__PURE__ */ (0,o.jsx)(`option`,{value:e,children:n(`archive.children.${e}`)},e))})]}),l&&/* @__PURE__ */ (0,o.jsx)(`span`,{role:`alert`,children:n(`archive.children.preferenceFailed`)})]})}let Lt=[`ask`,`always`,`never`],Rt={...Tt,threadTreeCollapseStyle:`summary`,archiveChildren:`ask`},zt=Y.object({...Et,threadTreeCollapseStyle:Y.union([`summary`,`ring`]).default(`summary`),archiveChildren:Y.union([...Lt]).default(`ask`)});function Bt(e){return typeof e==`object`&&!!e&&Object.hasOwn(e,`threadTreeCollapseStyle`)}function Vt(e){let t=e.configForms.registerBrowser(`ui-workspace`,zt.toJSON(),{...Rt});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)})},Ft)),e.slots.inject(`settings.general.item`,()=>e.slots.register({name:`settings.general.item`,id:`workspace.archive-children`,order:11.6,locale:`workspace`,inject:()=>({hooks:{preference:t},setMode:e=>t.set(`archiveChildren`,e)})},It)),t}function Ht(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 Ut(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=Ut(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=Ut(e))&&(r&&(r+=` `),r+=t);return r}function Wt(e,t){return e===`default-workspace`?t:e}let Gt={},Kt=(0,s.createContext)({t:e=>e,expansion:Gt,rows:e=>T(e,Gt),toggle:()=>{},markCompletionsRead:()=>{},collapseStyle:`summary`,stylePrompt:void 0,dismissStylePrompt:()=>{},setCollapseStyle:async()=>!1,rootId:e=>e,reveal:()=>{},selectSidebarRow:()=>{},isSidebarSelection:()=>!1});function qt(){return(0,s.useContext)(Kt)}function Jt({browser:e,children:t}){let{useSessions:n,useStore:r,useWorkspaces:i,actions:a,useWorkspacePreferences:c,setThreadTreeCollapseStyle:l}=e,u=c(e=>e),d=Bt(u.user),f=u.value?.threadTreeCollapseStyle??`summary`,[p,m]=(0,s.useState)(),h=(0,s.useCallback)(()=>m(void 0),[]),g=n(e=>e),_=i(e=>e),v=r(e=>e.threadExpansion??Gt),y=r(e=>e.archivedFilter??`default`),b=(0,s.useMemo)(()=>R(g,{pinnedSessionIds:_.pinnedSessionIds,archivedSessionIds:_.archivedSessionIds,archivedFilter:y,...y===`only`||!_.threadSections?.length?{}:{sectionedSessionIds:new Set(_.threadSections.flatMap(e=>e.threadIds))}},/* @__PURE__ */ new Map),[g,_,y]),x=(0,s.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,s.useRef)(void 0),C=(0,s.useCallback)(e=>S.current===e,[]),w=(0,s.useCallback)(e=>{S.current=e,a.setThreadsExpanded(x.get(e)?.ancestors??[],!0)},[a,x]),E=(0,s.useCallback)(e=>{S.current=void 0;let t=x.get(e);t!==void 0&&a.setThreadsExpanded(t.ancestors,!0)},[a,x]),D=Object.values(g.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,O=(0,s.useRef)(``);(0,s.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,s.useMemo)(()=>({t:e.t,expansion:v,rows:e=>T(e,v),toggle:(e,t,n)=>{a.setThreadsExpanded([e],t),t&&n!==void 0&&!d&&m(n)},markCompletionsRead:e.markCompletionsRead??(()=>{}),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,e.markCompletionsRead,a,v,x,E,w,C,f,d,p,h,l]);return/* @__PURE__ */ (0,o.jsx)(Kt.Provider,{value:k,children:t})}function Yt({identity:e,ambient:t,title:n,onIdentityClick:r,identityLabel:i,identityControls:a,identityExpanded:s,children:c}){let l=/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[e,/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.statusOverlay,children:t})]});return/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[r?/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,className:`${q.slot} ${q.identityButton}`,onClick:r,"data-thread-icon-toggle":!0,"aria-label":i,title:i,"aria-expanded":s,"aria-controls":a,children:[l,/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.foldChevron,"aria-hidden":`true`})]}):/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.slot,children:l}),/* @__PURE__ */ (0,o.jsx)(`span`,{"data-session-title":!0,className:q.title,children:n}),c]})}function Xt({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,o.jsxs)(`span`,{className:q.hostBadge,"data-host-id":e?.hostId??`local`,"data-state":e?.state??`local`,role:`img`,"aria-label":i,title:i,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{children:n}),e&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.hostDot,"aria-hidden":`true`})]})}let Zt=`@deepseek-ai/dsh-client-ui-workspace/ThreadTreeControls.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Zt)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Zt,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 Qt={branch:`jGgv6G_branch`,children:`jGgv6G_children`,summary:`jGgv6G_summary`};function $t(e){return[{state:`running`,count:e.running},{state:`pending`,count:e.pendingInteraction},{state:`completed`,count:e.completed}]}function en(e){return e.pendingInteraction>0?`pending`:e.running>0?`running`:e.completed>0?`completed`:`idle`}function tn(e,t,n){return[n(`threadTree.children`,{n:e}),...$t(t).filter(e=>e.count>0).map(e=>n(`threadTree.${e.state}`,{n:e.count}))].join(` · `)}function nn({count:e,activity:t,t:n}){return/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[n(`threadTree.children`,{n:e}),$t(t).filter(e=>e.count>0).map(e=>/* @__PURE__ */ (0,o.jsx)(`span`,{"data-thread-tree-activity":e.state,children:` · ${n(`threadTree.${e.state}`,{n:e.count})}`},e.state))]})}let rn=`@deepseek-ai/dsh-client-ui-workspace/ThreadTreeRing.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(rn)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=rn,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 an={ring:`yY-O0a_ring`,spin:`yY-O0a_spin`};function on({activity:e}){return/* @__PURE__ */ (0,o.jsx)(`span`,{className:an.ring,"data-thread-ring":en(e),"aria-hidden":`true`,children:/* @__PURE__ */ (0,o.jsx)(`svg`,{viewBox:`0 0 22 22`,fill:`none`,children:/* @__PURE__ */ (0,o.jsx)(`circle`,{cx:`11`,cy:`11`,r:`10.25`})})})}let sn=[{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 cn({style:e,t}){return/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.preview,"aria-hidden":`true`,children:sn.map(({title:n,activity:r})=>/* @__PURE__ */ (0,o.jsx)(`div`,{className:Qt.branch,children:/* @__PURE__ */ (0,o.jsxs)(`div`,{className:`${q.sessionRow} ${Z.sampleRow}`,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:q.sessionMain,children:/* @__PURE__ */ (0,o.jsx)(Yt,{title:t(n),identity:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(`span`,{"data-harness-id":`codex`,className:Z.sampleIcon,children:/* @__PURE__ */ (0,o.jsx)(`img`,{src:`/harness-icons/codex`,width:14,height:14,alt:``})}),e===`ring`&&/* @__PURE__ */ (0,o.jsx)(on,{activity:r})]})})}),e===`summary`&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:`${Qt.summary} ${Z.sampleSummary}`,children:/* @__PURE__ */ (0,o.jsx)(nn,{count:2,activity:r,t})})]})},n))})}function ln({style:e,setStyle:t,onLater:n,onExit:r,t:i}){let a=(0,s.useId)(),[c,l]=(0,s.useState)(e),u=(0,s.useRef)(null),d=(0,s.useRef)(r);d.current=r,(0,s.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}=Nt(t);return/* @__PURE__ */ (0,o.jsxs)(`div`,{ref:u,className:Z.prompt,"data-thread-style-prompt":!0,role:`region`,"aria-labelledby":a,children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Z.promptHeading,children:[/* @__PURE__ */ (0,o.jsx)(`strong`,{id:a,children:i(`threadTree.style.promptTitle`)}),/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Z.later,disabled:f,onClick:n,children:i(`threadTree.style.later`)})]}),/* @__PURE__ */ (0,o.jsx)(`p`,{className:Z.hint,children:i(`threadTree.style.hint`)}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.comparison,role:`radiogroup`,"aria-labelledby":a,"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`?Mt[e.key===`Home`?0:1]:Mt[+(c===`summary`)];e.currentTarget.querySelector(`[data-thread-style-choice="${t}"]`)?.focus()},children:Mt.map(t=>/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,role:`radio`,className:Z.choice,"data-thread-style-choice":t,"aria-disabled":f,"aria-checked":e===t,"aria-labelledby":`${a}-${t}`,"aria-describedby":`${a}-${t}-description`,tabIndex:c===t?0:-1,onFocus:()=>l(t),onClick:()=>void m(t),children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:Z.choiceTitle,id:`${a}-${t}`,children:i(`threadTree.style.${t}`)}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Z.choiceSubtitle,id:`${a}-${t}-description`,children:i(`threadTree.style.${t}Subtitle`)}),/* @__PURE__ */ (0,o.jsx)(cn,{style:t,t:i})]},t))}),p&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.error,role:`alert`,children:i(`threadTree.style.error`)})]})}let un=(0,s.createContext)(void 0),dn=()=>(0,s.useContext)(un);function fn({roots:e,children:t}){return e.map(e=>/* @__PURE__ */ (0,o.jsx)(pn,{node:e,renderRow:t},e.id))}function pn({node:e,renderRow:t}){let n=(0,s.useId)(),{expansion:r,stylePrompt:i,dismissStylePrompt:a,collapseStyle:c,setCollapseStyle:l,t:u}=qt(),d=r[e.id]===!0,f=e.tree?.depth??0,p=e.tree?.children??[];return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Qt.branch,"data-thread-branch":!0,children:[/* @__PURE__ */ (0,o.jsx)(un.Provider,{value:n,children:t(e)}),d&&i===n&&/* @__PURE__ */ (0,o.jsx)(ln,{style:c,setStyle:l,onLater:a,onExit:()=>document.querySelector(`[data-thread-icon-toggle][aria-controls="${CSS.escape(n)}"]`)?.focus({preventScroll:!0}),t:u}),p.length>0&&/* @__PURE__ */ (0,o.jsx)(`div`,{id:n,role:`group`,hidden:!d,"data-thread-guide":d&&f<3?``:void 0,className:Qt.children,style:{"--dsh-thread-guide-indent":`${Math.min(f,3)*24}px`},children:d&&/* @__PURE__ */ (0,o.jsx)(fn,{roots:p,children:t})})]})}function mn({node:e,title:t,toggle:n,t:r}){let i=dn(),a=(0,s.useRef)(null);(0,s.useLayoutEffect)(()=>{let e=a.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=tn(c.descendantCount,c.activity,r);return/* @__PURE__ */ (0,o.jsx)(`button`,{ref:a,type:`button`,"data-thread-summary":!0,className:Qt.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,o.jsx)(nn,{count:c.descendantCount,activity:c.activity,t:r})})}function hn(e,t){return e.blank?t(`session.new`):e.title||t(`session.untitled`)}function gn(e,t,n){let{unit:r,n:i}=(0,a.relativeTime)(e,t);return r===`now`?n(`time.now`):n(`time.${r}`,{n:i})}function _n(e,t,n){let{unit:r,n:i}=(0,a.relativeTime)(e,t);return r===`now`?n(`time.now`):n(`time.ago`,{t:n(`time.${r}`,{n:i})})}function vn(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 yn({label:e,cwd:t,createdAt:n,t:r}){return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:q.hoverContent,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:q.hoverTitle,children:e}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:q.hoverPath,children:t}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:q.hoverTime,children:vn(n,r)})]})}function bn(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function xn({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,s.useState)(!1),[_,v]=(0,s.useState)(null),b=[{id:`rename`,label:u(`rename`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconEditOutlineRegular,{})},{id:`delete`,label:u(`delete.workspace`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconTrashOutlineRegular,{}),danger:!0}],x=/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q(q.projectRow,h&&q.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,o.jsx)(`span`,{className:Q(q.slot,d.expanded&&q.folderExpanded),children:d.expanded?/* @__PURE__ */ (0,o.jsx)(a.IconFolderOpenRegular,{}):/* @__PURE__ */ (0,o.jsx)(a.IconFolderCloseRegular,{})}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.projectText,children:/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.title,children:m})}),d.workspaceId!==void 0&&d.remote&&/* @__PURE__ */ (0,o.jsx)(Xt,{host:d.remote,t:u}),/* @__PURE__ */ (0,o.jsxs)(`span`,{className:q.rowActions,children:[f!==void 0&&/* @__PURE__ */ (0,o.jsx)(a.Menu,{open:h,onClose:()=>{g(!1)},items:b,onSelect:e=>{
9
+ default:return v(n)}}function ae(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 oe(e){return e.blank?``:e.title?.trim()??``}function se(e){let t=Date.parse(e);return Number.isFinite(t)&&t>0?t:void 0}function k(e,t,n,r,i,a,o){return{key:e,workspaceId:t,cwd:n,createdAt:r,label:i,sessions:[...a],remote:o}}function ce(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&&ie(a,n,r)&&t.push(a)}(r!==`only`||t.length!==0)&&i.push(k(a.workspaceId,a.workspaceId,a.path,se(a.createdAt),a.title,t,a.remote))}let a=O(e.ids,e.byId).map(t=>e.byId[t]).filter(e=>e!==void 0&&ie(e,n,r));return a.length>0&&i.push(k(``,void 0,void 0,void 0,``,a)),i}function le(e){switch(e){case`approval`:case`plan-review`:case`question`:return e;default:return}}function ue(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 de(e,t,n){let r=n.get(e.id),i=le(r?.pendingInteraction?.kind);return{running:r?.running??e.running,runningSubagentCount:ue(t,e.id,n),completed:r?.completionUnread===!0,...i===void 0?{}:{pendingInteraction:i}}}function fe(e,t,n,r,i){return{id:e.id,reference:S(e),remote:e.projectionValues?.remoteHost??void 0,title:oe(e),...e.cwd===void 0?{}:{cwd:e.cwd},blank:e.blank,...de(e,t,n),pinned:!i.has(e.id)&&r.has(e.id),archived:i.has(e.id),updatedAt:e.updatedAt}}function A(e,t){let n=e.projectionValues?.threadTreeParent??null;if(n===null)return null;let r=t?.byId[p(n)];return r===void 0?null:(e.projectionValues?.threadReference?.hostId??e.projectionValues?.remoteHost?.hostId??`local`)===(r.projectionValues?.threadReference?.hostId??r.projectionValues?.remoteHost?.hostId??`local`)?n:null}function pe(e,t,n){let r=new Set(t.archivedSessionIds),i=new Set(t.pinnedSessionIds);return w(ge(e,t.archivedSessionIds,t.archivedFilter).flatMap(t=>{let a=e.byId[t];return a===void 0?[]:[fe(a,e,n,i,r)]}),n=>{if(t.sectionedSessionIds?.has(n.id))return null;let r=e.byId[n.id];return r===void 0?null:A(r,e)})}function me(e,t,n,r,i){let a=new Set(n.archivedSessionIds),o=new Set(n.pinnedSessionIds),s=new Set(i.expandedGroups),c=E(e),l=new Map(pe(e,n,r).map(e=>[e.id,e])),u=[];for(let r of ce(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||n.sectionedSessionIds?.has(t.id))?[]:[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?ae(t,o,a):[]})}return u}function he(e,t=[]){return[...ge(e,[],`show`),...t.filter(t=>e.byId[t]===void 0)]}function ge(e,t,n){let r=new Set(t);return e.ids.filter(t=>{let i=e.byId[t];return i!==void 0&&ie(i,r,n)})}function _e(e,t,n,r){let i=new Set(n.archivedSessionIds),a=new Set(n.pinnedSessionIds),o=new Map(pe(e,n,r).map(e=>[e.id,e]));return ae(t.flatMap(e=>{let t=o.get(e);return t===void 0?[]:[t]}),a,i)}function ve(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)??D(e.cwd),f=/* @__PURE__ */ new Map;for(let e of o.items)f.has(e.sessionId)||f.set(e.sessionId,e);let m=[];for(let t of e.ids){let n=e.byId[t];n!==void 0&&!n.blank&&ie(n,l,i)&&(oe(n).toLowerCase().includes(c)||d(n).toLowerCase().includes(c))&&m.push(n)}let h=new Map(m.map(e=>[e.id,e])),g=O(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&&ie(n,l,i)&&y(n)}return{items:_.slice(0,s).map(t=>{let n=f.get(t.id),r=a.get(t.id),i=le(r?.pendingInteraction?.kind),o=A(t,e);return{id:t.id,title:oe(t),workspace:d(t),...o===null?{}:{parentTitle:e.byId[p(o)]?.title??``},remote:t.projectionValues?.remoteHost??void 0,running:r?.running??t.running,runningSubagentCount:ue(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 ye(e){return(/^[A-Za-z]:[/\\]/.test(e)||e.startsWith(`\\\\`)?e.replaceAll(`\\`,`/`):e).replace(/\/+$/,``)}function be(e,t){let n=ye(e),r,i=-1;for(let e of t){let t=ye(e);t.length>i&&n!==t&&n.startsWith(`${t}/`)&&(r=e,i=t.length)}return r}let xe=`__flat_session_order__`,Se=`pinned`,Ce=`workspaces`;function we(e,t){return e?.[t]??!0}function Te(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 j(){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`?Te(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,Te(t,e.sessionOrderByAccount,n))},setSessionOrder:(e,t,n,r,i)=>{let a=Te({...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=Te(Object.fromEntries(Object.entries(r.members).map(([t,n])=>[t,ne(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 Ee(e,t){let n=pe(e,t,/* @__PURE__ */ new Map),r=new Set(ge(e,t.archivedSessionIds,t.archivedFilter)),i=/* @__PURE__ */ new Set([...n.map(e=>e.id),...he(e,t.archivedSessionIds).filter(e=>!r.has(e))]),a=/* @__PURE__ */ new Map,o={...e.byId};for(let e of n){for(let t of e.tree?.descendantIds??[])a.set(p(t),e.id);let t=o[e.id];t!==void 0&&(o[e.id]={...t,updatedAt:e.tree?.updatedAt??e.updatedAt})}return{rootIds:i,rootOf:a,summaries:o}}function De(e,t){let n=new Set(e),r=[],i=/* @__PURE__ */ new Set;for(let a of e){if(t.summaries[a]===void 0||t.rootIds.has(a)){r.push(a);continue}let e=t.rootOf.get(a);e===void 0||n.has(e)||i.has(e)||(i.add(e),r.push(e))}return{memberIds:r,linkedRootIds:i}}function Oe(e,t,n){let r=Ee(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,De(e.sessionIds,r).memberIds]),[``,i([.../* @__PURE__ */ new Set([...t.ids,...n.archivedSessionIds])]).filter(e=>!a.has(e))],[xe,i(he(t,n.archivedSessionIds))]]),summaries:r.summaries,rowState:n}}function ke(e,t){return[T(e,t),xe]}var Ae=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 je=`codexhost.web.session-tabs.v2:local`,Me=`codexhost.web.session-tabs.v1:local`,Ne=`codexhost.web.recent-visits.v1:local`,Pe=1048576;function Fe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ie(e){return typeof e==`string`&&e.length>0&&e.length<=1024&&e.trim()===e&&!/[\u0000-\u001f\u007f]/u.test(e)?p(e):void 0}function Le(e,t){if(typeof e==`string`)return e===t?t:void 0;if(!Fe(e)||Object.keys(e).length!==3)return;let n=Ie(e.parentSessionId),r=Ie(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 M(e,t){if(e===null||e.length>Pe)return[];try{let n=JSON.parse(e);if(!Fe(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(!Fe(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=Ie(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=Le(e.target,o);c!==void 0&&(i.add(o),r.push({sessionId:o,target:c,lastVisitedAt:s}))}return r}catch{return[]}}var Re=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>Pe){this.failed();return}localStorage.getItem(je)!==i&&localStorage.setItem(je,i),localStorage.removeItem(Me),localStorage.removeItem(Ne)}catch{this.failed()}}latest(){let e=localStorage.getItem(je);return e===null?M(localStorage.getItem(Me)??localStorage.getItem(Ne),1):M(e,2)}failed(){if(!this.reported){this.reported=!0;try{this.onFailure()}catch{}}}},ze=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 Re(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=de(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)||Be(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 Be(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 Ve=class extends Error{rpcError;name=`DirectoryBrowseError`;constructor(e){super(`directory browse failed: ${e.code}: ${e.message}`),this.rpcError=e}},He=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;mainIsRemote=!1;disposeMainSessionWatch;opening=(0,r.createSnapshotStore)({state:`idle`});retryOpen;openingLoad;creating=(0,r.createSnapshotStore)({state:`idle`});retryCreate;creatingLoad;creationToken=0;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 Ae(r,n);let o=e.get(`remote`);this.recentVisits=new ze(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(),this.disposeMainSessionWatch?.(),this.disposeMainSessionWatch=void 0;let e=this.mainReference;this.mainReference=void 0,this.mainIsRemote=!1,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(Ue(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?.()}retryCreating(){this.retryCreate?.()}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){if(this.mainReference===void 0){let n=this.creating.getSnapshot(),r=n.state===`idle`?++this.creationToken:n.token,i=n.state===`idle`?void 0:n.initialPrompt;await this.runCreation({workspaceId:e,token:r,...i===void 0?{}:{initialPrompt:i},...t===void 0?{}:{beforeOpen:t}});return}let n=AbortSignal.any([this.ctx.layout.beginNavigation(),this.lifetime.signal]),r;try{if(e===null&&!this.workspaces.list.getSnapshot().canStartProjectless)throw new We;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`?qe(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();return}this.ctx.layout.selectPanel(null),this.releaseMainSelection();let u=++this.creationToken;this.runCreation({workspaceId:l,token:u,...n?.prompt===void 0?{}:{initialPrompt:n.prompt},...r?{draftOptions:n}:{}}).catch(e=>{console.warn(`new session failed:`,e)})}async runCreation(e){this.creatingLoad?.stop(),this.creatingLoad=void 0,this.retryCreate=void 0;let t=AbortSignal.any([this.ctx.layout.beginNavigation(),this.lifetime.signal]);this.openingLoad?.stop(),this.openingLoad=void 0,this.opening.set({state:`idle`}),this.retryOpen=void 0;let n={stop:()=>t.removeEventListener(`abort`,r)},r=()=>{n.stop(),this.creatingLoad===n&&(this.creatingLoad=void 0,this.retryCreate=void 0,this.creating.set({state:`idle`}))};t.addEventListener(`abort`,r,{once:!0}),this.creatingLoad=n,this.creating.set({state:`creating`,workspaceId:e.workspaceId,token:e.token,...e.initialPrompt===void 0?{}:{initialPrompt:e.initialPrompt}});try{if(e.workspaceId===null&&!this.workspaces.list.getSnapshot().canStartProjectless)throw new We;let i=e.workspaceId===null?await this.sessions.create():await this.connectWorkspace(e.workspaceId);if(t.aborted||this.creatingLoad!==n)return;this.replaceMain(i,t,`preserve`,t=>{e.beforeOpen?.(t),this.handoffPendingDraft(t,e.draftOptions)}),r()}catch(r){if(t.aborted||this.creatingLoad!==n)return;this.retryCreate=()=>{this.runCreation(e).catch(e=>{console.warn(`new session retry failed:`,e)})};let i=N(r),a=i===`unknown`?Ge(r):void 0;throw this.creating.set({state:`error`,workspaceId:e.workspaceId,reason:i,...a===void 0?{}:{message:a},token:e.token,...e.initialPrompt===void 0?{}:{initialPrompt:e.initialPrompt}}),r}}handoffPendingDraft(e,t){let n=this.sessions.binding(e),r=this.ctx.get(`conversation`);t===void 0?n!==void 0&&r!==void 0&&r.input.adoptPendingDraft(n):((n===void 0||r===void 0)&&this.draftPreparationFailed(),r.input.adoptPendingDraft(n,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,ke(t,e),Oe(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 Ve(n.error);return n.value}async createDirectory(e,t){let n=await this.directoryPicker.createDirectory(e,t);if(!n.ok)throw new Ve(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)return;let n=this.mainReference?.sessionId;if(n!==void 0&&!this.mainIsRemote&&this.isRemoteSession(n)&&(this.mainIsRemote=!0),this.clearArchivedCurrent()||this.clearRemovedRemoteCurrent()||e!==`waiting`)return;let r=this.workspaces.list.getSnapshot(),i=this.sessions.list.getSnapshot();this.mainReference===void 0?r.phase===`ready`&&i.phase===`ready`&&(e=`connecting`,this.restoreSelection(r,i,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.ctx.get(`remote`)?.$on(`api-session/removed`,e=>{this.lifetime.signal.aborted||this.clearRemovedRemoteCurrent(e)}),o=this.selection.getSnapshot();if(o.sessionId!==void 0||o.subagentAddress!==void 0){if(e=`connecting`,o.subagentAddress!==void 0)this.replaceMain(o.subagentAddress,t,`preserve`),e=`done`;else if(o.sessionId!==void 0){let r=o.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(),a?.(),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??qe(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)}isDurableSubagent(e){return this.sessions.subagentAddress(e)!==void 0||this.sessions.list.getSnapshot().byId[e]?.origin===`subagent`}isRemoteSession(e){let t=this.sessions.list.getSnapshot(),n=this.workspaces.list.getSnapshot().items,r=/* @__PURE__ */ new Set,i=e;for(;i!==void 0&&!r.has(i);){let e=i;if(r.add(e),t.byId[e]?.projectionValues?.remoteHost!=null||t.projectionsBySession[e]?.values.remoteHost!=null||n.some(t=>t.remote!==void 0&&t.sessionIds.includes(e)))return!0;i=this.sessions.subagentAddress(e)?.parentSessionId}return!1}clearRemovedRemoteCurrent(e){let t=this.mainReference;if(t===void 0||e!==void 0&&this.isDurableSubagent(e))return!1;let n=/* @__PURE__ */ new Set,r=t.sessionId,i=!1;for(;r!==void 0&&!n.has(r);){let a=r;n.add(a);let o=a===t.sessionId?t.binding:this.sessions.binding(a);if(e!==void 0&&a===e||o?.session.getSnapshot().removed===!0){i=!0;break}r=this.sessions.subagentAddress(a)?.parentSessionId}return!i||!(this.mainIsRemote||this.isRemoteSession(t.sessionId)||e!==void 0&&this.isRemoteSession(e))?!1:(this.clearMain(),!0)}releaseMainSelection(){let e=this.mainReference;this.disposeMainSessionWatch?.(),this.disposeMainSessionWatch=void 0,this.mainReference=void 0,this.mainIsRemote=!1,this.recentVisits.clearCurrent(),this.selection.set({}),e?.release()}clearMain(){this.releaseMainSelection(),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.disposeMainSessionWatch?.(),this.disposeMainSessionWatch=void 0,this.mainReference=i,this.mainIsRemote=this.isRemoteSession(i.sessionId),this.disposeMainSessionWatch=typeof i.binding.session.subscribe==`function`?i.binding.session.subscribe(()=>{this.lifetime.signal.aborted||this.clearRemovedRemoteCurrent()}):void 0,this.keepalive.visit(i,e),this.recentVisits.visit(i.sessionId,e),a?.release(),n===`reveal`&&this.ctx.layout.selectPanel(null)}};function Ue(e){return e instanceof Error&&e.name===`SessionCreateError`?e:void 0}var We=class extends Error{name=`WorkspaceRequiredError`;constructor(){super(`This Host requires a Workspace.`)}};function N(e){return Ue(e)?.rpcError.code===`host/no-harness`?`no-harness`:e instanceof We?`workspace-required`:`unknown`}function Ge(e){let t=Ue(e),n=(t===void 0?e instanceof Error?e.message:String(e):t.rpcError.message).trim();return n===``?void 0:n}function Ke(e){let t=Ue(e);return t===void 0?e instanceof Error?e.message:String(e):`${t.rpcError.code}: ${t.rpcError.message}`}function qe(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/PhoneHeaderNewSession.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=`.--73Qq_button{display:none}[data-phone] .--73Qq_button{corner-shape:round;width:34px;height:34px;color:var(--dsw-alias-label-primary);cursor:pointer;-webkit-app-region:no-drag;-webkit-tap-highlight-color:transparent;background:0 0;border:0;border-radius:9999px;flex:none;justify-content:center;align-items:center;padding:0;transition:transform .14s,background-color .14s;display:inline-flex;position:relative}[data-phone] .--73Qq_button:after{content:"";position:absolute;inset:-5px -1px}[data-phone] .--73Qq_icon{width:17px;height:17px}[data-phone] .--73Qq_button:active{background:color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent);transform:scale(.92)}[data-phone] .--73Qq_button:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:-2px}@media (prefers-reduced-motion:reduce){[data-phone] .--73Qq_button{transition:none}[data-phone] .--73Qq_button:active{transform:none}}@media (forced-colors:active){[data-phone] .--73Qq_button{color:buttontext}[data-phone] .--73Qq_button:focus-visible{outline-color:highlight}}`,document.head.appendChild(e)}var Ye={button:`--73Qq_button`,icon:`--73Qq_icon`};function Xe({startSession:e,useShortcuts:t,t:n}){let r=t(e=>e.find(e=>e.id===`session.new`));return/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:n(`actions.newSession`),shortcutKeys:r?.keys,side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Ye.button,"aria-label":n(`actions.newSession`),"aria-keyshortcuts":r?.aria,"data-phone-new-session":!0,onClick:()=>{e()},children:/* @__PURE__ */ (0,o.jsx)(a.IconNewChatOutlineRegular,{size:17,className:Ye.icon})})})}let Ze=`@deepseek-ai/dsh-client-ui-workspace/RecentShortcut.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Ze)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Ze,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;-webkit-tap-highlight-color:transparent;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:28px;color:var(--dsw-alias-label-secondary);flex:0 0 28px;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:none}@media (hover:hover) and (pointer:fine){.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 Qe={activity:`oOF3UG_activity`,close:`oOF3UG_close`,identity:`oOF3UG_identity`,select:`oOF3UG_select`,shortcut:`oOF3UG_shortcut`,title:`oOF3UG_title`};function $e({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,s.useRef)(null),h=(0,s.useCallback)(e=>{e===null&&m.current?.contains(document.activeElement)&&p(),m.current=e},[p]);return/* @__PURE__ */ (0,o.jsxs)(`div`,{ref:h,className:Qe.shortcut,"data-active":c||void 0,children:[/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,className:Qe.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,o.jsx)(`span`,{className:Qe.identity,children:n}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Qe.title,children:t.displayTitle}),i!=null&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:Qe.activity,title:r,children:i})]}),/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Qe.close,onMouseDown:e=>e.preventDefault(),"aria-label":l,title:u,onClick:()=>{p(),f(e.sessionId)},children:/* @__PURE__ */ (0,o.jsx)(a.IconCloseOutlineRegular,{size:12})})]})}let et=`@deepseek-ai/dsh-client-ui-workspace/Rows.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(et)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=et,e.textContent=`._5OaiBG_hostBadge{--ch-peer-dot-color:#3b82f6;letter-spacing:.01em;min-width:0;max-width:88px;height:18px;color:color-mix(in srgb, var(--dsw-alias-label-secondary) 60%, var(--dsw-alias-label-tertiary));background:0 0;border:none;flex-shrink:0;align-items:center;gap:4.5px;margin-left:4px;padding:0;font-size:11px;font-weight:500;line-height:16px;display:inline-flex;overflow:hidden}._5OaiBG_hostBadgeSession{gap:4px;max-width:74px;height:16px;margin-left:2px;font-size:10.5px}._5OaiBG_hostBadge[data-color=blue]{--ch-peer-dot-color:#3b82f6}._5OaiBG_hostBadge[data-color=purple]{--ch-peer-dot-color:#8b5cf6}._5OaiBG_hostBadge[data-color=cyan]{--ch-peer-dot-color:#06b6d4}._5OaiBG_hostBadge[data-color=green]{--ch-peer-dot-color:#10b981}._5OaiBG_hostBadge[data-color=amber]{--ch-peer-dot-color:#f59e0b}._5OaiBG_hostBadge[data-color=rose]{--ch-peer-dot-color:#f43f5e}._5OaiBG_hostBadge[data-color=slate]{--ch-peer-dot-color:#64748b}body[data-ds-dark-theme] ._5OaiBG_hostBadge[data-color=blue]{--ch-peer-dot-color:#60a5fa}body[data-ds-dark-theme] ._5OaiBG_hostBadge[data-color=purple]{--ch-peer-dot-color:#a78bfa}body[data-ds-dark-theme] ._5OaiBG_hostBadge[data-color=cyan]{--ch-peer-dot-color:#22d3ee}body[data-ds-dark-theme] ._5OaiBG_hostBadge[data-color=green]{--ch-peer-dot-color:#34d399}body[data-ds-dark-theme] ._5OaiBG_hostBadge[data-color=amber]{--ch-peer-dot-color:#fbbf24}body[data-ds-dark-theme] ._5OaiBG_hostBadge[data-color=rose]{--ch-peer-dot-color:#fb7185}body[data-ds-dark-theme] ._5OaiBG_hostBadge[data-color=slate]{--ch-peer-dot-color:#94a3b8}._5OaiBG_hostBadge[data-state=connecting]{color:color-mix(in srgb, var(--dsw-alias-state-warning-primary,var(--dsw-alias-state-warn-primary,#d97706)) 78%, var(--dsw-alias-label-secondary))}._5OaiBG_hostBadge:is([data-state=disconnected],[data-state=offline],[data-state=auth-error]){color:var(--dsw-alias-label-tertiary);opacity:.72}._5OaiBG_hostLabel{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-width:0;overflow:hidden}._5OaiBG_hostDot{background:var(--dsw-alias-label-tertiary);opacity:.45;border-radius:50%;flex-shrink:0;width:5px;height:5px}._5OaiBG_hostBadge[data-state=connected] ._5OaiBG_hostDot{background:var(--ch-peer-dot-color);opacity:.95}._5OaiBG_hostBadge[data-state=connecting] ._5OaiBG_hostDot{background:var(--dsw-alias-state-warning-primary,var(--dsw-alias-state-warn-primary,#d97706));opacity:.9;animation:1.6s ease-in-out infinite _5OaiBG_hostDotPulse}@keyframes _5OaiBG_hostDotPulse{0%,to{opacity:.95}50%{opacity:.35}}@media (prefers-reduced-motion:reduce){._5OaiBG_hostBadge[data-state=connecting] ._5OaiBG_hostDot{animation:none}}._5OaiBG_hostTimeSep{color:var(--dsw-alias-label-tertiary);opacity:.45;user-select:none;flex:none;margin:0 5px;font-size:10px;line-height:16px}._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(:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen),._5OaiBG_sessionRow:is(: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(: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))}@media (hover:hover){._5OaiBG_projectRow:hover,._5OaiBG_sessionRow:hover{--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:hover{--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;gap:4px;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_identityButton:after{content:"";position:absolute;inset:-6px -4px -6px -8px}@media (hover:none),(pointer:coarse){._5OaiBG_sessionRow:not(:has(>[data-thread-summary])) ._5OaiBG_identityButton:after{inset:-12px -6px -12px -8px}}._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) :is(._5OaiBG_time,._5OaiBG_hostTimeSep,._5OaiBG_hostBadge),._5OaiBG_projectRow:is(:hover,:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen) ._5OaiBG_hostBadge{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}@media (hover:hover){._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}body[data-codexhost-wallpaper] :is(._5OaiBG_projectRow,._5OaiBG_sessionRow){--dsh-row-surface:transparent}body[data-codexhost-wallpaper] :is(._5OaiBG_projectRow,._5OaiBG_sessionRow):is(:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen){--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}body[data-codexhost-wallpaper] ._5OaiBG_sessionRow._5OaiBG_selected{--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent)}body[data-codexhost-wallpaper] ._5OaiBG_sessionRow._5OaiBG_selected:is(:focus-visible,:has(:focus-visible),._5OaiBG_menuOpen){--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent)}@media (hover:hover){body[data-codexhost-wallpaper] :is(._5OaiBG_projectRow,._5OaiBG_sessionRow):hover{--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent)}body[data-codexhost-wallpaper] ._5OaiBG_sessionRow._5OaiBG_selected:hover{--dsh-row-surface:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent)}}@media (hover:hover) and (pointer:fine){body[data-codexhost-wallpaper] :is(._5OaiBG_projectRow>._5OaiBG_rowActions,._5OaiBG_sessionRow ._5OaiBG_rowActions){background:color-mix(in srgb, var(--dsw-specific-sidebar-fill) 82%, transparent);backdrop-filter:blur(10px)}body[data-codexhost-wallpaper] :is(){display:none}}[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),._5OaiBG_sessionRow:not(:has(._5OaiBG_timeStatus)) ._5OaiBG_hostTimeSep{display:none}._5OaiBG_sessionRow ._5OaiBG_timeStatus{visibility:visible;padding-inline-end:0}._5OaiBG_iconButton{width:44px;height:44px}}`,document.head.appendChild(e)}var P={archived:`_5OaiBG_archived`,dot:`_5OaiBG_dot`,dropAfter:`_5OaiBG_dropAfter`,dropBefore:`_5OaiBG_dropBefore`,foldChevron:`_5OaiBG_foldChevron`,folderExpanded:`_5OaiBG_folderExpanded`,hostBadge:`_5OaiBG_hostBadge`,hostBadgeSession:`_5OaiBG_hostBadgeSession`,hostDot:`_5OaiBG_hostDot`,hostDotPulse:`_5OaiBG_hostDotPulse`,hostLabel:`_5OaiBG_hostLabel`,hostTimeSep:`_5OaiBG_hostTimeSep`,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 tt(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 nt(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 nt(e){throw Error(`unknown pending interaction: ${String(e)}`)}function rt({statuses:e}){return/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.StateDot,{state:e[0].state,size:e[0].state===`ongoing`?16:void 0}),e.map(e=>/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.visuallyHidden,children:e.label},e.label))]})}let it=`@deepseek-ai/dsh-client-ui-workspace/RecentNavigation.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(it)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=it,e.textContent=`.qXmkFa_trigger,.qXmkFa_shortcuts{display:none}[data-phone] .qXmkFa_trigger{width:auto;height:auto;color:var(--dsw-alias-label-secondary);cursor:pointer;-webkit-tap-highlight-color:transparent;-webkit-app-region:no-drag;-webkit-tap-highlight-color:transparent;background:0 0;border:0;border-radius:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[data-phone] .qXmkFa_trigger:after{content:"";position:absolute;inset:-12px -10px}[data-phone] .qXmkFa_trigger>svg{transition:transform .18s;display:block}.qXmkFa_trigger[aria-disabled=true]{cursor:wait}.qXmkFa_trigger:focus-visible{outline:none}.qXmkFa_expanded{transform:rotate(180deg)}@media (prefers-reduced-motion:reduce){[data-phone] .qXmkFa_trigger>svg{transition:none}}[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;-webkit-tap-highlight-color:transparent;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:none}@media (hover:hover) and (pointer:fine){.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 at={clear:`qXmkFa_clear`,expanded:`qXmkFa_expanded`,shortcuts:`qXmkFa_shortcuts`,trigger:`qXmkFa_trigger`};function ot({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:tt(de(t,o,c),i)}]})}function st(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=ot(e),m=f&&p.length>0,h=(0,s.useRef)(null),[g,_]=(0,s.useState)(!1),v=(0,s.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,s.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,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsxs)(`nav`,{ref:h,className:at.shortcuts,"aria-label":d(`recent.navigation`),onScroll:e=>v(e.currentTarget),children:[p.map(({visit:t,summary:i,statuses:a})=>/* @__PURE__ */ (0,o.jsx)($e,{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,o.jsx)(rt,{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,o.jsx)(`button`,{type:`button`,className:at.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,o.jsx)(a.Toast,{text:d(`recent.closeFailed`),onDone:()=>_(!1)})]}):null}function ct(e){let{useRecentNavigationSettings:t,setEnabled:n,t:r}=e,i=t(e=>e.value?.showRecentVisits??!0),c=ot(e),[l,u]=(0,s.useState)(!1),[d,f]=(0,s.useState)(!1),p=(0,s.useRef)(!1);return/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[c.length>0&&/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,"data-navigation-focus-return":!0,className:at.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,o.jsx)(a.IconChevronDownOutlineRegular,{size:14,className:i?at.expanded:void 0})}),d&&/* @__PURE__ */ (0,o.jsx)(a.Toast,{text:r(`recent.settings.error`),onDone:()=>f(!1)})]})}function lt(e){return e==null}function ut(e){return e&&typeof e==`object`&&!Array.isArray(e)}function dt(e,t){return Object.fromEntries(Object.entries(e).filter(([e,n])=>t(e,n)))}function ft(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n,e)]))}function pt(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 mt=Symbol.for(`cosmokit.volatile.write`);function ht(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=>ht(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,ht(n,t)])))}finally{t.delete(e)}}function gt(e){let t=ht(e);return Object.freeze({get:()=>t,[mt]:e=>{t=e}})}function _t(e){return typeof e==`object`&&!!e&&mt in e}function F(e,t){return arguments.length===1?t=>F(e,t):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}function vt(e){return F(`ArrayBuffer`,e)||F(`SharedArrayBuffer`,e)}function yt(e){return vt(e)||ArrayBuffer.isView(e)}let bt;(function(e){e.is=vt,e.isSource=yt;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})(bt||={}),bt.fromBase64,bt.toBase64,bt.fromHex,bt.toHex;function xt(e,t=/* @__PURE__ */ new Map){if(!e||typeof e!=`object`)return e;if(F(`Date`,e))return new Date(e.valueOf());if(F(`RegExp`,e))return new RegExp(e.source,e.flags);if(vt(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(xt,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(xt,null,[i.value,t])),Reflect.defineProperty(r,n,i)}return r}function St(e,t,n){let r=/* @__PURE__ */ new Set;function i(e,t){if(e===t)return!0;if(_t(e)||_t(t))return _t(e)&&_t(t);if(!n&&lt(e)&&lt(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(F(`Date`),(e,t)=>e.valueOf()===t.valueOf())??a(F(`URL`),(e,t)=>e.href===t.href)??a(F(`RegExp`),(e,t)=>e.source===t.source&&e.flags===t.flags)??a(vt,(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 Ct;(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})(Ct||={});let wt=Symbol.for(`schemastery`),Tt=Symbol.for(`ValidationError`);globalThis.__schemastery_index__??=0,globalThis.__schemastery_refs__=void 0;var I=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?.[Tt]}};Object.defineProperty(I.prototype,Tt,{value:!0});let L=function(e){let t=function(e,n={}){return L.resolve(e,t,n)[0]};if(e.refs){let t=ft(e.refs,e=>new L(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&&ft(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,L.prototype),t.meta||={},t.toString=t.toString.bind(t),t};L.prototype=Object.create(Function.prototype),L.prototype[wt]=!0,Object.defineProperty(L.prototype,"~standard",{get(){return{version:1,vendor:`schemastery`,validate:e=>{try{return{value:L.resolve(e,this,{})[0]}}catch(e){if(I.is(e))return{issues:[{message:e.message,path:e.options.path}]};throw e}}}}}),L.ValidationError=I,L.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},L.prototype.set=function(e,t){return this.dict[e]=t,this},L.prototype.push=function(e){return this.list.push(e),this};function Et(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 Dt(e){return e?.$value??e?.$inner}function Ot(e){return dt(e??{},e=>!e.startsWith(`$`))}L.prototype.i18n=function(e){let t=L(this),n=Et(t.meta.description,e);return Object.keys(n).length&&(t.meta.description=n),t.dict&&=ft(t.dict,(t,n)=>t.i18n(ft(e,e=>Dt(e)?.[n]??e?.[n]))),t.list&&=t.list.map((t,n)=>t.i18n(ft(e,(e={})=>Array.isArray(Dt(e))?Dt(e)[n]:Array.isArray(e)?e[n]:Ot(e)))),t.inner&&=t.inner.i18n(ft(e,e=>Dt(e)?Dt(e):Ot(e))),t.sKey&&=t.sKey.i18n(ft(e,e=>e?.$key)),t},L.prototype.extra=function(e,t){let n=L(this);return n.meta={...n.meta,[e]:t},n};for(let e of[`required`,`disabled`,`collapse`,`hidden`,`loose`])Object.assign(L.prototype,{[e](t=!0){let n=L(this);return n.meta={...n.meta,[e]:t},n}});L.prototype.deprecated=function(){let e=L(this);return e.meta.badges||=[],e.meta.badges.push({text:`deprecated`,type:`danger`}),e},L.prototype.experimental=function(){let e=L(this);return e.meta.badges||=[],e.meta.badges.push({text:`experimental`,type:`warning`}),e},L.prototype.pattern=function(e){let t=L(this),n=pt(e,[`source`,`flags`]);return t.meta={...t.meta,pattern:n},t},L.prototype.simplify=function(e){if(_t(e)&&(e=e.get()),St(e,this.meta.default,this.type===`dict`))return null;if(lt(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`||!lt(r))&&(t[n]=r)}return St(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 L.resolve(e,t,{}),t.simplify(e)}catch{}return e},L.prototype.toString=function(e){return Lt[this.type]?.(this,e)??`Schema<${this.type}>`},L.prototype.role=function(e,t){let n=L(this);return n.meta={...n.meta,role:e,extra:t},n};for(let e of[`default`,`link`,`comment`,`description`,`max`,`min`,`step`])Object.assign(L.prototype,{[e](t){let n=L(this);return n.meta={...n.meta,[e]:t},n}});L.prototype.volatile=function(){if(this.meta.volatile)throw TypeError(`volatile schema is already wrapped`);return this.extra(`volatile`,!0)};let kt={},At=Symbol(`checked-volatile-schema`);function jt(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 I(`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))jt(i,[...t,n],a,r);if(e.sKey&&jt(e.sKey,[...t,`<key>`],!0,r),e.inner&&(e.type!==`lazy`||e.inner[wt])&&jt(e.inner,[...t,`*`],!0,r),e.list)for(let n=0;n<e.list.length;n++)jt(e.list[n],[...t,String(n)],!0,r)}L.extend=function(e,t){kt[e]=t},L.resolve=function(e,t,n={},r=!1){if(!t)return[e];if(n[At]||(jt(t,n.path),n={...n,[At]:!0}),t.meta?.volatile){let i=L(t);i.meta={...t.meta,volatile:!1};let[a,o]=L.resolve(e,i,n,r);try{return[gt(a),o]}catch(e){throw new I(e instanceof Error?e.message:String(e),n)}}if(n.ignore?.(e,t))return[e];if(lt(e)&&t.type!==`lazy`){if(t.meta.required)throw new I(`missing required value`,n);let r=t,i=t.meta.default;for(;r?.type===`intersect`&&lt(i);)r=r.list[0],i=r?.meta.default;if(lt(i))return[e];e=xt(i)}let i=kt[t.type];if(!i)throw new I(`unsupported type "${t.type}"`,n);try{return i(e,t,n,r)}catch(e){if(!t.meta.loose)throw e;return[t.meta.default]}},L.from=function(e){if(lt(e))return L.any();if([`string`,`number`,`boolean`].includes(typeof e))return L.const(e).required();if(e[wt])return e;if(typeof e==`function`)switch(e){case String:return L.string().required();case Number:return L.number().required();case Boolean:return L.boolean().required();case Function:return L.function().required();default:return L.is(e).required()}else throw TypeError(`cannot infer schema from ${e}`)},L.lazy=function(e){let t=new L({type:`lazy`,builder:e,inner:{toJSON:()=>(t.inner[wt]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta}),t.inner.toJSON())}});return t},L.natural=function(){return L.number().step(1).min(0)},L.percent=function(){return L.number().step(.01).min(0).max(1).role(`slider`)},L.date=function(){return L.union([L.is(Date),L.transform(L.string().role(`datetime`),(e,t)=>{let n=new Date(e);if(isNaN(+n))throw new I(`invalid date "${e}"`,t);return n},!0)])},L.regExp=function(e=``){return L.union([L.is(RegExp),L.transform(L.string().role(`regexp`,{flag:e}),(t,n)=>{try{return new RegExp(t,e)}catch(e){throw new I(e.message,n)}},!0)])},L.arrayBuffer=function(e){return L.union([L.is(ArrayBuffer),L.is(SharedArrayBuffer),L.transform(L.any(),(e,t)=>{if(bt.isSource(e))return bt.fromSource(e);throw new I(`expected ArrayBufferSource but got ${e}`,t)},!0),...e?[L.transform(L.string(),(t,n)=>{try{return e===`base64`?bt.fromBase64(t):bt.fromHex(t)}catch(e){throw new I(e.message,n)}},!0)]:[]])},L.extend(`lazy`,(e,t,n,r)=>(t.inner[wt]||(t.inner=t.builder(),t.inner.meta={...t.meta,...t.inner.meta},jt(t.inner,n.path,!0)),L.resolve(e,t.inner,n,r))),L.extend(`any`,e=>[e]),L.extend(`never`,(e,t,n)=>{throw new I(`expected nullable but got ${e}`,n)}),L.extend(`const`,(e,{value:t},n)=>{if(St(e,t))return[t];throw new I(`expected ${t} but got ${e}`,n)});function Mt(e,t,n,r,i=!1){let{max:a=1/0,min:o=-1/0}=t;if(e>a)throw new I(`expected ${n} <= ${a} but got ${e}`,r);if(e<o&&!i)throw new I(`expected ${n} >= ${o} but got ${e}`,r)}L.extend(`string`,(e,{meta:t},n)=>{if(typeof e!=`string`)throw new I(`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 I(`expect string to match regexp ${r}`,n)}return Mt(e.length,t,`string length`,n),[e]});function Nt(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(Nt(e,i)-Nt(t,i))%Nt(n,i)===0}L.extend(`number`,(e,{meta:t},n)=>{if(typeof e!=`number`)throw new I(`expected number but got ${e}`,n);Mt(e,t,`number`,n);let{step:r}=t;if(r&&!Pt(e,t.min??0,r))throw new I(`expected number multiple of ${r} but got ${e}`,n);return[e]}),L.extend(`boolean`,(e,t,n)=>{if(typeof e==`boolean`)return[e];throw new I(`expected boolean but got ${e}`,n)}),L.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 I(`expected string but got ${e}`,r);e in t&&(i|=t[e])}}else throw new I(`expected number or array but got ${e}`,r);return i===n.default?[i]:[i,a]}),L.extend(`function`,(e,t,n)=>{if(typeof e==`function`)return[e];throw new I(`expected function but got ${e}`,n)}),L.extend(`is`,(e,{constructor:t},n)=>{if(typeof t==`function`){if(e instanceof t)return[e];throw new I(`expected ${t.name} but got ${e}`,n)}{if(lt(e))throw new I(`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 I(`expected ${t} but got ${e}`,n)}});function Ft(e,t,n,r){try{let[i,a]=L.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?gt(n.meta.default):n.meta.default}}L.extend(`array`,(e,{inner:t,meta:n},r)=>{if(!Array.isArray(e))throw new I(`expected array but got ${e}`,r);return Mt(e.length,n,`array length`,r,!lt(t.meta.default)),[e.map((n,i)=>Ft(e,i,t,r))]}),L.extend(`dict`,(e,{inner:t,sKey:n},r,i)=>{if(!ut(e))throw new I(`expected object but got ${e}`,r);let a={};for(let o in e){let s;try{s=L.resolve(o,n,r)[0]}catch(e){if(i)continue;throw e}a[s]=Ft(e,o,t,r),e[s]=e[o],o!==s&&delete e[o]}return[a]}),L.extend(`tuple`,(e,{list:t},n,r)=>{if(!Array.isArray(e))throw new I(`expected array but got ${e}`,n);let i=t.map((t,r)=>Ft(e,r,t,n));return r||i.push(...e.slice(t.length)),[i]});function It(e,t){for(let n in t)n in e||(e[n]=t[n])}L.extend(`object`,(e,{dict:t},n,r)=>{if(!ut(e))throw new I(`expected object but got ${e}`,n);let i={};for(let r in t){let a=Ft(e,r,t[r],n);(!lt(a)||r in e)&&(i[r]=a)}return r||It(i,e),[i]}),L.extend(`union`,(e,{list:t,toString:n},r,i)=>{let a=[];for(let n of t)try{return L.resolve(e,n,r,i)}catch(e){a.push(e)}throw new I(`expected ${n()} but got ${JSON.stringify(e)}`,r)}),L.extend(`intersect`,(e,{list:t,toString:n},r,i)=>{if(!t.length)return[e];let a;for(let i of t){let t=L.resolve(e,i,r,!0)[0];if(!lt(t)){if(lt(a))a=t;else if(typeof a!=typeof t)throw new I(`expected ${n()} but got ${JSON.stringify(e)}`,r);else if(typeof t==`object`)It(a??={},t);else if(a!==t)throw new I(`expected ${n()} but got ${JSON.stringify(e)}`,r)}}return!i&&ut(e)&&It(a,e),[a]}),L.extend(`transform`,(e,{inner:t,callback:n,preserve:r},i)=>{let[a,o=e]=L.resolve(e,t,i,!0);return r?[n(a)]:[n(a),n(o)]});let Lt={};function Rt(e,t,n){Lt[e]=n,Object.assign(L,{[e](...n){let r=new L({type:e});return t.forEach((e,t)=>{switch(e){case`sKey`:r.sKey=n[t]??L.string();break;case`inner`:r.inner=L.from(n[t]);break;case`list`:r.list=n[t].map(L.from);break;case`dict`:r.dict=ft(n[t],L.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}})}Rt(`is`,[`constructor`],({constructor:e})=>typeof e==`function`?e.name:e),Rt(`any`,[],()=>`any`),Rt(`never`,[],()=>`never`),Rt(`const`,[`value`],({value:e})=>typeof e==`string`?JSON.stringify(e):e),Rt(`string`,[],()=>`string`),Rt(`number`,[],()=>`number`),Rt(`boolean`,[],()=>`boolean`),Rt(`bitset`,[`bits`],()=>`bitset`),Rt(`function`,[],()=>`function`),Rt(`array`,[`inner`],({inner:e})=>`${e.toString(!0)}[]`),Rt(`dict`,[`inner`,`sKey`],({inner:e,sKey:t})=>`{ [key: ${t.toString()}]: ${e.toString()} }`),Rt(`tuple`,[`list`],({list:e})=>`[${e.map(e=>e.toString()).join(`, `)}]`),Rt(`object`,[`dict`],({dict:e})=>Object.keys(e).length===0?`{}`:`{ ${Object.entries(e).map(([e,t])=>`${e}${t.meta.required?``:`?`}: ${t.toString()}`).join(`, `)} }`),Rt(`union`,[`list`],({list:e},t)=>{let n=e.map(({toString:e})=>e()).join(` | `);return t?`(${n})`:n}),Rt(`intersect`,[`list`],({list:e})=>`${e.map(e=>e.toString(!0)).join(` & `)}`),Rt(`transform`,[`inner`,`callback`,`preserve`],({inner:e},t)=>e.toString(t));let zt=[0,15,30,60,120,240,1440],Bt={showRecentVisits:!0,tabIdleTimeoutMinutes:60},Vt={showRecentVisits:L.boolean().default(!0),tabIdleTimeoutMinutes:L.natural().max(1440).default(60)},Ht=`@deepseek-ai/dsh-client-ui-workspace/RecentNavigationRow.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=`._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 Ut={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 Wt({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,s.useState)(!1),[f,p]=(0,s.useState)(!1),[m,h]=(0,s.useState)(!1),g=(0,s.useRef)(!1),_=(0,s.useId)();(0,s.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,o.jsxs)(`div`,{children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Ut.row,children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Ut.text,children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Ut.titleLine,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:Ut.title,children:r(`recent.settings.title`)}),/* @__PURE__ */ (0,o.jsx)(a.Tag,{tone:`neutral`,children:r(`recent.settings.mobile`)})]}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:Ut.description,children:r(`recent.settings.description`)})]}),/* @__PURE__ */ (0,o.jsx)(a.Switch,{checked:c,disabled:f,label:`${r(`recent.settings.title`)} · ${r(`recent.settings.mobile`)}`,onChange:e=>y(()=>t(e))})]}),c&&/* @__PURE__ */ (0,o.jsxs)(`div`,{className:`${Ut.row} ${Ut.timeoutRow}`,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:Ut.text,children:/* @__PURE__ */ (0,o.jsx)(`div`,{className:Ut.title,id:`${_}-label`,children:r(`recent.timeout.title`)})}),/* @__PURE__ */ (0,o.jsx)(a.Menu,{className:Ut.menu,open:u&&c&&!f,onClose:()=>d(!1),items:zt.map(e=>({id:String(e),label:e===60?r(`recent.timeout.default`,{value:v(e)}):v(e)})),selectedId:String(l),onSelect:e=>{let t=zt.find(t=>String(t)===e);t!==void 0&&y(()=>n(t))},align:`end`,portal:!0,anchor:/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,className:Ut.selector,disabled:!c||f,"aria-labelledby":`${_}-label ${_}-value`,"aria-haspopup":`menu`,"aria-expanded":u&&c&&!f,onClick:()=>d(e=>!e),children:[/* @__PURE__ */ (0,o.jsx)(`span`,{id:`${_}-value`,children:v(l)}),/* @__PURE__ */ (0,o.jsx)(a.IconChevronDownOutlineRegular,{size:14})]})})]}),m&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Ut.error,role:`alert`,children:r(`recent.settings.error`)})]})}function Gt(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.trailing`,()=>e.slots.register({name:`conversation.header.trailing`,locale:`workspace`,inject:()=>({startSession:()=>t.startSession(),hooks:{shortcuts:e.shortcuts.catalog}})},Xe)),e.slots.inject(`conversation.header.navigation`,()=>e.slots.register({name:`conversation.header.navigation`,locale:`workspace`,inject:o},ct)),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`}}},st)),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})},Wt))}let Kt=`@deepseek-ai/dsh-client-ui-workspace/ThreadTreeStyle.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Kt)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Kt,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 qt={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 Jt=[`summary`,`ring`];function Yt(e){let[t,n]=(0,s.useState)(!1),[r,i]=(0,s.useState)(!1),a=(0,s.useRef)(!1);return{busy:t,failed:r,save:async t=>{if(a.current)return!1;a.current=!0,n(!0),i(!1);try{let n=await e(t);return i(!n),n}catch{return i(!0),!1}finally{a.current=!1,n(!1)}}}}function Xt({style:e,setStyle:t,t:n,settings:r=!1}){let i=(0,s.useId)(),{busy:c,failed:l,save:u}=Yt(t);return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:r?a.preferenceRowStyles.row:qt.options,children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:`${a.preferenceRowStyles.rowText} ${r?qt.settingsText:``}`,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:a.preferenceRowStyles.title,id:i,children:n(`threadTree.style.title`)}),r&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:a.preferenceRowStyles.description,id:`${i}-description`,children:n(`threadTree.style.description`)})]}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:a.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:Jt.map(t=>/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,role:`radio`,className:a.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,o.jsx)(`div`,{className:qt.error,role:`alert`,children:n(`threadTree.style.error`)})]})}function Zt({usePreference:e,setStyle:t,t:n}){let r=e(e=>e.value?.threadTreeCollapseStyle??`summary`);return/* @__PURE__ */ (0,o.jsx)(Xt,{style:r,setStyle:t,t:n,settings:!0})}let Qt={...Bt,threadTreeCollapseStyle:`summary`},$t=L.object({...Vt,threadTreeCollapseStyle:L.union([`summary`,`ring`]).default(`summary`)});function en(e){return typeof e==`object`&&!!e&&Object.hasOwn(e,`threadTreeCollapseStyle`)}function tn(e){let t=e.configForms.registerBrowser(`ui-workspace`,$t.toJSON(),{...Qt});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)})},Zt)),t}function nn(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 rn(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=rn(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function R(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=rn(e))&&(r&&(r+=` `),r+=t);return r}function an(e,t){return e===`default-workspace`?t:e}let on={},sn=(0,s.createContext)({t:e=>e,expansion:on,rows:e=>te(e,on),toggle:()=>{},markCompletionsRead:()=>{},collapseStyle:`summary`,stylePrompt:void 0,dismissStylePrompt:()=>{},setCollapseStyle:async()=>!1,rootId:e=>e,reveal:()=>{},selectSidebarRow:()=>{},isSidebarSelection:()=>!1});function cn(){return(0,s.useContext)(sn)}function ln({browser:e,children:t}){let{useSessions:n,useStore:r,useWorkspaces:i,actions:a,useWorkspacePreferences:c,setThreadTreeCollapseStyle:l}=e,u=c(e=>e),d=en(u.user),f=u.value?.threadTreeCollapseStyle??`summary`,[p,m]=(0,s.useState)(),h=(0,s.useCallback)(()=>m(void 0),[]),g=n(e=>e),_=i(e=>e),v=r(e=>e.threadExpansion??on),y=r(e=>e.archivedFilter??`default`),b=(0,s.useMemo)(()=>pe(g,{pinnedSessionIds:_.pinnedSessionIds,archivedSessionIds:_.archivedSessionIds,archivedFilter:y,...y===`only`||!_.threadSections?.length?{}:{sectionedSessionIds:new Set(_.threadSections.flatMap(e=>e.threadIds))}},/* @__PURE__ */ new Map),[g,_,y]),x=(0,s.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,s.useRef)(void 0),C=(0,s.useCallback)(e=>S.current===e,[]),ee=(0,s.useCallback)(e=>{S.current=e,a.setThreadsExpanded(x.get(e)?.ancestors??[],!0)},[a,x]),w=(0,s.useCallback)(e=>{S.current=void 0;let t=x.get(e);t!==void 0&&a.setThreadsExpanded(t.ancestors,!0)},[a,x]),T=Object.values(g.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,E=(0,s.useRef)(``);(0,s.useEffect)(()=>{T===void 0?E.current=``:x.get(T)!==void 0&&E.current!==T&&(E.current=T,C(T)||w(T))},[T,C,w,x]);let D=(0,s.useMemo)(()=>({t:e.t,expansion:v,rows:e=>te(e,v),toggle:(e,t,n)=>{a.setThreadsExpanded([e],t),t&&n!==void 0&&!d&&m(n)},markCompletionsRead:e.markCompletionsRead??(()=>{}),collapseStyle:f,stylePrompt:d?void 0:p,dismissStylePrompt:h,setCollapseStyle:l,rootId:e=>x.get(e)?.root.id??e,reveal:w,selectSidebarRow:ee,isSidebarSelection:C}),[e.t,e.markCompletionsRead,a,v,x,w,ee,C,f,d,p,h,l]);return/* @__PURE__ */ (0,o.jsx)(sn.Provider,{value:D,children:t})}function un({identity:e,ambient:t,title:n,onIdentityClick:r,identityLabel:i,identityControls:a,identityExpanded:s,children:c}){let l=/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[e,/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.statusOverlay,children:t})]});return/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[r?/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,className:`${P.slot} ${P.identityButton}`,onClick:r,"data-thread-icon-toggle":!0,"aria-label":i,title:i,"aria-expanded":s,"aria-controls":a,children:[l,/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.foldChevron,"aria-hidden":`true`})]}):/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.slot,children:l}),/* @__PURE__ */ (0,o.jsx)(`span`,{"data-session-title":!0,className:P.title,children:n}),c]})}var dn;let fn=/*@__PURE__*/ Object.freeze({status:`aborted`});function z(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:/* @__PURE__ */ new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var pn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},mn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(dn=globalThis).__zod_globalConfig??(dn.__zod_globalConfig={});let hn=globalThis.__zod_globalConfig;function gn(e){return e&&Object.assign(hn,e),hn}function _n(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function vn(e,t){return typeof t==`bigint`?t.toString():t}function yn(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function bn(e){return e==null}function xn(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Sn(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let Cn=/* @__PURE__*/ Symbol(`evaluating`);function B(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Cn)return r===void 0&&(r=Cn,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function wn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Tn(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function En(e){return JSON.stringify(e)}function Dn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let On=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function kn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let An=/* @__PURE__*/ yn(()=>{if(hn.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function jn(e){if(kn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return kn(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Mn(e){return jn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let Nn=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Pn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Fn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function V(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function In(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let Ln={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Rn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Fn(e,Tn(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return wn(this,`shape`,e),e},checks:[]}))}function zn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Fn(e,Tn(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return wn(this,`shape`,r),r},checks:[]}))}function Bn(e,t){if(!jn(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Fn(e,Tn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return wn(this,`shape`,n),n}}))}function Vn(e,t){if(!jn(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Fn(e,Tn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return wn(this,`shape`,n),n}}))}function Hn(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Fn(e,Tn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return wn(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Un(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Fn(t,Tn(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return wn(this,`shape`,i),i},checks:[]}))}function Wn(e,t,n){return Fn(t,Tn(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return wn(this,`shape`,i),i}}))}function Gn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Kn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function qn(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Jn(e){return typeof e==`string`?e:e?.message}function Yn(e,t,n){let r=e.message?e.message:Jn(e.inst?._zod.def?.error?.(e))??Jn(t?.error?.(e))??Jn(n.customError?.(e))??Jn(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Xn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Zn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let Qn=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,vn,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$n=z(`$ZodError`,Qn),er=z(`$ZodError`,Qn,{Parent:Error});function tr(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function nr(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}let rr=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new pn;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Yn(e,a,gn())));throw On(t,i?.callee),t}return o.value},ir=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Yn(e,a,gn())));throw On(t,i?.callee),t}return o.value},ar=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new pn;return a.issues.length?{success:!1,error:new(e??$n)(a.issues.map(e=>Yn(e,i,gn())))}:{success:!0,data:a.value}},or=/* @__PURE__*/ ar(er),sr=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Yn(e,i,gn())))}:{success:!0,data:a.value}},cr=/* @__PURE__*/ sr(er),lr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return rr(e)(t,n,i)},ur=e=>(t,n,r)=>rr(e)(t,n,r),dr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ir(e)(t,n,i)},fr=e=>async(t,n,r)=>ir(e)(t,n,r),pr=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ar(e)(t,n,i)},mr=e=>(t,n,r)=>ar(e)(t,n,r),hr=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return sr(e)(t,n,i)},gr=e=>async(t,n,r)=>sr(e)(t,n,r),_r=/^[cC][0-9a-z]{6,}$/,vr=/^[0-9a-z]+$/,yr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,br=/^[0-9a-vA-V]{20}$/,xr=/^[A-Za-z0-9]{27}$/,Sr=/^[a-zA-Z0-9_-]{21}$/,Cr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,wr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Tr=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Er=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Dr(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}let Or=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,kr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ar=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,jr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Mr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Nr=/^[A-Za-z0-9_-]*$/,Pr=/^https?$/,Fr=/^\+[1-9]\d{6,14}$/,Ir=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Lr=/*@__PURE__*/ RegExp(`^${Ir}$`);function Rr(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function zr(e){return RegExp(`^${Rr(e)}$`)}function Br(e){let t=Rr({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Ir}T(?:${r})$`)}let Vr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Hr=/^-?\d+$/,Ur=/^-?\d+(?:\.\d+)?$/,Wr=/^(?:true|false)$/i,Gr=/^null$/i,Kr=/^[^A-Z]*$/,qr=/^[^a-z]*$/,Jr=/*@__PURE__*/ z(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Yr={number:`number`,bigint:`bigint`,object:`date`},Xr=/*@__PURE__*/ z(`$ZodCheckLessThan`,(e,t)=>{Jr.init(e,t);let n=Yr[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Zr=/*@__PURE__*/ z(`$ZodCheckGreaterThan`,(e,t)=>{Jr.init(e,t);let n=Yr[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Qr=/*@__PURE__*/ z(`$ZodCheckMultipleOf`,(e,t)=>{Jr.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Sn(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),$r=/*@__PURE__*/ z(`$ZodCheckNumberFormat`,(e,t)=>{Jr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ln[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Hr)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),ei=/*@__PURE__*/ z(`$ZodCheckMaxLength`,(e,t)=>{var n;Jr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!bn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Xn(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ti=/*@__PURE__*/ z(`$ZodCheckMinLength`,(e,t)=>{var n;Jr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!bn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Xn(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ni=/*@__PURE__*/ z(`$ZodCheckLengthEquals`,(e,t)=>{var n;Jr.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!bn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Xn(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ri=/*@__PURE__*/ z(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Jr.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=/* @__PURE__ */ new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ii=/*@__PURE__*/ z(`$ZodCheckRegex`,(e,t)=>{ri.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ai=/*@__PURE__*/ z(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Kr,ri.init(e,t)}),oi=/*@__PURE__*/ z(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=qr,ri.init(e,t)}),si=/*@__PURE__*/ z(`$ZodCheckIncludes`,(e,t)=>{Jr.init(e,t);let n=Pn(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),ci=/*@__PURE__*/ z(`$ZodCheckStartsWith`,(e,t)=>{Jr.init(e,t);let n=RegExp(`^${Pn(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),li=/*@__PURE__*/ z(`$ZodCheckEndsWith`,(e,t)=>{Jr.init(e,t);let n=RegExp(`.*${Pn(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),ui=/*@__PURE__*/ z(`$ZodCheckOverwrite`,(e,t)=>{Jr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var di=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
10
+ `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
11
+ `))}};let fi={major:4,minor:4,patch:3},pi=/*@__PURE__*/ z(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=fi;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Gn(e),i;for(let a of t){if(a._zod.def.when){if(Kn(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new pn;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Gn(e,t))});else{if(e.issues.length===t)continue;r||=Gn(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Gn(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new pn;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new pn;return o.then(e=>t(e,r,a))}return t(o,r,a)}}B(e,`~standard`,()=>({validate:t=>{try{let n=or(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return cr(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),mi=/*@__PURE__*/ z(`$ZodString`,(e,t)=>{pi.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Vr(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),hi=/*@__PURE__*/ z(`$ZodStringFormat`,(e,t)=>{ri.init(e,t),mi.init(e,t)}),gi=/*@__PURE__*/ z(`$ZodGUID`,(e,t)=>{t.pattern??=wr,hi.init(e,t)}),_i=/*@__PURE__*/ z(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Tr(e)}else t.pattern??=Tr();hi.init(e,t)}),vi=/*@__PURE__*/ z(`$ZodEmail`,(e,t)=>{t.pattern??=Er,hi.init(e,t)}),yi=/*@__PURE__*/ z(`$ZodURL`,(e,t)=>{hi.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Pr.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),bi=/*@__PURE__*/ z(`$ZodEmoji`,(e,t)=>{t.pattern??=Dr(),hi.init(e,t)}),xi=/*@__PURE__*/ z(`$ZodNanoID`,(e,t)=>{t.pattern??=Sr,hi.init(e,t)}),Si=/*@__PURE__*/ z(`$ZodCUID`,(e,t)=>{t.pattern??=_r,hi.init(e,t)}),Ci=/*@__PURE__*/ z(`$ZodCUID2`,(e,t)=>{t.pattern??=vr,hi.init(e,t)}),wi=/*@__PURE__*/ z(`$ZodULID`,(e,t)=>{t.pattern??=yr,hi.init(e,t)}),Ti=/*@__PURE__*/ z(`$ZodXID`,(e,t)=>{t.pattern??=br,hi.init(e,t)}),Ei=/*@__PURE__*/ z(`$ZodKSUID`,(e,t)=>{t.pattern??=xr,hi.init(e,t)}),Di=/*@__PURE__*/ z(`$ZodISODateTime`,(e,t)=>{t.pattern??=Br(t),hi.init(e,t)}),Oi=/*@__PURE__*/ z(`$ZodISODate`,(e,t)=>{t.pattern??=Lr,hi.init(e,t)}),ki=/*@__PURE__*/ z(`$ZodISOTime`,(e,t)=>{t.pattern??=zr(t),hi.init(e,t)}),Ai=/*@__PURE__*/ z(`$ZodISODuration`,(e,t)=>{t.pattern??=Cr,hi.init(e,t)}),ji=/*@__PURE__*/ z(`$ZodIPv4`,(e,t)=>{t.pattern??=Or,hi.init(e,t),e._zod.bag.format=`ipv4`}),Mi=/*@__PURE__*/ z(`$ZodIPv6`,(e,t)=>{t.pattern??=kr,hi.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Ni=/*@__PURE__*/ z(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Ar,hi.init(e,t)}),Pi=/*@__PURE__*/ z(`$ZodCIDRv6`,(e,t)=>{t.pattern??=jr,hi.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Fi(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let Ii=/*@__PURE__*/ z(`$ZodBase64`,(e,t)=>{t.pattern??=Mr,hi.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Fi(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Li(e){if(!Nr.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Fi(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let Ri=/*@__PURE__*/ z(`$ZodBase64URL`,(e,t)=>{t.pattern??=Nr,hi.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Li(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),zi=/*@__PURE__*/ z(`$ZodE164`,(e,t)=>{t.pattern??=Fr,hi.init(e,t)});function Bi(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}let Vi=/*@__PURE__*/ z(`$ZodJWT`,(e,t)=>{hi.init(e,t),e._zod.check=n=>{Bi(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Hi=/*@__PURE__*/ z(`$ZodNumber`,(e,t)=>{pi.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ur,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Ui=/*@__PURE__*/ z(`$ZodNumberFormat`,(e,t)=>{$r.init(e,t),Hi.init(e,t)}),Wi=/*@__PURE__*/ z(`$ZodBoolean`,(e,t)=>{pi.init(e,t),e._zod.pattern=Wr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Gi=/*@__PURE__*/ z(`$ZodNull`,(e,t)=>{pi.init(e,t),e._zod.pattern=Gr,e._zod.values=/* @__PURE__ */ new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Ki=/*@__PURE__*/ z(`$ZodUnknown`,(e,t)=>{pi.init(e,t),e._zod.parse=e=>e}),qi=/*@__PURE__*/ z(`$ZodNever`,(e,t)=>{pi.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Ji(e,t,n){e.issues.length&&t.issues.push(...qn(n,e.issues)),t.value[n]=e.value}let Yi=/*@__PURE__*/ z(`$ZodArray`,(e,t)=>{pi.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Ji(t,n,e))):Ji(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Xi(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...qn(n,e.issues))}!o&&!i?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Zi(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=In(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Qi(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Xi(e,n,i,t,u,d))):Xi(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}let $i=/*@__PURE__*/ z(`$ZodObject`,(e,t)=>{if(pi.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=yn(()=>Zi(t));B(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */ new Set);for(let e of r.values)n[t].add(e)}}return n});let r=kn,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Xi(n,t,e,s,r,i))):Xi(a,t,e,s,r,i)}return i?Qi(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),ea=/*@__PURE__*/ z(`$ZodObjectJIT`,(e,t)=>{$i.init(e,t);let n=e._zod.parse,r=yn(()=>Zi(t)),i=e=>{let t=new di([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=En(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=En(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
12
+ if (${n}.issues.length) {
13
+ if (${o} in input) {
14
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
15
+ ...iss,
16
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
17
+ })));
18
+ }
19
+ }
20
+
21
+ if (${n}.value === undefined) {
22
+ if (${o} in input) {
23
+ newResult[${o}] = undefined;
24
+ }
25
+ } else {
26
+ newResult[${o}] = ${n}.value;
27
+ }
28
+
29
+ `):c?t.write(`
30
+ if (${n}.issues.length) {
31
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
32
+ ...iss,
33
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
34
+ })));
35
+ }
36
+
37
+ if (${n}.value === undefined) {
38
+ if (${o} in input) {
39
+ newResult[${o}] = undefined;
40
+ }
41
+ } else {
42
+ newResult[${o}] = ${n}.value;
43
+ }
44
+
45
+ `):t.write(`
46
+ const ${n}_present = ${o} in input;
47
+ if (${n}.issues.length) {
48
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
49
+ ...iss,
50
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
51
+ })));
52
+ }
53
+ if (!${n}_present && !${n}.issues.length) {
54
+ payload.issues.push({
55
+ code: "invalid_type",
56
+ expected: "nonoptional",
57
+ input: undefined,
58
+ path: [${o}]
59
+ });
60
+ }
61
+
62
+ if (${n}_present) {
63
+ if (${n}.value === undefined) {
64
+ newResult[${o}] = undefined;
65
+ } else {
66
+ newResult[${o}] = ${n}.value;
67
+ }
68
+ }
69
+
70
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=kn,s=!hn.jitless,c=s&&An.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Qi([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function ta(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Gn(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Yn(e,r,gn())))}),t)}let na=/*@__PURE__*/ z(`$ZodUnion`,(e,t)=>{pi.init(e,t),B(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),B(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),B(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),B(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>xn(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>ta(t,r,e,i)):ta(o,r,e,i)}}),ra=/*@__PURE__*/ z(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,na.init(e,t);let n=e._zod.parse;B(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=/* @__PURE__ */ new Set);for(let r of n)e[t].add(r)}}return e});let r=yn(()=>{let e=t.options,n=/* @__PURE__ */ new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!kn(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),ia=/*@__PURE__*/ z(`$ZodIntersection`,(e,t)=>{pi.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>oa(e,t,n)):oa(e,i,a)}});function aa(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(jn(e)&&jn(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=aa(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=aa(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function oa(e,t,n){let r=/* @__PURE__ */ new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Gn(e))return e;let o=aa(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}let sa=/*@__PURE__*/ z(`$ZodTuple`,(e,t)=>{pi.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=ca(n,`optin`),c=ca(n,`optout`);if(!t.rest){if(a.length<s)return r.issues.push({code:`too_small`,minimum:s,inclusive:!0,input:a,inst:e,origin:`array`}),r;a.length>n.length&&r.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:a,inst:e,origin:`array`})}let l=Array(n.length);for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:a[e],issues:[]},i);t instanceof Promise?o.push(t.then(t=>{l[e]=t})):l[e]=t}if(t.rest){let e=n.length-1,s=a.slice(n.length);for(let n of s){e++;let a=t.rest._zod.run({value:n,issues:[]},i);a instanceof Promise?o.push(a.then(t=>la(t,r,e))):la(a,r,e)}}return o.length?Promise.all(o).then(()=>ua(l,r,n,a,c)):ua(l,r,n,a,c)}});function ca(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]._zod[t]!==`optional`)return n+1;return 0}function la(e,t,n){e.issues.length&&t.issues.push(...qn(n,e.issues)),t.value[n]=e.value}function ua(e,t,n,r,i){for(let a=0;a<n.length;a++){let n=e[a],o=a<r.length;if(n.issues.length){if(!o&&a>=i){t.value.length=a;break}t.issues.push(...qn(a,n.issues))}t.value[a]=n.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}let da=/*@__PURE__*/ z(`$ZodRecord`,(e,t)=>{pi.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!jn(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=/* @__PURE__ */ new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Yn(e,r,gn())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...qn(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...qn(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Ur.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Yn(e,r,gn())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...qn(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...qn(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),fa=/*@__PURE__*/ z(`$ZodEnum`,(e,t)=>{pi.init(e,t);let n=_n(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Nn.has(typeof e)).map(e=>typeof e==`string`?Pn(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),pa=/*@__PURE__*/ z(`$ZodLiteral`,(e,t)=>{if(pi.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Pn(e):e?Pn(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),ma=/*@__PURE__*/ z(`$ZodTransform`,(e,t)=>{pi.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new mn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new pn;return n.value=i,n.fallback=!0,n}});function ha(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let ga=/*@__PURE__*/ z(`$ZodOptional`,(e,t)=>{pi.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,B(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,void 0]):void 0),B(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${xn(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>ha(e,r)):ha(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),_a=/*@__PURE__*/ z(`$ZodExactOptional`,(e,t)=>{ga.init(e,t),B(e._zod,`values`,()=>t.innerType._zod.values),B(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),va=/*@__PURE__*/ z(`$ZodNullable`,(e,t)=>{pi.init(e,t),B(e._zod,`optin`,()=>t.innerType._zod.optin),B(e._zod,`optout`,()=>t.innerType._zod.optout),B(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${xn(e.source)}|null)$`):void 0}),B(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ya=/*@__PURE__*/ z(`$ZodDefault`,(e,t)=>{pi.init(e,t),e._zod.optin=`optional`,B(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>ba(e,t)):ba(r,t)}});function ba(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let xa=/*@__PURE__*/ z(`$ZodPrefault`,(e,t)=>{pi.init(e,t),e._zod.optin=`optional`,B(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Sa=/*@__PURE__*/ z(`$ZodNonOptional`,(e,t)=>{pi.init(e,t),B(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ca(t,e)):Ca(i,e)}});function Ca(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}let wa=/*@__PURE__*/ z(`$ZodCatch`,(e,t)=>{pi.init(e,t),e._zod.optin=`optional`,B(e._zod,`optout`,()=>t.innerType._zod.optout),B(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Yn(e,n,gn()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Yn(e,n,gn()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Ta=/*@__PURE__*/ z(`$ZodPipe`,(e,t)=>{pi.init(e,t),B(e._zod,`values`,()=>t.in._zod.values),B(e._zod,`optin`,()=>t.in._zod.optin),B(e._zod,`optout`,()=>t.out._zod.optout),B(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ea(e,t.in,n)):Ea(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ea(e,t.out,n)):Ea(r,t.out,n)}});function Ea(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}let Da=/*@__PURE__*/ z(`$ZodReadonly`,(e,t)=>{pi.init(e,t),B(e._zod,`propValues`,()=>t.innerType._zod.propValues),B(e._zod,`values`,()=>t.innerType._zod.values),B(e._zod,`optin`,()=>t.innerType?._zod?.optin),B(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Oa):Oa(r)}});function Oa(e){return e.value=Object.freeze(e.value),e}let ka=/*@__PURE__*/ z(`$ZodLazy`,(e,t)=>{pi.init(e,t),B(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),B(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),B(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),B(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),B(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Aa=/*@__PURE__*/ z(`$ZodCustom`,(e,t)=>{Jr.init(e,t),pi.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ja(t,n,r,e));ja(i,n,r,e)}});function ja(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Zn(e))}}var Ma,Na=class{constructor(){this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Pa(){return new Na}(Ma=globalThis).__zod_globalRegistry??(Ma.__zod_globalRegistry=Pa());let Fa=globalThis.__zod_globalRegistry;// @__NO_SIDE_EFFECTS__
71
+ function Ia(e,t){return new e({type:`string`,...V(t)})}// @__NO_SIDE_EFFECTS__
72
+ function La(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
73
+ function Ra(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
74
+ function za(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
75
+ function Ba(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...V(t)})}// @__NO_SIDE_EFFECTS__
76
+ function Va(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...V(t)})}// @__NO_SIDE_EFFECTS__
77
+ function Ha(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...V(t)})}// @__NO_SIDE_EFFECTS__
78
+ function Ua(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
79
+ function Wa(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
80
+ function Ga(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
81
+ function Ka(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
82
+ function qa(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
83
+ function Ja(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
84
+ function Ya(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
85
+ function Xa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
86
+ function Za(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
87
+ function Qa(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
88
+ function $a(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
89
+ function eo(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
90
+ function to(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
91
+ function no(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
92
+ function ro(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
93
+ function io(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...V(t)})}// @__NO_SIDE_EFFECTS__
94
+ function ao(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...V(t)})}// @__NO_SIDE_EFFECTS__
95
+ function oo(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...V(t)})}// @__NO_SIDE_EFFECTS__
96
+ function so(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...V(t)})}// @__NO_SIDE_EFFECTS__
97
+ function co(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...V(t)})}// @__NO_SIDE_EFFECTS__
98
+ function lo(e,t){return new e({type:`number`,checks:[],...V(t)})}// @__NO_SIDE_EFFECTS__
99
+ function uo(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...V(t)})}// @__NO_SIDE_EFFECTS__
100
+ function fo(e,t){return new e({type:`boolean`,...V(t)})}// @__NO_SIDE_EFFECTS__
101
+ function po(e,t){return new e({type:`null`,...V(t)})}// @__NO_SIDE_EFFECTS__
102
+ function mo(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
103
+ function ho(e,t){return new e({type:`never`,...V(t)})}// @__NO_SIDE_EFFECTS__
104
+ function go(e,t){return new Xr({check:`less_than`,...V(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
105
+ function _o(e,t){return new Xr({check:`less_than`,...V(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
106
+ function vo(e,t){return new Zr({check:`greater_than`,...V(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
107
+ function yo(e,t){return new Zr({check:`greater_than`,...V(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
108
+ function bo(e,t){return new Qr({check:`multiple_of`,...V(t),value:e})}// @__NO_SIDE_EFFECTS__
109
+ function xo(e,t){return new ei({check:`max_length`,...V(t),maximum:e})}// @__NO_SIDE_EFFECTS__
110
+ function So(e,t){return new ti({check:`min_length`,...V(t),minimum:e})}// @__NO_SIDE_EFFECTS__
111
+ function Co(e,t){return new ni({check:`length_equals`,...V(t),length:e})}// @__NO_SIDE_EFFECTS__
112
+ function wo(e,t){return new ii({check:`string_format`,format:`regex`,...V(t),pattern:e})}// @__NO_SIDE_EFFECTS__
113
+ function To(e){return new ai({check:`string_format`,format:`lowercase`,...V(e)})}// @__NO_SIDE_EFFECTS__
114
+ function Eo(e){return new oi({check:`string_format`,format:`uppercase`,...V(e)})}// @__NO_SIDE_EFFECTS__
115
+ function Do(e,t){return new si({check:`string_format`,format:`includes`,...V(t),includes:e})}// @__NO_SIDE_EFFECTS__
116
+ function Oo(e,t){return new ci({check:`string_format`,format:`starts_with`,...V(t),prefix:e})}// @__NO_SIDE_EFFECTS__
117
+ function ko(e,t){return new li({check:`string_format`,format:`ends_with`,...V(t),suffix:e})}// @__NO_SIDE_EFFECTS__
118
+ function Ao(e){return new ui({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
119
+ function jo(e){return/* @__PURE__ */ Ao(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
120
+ function Mo(){return/* @__PURE__ */ Ao(e=>e.trim())}// @__NO_SIDE_EFFECTS__
121
+ function No(){return/* @__PURE__ */ Ao(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
122
+ function Po(){return/* @__PURE__ */ Ao(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
123
+ function Fo(){return/* @__PURE__ */ Ao(e=>Dn(e))}// @__NO_SIDE_EFFECTS__
124
+ function Io(e,t,n){return new e({type:`array`,element:t,...V(n)})}// @__NO_SIDE_EFFECTS__
125
+ function Lo(e,t,n){let r=V(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}// @__NO_SIDE_EFFECTS__
126
+ function Ro(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...V(n)})}// @__NO_SIDE_EFFECTS__
127
+ function zo(e,t){let n=/* @__PURE__ */ Bo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Zn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Zn(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
128
+ function Bo(e,t){let n=new Jr({check:`custom`,...V(t)});return n._zod.check=e,n}function Vo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Fa,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Ho(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Ho(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Go(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Uo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
129
+
130
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}}function Wo(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:qo(t,`input`,e.processors),output:qo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Go(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Go(r.element,n);if(r.type===`set`)return Go(r.valueType,n);if(r.type===`lazy`)return Go(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return Go(r.innerType,n);if(r.type===`intersection`)return Go(r.left,n)||Go(r.right,n);if(r.type===`record`||r.type===`map`)return Go(r.keyType,n)||Go(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Go(r.in,n)||Go(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Go(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Go(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Go(e,n))return!0;return!!(r.rest&&Go(r.rest,n))}return!1}let Ko=(e,t={})=>n=>{let r=Vo({...n,processors:t});return Ho(e,r),Uo(r,e),Wo(r,e)},qo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Vo({...i??{},target:a,io:t,processors:n});return Ho(e,o),Uo(o,e),Wo(o,e)},Jo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Yo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Jo[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Xo=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Zo=(e,t,n,r)=>{n.type=`boolean`},Qo=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},$o=(e,t,n,r)=>{n.not={}},es=(e,t,n,r)=>{let i=e._zod.def,a=_n(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ts=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},ns=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},rs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},is=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Ho(a.element,t,{...r,path:[...r.path,`items`]})},as=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Ho(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Ho(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},os=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Ho(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ss=(e,t,n,r)=>{let i=e._zod.def,a=Ho(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Ho(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},cs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Ho(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Ho(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},ls=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Ho(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Ho(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Ho(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},us=(e,t,n,r)=>{let i=e._zod.def,a=Ho(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ds=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},fs=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ps=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ms=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},hs=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Ho(o,t,r);let s=t.seen.get(e);s.ref=o},gs=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},_s=(e,t,n,r)=>{let i=e._zod.def;Ho(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},vs=(e,t,n,r)=>{let i=e._zod.innerType;Ho(i,t,r);let a=t.seen.get(e);a.ref=i},ys=/*@__PURE__*/ z(`ZodISODateTime`,(e,t)=>{Di.init(e,t),Gs.init(e,t)});function bs(e){return/* @__PURE__ */ ao(ys,e)}let xs=/*@__PURE__*/ z(`ZodISODate`,(e,t)=>{Oi.init(e,t),Gs.init(e,t)});function Ss(e){return/* @__PURE__ */ oo(xs,e)}let Cs=/*@__PURE__*/ z(`ZodISOTime`,(e,t)=>{ki.init(e,t),Gs.init(e,t)});function ws(e){return/* @__PURE__ */ so(Cs,e)}let Ts=/*@__PURE__*/ z(`ZodISODuration`,(e,t)=>{Ai.init(e,t),Gs.init(e,t)});function Es(e){return/* @__PURE__ */ co(Ts,e)}let Ds=/*@__PURE__*/ z(`ZodError`,(e,t)=>{$n.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>nr(e,t)},flatten:{value:t=>tr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,vn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,vn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Os=/* @__PURE__ */ rr(Ds),ks=/* @__PURE__ */ ir(Ds),As=/* @__PURE__ */ ar(Ds),js=/* @__PURE__ */ sr(Ds),Ms=/* @__PURE__ */ lr(Ds),Ns=/* @__PURE__ */ ur(Ds),Ps=/* @__PURE__ */ dr(Ds),Fs=/* @__PURE__ */ fr(Ds),Is=/* @__PURE__ */ pr(Ds),Ls=/* @__PURE__ */ mr(Ds),Rs=/* @__PURE__ */ hr(Ds),zs=/* @__PURE__ */ gr(Ds),Bs=/* @__PURE__ */ new WeakMap;function Vs(e,t,n){let r=Object.getPrototypeOf(e),i=Bs.get(r);if(i||(i=/* @__PURE__ */ new Set,Bs.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}let Hs=/*@__PURE__*/ z(`ZodType`,(e,t)=>(pi.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:qo(e,`input`),output:qo(e,`output`)}}),e.toJSONSchema=Ko(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Os(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>As(e,t,n),e.parseAsync=async(t,n)=>ks(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>js(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ms(e,t,n),e.decode=(t,n)=>Ns(e,t,n),e.encodeAsync=async(t,n)=>Ps(e,t,n),e.decodeAsync=async(t,n)=>Fs(e,t,n),e.safeEncode=(t,n)=>Is(e,t,n),e.safeDecode=(t,n)=>Ls(e,t,n),e.safeEncodeAsync=async(t,n)=>Rs(e,t,n),e.safeDecodeAsync=async(t,n)=>zs(e,t,n),Vs(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Tn(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Fn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(sl(e,t))},superRefine(e,t){return this.check(cl(e,t))},overwrite(e){return this.check(/* @__PURE__ */ Ao(e))},optional(){return Bc(this)},exactOptional(){return Hc(this)},nullable(){return Wc(this)},nullish(){return Bc(Wc(this))},nonoptional(e){return Xc(this,e)},array(){return G(this)},or(e){return Ec([this,e])},and(e){return Ac(this,e)},transform(e){return el(this,Rc(e))},default(e){return Kc(this,e)},prefault(e){return Jc(this,e)},catch(e){return Qc(this,e)},pipe(e){return el(this,e)},readonly(){return nl(this)},describe(e){let t=this.clone();return Fa.add(t,{description:e}),t},meta(...e){if(e.length===0)return Fa.get(this);let t=this.clone();return Fa.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Fa.get(e)?.description},configurable:!0}),e)),Us=/*@__PURE__*/ z(`_ZodString`,(e,t)=>{mi.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Vs(e,`_ZodString`,{regex(...e){return this.check(/* @__PURE__ */ wo(...e))},includes(...e){return this.check(/* @__PURE__ */ Do(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Oo(...e))},endsWith(...e){return this.check(/* @__PURE__ */ ko(...e))},min(...e){return this.check(/* @__PURE__ */ So(...e))},max(...e){return this.check(/* @__PURE__ */ xo(...e))},length(...e){return this.check(/* @__PURE__ */ Co(...e))},nonempty(...e){return this.check(/* @__PURE__ */ So(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ To(e))},uppercase(e){return this.check(/* @__PURE__ */ Eo(e))},trim(){return this.check(/* @__PURE__ */ Mo())},normalize(...e){return this.check(/* @__PURE__ */ jo(...e))},toLowerCase(){return this.check(/* @__PURE__ */ No())},toUpperCase(){return this.check(/* @__PURE__ */ Po())},slugify(){return this.check(/* @__PURE__ */ Fo())}})}),Ws=/*@__PURE__*/ z(`ZodString`,(e,t)=>{mi.init(e,t),Us.init(e,t),e.email=t=>e.check(/* @__PURE__ */ La(Ks,t)),e.url=t=>e.check(/* @__PURE__ */ Ua(Xs,t)),e.jwt=t=>e.check(/* @__PURE__ */ io(fc,t)),e.emoji=t=>e.check(/* @__PURE__ */ Wa(Qs,t)),e.guid=t=>e.check(/* @__PURE__ */ Ra(qs,t)),e.uuid=t=>e.check(/* @__PURE__ */ za(Js,t)),e.uuidv4=t=>e.check(/* @__PURE__ */ Ba(Js,t)),e.uuidv6=t=>e.check(/* @__PURE__ */ Va(Js,t)),e.uuidv7=t=>e.check(/* @__PURE__ */ Ha(Js,t)),e.nanoid=t=>e.check(/* @__PURE__ */ Ga($s,t)),e.guid=t=>e.check(/* @__PURE__ */ Ra(qs,t)),e.cuid=t=>e.check(/* @__PURE__ */ Ka(ec,t)),e.cuid2=t=>e.check(/* @__PURE__ */ qa(tc,t)),e.ulid=t=>e.check(/* @__PURE__ */ Ja(nc,t)),e.base64=t=>e.check(/* @__PURE__ */ to(lc,t)),e.base64url=t=>e.check(/* @__PURE__ */ no(uc,t)),e.xid=t=>e.check(/* @__PURE__ */ Ya(rc,t)),e.ksuid=t=>e.check(/* @__PURE__ */ Xa(ic,t)),e.ipv4=t=>e.check(/* @__PURE__ */ Za(ac,t)),e.ipv6=t=>e.check(/* @__PURE__ */ Qa(oc,t)),e.cidrv4=t=>e.check(/* @__PURE__ */ $a(sc,t)),e.cidrv6=t=>e.check(/* @__PURE__ */ eo(cc,t)),e.e164=t=>e.check(/* @__PURE__ */ ro(dc,t)),e.datetime=t=>e.check(bs(t)),e.date=t=>e.check(Ss(t)),e.time=t=>e.check(ws(t)),e.duration=t=>e.check(Es(t))});function H(e){return/* @__PURE__ */ Ia(Ws,e)}let Gs=/*@__PURE__*/ z(`ZodStringFormat`,(e,t)=>{hi.init(e,t),Us.init(e,t)}),Ks=/*@__PURE__*/ z(`ZodEmail`,(e,t)=>{vi.init(e,t),Gs.init(e,t)}),qs=/*@__PURE__*/ z(`ZodGUID`,(e,t)=>{gi.init(e,t),Gs.init(e,t)}),Js=/*@__PURE__*/ z(`ZodUUID`,(e,t)=>{_i.init(e,t),Gs.init(e,t)});function Ys(e){return/* @__PURE__ */ za(Js,e)}let Xs=/*@__PURE__*/ z(`ZodURL`,(e,t)=>{yi.init(e,t),Gs.init(e,t)});function Zs(e){return/* @__PURE__ */ Ua(Xs,e)}let Qs=/*@__PURE__*/ z(`ZodEmoji`,(e,t)=>{bi.init(e,t),Gs.init(e,t)}),$s=/*@__PURE__*/ z(`ZodNanoID`,(e,t)=>{xi.init(e,t),Gs.init(e,t)}),ec=/*@__PURE__*/ z(`ZodCUID`,(e,t)=>{Si.init(e,t),Gs.init(e,t)}),tc=/*@__PURE__*/ z(`ZodCUID2`,(e,t)=>{Ci.init(e,t),Gs.init(e,t)}),nc=/*@__PURE__*/ z(`ZodULID`,(e,t)=>{wi.init(e,t),Gs.init(e,t)}),rc=/*@__PURE__*/ z(`ZodXID`,(e,t)=>{Ti.init(e,t),Gs.init(e,t)}),ic=/*@__PURE__*/ z(`ZodKSUID`,(e,t)=>{Ei.init(e,t),Gs.init(e,t)}),ac=/*@__PURE__*/ z(`ZodIPv4`,(e,t)=>{ji.init(e,t),Gs.init(e,t)}),oc=/*@__PURE__*/ z(`ZodIPv6`,(e,t)=>{Mi.init(e,t),Gs.init(e,t)}),sc=/*@__PURE__*/ z(`ZodCIDRv4`,(e,t)=>{Ni.init(e,t),Gs.init(e,t)}),cc=/*@__PURE__*/ z(`ZodCIDRv6`,(e,t)=>{Pi.init(e,t),Gs.init(e,t)}),lc=/*@__PURE__*/ z(`ZodBase64`,(e,t)=>{Ii.init(e,t),Gs.init(e,t)}),uc=/*@__PURE__*/ z(`ZodBase64URL`,(e,t)=>{Ri.init(e,t),Gs.init(e,t)}),dc=/*@__PURE__*/ z(`ZodE164`,(e,t)=>{zi.init(e,t),Gs.init(e,t)}),fc=/*@__PURE__*/ z(`ZodJWT`,(e,t)=>{Vi.init(e,t),Gs.init(e,t)}),pc=/*@__PURE__*/ z(`ZodNumber`,(e,t)=>{Hi.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),Vs(e,`ZodNumber`,{gt(e,t){return this.check(/* @__PURE__ */ vo(e,t))},gte(e,t){return this.check(/* @__PURE__ */ yo(e,t))},min(e,t){return this.check(/* @__PURE__ */ yo(e,t))},lt(e,t){return this.check(/* @__PURE__ */ go(e,t))},lte(e,t){return this.check(/* @__PURE__ */ _o(e,t))},max(e,t){return this.check(/* @__PURE__ */ _o(e,t))},int(e){return this.check(hc(e))},safe(e){return this.check(hc(e))},positive(e){return this.check(/* @__PURE__ */ vo(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ yo(0,e))},negative(e){return this.check(/* @__PURE__ */ go(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ _o(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ bo(e,t))},step(e,t){return this.check(/* @__PURE__ */ bo(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function U(e){return/* @__PURE__ */ lo(pc,e)}let mc=/*@__PURE__*/ z(`ZodNumberFormat`,(e,t)=>{Ui.init(e,t),pc.init(e,t)});function hc(e){return/* @__PURE__ */ uo(mc,e)}let gc=/*@__PURE__*/ z(`ZodBoolean`,(e,t)=>{Wi.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r)});function W(e){return/* @__PURE__ */ fo(gc,e)}let _c=/*@__PURE__*/ z(`ZodNull`,(e,t)=>{Gi.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r)});function vc(e){return/* @__PURE__ */ po(_c,e)}let yc=/*@__PURE__*/ z(`ZodUnknown`,(e,t)=>{Ki.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function bc(){return/* @__PURE__ */ mo(yc)}let xc=/*@__PURE__*/ z(`ZodNever`,(e,t)=>{qi.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r)});function Sc(e){return/* @__PURE__ */ ho(xc,e)}let Cc=/*@__PURE__*/ z(`ZodArray`,(e,t)=>{Yi.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),e.element=t.element,Vs(e,`ZodArray`,{min(e,t){return this.check(/* @__PURE__ */ So(e,t))},nonempty(e){return this.check(/* @__PURE__ */ So(1,e))},max(e,t){return this.check(/* @__PURE__ */ xo(e,t))},length(e,t){return this.check(/* @__PURE__ */ Co(e,t))},unwrap(){return this.element}})});function G(e,t){return/* @__PURE__ */ Io(Cc,e,t)}let wc=/*@__PURE__*/ z(`ZodObject`,(e,t)=>{ea.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),B(e,`shape`,()=>t.shape),Vs(e,`ZodObject`,{keyof(){return J(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:bc()})},loose(){return this.clone({...this._zod.def,catchall:bc()})},strict(){return this.clone({...this._zod.def,catchall:Sc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Bn(this,e)},safeExtend(e){return Vn(this,e)},merge(e){return Hn(this,e)},pick(e){return Rn(this,e)},omit(e){return zn(this,e)},partial(...e){return Un(zc,this,e[0])},required(...e){return Wn(Yc,this,e[0])}})});function K(e,t){let n={type:`object`,shape:e??{},...V(t)};return new wc(n)}function q(e,t){return new wc({type:`object`,shape:e,catchall:Sc(),...V(t)})}let Tc=/*@__PURE__*/ z(`ZodUnion`,(e,t)=>{na.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r),e.options=t.options});function Ec(e,t){return new Tc({type:`union`,options:e,...V(t)})}let Dc=/*@__PURE__*/ z(`ZodDiscriminatedUnion`,(e,t)=>{Tc.init(e,t),ra.init(e,t)});function Oc(e,t,n){return new Dc({type:`union`,options:t,discriminator:e,...V(n)})}let kc=/*@__PURE__*/ z(`ZodIntersection`,(e,t)=>{ia.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r)});function Ac(e,t){return new kc({type:`intersection`,left:e,right:t})}let jc=/*@__PURE__*/ z(`ZodTuple`,(e,t)=>{sa.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function Mc(e,t,n){let r=t instanceof pi;return new jc({type:`tuple`,items:e,rest:r?t:null,...V(r?n:t)})}let Nc=/*@__PURE__*/ z(`ZodRecord`,(e,t)=>{da.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Pc(e,t,n){return!t||!t._zod?new Nc({type:`record`,keyType:H(),valueType:e,...V(t)}):new Nc({type:`record`,keyType:e,valueType:t,...V(n)})}let Fc=/*@__PURE__*/ z(`ZodEnum`,(e,t)=>{fa.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Fc({...t,checks:[],...V(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Fc({...t,checks:[],...V(r),entries:i})}});function J(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Fc({type:`enum`,entries:n,...V(t)})}let Ic=/*@__PURE__*/ z(`ZodLiteral`,(e,t)=>{pa.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Y(e,t){return new Ic({type:`literal`,values:Array.isArray(e)?e:[e],...V(t)})}let Lc=/*@__PURE__*/ z(`ZodTransform`,(e,t)=>{ma.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new mn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Zn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Zn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Rc(e){return new Lc({type:`transform`,transform:e})}let zc=/*@__PURE__*/ z(`ZodOptional`,(e,t)=>{ga.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Bc(e){return new zc({type:`optional`,innerType:e})}let Vc=/*@__PURE__*/ z(`ZodExactOptional`,(e,t)=>{_a.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hc(e){return new Vc({type:`optional`,innerType:e})}let Uc=/*@__PURE__*/ z(`ZodNullable`,(e,t)=>{va.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wc(e){return new Uc({type:`nullable`,innerType:e})}let Gc=/*@__PURE__*/ z(`ZodDefault`,(e,t)=>{ya.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kc(e,t){return new Gc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Mn(t)}})}let qc=/*@__PURE__*/ z(`ZodPrefault`,(e,t)=>{xa.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Jc(e,t){return new qc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Mn(t)}})}let Yc=/*@__PURE__*/ z(`ZodNonOptional`,(e,t)=>{Sa.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xc(e,t){return new Yc({type:`nonoptional`,innerType:e,...V(t)})}let Zc=/*@__PURE__*/ z(`ZodCatch`,(e,t)=>{wa.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Qc(e,t){return new Zc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let $c=/*@__PURE__*/ z(`ZodPipe`,(e,t)=>{Ta.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r),e.in=t.in,e.out=t.out});function el(e,t){return new $c({type:`pipe`,in:e,out:t})}let tl=/*@__PURE__*/ z(`ZodReadonly`,(e,t)=>{Da.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nl(e){return new tl({type:`readonly`,innerType:e})}let rl=/*@__PURE__*/ z(`ZodLazy`,(e,t)=>{ka.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function il(e){return new rl({type:`lazy`,getter:e})}let al=/*@__PURE__*/ z(`ZodCustom`,(e,t)=>{Aa.init(e,t),Hs.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r)});function ol(e,t){return/* @__PURE__ */ Lo(al,e??(()=>!0),t)}function sl(e,t={}){return/* @__PURE__ */ Ro(al,e,t)}function cl(e,t){return/* @__PURE__ */ zo(e,t)}function ll(e){return(t,n)=>{for(let r of e)Object.hasOwn(t,r)&&t[r]===void 0&&n.addIssue({code:`custom`,path:[r],message:`Explicit undefined is not valid JSON`})}}let ul=Ec([H(),U(),W(),vc()]);function dl(e){let t=/* @__PURE__ */ new WeakSet,n=[{value:e,leaving:!1}];try{for(;n.length>0;){let e=n.pop();if(!e)break;if(e.leaving)t.delete(e.value);else if(typeof e.value==`object`&&e.value!==null){if(t.has(e.value))return!1;t.add(e.value),n.push({value:e.value,leaving:!0});for(let t of Object.values(e.value))n.push({value:t,leaving:!1})}}}catch{return!1}return!0}let fl=ol(dl,{message:`JSON value must not contain circular references`}),pl=il(()=>Ec([ul,G(pl),Pc(H(),pl)])),ml=fl.pipe(pl);fl.pipe(G(pl));let hl=fl.pipe(Pc(H(),pl)),gl=q({code:H().min(1),message:H().min(1),retryable:W(),diagnostic:H().min(1).optional(),stage:H().min(1).optional(),durationMs:U().int().nonnegative().optional(),stderrTail:H().min(1).optional()}).superRefine(ll([`diagnostic`,`stage`,`durationMs`,`stderrTail`])),_l=H().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u),vl=e=>H().min(1).max(e).refine(e=>e.trim().length>0),yl=Pc(_l,K({label:vl(256).optional(),description:vl(1024).optional()}).strict()).refine(e=>Object.keys(e).length<=16,`Too many locales`),bl=Pc(_l,vl(4096)).refine(e=>typeof e.en==`string`,`English fallback is required`).refine(e=>Object.keys(e).length<=16,`Too many locales`),xl=H().refine(e=>e.trim().length>0,{message:`Identifier must not be empty or whitespace`}),Sl=xl.brand(),Cl=xl.brand(),wl=xl.brand();xl.brand(),xl.brand();let Tl=H().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),El=Tl.max(128).regex(/^[A-Za-z0-9._~:-]+$/u,`Permission Mode ID must use transport-safe characters`).brand(),Dl=K({modes:G(K({id:El,label:Tl.max(256),description:Tl.max(1024).optional(),dangerous:W().optional(),localizations:yl.optional()}).strict()).min(1).max(32),defaultModeId:El}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.modes.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Permission Mode IDs must be unique`,path:[`modes`,r,`id`]}),n.add(i.id);n.has(e.defaultModeId)||t.addIssue({code:`custom`,message:`Default Permission Mode must exist in the catalog`,path:[`defaultModeId`]})});K({threadId:Cl,permissionModeId:El}).strict();let Ol=U().int().safe().nonnegative(),kl=U().finite().nonnegative(),Al=U().finite().min(0).max(100),jl=K({version:Ec([Y(3),Y(4)]).optional(),requestId:H().min(1),turnId:H().min(1).max(1024),outputTokens:Ol,startedAtMs:Ol,completedAtMs:Ol}).strict().refine(e=>e.completedAtMs>e.startedAtMs),Ml=K({version:Ec([Y(2),Y(3),Y(4)]).optional(),value:kl,turnId:H().min(1).max(1024),at:Ol}).strict();K({outputTimings:G(jl).transform(e=>e.filter(e=>e.version===4)).optional(),outputTokensPerSecond:Ml.refine(e=>e.version===4).optional().catch(void 0),timeToFirstOutputMs:Ml.extend({value:Ol}).optional()}).strict();let Nl=e=>bl.refine(t=>Object.values(t).every(t=>t.length<=e)),Pl=K({composerIndicators:G(K({kind:Y(`countdown`),id:H().min(1).max(64),expiresAtUnix:Ol,label:Nl(256).optional(),tooltip:Nl(1024).optional()}).strict()).max(2).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,{message:`Composer indicator IDs must be unique`}).optional(),inputTokens:Ol.optional(),cachedInputTokens:Ol.optional(),cacheWriteInputTokens:Ol.optional(),outputTokens:Ol.optional(),outputTokensPerSecond:kl.optional(),sessionOutputTokensPerSecond:kl.optional(),apiOutputTokensPerSecond:kl.optional(),reasoningOutputTokens:Ol.optional(),totalTokens:Ol.optional(),totalCostUsd:kl.optional(),totalCredits:kl.optional(),contextUsagePercent:kl.optional(),cacheHitRatePercent:Al.optional(),contextWindowTokens:Ol.optional(),contextUsedTokens:Ol.optional(),planFiveHourUsedPercent:Al.optional(),planFiveHourResetsAtUnix:Ol.optional(),planSevenDayUsedPercent:Al.optional(),planSevenDayResetsAtUnix:Ol.optional(),sessionCacheHitRatePercent:Al.optional(),timeToFirstOutputMs:Ol.optional(),latestRequestTimeToFirstOutputMs:Ol.optional(),costSource:J([`publicPrice`,`native`]).optional(),unpricedModels:G(H().min(1)).min(1).optional()}).strict().superRefine((e,t)=>{Object.keys(e).length===0&&t.addIssue({code:`custom`,message:`Thread Usage must contain a reliable field`});let n=e.contextUsedTokens!==void 0;n!==(e.contextWindowTokens!==void 0)&&t.addIssue({code:`custom`,message:`Thread Usage context fields must be provided together`,path:[n?`contextWindowTokens`:`contextUsedTokens`]}),e.contextWindowTokens===0&&t.addIssue({code:`custom`,message:`Thread Usage contextWindowTokens must be greater than zero`,path:[`contextWindowTokens`]}),e.costSource!==void 0&&e.totalCostUsd===void 0&&t.addIssue({code:`custom`,message:`Thread Usage costSource must be provided with totalCostUsd`,path:[`costSource`]}),e.unpricedModels!==void 0&&e.costSource!==`publicPrice`&&t.addIssue({code:`custom`,message:`Thread Usage unpricedModels must be provided with a publicPrice cost`,path:[`unpricedModels`]}),e.planFiveHourResetsAtUnix!==void 0&&e.planFiveHourUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent`,path:[`planFiveHourResetsAtUnix`]}),e.planSevenDayResetsAtUnix!==void 0&&e.planSevenDayUsedPercent===void 0&&t.addIssue({code:`custom`,message:`Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent`,path:[`planSevenDayResetsAtUnix`]})}),Fl=U().finite().min(0).max(100),Il=J([`weekly`,`monthly`,`five_hour`,`seven_day`,`unknown`]),Ll=K({id:H().min(1).max(256),label:H().min(1).max(256),localizations:yl.optional()}).strict(),Rl=K({product:H().min(1),periodType:Il.optional(),scope:Ll.optional(),localizations:yl.optional(),used:U().finite().nonnegative().optional(),limit:U().finite().nonnegative().optional(),unit:H().min(1).max(32).optional(),usagePercent:Fl,resetsAt:H().min(1).optional()}).strict(),zl=K({availableCount:U().int().safe().positive(),nextExpiresAt:H().min(1).optional(),expiresAt:G(H().min(1)).min(1).max(32).optional()}).strict(),Bl=K({used:U().finite().nonnegative().optional(),limit:U().finite().nonnegative().optional(),unit:H().min(1).max(32).optional(),label:H().min(1).optional(),scope:Ll.optional(),localizations:yl.optional(),usedPercent:Fl,resetsAt:H().min(1).optional(),periodType:Il,productUsage:G(Rl).min(1).optional(),resetCredits:zl.optional()}).strict(),Vl=K({amount:U().finite().nonnegative(),currency:H().trim().min(1).max(8),label:H().trim().min(1).max(128).optional()}).strict();K({threadId:Cl,refresh:Y(`exact`).optional()}).strict(),K({threadId:Cl,usage:Pl.nullable(),accountCredits:Bl.optional(),accountBalance:Vl.optional(),accountCreditsSupported:W().optional()}).strict();let Hl=H().refine(e=>e.trim().length>0,{message:`Value must not be empty or whitespace`}),Ul=H().min(1).max(512).refine(e=>!/\p{Cc}/u.test(e),`Model Ref must not contain control characters`).brand(),Wl=J([`priority`,`ultrafast`]),Gl=K({id:Ul,serviceTier:Wl.optional()}).strict();function Kl(e,t){return e?.id===t?.id&&e?.serviceTier===t?.serviceTier}let ql=Hl.max(128).regex(/^[A-Za-z0-9._~-]+$/u,`Thinking option ID must use transport-safe characters`).brand(),Jl=Hl.max(256),Yl=K({id:ql,label:Hl.max(256)}).strict(),Xl=K({ref:Gl,label:Hl.max(256),resolvedModelLabel:Jl.optional(),fastModel:Gl.optional(),supportedThinkingOptionIds:G(ql).optional()}).strict().refine(e=>e.fastModel?.serviceTier===void 0||e.fastModel.id===e.ref.id,{path:[`fastModel`,`id`],message:`A tiered Fast Model must share the base Model ID`});function Zl(e,t){if(t)return e?.models.find(e=>Kl(e.ref,t)||Kl(e.fastModel,t))}let Ql=G(Yl).superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Thinking option IDs must be unique`,path:[r,`id`]}),n.add(i.id)}),$l=K({models:G(Xl),defaultModel:Gl.optional(),thinkingOptions:Ql,defaultThinkingOptionId:ql.optional()}).strict().superRefine((e,t)=>{let n=[],r=new Set(e.thinkingOptions.map(({id:e})=>e));for(let[i,a]of e.models.entries()){n.some(e=>Kl(e,a.ref))&&t.addIssue({code:`custom`,message:`Model Catalog refs must be unique`,path:[`models`,i,`ref`,`id`]}),n.push(a.ref),a.fastModel&&(n.some(e=>Kl(e,a.fastModel))&&t.addIssue({code:`custom`,message:`Fast Model refs must be distinct and unique`,path:[`models`,i,`fastModel`]}),n.push(a.fastModel));let e=/* @__PURE__ */ new Set;for(let[n,o]of(a.supportedThinkingOptionIds??[]).entries())e.has(o)&&t.addIssue({code:`custom`,message:`Supported Thinking option IDs must be unique per Model`,path:[`models`,i,`supportedThinkingOptionIds`,n]}),e.add(o),r.has(o)||t.addIssue({code:`custom`,message:`Supported Thinking option must exist in the catalog`,path:[`models`,i,`supportedThinkingOptionIds`,n]})}e.defaultModel&&!Zl(e,e.defaultModel)&&t.addIssue({code:`custom`,message:`Default Model must exist in the Model Catalog`,path:[`defaultModel`,`id`]}),e.defaultThinkingOptionId&&!r.has(e.defaultThinkingOptionId)&&t.addIssue({code:`custom`,message:`Default Thinking option must exist in the catalog`,path:[`defaultThinkingOptionId`]})}),eu=K({fork:W(),forkAcrossCwd:W(),rollbackLastTurn:W()}).strict().refine(e=>e.fork||!e.forkAcrossCwd,{path:[`forkAcrossCwd`],message:`Cross-cwd Fork requires exact history Fork support`}),tu=J([`live`,`atCreate`]),nu=K({configuration:K({selectModel:W(),selectThinkingOption:W(),selectPermissionMode:W(),permissionModeScope:tu.default(`live`)}).strict(),history:eu,subagents:K({observe:W(),readTranscript:W()}).strict().optional(),autonomousTurns:K({observe:W()}).strict().optional(),steer:W().optional(),persistentPlan:W().optional()}).strict();K({effectiveModel:Gl.optional(),resolvedModelLabel:Jl.optional(),effectiveThinkingOptionId:ql.optional(),availableThinkingOptions:Ql.optional(),effectivePermissionModeId:El.optional()}).strict().superRefine((e,t)=>{e.effectiveThinkingOptionId&&e.availableThinkingOptions&&!e.availableThinkingOptions.some(({id:t})=>t===e.effectiveThinkingOptionId)&&t.addIssue({code:`custom`,message:`Effective Thinking option must be currently available`,path:[`effectiveThinkingOptionId`]})});let ru=K({open:Y(!0)}).strict();Ec([K({status:Y(`ready`),catalog:$l,permissionModes:Dl.optional(),capabilities:nu,webUi:ru.optional()}).strict().superRefine((e,t)=>{let n=e.capabilities.configuration.selectPermissionMode;n!==!!e.permissionModes&&t.addIssue({code:`custom`,message:`Permission Mode catalog and capability must agree`,path:n?[`permissionModes`]:[`capabilities`,`configuration`,`selectPermissionMode`]})}),K({status:J([`notInstalled`,`unavailable`,`error`]),error:gl}).strict()]),K({harnessId:Sl,cwd:Hl.max(16384).optional(),refresh:W().optional(),purpose:Y(`availability`).optional(),credentialAccess:J([`allow`,`retry`]).optional()}).strict(),K({harnessId:Sl}).strict(),K({}).strict(),K({threadId:Cl,model:Gl}).strict(),K({threadId:Cl,thinkingOptionId:ql}).strict(),K({threadId:Cl,includeReferenceCapability:W().optional()}).strict(),Oc(`owner`,[K({owner:Y(`codex`),locked:W(),effectiveModel:Gl.optional(),resolvedModelLabel:Jl.optional(),effectiveThinkingOptionId:ql.optional(),effectivePermissionModeId:El.optional(),history:eu.optional(),supportsThreadReferences:Y(!0).optional()}).strict(),K({owner:Y(`external`),harnessId:Hl.max(256),transportModelId:Hl.max(8192),effectiveModel:Gl.optional(),resolvedModelLabel:Jl.optional(),effectiveThinkingOptionId:ql.optional(),availableThinkingOptions:Ql.optional(),effectivePermissionModeId:El.optional(),catalog:$l.optional(),history:eu,usage:Pl.optional(),locked:Y(!0)}).strict()]),K({threadIds:G(Cl).min(1).max(100)}).strict().superRefine(({threadIds:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i)&&t.addIssue({code:`custom`,message:`Thread ownership-list IDs must be unique`,path:[`threadIds`,r]}),n.add(i)});let iu=Oc(`owner`,[K({threadId:Cl,owner:Y(`codex`)}).strict(),K({threadId:Cl,owner:Y(`external`),harnessId:H().max(256).pipe(Sl)}).strict()]);K({threads:G(iu).min(1).max(100)}).strict().superRefine(({threads:e},t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.entries())n.has(i.threadId)&&t.addIssue({code:`custom`,message:`Thread ownership-list results must be unique`,path:[`threads`,r,`threadId`]}),n.add(i.threadId)}),K({threadId:Cl,text:H().optional()}).strict(),K({kind:Y(`application`),value:H().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:`custom`,message:`Invalid steering context JSON`}),fn}}).pipe(K({expectedTurnId:wl,clientUserMessageId:H().min(1),delivery:J([`newTurn`,`activeTurn`])}).strict())}).strict().transform(e=>e.value),J([`activeTurn`,`newTurn`]),K({delivery:J([`official`,`activeTurn`,`newTurn`])}).strict();let au=H().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u),ou=au.pipe(Sl),su=ou.refine(e=>e!==`codex`,`The official Codex identity is reserved`),cu=H().min(1).max(512).refine(e=>!/[\\\u0000:#?]/u.test(e)&&!e.startsWith(`/`)&&!e.split(`/`).some(e=>e===`..`||e===``),`Plugin resources must be relative paths inside the plugin`),lu=Zs().refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Plugin documentation links must be credential-free HTTPS URLs`),uu=K({en:H().max(4096),"zh-CN":H().max(4096).optional()}).strict(),du=K({commands:G(K({terminal:H().max(256),command:H().max(4096)}).strict()).max(8),before:uu.optional(),after:uu.optional(),downloads:G(K({label:H().max(128),url:lu}).strict()).max(8).optional()}).strict(),fu={id:ou,name:H().trim().min(1).max(128),version:H().min(1).max(128),kind:Y(`usage`).optional(),iconStyle:K({vector:K({viewBox:H().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),color:H().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),paths:G(K({d:H().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),fillRule:J([`evenodd`,`nonzero`]).optional(),fill:H().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()}).strict()).min(1).max(32)}).strict().optional(),background:H().regex(/^#[a-f0-9]{6}$/iu).optional(),borderRadius:U().min(0).max(50).optional(),paddingRatio:U().min(0).max(.25).optional()}).strict().optional(),installation:du.optional(),notice:uu.optional(),launchCommand:Y(!0).optional(),links:K({website:lu.optional(),documentation:lu.optional(),installation:lu.optional()}).strict().optional()};K({manifestVersion:Y(1),...fu,adapterApiVersion:U().int().positive(),entry:cu,icon:cu.optional()}).strict();let pu=H().max(174828).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u),mu=K({...fu,icon:pu.optional()}).strict();K({}).strict(),K({plugins:G(mu.extend({id:su})).max(128)}).strict(),K({version:Y(1),enabled:G(ou).max(128)}).strict().refine(e=>new Set(e.enabled).size===e.enabled.length,{message:`Enabled plugin IDs must be unique`,path:[`enabled`]});let hu=au,gu=J([`sidebar.thread-layout`,`sidebar.thread-badge`,`appearance.theme`]),_u=J([`appearance`,`interface`,`workflow`,`analytics`,`integrations`,`tools`]),vu=H().trim().min(1).max(128);function yu(e){switch(e.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`webp`:return`image/webp`;default:return}}let bu=e=>e.split(`/`).every(e=>!/[. ]$/u.test(e)),xu=cu.refine(e=>yu(e)!==void 0&&bu(e),`Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space`),Su=H().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu,`Expected an HTTP(S) URL`).pipe(Zs({protocol:/^https?$/u})).refine(e=>{let{username:t,password:n}=new URL(e);return!t&&!n&&!/[\\\s]/u.test(e)},`URL must not contain credentials, backslashes, or whitespace`);function Cu(e){return q({en:e,"zh-CN":e})}let wu=Cu(H().trim().min(1)),Tu=G(_u).max(_u.options.length).refine(e=>new Set(e).size===e.length,`Duplicate categories`),Eu=G(gu).max(gu.options.length).refine(e=>new Set(e).size===e.length,`Duplicate slots`),Du={key:H().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),label:wu,description:wu.optional()},Ou={...Du,step:U().positive().optional(),default:U().optional()},ku=q({value:H(),label:wu}),Au=Oc(`type`,[q({...Du,type:Y(`boolean`),default:W().optional()}),q({...Du,type:Y(`string`),placeholder:wu.optional(),default:H().optional()}),q({...Ou,type:Y(`number`),min:U().optional(),max:U().optional()}),q({...Ou,type:Y(`range`),min:U(),max:U()}),q({...Du,type:Y(`select`),options:G(ku).min(1),default:H().optional()})]).superRefine((e,t)=>{let n=(e,n)=>t.addIssue({code:`custom`,path:[e],message:n});if(e.type===`number`||e.type===`range`){let{min:t=-1/0,max:r=1/0,default:i}=e;t>r&&n(`max`,`Must be at least min`),i!==void 0&&(i<t||i>r)&&n(`default`,`Must be within min and max`)}else if(e.type===`select`){let t=new Set(e.options.map(({value:e})=>e));t.size!==e.options.length&&n(`options`,`Duplicate option values`),e.default!==void 0&&!t.has(e.default)&&n(`default`,`Must match an option value`)}}),ju=K({manifestVersion:hc().positive(),id:hu,name:Ec([vu,Cu(vu)]),version:H().min(1).max(128),desktopApi:hc().positive()}).passthrough().extend({manifestVersion:Y(1),desktopApi:Y(1),description:q({en:H().max(4096),"zh-CN":H().max(4096).optional()}).optional(),author:H().trim().min(1).max(128).optional(),repository:Su.optional(),details:q({en:H().max(16384),"zh-CN":H().max(16384).optional()}).optional(),icon:xu.optional(),screenshots:G(xu).max(4).refine(e=>new Set(e).size===e.length,`Duplicate screenshots`).optional(),desktop:q({script:cu,style:cu.optional()}).optional(),backend:q({script:cu.refine(bu)}).optional(),slots:Eu.default(()=>[]),settingsSchema:G(Au).max(32).refine(e=>new Set(e.map(({key:e})=>e)).size===e.length,`Duplicate setting keys`).optional(),categories:Tu.optional()}).strict().refine(e=>e.desktop!==void 0||e.backend!==void 0,`Expected at least one desktop or backend entry`),Mu=H().regex(/^[a-f0-9]{64}$/u),Nu=q({state:J([`running`,`disabled`,`invalid`,`incompatible`,`conflict`,`failed`,`waiting`]),hash:Mu.optional(),error:H().optional(),conflictWith:hu.optional()});q({controllerPid:hc().positive(),targetId:H().nullable(),updatedAt:bs(),handledReloadToken:Ys().optional(),extensions:Pc(H(),Nu),surfaces:Pc(H(),Nu).optional()});let Pu=J([`official`,`community`]);function Fu(e){return e.origin===`https://api.github.com`&&/^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(e.pathname)}let Iu=Su.refine(e=>{let t=new URL(e);return/\.zip$/iu.test(t.pathname)||Fu(t)||t.origin===`https://github.com`&&/^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(t.pathname)||t.origin===`https://codeload.github.com`&&/^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(t.pathname)},`Expected a .zip download URL or a GitHub zipball URL`),Lu=q({id:hu,version:H().trim().min(1).max(128),name:wu.extend({en:vu,"zh-CN":vu}),description:Cu(H().trim().min(1).max(4096)),details:Cu(H().trim().min(1).max(16384)).optional(),author:H().trim().min(1).max(128),repository:Su,stars:U().int().min(0).optional(),downloads:U().int().min(0).optional(),categories:Tu.optional(),trustTier:Pu.default(`community`),icon:Su.optional(),screenshots:G(Su).max(4).optional(),downloadUrl:Iu,sha256:Mu,slots:Eu.optional(),publishedAt:H().optional(),updatedAt:H().optional(),minCodexHostVersion:H().optional()});q({schemaVersion:Y(1),generatedAt:H(),extensions:G(Lu).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)});let Ru=H().trim().min(1).max(128),zu=/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu,Bu=hu.refine(e=>!zu.test(e),`Reserved extension ID`),Vu=J([`desktop`,`web`]),Hu=Mu,Uu=Ys(),Wu=cu.refine(e=>!/[\x00-\x1f\x7f<>"|*]/u.test(e)&&e.split(`/`).every(e=>!/[. ]$/u.test(e)&&!zu.test(e)),`Expected a portable relative resource path`).refine(e=>e.split(`/`).length<=32,`Extension resources may be at most 32 segments deep`),Gu=ju.shape,Ku=(e,t=0)=>q({en:H().trim().min(t).max(e),"zh-CN":H().trim().min(t).max(e)}),qu=e=>Wu.refine(t=>t.endsWith(e),`Expected a ${e} file`),Ju=qu(`.mjs`),Yu=qu(`.css`).optional(),Xu=e=>e.normalize(`NFC`).toLowerCase(),Zu=q({manifestVersion:Y(2),id:Bu,name:Ku(128,1),version:H().trim().min(1).max(128),description:Ku(4096),details:Ku(16384).optional(),author:Gu.author,repository:Gu.repository,icon:Gu.icon.refine(e=>e===void 0||Wu.safeParse(e).success),screenshots:Gu.screenshots.refine(e=>e===void 0||e.every(e=>Wu.safeParse(e).success)),categories:Gu.categories,settingsSchema:Gu.settingsSchema,slots:Gu.slots.removeDefault().optional(),page:q({apiVersion:Y(1),entry:Ju,style:Yu,title:Ku(128,1).optional()}).optional(),widget:q({apiVersion:Y(1),entry:Ju,style:Yu}).optional(),desktop:q({apiVersion:Y(1),script:qu(`.js`),style:Yu}).optional(),web:q({apiVersion:Y(1),entry:Ju.optional(),style:Yu}).refine(({entry:e,style:t})=>e!==void 0||t!==void 0,`Expected a Web entry or style`).optional(),backend:q({apiVersion:Y(1),entry:Ju}).optional()}).refine(({page:e,widget:t,desktop:n,web:r,backend:i})=>!!(e||t||n||r||i),`Expected at least one page, widget, desktop, web, or backend entry`).refine(({page:e,widget:t,web:n,backend:r})=>!r||[e?.entry,t?.entry,n?.entry].every(e=>e===void 0||Xu(e)!==Xu(r.entry)),{path:[`backend`,`entry`],message:`A backend entry cannot also be a frontend entry`});function Qu({hasPage:e,hasWidget:t,hasDesktop:n,hasWeb:r,hasBackend:i}){if(e||t||i&&!n&&!r)return[`desktop`,`web`];let a=[];return n&&a.push(`desktop`),r&&a.push(`web`),a}let $u=Ru,ed=hc().nonnegative(),td=q({revision:ed,enabled:G(Bu).max(64).refine(e=>new Set(e).size===e.length,`Duplicate extension IDs`)}),{downloadUrl:nd,...rd}=Lu.shape,id=K({...rd,id:Bu,format:Y(`codexhost`),targets:G(Vu).min(1).max(2).refine(e=>new Set(e).size===e.length,`Duplicate targets`),apis:q({page:hc().positive().optional(),widget:hc().positive().optional(),desktop:hc().positive().optional(),web:hc().positive().optional(),backend:hc().positive().optional()}),downloadUrl:nd.refine(e=>e.startsWith(`https://`),`Expected HTTPS`)}).refine(({targets:e,apis:t})=>{let n=Qu({hasPage:!!t.page,hasWidget:!!t.widget,hasDesktop:!!t.desktop,hasWeb:!!t.web,hasBackend:!!t.backend});return e.length===n.length&&n.every(t=>e.includes(t))},`Catalog targets must match the declared APIs`);K({schemaVersion:Y(2),generatedAt:H().min(1),extensions:G(id).max(1e4).refine(e=>new Set(e.map(({id:e})=>e)).size===e.length,`Duplicate extension IDs`)}).extend({catalogUrl:Su,fetchedAt:bs(),cached:W()});let ad={id:Bu},od={...ad,activationId:Uu,digest:Hu},sd={...ad,activationId:od.activationId.optional()},cd=H().min(1).max(4096).refine(e=>/^(?:\/|[a-z]:[/\\])/iu.test(e)&&!e.includes(`\0`)&&!e.split(/[/\\]/u).some(e=>e===`.`||e===`..`),`Expected an absolute local path without dot segments`),ld=H().min(1).max(256).refine(e=>e.split(`/`).every(e=>e&&/^[a-z0-9_.-]+$/iu.test(e)&&e!==`.`&&e!==`..`),`Invalid GitHub ref`);function ud(e){return H().max(4*Math.ceil(e/3)).refine(t=>{let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`);return t.length%4==0&&t.length*3/4-n<=e&&/^[A-Za-z0-9+/]*={0,2}$/u.test(t)},`Expected bounded standard padded base64`)}let dd=q({type:Y(`github`),repository:H().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),ref:ld.optional(),tag:ld.optional(),asset:H().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),subpath:Wu.optional()}).refine(({ref:e,tag:t,asset:n})=>!e||!t&&!n,`Use either a zipball ref or a release tag/asset`),fd=Ec([q({type:Y(`catalog`),...ad}),dd,q({type:Y(`zip`),base64:ud(67108864).min(4)}),q({type:Y(`zip`),localZipPath:cd}),q({type:Y(`localDir`),localDir:cd})]),pd=Oc(`type`,[q({type:Y(`catalog`),...ad}),dd,q({type:Y(`zip`)}),q({type:Y(`localDir`)})]),md=q({...od,manifest:Zu,installedAt:bs(),source:pd.optional()}),hd=e=>H().max(23+4*Math.ceil(e/3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u),gd={desktopConflictWith:Bu.optional()},_d=J([`none`,`inactive`,`starting`,`running`,`failed`]),vd=Oc(`state`,[md.extend({state:Y(`valid`),enabled:W(),...gd,iconDataUrl:hd(131072).optional(),screenshotDataUrls:G(hd(524288)).max(4).optional(),backendState:_d.optional(),backendError:H().optional()}),q({state:J([`invalid`,`incompatible`]),id:H().min(1),enabled:W(),error:H()})]);q({revision:ed,configuration:td,diagnostics:G(H()),extensions:G(vd)}),q({revision:ed,extensions:G(md.extend({...gd,settingsRevision:ed})).max(64)});let yd={list:`codexhost/extensions/list`,snapshot:`codexhost/extensions/snapshot`,catalog:`codexhost/extensions/catalog`,install:`codexhost/extensions/install`,update:`codexhost/extensions/update`,enable:`codexhost/extensions/enable`,disable:`codexhost/extensions/disable`,uninstall:`codexhost/extensions/uninstall`,recover:`codexhost/extensions/recover`,asset:`codexhost/extensions/asset`,settingsGet:`codexhost/extensions/settings/get`,settingsSet:`codexhost/extensions/settings/set`,backendInvoke:`codexhost/extensions/backend/invoke`},bd=Object.freeze(Object.values(yd));new Set(bd),q({});let xd={expectedRevision:ed};q({...ad,...xd}),md.extend({replaced:W()}),Oc(`state`,[q({state:Y(`saved`),configuration:td}),q({state:Y(`revision-conflict`),revision:ed})]),q({...sd,digest:od.digest.optional(),path:Wu}),q({mimeType:H().min(1),base64:ud(16777216),digest:od.digest}),q({settingsRevision:ed,values:hl}),yd.list,yd.snapshot,yd.catalog,q({forceRefresh:W().optional()}),yd.install,q({source:fd}),yd.update,q({...ad,expectedDigest:od.digest,expectedActivationId:od.activationId.optional(),source:fd.optional()}),yd.enable,yd.disable,yd.uninstall,q({...ad,removeData:W().optional(),expectedDigest:od.digest.optional()}),q({...ad,removed:W()}),yd.recover,q({expectedRevision:xd.expectedRevision.optional()}),yd.asset,yd.settingsGet,q(sd),yd.settingsSet,q({...sd,expectedSettingsRevision:ed,values:hl}),yd.backendInvoke,q({...sd,method:$u,params:ml.optional()}),q({result:ml}),K({threadId:Cl}).strict(),K({confirmed:W()}).strict(),[...bd],K({sections:G(K({id:H().min(1),name:H().min(1),threads:G(hl)}).strict())}).strict(),K({threadId:H().min(1).max(1024),sectionId:H().min(1).max(1024).nullable()}).strict(),K({threadIds:G(H().min(1))}).strict(),K({threadId:H().min(1).max(1024),pinned:W()}).strict(),K({}).strict(),K({parents:Pc(H().min(1),H().min(1))}).strict(),K({prompt:H().max(16384).optional()}).strict(),K({projects:G(K({id:H(),name:H(),rootPaths:G(H())})),assignments:Pc(H(),H()),projectless:G(H()),pinned:G(H()),sectionProjects:Pc(H(),G(H())).optional()});let Sd=Pc(H(),bc()),Cd=K({epoch:H().uuid(),sequence:U().int().nonnegative()});Oc(`type`,[K({type:Y(`skills-changed`),cursor:Cd,cwd:H().optional()}),K({type:Y(`harness-inspection-changed`),cursor:Cd,harnessId:H().min(1)}),K({type:Y(`display-settings-changed`),cursor:Cd}),K({type:Y(`preferences-changed`),cursor:Cd,revision:U().int().nonnegative()}),K({type:Y(`extensions-changed`),cursor:Cd,revision:ed}),K({type:Y(`hello`),version:Y(1),cursor:Cd,reset:W()}),K({type:Y(`changed`),cursor:Cd,threadId:H().min(1),method:H().min(1)})]);let wd=Oc(`type`,[K({type:Y(`text`),id:H(),prompt:H(),secret:W().optional(),optional:W().optional()}),K({type:Y(`choice`),id:H(),prompt:H(),multiple:W(),allowOther:W(),optional:W().optional(),options:G(K({value:H(),label:H(),description:H().optional()}))})]),Td=Oc(`type`,[K({type:Y(`approval`),title:H(),description:H().optional(),subject:bc().optional(),actions:G(K({id:H(),label:H(),effect:H()}))}),K({type:Y(`question`),title:H().optional(),questions:G(wd)})]),Ed=K({requestId:Ec([H(),U().int()]),threadId:H(),kind:J([`approval`,`question`]),interaction:Td,request:Sd}),Dd=K({id:H().min(1),clientUserMessageId:H().min(1),input:G(Sd),presentationInput:G(Sd).nullable().optional()}).passthrough();K({fields:G(K({path:G(Ec([H(),U().int().nonnegative()])),originalLength:U().int().nonnegative()}))});let Od=K({id:H().min(1),status:H().min(1),codexhostTurnOutcome:K({status:Y(`unknown`),reason:H()}).optional(),items:G(K({id:H().min(1),type:H().min(1)}).passthrough()),codexhostFileOperations:G(K({beforeItemId:H().nullable(),item:K({id:H().min(1),type:H().min(1)}).passthrough()})).optional(),error:K({message:H().optional()}).passthrough().nullable().optional(),fingerprint:H().min(1).optional(),unchanged:Y(!0).optional()}).passthrough(),kd=K({id:H().min(1).max(512),fingerprint:H().min(1).max(128)});K({threadId:H().min(1),knownTurns:G(kd).max(64).optional(),truncateToolOutput:W().optional()});let Ad=K({harnessId:H().min(1),nativeSessionId:H().min(1)});K({cursor:Cd,activeTurnId:H().min(1).nullable().optional(),command:K({name:H().min(1),turn:Od,subsequentTurnId:H().min(1).optional()}).optional(),thread:K({id:H().min(1),cwd:H(),modelProvider:H().min(1),createdAt:U(),updatedAt:U(),status:K({type:H()}).passthrough(),name:H().nullable().optional(),preview:H().optional(),codexhostImportSource:Ad.optional(),turns:G(Od).length(0)}).passthrough(),turnsPage:K({data:G(Od).max(5),nextCursor:H().nullable()}),configuration:K({native:K({model:H().min(1).max(1024).optional(),reasoningEffort:H().min(1).max(128).optional()}).optional(),effectiveModel:Gl.optional(),effectiveThinkingOptionId:ql.optional(),effectivePermissionModeId:El.optional()}),queue:K({items:G(Dd),pausedReason:J([`interrupted`,`outcome-unknown`,`failed`]).nullable()}).optional(),interactions:G(Ed)}),K({version:Y(1),owner:Y(`service`).optional(),pid:U().int().positive(),port:U().int().min(1).max(65535),token:H().regex(/^[0-9a-f]{64}$/u),startedAt:U(),epoch:H().uuid()}),K({epoch:H().uuid(),threadId:H().min(1),requestId:Ec([H(),U().int()]),result:Sd}),K({includeArchived:W().optional(),officialCursor:K({live:H().nullable(),archived:H().nullable().optional()}).strict().optional(),scope:K({cwd:H().min(1).max(4096),excludeCwds:G(H().min(1).max(4096)).max(1024)}).strict().optional()}).strict(),K({threads:G(hl),ownership:G(iu),archivedThreadIds:G(Cl),officialCursor:K({live:H().nullable(),archived:H().nullable().optional()}).strict().optional()}).strict();let jd=J([`running`,`waiting`,`idle`,`unknown`]),Md=q({harnessId:Sl,title:H().optional(),status:jd,archived:W()}),Nd=q({revision:hc().nonnegative(),parents:Pc(Cl,Cl),nodes:Pc(Cl,Md),truncated:W()}).refine(e=>Object.keys(e.nodes).length<=5e3,`Too many Thread tree nodes`).refine(({parents:e,nodes:t})=>Object.entries(e).every(([e,n])=>Object.hasOwn(t,e)&&Object.hasOwn(t,n)),`Missing Thread tree node`),Pd=H().min(1).max(128);q({});let Fd=q({subscriptionId:Pd});q({}),Fd.extend({snapshot:Nd});let Id=H().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);K({available:W()}).strict(),K({path:H().min(1),mimeType:Id}).strict();let Ld=J([`credentials-unavailable`,`login-expired`,`rate-limited`,`service-rejected`,`host-incompatible`,`network`,`timeout`,`audio-empty`,`audio-too-large`,`audio-format`,`audio-invalid`]);Oc(`ok`,[K({ok:Y(!0),text:H()}).strict(),K({ok:Y(!1),error:K({code:Ld}).strict()}).strict()]),K({threadId:Cl.optional(),cwd:H().min(1).optional()}).strict().refine(e=>!(e.threadId&&e.cwd),{message:`Specify threadId or cwd, not both`});let Rd=K({name:H().min(1).regex(/^[^\s[\]]+$/u),description:H().optional(),path:H().min(1),scope:J([`project`,`global`]),source:H().min(1)}).strict();K({revision:U().int().nonnegative(),complete:W(),skills:G(Rd),warnings:G(H()).optional()}).strict(),K({cwd:H().min(1).optional()}).strict();let zd=K({kind:J([`public`,`relay`,`tailscale-funnel`,`tailscale-https`,`tailscale`,`lan`,`virtual`]),url:H().min(1)}).strict(),Bd=Oc(`status`,[K({status:Y(`not-installed`)}),K({status:Y(`not-running`)}),K({status:Y(`not-logged-in`)}),K({status:Y(`https-disabled`)}),K({status:Y(`not-serving`),command:H()}),K({status:Y(`occupied`),target:H()}),K({status:Y(`serving`),url:H(),funnel:W()}),K({status:Y(`error`),message:H()})]);K({state:Bd,error:H().optional()}).strict();let Vd=Oc(`status`,[K({status:Y(`on`)}),K({status:Y(`off`)}),K({status:Y(`invalid`),reason:H()})]),Hd=K({lan:W(),autostart:Vd}).strict(),Ud=K({expiresAt:H().optional(),issuing:W(),failure:K({detail:H().optional(),retryAt:H(),paused:W()}).optional()}),Wd=Oc(`status`,[K({status:Y(`off`),reason:J([`invite`,`name-taken`,`banned`]).optional()}),K({status:Y(`connecting`),reason:J([`full`,`unreachable`]).optional()}),K({status:Y(`connected`),url:H(),certificate:Ud}),K({status:Y(`missing-certificate`),url:H(),certificate:Ud}),K({status:Y(`stopped`),reason:J([`replaced`,`rejected`,`unsupported-version`])})]);H().max(253).regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/i).transform(e=>e.toLowerCase()),H().regex(/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)?$/);let Gd=J([`official`,`self-hosted`]);K({secret:H().min(1),lastUsedAt:U().nullable(),networkUrls:G(zd),directCandidates:G(zd).optional(),tailscale:Bd,background:Hd.optional(),relay:K({state:Wd,enabled:W(),kind:Gd,officialHost:H(),customHost:H().optional(),officialHostname:H().optional(),customHostname:H().optional(),quotaUntil:H().optional()}).strict().optional()}).strict();let Kd=q({threadId:H().min(1).max(1024),view:J([`result`,`messages`]),from:U().int().min(1).max(2**53-1).optional(),to:U().int().min(1).max(2**53-1).optional()}),qd=K({id:H().min(1).max(256),harnessId:H().min(1),label:H().min(1).max(512),provider:J([`openai-codex`,`xai`])}).strict(),Jd=H().regex(/^[a-z][a-z0-9-]{0,47}$/),Yd=K({name:Jd,source:qd,importedAt:H()}).strict(),Xd=Oc(`action`,[K({action:Y(`list`)}).strict(),K({action:Y(`import`),sourceId:H().min(1).max(256),name:Jd,confirmed:Y(!0)}).strict(),K({action:Y(`reimport`),sourceId:H().min(1).max(256),name:Jd,confirmed:Y(!0)}).strict(),K({action:Y(`remove`),name:Jd,confirmed:Y(!0)}).strict()]),Zd=K({provider:H().min(1).max(128),type:J([`oauth`,`api_key`,`unknown`]),label:H().min(1).max(512).optional(),vendor:J([`openai-codex`,`xai`]).optional()}).strict();K({sources:G(qd),targets:G(K({harnessId:H(),providers:G(J([`openai-codex`,`xai`])),imports:G(Yd),others:G(Zd).default([])}).strict())}).strict(),K({targetHarnessId:H().min(1).max(128).optional(),request:Xd}).strict(),K({events:W()});let Qd=G(q({agent:H().min(1).max(128),section:J([`main`,`more`,`auto`])})).max(256).refine(e=>new Set(e.map(e=>e.agent)).size===e.length,`Duplicate Harness IDs`);q({entries:Qd.nullable()}),q({}),q({entries:Qd,initializeOnly:W().optional()});let $d=q({enabled:W(),timeoutMinutes:U().int().min(5).max(1440)});Object.freeze({enabled:!0,timeoutMinutes:10});let ef=H().regex(/^external$/u),tf=Sl.transform(e=>String(e)),nf=q({model:Gl.optional(),thinkingOptionId:ql.optional(),permissionModeId:El.optional()}).refine(e=>!!(e.model||e.thinkingOptionId||e.permissionModeId),`A default configuration must contain a preference`),rf=q({lastHarness:Sl.optional(),byHarness:Pc(tf,nf)}),af=q({model:Gl.optional(),thinkingOptionId:ql.optional()}).refine(e=>!!(e.model||e.thinkingOptionId),`A delegation default must contain a Model or Thinking option`),of=q({byHarness:Pc(tf,af)}),sf=H().min(1).max(1024),cf=q({idleRelease:$d.optional(),favorites:Pc(tf,G(sf).max(2048)).default({}),newThread:rf.optional(),delegation:of.optional()});q({scope:ef,revision:U().int().nonnegative(),values:cf}),q({scope:ef.default(`external`)});let lf=Oc(`kind`,[q({kind:Y(`idleRelease`),value:$d}),q({kind:Y(`favorite`),harnessId:Sl,modelId:sf,enabled:W()}),q({kind:Y(`favorites`),harnessId:Sl,modelIds:G(sf).max(2048)}),q({kind:Y(`newThread`),lastHarness:Sl.optional(),harnessId:Sl.optional(),configuration:nf.optional()}),q({kind:Y(`delegation`),harnessId:Sl,configuration:af.nullable()})]);q({scope:ef.default(`external`),operations:G(lf).min(1).max(256),initializeOnly:W().optional(),expectedRevision:U().int().nonnegative().optional()}).superRefine((e,t)=>{for(let n of e.operations)n.kind===`newThread`&&(!n.lastHarness&&!n.configuration||!!n.harnessId!=!!n.configuration)&&t.addIssue({code:`custom`,message:`A default Harness or complete configuration is required`})}),q({version:Y(1),revision:U().int().nonnegative(),scopes:Pc(ef,cf)});let uf=U().finite().nonnegative(),df=q({input:uf,output:uf,cacheRead:uf.optional(),cacheWrite:uf.optional(),cacheWrite1h:uf.optional()}),ff=H().max(512).refine(e=>e.trim()===e&&e.length>0,`Model ID is required`);q({path:H(),entries:G(q({key:H(),price:df})),error:H().nullable()}),q({}),q({key:ff,price:df.nullable(),previousKey:ff.optional()}),q({model:ff});let pf=q({official:W().optional(),canonicalModelId:H().min(1).optional(),provider:H().min(1).max(512),model:H().min(1).max(512),price:df});q({price:df.nullable(),suggestions:G(pf).max(6).optional()});let mf=[`today`,`7d`,`30d`,`90d`,`all`],hf=U().int().min(0).max(2**53-1),gf=H().regex(/^\d{4}-\d{2}-\d{2}$/u),_f=H().min(1).max(128),vf=H().min(1).max(512),yf=H().min(1).max(4096);q({range:J(mf),timeZone:H().min(1).max(128).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Unsupported usage statistics timezone`).optional(),harness:_f.optional(),model:vf.nullable().optional(),project:yf.nullable().optional(),date:gf.optional()});let bf=q({requests:hf,inputTokens:hf,cachedInputTokens:hf,cacheWriteInputTokens:hf,cacheKnownInputTokens:hf,cacheHitCachedInputTokens:hf,cacheHitInputTokens:hf,outputTokens:hf,reasoningOutputTokens:hf,costUsd:U().finite().min(0),unpricedRequests:hf,unmeteredRequests:hf}),xf=bf.shape,Sf=q({harness:_f,sessionId:H().min(1).max(512),project:yf.nullable(),title:H().min(1).max(200).optional(),models:G(vf).max(16),firstAtMs:hf,lastAtMs:hf,...xf});q({range:J(mf),from:gf.nullable(),to:gf,filters:q({harness:_f.nullable(),model:vf.nullable(),unknownModel:W(),project:yf.nullable(),unknownProject:W(),date:gf.nullable()}),reading:q({complete:W(),sources:hf,read:hf}),failures:G(q({harness:_f,message:H().max(2048)})).max(256),options:q({harnesses:G(_f).max(256),models:G(vf.nullable()).max(4096),projects:G(yf.nullable()).max(4096)}),modelLabels:G(q({harness:_f,model:vf,label:vf})).max(4096).optional(),credits:G(q({harness:_f,model:vf.nullable(),credits:U().finite().min(0),reportedRequests:hf,requests:hf})).max(4096).optional(),totals:bf,daily:G(q({date:gf,harness:_f,...xf})).max(2e5),hourly:G(q({weekday:U().int().min(0).max(6),hour:U().int().min(0).max(23),...xf})).max(168),byHarness:G(q({harness:_f,...xf})).max(256),byModel:G(q({model:vf.nullable(),...xf,harnessPricedRequests:hf})).max(4096),byProject:G(q({project:yf.nullable(),...xf})).max(4096),sessions:G(Sf).max(100),recentSessions:G(Sf).max(100).optional()}),K({threadId:Cl}),K({discarded:W()});let Cf=Oc(`type`,[K({id:H().min(1),type:Y(`choice`),prompt:H(),options:G(K({value:H().min(1),label:H(),description:H().optional()})).min(1),multiple:W(),allowOther:W(),optional:W()}),K({id:H().min(1),type:Y(`text`),prompt:H(),multiline:W(),secret:Y(!1),optional:W(),placeholder:H().optional(),prefill:H().optional()})]),wf=K({interactionId:H().min(1),turnId:H().min(1),title:H().optional(),questions:G(Cf).min(1)}).refine(({questions:e})=>e.some(e=>e.type===`choice`&&e.multiple),{message:`Shared cards require at least one multi-select question`});q({threadId:H().min(1)}),K({questions:G(wf)}),q({threadId:H().min(1),turnId:H().min(1),interactionId:H().min(1),answers:Pc(H(),G(H())),cancelled:W().default(!1)}),K({accepted:Y(!0)});let Tf=K({path:H(),oldText:H().nullable(),newText:H()});K({sessionId:H().min(1),turn:U().int().nonnegative(),path:H().min(1).optional()}),K({diffs:G(Tf)}),q({}),q({}),K({reference:K({sessionId:H().min(1),epoch:H().min(1),turn:U().int().nonnegative(),seq:U().int().nonnegative(),callId:H().min(1),part:U().int().nonnegative(),version:H().min(1)}),length:U().int().nonnegative(),bytes:U().int().nonnegative()}),q({title:H().trim().min(1).max(200),type:J([`info`,`warning`,`danger`]),body:H().trim().min(1).max(16384)}),q({}),q({url:H().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)}),Object.freeze(/* @__PURE__ */ `codexhost/console/remote-connections.codexhost/runtime/status.codexhost/remote/ssh-setup.codexhost/harness/plugins/list.codexhost/harness/display-settings/capabilities.codexhost/harness/display-settings/get.codexhost/harness/display-settings/set.codexhost/harness/inspect.codexhost/harness/installation.codexhost/harness/installation/start.codexhost/harness/installation/status.codexhost/harness/launch-settings/get.codexhost/harness/launch-settings/set.codexhost/harness/web-ui/open.codexhost/harness/accounts/sources.codexhost/harness/accounts/list.codexhost/harness/accounts/inspect.codexhost/harness/credential-imports.codexhost/harness/session-import/sources.codexhost/harness/session-import/list.codexhost/harness/session-import/import.codexhost/account/list.codexhost/account/refresh.codexhost/account/usage/inspect.codexhost/usage/model-prices/get.codexhost/usage/model-prices/set.codexhost/usage/model-prices/default.codexhost/usage/statistics/get.codexhost/update/check.codexhost/update/start.codexhost/update/status`.split(`.`));let Ef=J([`idle`,`running`,`busy`,`closing`,`failed`,`blocked`]),Df=J([`none`,`disabled`,`timeout`,`operation`,`background`,`identity`,`persistence`,`closeFailed`]);q({threadId:H(),title:H(),harnessId:H(),state:Ef,reason:Df,inactiveMs:U().nonnegative()}),q({threadId:Cl,turnId:wl});let Of=K({email:H().trim().min(1).max(320).optional(),label:H().trim().min(1).max(256).optional(),plan:H().trim().min(1).max(128).optional(),credits:Bl.optional(),balance:Vl.optional()}).strict();function kf(e){return e.refine(e=>{let t=e;return t.credits!==void 0||t.balance!==void 0},{message:`Account must report either credits or a balance`})}let Af=kf(Of),jf={harnessId:Sl,harnessName:H().trim().min(1).max(128)},Mf=K(jf).strict();K({}).strict(),K({sources:G(Mf).max(128)}).strict(),K({harnessId:Sl,refresh:W().optional()}).strict(),K({...jf,account:Af.nullable(),accounts:G(Af).max(8).optional()}).strict(),K({refresh:W().optional()}).strict(),K({accounts:G(kf(Of.extend(jf))).max(128)}).strict(),K({harnessId:su,model:Gl.optional(),thinkingOptionId:ql.optional(),permissionModeId:El.optional(),prewarm:Y(!0).optional()}).strict();let Nf=H().trim().min(1).max(4096).refine(e=>!/[\u0000\r\n]/u.test(e),`Invalid entrypoint path`);K({harnessId:su}).strict().extend({path:Nf.nullable()}),K({path:Nf.nullable(),restartRequired:W()}).strict(),K({harnessId:Sl,action:J([`check`,`update`,`install`]),confirmedVersion:H().min(1).max(128).optional()}).strict().refine(({action:e,confirmedVersion:t})=>e===`update`||t===void 0);let Pf=K({currentVersion:H().min(1).max(128),latestVersion:H().min(1).max(128),updateAvailable:W(),canUpdate:W(),latestVerifiedVersion:H().min(1).max(128).optional(),confirmationRequired:Y(!0).optional(),versionKind:J([`cli`,`application`]).optional(),manualUpdateUrl:Zs().max(2048).refine(e=>/^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(e),`Manual updates require a credential-free HTTPS URL`).optional(),message:H().max(2048).optional(),messageCode:H().min(1).max(128).optional(),notice:bl.optional(),latestVersionKind:J([`unknown`,`tracking-branch`]).optional()}).strict();K({taskId:H().uuid()}).strict(),Oc(`status`,[K({taskId:H().uuid(),status:Y(`running`)}).strict(),K({taskId:H().uuid(),status:Y(`succeeded`),result:Pf}).strict(),K({taskId:H().uuid(),status:Y(`failed`),error:K({code:U().int(),message:H().min(1).max(2048)}).strict()}).strict()]);let Ff=H().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u),If=H().trim().min(1),Lf=J([`free`,`go`,`plus`,`pro`,`prolite`,`team`,`self_serve_business_prolite`,`self_serve_business_usage_based`,`business`,`ent26`,`enterprise_cbp_automation`,`enterprise_cbp_usage_based`,`enterprise`,`edu`,`edu_plus`,`edu_pro`,`unknown`]),Rf=K({accountId:Ff,label:If.max(256),email:H().email().max(320).optional(),planType:Lf.optional()}).strict(),zf=J([`ready`,`unavailable`]);K({version:Y(2),currentAccountId:Ff.nullable(),phase:zf,revision:U().int().nonnegative(),instanceId:If.max(1024).optional(),accounts:G(Rf).max(1)}).strict(),K({accountId:Ff,refresh:W().optional()}).strict(),K({accountId:Ff,usage:Pl.nullable(),accountCredits:Bl.optional(),freshness:J([`live`,`cached`]),observedAt:H().datetime().nullable()}).strict();let Bf=1e3,Vf=H().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Hf=Vf.max(1024),Uf=K({nativeSessionId:Hf,title:Vf.max(4096).nullable(),updatedAt:U().int().nonnegative().max(864e13),cwd:Vf.max(16384),running:W().nullable()}).strict();K({}).strict(),K({harnesses:G(K({harnessId:su,name:Vf.max(128)}).strict()).max(128)}).strict(),K({harnessId:su,query:H().trim().max(4096).refine(e=>!e.includes(`\0`)).optional(),offset:U().int().nonnegative().safe().optional(),limit:U().int().min(1).max(Bf).optional()}).strict(),K({candidates:G(Uf).max(Bf),total:U().int().nonnegative().safe()}).strict(),K({harnessId:su,nativeSessionId:Hf}).strict(),K({threadId:Vf.max(1024).pipe(Cl)}).strict();let Wf=H().refine(e=>e.trim().length>0,`Value must not be empty or whitespace`).refine(e=>!e.includes(`\0`),`Value must not contain NUL`),Gf=Hf,Kf=Uf;K({}).strict(),K({candidates:G(Kf).max(1e3)}).strict(),K({nativeSessionId:Gf}).strict(),K({threadId:Wf.max(1024).pipe(Cl)}).strict(),K({threadId:Cl,lastTurnId:wl}).strict(),K({threadId:Cl}).strict();let qf=H().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();K({commands:G(K({id:qf,invocation:H().min(1).max(128),label:H().trim().min(1).max(128),description:H().trim().min(1).max(512).optional(),localizations:yl.optional(),argumentMode:J([`none`,`text`]),kind:J([`command`,`skill`]).optional()}).strict()),warnings:G(H().min(1)).optional(),source:J([`live`,`static`]).optional()}).strict().superRefine((e,t)=>{let n=/* @__PURE__ */ new Set;for(let[r,i]of e.commands.entries())n.has(i.id)&&t.addIssue({code:`custom`,message:`Harness command IDs must be unique`,path:[`commands`,r,`id`]}),n.add(i.id)}),K({harnessId:Sl,cwd:H().min(1).optional()}).strict(),K({threadId:Cl}).strict(),K({threadId:Cl,commandId:qf,turnId:wl.optional(),arguments:hl.optional()}).strict(),K({accepted:Y(!0),turnId:wl.optional()}).strict();let Jf=Y(`2.0`).optional(),Yf=Sc().optional(),Xf=H().min(1),Zf=Ec([H(),U().int()]),Qf=K({code:U().int(),message:H(),data:ml.optional()}).catchall(ml).superRefine(ll([`data`]));Ec([K({jsonrpc:Jf,id:Zf,method:Xf,params:ml.optional(),result:Yf,error:Yf}).catchall(ml).superRefine(ll([`jsonrpc`,`params`,`result`,`error`])),K({jsonrpc:Jf,id:Yf,method:Xf,params:ml.optional(),result:Yf,error:Yf}).catchall(ml).superRefine(ll([`jsonrpc`,`id`,`params`,`result`,`error`])),K({jsonrpc:Jf,id:Zf,method:Yf,params:Yf,result:ml,error:Yf}).catchall(ml).superRefine(ll([`jsonrpc`,`method`,`params`,`error`])),K({jsonrpc:Jf,id:Zf,method:Yf,params:Yf,result:Yf,error:Qf}).catchall(ml).superRefine(ll([`jsonrpc`,`method`,`params`,`result`]))]);let $f=H().refine(e=>e.trim().length>0,{message:`Native identifier must not be empty or whitespace`});q({harnessId:Sl,nativeSessionId:$f,locator:ml.optional(),formatVersion:Y(1)}).superRefine(ll([`locator`])),q({harnessId:Sl,nativeSessionId:$f,nativeTurnKey:$f,formatVersion:Y(1)}),q({harnessId:Sl,nativeSessionId:$f,checkpointId:$f,locator:ml.optional(),formatVersion:Y(1)}).superRefine(ll([`locator`]));let ep=H().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u),tp=J([`npm`,`windows-installer`,`macos-dmg`,`linux-archive`]),np=q({version:ep,installation:tp,phase:J([`prepared`,`downloading`,`waiting-for-exit`,`installing`,`restarting`,`succeeded`,`failed`]),updatedAt:U().int().nonnegative(),downloadedBytes:U().int().nonnegative().optional(),totalBytes:U().int().positive().optional(),error:H().min(1).max(500).nullable(),serviceStopOutput:H().optional()}).superRefine((e,t)=>{e.downloadedBytes!==void 0&&e.totalBytes!==void 0&&e.downloadedBytes>e.totalBytes&&t.addIssue({code:`custom`,path:[`downloadedBytes`],message:`downloadedBytes must not exceed totalBytes`})});q({});let rp=H().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u,`release notes URL must identify a codexhost GitHub Release`);q({currentVersion:ep,installation:tp.nullable(),latestVersion:ep.nullable(),updateAvailable:W(),installationAvailable:W(),releaseNotes:H().min(1).max(2e4).nullable(),releaseNotesUrl:rp.nullable(),status:np.nullable(),error:H().min(1).max(500).nullable()}),q({status:np}),q({status:np.nullable()});let ip=q({icon:H().min(1).max(16).optional(),title:H().min(1).max(120),body:H().min(1).max(1200),contributors:G(H().min(1).max(39)).max(30)}),ap=q({summary:H().min(1).max(600).optional(),themes:G(ip).min(1).max(12)}),op=q({version:ep,publishedAt:bs(),url:H().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),zh:ap.nullable(),en:ap.nullable()}).refine(e=>e.zh!==null||e.en!==null,{message:`an announcement needs at least one language`});q({manual:W().optional()}),q({announcement:op.nullable(),unread:W()}),q({version:ep}),RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): `+`(${[`completed`,`failed`,`interrupted`,`needsInput`,`timedOut`,`unreadable`,`notFound`].join(`|`)})(?:\. (.+))?$`,`u`);let sp=J([`idle`,`installing`,`restarting`,`succeeded`,`failed`]);K({runningVersion:H().nullable(),installedVersion:H().nullable(),restartRequired:W(),remote:W(),updateSupported:W(),update:K({phase:sp,targetVersion:H().nullable(),error:H().nullable()})});let cp=K({version:H().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)}).strict();K({hostname:H().min(1).max(1024).refine(e=>!e.startsWith(`-`)&&!/\s/u.test(e)),port:U().int().min(1).max(65535).nullable(),identity:H().max(4096).nullable(),action:J([`inspect`,`install`,`update`,`repair`,`uninstall`]),uninstallPackage:W().optional(),version:H().regex(/^\d+\.\d+\.\d+$/u).nullable()}).strict(),K({state:J([`installed`,`not-installed`])}).strict();let X=H().min(1).max(1024),lp={hostId:X.regex(/^(?:remote-(?:ssh(?:-|:)|control:)|remote-peer:[a-zA-Z0-9_-]{1,64}$)/u)},up={...lp,threadId:X},dp=H().min(1).max(8e3),fp={text:dp,requestId:X};Oc(`accepted`,[K({accepted:Y(!0),startQueuedItemId:X.optional()}),K({accepted:Y(!1),code:J([`remote/queue-unavailable`,`remote/steer-unavailable`,`remote/turn-changed`,`remote/send-rejected`,`session/queue-item-not-found`,`session/queue-item-starting`]),message:H()})]),Oc(`available`,[K({available:Y(!1)}),K({available:Y(!0),items:G(K({id:X,clientUserMessageId:X,preview:H().max(801)})).max(100)})]);let pp=Oc(`kind`,[q({kind:Y(`hosts`)}),q({kind:Y(`create`),...lp,cwd:H().min(1).max(8192),epoch:X}),q({kind:Y(`projectHarnesses`),...lp,epoch:X}),q({kind:Y(`inspectHarness`),...lp,epoch:X,cwd:H().min(1).max(8192),harnessId:X}),q({kind:Y(`startSelected`),...lp,epoch:X,cwd:H().min(1).max(8192),harnessId:X,model:H().min(1).max(4096),serviceTier:J([`priority`,`ultrafast`]).optional(),reasoningEffort:X.optional()}),q({kind:Y(`status`),...up}),q({kind:Y(`list`),...lp,cursor:H().nullable(),archived:W(),includeLoaded:Y(!0).optional()}),q({kind:Y(`read`),...up,page:q({cursor:H().min(1).max(8192).nullable(),epoch:X.optional(),sortDirection:J([`asc`,`desc`]).optional(),limit:U().int().min(1).max(20).optional()}).refine(e=>e.cursor===null||e.epoch!==void 0,{message:`A history continuation requires its connection epoch`}).optional()}),q({kind:Y(`usage`),...up,epoch:X}),q({kind:Y(`configure`),...up,epoch:X,modelId:X.optional(),serviceTier:Wl.optional(),thinkingOptionId:X.optional(),permissionModeId:X.optional()}).refine(e=>[e.modelId,e.thinkingOptionId,e.permissionModeId].filter(e=>e!==void 0).length===1,`Select exactly one remote setting`).refine(e=>e.serviceTier===void 0||e.modelId!==void 0,{message:`A service tier requires a Model ID`}),q({kind:Y(`prompt`),...up,epoch:X,text:dp,requestId:X.optional()}),q({kind:Y(`queue`),...up,epoch:X}),q({kind:Y(`delivery`),...up,epoch:X,action:Oc(`kind`,[q({kind:Y(`enqueue`),...fp}),q({kind:Y(`steer`),...fp,turnId:X}),q({kind:Y(`remove`),itemId:X}),q({kind:Y(`start`),itemId:X,onlyIfHead:Y(!0).optional()})])}),q({kind:Y(`interrupt`),...up,epoch:X,turnId:X}),q({kind:Y(`rename`),...up,epoch:X,name:H().min(1).max(512)}),q({kind:Y(`archive`),...up,epoch:X,archived:W()}),q({kind:Y(`respond`),...up,epoch:X,requestId:Ec([X,U().int()]),result:Pc(H(),bc())})]),mp=H().min(1).max(1024),hp=K({hostId:mp,displayName:H().min(1).max(1024),source:J([`codex-managed`,`discovered`]),sshAlias:H().max(1024).nullable(),sshHost:H().min(1).max(1024),sshPort:U().int().min(1).max(65535).nullable(),identity:H().max(4096).nullable(),autoConnect:W(),connectionAnalyticsId:H().max(1024).optional()}),gp=q({displayName:H().min(1).max(1024),hostname:H().min(1).max(1024),sshPort:U().int().min(1).max(65535).nullable(),identity:H().max(4096).nullable()});Oc(`action`,[q({action:Y(`session`),operation:pp}),q({action:Y(`list`)}),q({action:Y(`catalog`)}),q({action:Y(`read-thread`),hostId:mp.refine(e=>e!==`local`),input:Kd}),q({action:Y(`save`),draft:gp,previous:hp.nullable()}),q({action:Y(`remove`),previous:hp}),q({action:Y(`connect`),hostId:mp,enabled:W()}),q({action:Y(`state`),hostId:mp}),q({action:Y(`runtime`),hostId:mp}),q({action:Y(`update`),hostId:mp.refine(e=>e!==`local`),version:cp.shape.version})]),Ec([q({result:ml}),q({error:q({code:U().int(),message:H()})})]),q({prompt:H().trim().min(1).max(2e3),cwd:H().max(4096).nullable()}),H().trim().min(1).max(60).nullable();let _p=H().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u),vp=Ec([H(),K({en:H()}).catchall(H())]),yp=K({title:vp.optional(),description:vp.optional(),icon:H().max(349592).regex(/^data:image\/(?:svg\+xml|png|jpeg|webp);base64,[A-Za-z0-9+/]*={0,2}$/u).optional(),error:H().optional()});K({extensions:G(K({id:_p,name:H().min(1).max(214),version:H().min(1).max(128),format:Y(`dsh`),supportedTargets:Mc([Y(`web`)]),enabledTargets:G(Y(`web`)).max(1),source:H().min(1).max(4096),projectUrl:H().max(4096).url({protocol:/^https?$/u}).optional(),installedAt:H(),meta:yp.optional(),loadError:H().optional()})),loadedIds:G(_p),safeMode:W(),storeError:H().optional()});let bp=H().trim().max(2048).url({protocol:/^https?$/u,normalize:!0}).refine(e=>!/[\s\\?#]/u.test(e)&&!e.split(`/`)[2]?.includes(`@`),`Use an HTTP(S) registry URL without credentials, a query, or a fragment.`).transform(e=>e.endsWith(`/`)?e:`${e}/`);K({spec:H().trim().min(1).max(4096),registry:bp.optional()}).strict(),K({id:_p,enabled:W()}).strict(),K({id:_p}).strict();let xp=H().regex(/^[a-zA-Z0-9_-]{1,64}$/u),Sp=H().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u),Cp=J([`relay`,`tailscale`,`lan`,`custom`]),wp=[`blue`,`purple`,`cyan`,`green`,`amber`,`rose`,`slate`],Tp=J(wp),Ep=new Set(wp);function Dp(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return wp[(t>>>0)%wp.length]??wp[0]}function Op(e,t){return typeof t==`string`&&Ep.has(t)?t:Dp(e)}let kp=J([`connected`,`connecting`,`auth-error`,`offline`,`disabled`]);K({peers:G(K({peerId:xp,hostId:Sp,name:H().min(1).max(120),color:Tp.optional(),origin:H().min(1).max(2048),transportKind:Cp,encrypted:W(),enabled:W(),state:kp,latencyMs:U().int().nonnegative().optional(),version:H().max(128).optional(),platform:H().max(64).optional(),hostname:H().max(255).optional(),homeDir:H().max(4096).optional(),lastError:H().max(1e3).optional(),projectCount:U().int().nonnegative(),createdAt:H(),updatedAt:H()}))}),K({connectionUrl:H().min(1).max(4096).optional(),origin:H().min(1).max(2048).optional(),token:H().min(1).max(2048).optional(),name:H().trim().min(1).max(120).optional(),color:Tp.optional()}).refine(e=>!!e.connectionUrl||!!e.origin&&!!e.token,`Provide either connectionUrl or both origin and token`),K({peerId:xp,name:H().trim().min(1).max(120).optional(),color:Tp.nullable().optional(),connectionUrl:H().min(1).max(4096).optional(),origin:H().min(1).max(2048).optional(),token:H().min(1).max(2048).optional(),enabled:W().optional()}),K({peerId:xp}),K({removed:W()}),K({peerId:xp.optional(),connectionUrl:H().min(1).max(4096).optional(),origin:H().min(1).max(2048).optional(),token:H().min(1).max(2048).optional()}).refine(e=>!!e.peerId||!!e.connectionUrl||!!e.origin&&!!e.token,`Provide peerId, connectionUrl, or both origin and token`);let Ap=K({id:H().min(1).max(1024),name:H().min(1).max(512),path:H().min(1).max(8192)});K({ok:W(),latencyMs:U().int().nonnegative().optional(),origin:H().max(2048).optional(),transportKind:Cp.optional(),encrypted:W().optional(),version:H().max(128).optional(),platform:H().max(64).optional(),hostname:H().max(255).optional(),homeDir:H().max(4096).optional(),projectCount:U().int().nonnegative().optional(),projects:G(Ap).optional(),error:H().max(1e3).optional()});let jp=K({id:H().min(1).max(1024),name:H().min(1).max(512),path:H().min(1).max(8192),threadIds:G(H().min(1).max(1024))}),Mp=K({attachments:Y(1).optional(),workspaceFiles:Y(1).optional(),officePreview:Y(1).optional()}),Np=K({version:H().max(128),platform:H().max(64),hostname:H().max(255),homeDir:H().max(4096).optional(),epoch:H().min(1).max(256),projects:G(jp),capabilities:Mp.optional()});q({threadId:H().min(1).max(1024),scope:H().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u).optional(),requestId:H().min(1).max(256).optional(),mode:J([`queue`,`steer`]).optional(),expectedTurnId:H().min(1).max(1024).nullable().optional(),content:G(Oc(`type`,[q({type:Y(`text`),text:H()}),q({type:Y(`file`),receiptId:H().min(1).max(128)})])).min(1).max(64)});let Pp=K({ok:Y(!1),error:K({code:H(),message:H(),details:Pc(H(),bc()).optional()})});Ec([K({ok:Y(!0),value:K({receiptId:H().min(1),file:K({attachmentId:H(),name:H(),bytes:U().int().nonnegative()})})}),Pp]),Ec([K({ok:Y(!0),value:K({accepted:Y(!0)})}),Pp]);let Fp=K({name:H().min(1).max(512),path:H().min(1).max(8192),kind:Y(`directory`)});K({peerId:xp,path:H().min(1).max(8192).optional()}),K({path:H().min(1).max(8192),parentPath:H().min(1).max(8192).nullable(),homeDir:H().min(1).max(8192).optional(),entries:G(Fp)}),K({peerId:xp,parentPath:H().min(1).max(8192),name:H().min(1).max(255).refine(e=>e.trim().length>0,`Directory name cannot be blank`)}),K({path:H().min(1).max(8192),name:H().min(1).max(255)}),K({peerId:xp,path:H().min(1).max(8192),title:H().trim().min(1).max(255).optional()}),K({peerId:xp,workspaceId:H().min(1).max(1024),title:H().trim().min(1).max(255)}),K({peerId:xp,workspaceId:H().min(1).max(1024)}),K({workspaceId:H().min(1).max(1024).optional(),manifest:Np}),Y(1);function Ip({host:e,variant:t=`workspace`,t:n}){let r=e?.displayName??n(`host.local`),i=e?.state===`connected`?n(`host.connected`):e?.state===`connecting`?n(`host.connecting`):n(`host.disconnected`),a=e?`${r} · ${i}`:r,s=e===void 0?void 0:Op(e.hostId,e.color);return/* @__PURE__ */ (0,o.jsxs)(`span`,{className:R(P.hostBadge,t===`session`&&P.hostBadgeSession),"data-host-id":e?.hostId??`local`,"data-state":e?.state??`local`,"data-color":s,role:`img`,"aria-label":a,title:a,children:[e!==void 0&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.hostDot,"aria-hidden":`true`}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.hostLabel,children:r})]})}let Lp=`@deepseek-ai/dsh-client-ui-workspace/ThreadTreeControls.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Lp)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Lp,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 Rp={branch:`jGgv6G_branch`,children:`jGgv6G_children`,summary:`jGgv6G_summary`};function zp(e){return[{state:`running`,count:e.running},{state:`pending`,count:e.pendingInteraction},{state:`completed`,count:e.completed}]}function Bp(e){return e.pendingInteraction>0?`pending`:e.running>0?`running`:e.completed>0?`completed`:`idle`}function Vp(e,t,n){return[n(`threadTree.children`,{n:e}),...zp(t).filter(e=>e.count>0).map(e=>n(`threadTree.${e.state}`,{n:e.count}))].join(` · `)}function Hp({count:e,activity:t,t:n}){return/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[n(`threadTree.children`,{n:e}),zp(t).filter(e=>e.count>0).map(e=>/* @__PURE__ */ (0,o.jsx)(`span`,{"data-thread-tree-activity":e.state,children:` · ${n(`threadTree.${e.state}`,{n:e.count})}`},e.state))]})}let Up=`@deepseek-ai/dsh-client-ui-workspace/ThreadTreeRing.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Up)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Up,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 Wp={ring:`yY-O0a_ring`,spin:`yY-O0a_spin`};function Gp({activity:e}){return/* @__PURE__ */ (0,o.jsx)(`span`,{className:Wp.ring,"data-thread-ring":Bp(e),"aria-hidden":`true`,children:/* @__PURE__ */ (0,o.jsx)(`svg`,{viewBox:`0 0 22 22`,fill:`none`,children:/* @__PURE__ */ (0,o.jsx)(`circle`,{cx:`11`,cy:`11`,r:`10.25`})})})}let Kp=[{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 qp({style:e,t}){return/* @__PURE__ */ (0,o.jsx)(`div`,{className:qt.preview,"aria-hidden":`true`,children:Kp.map(({title:n,activity:r})=>/* @__PURE__ */ (0,o.jsx)(`div`,{className:Rp.branch,children:/* @__PURE__ */ (0,o.jsxs)(`div`,{className:`${P.sessionRow} ${qt.sampleRow}`,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:P.sessionMain,children:/* @__PURE__ */ (0,o.jsx)(un,{title:t(n),identity:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(`span`,{"data-harness-id":`codex`,className:qt.sampleIcon,children:/* @__PURE__ */ (0,o.jsx)(`img`,{src:`/harness-icons/codex`,width:14,height:14,alt:``})}),e===`ring`&&/* @__PURE__ */ (0,o.jsx)(Gp,{activity:r})]})})}),e===`summary`&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:`${Rp.summary} ${qt.sampleSummary}`,children:/* @__PURE__ */ (0,o.jsx)(Hp,{count:2,activity:r,t})})]})},n))})}function Jp({style:e,setStyle:t,onLater:n,onExit:r,t:i}){let a=(0,s.useId)(),[c,l]=(0,s.useState)(e),u=(0,s.useRef)(null),d=(0,s.useRef)(r);d.current=r,(0,s.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}=Yt(t);return/* @__PURE__ */ (0,o.jsxs)(`div`,{ref:u,className:qt.prompt,"data-thread-style-prompt":!0,role:`region`,"aria-labelledby":a,children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:qt.promptHeading,children:[/* @__PURE__ */ (0,o.jsx)(`strong`,{id:a,children:i(`threadTree.style.promptTitle`)}),/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:qt.later,disabled:f,onClick:n,children:i(`threadTree.style.later`)})]}),/* @__PURE__ */ (0,o.jsx)(`p`,{className:qt.hint,children:i(`threadTree.style.hint`)}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:qt.comparison,role:`radiogroup`,"aria-labelledby":a,"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`?Jt[e.key===`Home`?0:1]:Jt[+(c===`summary`)];e.currentTarget.querySelector(`[data-thread-style-choice="${t}"]`)?.focus()},children:Jt.map(t=>/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,role:`radio`,className:qt.choice,"data-thread-style-choice":t,"aria-disabled":f,"aria-checked":e===t,"aria-labelledby":`${a}-${t}`,"aria-describedby":`${a}-${t}-description`,tabIndex:c===t?0:-1,onFocus:()=>l(t),onClick:()=>void m(t),children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:qt.choiceTitle,id:`${a}-${t}`,children:i(`threadTree.style.${t}`)}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:qt.choiceSubtitle,id:`${a}-${t}-description`,children:i(`threadTree.style.${t}Subtitle`)}),/* @__PURE__ */ (0,o.jsx)(qp,{style:t,t:i})]},t))}),p&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:qt.error,role:`alert`,children:i(`threadTree.style.error`)})]})}let Yp=(0,s.createContext)(void 0),Xp=()=>(0,s.useContext)(Yp);function Zp({roots:e,children:t}){return e.map(e=>/* @__PURE__ */ (0,o.jsx)(Qp,{node:e,renderRow:t},e.id))}function Qp({node:e,renderRow:t}){let n=(0,s.useId)(),{expansion:r,stylePrompt:i,dismissStylePrompt:a,collapseStyle:c,setCollapseStyle:l,t:u}=cn(),d=r[e.id]===!0,f=e.tree?.depth??0,p=e.tree?.children??[];return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Rp.branch,"data-thread-branch":!0,children:[/* @__PURE__ */ (0,o.jsx)(Yp.Provider,{value:n,children:t(e)}),d&&i===n&&/* @__PURE__ */ (0,o.jsx)(Jp,{style:c,setStyle:l,onLater:a,onExit:()=>document.querySelector(`[data-thread-icon-toggle][aria-controls="${CSS.escape(n)}"]`)?.focus({preventScroll:!0}),t:u}),p.length>0&&/* @__PURE__ */ (0,o.jsx)(`div`,{id:n,role:`group`,hidden:!d,"data-thread-guide":d&&f<3?``:void 0,className:Rp.children,style:{"--dsh-thread-guide-indent":`${Math.min(f,3)*24}px`},children:d&&/* @__PURE__ */ (0,o.jsx)(Zp,{roots:p,children:t})})]})}function $p({node:e,title:t,toggle:n,t:r}){let i=Xp(),a=(0,s.useRef)(null);(0,s.useLayoutEffect)(()=>{let e=a.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=Vp(c.descendantCount,c.activity,r);return/* @__PURE__ */ (0,o.jsx)(`button`,{ref:a,type:`button`,"data-thread-summary":!0,className:Rp.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,o.jsx)(Hp,{count:c.descendantCount,activity:c.activity,t:r})})}function em(e,t){return e.blank?t(`session.new`):e.title||t(`session.untitled`)}function tm(e,t,n){let{unit:r,n:i}=(0,a.relativeTime)(e,t);return r===`now`?n(`time.now`):n(`time.${r}`,{n:i})}function nm(e,t,n){let{unit:r,n:i}=(0,a.relativeTime)(e,t);return r===`now`?n(`time.now`):n(`time.ago`,{t:n(`time.${r}`,{n:i})})}function rm(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 im({label:e,cwd:t,createdAt:n,t:r}){return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:P.hoverContent,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:P.hoverTitle,children:e}),t!==void 0&&t!==``&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:P.hoverPath,children:t}),n!==void 0&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:P.hoverTime,children:rm(n,r)})]})}function am(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function om({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,s.useState)(!1),[_,v]=(0,s.useState)(null),y=[{id:`rename`,label:u(`rename`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconEditOutlineRegular,{})},{id:`delete`,label:u(`delete.workspace`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconTrashOutlineRegular,{}),danger:!0}],x=/* @__PURE__ */ (0,o.jsxs)(`div`,{className:R(P.projectRow,h&&P.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,o.jsx)(`span`,{className:R(P.slot,d.expanded&&P.folderExpanded),children:d.expanded?/* @__PURE__ */ (0,o.jsx)(a.IconFolderOpenRegular,{}):/* @__PURE__ */ (0,o.jsx)(a.IconFolderCloseRegular,{})}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.projectText,children:/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.title,children:m})}),d.workspaceId!==void 0&&d.remote&&/* @__PURE__ */ (0,o.jsx)(Ip,{host:d.remote,variant:`workspace`,t:u}),/* @__PURE__ */ (0,o.jsxs)(`span`,{className:P.rowActions,children:[f!==void 0&&/* @__PURE__ */ (0,o.jsx)(a.Menu,{open:h,onClose:()=>{g(!1)},items:y,onSelect:e=>{
10
131
  /* 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:_===null?void 0:()=>_,anchor:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:q.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,o.jsx)(a.IconEllipsisOutlineRegular,{})})}),(!d.remote||d.remote.state===`connected`&&!!e.cwd)&&/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:u(`actions.newSession`),shortcutKeys:l?.keys,side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:q.iconButton,"aria-keyshortcuts":l?.aria,"aria-label":u(`actions.newSession.aria`,{name:m}),onClick:e=>{e.stopPropagation(),n()},children:/* @__PURE__ */ (0,o.jsx)(a.IconNewChatOutlineRegular,{})})})]})]});return d.createdAt===void 0?x:/* @__PURE__ */ (0,o.jsx)(a.HoverCard,{anchor:x,content:/* @__PURE__ */ (0,o.jsx)(yn,{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 Sn({node:e,now:t,renderSlot:n,t:r}){let i=Be(e,r).filter(t=>!e.archived||t.state!==`done`&&t.state!==`idle`);return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:q.hoverContent,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:q.hoverTitle,children:hn(e,r)}),e.cwd&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:q.hoverPath,children:e.cwd}),!e.blank&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:q.hoverTime,children:_n(e.updatedAt,t,r)}),n(`sidebar.session.row.hover`,{sessionId:e.id}),i.map(e=>/* @__PURE__ */ (0,o.jsxs)(`div`,{className:q.hoverStatus,children:[/* @__PURE__ */ (0,o.jsx)(a.StateDot,{state:e.state}),/* @__PURE__ */ (0,o.jsx)(`span`,{children:e.label})]},e.label)),e.archived&&/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q(q.hoverStatus,q.hoverArchived),children:[/* @__PURE__ */ (0,o.jsx)(a.IconArchiveOutlineRegular,{size:16}),/* @__PURE__ */ (0,o.jsx)(`span`,{children:r(`row.archived`)})]})]})}function Cn({result:e,currentId:t,onOpen:n,onUnarchive:r,t:i}){let s=e.id===t,c=Be(e,i),l=c[0];return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q(q.searchResultRow,s&&q.selected,e.archived&&q.archived),role:`treeitem`,"aria-selected":s,"aria-description":e.archived?i(`toast.archivedNotOpenable`):void 0,onClick:()=>{n(e.id)},children:[/* @__PURE__ */ (0,o.jsxs)(`span`,{className:q.searchResultHeading,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.slot}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.searchResultTitle,children:e.title||i(`session.untitled`)}),e.remote&&/* @__PURE__ */ (0,o.jsx)(Xt,{host:e.remote,t:i}),!e.archived&&l.state!==`idle`&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.timeStatus,"data-session-status":l.state,children:/* @__PURE__ */ (0,o.jsx)(He,{statuses:c})}),e.archived&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.rowActions,children:/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:i(`actions.unarchive`),side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:q.iconButton,"aria-label":i(`menu.unarchiveSession`),onClick:t=>{t.stopPropagation(),r(e.id)},children:/* @__PURE__ */ (0,o.jsx)(a.IconUnarchiveOutlineRegular,{size:16})})})})]}),/* @__PURE__ */ (0,o.jsxs)(`span`,{className:q.searchResultMeta,children:[/* @__PURE__ */ (0,o.jsxs)(`span`,{className:q.searchResultWorkspace,children:[e.workspace||i(`group.ungrouped`),e.parentTitle!==void 0&&` · ${e.parentTitle||i(`session.untitled`)}`]}),e.snippet!==void 0&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.searchResultSnippet,children:e.snippet})]})]})}function wn({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,markCompletionsRead:_,collapseStyle:v}=qt(),y=dn(),b=e.tree?.depth??0,x=h[e.id]===!0,S=b===0?d:void 0,w=hn(e,p),T=e.id===n,E=Be(e,p),D=E[0],O=!m.archived&&D.state!==`idle`,k=S!==void 0&&!m.blank&&!m.archived,A=m.blank?void 0:m.reference,j=k||A!==void 0,M=(0,s.useRef)(!1),[N,P]=(0,s.useState)(!1),[ee,F]=(0,s.useState)(null),I=(0,s.useMemo)(()=>[N,P],[N]),te=(0,s.useRef)(null);(0,s.useEffect)(()=>{u!==void 0&&(te.current?.scrollIntoView({block:`nearest`}),u())},[u]);let L=/* @__PURE__ */ (0,o.jsxs)(`div`,{ref:te,"data-row-key":t,"data-thread-parent":e.tree?.parentId??void 0,"data-thread-depth":b,"data-thread-sortable":String(k),"data-thread-pinned":String(e.pinned),style:{"--dsh-thread-indent":`${Math.min(b,3)*24}px`},className:Q(q.sessionRow,T&&q.selected,N&&q.menuOpen,m.archived&&q.archived,S?.marker===`before`&&q.dropBefore,S?.marker===`after`&&q.dropAfter),role:`treeitem`,"aria-selected":T,"aria-current":T?`page`:void 0,"aria-level":b+1,"aria-expanded":e.tree?.descendantCount?x:void 0,tabIndex:-1,onContextMenu:e=>{m.blank||e.target.closest(`button`)||(e.preventDefault(),F(new DOMRect(e.clientX,e.clientY,0,0)),P(!0))},onKeyDown:t=>{t.target!==t.currentTarget||m.blank||(M.current=!1,t.key===`ContextMenu`||t.shiftKey&&t.key===`F10`?(t.preventDefault(),F(null),P(!0)):t.key===`F2`&&!m.archived&&(t.preventDefault(),c(e.id,m.title)))},"aria-description":m.archived?p(`toast.archivedNotOpenable`):void 0,onPointerDown:()=>{M.current=!1},onClick:()=>{M.current||(T&&!m.archived&&e.tree?.descendantCount?(x&&_(e.tree.descendantIds),g(e.id,!x,y)):i(e.id))},draggable:j,onDragStart:j?t=>{M.current=!0,t.dataTransfer.effectAllowed=A===void 0?`move`:k?`copyMove`:`copy`,t.dataTransfer.setData(`text/plain`,A===void 0?e.id:C(A).clipboardText),A!==void 0&&t.dataTransfer.setData(`application/x-codexhost-thread-reference`,JSON.stringify(A)),k&&S?.start()}:void 0,onDragEnd:j?e=>S?.end(e.dataTransfer.dropEffect===`copy`):void 0,onDragOver:S===void 0?void 0:e=>{S.active&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,S.hover(bn(e)))},onDrop:S===void 0?void 0:e=>{S.active&&(e.preventDefault(),S.drop(bn(e)))},children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:q.sessionMain,children:/* @__PURE__ */ (0,o.jsxs)(Yt,{identityLabel:e.tree?.descendantCount?!x&&v===`ring`?p(`threadTree.expandSummary`,{title:w,summary:tn(e.tree.descendantCount,e.tree.activity,p)}):p(x?`threadTree.collapse`:`threadTree.expand`,{n:e.tree.descendantCount}):void 0,identityExpanded:e.tree?.descendantCount?x:void 0,identityControls:y,identity:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[l(`sidebar.session.row.identity`,{sessionId:e.id}),!x&&v===`ring`&&!!e.tree?.descendantCount&&/* @__PURE__ */ (0,o.jsx)(on,{activity:e.tree.activity})]}),ambient:!m.archived&&!m.blank&&!O&&l(`sidebar.session.row.leading`,{sessionId:e.id}),title:w,onIdentityClick:e.tree?.descendantCount?t=>{t.stopPropagation(),g(e.id,!x,y)}:void 0,children:[f&&m.remote&&/* @__PURE__ */ (0,o.jsx)(Xt,{host:m.remote,t:p}),/* @__PURE__ */ (0,o.jsxs)(`span`,{className:q.trailing,children:[!m.blank&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q(q.time,O&&q.timeStatus),"data-session-status":O?D.state:void 0,children:O?/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(He,{statuses:E}),D.trailingLabel!==void 0&&/* @__PURE__ */ (0,o.jsx)(`span`,{"aria-hidden":`true`,children:D.trailingLabel})]}):gn(m.updatedAt,r,p)}),!m.blank&&/* @__PURE__ */ (0,o.jsxs)(`span`,{className:q.rowActions,onClick:e=>{e.stopPropagation()},children:[/* @__PURE__ */ (0,o.jsx)(a.Menu,{open:N,onClose:()=>{P(!1)},portal:!0,autoFocus:!0,phoneSidebarTitle:w,phoneSidebarFooterBackLabel:p(`session.backToList`),phoneSidebarDetails:/* @__PURE__ */ (0,o.jsx)(`div`,{className:q.phoneDetails,children:/* @__PURE__ */ (0,o.jsx)(Sn,{node:e,now:r,renderSlot:l,t:p})}),getAnchorRect:ee===null?void 0:()=>ee,anchor:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:q.iconButton,"aria-label":p(`actions.session.aria`,{name:w}),"aria-haspopup":`menu`,"aria-expanded":N,onClick:()=>{F(null),P(e=>!e)},children:/* @__PURE__ */ (0,o.jsx)(a.IconEllipsisOutlineRegular,{})}),children:l(`sidebar.workspaces.session.menu.item`,{sessionId:e.id,displayTitle:m.title,threadTreeChild:b>0},{hookContext:I})}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:q.quickActions,children:l(`sidebar.workspaces.session.row.action`,{sessionId:e.id,displayTitle:m.title,threadTreeChild:b>0})})]})]})]})}),!x&&v===`summary`&&/* @__PURE__ */ (0,o.jsx)(mn,{node:e,title:w,toggle:()=>g(e.id,!0,y),t:p})]});return/* @__PURE__ */ (0,o.jsx)(a.HoverCard,{anchor:L,content:/* @__PURE__ */ (0,o.jsx)(Sn,{node:e,now:r,renderSlot:l,t:p}),openDelayMs:800,disabled:N||S?.active===!0,copyText:m.blank||m.title===``?void 0:m.title,copyLabel:p(`copy`),copiedLabel:p(`hover.copied`)})}let Tn=`@deepseek-ai/dsh-client-ui-workspace/AnimatedRows.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Tn)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Tn,e.textContent=`.Jek-Ha_exits{contain:strict;pointer-events:none;position:absolute;inset:0;overflow:clip}`,document.head.appendChild(e)}var En={exits:`Jek-Ha_exits`};function Dn(e){return[...e.querySelectorAll(`[data-row-key]`)].filter(e=>e.offsetHeight>0&&!e.closest(`[inert]`))}function On(e){if(!e)return;let t=Dn(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 kn(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=Dn(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??``,i=t.startsWith(`linked:`)?t.slice(0,t.indexOf(`:`,7)+1):t.startsWith(`recent:`)?`recent:`:`session:`;c=r.find(t=>t.dataset.rowKey===`${i}${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`}),On(t))}function An(e,t){return e.rowKeys.length===t.rowKeys.length&&e.rowKeys.every((e,n)=>e===t.rowKeys[n])}function jn(e,t){return e.bottom>t.top&&e.top<t.bottom&&e.right>t.left&&e.left<t.right}var Mn=class extends s.Component{armed=!1;list=(0,s.createRef)();overlay=(0,s.createRef)();movements=/* @__PURE__ */ new Map;exits=/* @__PURE__ */ new Map;componentDidMount(){On(this.list.current)}getSnapshotBeforeUpdate(e){let t=this.list.current;if(!this.armed||An(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)||!jn(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(On(this.list.current),n===null){(!An(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(!jn(t.rect,a)&&(r===void 0||!jn(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,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(`div`,{ref:this.list,className:this.props.className,role:`tree`,"aria-label":this.props.label,onKeyDown:kn,onFocusCapture:()=>On(this.list.current),onPointerDownCapture:()=>{this.armed=!0},onKeyDownCapture:()=>{this.armed=!0},children:this.props.children}),/* @__PURE__ */ (0,o.jsx)(`div`,{ref:this.overlay,className:En.exits,"aria-hidden":`true`})]})}};let Nn=`@deepseek-ai/dsh-client-ui-workspace/SectionHeading.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Nn)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Nn,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 Pn={action:`Z54rEq_action`,chevron:`Z54rEq_chevron`,collapsed:`Z54rEq_collapsed`,heading:`Z54rEq_heading`,title:`Z54rEq_title`};function Fn({label:e,icon:t,expanded:n,onToggle:r,rowKey:i,action:s}){let c=n!==void 0&&r!==void 0&&i!==void 0,l=/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[t,/* @__PURE__ */ (0,o.jsx)(`span`,{className:Pn.title,children:e}),c&&/* @__PURE__ */ (0,o.jsx)(a.IconChevronDownOutlineRegular,{className:n?Pn.chevron:Pn.collapsed,size:12}),s!==void 0&&/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:s.label,portal:!0,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Pn.action,"aria-label":s.label,onClick:e=>{e.stopPropagation(),s.onActivate()},children:s.icon})})]});return c?/* @__PURE__ */ (0,o.jsx)(`div`,{className:Pn.heading,role:`treeitem`,tabIndex:-1,"data-row-key":i,"aria-label":e,"aria-expanded":n,onClick:r,children:l}):/* @__PURE__ */ (0,o.jsx)(`div`,{className:Pn.heading,children:l})}let In=`@deepseek-ai/dsh-client-ui-workspace/PinnedSection.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(In)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=In,e.textContent=`.t4p6JG_section{margin-bottom:8px}.t4p6JG_section>*+[data-thread-branch]{margin-top:2px}`,document.head.appendChild(e)}var Ln={section:`t4p6JG_section`};function Rn({rows:e,customSection:t,currentId:n,onOpen:r,onRenameRequest:i,renderSlot:s,t:c,revealSessionId:l,onSessionRevealed:u,expanded:d,onToggle:f}){if(e.length===0&&!t)return null;let p=t?.name??c(`section.pinned`);return/* @__PURE__ */ (0,o.jsxs)(`div`,{role:`group`,"aria-label":p,className:Ln.section,"data-sidebar-pinned":!t||void 0,children:[/* @__PURE__ */ (0,o.jsx)(Fn,{label:p,icon:t?void 0:/* @__PURE__ */ (0,o.jsx)(a.IconPinOutlineRegular,{size:14}),expanded:d,onToggle:f,rowKey:`section:${t?.key??`pinned`}`}),d&&/* @__PURE__ */ (0,o.jsx)(fn,{roots:e,children:e=>/* @__PURE__ */ (0,o.jsx)(wn,{node:e,currentId:n,now:Date.now(),onOpen:r,onRenameRequest:i,renderSlot:s,onReveal:e.id===l?()=>u(e.id):void 0,t:c},e.id)})]})}let zn=`@deepseek-ai/dsh-client-ui-workspace/WorkspaceBrowser.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(zn)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=zn,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,body[data-codexhost-wallpaper] ._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))}@media (hover:hover){._14DcuW_sessionOverflowButton:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}}._14DcuW_sessionOverflowButton:active{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_searchInput,._14DcuW_renameInput{font-size:16px}}._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 Bn({list:e,refreshSessions:t,loadMoreSessions:n,t:r}){return e.listError?/* @__PURE__ */ (0,o.jsxs)(`div`,{role:`alert`,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{children:e.listError}),/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:$.sessionOverflowButton,disabled:e.loading,onClick:e.listErrorPage===`more`?n:t,children:r(`sessions.retry`)})]}):null}function Vn(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 Hn(e,t,n){let r=e.filter((e,r)=>r<t||n.has(e.key));return{rows:r,hiddenCount:e.length-r.length}}function Un({rowKey:e,hiddenCount:t,hasMore:n,loading:r,expanded:i,expand:a,collapse:s,loadMoreSessions:c,t:l}){if(t===0&&!n&&!s)return null;let u=t===0&&n&&r;return/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,"data-row-key":e,className:$.sessionOverflowButton,"aria-expanded":i,disabled:u,onClick:()=>{t>0?a():n?(a(),c()):s?.()},children:u?l(`sessions.loading`):t>0?l(`sessions.expand`,{n:Math.min(10,t)}):l(n?`sessions.expandMore`:`sessions.collapse`)})}let Wn=`@deepseek-ai/dsh-client-ui-workspace/WorkspacePicker.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=`.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 Gn={menuStatus:`s4nt4G_menuStatus`,modalAction:`s4nt4G_modalAction`,modalError:`s4nt4G_modalError`};let Kn=`::add-workspace`,qn=`::no-workspace`;function Jn({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,s.useCallback)(()=>n?.current?.getBoundingClientRect()??null,[n]),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)(null),[w,T]=(0,s.useState)(!1),E=(0,a.usePhoneSidebar)(),D=(0,s.useRef)(!1),[O,k]=(0,s.useState)(!1),A=w||O;(0,s.useEffect)(()=>{m?.(A)},[A,m]);let j=c(e=>e);(0,s.useEffect)(()=>{w&&!j&&T(!1)},[w,j]);let M=j?[{id:Kn,label:e(`menu.addWorkspace`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconPlusOutlineRegular,{size:16}),disabled:A}]:[],N=!p&&v.length>0,P=d!==void 0&&!p,ee=P?[{id:qn,label:e(`menu.noWorkspace`),disabled:A}]:[],F=N?[...ee,...v.map(t=>({id:t.workspaceId,label:Wt(t.title,e(`workspace.defaultName`)),icon:/* @__PURE__ */ (0,o.jsx)(a.IconFolderCloseRegular,{size:16}),disabled:A}))]:[...ee,...M],I=F.length===0,te=()=>{x(!1),C(null)},L=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)}),ne=(0,s.useCallback)(()=>{D.current=E?.open===!0,f(),x(!1),C(null),T(!0)},[f,E?.open]),re=p||_.phase===`ready`,R=!P&&!N&&re&&M.length===1;(0,s.useEffect)(()=>{t&&R&&!A&&ne()},[t,R,A,ne]);let z={open:w,busy:O,onPicked:e=>{k(!0),L(e).finally(()=>{k(!1)})},onCancel:()=>{T(!1)},onError:e=>{T(!1),C(e),x(!0)}},ie=e=>{e===qn?d?.():e===Kn?ne():u(e)};return/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Menu,{open:t&&!R&&!I,anchor:null,items:F,...N?{footer:M}:{},selectedId:g??(P?qn:void 0),onSelect:ie,onClose:f,side:h,portal:!0,getAnchorRect:y}),t&&!R&&!I&&_.phase===`pending`&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Gn.menuStatus,role:`status`,children:e(`picker.loading`)}),l(z),/* @__PURE__ */ (0,o.jsx)(a.Modal,{phoneSidebar:!0,phoneSidebarOrigin:D.current,open:b,onClose:te,closeLabel:e(`close`),title:e(`folderError.title`),footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,className:Gn.modalAction,onClick:te,children:e(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`primary`,className:Gn.modalAction,disabled:!j,onClick:ne,children:e(`folderError.retry`)})]}),children:/* @__PURE__ */ (0,o.jsx)(`div`,{className:Gn.modalError,role:`alert`,children:S})})]})}function Yn({open:e,anchorRef:t,useWorkspaces:n,selectedId:r,onPick:i,onClose:a,createWorkspace:s,useDirectoryFlow:c,renderSlot:l,t:u}){let d=n(e=>e.canStartProjectless);return/* @__PURE__ */ (0,o.jsx)(Jn,{t:u,open:e,anchorRef:t,useWorkspaces:n,createWorkspace:s,useDirectoryFlow:c,renderDirectoryFlow:e=>l(`conversation.hero.workspace.directoryFlow`,e),selectedId:r,onPick:i,...d?{onPickNone:()=>i(null)}:{},onClose:a})}function Xn(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 Zn(e){(0,s.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 Qn({groupBy:e,orderBy:t,archivedFilter:n,onGroupPick:r,onOrderPick:i,onArchivedFilterPick:c,t:l}){let[u,d]=(0,s.useState)(!1),f=(0,s.useRef)(null),p=(0,a.usePhoneSidebar)(),{collapseStyle:m,setCollapseStyle:h}=qt(),{busy:g,failed:_,save:v}=Nt(h);return/* @__PURE__ */ (0,o.jsx)(a.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,o.jsx)(a.IconFolderCloseRegular,{})},{id:`workspace-tree`,label:l(`groupBy.workspaceTree`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconWorkspaceTreeOutlineRegular,{})},{id:`flat`,label:l(`groupBy.flat`),icon:/* @__PURE__ */ (0,o.jsx)(a.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,o.jsx)(a.IconChevronsUpDownOutlineRegular,{})},{id:`updated`,label:l(`orderBy.updated`),icon:/* @__PURE__ */ (0,o.jsx)(a.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,o.jsx)(a.IconArchiveOffOutlineRegular,{})},{id:`show-archived`,label:l(`viewOptions.showArchived`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconQueueOutlineRegular,{})},{id:`only-archived`,label:l(`viewOptions.onlyArchived`),icon:/* @__PURE__ */ (0,o.jsx)(a.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,a.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,o.jsx)(a.Tooltip,{label:l(`viewOptions.label`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,o.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,o.jsx)(a.IconSlidersTwoOutlineRegular,{})})}),children:_&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.error,role:`alert`,children:l(`threadTree.style.error`)})})}function $n(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 er(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function tr({rowState:e,onLeaveArchivedOnly:t,partial:n,t:r}){let i=e.archivedFilter===`only`;return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:$.emptyState,"data-row-key":`empty`,children:[i?/* @__PURE__ */ (0,o.jsx)(a.IconArchiveOutlineRegular,{size:24}):/* @__PURE__ */ (0,o.jsx)(a.IconQueueOutlineRegular,{size:24}),/* @__PURE__ */ (0,o.jsx)(`div`,{children:r(n?`sessions.notLoaded`:i?`empty.noneArchived`:`empty.none`)}),i&&/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:$.emptyAction,onClick:t,children:r(`empty.viewOthers`)})]})}function nr({list:e,useSessionStatus:t,startSession:n,open:r,workspaces:i,linkedRoots:c,ungroupedSessionIds:l,rowState:u,nativeSections:d,onLeaveArchivedOnly:f,workspaceReady:p,canStartProjectless:m,animationResetKey:h,usePanelInfo:g,onRenameRequest:_,onDeleteRequest:v,onSessionRenameRequest:y,renderSlot:b,insertWorkspaceBefore:x,nestWorkspaces:S,groupExpansion:C,setGroupExpanded:w,sectionExpansion:T,setSectionExpanded:D,setSessionOrder:O,home:k,t:A,revealSessionId:j,onSessionRevealed:M,shortcuts:N,loadMoreSessions:P}){let ee=qt(),F=(0,a.usePhoneSidebar)(),I=g(e=>e.activePanelId!==null),te=t(e=>e),L=I?void 0:Object.values(e.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,ne=(0,s.useMemo)(()=>i.map(e=>{let t=c.get(e.workspaceId);return t===void 0||t.size===0?e:{...e,sessionIds:e.sessionIds.filter(e=>!t.has(e))}}),[c,i]),re=j===void 0||!p?void 0:E(ne,ee.rootId(j)),[R,ie]=(0,s.useState)({}),[B,oe]=(0,s.useState)(null),V=(0,s.useRef)(!1),[H,de]=(0,s.useState)(null),fe=(0,s.useRef)(!1),pe=B!==null||H!==null;Zn(pe);let me=L===void 0||!p?void 0:E(ne,ee.rootId(L)),he=(0,s.useMemo)(()=>{if(!S)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=se(t.path,[...n?.keys()??[]]);return[t.workspaceId,r===void 0?void 0:n?.get(r)]}))},[S,i]),ge=(0,s.useMemo)(()=>{let e=new Set(he.values());return[...i.map(e=>e.workspaceId),``].filter(t=>C[t]??(t===``||e.has(t)))},[C,he,i]),U=(0,s.useMemo)(()=>{let t=z(e,i,u,te,{expandedGroups:ge,excludePinned:!0});return(m||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:ge.includes(``),containsCurrent:!1,sessions:[]}),t},[e,i,u,te,ge,m]),_e=Date.now(),ve=(e,t)=>{if(V.current)return;V.current=!0,oe(null);let n=U.find(t=>t.key===e.accountKey);if(n===void 0||t.id===e.sessionId)return;let r=e.accountKey===``?l:i.find(t=>t.workspaceId===e.accountKey)?.sessionIds;if(r===void 0)return;let a=Vn(n.sessions,R[n.key]??5,L,j).rows,o=$n(r,a,e,t);o!==void 0&&O(e.accountKey,o)},ye=(e,t)=>{if(fe.current||(fe.current=!0,de(null),!Ht(i,e.workspaceId,t.id)))return;let n=he.get(e.workspaceId),r=i.filter(e=>!e.remote&&he.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)&&x(e.workspaceId,o).catch(e=>{console.warn(`workspace reorder rejected:`,e)})},be=(0,s.useMemo)(()=>{let e=new Set(U.map(e=>e.key)),t=/* @__PURE__ */ new Map;for(let n of U){let r=he.get(n.key);for(;r!==void 0&&!e.has(r);)r=he.get(r);let i=t.get(r);i===void 0?t.set(r,[n]):i.push(n)}return t},[U,he]),W=be.get(void 0)??[],xe=W[0]?.workspaceId!==void 0&&H?.over?.id===W[0].workspaceId&&H.over.half===`before`,Se=(0,s.useMemo)(()=>{let e=/* @__PURE__ */ new Map,t=(n,r)=>{e.set(n.key,r);for(let e of be.get(n.key)??[])t(e,r)};for(let e of W)t(e,e.key);return e},[be,W]),Ce=(0,s.useMemo)(()=>{let e=/* @__PURE__ */ new Set;for(let t of[me,re]){let n=t===void 0?void 0:Se.get(t);n!==void 0&&n!==``&&e.add(n)}return e},[me,re,Se]),[we,G]=(0,s.useState)(!1),Te=W.filter(e=>e.key!==``),Ee=Hn(Te,5,Ce),De=we?Te:Ee.rows,Oe=ue(T,ce),ke=ir(d,e,u,te,T),K=ue(T,le),Ae=e=>{e.expanded&&ie(t=>({...t,[e.key]:5})),w(e.key,!e.expanded)},je=ae(e,u.pinnedSessionIds,u,te).filter(e=>e.pinned),Me=[];if(je.length>0&&(Me.push(`section:${ce}`),Oe))for(let e of ee.rows(je))Me.push(`session:${e.id}`);Me.push(...ar(ke,ee.rows)),U.length===0&&je.length===0&&d.length===0&&Me.push(`empty`);let Ne=(t,s)=>{let l=t.workspaceId,u=be.get(t.key)??[],d=H!==null&&Ht(i,H.workspaceId,l)&&he.get(H.workspaceId)===he.get(t.key),f=Vn(t.sessions,R[t.key]??5,L,j);Me.push(`workspace:${t.key}`);let p=t.expanded?u.map(e=>Ne(e,s+1)):[],h=ee.rows(f.rows),g=c.get(t.key),x=new Set(g===void 0?[]:f.rows.flatMap(e=>g.has(e.id)?[e.id,...e.tree?.descendantIds??[]]:[])),S=e=>l===void 0?`recent:${e}`:x.has(e)?`linked:${t.key}:${e}`:`session:${e}`;for(let e of h)Me.push(S(e.id));let C=t.expanded&&(f.hiddenCount>0||e.hasMore);C&&Me.push(`overflow:${t.key}`);let T=l!==void 0&&H?.over?.id===l?H.over.half:null,E=l===void 0||t.remote?void 0:{start:()=>{fe.current=!1,de({workspaceId:l,over:null})},end:()=>{H?.over!==null&&H?.over!==void 0?ye(H,H.over):de(null),fe.current=!1}},D=l===void 0||!d?void 0:e=>{de(t=>t===null?t:{...t,over:{id:l,half:e}})},O=l===void 0||!d?void 0:e=>{ye(H,{id:l,half:e})};return/* @__PURE__ */ (0,o.jsxs)(`div`,{"data-sidebar-group":t.key,style:{"--dsh-workspace-indent":`${s*12}px`},className:Q($.groupSection,T===`before`&&$.workspaceDropBefore,T===`after`&&$.workspaceDropAfter),onDragOver:H===null?void 0:e=>{e.preventDefault(),(D!==void 0||he.get(t.key)===void 0)&&(e.stopPropagation(),D===void 0?(e.dataTransfer.dropEffect=`none`,H.over!==null&&de({...H,over:null})):(e.dataTransfer.dropEffect=`move`,D(er(e))))},onDrop:H===null?void 0:e=>{e.preventDefault(),(O!==void 0||he.get(t.key)===void 0)&&(e.stopPropagation(),O===void 0?(fe.current=!0,de(null)):O(er(e)))},children:[l===void 0?/* @__PURE__ */ (0,o.jsx)(Fn,{label:A(`group.ungrouped`),expanded:t.expanded,onToggle:()=>{Ae(t)},rowKey:`workspace:${t.key}`,action:m?{label:A(`actions.newSession`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconNewChatOutlineRegular,{size:16}),onActivate:()=>{w(t.key,!0),F?.close(),n()}}:void 0}):/* @__PURE__ */ (0,o.jsx)(xn,{newShortcut:N.find(e=>e.id===`session.new`),group:t,home:k,t:A,onToggle:()=>{Ae(t)},onCreate:()=>{t.workspaceId!==void 0&&(w(t.key,t.expanded),F?.close(),n(t.workspaceId))},drag:E,actions:t.workspaceId===void 0?void 0:{rename:()=>{
132
+ g(!1),(e===`rename`||e===`delete`)&&(e===`rename`?f.rename():f.delete())},portal:!0,autoFocus:!0,getAnchorRect:_===null?void 0:()=>_,anchor:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:P.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,o.jsx)(a.IconEllipsisOutlineRegular,{})})}),(!d.remote||d.remote.state===`connected`&&!!e.cwd)&&/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:u(`actions.newSession`),shortcutKeys:l?.keys,side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:P.iconButton,"aria-keyshortcuts":l?.aria,"aria-label":u(`actions.newSession.aria`,{name:m}),onClick:e=>{e.stopPropagation(),n()},children:/* @__PURE__ */ (0,o.jsx)(a.IconNewChatOutlineRegular,{})})})]})]}),S=d.cwd!==void 0&&d.cwd!==``?d.cwd:void 0;return d.workspaceId===void 0||S===void 0&&d.createdAt===void 0?x:/* @__PURE__ */ (0,o.jsx)(a.HoverCard,{anchor:x,content:/* @__PURE__ */ (0,o.jsx)(im,{label:d.label,cwd:S===void 0?void 0:b(S,c),createdAt:d.createdAt,t:u}),openDelayMs:800,disabled:h,copyText:S,copyLabel:u(`copy`),copiedLabel:u(`hover.copied`)})}function sm({node:e,now:t,renderSlot:n,t:r}){let i=tt(e,r).filter(t=>!e.archived||t.state!==`done`&&t.state!==`idle`);return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:P.hoverContent,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:P.hoverTitle,children:em(e,r)}),e.cwd&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:P.hoverPath,children:e.cwd}),!e.blank&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:P.hoverTime,children:nm(e.updatedAt,t,r)}),n(`sidebar.session.row.hover`,{sessionId:e.id}),i.map(e=>/* @__PURE__ */ (0,o.jsxs)(`div`,{className:P.hoverStatus,children:[/* @__PURE__ */ (0,o.jsx)(a.StateDot,{state:e.state}),/* @__PURE__ */ (0,o.jsx)(`span`,{children:e.label})]},e.label)),e.archived&&/* @__PURE__ */ (0,o.jsxs)(`div`,{className:R(P.hoverStatus,P.hoverArchived),children:[/* @__PURE__ */ (0,o.jsx)(a.IconArchiveOutlineRegular,{size:16}),/* @__PURE__ */ (0,o.jsx)(`span`,{children:r(`row.archived`)})]})]})}function cm({result:e,currentId:t,onOpen:n,onUnarchive:r,t:i}){let s=e.id===t,c=tt(e,i),l=c[0];return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:R(P.searchResultRow,s&&P.selected,e.archived&&P.archived),role:`treeitem`,"aria-selected":s,"aria-description":e.archived?i(`toast.archivedNotOpenable`):void 0,onClick:()=>{n(e.id)},children:[/* @__PURE__ */ (0,o.jsxs)(`span`,{className:P.searchResultHeading,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.slot}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.searchResultTitle,children:e.title||i(`session.untitled`)}),e.remote&&/* @__PURE__ */ (0,o.jsx)(Ip,{host:e.remote,variant:`session`,t:i}),!e.archived&&l.state!==`idle`&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.timeStatus,"data-session-status":l.state,children:/* @__PURE__ */ (0,o.jsx)(rt,{statuses:c})}),e.archived&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.rowActions,children:/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:i(`actions.unarchive`),side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:P.iconButton,"aria-label":i(`menu.unarchiveSession`),onClick:t=>{t.stopPropagation(),r(e.id)},children:/* @__PURE__ */ (0,o.jsx)(a.IconUnarchiveOutlineRegular,{size:16})})})})]}),/* @__PURE__ */ (0,o.jsxs)(`span`,{className:P.searchResultMeta,children:[/* @__PURE__ */ (0,o.jsxs)(`span`,{className:P.searchResultWorkspace,children:[e.workspace||i(`group.ungrouped`),e.parentTitle!==void 0&&` · ${e.parentTitle||i(`session.untitled`)}`]}),e.snippet!==void 0&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.searchResultSnippet,children:e.snippet})]})]})}function lm({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,markCompletionsRead:_,collapseStyle:v}=cn(),y=Xp(),b=e.tree?.depth??0,x=h[e.id]===!0,S=b===0?d:void 0,C=em(e,p),w=e.id===n,te=tt(e,p),T=te[0],E=!m.archived&&T.state!==`idle`,D=S!==void 0&&!m.blank&&!m.archived,O=m.blank?void 0:m.reference,ne=D||O!==void 0,re=(0,s.useRef)(!1),[ie,ae]=(0,s.useState)(!1),[oe,se]=(0,s.useState)(null),k=(0,s.useMemo)(()=>[ie,ae],[ie]),ce=(0,s.useRef)(null);(0,s.useEffect)(()=>{u!==void 0&&(ce.current?.scrollIntoView({block:`nearest`}),u())},[u]);let le=/* @__PURE__ */ (0,o.jsxs)(`div`,{ref:ce,"data-row-key":t,"data-thread-parent":e.tree?.parentId??void 0,"data-thread-depth":b,"data-thread-sortable":String(D),"data-thread-pinned":String(e.pinned),style:{"--dsh-thread-indent":`${Math.min(b,3)*24}px`},className:R(P.sessionRow,w&&P.selected,ie&&P.menuOpen,m.archived&&P.archived,S?.marker===`before`&&P.dropBefore,S?.marker===`after`&&P.dropAfter),role:`treeitem`,"aria-selected":w,"aria-current":w?`page`:void 0,"aria-level":b+1,"aria-expanded":e.tree?.descendantCount?x:void 0,tabIndex:-1,onContextMenu:e=>{m.blank||e.target.closest(`button`)||(e.preventDefault(),se(new DOMRect(e.clientX,e.clientY,0,0)),ae(!0))},onKeyDown:t=>{t.target!==t.currentTarget||m.blank||(re.current=!1,t.key===`ContextMenu`||t.shiftKey&&t.key===`F10`?(t.preventDefault(),se(null),ae(!0)):t.key===`F2`&&!m.archived&&(t.preventDefault(),c(e.id,m.title)))},"aria-description":m.archived?p(`toast.archivedNotOpenable`):void 0,onPointerDown:()=>{re.current=!1},onClick:()=>{re.current||(w&&!m.archived&&e.tree?.descendantCount?(x&&_(e.tree.descendantIds),g(e.id,!x,y)):i(e.id))},draggable:ne,onDragStart:ne?t=>{re.current=!0,t.dataTransfer.effectAllowed=O===void 0?`move`:D?`copyMove`:`copy`,t.dataTransfer.setData(`text/plain`,O===void 0?e.id:ee(O).clipboardText),O!==void 0&&t.dataTransfer.setData(`application/x-codexhost-thread-reference`,JSON.stringify(O)),D&&S?.start()}:void 0,onDragEnd:ne?e=>S?.end(e.dataTransfer.dropEffect===`copy`):void 0,onDragOver:S===void 0?void 0:e=>{S.active&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,S.hover(am(e)))},onDrop:S===void 0?void 0:e=>{S.active&&(e.preventDefault(),S.drop(am(e)))},children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:P.sessionMain,children:/* @__PURE__ */ (0,o.jsxs)(un,{identityLabel:e.tree?.descendantCount?!x&&v===`ring`?p(`threadTree.expandSummary`,{title:C,summary:Vp(e.tree.descendantCount,e.tree.activity,p)}):p(x?`threadTree.collapse`:`threadTree.expand`,{n:e.tree.descendantCount}):void 0,identityExpanded:e.tree?.descendantCount?x:void 0,identityControls:y,identity:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[l(`sidebar.session.row.identity`,{sessionId:e.id}),!x&&v===`ring`&&!!e.tree?.descendantCount&&/* @__PURE__ */ (0,o.jsx)(Gp,{activity:e.tree.activity})]}),ambient:!m.archived&&!m.blank&&!E&&l(`sidebar.session.row.leading`,{sessionId:e.id}),title:C,onIdentityClick:e.tree?.descendantCount?t=>{t.stopPropagation(),g(e.id,!x,y)}:void 0,children:[f&&m.remote&&/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(Ip,{host:m.remote,variant:`session`,t:p}),!m.blank&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.hostTimeSep,"aria-hidden":`true`,children:`·`})]}),/* @__PURE__ */ (0,o.jsxs)(`span`,{className:P.trailing,children:[!m.blank&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:R(P.time,E&&P.timeStatus),"data-session-status":E?T.state:void 0,children:E?/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(rt,{statuses:te}),T.trailingLabel!==void 0&&/* @__PURE__ */ (0,o.jsx)(`span`,{"aria-hidden":`true`,children:T.trailingLabel})]}):tm(m.updatedAt,r,p)}),!m.blank&&/* @__PURE__ */ (0,o.jsxs)(`span`,{className:P.rowActions,onClick:e=>{e.stopPropagation()},children:[/* @__PURE__ */ (0,o.jsx)(a.Menu,{open:ie,onClose:()=>{ae(!1)},portal:!0,autoFocus:!0,phoneSidebarTitle:C,phoneSidebarFooterBackLabel:p(`session.backToList`),phoneSidebarDetails:/* @__PURE__ */ (0,o.jsx)(`div`,{className:P.phoneDetails,children:/* @__PURE__ */ (0,o.jsx)(sm,{node:e,now:r,renderSlot:l,t:p})}),getAnchorRect:oe===null?void 0:()=>oe,anchor:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:P.iconButton,"aria-label":p(`actions.session.aria`,{name:C}),"aria-haspopup":`menu`,"aria-expanded":ie,onClick:()=>{se(null),ae(e=>!e)},children:/* @__PURE__ */ (0,o.jsx)(a.IconEllipsisOutlineRegular,{})}),children:l(`sidebar.workspaces.session.menu.item`,{sessionId:e.id,displayTitle:m.title,threadTreeChild:b>0},{hookContext:k})}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:P.quickActions,children:l(`sidebar.workspaces.session.row.action`,{sessionId:e.id,displayTitle:m.title,threadTreeChild:b>0})})]})]})]})}),!x&&v===`summary`&&/* @__PURE__ */ (0,o.jsx)($p,{node:e,title:C,toggle:()=>g(e.id,!0,y),t:p})]});return/* @__PURE__ */ (0,o.jsx)(a.HoverCard,{anchor:le,content:/* @__PURE__ */ (0,o.jsx)(sm,{node:e,now:r,renderSlot:l,t:p}),openDelayMs:800,disabled:ie||S?.active===!0,copyText:m.blank||m.title===``?void 0:m.title,copyLabel:p(`copy`),copiedLabel:p(`hover.copied`)})}let um=`@deepseek-ai/dsh-client-ui-workspace/AnimatedRows.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(um)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=um,e.textContent=`.Jek-Ha_exits{contain:strict;pointer-events:none;position:absolute;inset:0;overflow:clip}`,document.head.appendChild(e)}var dm={exits:`Jek-Ha_exits`};function fm(e){return[...e.querySelectorAll(`[data-row-key]`)].filter(e=>e.offsetHeight>0&&!e.closest(`[inert]`))}function pm(e){if(!e)return;let t=fm(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 mm(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=fm(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??``,i=t.startsWith(`linked:`)?t.slice(0,t.indexOf(`:`,7)+1):t.startsWith(`recent:`)?`recent:`:`session:`;c=r.find(t=>t.dataset.rowKey===`${i}${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`}),pm(t))}function hm(e,t){return e.rowKeys.length===t.rowKeys.length&&e.rowKeys.every((e,n)=>e===t.rowKeys[n])}function gm(e,t){return e.bottom>t.top&&e.top<t.bottom&&e.right>t.left&&e.left<t.right}var _m=class extends s.Component{armed=!1;list=(0,s.createRef)();overlay=(0,s.createRef)();movements=/* @__PURE__ */ new Map;exits=/* @__PURE__ */ new Map;componentDidMount(){pm(this.list.current)}getSnapshotBeforeUpdate(e){let t=this.list.current;if(!this.armed||hm(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)||!gm(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(pm(this.list.current),n===null){(!hm(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(!gm(t.rect,a)&&(r===void 0||!gm(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,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(`div`,{ref:this.list,className:this.props.className,role:`tree`,"aria-label":this.props.label,onKeyDown:mm,onFocusCapture:()=>pm(this.list.current),onPointerDownCapture:()=>{this.armed=!0},onKeyDownCapture:()=>{this.armed=!0},children:this.props.children}),/* @__PURE__ */ (0,o.jsx)(`div`,{ref:this.overlay,className:dm.exits,"aria-hidden":`true`})]})}};let vm=`@deepseek-ai/dsh-client-ui-workspace/SectionHeading.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(vm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=vm,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_trailing{align-items:center;min-width:0;margin-inline-start:auto;display:inline-flex}.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_actionAfterTrailing{margin-inline-start:0}.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 ym={action:`Z54rEq_action`,actionAfterTrailing:`Z54rEq_actionAfterTrailing`,chevron:`Z54rEq_chevron`,collapsed:`Z54rEq_collapsed`,heading:`Z54rEq_heading`,title:`Z54rEq_title`,trailing:`Z54rEq_trailing`};function bm({label:e,icon:t,expanded:n,onToggle:r,rowKey:i,trailing:s,action:c}){let l=n!==void 0&&r!==void 0&&i!==void 0,u=/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[t,/* @__PURE__ */ (0,o.jsx)(`span`,{className:ym.title,children:e}),l&&/* @__PURE__ */ (0,o.jsx)(a.IconChevronDownOutlineRegular,{className:n?ym.chevron:ym.collapsed,size:12}),s!==void 0&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:ym.trailing,onClick:e=>{e.stopPropagation()},children:s}),c!==void 0&&/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:c.label,portal:!0,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:R(ym.action,s!==void 0&&ym.actionAfterTrailing),"aria-label":c.label,onClick:e=>{e.stopPropagation(),c.onActivate()},children:c.icon})})]});return l?/* @__PURE__ */ (0,o.jsx)(`div`,{className:ym.heading,role:`treeitem`,tabIndex:-1,"data-row-key":i,"aria-label":e,"aria-expanded":n,onClick:r,children:u}):/* @__PURE__ */ (0,o.jsx)(`div`,{className:ym.heading,children:u})}let xm=`@deepseek-ai/dsh-client-ui-workspace/PinnedSection.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(xm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=xm,e.textContent=`.t4p6JG_section{margin-bottom:8px}.t4p6JG_section>*+[data-thread-branch]{margin-top:2px}`,document.head.appendChild(e)}var Sm={section:`t4p6JG_section`};function Cm({rows:e,customSection:t,currentId:n,onOpen:r,onRenameRequest:i,renderSlot:s,t:c,revealSessionId:l,onSessionRevealed:u,expanded:d,onToggle:f,children:p}){if(e.length===0&&!t)return null;let m=t?.name??c(`section.pinned`);return/* @__PURE__ */ (0,o.jsxs)(`div`,{role:`group`,"aria-label":m,className:Sm.section,"data-sidebar-pinned":!t||void 0,children:[/* @__PURE__ */ (0,o.jsx)(bm,{label:m,icon:t?void 0:/* @__PURE__ */ (0,o.jsx)(a.IconPinOutlineRegular,{size:14}),expanded:d,onToggle:f,rowKey:`section:${t?.key??`pinned`}`}),d&&/* @__PURE__ */ (0,o.jsx)(Zp,{roots:e,children:e=>/* @__PURE__ */ (0,o.jsx)(lm,{node:e,currentId:n,now:Date.now(),onOpen:r,onRenameRequest:i,renderSlot:s,onReveal:e.id===l?()=>u(e.id):void 0,t:c},e.id)}),d&&p]})}let wm=`@deepseek-ai/dsh-client-ui-workspace/WorkspaceBrowser.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(wm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=wm,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]:not([data-tauri-shell]) ._14DcuW_fade,[data-phone-drawer] ._14DcuW_fade,body[data-codexhost-wallpaper] ._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))}@media (hover:hover){._14DcuW_sessionOverflowButton:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}}._14DcuW_sessionOverflowButton:active{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_searchInput,._14DcuW_renameInput{font-size:16px}}._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_filterEmptyHint{color:var(--dsw-alias-label-tertiary);flex-direction:column;align-items:flex-start;gap:4px;padding:10px 12px;font-size:12px;line-height:18px;display:flex}._14DcuW_filterEmptyHint ._14DcuW_emptyAction{font-size:12px;line-height:18px}._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 Z={archiveActivity:`_14DcuW_archiveActivity`,clearButton:`_14DcuW_clearButton`,deleteAction:`_14DcuW_deleteAction`,deleteStatus:`_14DcuW_deleteStatus`,empty:`_14DcuW_empty`,emptyAction:`_14DcuW_emptyAction`,emptyState:`_14DcuW_emptyState`,fade:`_14DcuW_fade`,filterEmptyHint:`_14DcuW_filterEmptyHint`,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 Tm({list:e,refreshSessions:t,loadMoreSessions:n,t:r}){return e.listError?/* @__PURE__ */ (0,o.jsxs)(`div`,{role:`alert`,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{children:e.listError}),/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Z.sessionOverflowButton,disabled:e.loading,onClick:()=>{e.listErrorPage===`more`?n(e.listErrorWorkspaceId??void 0):t()},children:r(`sessions.retry`)})]}):null}function Em(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 Dm(e,t,n){let r=e.filter((e,r)=>r<t||n.has(e.key));return{rows:r,hiddenCount:e.length-r.length}}function Om({rowKey:e,hiddenCount:t,hasMore:n,loading:r,expanded:i,expand:a,collapse:s,loadMoreSessions:c,t:l}){if(t===0&&!n&&!s)return null;let u=t===0&&n&&r;return/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,"data-row-key":e,className:Z.sessionOverflowButton,"aria-expanded":i,disabled:u,onClick:()=>{t>0?a():n?(a(),c()):s?.()},children:u?l(`sessions.loading`):t>0?l(`sessions.expand`,{n:Math.min(10,t)}):l(n?`sessions.expandMore`:`sessions.collapse`)})}let km=`codexhost.sidebar.hostScopeFilter.v1`,Am=`codexhost:apply-host-scope-workspace-selection`;function jm(e){return e.some(e=>e.remote!==void 0)}function Mm(e){return e.some(e=>e.remote?.hostId.startsWith(`remote-peer:`)===!0)}function Nm(e){let t=[],n=/* @__PURE__ */ new Map;for(let r of e){let e=r.remote;if(e===void 0){t.push(r);continue}let i=n.get(e.hostId);i===void 0?n.set(e.hostId,{key:e.hostId,hostId:e.hostId,displayName:e.displayName,state:e.state,...e.color===void 0?{}:{color:e.color},workspaceCount:1,workspaces:[r]}):(i.workspaces.push(r),i.workspaceCount+=1,i.color===void 0&&e.color!==void 0&&(i.color=e.color))}return t.length===0&&n.size===0?[]:[{key:`local`,workspaceCount:t.length,workspaces:t},...n.values()]}function Pm(e,t){return e.selectedHost===`all`||Nm(t).some(t=>t.key===e.selectedHost)?e:{...e,selectedHost:`all`}}function Fm(e,t,n){let r=Nm(t),i=new Map(r.map(e=>[e.key,e])),a=n?.preserveHostKeys,o=e.selectedHost!==`all`&&e.selectedHost!==`local`&&!i.has(e.selectedHost)?`all`:e.selectedHost,s=o!==e.selectedHost,c={};for(let[t,n]of Object.entries(e.perHost)){let e=i.get(t);if(e===void 0){if(t!==`local`){a?.has(t)===!0?c[t]=n:s=!0;continue}n.workspaceIds.length>0?(s=!0,c[t]={mode:n.mode,workspaceIds:[]}):c[t]=n;continue}if(t!==`local`&&(e.state===`connecting`||e.state!==`connected`&&a?.has(t)===!0)){c[t]=n;continue}let r=new Set(e.workspaces.map(e=>e.workspaceId)),o=n.workspaceIds.filter(e=>r.has(e));o.length===n.workspaceIds.length?c[t]=n:(s=!0,c[t]={mode:n.mode,workspaceIds:o})}return s?{selectedHost:o,perHost:c}:e}function Im(e,t){let n=Pm(e,t);return n.selectedHost!==`all`||Nm(t).some(e=>n.perHost[e.key]?.mode===`selected`)}function Lm(e,t){let n=Pm(t,e);return e.filter(e=>{let t=e.remote?.hostId??`local`;if(n.selectedHost===`local`){if(e.remote!==void 0)return!1}else if(n.selectedHost!==`all`&&e.remote?.hostId!==n.selectedHost)return!1;let r=n.perHost[t];return r?.mode!==`selected`||r.workspaceIds.includes(e.workspaceId)})}function Rm(e){return typeof e==`string`?e:e.id}function zm(e){return typeof e!=`string`&&(e.remote??e.projectionValues?.remoteHost??null)!==null}function Bm(e,t,n,r){let i=Pm(r,n);if(!Im(i,n))return[...e];let a=t instanceof Set?t:new Set(t),o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set;for(let e of n){let t=a.has(e.workspaceId);for(let n of e.sessionIds)o.add(n),t&&s.add(n)}let c=(i.selectedHost===`all`||i.selectedHost===`local`)&&i.perHost.local?.mode!==`selected`;return e.filter(e=>{let t=Rm(e);return s.has(t)?!0:!o.has(t)&&!zm(e)&&c})}function Vm(e,t){if(t===void 0||t.mode!==`selected`)return e.workspaceCount;let n=new Set(t.workspaceIds),r=0;for(let t of e.workspaces)n.has(t.workspaceId)&&(r+=1);return r}function Hm(e,t){return e.selectedHost===t?e:{...e,selectedHost:t}}function Um(e,t,n,r){let i=e.perHost[t],a=n===`selected`?i===void 0?[...new Set(r)]:[...i.workspaceIds]:i===void 0?[]:[...i.workspaceIds];return{...e,perHost:{...e.perHost,[t]:{mode:n,workspaceIds:a}}}}function Wm(e,t,n,r){let i=e.perHost[t],a=i?.mode===`selected`?i.workspaceIds:[...r],o=a.includes(n)?a.filter(e=>e!==n):[...a,n];return{...e,perHost:{...e.perHost,[t]:{mode:`selected`,workspaceIds:o}}}}function Gm(e,t,n){return{...e,perHost:{...e.perHost,[t]:{mode:`selected`,workspaceIds:[...new Set(n)]}}}}function Km(){return{selectedHost:`all`,perHost:{}}}function qm(e,t,n){let r=Pm(e,n),i=t?.remote?.hostId??`local`,a=r.selectedHost,o=r.perHost,s=!1;a!==`all`&&a!==i&&(a=`all`,s=!0);let c=o[i];return c?.mode===`selected`&&(t===void 0?(o={...o,[i]:{...c,mode:`all`}},s=!0):c.workspaceIds.includes(t.workspaceId)||(o={...o,[i]:{mode:`selected`,workspaceIds:[...c.workspaceIds,t.workspaceId]}},s=!0)),s?{selectedHost:a,perHost:o}:e}function Jm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ym(e){if(e===null||e===``)return Km();try{let t=JSON.parse(e);if(!Jm(t))return Km();let n=typeof t.selectedHost==`string`&&t.selectedHost.trim()!==``?t.selectedHost:`all`,r={};if(Jm(t.perHost))for(let[e,n]of Object.entries(t.perHost)){if(e===``||!Jm(n)||n.mode!==`all`&&n.mode!==`selected`)continue;let t=Array.isArray(n.workspaceIds)?[...new Set(n.workspaceIds.filter(e=>typeof e==`string`))]:[];r[e]={mode:n.mode,workspaceIds:t}}return{selectedHost:n,perHost:r}}catch{return Km()}}function Xm(e){try{let t=e===void 0?typeof window<`u`?window.localStorage:null:e;return t===null?Km():Ym(t.getItem(km))}catch{return Km()}}function Zm(e,t){try{let n=t===void 0?typeof window<`u`?window.localStorage:null:t;if(n===null)return;n.setItem(km,JSON.stringify(e))}catch{}}let Qm=`@deepseek-ai/dsh-client-ui-workspace/HostScopeFilter.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Qm)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Qm,e.textContent=`.jFA5LW_anchorRoot{align-items:center;min-width:0;display:inline-flex;position:relative}.jFA5LW_trigger{max-width:128px;height:22px;color:var(--dsw-alias-label-tertiary);font:inherit;cursor:pointer;transition:background-color .12s var(--ds-ease-in-out), color .12s var(--ds-ease-in-out);background:0 0;border:none;border-radius:6px;align-items:center;gap:4px;padding:0 6px;font-size:11.5px;font-weight:500;line-height:16px;display:inline-flex}.jFA5LW_trigger:hover,.jFA5LW_triggerOpen{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.jFA5LW_triggerActive{background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 10%, transparent);color:var(--dsw-alias-state-business-primary)}.jFA5LW_triggerActive:hover,.jFA5LW_triggerActive.jFA5LW_triggerOpen{background:color-mix(in srgb, var(--dsw-alias-state-business-primary) 16%, transparent);color:var(--dsw-alias-state-business-primary)}.jFA5LW_trigger:focus-visible,.jFA5LW_hostRow:focus-visible,.jFA5LW_segmentButton:focus-visible,.jFA5LW_perHostTrigger:focus-visible,.jFA5LW_footerAction:focus-visible,.jFA5LW_resetLink:focus-visible,.jFA5LW_miniLink:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.jFA5LW_triggerLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.jFA5LW_triggerChevron{opacity:.65;flex:none}.jFA5LW_dot{--ch-peer-dot-color:#3b82f6;background:var(--dsw-alias-label-tertiary);opacity:.5;border-radius:50%;flex:none;width:6px;height:6px}.jFA5LW_dot[data-color=blue]{--ch-peer-dot-color:#3b82f6}.jFA5LW_dot[data-color=purple]{--ch-peer-dot-color:#8b5cf6}.jFA5LW_dot[data-color=cyan]{--ch-peer-dot-color:#06b6d4}.jFA5LW_dot[data-color=green]{--ch-peer-dot-color:#10b981}.jFA5LW_dot[data-color=amber]{--ch-peer-dot-color:#f59e0b}.jFA5LW_dot[data-color=rose]{--ch-peer-dot-color:#f43f5e}.jFA5LW_dot[data-color=slate]{--ch-peer-dot-color:#64748b}body[data-ds-dark-theme] .jFA5LW_dot[data-color=blue]{--ch-peer-dot-color:#60a5fa}body[data-ds-dark-theme] .jFA5LW_dot[data-color=purple]{--ch-peer-dot-color:#a78bfa}body[data-ds-dark-theme] .jFA5LW_dot[data-color=cyan]{--ch-peer-dot-color:#22d3ee}body[data-ds-dark-theme] .jFA5LW_dot[data-color=green]{--ch-peer-dot-color:#34d399}body[data-ds-dark-theme] .jFA5LW_dot[data-color=amber]{--ch-peer-dot-color:#fbbf24}body[data-ds-dark-theme] .jFA5LW_dot[data-color=rose]{--ch-peer-dot-color:#fb7185}body[data-ds-dark-theme] .jFA5LW_dot[data-color=slate]{--ch-peer-dot-color:#94a3b8}.jFA5LW_dot[data-state=connected]{background:var(--ch-peer-dot-color);opacity:.95}.jFA5LW_dot[data-state=connecting]{background:var(--dsw-alias-state-warning-primary,#c27803);opacity:.9}.jFA5LW_popover{z-index:1100;box-sizing:border-box;width:min(260px,100vw - 24px);max-height:calc(100vh - 24px - max(12px, var(--dsh-frame-overlay-top,12px)));--dsw-elevation-stroke-color:var(--dsw-alias-border-l2);box-shadow:var(--dsw-elevation-prominent);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);color:var(--dsw-alias-label-primary);border:0;flex-direction:column;padding:5px;display:flex;position:fixed}.jFA5LW_scrollArea{flex-direction:column;flex:1;gap:2px;min-height:0;display:flex;overflow-y:auto}.jFA5LW_section{flex-direction:column;gap:1px;display:flex}.jFA5LW_sectionTitleRow{justify-content:space-between;align-items:center;gap:8px;padding:4px 7px 3px;display:flex}.jFA5LW_sectionTitle{letter-spacing:.01em;color:var(--dsw-alias-label-tertiary);font-size:10.5px;font-weight:500;line-height:14px}.jFA5LW_resetLink,.jFA5LW_miniLink{color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:4px;padding:1px 4px;font-size:11px;line-height:15px;transition:background-color .1s,color .1s}.jFA5LW_resetLink:hover:not(:disabled),.jFA5LW_miniLink:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.jFA5LW_miniLink:disabled{opacity:.35;cursor:default}.jFA5LW_hostList{flex-direction:column;gap:1px;display:flex}.jFA5LW_hostRow{width:100%;min-height:28px;color:var(--dsw-alias-label-primary);text-align:left;cursor:pointer;background:0 0;border:none;border-radius:6px;align-items:center;gap:7px;padding:3px 7px;font-size:12.5px;line-height:18px;transition:background-color .1s;display:flex}.jFA5LW_hostRow:hover{background:var(--dsw-alias-interactive-bg-hover)}.jFA5LW_hostRowSelected{background:color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent);font-weight:500}.jFA5LW_hostName{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}.jFA5LW_hostCount{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-tertiary);flex:none;font-size:11px;line-height:15px}.jFA5LW_hostCountFiltered{color:var(--dsw-alias-state-business-primary);font-weight:500}.jFA5LW_checkSlot{width:14px;height:14px;color:var(--dsw-alias-label-primary);flex:none;justify-content:center;align-items:center;display:inline-flex}.jFA5LW_divider{background:var(--dsw-alias-border-l2);height:1px;margin:4px 3px}.jFA5LW_scopeEditor{flex-direction:column;gap:6px;padding:2px 4px 4px;display:flex}.jFA5LW_segmented{background:var(--dsw-alias-interactive-bg-hover);border-radius:7px;grid-template-columns:1fr 1fr;gap:2px;padding:2px;display:grid}.jFA5LW_segmentButton{box-sizing:border-box;height:24px;color:var(--dsw-alias-label-secondary);font:inherit;white-space:nowrap;text-overflow:ellipsis;cursor:pointer;background:0 0;border:none;border-radius:5px;padding:0 7px;font-size:11.5px;font-weight:500;line-height:16px;transition:color .1s;overflow:hidden}.jFA5LW_segmentButton:hover:not(.jFA5LW_segmentActive){color:var(--dsw-alias-label-primary)}.jFA5LW_segmentActive{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);box-shadow:var(--dsw-elevation-soft)}.jFA5LW_workspacePicker{flex-direction:column;gap:3px;display:flex}.jFA5LW_workspacePickerBar{justify-content:space-between;align-items:center;gap:6px;padding:0 3px;display:flex}.jFA5LW_workspacePickerCount{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:15px}.jFA5LW_workspacePickerActions{align-items:center;gap:2px;display:inline-flex}.jFA5LW_workspaceList{flex-direction:column;gap:1px;max-height:160px;display:flex;overflow-y:auto}.jFA5LW_workspaceOption{min-height:25px;color:var(--dsw-alias-label-primary);cursor:pointer;border-radius:5px;align-items:center;gap:7px;padding:2px 6px;font-size:12px;line-height:17px;display:flex}.jFA5LW_workspaceOption:hover{background:var(--dsw-alias-interactive-bg-hover)}.jFA5LW_workspaceCheckbox{width:13px;height:13px;accent-color:var(--dsw-alias-brand-primary,var(--dsw-alias-state-business-primary));cursor:pointer;flex:none;margin:0}.jFA5LW_workspaceOptionName{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}.jFA5LW_noWorkspaces{color:var(--dsw-alias-label-tertiary);padding:6px;font-size:11.5px;line-height:16px}.jFA5LW_allHostsScopeList{flex-direction:column;gap:1px;display:flex}.jFA5LW_perHostAccordion{border-radius:6px;flex-direction:column;display:flex}.jFA5LW_perHostTrigger{width:100%;min-height:27px;color:var(--dsw-alias-label-primary);text-align:left;cursor:pointer;background:0 0;border:none;border-radius:6px;align-items:center;gap:6px;padding:3px 6px;font-size:12px;line-height:17px;display:flex}.jFA5LW_perHostTrigger:hover,.jFA5LW_perHostTriggerOpen{background:var(--dsw-alias-interactive-bg-hover)}.jFA5LW_accordionIcon{color:var(--dsw-alias-label-tertiary);flex:none}.jFA5LW_scopeSummaryTag{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-tertiary);flex:none;font-size:11px;line-height:15px}.jFA5LW_scopeSummaryTagFiltered{color:var(--dsw-alias-state-business-primary);font-weight:500}.jFA5LW_perHostBody{padding:3px 2px 2px 10px}.jFA5LW_footer{border-top:1px solid var(--dsw-alias-border-l2);flex-direction:column;flex:none;gap:1px;margin-top:4px;padding-top:4px;display:flex}.jFA5LW_footerAction{width:100%;min-height:28px;color:var(--dsw-alias-label-secondary);text-align:left;cursor:pointer;background:0 0;border:none;border-radius:6px;align-items:center;gap:7px;padding:3px 7px;font-size:12.5px;line-height:18px;transition:background-color .1s,color .1s;display:flex}.jFA5LW_footerAction:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.jFA5LW_footerIcon{color:var(--dsw-alias-label-tertiary);flex:none}.jFA5LW_footerAction:hover .jFA5LW_footerIcon{color:var(--dsw-alias-label-primary)}@media (hover:none),(pointer:coarse){.jFA5LW_trigger{min-height:32px;padding:0 8px}.jFA5LW_hostRow,.jFA5LW_footerAction{min-height:38px}.jFA5LW_workspaceOption{min-height:34px}}@media (prefers-reduced-motion:reduce){.jFA5LW_trigger,.jFA5LW_hostRow,.jFA5LW_footerAction{transition:none}}`,document.head.appendChild(e)}var Q={accordionIcon:`jFA5LW_accordionIcon`,allHostsScopeList:`jFA5LW_allHostsScopeList`,anchorRoot:`jFA5LW_anchorRoot`,checkSlot:`jFA5LW_checkSlot`,divider:`jFA5LW_divider`,dot:`jFA5LW_dot`,footer:`jFA5LW_footer`,footerAction:`jFA5LW_footerAction`,footerIcon:`jFA5LW_footerIcon`,hostCount:`jFA5LW_hostCount`,hostCountFiltered:`jFA5LW_hostCountFiltered`,hostList:`jFA5LW_hostList`,hostName:`jFA5LW_hostName`,hostRow:`jFA5LW_hostRow`,hostRowSelected:`jFA5LW_hostRowSelected`,miniLink:`jFA5LW_miniLink`,noWorkspaces:`jFA5LW_noWorkspaces`,perHostAccordion:`jFA5LW_perHostAccordion`,perHostBody:`jFA5LW_perHostBody`,perHostTrigger:`jFA5LW_perHostTrigger`,perHostTriggerOpen:`jFA5LW_perHostTriggerOpen`,popover:`jFA5LW_popover`,resetLink:`jFA5LW_resetLink`,scopeEditor:`jFA5LW_scopeEditor`,scopeSummaryTag:`jFA5LW_scopeSummaryTag`,scopeSummaryTagFiltered:`jFA5LW_scopeSummaryTagFiltered`,scrollArea:`jFA5LW_scrollArea`,section:`jFA5LW_section`,sectionTitle:`jFA5LW_sectionTitle`,sectionTitleRow:`jFA5LW_sectionTitleRow`,segmentActive:`jFA5LW_segmentActive`,segmentButton:`jFA5LW_segmentButton`,segmented:`jFA5LW_segmented`,trigger:`jFA5LW_trigger`,triggerActive:`jFA5LW_triggerActive`,triggerChevron:`jFA5LW_triggerChevron`,triggerLabel:`jFA5LW_triggerLabel`,triggerOpen:`jFA5LW_triggerOpen`,workspaceCheckbox:`jFA5LW_workspaceCheckbox`,workspaceList:`jFA5LW_workspaceList`,workspaceOption:`jFA5LW_workspaceOption`,workspaceOptionName:`jFA5LW_workspaceOptionName`,workspacePicker:`jFA5LW_workspacePicker`,workspacePickerActions:`jFA5LW_workspacePickerActions`,workspacePickerBar:`jFA5LW_workspacePickerBar`,workspacePickerCount:`jFA5LW_workspacePickerCount`};function $m(e,t){return e.key===`local`?t(`host.local`):e.displayName||e.hostId||e.key}function eh(e,t){return t(e===`connected`?`host.connected`:e===`connecting`?`host.connecting`:`host.disconnected`)}function th({host:e,state:t,onChange:n,t:r}){let i=t.perHost[e.key],a=i?.mode===`selected`?`selected`:`all`,c=(0,s.useMemo)(()=>new Set(i?.mode===`selected`?i.workspaceIds:[]),[i]),l=(0,s.useMemo)(()=>e.workspaces.map(e=>e.workspaceId),[e.workspaces]),u=Vm(e,i);return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q.scopeEditor,children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q.segmented,role:`tablist`,"aria-label":r(`hostScope.scope.label`),children:[/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":a===`all`,className:R(Q.segmentButton,a===`all`&&Q.segmentActive),onClick:()=>{n(Um(t,e.key,`all`,l))},children:r(`hostScope.scope.allSessions`)}),/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":a===`selected`,className:R(Q.segmentButton,a===`selected`&&Q.segmentActive),onClick:()=>{n(Um(t,e.key,`selected`,l))},children:r(`hostScope.scope.selectedWorkspaces`)})]}),a===`selected`&&/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q.workspacePicker,children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q.workspacePickerBar,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.workspacePickerCount,children:r(`hostScope.selectedCount`,{selected:u,total:e.workspaceCount})}),/* @__PURE__ */ (0,o.jsxs)(`span`,{className:Q.workspacePickerActions,children:[/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Q.miniLink,disabled:e.workspaces.length===0||u===e.workspaces.length,onClick:()=>{n(Gm(t,e.key,l))},children:r(`hostScope.selectAll`)}),/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Q.miniLink,disabled:u===0,onClick:()=>{n(Gm(t,e.key,[]))},children:r(`hostScope.clear`)})]})]}),e.workspaces.length===0?/* @__PURE__ */ (0,o.jsx)(`div`,{className:Q.noWorkspaces,children:r(`hostScope.noHostWorkspaces`)}):/* @__PURE__ */ (0,o.jsx)(`div`,{className:Q.workspaceList,children:e.workspaces.map(r=>{let i=c.has(r.workspaceId);return/* @__PURE__ */ (0,o.jsxs)(`label`,{className:Q.workspaceOption,title:r.path||r.title,children:[/* @__PURE__ */ (0,o.jsx)(`input`,{type:`checkbox`,className:Q.workspaceCheckbox,checked:i,onChange:()=>{n(Wm(t,e.key,r.workspaceId,l))}}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.workspaceOptionName,children:r.title})]},r.workspaceId)})})]})]})}function nh({workspaces:e,state:t,onChange:n,t:r}){let[i,l]=(0,s.useState)(!1),[u,d]=(0,s.useState)(null),f=(0,s.useRef)(null),p=(0,s.useRef)(null),m=(0,s.useRef)(null),h=(0,s.useId)(),g=(0,s.useMemo)(()=>jm(e),[e]),_=(0,s.useMemo)(()=>Nm(e),[e]),v=(0,s.useMemo)(()=>Pm(t,e),[t,e]),y=(0,s.useMemo)(()=>Im(v,e),[v,e]),b=(0,s.useMemo)(()=>v.selectedHost===`all`?void 0:_.find(e=>e.key===v.selectedHost),[v.selectedHost,_]),x=(0,a.useAnchoredPosition)({open:i,anchorRef:p,panelRef:m,side:`bottom`,align:`end`,gap:4,margin:12});if((0,a.useDismissOnOutsidePointer)(f,i,l,m),(0,s.useEffect)(()=>{if(!i)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),l(!1),p.current?.focus({preventScroll:!0}))};return document.addEventListener(`keydown`,e,!0),()=>{document.removeEventListener(`keydown`,e,!0)}},[i]),!g)return null;let S=(()=>{if(!y)return r(`hostScope.allShort`);if(b!==void 0){let e=$m(b,r),t=v.perHost[b.key];return t?.mode===`selected`?`${e} · ${Vm(b,t)}`:e}return r(`hostScope.filtered`)})(),C=b?.hostId===void 0?void 0:b.hostId,ee=()=>{l(!1),window.dispatchEvent(new CustomEvent(`codexhost:open-add-remote-workspace`,{detail:C===void 0?{}:{hostId:C}}))},w=()=>{l(!1),window.dispatchEvent(new CustomEvent(`codexhost:open-remote-peers-settings`))},te=e.length;return/* @__PURE__ */ (0,o.jsxs)(`span`,{ref:f,className:Q.anchorRoot,children:[/* @__PURE__ */ (0,o.jsxs)(`button`,{ref:p,type:`button`,className:R(Q.trigger,y&&Q.triggerActive,i&&Q.triggerOpen),"aria-haspopup":`dialog`,"aria-expanded":i,"aria-controls":i?h:void 0,"aria-label":r(`hostScope.trigger.aria`,{current:S}),title:r(`hostScope.trigger.aria`,{current:S}),onClick:e=>{e.stopPropagation(),l(e=>!e)},children:[b?.hostId!==void 0&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.dot,"data-state":b.state??`disconnected`,"data-color":Op(b.hostId,b.color),"aria-hidden":`true`}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.triggerLabel,children:S}),/* @__PURE__ */ (0,o.jsx)(a.IconChevronDownOutlineRegular,{size:12,className:Q.triggerChevron})]}),i&&(0,c.createPortal)(/* @__PURE__ */ (0,o.jsxs)(a.MenuSurface,{ref:m,id:h,role:`dialog`,"aria-label":r(`hostScope.popover.aria`),className:Q.popover,style:x??{visibility:`hidden`,left:0,top:0},onClick:e=>{e.stopPropagation()},children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q.scrollArea,children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q.section,children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q.sectionTitleRow,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.sectionTitle,children:r(`hostScope.host.label`)}),y&&/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Q.resetLink,onClick:()=>{n(Km())},children:r(`hostScope.reset`)})]}),/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q.hostList,role:`radiogroup`,"aria-label":r(`hostScope.host.label`),children:[/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":v.selectedHost===`all`,className:R(Q.hostRow,v.selectedHost===`all`&&Q.hostRowSelected),onClick:()=>{n(Hm(v,`all`))},children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.hostName,children:r(`hostScope.allHosts`)}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.hostCount,children:te}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.checkSlot,children:v.selectedHost===`all`&&/* @__PURE__ */ (0,o.jsx)(a.IconCheckOutlineRegular,{size:14})})]}),_.map(e=>{let t=v.selectedHost===e.key,i=v.perHost[e.key],s=i?.mode===`selected`,c=Vm(e,i),l=s?`${c}/${e.workspaceCount}`:String(e.workspaceCount),u=$m(e,r),d=e.hostId===void 0?u:`${u} · ${eh(e.state,r)}`;return/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,className:R(Q.hostRow,t&&Q.hostRowSelected),title:d,onClick:()=>{n(Hm(v,e.key))},children:[e.hostId!==void 0&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.dot,"data-state":e.state??`disconnected`,"data-color":Op(e.hostId,e.color),"aria-hidden":`true`}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.hostName,children:u}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:R(Q.hostCount,s&&Q.hostCountFiltered),children:l}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.checkSlot,children:t&&/* @__PURE__ */ (0,o.jsx)(a.IconCheckOutlineRegular,{size:14})})]},e.key)})]})]}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:Q.divider,role:`separator`}),/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q.section,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:Q.sectionTitleRow,children:/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.sectionTitle,children:r(`hostScope.scope.label`)})}),b===void 0?/* @__PURE__ */ (0,o.jsx)(`div`,{className:Q.allHostsScopeList,children:_.map(e=>{let t=u===e.key,i=v.perHost[e.key],s=i?.mode===`selected`,c=s?`${Vm(e,i)}/${e.workspaceCount}`:r(`hostScope.allShort`);return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q.perHostAccordion,children:[/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,className:R(Q.perHostTrigger,t&&Q.perHostTriggerOpen),"aria-expanded":t,onClick:()=>{d(t=>t===e.key?null:e.key)},children:[t?/* @__PURE__ */ (0,o.jsx)(a.IconChevronDownOutlineRegular,{size:12,className:Q.accordionIcon}):/* @__PURE__ */ (0,o.jsx)(a.IconChevronRightOutlineRegular,{size:12,className:Q.accordionIcon}),e.hostId!==void 0&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.dot,"data-state":e.state??`disconnected`,"data-color":Op(e.hostId,e.color),"aria-hidden":`true`}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q.hostName,children:$m(e,r)}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:R(Q.scopeSummaryTag,s&&Q.scopeSummaryTagFiltered),children:c})]}),t&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Q.perHostBody,children:/* @__PURE__ */ (0,o.jsx)(th,{host:e,state:v,onChange:n,t:r})})]},e.key)})}):/* @__PURE__ */ (0,o.jsx)(th,{host:b,state:v,onChange:n,t:r})]})]}),/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q.footer,children:[/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,className:Q.footerAction,onClick:ee,children:[/* @__PURE__ */ (0,o.jsx)(a.IconPlusOutlineRegular,{size:14,className:Q.footerIcon}),/* @__PURE__ */ (0,o.jsx)(`span`,{children:r(`hostScope.action.addRemoteWorkspace`)})]}),/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,className:Q.footerAction,onClick:w,children:[/* @__PURE__ */ (0,o.jsx)(a.IconSettingsOutlineRegular,{size:14,className:Q.footerIcon}),/* @__PURE__ */ (0,o.jsx)(`span`,{children:r(`hostScope.action.manageRemoteHosts`)})]})]})]}),document.body)]})}function rh(e,t){let n=Nm(e),r=n.find(e=>e.key===`local`)??{key:`local`,workspaces:[]},i=/* @__PURE__ */ new Map;for(let e of n)e.key!==`local`&&e.hostId!==void 0&&i.set(e.hostId,e);for(let e of t){if(!e.enabled){i.delete(e.hostId);continue}let t=i.get(e.hostId);t===void 0?i.set(e.hostId,{key:e.hostId,hostId:e.hostId,displayName:e.name,state:e.state,workspaces:[]}):i.set(e.hostId,{...t,displayName:e.name||t.displayName,state:e.state||t.state})}return[r,...i.values()]}function ih(e,t){return t===void 0?`local`:e.find(e=>e.workspaceId===t)?.remote?.hostId??`local`}function ah(e,t,n){let r=t.trim().toLowerCase();return r===``?[...e]:e.filter(e=>(e.key===`local`?n:e.displayName??e.hostId??e.key).toLowerCase().includes(r)||e.hostId!==void 0&&e.hostId.toLowerCase().includes(r))}function oh(e,t,n){let r=t.trim().toLowerCase();return r===``?[...e]:e.filter(e=>{let t=n(e).toLowerCase(),i=(e.path??``).toLowerCase();return t.includes(r)||i.includes(r)})}function sh(e,t){if(!e)return;let n=e.replace(/[\\/]+$/u,``);if(!n)return;let r=n.split(/[\\/]+/u).filter(Boolean);if(r.length<2)return;let i=r[r.length-2];if(i&&i!==t&&i!==`~`&&i!==`Users`&&i!==`home`)return i}function ch(e){if(typeof e!=`object`||!e)return[];let t=e.result;if(typeof t!=`object`||!t)return[];let n=t,r=(n.ok===!0&&typeof n.value==`object`&&n.value!==null?n.value:n).peers;if(!Array.isArray(r))return[];let i=[];for(let e of r){if(typeof e!=`object`||!e)continue;let t=e;typeof t.hostId==`string`&&t.hostId!==``&&typeof t.name==`string`&&typeof t.state==`string`&&i.push({hostId:t.hostId,name:t.name,state:t.state,enabled:t.enabled!==!1})}return i}function lh(e,t){if(t.workspaceId!==void 0){let n=e.find(e=>e.workspaceId===t.workspaceId);if(n!==void 0)return n}let n=t.path.replace(/[\\/]+$/u,``);return e.find(e=>e.remote?.hostId===t.hostId&&e.path.replace(/[\\/]+$/u,``)===n)}let uh=`@deepseek-ai/dsh-client-ui-workspace/HeroLocationWorkspacePicker.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(uh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=uh,e.textContent=`.tXrwyq_root{align-items:center;gap:4px;min-width:0;max-width:100%;display:inline-flex}.tXrwyq_trigger{min-width:0;max-width:240px;height:30px;color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;background:0 0;border:none;border-radius:9999px;align-items:center;gap:7px;padding:0 10px;font-size:13.5px;font-weight:450;line-height:20px;transition:background-color .11s,color .11s;display:inline-flex}.tXrwyq_trigger:hover:not(:disabled),.tXrwyq_triggerOpen{background:color-mix(in srgb, var(--dsw-alias-label-primary) 9%, transparent)}.tXrwyq_trigger:disabled{opacity:.55;cursor:default}.tXrwyq_trigger:focus-visible,.tXrwyq_row:focus-visible,.tXrwyq_footerAction:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}.tXrwyq_triggerPlaceholder{color:var(--dsw-alias-label-tertiary);font-weight:400}.tXrwyq_triggerPlaceholder:hover:not(:disabled),.tXrwyq_triggerPlaceholder.tXrwyq_triggerOpen{color:var(--dsw-alias-label-secondary)}.tXrwyq_triggerLocation{flex:0 auto;max-width:180px}.tXrwyq_triggerProject{flex:0 auto;max-width:260px}.tXrwyq_triggerIcon{color:currentColor;opacity:.9;flex:none}.tXrwyq_triggerPlaceholder .tXrwyq_triggerIcon{opacity:.8}.tXrwyq_triggerLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.tXrwyq_statusDot{background:var(--dsw-alias-label-tertiary);opacity:.78;border-radius:50%;flex:none;width:6px;height:6px}.tXrwyq_statusDot[data-state=connecting]{background:var(--dsw-alias-state-warning-primary,#c27803);opacity:.92}.tXrwyq_statusDot[data-state=auth-error]{background:var(--dsw-alias-state-error-primary);opacity:.92}.tXrwyq_popover{z-index:1100;box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l3);--dsw-elevation-stroke-color:transparent;box-shadow:var(--dsw-elevation-prominent);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);color:var(--dsw-alias-label-primary);border-radius:16px;flex-direction:column;padding:6px;display:flex;position:fixed}.tXrwyq_popoverLocation{width:min(264px,100vw - 24px)}.tXrwyq_popoverProject{width:min(280px,100vw - 24px)}.tXrwyq_searchRow{align-items:center;gap:8px;height:36px;padding:0 10px;display:flex}.tXrwyq_searchIcon{color:var(--dsw-alias-label-tertiary);flex:none}.tXrwyq_searchInput{min-width:0;height:100%;color:var(--dsw-alias-label-primary);font:inherit;background:0 0;border:none;outline:none;flex:1;padding:0;font-size:14px;line-height:20px}.tXrwyq_searchInput::placeholder{color:var(--dsw-alias-label-tertiary)}.tXrwyq_divider{background:var(--dsw-alias-border-l2);flex:none;height:.5px;margin:4px 10px 6px}.tXrwyq_footerDivider{background:var(--dsw-alias-border-l2);flex:none;height:.5px;margin:6px 10px 4px}.tXrwyq_list{flex-direction:column;gap:2px;max-height:260px;display:flex;overflow-y:auto}.tXrwyq_row{width:100%;min-height:36px;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:none;border-radius:11px;align-items:center;gap:9px;padding:6px 10px;font-size:14px;font-weight:450;line-height:20px;transition:background-color 90ms;display:flex}.tXrwyq_row:hover,.tXrwyq_rowActive{background:color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent)}.tXrwyq_rowIcon{width:16px;height:16px;color:var(--dsw-alias-label-secondary);flex:none;justify-content:center;align-items:center;display:inline-flex}.tXrwyq_rowMain{flex:1;align-items:baseline;gap:7px;min-width:0;display:flex}.tXrwyq_rowTitle{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.tXrwyq_rowHint{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-tertiary);flex:0 auto;font-size:13px;font-weight:400;line-height:18px;overflow:hidden}.tXrwyq_rowStatus{color:var(--dsw-alias-label-tertiary);flex:none;font-size:11.5px;line-height:16px}.tXrwyq_checkSlot{width:16px;height:16px;color:var(--dsw-alias-label-primary);flex:none;justify-content:center;align-items:center;display:inline-flex}.tXrwyq_emptyState{text-align:center;color:var(--dsw-alias-label-tertiary);padding:16px 10px;font-size:13px;line-height:18px}.tXrwyq_footerAction{width:100%;min-height:36px;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:none;border-radius:11px;align-items:center;gap:9px;padding:6px 10px;font-size:14px;font-weight:450;line-height:20px;transition:background-color 90ms;display:flex}.tXrwyq_footerAction:hover:not(:disabled){background:color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent)}.tXrwyq_footerAction:disabled{opacity:.5;cursor:default}.tXrwyq_footerIcon{color:var(--dsw-alias-label-secondary);flex:none}.tXrwyq_modalAction{min-width:72px}.tXrwyq_modalError{color:var(--dsw-alias-state-error-primary);margin-top:8px;font-size:12px;line-height:18px}@media (hover:none),(pointer:coarse){.tXrwyq_trigger{min-height:34px;padding:0 11px}.tXrwyq_row,.tXrwyq_footerAction{min-height:40px}}@media (prefers-reduced-motion:reduce){.tXrwyq_trigger,.tXrwyq_row,.tXrwyq_footerAction{transition:none}}`,document.head.appendChild(e)}var $={checkSlot:`tXrwyq_checkSlot`,divider:`tXrwyq_divider`,emptyState:`tXrwyq_emptyState`,footerAction:`tXrwyq_footerAction`,footerDivider:`tXrwyq_footerDivider`,footerIcon:`tXrwyq_footerIcon`,list:`tXrwyq_list`,modalAction:`tXrwyq_modalAction`,modalError:`tXrwyq_modalError`,popover:`tXrwyq_popover`,popoverLocation:`tXrwyq_popoverLocation`,popoverProject:`tXrwyq_popoverProject`,root:`tXrwyq_root`,row:`tXrwyq_row`,rowActive:`tXrwyq_rowActive`,rowHint:`tXrwyq_rowHint`,rowIcon:`tXrwyq_rowIcon`,rowMain:`tXrwyq_rowMain`,rowStatus:`tXrwyq_rowStatus`,rowTitle:`tXrwyq_rowTitle`,searchIcon:`tXrwyq_searchIcon`,searchInput:`tXrwyq_searchInput`,searchRow:`tXrwyq_searchRow`,statusDot:`tXrwyq_statusDot`,trigger:`tXrwyq_trigger`,triggerIcon:`tXrwyq_triggerIcon`,triggerLabel:`tXrwyq_triggerLabel`,triggerLocation:`tXrwyq_triggerLocation`,triggerOpen:`tXrwyq_triggerOpen`,triggerPlaceholder:`tXrwyq_triggerPlaceholder`,triggerProject:`tXrwyq_triggerProject`};let dh=`codexhost:remote-peers-updated`,fh=`codexhost:remote-workspace-created`,ph=`codexhost/remote-peers/list`,mh=`::no-project`;function hh({className:e}){return/* @__PURE__ */ (0,o.jsxs)(`svg`,{width:15,height:15,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,o.jsx)(`rect`,{x:`2.25`,y:`2.75`,width:`11.5`,height:`8`,rx:`1.5`}),/* @__PURE__ */ (0,o.jsx)(`path`,{d:`M1.25 12.75h13.5`})]})}function gh({className:e}){return/* @__PURE__ */ (0,o.jsxs)(`svg`,{width:15,height:15,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,o.jsx)(`rect`,{x:`2`,y:`2.5`,width:`12`,height:`8.5`,rx:`1.6`}),/* @__PURE__ */ (0,o.jsx)(`path`,{d:`M5.5 13.5h5M8 11v2.5`})]})}function _h(e,t){return e.key===`local`?t(`host.thisComputer`):e.displayName||e.hostId||e.key}function vh(e,t){if(e!==void 0&&e!==`connected`)return t(e===`connecting`?`host.connecting`:`host.disconnected`)}function yh({location:e,className:t}){return e.key===`local`?/* @__PURE__ */ (0,o.jsx)(hh,{className:t}):e.state!==void 0&&e.state!==`connected`?/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.statusDot,"data-state":e.state,"aria-hidden":`true`}):/* @__PURE__ */ (0,o.jsx)(gh,{className:t})}async function bh(e){try{let t=typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`hero-peers-${Date.now()}`,n=await fetch(`api/${ph}`,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify({type:`client-request`,rpcId:t,method:ph,payload:{args:{}}}),...e===void 0?{}:{signal:e}});return n.ok?ch(await n.json()):null}catch{return null}}function xh({open:e,selectedId:t,fallbackLabel:n,onOpenChange:r,onPick:i,onClose:l,useWorkspaces:u,createWorkspace:d,useDirectoryFlow:f,renderSlot:p,t:m}){let h=u(e=>e),g=h.items,_=h.canStartProjectless===!0,v=f(e=>e),[y,b]=(0,s.useState)([]),[x,S]=(0,s.useState)(!1),[C,ee]=(0,s.useState)(!1),[w,te]=(0,s.useState)(!1),[T,E]=(0,s.useState)(``),[D,O]=(0,s.useState)(``),[ne,re]=(0,s.useState)(-1),[ie,ae]=(0,s.useState)(-1),[oe,se]=(0,s.useState)(!1),[k,ce]=(0,s.useState)(!1),[le,ue]=(0,s.useState)(!1),[de,fe]=(0,s.useState)(null),A=(0,a.usePhoneSidebar)(),pe=(0,s.useRef)(!1),me=(0,s.useRef)(null),[he,ge]=(0,s.useState)(null),_e=(0,s.useRef)(null),ve=(0,s.useRef)(null),ye=(0,s.useRef)(null),be=(0,s.useRef)(null),xe=(0,s.useRef)(null),Se=(0,s.useRef)(null),Ce=(0,s.useRef)(null),we=(0,s.useId)(),Te=(0,s.useId)(),j=e||w,Ee=oe||k,De=(0,s.useMemo)(()=>ih(g,t),[g,t]),Oe=(0,s.useMemo)(()=>rh(g,y),[g,y]),ke=(0,s.useMemo)(()=>new Set(Oe.map(e=>e.key)),[Oe]),Ae=(0,s.useMemo)(()=>new Set(y.filter(e=>!e.enabled).map(e=>e.hostId)),[y]),je=h.phase===`ready`&&h.state===`idle`&&x,[Me,Ne]=(0,s.useState)(()=>De),Pe=(0,s.useCallback)((e,t=!1)=>{te(e),r?.(e),e||(t||Ne(ke.has(De)?De:`local`),l())},[ke,l,r,De]);(0,s.useEffect)(()=>{e&&(ee(!1),te(!0))},[e]);let Fe=(0,s.useCallback)(e=>{bh(e).then(t=>{e?.aborted||t===null||(b(t),S(!0))})},[]);(0,s.useEffect)(()=>{let e=new AbortController;Fe(e.signal);let t=()=>{Fe()};return window.addEventListener(dh,t),()=>{e.abort(),window.removeEventListener(dh,t)}},[Fe]),(0,s.useEffect)(()=>{C&&Fe()},[C,Fe]),(0,s.useEffect)(()=>{let e=e=>{let t=e.detail;t&&typeof t.hostId==`string`&&typeof t.path==`string`&&me.current!==null&&t.hostId===me.current&&(me.current=null,ge({hostId:t.hostId,path:t.path,...typeof t.workspaceId==`string`?{workspaceId:t.workspaceId}:{}}))};return window.addEventListener(fh,e),()=>{window.removeEventListener(fh,e)}},[]);let Ie=(0,s.useRef)(t);(0,s.useEffect)(()=>{if(t!==Ie.current&&(Ie.current=t,t!==void 0)){let e=ih(g,t);Ne(ke.has(e)?e:`local`)}},[ke,t,g]),(0,s.useEffect)(()=>{t!==void 0&&De!==`local`&&ke.has(De)&&Ne(e=>e===`local`?De:e)},[ke,t,De]);let Le=(0,s.useRef)(void 0);(0,s.useEffect)(()=>{let e=e=>e!==`local`&&!ke.has(e)&&(je||Ae.has(e));e(Me)&&Ne(`local`),me.current!==null&&e(me.current)&&(me.current=null),he!==null&&e(he.hostId)&&ge(null);let n=t===void 0?void 0:g.find(e=>e.workspaceId===t),r=n?.remote!==void 0&&e(n.remote.hostId),a=he!==null&&!e(he.hostId)&&he.workspaceId===t,o=je&&t!==void 0&&n===void 0&&!a&&(Me!==`local`||t.startsWith(`remote-peer:`));r||o?_&&Le.current!==t&&(Le.current=t,i(null)):Le.current=void 0},[Me,ke,_,Ae,je,i,he,t,g]);let M=(0,s.useMemo)(()=>Oe.find(e=>e.key===Me)??Oe[0]??{key:`local`,workspaces:[]},[Me,Oe]);(0,s.useEffect)(()=>{if(he===null)return;let e=lh(g,he);e!==void 0&&(ge(null),Ne(e.remote?.hostId??`local`),i(e.workspaceId))},[i,he,g]),(0,s.useEffect)(()=>{oe&&!v&&se(!1)},[oe,v]);let Re=(0,a.useAnchoredPosition)({open:C,anchorRef:ve,panelRef:be,side:`bottom`,align:`start`,gap:6,margin:12}),ze=(0,a.useAnchoredPosition)({open:j,anchorRef:ye,panelRef:xe,side:`bottom`,align:`start`,gap:6,margin:12});(0,a.useDismissOnOutsidePointer)(_e,C,ee,be),(0,a.useDismissOnOutsidePointer)(_e,j,(0,s.useCallback)(e=>{e||Pe(!1)},[Pe]),xe),(0,s.useEffect)(()=>{if(!C)return;E(``),re(-1);let e=requestAnimationFrame(()=>{Se.current?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(e)},[C]),(0,s.useEffect)(()=>{if(!j)return;O(``),ae(-1);let e=requestAnimationFrame(()=>{Ce.current?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(e)},[j]),(0,s.useEffect)(()=>{if(!C&&!j)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),C?(ee(!1),ve.current?.focus({preventScroll:!0})):j&&(Pe(!1),ye.current?.focus({preventScroll:!0})))};return document.addEventListener(`keydown`,e,!0),()=>{document.removeEventListener(`keydown`,e,!0)}},[C,j,Pe]);let Be=(0,s.useCallback)(e=>an(e.title,m(`workspace.defaultName`)),[m]),Ve=(0,s.useMemo)(()=>ah(Oe,T,m(`host.thisComputer`)),[Oe,T,m]),He=(0,s.useMemo)(()=>oh(M.workspaces,D,Be),[M.workspaces,D,Be]),Ue=M.key===`local`&&_&&D.trim()===``,We=(0,s.useMemo)(()=>[...Ue?[{id:mh,workspace:void 0}]:[],...He.map(e=>({id:e.workspaceId,workspace:e}))],[He,Ue]);(0,s.useEffect)(()=>{re(e=>Ve.length===0?-1:e>=Ve.length?0:e)},[Ve.length]),(0,s.useEffect)(()=>{ae(e=>We.length===0?-1:e>=We.length?0:e)},[We.length]);let N=Oe.length>1,Ge=_h(M,m),Ke=(0,s.useMemo)(()=>t===void 0?void 0:g.find(e=>e.workspaceId===t),[t,g]),qe=Ke!==void 0&&(Ke.remote?.hostId??`local`)===M.key,Je=qe&&Ke!==void 0?Be(Ke):t===void 0&&M.key===`local`&&n!==void 0?n:m(`heroPicker.project.choose`),Ye=!qe&&(t!==void 0||M.key!==`local`||n===void 0),Xe=e=>{let t=e.key!==M.key;Ne(e.key),ee(!1),t&&Pe(!0)},Ze=e=>{me.current=null,Pe(!1,!0),i(e===mh?null:e)},Qe=(0,s.useCallback)(()=>{me.current=null,pe.current=A?.open===!0,Pe(!1,!0),ue(!1),fe(null),se(!0)},[A?.open,Pe]),$e=()=>{M.key===`local`?v&&!Ee&&Qe():M.hostId?.startsWith(`remote-peer:`)&&M.state===`connected`&&(Pe(!1),me.current=M.hostId,window.dispatchEvent(new CustomEvent(`codexhost:open-add-remote-workspace`,{detail:{hostId:M.hostId}})))},et=M.key===`local`?v:M.hostId?.startsWith(`remote-peer:`)===!0&&M.state===`connected`,P=()=>{ee(!1),window.dispatchEvent(new CustomEvent(`codexhost:open-remote-peers-settings`))},tt=e=>d({path:e}).then(e=>{se(!1),Ne(`local`),i(e.workspaceId)}).catch(e=>{fe(e instanceof Error?e.message:String(e)),se(!1),ue(!0)}),nt={open:oe,busy:k,onPicked:e=>{ce(!0),tt(e).finally(()=>{ce(!1)})},onCancel:()=>{se(!1)},onError:e=>{se(!1),fe(e),ue(!0)}},rt=e=>{if(Ve.length!==0){if(e.key===`ArrowDown`)e.preventDefault(),re(e=>e<0?0:(e+1)%Ve.length);else if(e.key===`ArrowUp`)e.preventDefault(),re(e=>e<0?Ve.length-1:(e-1+Ve.length)%Ve.length);else if(e.key===`Enter`){e.preventDefault();let t=Ve[ne>=0?ne:0];t!==void 0&&Xe(t)}}},it=e=>{if(We.length!==0){if(e.key===`ArrowDown`)e.preventDefault(),ae(e=>e<0?0:(e+1)%We.length);else if(e.key===`ArrowUp`)e.preventDefault(),ae(e=>e<0?We.length-1:(e-1+We.length)%We.length);else if(e.key===`Enter`){e.preventDefault();let t=We[ie>=0?ie:0];t!==void 0&&Ze(t.id)}}},at=()=>{ue(!1),fe(null)};return/* @__PURE__ */ (0,o.jsxs)(`div`,{ref:_e,className:$.root,"data-hero-location-picker":``,children:[/* @__PURE__ */ (0,o.jsxs)(`button`,{ref:ve,type:`button`,className:R($.trigger,$.triggerLocation,C&&$.triggerOpen),"aria-haspopup":`dialog`,"aria-expanded":C,"aria-controls":C?we:void 0,"aria-label":m(`heroPicker.location.aria`,{current:Ge}),disabled:Ee,"data-hero-location-trigger":``,onClick:()=>{Pe(!1),ee(e=>!e)},children:[/* @__PURE__ */ (0,o.jsx)(yh,{location:M,className:$.triggerIcon}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.triggerLabel,children:Ge})]}),/* @__PURE__ */ (0,o.jsxs)(`button`,{ref:ye,type:`button`,className:R($.trigger,$.triggerProject,Ye&&$.triggerPlaceholder,j&&$.triggerOpen),"aria-haspopup":`dialog`,"aria-expanded":j,"aria-controls":j?Te:void 0,"aria-label":m(`heroPicker.project.aria`,{current:Je}),disabled:Ee,"data-hero-project-trigger":``,onClick:()=>{ee(!1),Pe(!j)},children:[Ye?/* @__PURE__ */ (0,o.jsx)(a.IconFolderCloseRegular,{size:15,className:$.triggerIcon}):/* @__PURE__ */ (0,o.jsx)(a.IconFolderOpenOutlineRegular,{size:15,className:$.triggerIcon}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.triggerLabel,children:Je})]}),C&&(0,c.createPortal)(/* @__PURE__ */ (0,o.jsxs)(a.MenuSurface,{ref:be,id:we,role:`dialog`,"aria-label":m(`heroPicker.location.placeholder`),className:R($.popover,$.popoverLocation),style:Re??{visibility:`hidden`,left:0,top:0},"data-hero-location-popover":``,onClick:e=>{e.stopPropagation()},children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:$.searchRow,children:[/* @__PURE__ */ (0,o.jsx)(a.IconSearchOutlineRegular,{size:15,className:$.searchIcon}),/* @__PURE__ */ (0,o.jsx)(`input`,{ref:Se,type:`text`,className:$.searchInput,value:T,placeholder:m(`heroPicker.location.placeholder`),"aria-label":m(`heroPicker.location.placeholder`),spellCheck:!1,autoComplete:`off`,onChange:e=>{E(e.target.value),re(e.target.value.trim()===``?-1:0)},onKeyDown:rt})]}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.divider,role:`separator`}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.list,role:`listbox`,"aria-label":m(`heroPicker.location.placeholder`),onMouseLeave:()=>re(-1),children:Ve.length===0?/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.emptyState,children:m(`heroPicker.location.empty`)}):Ve.map((e,t)=>{let n=e.key===M.key,r=_h(e,m),i=vh(e.state,m);return/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:R($.row,t===ne&&$.rowActive),onMouseEnter:()=>re(t),onClick:()=>Xe(e),children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.rowIcon,children:/* @__PURE__ */ (0,o.jsx)(yh,{location:e})}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.rowMain,children:/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.rowTitle,children:r})}),i!==void 0&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.rowStatus,children:i}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.checkSlot,children:n&&/* @__PURE__ */ (0,o.jsx)(a.IconCheckOutlineRegular,{size:15})})]},e.key)})}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.footerDivider,role:`separator`}),/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,className:$.footerAction,onClick:P,children:[N?/* @__PURE__ */ (0,o.jsx)(a.IconSettingsOutlineRegular,{size:15,className:$.footerIcon}):/* @__PURE__ */ (0,o.jsx)(a.IconPlusOutlineRegular,{size:15,className:$.footerIcon}),/* @__PURE__ */ (0,o.jsx)(`span`,{children:m(N?`heroPicker.location.manageRemote`:`heroPicker.location.connectRemote`)})]})]}),document.body),j&&(0,c.createPortal)(/* @__PURE__ */ (0,o.jsxs)(a.MenuSurface,{ref:xe,id:Te,role:`dialog`,"aria-label":m(`heroPicker.project.placeholder`),className:R($.popover,$.popoverProject),style:ze??{visibility:`hidden`,left:0,top:0},"data-hero-project-popover":``,onClick:e=>{e.stopPropagation()},children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:$.searchRow,children:[/* @__PURE__ */ (0,o.jsx)(a.IconSearchOutlineRegular,{size:15,className:$.searchIcon}),/* @__PURE__ */ (0,o.jsx)(`input`,{ref:Ce,type:`text`,className:$.searchInput,value:D,placeholder:m(`heroPicker.project.placeholder`),"aria-label":m(`heroPicker.project.placeholder`),spellCheck:!1,autoComplete:`off`,onChange:e=>{O(e.target.value),ae(e.target.value.trim()===``?-1:0)},onKeyDown:it})]}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.divider,role:`separator`}),/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.list,role:`listbox`,"aria-label":m(`heroPicker.project.placeholder`),onMouseLeave:()=>ae(-1),children:h.phase===`pending`&&We.length===0?/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.emptyState,role:`status`,children:m(`picker.loading`)}):We.length===0?/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.emptyState,children:D.trim()===``?m(`heroPicker.project.empty`):m(`heroPicker.project.noMatches`)}):We.map((e,n)=>{let r=e.workspace===void 0,i=r?t===void 0:e.id===t,s=r?m(`heroPicker.project.noProject`):Be(e.workspace),c=r?void 0:sh(e.workspace.path,s);return/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":i,className:R($.row,n===ie&&$.rowActive),title:e.workspace?.path||s,onMouseEnter:()=>ae(n),onClick:()=>Ze(e.id),children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.rowIcon,children:/* @__PURE__ */ (0,o.jsx)(a.IconFolderCloseRegular,{size:15})}),/* @__PURE__ */ (0,o.jsxs)(`span`,{className:$.rowMain,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.rowTitle,children:s}),c!==void 0&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.rowHint,children:c})]}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.checkSlot,children:i&&/* @__PURE__ */ (0,o.jsx)(a.IconCheckOutlineRegular,{size:15})})]},e.id)})}),et&&/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.footerDivider,role:`separator`}),/* @__PURE__ */ (0,o.jsxs)(`button`,{type:`button`,className:$.footerAction,disabled:Ee,onClick:$e,children:[/* @__PURE__ */ (0,o.jsx)(a.IconPlusOutlineRegular,{size:15,className:$.footerIcon}),/* @__PURE__ */ (0,o.jsx)(`span`,{children:m(`heroPicker.project.new`)})]})]})]}),document.body),p(`conversation.hero.workspace.directoryFlow`,nt),/* @__PURE__ */ (0,o.jsx)(a.Modal,{phoneSidebar:!0,phoneSidebarOrigin:pe.current,open:le,onClose:at,closeLabel:m(`close`),title:m(`folderError.title`),footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,className:$.modalAction,onClick:at,children:m(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`primary`,className:$.modalAction,disabled:!v,onClick:Qe,children:m(`folderError.retry`)})]}),children:/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.modalError,role:`alert`,children:de})})]})}let Sh=`@deepseek-ai/dsh-client-ui-workspace/WorkspacePicker.module.css`;if(typeof document<`u`&&document.querySelector(`style[data-plugin-css=`+JSON.stringify(Sh)+`]`)===null){let e=document.createElement(`style`);e.dataset.plugin=`@deepseek-ai/dsh-client-ui-workspace`,e.dataset.pluginCss=Sh,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 Ch={menuStatus:`s4nt4G_menuStatus`,modalAction:`s4nt4G_modalAction`,modalError:`s4nt4G_modalError`};let wh=`::add-workspace`,Th=`::no-workspace`;function Eh({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,s.useCallback)(()=>n?.current?.getBoundingClientRect()??null,[n]),[b,x]=(0,s.useState)(!1),[S,C]=(0,s.useState)(null),[ee,w]=(0,s.useState)(!1),te=(0,a.usePhoneSidebar)(),T=(0,s.useRef)(!1),[E,D]=(0,s.useState)(!1),O=ee||E;(0,s.useEffect)(()=>{m?.(O)},[O,m]);let ne=c(e=>e);(0,s.useEffect)(()=>{ee&&!ne&&w(!1)},[ee,ne]);let re=ne?[{id:wh,label:e(`menu.addWorkspace`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconPlusOutlineRegular,{size:16}),disabled:O}]:[],ie=!p&&v.length>0,ae=d!==void 0&&!p,oe=ae?[{id:Th,label:e(`menu.noWorkspace`),disabled:O}]:[],se=ie?[...oe,...v.map(t=>({id:t.workspaceId,label:an(t.title,e(`workspace.defaultName`)),icon:/* @__PURE__ */ (0,o.jsx)(a.IconFolderCloseRegular,{size:16}),disabled:O}))]:[...oe,...re],k=se.length===0,ce=()=>{x(!1),C(null)},le=e=>i({path:e}).then(e=>{w(!1),u(e.workspaceId)}).catch(e=>{C(e instanceof Error?e.message:String(e)),w(!1),x(!0)}),ue=(0,s.useCallback)(()=>{T.current=te?.open===!0,f(),x(!1),C(null),w(!0)},[f,te?.open]),de=p||_.phase===`ready`,fe=!ae&&!ie&&de&&re.length===1;(0,s.useEffect)(()=>{t&&fe&&!O&&ue()},[t,fe,O,ue]);let A={open:ee,busy:E,onPicked:e=>{D(!0),le(e).finally(()=>{D(!1)})},onCancel:()=>{w(!1)},onError:e=>{w(!1),C(e),x(!0)}},pe=e=>{e===Th?d?.():e===wh?ue():u(e)};return/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Menu,{open:t&&!fe&&!k,anchor:null,items:se,...ie?{footer:re}:{},selectedId:g??(ae?Th:void 0),onSelect:pe,onClose:f,side:h,portal:!0,getAnchorRect:y}),t&&!fe&&!k&&_.phase===`pending`&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Ch.menuStatus,role:`status`,children:e(`picker.loading`)}),l(A),/* @__PURE__ */ (0,o.jsx)(a.Modal,{phoneSidebar:!0,phoneSidebarOrigin:T.current,open:b,onClose:ce,closeLabel:e(`close`),title:e(`folderError.title`),footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,className:Ch.modalAction,onClick:ce,children:e(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`primary`,className:Ch.modalAction,disabled:!ne,onClick:ue,children:e(`folderError.retry`)})]}),children:/* @__PURE__ */ (0,o.jsx)(`div`,{className:Ch.modalError,role:`alert`,children:S})})]})}function Dh(e){return/* @__PURE__ */ (0,o.jsx)(xh,{...e})}function Oh(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 kh(e){(0,s.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 Ah({groupBy:e,orderBy:t,archivedFilter:n,onGroupPick:r,onOrderPick:i,onArchivedFilterPick:c,t:l}){let[u,d]=(0,s.useState)(!1),f=(0,s.useRef)(null),p=(0,a.usePhoneSidebar)(),{collapseStyle:m,setCollapseStyle:h}=cn(),{busy:g,failed:_,save:v}=Yt(h);return/* @__PURE__ */ (0,o.jsx)(a.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,o.jsx)(a.IconFolderCloseRegular,{})},{id:`workspace-tree`,label:l(`groupBy.workspaceTree`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconWorkspaceTreeOutlineRegular,{})},{id:`flat`,label:l(`groupBy.flat`),icon:/* @__PURE__ */ (0,o.jsx)(a.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,o.jsx)(a.IconChevronsUpDownOutlineRegular,{})},{id:`updated`,label:l(`orderBy.updated`),icon:/* @__PURE__ */ (0,o.jsx)(a.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,o.jsx)(a.IconArchiveOffOutlineRegular,{})},{id:`show-archived`,label:l(`viewOptions.showArchived`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconQueueOutlineRegular,{})},{id:`only-archived`,label:l(`viewOptions.onlyArchived`),icon:/* @__PURE__ */ (0,o.jsx)(a.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,a.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:Z.viewOptionsMenu,portal:!0,anchor:/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:l(`viewOptions.label`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,ref:f,className:R(Z.iconButton,Z.wide),"aria-label":l(`viewOptions.label`),"data-phone-sidebar-return":p!==null||void 0,onClick:()=>{d(e=>!e)},children:/* @__PURE__ */ (0,o.jsx)(a.IconSlidersTwoOutlineRegular,{})})}),children:_&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:qt.error,role:`alert`,children:l(`threadTree.style.error`)})})}function jh(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),re(c,t.find(e=>e.blank)?.id)}function Mh(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function Nh({rowState:e,onLeaveArchivedOnly:t,partial:n,t:r}){let i=e.archivedFilter===`only`;return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Z.emptyState,"data-row-key":`empty`,children:[i?/* @__PURE__ */ (0,o.jsx)(a.IconArchiveOutlineRegular,{size:24}):/* @__PURE__ */ (0,o.jsx)(a.IconQueueOutlineRegular,{size:24}),/* @__PURE__ */ (0,o.jsx)(`div`,{children:r(n?`sessions.notLoaded`:i?`empty.noneArchived`:`empty.none`)}),i&&/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Z.emptyAction,onClick:t,children:r(`empty.viewOthers`)})]})}function Ph({list:e,useSessionStatus:t,startSession:n,open:r,workspaces:i,linkedRoots:c,ungroupedSessionIds:l,rowState:u,nativeSections:d,onLeaveArchivedOnly:f,workspaceReady:p,canStartProjectless:m,animationResetKey:h,usePanelInfo:g,onRenameRequest:_,onDeleteRequest:v,onSessionRenameRequest:y,renderSlot:b,insertWorkspaceBefore:x,nestWorkspaces:S,groupExpansion:C,setGroupExpanded:ee,sectionExpansion:w,setSectionExpanded:te,setSessionOrder:E,home:D,t:O,revealSessionId:ne,onSessionRevealed:re,shortcuts:ie,loadMoreSessions:ae,hostScopeFilterControl:oe,hostScopeFiltered:se=!1,singleRemoteHostScoped:k=!1,onResetHostScope:ce}){let le=cn(),ue=(0,a.usePhoneSidebar)(),de=g(e=>e.activePanelId!==null),fe=t(e=>e),A=de?void 0:Object.values(e.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,pe=(0,s.useMemo)(()=>i.map(e=>{let t=c.get(e.workspaceId);return t===void 0||t.size===0?e:{...e,sessionIds:e.sessionIds.filter(e=>!t.has(e))}}),[c,i]),he=ne===void 0||!p?void 0:T(pe,le.rootId(ne)),[ge,ve]=(0,s.useState)({}),[ye,xe]=(0,s.useState)(null),Te=(0,s.useRef)(!1),[j,Ee]=(0,s.useState)(null),De=(0,s.useRef)(!1),Oe=ye!==null||j!==null;kh(Oe);let ke=A===void 0||!p?void 0:T(pe,le.rootId(A)),Ae=(0,s.useMemo)(()=>{let e=/* @__PURE__ */ new Map;for(let t of d)for(let n of t.workspaceIds??[])e.has(n)||e.set(n,t.id);return e},[d]),je=(0,s.useMemo)(()=>{if(!S)return/* @__PURE__ */ new Map;let e=e=>`${e.remote?.hostId??`local`}\n${Ae.get(e.workspaceId)??``}`,t=/* @__PURE__ */ new Map;for(let n of i){let r=e(n),i=t.get(r)??/* @__PURE__ */ new Map;n.path&&i.set(n.path,n.workspaceId),t.set(r,i)}return new Map(i.map(n=>{let r=t.get(e(n)),i=be(n.path,[...r?.keys()??[]]);return[n.workspaceId,i===void 0?void 0:r?.get(i)]}))},[S,Ae,i]),Me=(0,s.useMemo)(()=>{let e=new Set(je.values());return[...i.map(e=>e.workspaceId),``].filter(t=>C[t]??(t===``||e.has(t)))},[C,je,i]),Ne=(0,s.useMemo)(()=>{let t=me(e,i,u,fe,{expandedGroups:Me,excludePinned:!0});return(m||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:Me.includes(``),containsCurrent:!1,sessions:[]}),t},[e,i,u,fe,Me,m]),Pe=Date.now(),Fe=(e,t)=>{if(Te.current)return;Te.current=!0,xe(null);let n=Ne.find(t=>t.key===e.accountKey);if(n===void 0||t.id===e.sessionId)return;let r=e.accountKey===``?l:i.find(t=>t.workspaceId===e.accountKey)?.sessionIds;if(r===void 0)return;let a=Em(n.sessions,ge[n.key]??5,A,ne).rows,o=jh(r,a,e,t);o!==void 0&&E(e.accountKey,o)},Ie=(e,t)=>{if(De.current||(De.current=!0,Ee(null),!nn(i,e.workspaceId,t.id)))return;let n=je.get(e.workspaceId),r=i.filter(e=>!e.remote&&!Ae.has(e.workspaceId)&&je.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)&&x(e.workspaceId,o).catch(e=>{console.warn(`workspace reorder rejected:`,e)})},Le=(0,s.useMemo)(()=>{let e=new Set(Ne.map(e=>e.key)),t=/* @__PURE__ */ new Map;for(let n of Ne){let r=je.get(n.key);for(;r!==void 0&&!e.has(r);)r=je.get(r);let i=t.get(r);i===void 0?t.set(r,[n]):i.push(n)}return t},[Ne,je]),M=Le.get(void 0)??[],Re=M[0]?.workspaceId!==void 0&&j?.over?.id===M[0].workspaceId&&j.over.half===`before`,ze=(0,s.useMemo)(()=>{let e=/* @__PURE__ */ new Map,t=(n,r)=>{e.set(n.key,r);for(let e of Le.get(n.key)??[])t(e,r)};for(let e of M)t(e,e.key);return e},[Le,M]),Be=(0,s.useMemo)(()=>{let e=/* @__PURE__ */ new Set;for(let t of[ke,he]){let n=t===void 0?void 0:ze.get(t);n!==void 0&&n!==``&&e.add(n)}return e},[ke,he,ze]),[Ve,He]=(0,s.useState)(!1),Ue=M.filter(e=>e.key!==``&&!Ae.has(e.key)),We=(0,s.useMemo)(()=>{let e=new Map(M.map(e=>[e.key,e]));return new Map(d.map(t=>[t.id,(t.workspaceIds??[]).flatMap(n=>{let r=e.get(n);return r!==void 0&&Ae.get(n)===t.id?[r]:[]})]))},[d,M,Ae]),N=Dm(Ue,5,Be),Ge=Ve?Ue:N.rows,Ke=we(w,Se),qe=Ih(d,e,u,fe,w),Je=we(w,Ce),Ye=e=>{e.expanded&&ve(t=>({...t,[e.key]:5})),ee(e.key,!e.expanded)},Xe=_e(e,u.pinnedSessionIds,u,fe).filter(e=>e.pinned),Ze=[];if(Xe.length>0&&(Ze.push(`section:${Se}`),Ke))for(let e of le.rows(Xe))Ze.push(`session:${e.id}`);let Qe=(t,s)=>{let l=t.workspaceId,u=Le.get(t.key)??[],d=Ae.has(t.key),f=j!==null&&!d&&nn(i,j.workspaceId,l)&&je.get(j.workspaceId)===je.get(t.key),p=Em(t.sessions,ge[t.key]??5,A,ne);Ze.push(`workspace:${t.key}`);let h=t.expanded?u.map(e=>Qe(e,s+1)):[],g=le.rows(p.rows),x=c.get(t.key),S=new Set(x===void 0?[]:p.rows.flatMap(e=>x.has(e.id)?[e.id,...e.tree?.descendantIds??[]]:[])),C=e=>l===void 0?`recent:${e}`:S.has(e)?`linked:${t.key}:${e}`:`session:${e}`;for(let e of g)Ze.push(C(e.id));let w=!t.remote&&e.hasMore,te=t.expanded&&(p.hiddenCount>0||w);te&&Ze.push(`overflow:${t.key}`);let T=l!==void 0&&j?.over?.id===l?j.over.half:null,E=l===void 0||t.remote||d?void 0:{start:()=>{De.current=!1,Ee({workspaceId:l,over:null})},end:()=>{j?.over!==null&&j?.over!==void 0?Ie(j,j.over):Ee(null),De.current=!1}},oe=l===void 0||!f?void 0:e=>{Ee(t=>t===null?t:{...t,over:{id:l,half:e}})},se=l===void 0||!f?void 0:e=>{Ie(j,{id:l,half:e})};return/* @__PURE__ */ (0,o.jsxs)(`div`,{"data-sidebar-group":t.key,style:{"--dsh-workspace-indent":`${s*12}px`},className:R(Z.groupSection,T===`before`&&Z.workspaceDropBefore,T===`after`&&Z.workspaceDropAfter),onDragOver:j===null?void 0:e=>{e.preventDefault(),(oe!==void 0||je.get(t.key)===void 0)&&(e.stopPropagation(),oe===void 0?(e.dataTransfer.dropEffect=`none`,j.over!==null&&Ee({...j,over:null})):(e.dataTransfer.dropEffect=`move`,oe(Mh(e))))},onDrop:j===null?void 0:e=>{e.preventDefault(),(se!==void 0||je.get(t.key)===void 0)&&(e.stopPropagation(),se===void 0?(De.current=!0,Ee(null)):se(Mh(e)))},children:[l===void 0?/* @__PURE__ */ (0,o.jsx)(bm,{label:O(`group.ungrouped`),expanded:t.expanded,onToggle:()=>{Ye(t)},rowKey:`workspace:${t.key}`,action:m?{label:O(`actions.newSession`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconNewChatOutlineRegular,{size:16}),onActivate:()=>{ee(t.key,!0),ue?.close(),n()}}:void 0}):/* @__PURE__ */ (0,o.jsx)(om,{newShortcut:ie.find(e=>e.id===`session.new`),group:t,home:D,t:O,onToggle:()=>{Ye(t)},onCreate:()=>{t.workspaceId!==void 0&&(ee(t.key,t.expanded),ue?.close(),n(t.workspaceId))},drag:E,actions:t.workspaceId===void 0?void 0:{rename:()=>{
12
133
  /* v8 ignore next -- narrowing guard: the actions object exists only for real-workspace groups. */
13
134
  t.workspaceId!==void 0&&_(t.workspaceId,t.label)},delete:()=>{
14
135
  /* v8 ignore next -- narrowing guard: the actions object exists only for real-workspace groups. */
15
- t.workspaceId!==void 0&&v(t.workspaceId,t.label)}}}),p.length>0&&/* @__PURE__ */ (0,o.jsx)(`div`,{role:`group`,children:p}),(h.length>0||C)&&/* @__PURE__ */ (0,o.jsxs)(`div`,{role:`group`,className:$.groupSessions,style:{"--dsh-workspace-indent":`${l===void 0?0:s*12+22}px`},children:[/* @__PURE__ */ (0,o.jsx)(fn,{roots:f.rows,children:e=>{let n=B!==null&&B.accountKey===t.key,i=n&&B.pinned===e.pinned,a=t=>e.blank?`after`:t,s={start:()=>{V.current=!1,oe({accountKey:t.key,sessionId:e.id,pinned:e.pinned,over:null})},active:i,marker:n&&B.over?.id===e.id?B.over.half:null,hover:t=>{
136
+ t.workspaceId!==void 0&&v(t.workspaceId,t.label)}}}),h.length>0&&/* @__PURE__ */ (0,o.jsx)(`div`,{role:`group`,children:h}),(g.length>0||te)&&/* @__PURE__ */ (0,o.jsxs)(`div`,{role:`group`,className:Z.groupSessions,style:{"--dsh-workspace-indent":`${l===void 0?0:s*12+22}px`},children:[/* @__PURE__ */ (0,o.jsx)(Zp,{roots:p.rows,children:e=>{let n=ye!==null&&ye.accountKey===t.key,i=n&&ye.pinned===e.pinned,a=t=>e.blank?`after`:t,s={start:()=>{Te.current=!1,xe({accountKey:t.key,sessionId:e.id,pinned:e.pinned,over:null})},active:i,marker:n&&ye.over?.id===e.id?ye.over.half:null,hover:t=>{
16
137
  /* v8 ignore next -- narrowing guard: Rows gates hover on `active`, which is false while the drag state is null. */
17
- oe(n=>n===null?n:{...n,over:{id:e.id,half:a(t)}})},drop:t=>{
138
+ xe(n=>n===null?n:{...n,over:{id:e.id,half:a(t)}})},drop:t=>{
18
139
  /* v8 ignore next -- narrowing guard: Rows gates drop on `active`, which is false while the drag state is null. */
19
- B!==null&&ve(B,{id:e.id,half:a(t)})},end:e=>{!e&&B?.over!==null&&B?.over!==void 0?ve(B,B.over):oe(null),V.current=!1}};return/* @__PURE__ */ (0,o.jsx)(wn,{rowKey:S(e.id),showHost:!t.remote,node:e,currentId:L,now:_e,onOpen:r,onRenameRequest:y,renderSlot:b,onReveal:e.id===j&&t.key===re?()=>{M(e.id)}:void 0,drag:l===void 0||t.remote||(e.tree?.depth??0)>0?void 0:s,t:A},e.id)}}),C&&/* @__PURE__ */ (0,o.jsx)(Un,{rowKey:`overflow:${t.key}`,hiddenCount:f.hiddenCount,hasMore:e.hasMore,loading:e.loading,expand:()=>{ie(e=>({...e,[t.key]:(e[t.key]??5)+10}))},loadMoreSessions:P,t:A})]})]},t.key)},Pe=[];if(Te.length>0&&Me.push(`section:${le}`),K){for(let e of De)Pe.push(Ne(e,0));!we&&Ee.hiddenCount>0&&(Me.push(`overflow:workspaces`),Pe.push(/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:$.sessionOverflowButton,"data-row-key":`overflow:workspaces`,onClick:()=>{G(!0)},children:A(`workspaces.expand`)},`overflow:workspaces`)))}let Fe=W.find(e=>e.key===``);return Fe!==void 0&&Pe.push(Ne(Fe,0)),/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q($.treeBody,$.wide),children:[xe&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.listTopDropIndicator,"aria-hidden":`true`}),/* @__PURE__ */ (0,o.jsxs)(Mn,{className:Q($.list,xe&&$.listTopDropActive),label:A(`section.sessions`),rowKeys:Me,ready:e.phase===`ready`&&p&&!pe,resetKey:JSON.stringify([h,R,we,Oe,K]),children:[/* @__PURE__ */ (0,o.jsx)(Rn,{rows:je,currentId:L,onOpen:r,onRenameRequest:y,renderSlot:b,revealSessionId:j,onSessionRevealed:M,expanded:Oe,onToggle:()=>{D(ce,!Oe)},t:A}),/* @__PURE__ */ (0,o.jsx)(or,{sections:ke,currentId:L,onOpen:r,onRenameRequest:y,renderSlot:b,revealSessionId:j,onSessionRevealed:M,setSectionExpanded:D,t:A}),U.length===0&&je.length===0&&d.length===0&&/* @__PURE__ */ (0,o.jsx)(tr,{rowState:u,onLeaveArchivedOnly:f,partial:e.hasMore,t:A}),Te.length>0&&/* @__PURE__ */ (0,o.jsx)(Fn,{label:A(`section.workspaces`),expanded:K,onToggle:()=>{K&&G(!1),D(`workspaces`,!K)},rowKey:`section:workspaces`}),Pe]}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.fade})]})}let rr=[];function ir(e,t,n,r,i){if(!e.length)return[];let a=new Map(R(t,n,r).map(e=>[e.id,e])),o=/* @__PURE__ */ new Set;return e.map(({id:e,name:t,threadIds:n})=>{let r=`native-section:${e}`;return{key:r,name:t,rows:n.flatMap(e=>{let t=a.get(e);return!t||t.pinned||o.has(e)?[]:(o.add(e),[t])}),expanded:ue(i,r)}})}function ar(e,t){return e.flatMap(({key:e,rows:n,expanded:r})=>[`section:${e}`,...r?t(n).map(e=>`session:${e.id}`):[]])}function or({sections:e,setSectionExpanded:t,...n}){return e.map(({key:e,name:r,rows:i,expanded:a})=>/* @__PURE__ */ (0,o.jsx)(Rn,{...n,rows:i,customSection:{key:e,name:r},expanded:a,onToggle:()=>t(e,!a)},e))}function sr({list:e,sessionIds:t,rowState:n,nativeSections:r,onLeaveArchivedOnly:i,useSessionStatus:a,open:c,onSessionRenameRequest:l,usePanelInfo:u,setSessionOrder:d,sectionExpansion:f,setSectionExpanded:p,workspaceReady:m,animationResetKey:h,revealSessionId:g,onSessionRevealed:_,renderSlot:v,loadMoreSessions:y,t:b}){let x=u(e=>e.activePanelId!==null),S=a(e=>e),C=qt(),w=(0,s.useMemo)(()=>ae(e,t,n,S).filter(e=>!e.pinned&&!n.sectionedSessionIds?.has(e.id)),[e,t,n,S]),T=ae(e,n.pinnedSessionIds,n,S).filter(e=>e.pinned),[E,D]=(0,s.useState)(null),O=(0,s.useRef)(!1),[k,A]=(0,s.useState)(10);Zn(E!==null);let j=x?void 0:Object.values(e.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,M=Vn(w,k,j,g),N=Vn(w,10,j,g).hiddenCount>0,P=(e,n)=>{if(O.current)return;O.current=!0,D(null);let r=$n(t,w,e,n);r!==void 0&&d(H,r)},ee=Date.now(),F=ue(f,ce),I=ir(r,e,n,S,f);return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q($.treeBody,$.wide),children:[/* @__PURE__ */ (0,o.jsxs)(Mn,{className:Q($.list,$.flatList),label:b(`section.sessions`),rowKeys:[...T.length===0?[]:[`section:${ce}`],...F?C.rows(T).map(e=>`session:${e.id}`):[],...ar(I,C.rows),...w.length===0&&T.length===0&&r.length===0?[`empty`]:[],...C.rows(M.rows).map(e=>`session:${e.id}`),...N||e.hasMore?[`overflow:flat`]:[]],ready:e.phase===`ready`&&m&&E===null,resetKey:`${h}/${k}/${String(F)}`,children:[/* @__PURE__ */ (0,o.jsx)(Rn,{rows:T,currentId:j,onOpen:c,onRenameRequest:l,renderSlot:v,revealSessionId:g,onSessionRevealed:_,expanded:F,onToggle:()=>{p(ce,!F)},t:b}),/* @__PURE__ */ (0,o.jsx)(or,{sections:I,currentId:j,onOpen:c,onRenameRequest:l,renderSlot:v,revealSessionId:g,onSessionRevealed:_,setSectionExpanded:p,t:b}),(T.length>0||r.length>0)&&/* @__PURE__ */ (0,o.jsx)(Fn,{label:b(`section.sessions`)}),w.length===0&&T.length===0&&r.length===0&&/* @__PURE__ */ (0,o.jsx)(tr,{rowState:n,onLeaveArchivedOnly:i,partial:e.hasMore,t:b}),/* @__PURE__ */ (0,o.jsx)(fn,{roots:M.rows,children:e=>{let t=E!==null&&E.pinned===e.pinned,n=t=>e.blank?`after`:t;return/* @__PURE__ */ (0,o.jsx)(wn,{node:e,currentId:j,now:ee,onOpen:c,onRenameRequest:l,renderSlot:v,onReveal:e.id===g?()=>{_(e.id)}:void 0,drag:{start:()=>{O.current=!1,D({accountKey:H,sessionId:e.id,pinned:e.pinned,over:null})},active:t,marker:t&&E.over?.id===e.id?E.over.half:null,hover:t=>{D(r=>r===null?r:{...r,over:{id:e.id,half:n(t)}})},drop:t=>{E!==null&&P(E,{id:e.id,half:n(t)})},end:e=>{!e&&E?.over!==null&&E?.over!==void 0?P(E,E.over):D(null),O.current=!1}},t:b},e.id)}}),/* @__PURE__ */ (0,o.jsx)(Un,{rowKey:`overflow:flat`,hiddenCount:M.hiddenCount,hasMore:e.hasMore,loading:e.loading,expanded:k>10,expand:()=>A(k+10),collapse:N?()=>A(10):void 0,loadMoreSessions:y,t:b})]}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.fade})]})}function cr({useSessions:e,useSessionStatus:t,open:n,onUnarchive:r,workspaces:i,archivedSessionIds:a,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,s.useMemo)(()=>oe(h,i,l,a,c,g,_,d),[h,i,l,a,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,o.jsxs)(`div`,{className:Q($.treeBody,$.wide),children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:$.list,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.searchTree,role:`tree`,"aria-label":p(`search.results.aria`),children:v.items.map(e=>/* @__PURE__ */ (0,o.jsx)(Cn,{result:e,currentId:b,onOpen:n,onUnarchive:r,t:p},e.id))}),y&&/* @__PURE__ */ (0,o.jsx)(`div`,{role:`status`,"aria-label":p(`search.pending`),children:(v.items.length===0?[0,1]:[0]).map(e=>/* @__PURE__ */ (0,o.jsxs)(`div`,{className:$.skeletonRow,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.skeletonDot}),/* @__PURE__ */ (0,o.jsxs)(`span`,{className:$.skeletonBars,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.skeletonBar}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q($.skeletonBar,$.skeletonBarWide)})]})]},e))}),!y&&v.items.length===0&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.empty,children:p(`search.noMatches`)}),v.hasMore&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.searchStatus,children:p(`search.hasMore`,{n:d})})]}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:$.fade})]})}function lr(e){return/* @__PURE__ */ (0,o.jsx)(Jt,{browser:e,children:/* @__PURE__ */ (0,o.jsx)(ur,{...e})})}function ur({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:P,loadMoreSessions:ee,renderSlot:F,t:I}){let te=C(e=>e.home),L=w(e=>e),ne=L.find(e=>e.id===`session.search`),re=L.find(e=>e.id===`workspace.add`),R=T(e=>e),z=r(e=>e),B=c(e=>e.items),ae=c(e=>e.canStartProjectless===!0),oe=I(`workspace.defaultName`),V=(0,s.useMemo)(()=>B.map(e=>({...e,title:Wt(e.title,oe)})),[B,oe]),se=c(e=>e.phase),ce=c(e=>e.state),le=c(e=>e.archivedSessionIds),ue=c(e=>e.pinnedSessionIds),de=c(e=>e.threadSections??rr),fe=S(e=>e),ge=l(e=>e.groupBy),U=l(e=>e.orderBy),_e=l(e=>e.archivedFilter??`default`),ve=l(e=>e.groupExpansion),ye=qt(),be=l(e=>e.sectionExpansion),W=l(e=>e.sessionOrderByAccount),xe=e=>{le.includes(e)?m():(ye.selectSidebarRow(e),f(e))},Se=()=>{u.setArchivedFilter(`default`)},Ce=se===`ready`&&ce!==`loading`,we=Object.values(z.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,G=we!==void 0&&z.byId[we]?.blank===!0?we:void 0,Te=(0,s.useMemo)(()=>{let e=new Set(V.flatMap(e=>e.sessionIds));return[.../* @__PURE__ */ new Set([...z.ids,...le])].filter(t=>!e.has(t))},[le,z.ids,V]),Ee=(0,s.useMemo)(()=>({pinnedSessionIds:ue,archivedSessionIds:le}),[le,ue]),De=_e===`only`?rr:de,Oe=(0,s.useMemo)(()=>({...Ee,archivedFilter:_e,sectionedSessionIds:new Set(De.flatMap(e=>e.threadIds))}),[Ee,_e,De]),ke=(0,s.useMemo)(()=>ie(z,le),[le,z]),K=(0,s.useMemo)(()=>pe(z,Oe),[z,Oe]),Ae=(0,s.useMemo)(()=>V.map(e=>{let{memberIds:t,linkedRootIds:n}=me(e.sessionIds,K),r=U===`updated`?k(t,K.summaries):A(t,W[e.workspaceId],K.summaries,Ee);return{workspace:{...e,sessionIds:j(r,G!==void 0&&t.includes(G)?G:void 0)},linkedRootIds:n}}),[G,K,U,Ee,W,V]),je=(0,s.useMemo)(()=>Ae.map(({workspace:e})=>e),[Ae]),Me=(0,s.useMemo)(()=>new Map(Ae.map(({workspace:e,linkedRootIds:t})=>[e.workspaceId,t])),[Ae]),Ne=(0,s.useMemo)(()=>k(Te.filter(e=>K.rootIds.has(e)),K.summaries),[K,Te]),Pe=(0,s.useMemo)(()=>{let e=ke.filter(e=>K.rootIds.has(e));return j(U===`updated`?k(e,K.summaries):A(e,W[H],K.summaries,Ee),G!==void 0&&ke.includes(G)?G:void 0)},[G,ke,K,U,Ee,W]),Fe=(0,s.useMemo)(()=>he(V,z,Oe),[z,Oe,V]),Ie=(0,s.useMemo)(()=>Object.fromEntries([...je.map(e=>[e.workspaceId,e.sessionIds]),[``,Ne],[H,Pe]]),[Pe,Ne,je]);(0,s.useEffect)(()=>{se===`ready`&&u.retainAccountKeys([``,H,...V.map(e=>e.workspaceId)])},[u.retainAccountKeys,se,V]),(0,s.useEffect)(()=>{if(z.phase!==`ready`||Ce||U!==`manual`||G===void 0)return;let e={};for(let[t,n]of Object.entries(Ie)){if(t!==`__flat_session_order__`&&se!==`ready`)continue;let r=W[t]??[];n[0]===G&&r[0]!==G&&(e[t]=[G,...r.filter(e=>e!==G)])}Object.keys(e).length>0&&u.syncSessionOrders(e,Fe)},[u.syncSessionOrders,Ie,G,z.phase,U,W,Fe,se,Ce]),(0,s.useEffect)(()=>{z.phase===`ready`&&Ce&&U===`manual`&&G!==void 0&&Object.entries(Ie).some(([e,t])=>t[0]===G&&W[e]?.[0]!==G)&&u.syncSessionOrders(Ie,Fe)},[u.syncSessionOrders,Ie,G,z.phase,U,W,Fe,Ce]);let Le=(e,t)=>{u.setSessionOrder(e,t,Ie,Fe)},[Re,ze]=(0,s.useState)(``),[q,Be]=(0,s.useState)(!1),[Ve,He]=(0,s.useState)(void 0),Ue=Xn(Re).trim(),[We,Ge]=(0,s.useState)({query:``,status:`idle`,items:[],hasMore:!1}),Ke=(0,s.useRef)(null),qe=(0,s.useRef)(null),Je=R.addRequested,Ye=(0,s.useRef)(null),Xe=(0,s.useRef)(!1),Ze=e=>{if(le.includes(e)){m();return}let t=De.find(({threadIds:t})=>t.includes(ye.rootId(e)));t&&u.setSectionExpanded(`native-section:${t.id}`,!0),He(e),ze(``),Be(!1),ye.reveal(e),f(e)},Qe=e=>{He(t=>t===e?void 0:t)};(0,s.useEffect)(()=>{Ue!==``&&He(void 0)},[Ue]);let[$e,et]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(e&&$e){let e=window.setTimeout(()=>{qe.current?.focus({preventScroll:!0}),et(!1)},300);return()=>{window.clearTimeout(e)}}},[e,$e]),(0,s.useEffect)(()=>{R.searchRequest!==0&&(O(),Be(!0),e?qe.current?.focus({preventScroll:!0}):(et(!0),n()))},[R.searchRequest]),(0,s.useEffect)(()=>{e&&q&&!$e&&qe.current?.focus({preventScroll:!0})},[e,q,$e]),(0,s.useEffect)(()=>{if(!e||!q||$e)return;let t=e=>{e.target instanceof Node&&Ke.current?.contains(e.target)!==!0&&(qe.current?.blur(),Ue===``&&Be(!1))};return document.addEventListener(`click`,t),()=>{document.removeEventListener(`click`,t)}},[Ue,e,q,$e]),(0,s.useEffect)(()=>{if(Ue===``){Ge({query:``,status:`idle`,items:[],hasMore:!1});return}let e=new AbortController;Ge({query:Ue,status:`loading`,items:[],hasMore:!1});let t=window.setTimeout(()=>{b(Ue,e.signal).then(t=>{e.signal.aborted||Ge({query:Ue,status:`ready`,items:t.items,hasMore:t.hasMore})}).catch(()=>{e.signal.aborted||Ge({query:Ue,status:`error`,items:[],hasMore:!1})})},250);return()=>{window.clearTimeout(t),e.abort()}},[Ue,b]);let[tt,nt]=(0,s.useState)(null),[rt,it]=(0,s.useState)(``),[at,ot]=(0,s.useState)(!1),[st,ct]=(0,s.useState)(null),lt=rt.trim(),ut=tt!==null&&lt!==``&&V.some(e=>e.workspaceId!==tt.workspaceId&&e.title===lt),dt=at||lt===``||tt===null||lt===tt.storedTitle||ut,J=()=>{at||(nt(null),ct(null))},Y=()=>{dt||(ot(!0),ct(null),h(tt.workspaceId,lt).then(()=>{ot(!1),nt(null)}).catch(e=>{ot(!1),ct(e instanceof Error?e.message:String(e))}))},ft=e=>{v(e).catch(e=>{console.warn(`session unarchive rejected:`,e)})},[pt,mt]=(0,s.useState)(null),[ht,gt]=(0,s.useState)(!1),[_t,vt]=(0,s.useState)(null),[yt,bt]=(0,s.useState)(null);(0,s.useEffect)(()=>{_t===null||V.some(e=>e.workspaceId===_t)||(gt(!1),vt(null),mt(null))},[_t,V]);let xt=()=>{ht||(mt(null),bt(null))},St=()=>{
140
+ ye!==null&&Fe(ye,{id:e.id,half:a(t)})},end:e=>{!e&&ye?.over!==null&&ye?.over!==void 0?Fe(ye,ye.over):xe(null),Te.current=!1}};return/* @__PURE__ */ (0,o.jsx)(lm,{rowKey:C(e.id),showHost:!t.remote&&!(l===void 0&&k),node:e,currentId:A,now:Pe,onOpen:r,onRenameRequest:y,renderSlot:b,onReveal:e.id===ne&&t.key===he?()=>{re(e.id)}:void 0,drag:l===void 0||t.remote||(e.tree?.depth??0)>0?void 0:s,t:O},e.id)}}),te&&/* @__PURE__ */ (0,o.jsx)(Om,{rowKey:`overflow:${t.key}`,hiddenCount:p.hiddenCount,hasMore:w,loading:!t.remote&&e.loading,expand:()=>{ve(e=>({...e,[t.key]:(e[t.key]??5)+10}))},loadMoreSessions:()=>{ae(l===void 0||t.remote?void 0:l)},t:O})]})]},t.key)},$e=/* @__PURE__ */ new Map;for(let e of qe)Ze.push(...Lh([e],le.rows)),e.expanded&&$e.set(e.key,(We.get(e.id)??[]).map(e=>Qe(e,0)));!se&&Ne.length===0&&Xe.length===0&&d.length===0&&Ze.push(`empty`);let et=Ue.length>0||se,P=se&&Ue.length===0,tt=[];if(et&&Ze.push(`section:${Ce}`),Je){P&&(Ze.push(`empty:host-scope`),tt.push(/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Z.filterEmptyHint,"data-row-key":`empty:host-scope`,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{children:O(`hostScope.emptyWorkspaces`)}),ce!==void 0&&/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Z.emptyAction,onClick:ce,children:O(`hostScope.showAll`)})]},`empty:host-scope`)));for(let e of Ge)tt.push(Qe(e,0));!Ve&&N.hiddenCount>0&&(Ze.push(`overflow:workspaces`),tt.push(/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Z.sessionOverflowButton,"data-row-key":`overflow:workspaces`,onClick:()=>{He(!0)},children:O(`workspaces.expand`)},`overflow:workspaces`)))}let nt=M.find(e=>e.key===``);return nt!==void 0&&tt.push(Qe(nt,0)),/* @__PURE__ */ (0,o.jsxs)(`div`,{className:R(Z.treeBody,Z.wide),children:[Re&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:Z.listTopDropIndicator,"aria-hidden":`true`}),/* @__PURE__ */ (0,o.jsxs)(_m,{className:R(Z.list,Re&&Z.listTopDropActive),label:O(`section.sessions`),rowKeys:Ze,ready:e.phase===`ready`&&p&&!Oe,resetKey:JSON.stringify([h,ge,Ve,Ke,Je]),children:[/* @__PURE__ */ (0,o.jsx)(Cm,{rows:Xe,currentId:A,onOpen:r,onRenameRequest:y,renderSlot:b,revealSessionId:ne,onSessionRevealed:re,expanded:Ke,onToggle:()=>{te(Se,!Ke)},t:O}),/* @__PURE__ */ (0,o.jsx)(Rh,{sections:qe,groupRows:$e,currentId:A,onOpen:r,onRenameRequest:y,renderSlot:b,revealSessionId:ne,onSessionRevealed:re,setSectionExpanded:te,t:O}),!se&&Ne.length===0&&Xe.length===0&&d.length===0&&/* @__PURE__ */ (0,o.jsx)(Nh,{rowState:u,onLeaveArchivedOnly:f,partial:e.hasMore,t:O}),et&&/* @__PURE__ */ (0,o.jsx)(bm,{label:O(`section.workspaces`),expanded:Je,onToggle:()=>{Je&&He(!1),te(`workspaces`,!Je)},rowKey:`section:workspaces`,trailing:oe}),tt]}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Z.fade})]})}let Fh=[];function Ih(e,t,n,r,i){if(!e.length)return[];let a=new Map(pe(t,n,r).map(e=>[e.id,e])),o=/* @__PURE__ */ new Set;return e.map(({id:e,name:t,threadIds:n})=>{let r=`native-section:${e}`;return{id:e,key:r,name:t,rows:n.flatMap(e=>{let t=a.get(e);return!t||t.pinned||o.has(e)?[]:(o.add(e),[t])}),expanded:we(i,r)}})}function Lh(e,t){return e.flatMap(({key:e,rows:n,expanded:r})=>[`section:${e}`,...r?t(n).map(e=>`session:${e.id}`):[]])}function Rh({sections:e,groupRows:t,setSectionExpanded:n,...r}){return e.map(({key:e,name:i,rows:a,expanded:s})=>/* @__PURE__ */ (0,o.jsx)(Cm,{...r,rows:a,customSection:{key:e,name:i},expanded:s,onToggle:()=>n(e,!s),children:t?.get(e)},e))}function zh({list:e,sessionIds:t,rowState:n,nativeSections:r,onLeaveArchivedOnly:i,useSessionStatus:a,open:c,onSessionRenameRequest:l,usePanelInfo:u,setSessionOrder:d,sectionExpansion:f,setSectionExpanded:p,workspaceReady:m,animationResetKey:h,revealSessionId:g,onSessionRevealed:_,renderSlot:v,loadMoreSessions:y,hostScopeFilterControl:b,hostScopeFiltered:x=!1,onResetHostScope:S,t:C}){let ee=u(e=>e.activePanelId!==null),w=a(e=>e),te=cn(),T=(0,s.useMemo)(()=>_e(e,t,n,w).filter(e=>!e.pinned&&!n.sectionedSessionIds?.has(e.id)),[e,t,n,w]),E=_e(e,n.pinnedSessionIds,n,w).filter(e=>e.pinned),[D,O]=(0,s.useState)(null),ne=(0,s.useRef)(!1),[re,ie]=(0,s.useState)(10);kh(D!==null);let ae=ee?void 0:Object.values(e.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,oe=Em(T,re,ae,g),se=Em(T,10,ae,g).hiddenCount>0,k=(e,n)=>{if(ne.current)return;ne.current=!0,O(null);let r=jh(t,T,e,n);r!==void 0&&d(xe,r)},ce=Date.now(),le=we(f,Se),ue=Ih(r,e,n,w,f);return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:R(Z.treeBody,Z.wide),children:[/* @__PURE__ */ (0,o.jsxs)(_m,{className:R(Z.list,Z.flatList),label:C(`section.sessions`),rowKeys:[...E.length===0?[]:[`section:${Se}`],...le?te.rows(E).map(e=>`session:${e.id}`):[],...Lh(ue,te.rows),...T.length===0&&E.length===0&&r.length===0?[x?`empty:host-scope`:`empty`]:[],...te.rows(oe.rows).map(e=>`session:${e.id}`),...se||e.hasMore?[`overflow:flat`]:[]],ready:e.phase===`ready`&&m&&D===null,resetKey:`${h}/${re}/${String(le)}`,children:[/* @__PURE__ */ (0,o.jsx)(Cm,{rows:E,currentId:ae,onOpen:c,onRenameRequest:l,renderSlot:v,revealSessionId:g,onSessionRevealed:_,expanded:le,onToggle:()=>{p(Se,!le)},t:C}),/* @__PURE__ */ (0,o.jsx)(Rh,{sections:ue,currentId:ae,onOpen:c,onRenameRequest:l,renderSlot:v,revealSessionId:g,onSessionRevealed:_,setSectionExpanded:p,t:C}),(E.length>0||r.length>0||b!==void 0)&&/* @__PURE__ */ (0,o.jsx)(bm,{label:C(`section.sessions`),trailing:b}),T.length===0&&E.length===0&&r.length===0&&(x?/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Z.filterEmptyHint,"data-row-key":`empty:host-scope`,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{children:C(`hostScope.emptySessions`)}),S!==void 0&&/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Z.emptyAction,onClick:S,children:C(`hostScope.showAll`)})]}):/* @__PURE__ */ (0,o.jsx)(Nh,{rowState:n,onLeaveArchivedOnly:i,partial:e.hasMore,t:C})),/* @__PURE__ */ (0,o.jsx)(Zp,{roots:oe.rows,children:e=>{let t=D!==null&&D.pinned===e.pinned,n=t=>e.blank?`after`:t;return/* @__PURE__ */ (0,o.jsx)(lm,{node:e,currentId:ae,now:ce,onOpen:c,onRenameRequest:l,renderSlot:v,onReveal:e.id===g?()=>{_(e.id)}:void 0,drag:{start:()=>{ne.current=!1,O({accountKey:xe,sessionId:e.id,pinned:e.pinned,over:null})},active:t,marker:t&&D.over?.id===e.id?D.over.half:null,hover:t=>{O(r=>r===null?r:{...r,over:{id:e.id,half:n(t)}})},drop:t=>{D!==null&&k(D,{id:e.id,half:n(t)})},end:e=>{!e&&D?.over!==null&&D?.over!==void 0?k(D,D.over):O(null),ne.current=!1}},t:C},e.id)}}),/* @__PURE__ */ (0,o.jsx)(Om,{rowKey:`overflow:flat`,hiddenCount:oe.hiddenCount,hasMore:e.hasMore,loading:e.loading,expanded:re>10,expand:()=>ie(re+10),collapse:se?()=>ie(10):void 0,loadMoreSessions:y,t:C})]}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Z.fade})]})}function Bh({useSessions:e,useSessionStatus:t,open:n,onUnarchive:r,workspaces:i,archivedSessionIds:a,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,s.useMemo)(()=>ve(h,i,l,a,c,g,_,d),[h,i,l,a,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,o.jsxs)(`div`,{className:R(Z.treeBody,Z.wide),children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Z.list,children:[/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.searchTree,role:`tree`,"aria-label":p(`search.results.aria`),children:v.items.map(e=>/* @__PURE__ */ (0,o.jsx)(cm,{result:e,currentId:b,onOpen:n,onUnarchive:r,t:p},e.id))}),y&&/* @__PURE__ */ (0,o.jsx)(`div`,{role:`status`,"aria-label":p(`search.pending`),children:(v.items.length===0?[0,1]:[0]).map(e=>/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Z.skeletonRow,"aria-hidden":`true`,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:Z.skeletonDot}),/* @__PURE__ */ (0,o.jsxs)(`span`,{className:Z.skeletonBars,children:[/* @__PURE__ */ (0,o.jsx)(`span`,{className:Z.skeletonBar}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:R(Z.skeletonBar,Z.skeletonBarWide)})]})]},e))}),!y&&v.items.length===0&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.empty,children:p(`search.noMatches`)}),v.hasMore&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.searchStatus,children:p(`search.hasMore`,{n:d})})]}),/* @__PURE__ */ (0,o.jsx)(`span`,{className:Z.fade})]})}function Vh(e){return/* @__PURE__ */ (0,o.jsx)(ln,{browser:e,children:/* @__PURE__ */ (0,o.jsx)(Hh,{...e})})}function Hh({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:ee,useWorkspaceShortcuts:w,requestSearch:te,requestAddWorkspace:T,closeAddWorkspace:E,setDirectoryBusy:D,dismissForkError:ie,refreshSessions:ae,loadMoreSessions:oe,renderSlot:se,t:k}){let ce=C(e=>e.home),le=ee(e=>e),ue=le.find(e=>e.id===`session.search`),de=le.find(e=>e.id===`workspace.add`),fe=w(e=>e),A=r(e=>e),pe=c(e=>e.items),me=c(e=>e.canStartProjectless===!0),ge=k(`workspace.defaultName`),_e=(0,s.useMemo)(()=>pe.map(e=>({...e,title:an(e.title,ge)})),[pe,ge]),ve=c(e=>e.phase),ye=c(e=>e.state),be=c(e=>e.archivedSessionIds),Se=c(e=>e.pinnedSessionIds),Ce=c(e=>e.threadSections??Fh),we=S(e=>e),Te=l(e=>e.groupBy),j=l(e=>e.orderBy),ke=l(e=>e.archivedFilter??`default`),Ae=l(e=>e.groupExpansion),je=cn(),Me=l(e=>e.sectionExpansion),Ne=l(e=>e.sessionOrderByAccount),Pe=e=>{be.includes(e)?m():(je.selectSidebarRow(e),f(e))},Fe=()=>{u.setArchivedFilter(`default`)},Ie=ve===`ready`&&ye!==`loading`,Le=Object.values(A.byId).find(e=>(e.retainedBy.mainView??0)>0)?.id,M=Le!==void 0&&A.byId[Le]?.blank===!0?Le:void 0,Re=(0,s.useMemo)(()=>{let e=new Set(_e.flatMap(e=>e.sessionIds));return[.../* @__PURE__ */ new Set([...A.ids,...be])].filter(t=>!e.has(t))},[be,A.ids,_e]),ze=(0,s.useMemo)(()=>({pinnedSessionIds:Se,archivedSessionIds:be}),[be,Se]),Be=ke===`only`?Fh:Ce,Ve=(0,s.useMemo)(()=>({...ze,archivedFilter:ke,sectionedSessionIds:new Set(Be.flatMap(e=>e.threadIds))}),[ze,ke,Be]),He=(0,s.useMemo)(()=>he(A,be),[be,A]),Ue=(0,s.useMemo)(()=>Ee(A,Ve),[A,Ve]),We=(0,s.useMemo)(()=>_e.map(e=>{let{memberIds:t,linkedRootIds:n}=De(e.sessionIds,Ue),r=j===`updated`?O(t,Ue.summaries):ne(t,Ne[e.workspaceId],Ue.summaries,ze);return{workspace:{...e,sessionIds:re(r,M!==void 0&&t.includes(M)?M:void 0)},linkedRootIds:n}}),[M,Ue,j,ze,Ne,_e]),N=(0,s.useMemo)(()=>We.map(({workspace:e})=>e),[We]),Ge=(0,s.useMemo)(()=>new Map(We.map(({workspace:e,linkedRootIds:t})=>[e.workspaceId,t])),[We]),Ke=(0,s.useMemo)(()=>O(Re.filter(e=>Ue.rootIds.has(e)),Ue.summaries),[Ue,Re]),qe=(0,s.useMemo)(()=>{let e=He.filter(e=>Ue.rootIds.has(e));return re(j===`updated`?O(e,Ue.summaries):ne(e,Ne[xe],Ue.summaries,ze),M!==void 0&&He.includes(M)?M:void 0)},[M,He,Ue,j,ze,Ne]),Je=(0,s.useMemo)(()=>Oe(_e,A,Ve),[A,Ve,_e]),Ye=(0,s.useMemo)(()=>Object.fromEntries([...N.map(e=>[e.workspaceId,e.sessionIds]),[``,Ke],[xe,qe]]),[qe,Ke,N]);(0,s.useEffect)(()=>{ve===`ready`&&u.retainAccountKeys([``,xe,..._e.map(e=>e.workspaceId)])},[u.retainAccountKeys,ve,_e]),(0,s.useEffect)(()=>{if(A.phase!==`ready`||Ie||j!==`manual`||M===void 0)return;let e={};for(let[t,n]of Object.entries(Ye)){if(t!==`__flat_session_order__`&&ve!==`ready`)continue;let r=Ne[t]??[];n[0]===M&&r[0]!==M&&(e[t]=[M,...r.filter(e=>e!==M)])}Object.keys(e).length>0&&u.syncSessionOrders(e,Je)},[u.syncSessionOrders,Ye,M,A.phase,j,Ne,Je,ve,Ie]),(0,s.useEffect)(()=>{A.phase===`ready`&&Ie&&j===`manual`&&M!==void 0&&Object.entries(Ye).some(([e,t])=>t[0]===M&&Ne[e]?.[0]!==M)&&u.syncSessionOrders(Ye,Je)},[u.syncSessionOrders,Ye,M,A.phase,j,Ne,Je,Ie]);let Xe=(e,t)=>{u.setSessionOrder(e,t,Ye,Je)},[Ze,Qe]=(0,s.useState)(``),[$e,et]=(0,s.useState)(!1),[P,tt]=(0,s.useState)(void 0),nt=Oh(Ze).trim(),[rt,it]=(0,s.useState)({query:``,status:`idle`,items:[],hasMore:!1}),at=(0,s.useRef)(null),ot=(0,s.useRef)(null),st=fe.addRequested,ct=(0,s.useRef)(null),[lt,ut]=(0,s.useState)(!1),[dt,ft]=(0,s.useState)(()=>Xm()),pt=(0,s.useRef)(null);if(pt.current===null){let e=/* @__PURE__ */ new Set;for(let t of Object.keys(dt.perHost))t!==`local`&&t!==dt.selectedHost&&e.add(t);pt.current=e}let mt=(0,s.useCallback)(e=>{ft(e),Zm(e)},[]);(0,s.useEffect)(()=>{let e=e=>{let t=e.detail;if(!t||typeof t.hostId!=`string`||t.hostId===``||!Array.isArray(t.workspaceIds))return;let n=t.workspaceIds.filter(e=>typeof e==`string`);pt.current?.add(t.hostId),ft(e=>{let r=Gm(e,t.hostId,n);return Zm(r),r})};return window.addEventListener(Am,e),()=>{window.removeEventListener(Am,e)}},[]),(0,s.useEffect)(()=>{if(ve!==`ready`||ye!==`idle`)return;let e=window.setTimeout(()=>{let e=pt.current;if(e!==null&&e.size>0)for(let t of N){let n=t.remote?.hostId;n!==void 0&&t.remote?.state===`connected`&&e.delete(n)}let t=Fm(dt,N,e===null||e.size===0?void 0:{preserveHostKeys:e});t!==dt&&mt(t)},250);return()=>{window.clearTimeout(e)}},[dt,N,mt,ve,ye]);let ht=()=>{mt(Km())},gt=(0,s.useMemo)(()=>jm(N),[N]),_t=(0,s.useMemo)(()=>Mm(N),[N]),F=(0,s.useMemo)(()=>Pm(dt,N),[dt,N]),vt=(0,s.useMemo)(()=>gt&&Im(F,N),[gt,F,N]),yt=(0,s.useMemo)(()=>gt&&F.selectedHost!==`all`&&F.selectedHost!==`local`,[gt,F.selectedHost]),bt=(0,s.useMemo)(()=>vt?Lm(N,F):N,[vt,N,F]),xt=(0,s.useMemo)(()=>new Set(bt.map(e=>e.workspaceId)),[bt]),St=(0,s.useMemo)(()=>vt?Bm(qe.map(e=>({id:e,remote:A.byId[e]?.projectionValues?.remoteHost??void 0})),xt,N,F).map(e=>e.id):qe,[vt,qe,A.byId,xt,N,F]),Ct=(0,s.useMemo)(()=>{if(!vt)return A;let e=new Set(Bm(A.ids.map(e=>({id:e,remote:A.byId[e]?.projectionValues?.remoteHost??void 0})),xt,N,F).map(e=>e.id));return{...A,ids:A.ids.filter(t=>e.has(t))}},[vt,A,xt,N,F]),wt=(0,s.useMemo)(()=>vt?JSON.stringify(F):`all`,[vt,F]),Tt=gt?/* @__PURE__ */ (0,o.jsx)(nh,{workspaces:N,state:F,onChange:mt,t:k}):void 0,I=()=>{let e=F.selectedHost!==`all`&&F.selectedHost!==`local`?F.selectedHost:void 0;window.dispatchEvent(new CustomEvent(`codexhost:open-add-remote-workspace`,{detail:e===void 0?{}:{hostId:e}}))},L=(0,s.useRef)(!1),Et=e=>{if(be.includes(e)){m();return}let t=je.rootId(e),n=_e.find(e=>e.sessionIds.includes(t));if(vt){let e=qm(F,n,N);e!==F&&mt(e)}let r=Te===`flat`?void 0:n?.workspaceId,i=Be.find(({threadIds:e})=>e.includes(t))??(r===void 0?void 0:Be.find(({workspaceIds:e})=>e?.includes(r)===!0));i&&u.setSectionExpanded(`native-section:${i.id}`,!0),tt(e),Qe(``),et(!1),je.reveal(e),f(e)},Dt=e=>{tt(t=>t===e?void 0:t)};(0,s.useEffect)(()=>{nt!==``&&tt(void 0)},[nt]);let[Ot,kt]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(e&&Ot){let e=window.setTimeout(()=>{ot.current?.focus({preventScroll:!0}),kt(!1)},300);return()=>{window.clearTimeout(e)}}},[e,Ot]),(0,s.useEffect)(()=>{fe.searchRequest!==0&&(E(),et(!0),e?ot.current?.focus({preventScroll:!0}):(kt(!0),n()))},[fe.searchRequest]),(0,s.useEffect)(()=>{e&&$e&&!Ot&&ot.current?.focus({preventScroll:!0})},[e,$e,Ot]),(0,s.useEffect)(()=>{if(!e||!$e||Ot)return;let t=e=>{e.target instanceof Node&&at.current?.contains(e.target)!==!0&&(ot.current?.blur(),nt===``&&et(!1))};return document.addEventListener(`click`,t),()=>{document.removeEventListener(`click`,t)}},[nt,e,$e,Ot]),(0,s.useEffect)(()=>{if(nt===``){it({query:``,status:`idle`,items:[],hasMore:!1});return}let e=new AbortController;it({query:nt,status:`loading`,items:[],hasMore:!1});let t=window.setTimeout(()=>{b(nt,e.signal).then(t=>{e.signal.aborted||it({query:nt,status:`ready`,items:t.items,hasMore:t.hasMore})}).catch(()=>{e.signal.aborted||it({query:nt,status:`error`,items:[],hasMore:!1})})},250);return()=>{window.clearTimeout(t),e.abort()}},[nt,b]);let[At,jt]=(0,s.useState)(null),[Mt,Nt]=(0,s.useState)(``),[Pt,Ft]=(0,s.useState)(!1),[It,Lt]=(0,s.useState)(null),Rt=Mt.trim(),zt=At!==null&&Rt!==``&&_e.some(e=>e.workspaceId!==At.workspaceId&&e.title===Rt),Bt=Pt||Rt===``||At===null||Rt===At.storedTitle||zt,Vt=()=>{Pt||(jt(null),Lt(null))},Ht=()=>{Bt||(Ft(!0),Lt(null),h(At.workspaceId,Rt).then(()=>{Ft(!1),jt(null)}).catch(e=>{Ft(!1),Lt(e instanceof Error?e.message:String(e))}))},Ut=e=>{v(e).catch(e=>{console.warn(`session unarchive rejected:`,e)})},[Wt,Gt]=(0,s.useState)(null),[Kt,qt]=(0,s.useState)(!1),[Jt,Yt]=(0,s.useState)(null),[Xt,Zt]=(0,s.useState)(null);(0,s.useEffect)(()=>{Jt===null||_e.some(e=>e.workspaceId===Jt)||(qt(!1),Yt(null),Gt(null))},[Jt,_e]);let Qt=()=>{Kt||(Gt(null),Zt(null))},$t=()=>{
20
141
  /* v8 ignore next -- the Modal is absent without a target and its button is disabled while deleting. */
21
- ht||pt===null||(gt(!0),vt(null),bt(null),g(pt.workspaceId).then(()=>{vt(pt.workspaceId)}).catch(e=>{gt(!1),bt(e instanceof Error?e.message:String(e))}))};return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q($.root,!e&&$.rail),children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:$.sectionHeader,children:[e&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:Q($.sectionLabel,$.wide,q&&$.sectionLabelHidden),children:I(`section.sessions`)}),e&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Q($.searchSlot,q&&$.searchSlotExpanded),children:/* @__PURE__ */ (0,o.jsxs)(`div`,{ref:Ke,className:Q($.search,q&&$.searchExpanded),onClick:()=>{O(),Be(!0),qe.current?.focus()},children:[/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:I(`search`),shortcutKeys:ne?.keys,side:`bottom`,delayMs:500,disabled:q,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:$.searchButton,"aria-label":I(`search.sessions.aria`),"aria-keyshortcuts":ne?.aria,"aria-expanded":q,onClick:()=>{E()},children:/* @__PURE__ */ (0,o.jsx)(a.IconSearchOutlineRegular,{size:16})})}),/* @__PURE__ */ (0,o.jsx)(`input`,{ref:qe,className:$.searchInput,type:`text`,placeholder:I(`search.placeholder`),maxLength:500,value:Re,tabIndex:q?0:-1,onChange:e=>{ze(Xn(e.target.value))},onKeyDown:e=>{e.key===`Escape`&&(e.currentTarget.closest(`[data-phone-drawer]`)&&(e.preventDefault(),e.stopPropagation()),ze(``),Be(!1))}}),q&&/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:$.clearButton,"aria-label":I(`search.clear`),onClick:e=>{e.stopPropagation(),ze(``),Be(!1)},children:/* @__PURE__ */ (0,o.jsx)(a.IconCloseFillRegular,{})})]})}),/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Q($.headerActions,e&&q&&$.headerActionsHidden),children:[e&&/* @__PURE__ */ (0,o.jsx)(Qn,{groupBy:ge,orderBy:U,archivedFilter:_e,onGroupPick:u.setGroupBy,onOrderPick:e=>{u.setOrderBy(e,Ie,Fe)},onArchivedFilterPick:u.setArchivedFilter,t:I}),fe&&/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:I(`workspace.add`),shortcutKeys:re?.keys,side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{ref:Ye,type:`button`,className:$.iconButton,"aria-label":I(`workspace.add`),"aria-keyshortcuts":re?.aria,onClick:()=>{D()},children:/* @__PURE__ */ (0,o.jsx)(a.IconProjectAddOutlineRegular,{size:e?16:18})})})]}),/* @__PURE__ */ (0,o.jsx)(Jn,{t:I,open:Je,anchorRef:Ye,useWorkspaces:c,createWorkspace:y,useDirectoryFlow:S,renderDirectoryFlow:e=>F(`sidebar.workspaces.directoryFlow`,e),addOnly:!0,onBusyChange:M,side:`right`,onPick:e=>{O(),d(e)},onClose:()=>{O()}})]}),!e&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.search,children:/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:I(`search`),shortcutKeys:ne?.keys,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:$.searchButton,"aria-label":I(`search.sessions.aria`),"aria-keyshortcuts":ne?.aria,onClick:()=>{E()},children:/* @__PURE__ */ (0,o.jsx)(a.IconSearchOutlineRegular,{size:18})})})}),/* @__PURE__ */ (0,o.jsxs)(`div`,{className:$.listArea,children:[e&&z.phase===`pending`&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.empty,role:`status`,children:I(`sessions.loading`)}),e&&(Ue===``?ge===`flat`?/* @__PURE__ */ (0,o.jsx)(sr,{loadMoreSessions:ee,usePanelInfo:t,list:z,sessionIds:Pe,rowState:Oe,nativeSections:De,onLeaveArchivedOnly:Se,workspaceReady:Ce,animationResetKey:`${ge}/${U}/${_e}`,useSessionStatus:i,open:xe,onSessionRenameRequest:p,renderSlot:F,setSessionOrder:Le,sectionExpansion:be,setSectionExpanded:u.setSectionExpanded,revealSessionId:Ve,onSessionRevealed:Qe,t:I}):/* @__PURE__ */ (0,o.jsx)(nr,{loadMoreSessions:ee,usePanelInfo:t,list:z,shortcuts:L,useSessionStatus:i,onSessionRenameRequest:p,renderSlot:F,workspaces:je,linkedRoots:Me,ungroupedSessionIds:Ne,canStartProjectless:ae,workspaceReady:Ce,nestWorkspaces:ge===`workspace-tree`,animationResetKey:`${ge}/${U}/${_e}`,groupExpansion:ve,setGroupExpanded:u.setGroupExpanded,sectionExpansion:be,setSectionExpanded:u.setSectionExpanded,setSessionOrder:Le,rowState:Oe,nativeSections:De,onLeaveArchivedOnly:Se,startSession:d,open:xe,insertWorkspaceBefore:_,revealSessionId:Ve,onSessionRevealed:Qe,home:te,t:I,onRenameRequest:(e,t)=>{nt({workspaceId:e,storedTitle:B.find(t=>t.workspaceId===e)?.title??t}),it(t),ct(null)},onDeleteRequest:(e,t)=>{mt({workspaceId:e,title:t}),bt(null)}}):/* @__PURE__ */ (0,o.jsx)(cr,{usePanelInfo:t,useSessions:r,useSessionStatus:i,open:Ze,onUnarchive:ft,workspaces:V,archivedSessionIds:le,archivedFilter:_e,query:Ue,remote:We,resultLimit:x,t:I}))]}),e&&/* @__PURE__ */ (0,o.jsx)(Bn,{list:z,refreshSessions:P,loadMoreSessions:ee,t:I}),/* @__PURE__ */ (0,o.jsxs)(a.Modal,{open:tt!==null,onClose:J,closeLabel:I(`close`),title:I(`rename.workspace.title`),footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,disabled:at,onClick:J,children:I(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`primary`,disabled:dt,onClick:Y,children:I(`rename`)})]}),children:[/* @__PURE__ */ (0,o.jsx)(`input`,{className:$.renameInput,value:rt,"aria-label":I(`field.workspaceName`),"data-modal-autofocus":!0,disabled:at,onFocus:e=>{e.target.select()},onChange:e=>{it(e.target.value),ct(null)},onCompositionStart:()=>{Xe.current=!0},onCompositionEnd:()=>{Xe.current=!1},onKeyDown:e=>{e.key===`Enter`&&!Xe.current&&(e.preventDefault(),Y())}}),ut&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.renameError,role:`alert`,children:I(`conflict.named`,{name:lt})}),st!==null&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.renameError,role:`alert`,children:st})]}),/* @__PURE__ */ (0,o.jsxs)(a.Modal,{open:pt!==null,onClose:xt,closeLabel:I(`close`),title:I(`delete.workspace`),...pt===null?{}:{description:I(`delete.desc`,{name:pt.title})},footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,disabled:ht,onClick:xt,children:I(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,className:$.deleteAction,disabled:ht,onClick:St,children:I(`delete.workspace`)})]}),children:[ht&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.deleteStatus,role:`status`,children:I(`delete.pending`)}),yt!==null&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.renameError,role:`alert`,children:yt})]}),R.forkError!==null&&/* @__PURE__ */ (0,o.jsx)(a.Toast,{text:I(R.forkError.reason===`unavailable`?`shortcut.noCompletedTurn`:`shortcut.forkFailed`),onDone:N},R.forkError.seq)]})}function dr({sessionId:e,useArchived:t,useMenuOpenState:n,useShortcuts:r,archiveSession:i,unarchiveSession:s,t:c}){let[,l]=n(),u=r(e=>e.find(e=>e.id===`session.archive`)),d=t(t=>t.has(e));return/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{shortcut:d?void 0:u,icon:d?/* @__PURE__ */ (0,o.jsx)(a.IconUnarchiveOutlineRegular,{size:16}):/* @__PURE__ */ (0,o.jsx)(a.IconArchiveOutlineRegular,{size:16}),onSelect:()=>{l(!1),(d?s:i)(e)},children:c(d?`menu.unarchiveSession`:`menu.archiveSession`)})}function fr({sessionId:e,useArchived:t,archiveSession:n,unarchiveSession:r,t:i}){let s=t(t=>t.has(e));return/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:i(s?`actions.unarchive`:`actions.archive`),side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:q.iconButton,"aria-label":i(s?`menu.unarchiveSession`:`menu.archiveSession`),onClick:()=>{(s?r:n)(e)},children:s?/* @__PURE__ */ (0,o.jsx)(a.IconUnarchiveOutlineRegular,{size:16}):/* @__PURE__ */ (0,o.jsx)(a.IconArchiveOutlineRegular,{size:16})})})}function pr({useArchiveRequest:e,settleSessionArchive:t,stopAndArchiveSession:n,t:r}){let i=e(e=>e);return i===null?null:/* @__PURE__ */ (0,o.jsx)(mr,{request:i,stopAndArchiveSession:n,onSettle:t,t:r},i.sessionId)}function mr({request:e,stopAndArchiveSession:t,onSettle:n,t:r}){let[i,c]=(0,s.useState)(!1),[l,u]=(0,s.useState)(null),d=()=>{i||n()};return/* @__PURE__ */ (0,o.jsxs)(a.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,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,disabled:i,onClick:d,children:r(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,className:$.deleteAction,disabled:i,onClick:()=>{c(!0),u(null),t(e.sessionId,e.children).then(()=>{c(!1),n()}).catch(e=>{c(!1),u(e instanceof Error?e.message:String(e))})},children:r(`archive.confirm.action`)})]}),children:[/* @__PURE__ */ (0,o.jsxs)(`ul`,{className:$.archiveActivity,"aria-label":r(`archive.confirm.activity`),children:[e.runningThreads?.map(e=>/* @__PURE__ */ (0,o.jsx)(`li`,{children:r(`archive.confirm.thread`,{title:e.title})},e.id)),e.activity.map((e,t)=>/* @__PURE__ */ (0,o.jsx)(`li`,{children:hr(e,r)},`${e.kind}-${String(t)}`))]}),i&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.deleteStatus,role:`status`,children:r(`archive.confirm.pending`)}),l!==null&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.renameError,role:`alert`,children:l})]})}function hr(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 gr({useArchiveChildrenRequest:e,...t}){let n=e(e=>e);return n?/* @__PURE__ */ (0,o.jsx)(_r,{request:n,...t},n.sessionId):null}function _r({request:e,choose:t,dismiss:n,t:r}){let[i,c]=(0,s.useState)(!1),[l,u]=(0,s.useState)(!1),[d,f]=(0,s.useState)(!1),p=(0,s.useRef)(!1),m=async n=>{if(!p.current){p.current=!0,u(!0),f(!1);try{await t(e,n,i)}catch{f(!0)}finally{p.current=!1,u(!1)}}};return/* @__PURE__ */ (0,o.jsxs)(a.Modal,{phoneSidebar:!0,open:!0,title:r(`archive.children.title`),description:r(`archive.children.description`,{title:e.title}),closeLabel:r(`close`),onClose:()=>{p.current||n()},footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,disabled:l,onClick:()=>void m(!1),children:r(`archive.children.parentOnly`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,className:$.deleteAction,disabled:l,onClick:()=>void m(!0),children:r(`archive.children.include`,{n:e.children.length})})]}),children:[/* @__PURE__ */ (0,o.jsx)(`ul`,{className:$.archiveActivity,children:e.children.map(({id:e,title:t})=>/* @__PURE__ */ (0,o.jsx)(`li`,{children:t},e))}),/* @__PURE__ */ (0,o.jsxs)(`label`,{children:[/* @__PURE__ */ (0,o.jsx)(`input`,{type:`checkbox`,checked:i,disabled:l,onChange:({target:e})=>c(e.checked)}),r(`archive.children.remember`)]}),d&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.renameError,role:`alert`,children:r(`archive.children.preferenceFailed`)})]})}function vr(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 yr({sessionId:e,useNativeThreads:t,useSectionWorkspace:n,useMenuOpenState:r,requestMove:i,t:s}){let[,c]=r(),l=t(t=>t.has(e)),u=n(e=>e),d=u.threadSections;return!l||!d?.length||u.pinnedSessionIds.includes(e)||u.archivedSessionIds.includes(e)?null:/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{icon:/* @__PURE__ */ (0,o.jsx)(a.IconFolderCloseRegular,{}),onSelect:()=>{c(!1),i({sessionId:e,sections:d})},children:s(`menu.moveToSection`)})}function br({useThreadSectionMove:e,...t}){let n=e(e=>e);return n?/* @__PURE__ */ (0,o.jsx)(xr,{request:n,...t},n.sessionId):null}function xr({request:e,dismiss:t,move:n,t:r}){let i=e.sections.find(t=>t.threadIds.includes(e.sessionId))?.id??``,[c,l]=(0,s.useState)(i),[u,d]=(0,s.useState)(!1),[f,p]=(0,s.useState)(!1),m=(0,s.useRef)(!1),h=()=>{m.current||t()},g=async()=>{if(!(m.current||c===i)){m.current=!0,d(!0),p(!1);try{await n(e.sessionId,c||null),t()}catch{p(!0)}finally{m.current=!1,d(!1)}}};return/* @__PURE__ */ (0,o.jsxs)(a.Modal,{phoneSidebar:!0,open:!0,title:r(`menu.moveToSection`),closeLabel:r(`close`),onClose:h,footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,disabled:u,onClick:h,children:r(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`primary`,disabled:u||c===i,onClick:()=>void g(),children:r(`section.move`)})]}),children:[/* @__PURE__ */ (0,o.jsxs)(`select`,{className:$.renameInput,"aria-label":r(`section.destination`),value:c,disabled:u,"data-modal-autofocus":!0,onChange:({target:e})=>l(e.value),children:[/* @__PURE__ */ (0,o.jsx)(`option`,{value:``,children:r(`section.unsectioned`)}),e.sections.map(({id:e,name:t})=>/* @__PURE__ */ (0,o.jsx)(`option`,{value:e,children:t},e))]}),f&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:$.renameError,role:`alert`,children:r(`section.moveFailed`)})]})}function Sr({sessionId:e,useMenuOpenState:t,useShortcuts:n,forkSession:r,t:i}){let[,s]=t(),c=n(e=>e.find(e=>e.id===`session.fork`));return/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{shortcut:c,icon:/* @__PURE__ */ (0,o.jsx)(a.IconBranchOutlineRegular,{}),onSelect:()=>{s(!1),r(e)},children:i(`menu.fork`)})}function Cr({sessionId:e,useSessions:t,useMenuOpenState:n,copySessionLink:r,t:i}){let s=t(t=>{let n=t.byId[e];return n!==void 0&&x(n)!==void 0}),[,c]=n();return s?/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{icon:/* @__PURE__ */ (0,o.jsx)(a.IconCopyOutlineRegular,{}),onSelect:()=>{c(!1),r(e)},children:i(`menu.copySessionLink`)}):null}function wr({sessionId:e,usePinned:t,useArchived:n}){return{pinned:t(t=>t.has(e)),archived:n(t=>t.has(e))}}function Tr(e){let{sessionId:t,useMenuOpenState:n,pinSession:r,unpinSession:i,t:s}=e,[,c]=n(),{pinned:l,archived:u}=wr(e);return u?null:/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{icon:l?/* @__PURE__ */ (0,o.jsx)(a.IconPinFillRegular,{}):/* @__PURE__ */ (0,o.jsx)(a.IconPinOutlineRegular,{}),onSelect:()=>{c(!1),(l?i:r)(t)},children:s(l?`menu.unpinSession`:`menu.pinSession`)})}function Er(e){let{sessionId:t,pinSession:n,unpinSession:r,t:i}=e,{pinned:s,archived:c}=wr(e);return c?null:/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:i(s?`actions.unpin`:`actions.pin`),side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:q.iconButton,"aria-label":i(s?`menu.unpinSession`:`menu.pinSession`),onClick:()=>{(s?r:n)(t)},children:s?/* @__PURE__ */ (0,o.jsx)(a.IconPinFillRegular,{size:16}):/* @__PURE__ */ (0,o.jsx)(a.IconPinOutlineRegular,{size:16})})})}function Dr({sessionId:e,displayTitle:t,useMenuOpenState:n,useShortcuts:r,requestSessionRename:i,t:s}){let[,c]=n(),l=r(e=>e.find(e=>e.id===`session.rename`));return/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{shortcut:l,icon:/* @__PURE__ */ (0,o.jsx)(a.IconEditOutlineRegular,{}),onSelect:()=>{c(!1),i(e,t)},children:s(`rename`)})}function Or({useRenameRequest:e,settleSessionRename:t,renameSession:n,t:r}){let i=e(e=>e);return i===null?null:/* @__PURE__ */ (0,o.jsx)(kr,{request:i,renameSession:n,onSettle:t,t:r},i.sessionId)}function kr({request:e,renameSession:t,onSettle:n,t:r}){let[i,c]=(0,s.useState)(e.currentTitle),[l,u]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null),p=(0,s.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,o.jsxs)(a.Modal,{phoneSidebar:!0,open:!0,onClose:g,closeLabel:r(`close`),title:r(`rename.session.title`),footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,disabled:l,onClick:g,children:r(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`primary`,disabled:h,onClick:_,children:r(`rename`)})]}),children:[/* @__PURE__ */ (0,o.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,o.jsx)(`div`,{className:$.renameError,role:`alert`,children:d})]})}let Ar=6e3;function jr({useToast:e,useStore:t,dismissToast:n,undoArchive:r,showArchived:i,t:s}){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,o.jsx)(a.Toast,{text:c.failedChildren?s(`archive.children.partial`,{n:c.failedChildren}):s(c.kind===`archived`?`toast.archived`:`toast.stoppedAndArchived`),...c.failedChildren?{icon:/* @__PURE__ */ (0,o.jsx)(a.IconWarningOutlineRegular,{})}:{tone:`success`},holdMs:Ar,actions:[{label:s(`toast.archivedUndo`),onClick:()=>{n(),r(e)}},...l?[]:[{prefix:s(`toast.archivedOr`),label:s(`toast.archivedFilter`),onClick:()=>{n(),i()}}]],onDone:n},`toast-${String(c.seq)}`)}return c.kind===`createFailed`||c.kind===`forkFailed`?/* @__PURE__ */ (0,o.jsx)(a.Toast,{text:s(c.kind===`forkFailed`?`toast.forkFailed`:`toast.createFailed`,{message:c.message}),icon:/* @__PURE__ */ (0,o.jsx)(a.IconWarningOutlineRegular,{}),holdMs:Ar,onDone:n},`toast-${String(c.seq)}`):/* @__PURE__ */ (0,o.jsx)(a.Toast,{text:Mr(c,s),icon:/* @__PURE__ */ (0,o.jsx)(a.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`);
142
+ Kt||Wt===null||(qt(!0),Yt(null),Zt(null),g(Wt.workspaceId).then(()=>{Yt(Wt.workspaceId)}).catch(e=>{qt(!1),Zt(e instanceof Error?e.message:String(e))}))};return/* @__PURE__ */ (0,o.jsxs)(`div`,{className:R(Z.root,!e&&Z.rail),children:[/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Z.sectionHeader,children:[e&&/* @__PURE__ */ (0,o.jsx)(`span`,{className:R(Z.sectionLabel,Z.wide,$e&&Z.sectionLabelHidden),children:k(`section.sessions`)}),e&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:R(Z.searchSlot,$e&&Z.searchSlotExpanded),children:/* @__PURE__ */ (0,o.jsxs)(`div`,{ref:at,className:R(Z.search,$e&&Z.searchExpanded),onClick:()=>{E(),et(!0),ot.current?.focus()},children:[/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:k(`search`),shortcutKeys:ue?.keys,side:`bottom`,delayMs:500,disabled:$e,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Z.searchButton,"aria-label":k(`search.sessions.aria`),"aria-keyshortcuts":ue?.aria,"aria-expanded":$e,onClick:()=>{te()},children:/* @__PURE__ */ (0,o.jsx)(a.IconSearchOutlineRegular,{size:16})})}),/* @__PURE__ */ (0,o.jsx)(`input`,{ref:ot,className:Z.searchInput,type:`text`,placeholder:k(`search.placeholder`),maxLength:500,value:Ze,tabIndex:$e?0:-1,onChange:e=>{Qe(Oh(e.target.value))},onKeyDown:e=>{e.key===`Escape`&&(e.currentTarget.closest(`[data-phone-drawer]`)&&(e.preventDefault(),e.stopPropagation()),Qe(``),et(!1))}}),$e&&/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Z.clearButton,"aria-label":k(`search.clear`),onClick:e=>{e.stopPropagation(),Qe(``),et(!1)},children:/* @__PURE__ */ (0,o.jsx)(a.IconCloseFillRegular,{})})]})}),/* @__PURE__ */ (0,o.jsxs)(`div`,{className:R(Z.headerActions,e&&$e&&Z.headerActionsHidden),children:[e&&/* @__PURE__ */ (0,o.jsx)(Ah,{groupBy:Te,orderBy:j,archivedFilter:ke,onGroupPick:u.setGroupBy,onOrderPick:e=>{u.setOrderBy(e,Ye,Je)},onArchivedFilterPick:u.setArchivedFilter,t:k}),e&&_t?we?/* @__PURE__ */ (0,o.jsx)(a.Menu,{phoneSidebarTitle:k(`workspace.add`),open:lt,onClose:()=>{ut(!1)},items:[{id:`add-local`,label:k(`workspace.addLocal`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconFolderCloseRegular,{})},{id:`add-remote`,label:k(`workspace.addRemote`),icon:/* @__PURE__ */ (0,o.jsx)(a.IconGlobeOutlineRegular,{})}],onSelect:e=>{ut(!1),e===`add-local`?T():e===`add-remote`&&I()},align:`end`,dense:!0,portal:!0,anchor:/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:k(`workspace.add`),shortcutKeys:de?.keys,side:`bottom`,delayMs:500,disabled:lt,children:/* @__PURE__ */ (0,o.jsx)(`button`,{ref:ct,type:`button`,className:Z.iconButton,"aria-label":k(`workspace.add`),"aria-keyshortcuts":de?.aria,"aria-haspopup":`menu`,"aria-expanded":lt,onClick:()=>{ut(e=>!e)},children:/* @__PURE__ */ (0,o.jsx)(a.IconProjectAddOutlineRegular,{size:16})})})}):/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:k(`workspace.addRemote`),side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{ref:ct,type:`button`,className:Z.iconButton,"aria-label":k(`workspace.addRemote`),onClick:I,children:/* @__PURE__ */ (0,o.jsx)(a.IconProjectAddOutlineRegular,{size:16})})}):we&&/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:k(`workspace.add`),shortcutKeys:de?.keys,side:`bottom`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{ref:ct,type:`button`,className:Z.iconButton,"aria-label":k(`workspace.add`),"aria-keyshortcuts":de?.aria,onClick:()=>{T()},children:/* @__PURE__ */ (0,o.jsx)(a.IconProjectAddOutlineRegular,{size:e?16:18})})})]}),/* @__PURE__ */ (0,o.jsx)(Eh,{t:k,open:st,anchorRef:ct,useWorkspaces:c,createWorkspace:y,useDirectoryFlow:S,renderDirectoryFlow:e=>se(`sidebar.workspaces.directoryFlow`,e),addOnly:!0,onBusyChange:D,side:`right`,onPick:e=>{E(),d(e)},onClose:()=>{E()}})]}),!e&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.search,children:/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:k(`search`),shortcutKeys:ue?.keys,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:Z.searchButton,"aria-label":k(`search.sessions.aria`),"aria-keyshortcuts":ue?.aria,onClick:()=>{te()},children:/* @__PURE__ */ (0,o.jsx)(a.IconSearchOutlineRegular,{size:18})})})}),/* @__PURE__ */ (0,o.jsxs)(`div`,{className:Z.listArea,children:[e&&A.phase===`pending`&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.empty,role:`status`,children:k(`sessions.loading`)}),e&&(nt===``?Te===`flat`?/* @__PURE__ */ (0,o.jsx)(zh,{loadMoreSessions:oe,usePanelInfo:t,list:Ct,sessionIds:St,rowState:Ve,nativeSections:Be,onLeaveArchivedOnly:Fe,workspaceReady:Ie,animationResetKey:`${Te}/${j}/${ke}/${wt}`,useSessionStatus:i,open:Pe,onSessionRenameRequest:p,renderSlot:se,setSessionOrder:Xe,sectionExpansion:Me,setSectionExpanded:u.setSectionExpanded,revealSessionId:P,onSessionRevealed:Dt,hostScopeFilterControl:Tt,hostScopeFiltered:vt,onResetHostScope:ht,t:k}):/* @__PURE__ */ (0,o.jsx)(Ph,{loadMoreSessions:oe,usePanelInfo:t,list:Ct,shortcuts:le,useSessionStatus:i,onSessionRenameRequest:p,renderSlot:se,workspaces:bt,linkedRoots:Ge,ungroupedSessionIds:Ke,canStartProjectless:me,workspaceReady:Ie,nestWorkspaces:Te===`workspace-tree`,animationResetKey:`${Te}/${j}/${ke}/${wt}`,groupExpansion:Ae,setGroupExpanded:u.setGroupExpanded,sectionExpansion:Me,setSectionExpanded:u.setSectionExpanded,setSessionOrder:Xe,rowState:Ve,nativeSections:Be,onLeaveArchivedOnly:Fe,startSession:d,open:Pe,insertWorkspaceBefore:_,revealSessionId:P,onSessionRevealed:Dt,hostScopeFilterControl:Tt,hostScopeFiltered:vt,singleRemoteHostScoped:yt,onResetHostScope:ht,home:ce,t:k,onRenameRequest:(e,t)=>{jt({workspaceId:e,storedTitle:pe.find(t=>t.workspaceId===e)?.title??t}),Nt(t),Lt(null)},onDeleteRequest:(e,t)=>{Gt({workspaceId:e,title:t}),Zt(null)}}):/* @__PURE__ */ (0,o.jsx)(Bh,{usePanelInfo:t,useSessions:r,useSessionStatus:i,open:Et,onUnarchive:Ut,workspaces:_e,archivedSessionIds:be,archivedFilter:ke,query:nt,remote:rt,resultLimit:x,t:k}))]}),e&&/* @__PURE__ */ (0,o.jsx)(Tm,{list:A,refreshSessions:ae,loadMoreSessions:oe,t:k}),/* @__PURE__ */ (0,o.jsxs)(a.Modal,{open:At!==null,onClose:Vt,closeLabel:k(`close`),title:k(`rename.workspace.title`),footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,disabled:Pt,onClick:Vt,children:k(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`primary`,disabled:Bt,onClick:Ht,children:k(`rename`)})]}),children:[/* @__PURE__ */ (0,o.jsx)(`input`,{className:Z.renameInput,value:Mt,"aria-label":k(`field.workspaceName`),"data-modal-autofocus":!0,disabled:Pt,onFocus:e=>{e.target.select()},onChange:e=>{Nt(e.target.value),Lt(null)},onCompositionStart:()=>{L.current=!0},onCompositionEnd:()=>{L.current=!1},onKeyDown:e=>{e.key===`Enter`&&!L.current&&(e.preventDefault(),Ht())}}),zt&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.renameError,role:`alert`,children:k(`conflict.named`,{name:Rt})}),It!==null&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.renameError,role:`alert`,children:It})]}),/* @__PURE__ */ (0,o.jsxs)(a.Modal,{open:Wt!==null,onClose:Qt,closeLabel:k(`close`),title:k(`delete.workspace`),...Wt===null?{}:{description:k(`delete.desc`,{name:Wt.title})},footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,disabled:Kt,onClick:Qt,children:k(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,className:Z.deleteAction,disabled:Kt,onClick:$t,children:k(`delete.workspace`)})]}),children:[Kt&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.deleteStatus,role:`status`,children:k(`delete.pending`)}),Xt!==null&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.renameError,role:`alert`,children:Xt})]}),fe.forkError!==null&&/* @__PURE__ */ (0,o.jsx)(a.Toast,{text:k(fe.forkError.reason===`unavailable`?`shortcut.noCompletedTurn`:`shortcut.forkFailed`),onDone:ie},fe.forkError.seq)]})}function Uh({sessionId:e,useArchived:t,useMenuOpenState:n,useShortcuts:r,archiveSession:i,unarchiveSession:s,t:c}){let[,l]=n(),u=r(e=>e.find(e=>e.id===`session.archive`)),d=t(t=>t.has(e));return/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{shortcut:d?void 0:u,icon:d?/* @__PURE__ */ (0,o.jsx)(a.IconUnarchiveOutlineRegular,{size:16}):/* @__PURE__ */ (0,o.jsx)(a.IconArchiveOutlineRegular,{size:16}),onSelect:()=>{l(!1),(d?s:i)(e)},children:c(d?`menu.unarchiveSession`:`menu.archiveSession`)})}function Wh({sessionId:e,useArchived:t,archiveSession:n,unarchiveSession:r,t:i}){let s=t(t=>t.has(e));return/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:i(s?`actions.unarchive`:`actions.archive`),side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:P.iconButton,"aria-label":i(s?`menu.unarchiveSession`:`menu.archiveSession`),onClick:()=>{(s?r:n)(e)},children:s?/* @__PURE__ */ (0,o.jsx)(a.IconUnarchiveOutlineRegular,{size:16}):/* @__PURE__ */ (0,o.jsx)(a.IconArchiveOutlineRegular,{size:16})})})}function Gh({useArchiveRequest:e,settleSessionArchive:t,stopAndArchiveSession:n,t:r}){let i=e(e=>e);return i===null?null:/* @__PURE__ */ (0,o.jsx)(Kh,{request:i,stopAndArchiveSession:n,onSettle:t,t:r},i.sessionId)}function Kh({request:e,stopAndArchiveSession:t,onSettle:n,t:r}){let[i,c]=(0,s.useState)(!1),[l,u]=(0,s.useState)(null),d=()=>{i||n()};return/* @__PURE__ */ (0,o.jsxs)(a.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,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,disabled:i,onClick:d,children:r(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,className:Z.deleteAction,disabled:i,onClick:()=>{c(!0),u(null),t(e.sessionId,e.children).then(()=>{c(!1),n()}).catch(e=>{c(!1),u(e instanceof Error?e.message:String(e))})},children:r(`archive.confirm.action`)})]}),children:[/* @__PURE__ */ (0,o.jsxs)(`ul`,{className:Z.archiveActivity,"aria-label":r(`archive.confirm.activity`),children:[e.runningThreads?.map(e=>/* @__PURE__ */ (0,o.jsx)(`li`,{children:r(`archive.confirm.thread`,{title:e.title})},e.id)),e.activity.map((e,t)=>/* @__PURE__ */ (0,o.jsx)(`li`,{children:qh(e,r)},`${e.kind}-${String(t)}`))]}),i&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.deleteStatus,role:`status`,children:r(`archive.confirm.pending`)}),l!==null&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.renameError,role:`alert`,children:l})]})}function qh(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 Jh({useArchiveChildrenRequest:e,...t}){let n=e(e=>e);return n?/* @__PURE__ */ (0,o.jsx)(Yh,{request:n,...t},n.sessionId):null}function Yh({request:e,choose:t,dismiss:n,t:r}){return/* @__PURE__ */ (0,o.jsx)(a.Modal,{phoneSidebar:!0,open:!0,title:r(`archive.children.title`),description:r(`archive.children.description`,{title:e.title}),closeLabel:r(`close`),onClose:n,footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,onClick:()=>t(e,!1),children:r(`archive.children.parentOnly`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,className:Z.deleteAction,onClick:()=>t(e,!0),children:r(`archive.children.include`,{n:e.children.length})})]}),children:/* @__PURE__ */ (0,o.jsx)(`ul`,{className:Z.archiveActivity,children:e.children.map(({id:e,title:t})=>/* @__PURE__ */ (0,o.jsx)(`li`,{children:t},e))})})}function Xh(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 Zh({sessionId:e,useNativeThreads:t,useSectionWorkspace:n,useMenuOpenState:r,requestMove:i,t:s}){let[,c]=r(),l=t(t=>t.has(e)),u=n(e=>e),d=u.threadSections;return!l||!d?.length||u.pinnedSessionIds.includes(e)||u.archivedSessionIds.includes(e)?null:/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{icon:/* @__PURE__ */ (0,o.jsx)(a.IconFolderCloseRegular,{}),onSelect:()=>{c(!1),i({sessionId:e,sections:d})},children:s(`menu.moveToSection`)})}function Qh({useThreadSectionMove:e,...t}){let n=e(e=>e);return n?/* @__PURE__ */ (0,o.jsx)($h,{request:n,...t},n.sessionId):null}function $h({request:e,dismiss:t,move:n,t:r}){let i=e.sections.find(t=>t.threadIds.includes(e.sessionId))?.id??``,[c,l]=(0,s.useState)(i),[u,d]=(0,s.useState)(!1),[f,p]=(0,s.useState)(!1),m=(0,s.useRef)(!1),h=()=>{m.current||t()},g=async()=>{if(!(m.current||c===i)){m.current=!0,d(!0),p(!1);try{await n(e.sessionId,c||null),t()}catch{p(!0)}finally{m.current=!1,d(!1)}}};return/* @__PURE__ */ (0,o.jsxs)(a.Modal,{phoneSidebar:!0,open:!0,title:r(`menu.moveToSection`),closeLabel:r(`close`),onClose:h,footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,disabled:u,onClick:h,children:r(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`primary`,disabled:u||c===i,onClick:()=>void g(),children:r(`section.move`)})]}),children:[/* @__PURE__ */ (0,o.jsxs)(`select`,{className:Z.renameInput,"aria-label":r(`section.destination`),value:c,disabled:u,"data-modal-autofocus":!0,onChange:({target:e})=>l(e.value),children:[/* @__PURE__ */ (0,o.jsx)(`option`,{value:``,children:r(`section.unsectioned`)}),e.sections.map(({id:e,name:t})=>/* @__PURE__ */ (0,o.jsx)(`option`,{value:e,children:t},e))]}),f&&/* @__PURE__ */ (0,o.jsx)(`div`,{className:Z.renameError,role:`alert`,children:r(`section.moveFailed`)})]})}function eg({sessionId:e,useMenuOpenState:t,useShortcuts:n,forkSession:r,t:i}){let[,s]=t(),c=n(e=>e.find(e=>e.id===`session.fork`));return/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{shortcut:c,icon:/* @__PURE__ */ (0,o.jsx)(a.IconBranchOutlineRegular,{}),onSelect:()=>{s(!1),r(e)},children:i(`menu.fork`)})}function tg({sessionId:e,useSessions:t,useMenuOpenState:n,copySessionLink:r,t:i}){let s=t(t=>{let n=t.byId[e];return n!==void 0&&S(n)!==void 0}),[,c]=n();return s?/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{icon:/* @__PURE__ */ (0,o.jsx)(a.IconCopyOutlineRegular,{}),onSelect:()=>{c(!1),r(e)},children:i(`menu.copySessionLink`)}):null}function ng({sessionId:e,usePinned:t,useArchived:n}){return{pinned:t(t=>t.has(e)),archived:n(t=>t.has(e))}}function rg(e){let{sessionId:t,useMenuOpenState:n,pinSession:r,unpinSession:i,t:s}=e,[,c]=n(),{pinned:l,archived:u}=ng(e);return u?null:/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{icon:l?/* @__PURE__ */ (0,o.jsx)(a.IconPinFillRegular,{}):/* @__PURE__ */ (0,o.jsx)(a.IconPinOutlineRegular,{}),onSelect:()=>{c(!1),(l?i:r)(t)},children:s(l?`menu.unpinSession`:`menu.pinSession`)})}function ig(e){let{sessionId:t,pinSession:n,unpinSession:r,t:i}=e,{pinned:s,archived:c}=ng(e);return c?null:/* @__PURE__ */ (0,o.jsx)(a.Tooltip,{label:i(s?`actions.unpin`:`actions.pin`),side:`bottom`,align:`end`,delayMs:500,children:/* @__PURE__ */ (0,o.jsx)(`button`,{type:`button`,className:P.iconButton,"aria-label":i(s?`menu.unpinSession`:`menu.pinSession`),onClick:()=>{(s?r:n)(t)},children:s?/* @__PURE__ */ (0,o.jsx)(a.IconPinFillRegular,{size:16}):/* @__PURE__ */ (0,o.jsx)(a.IconPinOutlineRegular,{size:16})})})}function ag({sessionId:e,displayTitle:t,useMenuOpenState:n,useShortcuts:r,requestSessionRename:i,t:s}){let[,c]=n(),l=r(e=>e.find(e=>e.id===`session.rename`));return/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{shortcut:l,icon:/* @__PURE__ */ (0,o.jsx)(a.IconEditOutlineRegular,{}),onSelect:()=>{c(!1),i(e,t)},children:s(`rename`)})}function og({useRenameRequest:e,settleSessionRename:t,renameSession:n,t:r}){let i=e(e=>e);return i===null?null:/* @__PURE__ */ (0,o.jsx)(sg,{request:i,renameSession:n,onSettle:t,t:r},i.sessionId)}function sg({request:e,renameSession:t,onSettle:n,t:r}){let[i,c]=(0,s.useState)(e.currentTitle),[l,u]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null),p=(0,s.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,o.jsxs)(a.Modal,{phoneSidebar:!0,open:!0,onClose:g,closeLabel:r(`close`),title:r(`rename.session.title`),footer:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`outline`,disabled:l,onClick:g,children:r(`cancel`)}),/* @__PURE__ */ (0,o.jsx)(a.Button,{variant:`primary`,disabled:h,onClick:_,children:r(`rename`)})]}),children:[/* @__PURE__ */ (0,o.jsx)(`input`,{className:Z.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,o.jsx)(`div`,{className:Z.renameError,role:`alert`,children:d})]})}let cg=6e3;function lg({useToast:e,useStore:t,dismissToast:n,undoArchive:r,showArchived:i,t:s}){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,o.jsx)(a.Toast,{text:c.failedChildren?s(`archive.children.partial`,{n:c.failedChildren}):s(c.kind===`archived`?`toast.archived`:`toast.stoppedAndArchived`),...c.failedChildren?{icon:/* @__PURE__ */ (0,o.jsx)(a.IconWarningOutlineRegular,{})}:{tone:`success`},holdMs:cg,actions:[{label:s(`toast.archivedUndo`),onClick:()=>{n(),r(e)}},...l?[]:[{prefix:s(`toast.archivedOr`),label:s(`toast.archivedFilter`),onClick:()=>{n(),i()}}]],onDone:n},`toast-${String(c.seq)}`)}return c.kind===`createFailed`||c.kind===`forkFailed`?/* @__PURE__ */ (0,o.jsx)(a.Toast,{text:s(c.kind===`forkFailed`?`toast.forkFailed`:`toast.createFailed`,{message:c.message}),icon:/* @__PURE__ */ (0,o.jsx)(a.IconWarningOutlineRegular,{}),holdMs:cg,onDone:n},`toast-${String(c.seq)}`):/* @__PURE__ */ (0,o.jsx)(a.Toast,{text:ug(c,s),icon:/* @__PURE__ */ (0,o.jsx)(a.IconWarningOutlineRegular,{}),onDone:n},`toast-${String(c.seq)}`)}function ug(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
143
  /* v8 ignore next 2 -- closed-union backstop; only reached if a notice kind is forged */
23
- default:return _(e)}}let Nr={"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":`归档会话`,"archive.children.title":`归档父会话`,"archive.children.description":`选择是否同时归档「{title}」下的全部子会话。`,"archive.children.parentOnly":`仅归档父会话`,"archive.children.include":`同时归档全部 {n} 个子会话`,"archive.children.remember":`记住我的选择`,"archive.children.partial":`父会话已归档,{n} 个子会话未归档。`,"archive.children.preference":`归档父会话时`,"archive.children.ask":`每次询问`,"archive.children.always":`总是归档子会话`,"archive.children.never":`从不归档子会话`,"archive.children.preferenceFailed":`无法保存归档偏好。`,"menu.moveToSection":`移动到分区`,"section.destination":`目标分区`,"section.unsectioned":`无分区`,"section.move":`移动`,"section.moveFailed":`无法移动会话。请刷新后重试。`,"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}前`},Pr={"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`,"archive.children.title":`Archive parent session`,"archive.children.description":`Choose whether to also archive all child sessions of “{title}”.`,"archive.children.parentOnly":`Archive parent only`,"archive.children.include":`Also archive all {n} child sessions`,"archive.children.remember":`Remember my choice`,"archive.children.partial":`Parent archived. {n} child sessions could not be archived.`,"archive.children.preference":`When archiving a parent session`,"archive.children.ask":`Ask each time`,"archive.children.always":`Always archive child sessions`,"archive.children.never":`Never archive child sessions`,"archive.children.preferenceFailed":`Could not save the archive preference.`,"menu.moveToSection":`Move to section`,"section.destination":`Destination section`,"section.unsectioned":`No section`,"section.move":`Move`,"section.moveFailed":`Could not move the session. Refresh and try again.`,"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 Fr(e,t,n=!1){let r=/* @__PURE__ */ new Map;for(let t of Object.values(e.byId)){if(n&&!Ir(t))continue;let i=re(t,e)??(n?t.projectionValues?.archiveForkParent:null);if(!i)continue;let a=r.get(i)??[];a.push(t.id),r.set(i,a)}let i=/* @__PURE__ */ new Set([t]),a=[...r.get(t)??[]];for(let e=a.pop();e!==void 0;e=a.pop())i.has(e)||(i.add(e),a.push(...r.get(e)??[]));return i.delete(t),i}function Ir(e){return e!==void 0&&!e.blank&&e.origin!==`subagent`&&!e.projectionValues?.remoteHost&&e.projectionValues?.threadTreeParent!==void 0}function Lr(e,t,n){let r=[];for(let i of Fr(e,t,!0)){let t=f(i),a=e.byId[t];!n.has(t)&&a&&r.push({id:t,title:a.displayTitle})}return r}function Rr(e,t,n=Fr(e,t)){let r=[t,...n],i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Map;for(let t=r.pop();t!==void 0;t=r.pop()){if(i.has(t))continue;i.add(t);let n=e.projectionsBySession[f(t)]?.values.subagentCatalog??[];for(let t of n)e.byId[t.id]?.running&&a.set(t.id,{id:t.id,...t.label===void 0?{}:{label:t.label}}),r.push(t.id)}return[...a.values()]}let zr=()=>!1,Br=()=>()=>{};function Vr(e){let t=(0,a.usePhoneSidebar)();return t!==null&&!t.open?null:/* @__PURE__ */ (0,o.jsx)(Hr,{...e,closeDrawer:t?.close},e.sessionId)}function Hr({sessionId:e,prepareDraftReference:t,closeDrawer:n,useMenuOpenState:r,t:i}){let[c]=(0,s.useState)(()=>t(e)),l=(0,s.useSyncExternalStore)(c?.subscribe??Br,c?.getSnapshot??zr),u=(0,s.useRef)(!1),[d,f]=(0,s.useState)(!1),[,p]=r();return c===void 0?null:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{icon:/* @__PURE__ */ (0,o.jsx)(a.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,o.jsx)(`div`,{role:`status`,children:i(`menu.referenceSessionFailed`)})]})}let Ur=`workspace`,Wr=[`slots`,`sessions`,`workspaces`,`locale`,`remote`,`remote.directoryPicker`,`layout`,`shortcuts`,`configForms`];function Gr(e){let t=e.get(`sessions`),n=e.get(`workspaces`),i=fe(),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 De(e,e.remote.directoryPicker,n,t,a.actions,f),m=Vt(e);At(e,p,m),e.slots.provideRoot({hooks:{workspaces:n.list}}),e.effect(()=>e.locale.register(Ur,{zh:Nr,en:Pr}),`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=vr(n.list,e=>new Set(e.pinnedSessionIds)),T=vr(n.list,e=>new Set(e.archivedSessionIds)),E=vr(h.state,e=>e.renameTarget),D=(0,r.createSnapshotStore)(null),O=(0,r.createSnapshotStore)(null),k=h.rename,A=e=>{p.unarchiveSession(e).catch(e=>{f({kind:`unarchiveFailed`,message:e instanceof Error?e.message:String(e)})})},j=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)},M=vr(t.list,e=>new Set(Object.values(e.byId).filter(e=>!e.blank&&e.origin!==`subagent`&&!e.projectionValues?.remoteHost&&e.projectionValues?.harnessIdentity?.id===`codex`).map(e=>e.id))),N=(0,r.createSnapshotStore)(null),P=()=>({hooks:{nativeThreads:M,sectionWorkspace:n.list},requestMove:e=>N.set(e)}),ee=()=>({hooks:{threadSectionMove:N},dismiss:()=>N.set(null),move:(e,t)=>n.moveSessionToSection?n.moveSessionToSection(e,t):Promise.reject(/* @__PURE__ */ Error(`Section moves are unavailable`))}),F=()=>({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)})})}}),I=async(e,r,i=!1)=>{await p.archiveSession(e,{stopActivity:i});let a=0;for(let e of r)if(!n.list.getSnapshot().archivedSessionIds.includes(e))try{let n=t.list.getSnapshot();if(n.byId[e]?.running||Rr(n,e,[]).length)throw Error(`Child Session is active`);await p.archiveSession(e)}catch{a++}f({kind:i?`stoppedAndArchived`:`archived`,sessionId:e,failedChildren:a})},te=(e,n)=>{let r=t.list.getSnapshot(),i=r.byId[e],a=i?.displayTitle??e,o=Rr(r,e,[]);i?.running||o.length>0?D.set({sessionId:e,displayTitle:a,children:n,activity:o.length?[{kind:`subagent`,items:o}]:[],...i?.running?{runningThreads:[{id:e,title:a}]}:{}}):I(e,n).catch(t=>{let r=Kr(t);r===void 0?f({kind:`archiveFailed`,message:t instanceof Error?t.message:String(t)}):D.set({sessionId:e,displayTitle:a,activity:r,children:n})})},L=()=>({hooks:{archived:T},archiveSession:e=>{let n=m.getSnapshot().value?.archiveChildren??`ask`,r=t.list.getSnapshot(),i=Lr(r,e,T.getSnapshot());!i.length||n!==`ask`?te(e,n===`always`?i.map(({id:e})=>e):[]):O.set({sessionId:e,title:r.byId[e]?.displayTitle??e,children:i})},unarchiveSession:A});u(e,p,h,L().archiveSession);let ne=()=>({hooks:{archiveChildrenRequest:O},dismiss:()=>O.set(null),async choose(e,t,n){if(O.getSnapshot()===e){if(n&&!await m.set(`archiveChildren`,t?`always`:`never`))throw Error(`Archive preference could not be saved`);O.getSnapshot()===e&&(O.set(null),te(e.sessionId,t?e.children.map(({id:e})=>e):[]))}}}),re=()=>({hooks:{archiveRequest:D},settleSessionArchive:()=>{D.set(null)},stopAndArchiveSession:(e,t=[])=>I(e,t,!0)}),R=()=>({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)})})}}),z=()=>({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`})}})()}}),ie=()=>({requestSessionRename:k}),B=()=>({hooks:{renameRequest:E},settleSessionRename:h.closeRename,renameSession:j}),ae=()=>({hooks:{toast:s},dismissToast:()=>{s.set(null)},undoArchive:A,showArchived:()=>{a.actions.setArchivedFilter(`show`)}}),oe=()=>({startSession:e=>{p.startSession(e)},open:C,markCompletionsRead:t=>{e.get(`uiSession`)?.markCompletionsRead(t)},searchSessions:g,refreshSessions:()=>{t.refresh()},loadMoreSessions:()=>{t.loadMore()},searchResultLimit:t.searchResultLimit,requestSessionRename:k,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}}),V=()=>({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:oe,locale:Ur},lr)),e.slots.inject(`sidebar.workspaces.session.menu.item`,function*(){yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`pin`,order:100,locale:Ur,inject:F},Tr),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`move-to-section`,order:150,locale:Ur,inject:P},yr),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`rename`,order:200,locale:Ur,inject:ie},Dr),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`fork`,order:300,locale:Ur,inject:R},Sr),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`copy-session-link`,order:350,locale:Ur,inject:z},Cr),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`archive`,order:400,locale:Ur,inject:L},dr)}),e.slots.inject(`sidebar.workspaces.session.row.action`,function*(){yield e.slots.register({name:`sidebar.workspaces.session.row.action`,id:`archive`,order:100,locale:Ur,inject:L},fr),yield e.slots.register({name:`sidebar.workspaces.session.row.action`,id:`pin`,order:200,locale:Ur,inject:F},Er)}),e.slots.inject(`shell.overlay`,function*(){yield e.slots.register({name:`shell.overlay`,id:`workspace.move-to-section`,locale:Ur,inject:ee},br),yield e.slots.register({name:`shell.overlay`,id:`workspace.session-rename`,locale:Ur,inject:B},Or),yield e.slots.register({name:`shell.overlay`,id:`workspace.session-archive`,locale:Ur,inject:re},pr),yield e.slots.register({name:`shell.overlay`,id:`workspace.archive-children`,locale:Ur,inject:ne},gr),yield e.slots.register({name:`shell.overlay`,id:`workspace.row-toast`,locale:Ur,store:o,inject:ae},jr)}),e.slots.inject(`conversation.hero.workspace`,()=>e.slots.register({name:`conversation.hero.workspace`,children:{"conversation.hero.workspace.directoryFlow":{kind:`single`,scope:`root`}},inject:V,locale:Ur},Yn))}function Kr(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=Vr,n.apply=Gr,n.inject=Wr,t.exports}});
144
+ default:return v(e)}}let dg={"host.local":`本机`,"host.thisComputer":`此计算机`,"host.connected":`已连接`,"host.connecting":`连接中`,"host.disconnected":`未连接`,"heroPicker.location.aria":`选择工作位置:{current}`,"heroPicker.location.placeholder":`工作位置`,"heroPicker.location.empty":`无匹配位置`,"heroPicker.location.connectRemote":`连接远程主机…`,"heroPicker.location.manageRemote":`管理远程主机`,"heroPicker.project.aria":`选择项目:{current}`,"heroPicker.project.choose":`选择项目`,"heroPicker.project.noProject":`不选择项目`,"heroPicker.project.placeholder":`搜索项目`,"heroPicker.project.empty":`该位置暂无项目`,"heroPicker.project.noMatches":`无匹配项目`,"heroPicker.project.new":`新建项目`,"hostScope.allShort":`全部`,"hostScope.allHosts":`全部主机`,"hostScope.filtered":`已筛选`,"hostScope.trigger.aria":`主机与工作区范围筛选:{current}`,"hostScope.popover.aria":`主机与工作区范围筛选`,"hostScope.host.label":`选择主机`,"hostScope.scope.label":`展示范围`,"hostScope.scope.allSessions":`全部会话`,"hostScope.scope.selectedWorkspaces":`仅选定工作区`,"hostScope.selectedCount":`已选 {selected}/{total}`,"hostScope.selectAll":`全选`,"hostScope.clear":`清空`,"hostScope.reset":`重置筛选`,"hostScope.noHostWorkspaces":`该主机暂无工作区`,"hostScope.emptyWorkspaces":`当前筛选下暂无工作区`,"hostScope.emptySessions":`当前筛选下暂无会话`,"hostScope.showAll":`显示全部`,"hostScope.action.addRemoteWorkspace":`远程新增工作区`,"hostScope.action.manageRemoteHosts":`管理远程主机`,"workspace.addLocal":`添加本机工作区`,"workspace.addRemote":`远程新增工作区…`,"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":`归档会话`,"archive.children.title":`归档父会话`,"archive.children.description":`选择是否同时归档「{title}」下的全部子会话。`,"archive.children.parentOnly":`仅归档父会话`,"archive.children.include":`同时归档全部 {n} 个子会话`,"archive.children.partial":`父会话已归档,{n} 个子会话未归档。`,"menu.moveToSection":`移动到分区`,"section.destination":`目标分区`,"section.unsectioned":`无分区`,"section.move":`移动`,"section.moveFailed":`无法移动会话。请刷新后重试。`,"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}前`},fg={"host.local":`Local`,"host.thisComputer":`This computer`,"host.connected":`Connected`,"host.connecting":`Connecting`,"host.disconnected":`Disconnected`,"heroPicker.location.aria":`Work location: {current}`,"heroPicker.location.placeholder":`Work location`,"heroPicker.location.empty":`No matching locations`,"heroPicker.location.connectRemote":`Connect remote host…`,"heroPicker.location.manageRemote":`Manage remote hosts`,"heroPicker.project.aria":`Project: {current}`,"heroPicker.project.choose":`Choose project`,"heroPicker.project.noProject":`No project`,"heroPicker.project.placeholder":`Search projects`,"heroPicker.project.empty":`No projects on this host`,"heroPicker.project.noMatches":`No matching projects`,"heroPicker.project.new":`New project`,"hostScope.allShort":`All`,"hostScope.allHosts":`All hosts`,"hostScope.filtered":`Filtered`,"hostScope.trigger.aria":`Filter host and workspace scope: {current}`,"hostScope.popover.aria":`Host and workspace scope filter`,"hostScope.host.label":`Host`,"hostScope.scope.label":`Display scope`,"hostScope.scope.allSessions":`All sessions`,"hostScope.scope.selectedWorkspaces":`Selected workspaces`,"hostScope.selectedCount":`{selected}/{total} selected`,"hostScope.selectAll":`Select all`,"hostScope.clear":`Clear`,"hostScope.reset":`Reset`,"hostScope.noHostWorkspaces":`No workspaces on this host`,"hostScope.emptyWorkspaces":`No workspaces match the current filter`,"hostScope.emptySessions":`No sessions match the current filter`,"hostScope.showAll":`Show all`,"hostScope.action.addRemoteWorkspace":`Add remote workspace`,"hostScope.action.manageRemoteHosts":`Manage remote hosts`,"workspace.addLocal":`Add local workspace`,"workspace.addRemote":`Add remote workspace…`,"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`,"archive.children.title":`Archive parent session`,"archive.children.description":`Choose whether to also archive all child sessions of “{title}”.`,"archive.children.parentOnly":`Archive parent only`,"archive.children.include":`Also archive all {n} child sessions`,"archive.children.partial":`Parent archived. {n} child sessions could not be archived.`,"menu.moveToSection":`Move to section`,"section.destination":`Destination section`,"section.unsectioned":`No section`,"section.move":`Move`,"section.moveFailed":`Could not move the session. Refresh and try again.`,"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 pg(e,t,n=!1){let r=/* @__PURE__ */ new Map;for(let t of Object.values(e.byId)){if(n&&!mg(t))continue;let i=A(t,e)??(n?t.projectionValues?.archiveForkParent:null);if(!i)continue;let a=r.get(i)??[];a.push(t.id),r.set(i,a)}let i=/* @__PURE__ */ new Set([t]),a=[...r.get(t)??[]];for(let e=a.pop();e!==void 0;e=a.pop())i.has(e)||(i.add(e),a.push(...r.get(e)??[]));return i.delete(t),i}function mg(e){return e!==void 0&&!e.blank&&e.origin!==`subagent`&&e.projectionValues?.threadTreeParent!==void 0}function hg(e,t,n){let r=[];for(let i of pg(e,t,!0)){let t=p(i),a=e.byId[t];!n.has(t)&&a&&r.push({id:t,title:a.displayTitle})}return r}function gg(e,t,n=pg(e,t)){let r=[t,...n],i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Map;for(let t=r.pop();t!==void 0;t=r.pop()){if(i.has(t))continue;i.add(t);let n=e.projectionsBySession[p(t)]?.values.subagentCatalog??[];for(let t of n)e.byId[t.id]?.running&&a.set(t.id,{id:t.id,...t.label===void 0?{}:{label:t.label}}),r.push(t.id)}return[...a.values()]}let _g=()=>!1,vg=()=>()=>{};function yg(e){let t=(0,a.usePhoneSidebar)();return t!==null&&!t.open?null:/* @__PURE__ */ (0,o.jsx)(bg,{...e,closeDrawer:t?.close},e.sessionId)}function bg({sessionId:e,prepareDraftReference:t,closeDrawer:n,useMenuOpenState:r,t:i}){let[c]=(0,s.useState)(()=>t(e)),l=(0,s.useSyncExternalStore)(c?.subscribe??vg,c?.getSnapshot??_g),u=(0,s.useRef)(!1),[d,f]=(0,s.useState)(!1),[,p]=r();return c===void 0?null:/* @__PURE__ */ (0,o.jsxs)(o.Fragment,{children:[/* @__PURE__ */ (0,o.jsx)(a.MenuItemButton,{icon:/* @__PURE__ */ (0,o.jsx)(a.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,o.jsx)(`div`,{role:`status`,children:i(`menu.referenceSessionFailed`)})]})}let xg=`workspace`,Sg=[`slots`,`sessions`,`workspaces`,`locale`,`remote`,`remote.directoryPicker`,`layout`,`shortcuts`,`configForms`];function Cg(e){let t=e.get(`sessions`),n=e.get(`workspaces`),i=j(),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),c=0,f=e=>{s.set({...e,seq:++c})},p=new He(e,e.remote.directoryPicker,n,t,a.actions,f),m=tn(e);Gt(e,p,m),e.slots.provideRoot({hooks:{workspaces:n.list}}),e.effect(()=>e.locale.register(xg,{zh:dg,en:fg}),`ui-workspace: dictionaries`);let h=u(),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`),x=e=>{p.openSession(e)},ee=Xh(n.list,e=>new Set(e.pinnedSessionIds)),w=Xh(n.list,e=>new Set(e.archivedSessionIds)),te=Xh(h.state,e=>e.renameTarget),T=(0,r.createSnapshotStore)(null),E=(0,r.createSnapshotStore)(null),D=h.rename,O=e=>{p.unarchiveSession(e).catch(e=>{f({kind:`unarchiveFailed`,message:e instanceof Error?e.message:String(e)})})},ne=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)},re=Xh(t.list,e=>new Set(Object.values(e.byId).filter(e=>!e.blank&&e.origin!==`subagent`&&!e.projectionValues?.remoteHost&&e.projectionValues?.harnessIdentity?.id===`codex`).map(e=>e.id))),ie=(0,r.createSnapshotStore)(null),ae=()=>({hooks:{nativeThreads:re,sectionWorkspace:n.list},requestMove:e=>ie.set(e)}),oe=()=>({hooks:{threadSectionMove:ie},dismiss:()=>ie.set(null),move:(e,t)=>n.moveSessionToSection?n.moveSessionToSection(e,t):Promise.reject(/* @__PURE__ */ Error(`Section moves are unavailable`))}),se=()=>({hooks:{pinned:ee,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)})})}}),k=async(e,r,i=!1)=>{await p.archiveSession(e,{stopActivity:i});let a=0;for(let e of r)if(!n.list.getSnapshot().archivedSessionIds.includes(e))try{let n=t.list.getSnapshot();if(n.byId[e]?.running||gg(n,e,[]).length)throw Error(`Child Session is active`);await p.archiveSession(e)}catch{a++}f({kind:i?`stoppedAndArchived`:`archived`,sessionId:e,failedChildren:a})},ce=(e,n)=>{let r=t.list.getSnapshot(),i=r.byId[e],a=i?.displayTitle??e,o=gg(r,e,[]);i?.running||o.length>0?T.set({sessionId:e,displayTitle:a,children:n,activity:o.length?[{kind:`subagent`,items:o}]:[],...i?.running?{runningThreads:[{id:e,title:a}]}:{}}):k(e,n).catch(t=>{let r=wg(t);r===void 0?f({kind:`archiveFailed`,message:t instanceof Error?t.message:String(t)}):T.set({sessionId:e,displayTitle:a,activity:r,children:n})})},le=()=>({hooks:{archived:w},archiveSession:e=>{let n=t.list.getSnapshot(),r=hg(n,e,w.getSnapshot());r.length?E.set({sessionId:e,title:n.byId[e]?.displayTitle??e,children:r}):ce(e,[])},unarchiveSession:O});d(e,p,h,le().archiveSession);let ue=()=>({hooks:{archiveChildrenRequest:E},dismiss:()=>E.set(null),choose(e,t){E.getSnapshot()===e&&(E.set(null),ce(e.sessionId,t?e.children.map(({id:e})=>e):[]))}}),de=()=>({hooks:{archiveRequest:T},settleSessionArchive:()=>{T.set(null)},stopAndArchiveSession:(e,t=[])=>k(e,t,!0)}),fe=()=>({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)})})}}),A=()=>({copySessionLink:e=>{let n=t.list.getSnapshot().byId[e],r=n===void 0?void 0:S(n);r!==void 0&&(async()=>{try{await navigator.clipboard.writeText(C(r)),f({kind:`sessionLinkCopied`})}catch{f({kind:`sessionLinkCopyFailed`})}})()}}),pe=()=>({requestSessionRename:D}),me=()=>({hooks:{renameRequest:te},settleSessionRename:h.closeRename,renameSession:ne}),he=()=>({hooks:{toast:s},dismissToast:()=>{s.set(null)},undoArchive:O,showArchived:()=>{a.actions.setArchivedFilter(`show`)}}),ge=()=>({startSession:e=>{p.startSession(e)},open:x,markCompletionsRead:t=>{e.get(`uiSession`)?.markCompletionsRead(t)},searchSessions:g,refreshSessions:()=>{t.refresh()},loadMoreSessions:e=>{t.loadMore(e)},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: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}}),_e=()=>({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:l,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:ge,locale:xg},Vh)),e.slots.inject(`sidebar.workspaces.session.menu.item`,function*(){yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`pin`,order:100,locale:xg,inject:se},rg),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`move-to-section`,order:150,locale:xg,inject:ae},Zh),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`rename`,order:200,locale:xg,inject:pe},ag),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`fork`,order:300,locale:xg,inject:fe},eg),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`copy-session-link`,order:350,locale:xg,inject:A},tg),yield e.slots.register({name:`sidebar.workspaces.session.menu.item`,id:`archive`,order:400,locale:xg,inject:le},Uh)}),e.slots.inject(`sidebar.workspaces.session.row.action`,function*(){yield e.slots.register({name:`sidebar.workspaces.session.row.action`,id:`archive`,order:100,locale:xg,inject:le},Wh),yield e.slots.register({name:`sidebar.workspaces.session.row.action`,id:`pin`,order:200,locale:xg,inject:se},ig)}),e.slots.inject(`shell.overlay`,function*(){yield e.slots.register({name:`shell.overlay`,id:`workspace.move-to-section`,locale:xg,inject:oe},Qh),yield e.slots.register({name:`shell.overlay`,id:`workspace.session-rename`,locale:xg,inject:me},og),yield e.slots.register({name:`shell.overlay`,id:`workspace.session-archive`,locale:xg,inject:de},Gh),yield e.slots.register({name:`shell.overlay`,id:`workspace.archive-children`,locale:xg,inject:ue},Jh),yield e.slots.register({name:`shell.overlay`,id:`workspace.row-toast`,locale:xg,store:o,inject:he},lg)}),e.slots.inject(`conversation.hero.workspace`,()=>e.slots.register({name:`conversation.hero.workspace`,children:{"conversation.hero.workspace.directoryFlow":{kind:`single`,scope:`root`}},inject:_e,locale:xg},Dh))}function wg(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=yg,n.apply=Cg,n.inject=Sg,t.exports}});