@jingyi0605/codingns 0.7.1 → 0.7.2
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.
- package/dist/public/assets/{AdaptiveButlerPage-Cd8nPdO0.js → AdaptiveButlerPage-174Mg-9X.js} +1 -1
- package/dist/public/assets/{App-CyxK-Nos.js → App-BRupl2Ul.js} +3 -3
- package/dist/public/assets/{BootstrapPage-DEwPKWR8.js → BootstrapPage-BKzDRWtn.js} +1 -1
- package/dist/public/assets/{ConversationPage-CxWtRhfz.js → ConversationPage-BLQXBsBc.js} +1 -1
- package/dist/public/assets/{DesktopDetachPreviewPage-DDOWolgB.js → DesktopDetachPreviewPage-DtHzSQOX.js} +1 -1
- package/dist/public/assets/{DesktopWindowPage-CtS9D8FD.js → DesktopWindowPage-ppc3h5sO.js} +1 -1
- package/dist/public/assets/{FileContextPanel-CNOjhsi5.js → FileContextPanel-h0kvRbSR.js} +1 -1
- package/dist/public/assets/{GitSidebar-DpC4UhFy.js → GitSidebar-TlaPNhxG.js} +1 -1
- package/dist/public/assets/{MobileCreateSessionSheet-DE4pTyXj.js → MobileCreateSessionSheet-Bp4xOKdt.js} +1 -1
- package/dist/public/assets/{MobileTopHeaderFrame-D_ZbS0qi.js → MobileTopHeaderFrame-BawK1vUE.js} +1 -1
- package/dist/public/assets/{MobileWorkspaceSwitcherHeader-Dc12IAXc.js → MobileWorkspaceSwitcherHeader-CWPXAMoX.js} +1 -1
- package/dist/public/assets/{RelayConnectEntryPage-D8kyZfdm.js → RelayConnectEntryPage-B0-OBZXu.js} +1 -1
- package/dist/public/assets/{ServerSettingsModal-8eRu6VXr.js → ServerSettingsModal-P_pcDvyR.js} +1 -1
- package/dist/public/assets/{SessionIndexPage-DIi0JWKP.js → SessionIndexPage-r8AZ0pJv.js} +1 -1
- package/dist/public/assets/{SettingsPage-OQq3kp32.js → SettingsPage-B-uNuML1.js} +1 -1
- package/dist/public/assets/{TerminalManagerPanel-BEMzisSy.js → TerminalManagerPanel-Bkgr9ZNV.js} +1 -1
- package/dist/public/assets/{TerminalPage-CXLQfwjU.js → TerminalPage-BpFpA3My.js} +1 -1
- package/dist/public/assets/{TerminalRuntimeFallbackModal-BY_VUAbq.js → TerminalRuntimeFallbackModal-D_BUt6HD.js} +1 -1
- package/dist/public/assets/{ToolFilesPage-CYx3DgHg.js → ToolFilesPage-BE9-iHL0.js} +1 -1
- package/dist/public/assets/{ToolGitPage-fgQcvF6v.js → ToolGitPage-ChUkwKgK.js} +1 -1
- package/dist/public/assets/{ToolProcessesPage-BL6yDDPV.js → ToolProcessesPage-C4dli_mi.js} +1 -1
- package/dist/public/assets/{ToolsHomePage-B1n2OeVw.js → ToolsHomePage-ZmcEotg4.js} +1 -1
- package/dist/public/assets/{WorkbenchLandingPage-Cu9yAWYo.js → WorkbenchLandingPage-DZzbQZHt.js} +1 -1
- package/dist/public/assets/{WorkbenchLayout-D6hGXWGE.js → WorkbenchLayout-Cht6Un5X.js} +3 -3
- package/dist/public/assets/{WorkbenchModal-Bpb_G1-U.js → WorkbenchModal-CAj_TqWW.js} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-DzbO05cD.js +1 -0
- package/dist/public/assets/{WorkspaceDebugDetailPage-CZwT99iQ.js → WorkspaceDebugDetailPage-qku5AzZQ.js} +1 -1
- package/dist/public/assets/{WorkspaceDetailPage-DCM-olfU.js → WorkspaceDetailPage-BtrSsZVP.js} +1 -1
- package/dist/public/assets/{WorkspaceHomePage-CsIIqIma.js → WorkspaceHomePage-BhekFDSu.js} +1 -1
- package/dist/public/assets/{client-runtime-manager-CMK7kLp8.js → client-runtime-manager-CgogHxt0.js} +1 -1
- package/dist/public/assets/{file-tree-icon-Bv-apgA1.js → file-tree-icon-CLfk31E7.js} +1 -1
- package/dist/public/assets/{index-O3gOb1E0.js → index-DvkfRpBe.js} +3 -3
- package/dist/public/assets/{login-direct-candidate-resolver-Bn4I5JHh.js → login-direct-candidate-resolver-DvJnjQCi.js} +1 -1
- package/dist/public/assets/{model-switch-api-ZGnyVir7.js → model-switch-api-Dps4yN2t.js} +1 -1
- package/dist/public/assets/{preferences-service-scuqVhuA.js → preferences-service-ohVuseA-.js} +1 -1
- package/dist/public/assets/{realtime-client-TRootbbB.js → realtime-client-CIci6rCd.js} +1 -1
- package/dist/public/assets/{relay-entry-eyCjVFMA.js → relay-entry-WiotM2TL.js} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-BGcnzxqn.js → terminal-runtime-meta-C3Mr0zW5.js} +1 -1
- package/dist/public/assets/{useRegisteredDebugTemplates-BdgPIDVM.js → useRegisteredDebugTemplates-DVQBPV-V.js} +1 -1
- package/dist/public/index.html +1 -1
- package/package.json +1 -1
- package/dist/public/assets/WorkbenchShellRoute-BCjcGWhl.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel-
|
|
2
|
-
var rk=Object.defineProperty;var sk=(e,t,n)=>t in e?rk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ke=(e,t,n)=>sk(e,typeof t!="symbol"?t+"":t,n);import{C as xe,t as l,b as f,j as s,e as Bn,m as Ji,H as Jc,J as af,F as ik,K as ok,w as Qc,A as Zc,g as lf,D as ak,p as Wa,L as lk,M as ck,N as cf,i as uf,O as dc,f as eu,h as hc,P as uk,l as df,y as dk,n as hk,z as pk,d as fk,_ as tu}from"./index-O3gOb1E0.js";import{m as at,e as bn,h as Fa,u as ao,f as Wn,g as ur,i as mk,j as gk,O as td}from"./App-CyxK-Nos.js";import{e as nu,f as Ys,i as ru,j as pn,k as Lo,V as hf,A as bk,a2 as kk,a3 as xk,H as pf,l as yk,m as wk,a4 as ff,a5 as vk,M as Sk,a6 as Ck,a7 as Nk,n as jk,t as Tk,q as Ik,s as mf,h as Hs,a as pc,v as Ek,o as Mk,p as su,a8 as Rk,a9 as Ak,aa as Pk,u as Do,g as Lk,ab as Dk,ac as _k,ad as Bk,ae as gf,af as Ok,ag as bf,ah as Wk,ai as Fk,aj as kf,K as $k,S as zk,R as nd,r as Hk,ak as Uk}from"./model-switch-api-ZGnyVir7.js";import{t as Xs,P as ya,g as xf}from"./window-BVUB8gMK.js";import{R as qk,_ as rd,a as sd,C as yf,i as Le}from"./event-DvH9tcej.js";import{W as Et,M as Gk,D as iu}from"./WorkbenchModal-Bpb_G1-U.js";import{r as Vk,b as Kk}from"./relay-entry-eyCjVFMA.js";const Js=new Map,wf=48;function ps(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function id(e,t){return!Number.isFinite(e)||Date.now()-e>t}function Yk(e){return!e||typeof e!="object"||!("savedAt"in e)||!("value"in e)?!1:Number.isFinite(e.savedAt)}function vf(e){try{const t=JSON.parse(e);return Yk(t)?t:null}catch{return null}}function Xk(){if(!ps())return[];try{return Array.from({length:window.sessionStorage.length},(e,t)=>window.sessionStorage.key(t)).filter(e=>typeof e=="string"&&e.length>0)}catch{return[]}}function Sf(){if(!ps())return[];const e=[];for(const t of Xk()){let n=null;try{n=window.sessionStorage.getItem(t)}catch{continue}if(!n)continue;const r=vf(n);r&&e.push({key:t,savedAt:r.savedAt})}return e.sort((t,n)=>t.savedAt-n.savedAt)}function Qi(e){if(ps())try{window.sessionStorage.removeItem(e)}catch{}}function _o(e){const t=new Set((e==null?void 0:e.preserveKeys)??[]),n=(e==null?void 0:e.maxCount)??wf,r=Sf().filter(o=>!t.has(o.key)),i=Math.max(0,t.size+r.length-n);for(let o=0;o<i;o+=1){const a=r[o];if(!a)break;Qi(a.key)}}function Jk(e){return e instanceof DOMException&&(e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED"||e.code===22||e.code===1014)}function yl(e,t){if(!ps())return"failed";try{return window.sessionStorage.setItem(e,t),"success"}catch(n){return Jk(n)?"quota_exceeded":"failed"}}function Qk(e,t){const n=yl(e,t);if(n==="success"){_o({preserveKeys:[e]});return}if(n==="quota_exceeded"){if(Qi(e),_o({maxCount:Math.max(0,wf-1)}),yl(e,t)==="success"){_o({preserveKeys:[e]});return}for(const r of Sf())if(r.key!==e&&(Qi(r.key),yl(e,t)==="success")){_o({preserveKeys:[e]});return}}}function wa(e,t){const n=Js.get(e);if(n){if(!id(n.savedAt,t))return n.value;Js.delete(e)}if(!ps())return null;let r=null;try{r=window.sessionStorage.getItem(e)}catch{return null}if(!r)return null;const i=vf(r);return!i||id(i.savedAt,t)?(Qi(e),Js.delete(e),null):(Js.set(e,i),i.value)}function qi(e,t){const n={savedAt:Date.now(),value:t};if(Js.set(e,n),!!ps())try{Qk(e,JSON.stringify(n))}catch{}}function LA(e){Js.delete(e),ps()&&Qi(e)}const Zk="codingns.debug.perf",ex="codingns.debug.sessionMessageDedup",tx="codingns.debug.opencodeOrder",nx="codingns.debug.timelineScroll";function rx(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Zk)==="1"}catch{return!1}}function Ot(e,t){if(!rx()||typeof performance>"u")return;const n=Math.round(performance.now());if(t&&Object.keys(t).length>0){console.info(`[perf-ui] ${e} ${n}ms`,t);return}console.info(`[perf-ui] ${e} ${n}ms`)}function sx(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(ex)==="1"}catch{return!1}}function fc(e,t){if(!sx()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,o=i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__??[];o.push(r),o.length>300&&o.splice(0,o.length-300),i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[session-dedup] ${e} ${n}ms`,t);return}console.info(`[session-dedup] ${e} ${n}ms`)}function ix(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(tx)==="1"}catch{return!1}}function DA(e,t){if(!ix()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,o=i.__CODINGNS_OPENCODE_ORDER_DEBUG__??[];o.push(r),o.length>500&&o.splice(0,o.length-500),i.__CODINGNS_OPENCODE_ORDER_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[opencode-order-ui] ${e} ${n}ms`,t);return}console.info(`[opencode-order-ui] ${e} ${n}ms`)}function mc(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(nx)==="1"}catch{return!1}}function ox(e,t){if(!mc()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,o=i.__CODINGNS_TIMELINE_SCROLL_DEBUG__??[];o.push(r),o.length>300&&o.splice(0,o.length-300),i.__CODINGNS_TIMELINE_SCROLL_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[timeline-scroll] ${e} ${n}ms`,t);return}console.info(`[timeline-scroll] ${e} ${n}ms`)}function _A(e,t,n,r){return xe.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:t,content:n,expectedVersion:r??void 0})})}function BA(e){return xe.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function OA(e){return xe.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function WA(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return xe.request(`/api/files/download?${n.toString()}`)}function ax(e,t,n=1,r=20){const i=new URLSearchParams({workspaceId:e,keyword:t,page:String(n),pageSize:String(r)});return xe.request(`/api/files/search?${i.toString()}`)}function FA(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return xe.request(`/api/files/preview?${n.toString()}`)}function lx(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return xe.request(`/api/files/preview-link?${n.toString()}`)}function $A(e){return xe.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function zA(e){return xe.request("/api/git/init",{method:"POST",body:JSON.stringify({workspaceId:e})})}function HA(e,t,n){const r=new URLSearchParams({workspaceId:e,path:t,staged:String(n)});return xe.request(`/api/git/diff?${r.toString()}`)}function UA(e,t){return xe.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function qA(e,t){return xe.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function GA(e,t){return xe.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function VA(e,t){return xe.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:t})})}function KA(e,t){return xe.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:t})})}function YA(e){return xe.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function XA(e,t=5,n=null){const r=new URLSearchParams({workspaceId:e,limit:String(t)});return n&&r.set("cursor",n),xe.request(`/api/git/history?${r.toString()}`)}function JA(e,t){const n=new URLSearchParams({workspaceId:e,commitHash:t});return xe.request(`/api/git/commit-detail?${n.toString()}`)}function cx(e){return xe.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function ux(e){return xe.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function QA(e,t,n){return xe.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:t,create:n})})}function ZA(e,t,n,r,i){return xe.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:t,...n?{remote:n}:{},...r?{auth:r}:{},...i?{remember:i}:{}})})}function eP(e){return xe.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}var pa,fa;function Cf(e){var t;if("items"in e)e.items=(t=e.items)===null||t===void 0?void 0:t.map(n=>"rid"in n?n:Cf(n));else if("action"in e&&e.action){const n=new yf;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function ai(e,t){const n=new yf;if(t&&typeof t=="object"&&("action"in t&&t.action&&(n.onmessage=t.action,delete t.action),"item"in t&&t.item&&typeof t.item=="object"&&"About"in t.item&&t.item.About&&typeof t.item.About=="object"&&"icon"in t.item.About&&t.item.About.icon&&(t.item.About.icon=Xs(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=Xs(t.icon)),"items"in t&&t.items)){let r=function(i){var o;return"rid"in i?[i.rid,i.kind]:("item"in i&&typeof i.item=="object"&&(!((o=i.item.About)===null||o===void 0)&&o.icon)&&(i.item.About.icon=Xs(i.item.About.icon)),"icon"in i&&i.icon&&(i.icon=Xs(i.icon)),"items"in i&&i.items&&(i.items=i.items.map(r)),Cf(i))};t.items=t.items.map(r)}return Le("plugin:menu|new",{kind:e,options:t,handler:n})}class li extends qk{get id(){return rd(this,pa,"f")}get kind(){return rd(this,fa,"f")}constructor(t,n,r){super(t),pa.set(this,void 0),fa.set(this,void 0),sd(this,pa,n),sd(this,fa,r)}}pa=new WeakMap,fa=new WeakMap;class ou extends li{constructor(t,n){super(t,n,"MenuItem")}static async new(t){return ai("MenuItem",t).then(([n,r])=>new ou(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}}class au extends li{constructor(t,n){super(t,n,"Check")}static async new(t){return ai("Check",t).then(([n,r])=>new au(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async isChecked(){return Le("plugin:menu|is_checked",{rid:this.rid})}async setChecked(t){return Le("plugin:menu|set_checked",{rid:this.rid,checked:t})}}var od;(function(e){e.Add="Add",e.Advanced="Advanced",e.Bluetooth="Bluetooth",e.Bookmarks="Bookmarks",e.Caution="Caution",e.ColorPanel="ColorPanel",e.ColumnView="ColumnView",e.Computer="Computer",e.EnterFullScreen="EnterFullScreen",e.Everyone="Everyone",e.ExitFullScreen="ExitFullScreen",e.FlowView="FlowView",e.Folder="Folder",e.FolderBurnable="FolderBurnable",e.FolderSmart="FolderSmart",e.FollowLinkFreestanding="FollowLinkFreestanding",e.FontPanel="FontPanel",e.GoLeft="GoLeft",e.GoRight="GoRight",e.Home="Home",e.IChatTheater="IChatTheater",e.IconView="IconView",e.Info="Info",e.InvalidDataFreestanding="InvalidDataFreestanding",e.LeftFacingTriangle="LeftFacingTriangle",e.ListView="ListView",e.LockLocked="LockLocked",e.LockUnlocked="LockUnlocked",e.MenuMixedState="MenuMixedState",e.MenuOnState="MenuOnState",e.MobileMe="MobileMe",e.MultipleDocuments="MultipleDocuments",e.Network="Network",e.Path="Path",e.PreferencesGeneral="PreferencesGeneral",e.QuickLook="QuickLook",e.RefreshFreestanding="RefreshFreestanding",e.Refresh="Refresh",e.Remove="Remove",e.RevealFreestanding="RevealFreestanding",e.RightFacingTriangle="RightFacingTriangle",e.Share="Share",e.Slideshow="Slideshow",e.SmartBadge="SmartBadge",e.StatusAvailable="StatusAvailable",e.StatusNone="StatusNone",e.StatusPartiallyAvailable="StatusPartiallyAvailable",e.StatusUnavailable="StatusUnavailable",e.StopProgressFreestanding="StopProgressFreestanding",e.StopProgress="StopProgress",e.TrashEmpty="TrashEmpty",e.TrashFull="TrashFull",e.User="User",e.UserAccounts="UserAccounts",e.UserGroup="UserGroup",e.UserGuest="UserGuest"})(od||(od={}));class lu extends li{constructor(t,n){super(t,n,"Icon")}static async new(t){return ai("Icon",t).then(([n,r])=>new lu(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async setIcon(t){return Le("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Xs(t)})}}class cu extends li{constructor(t,n){super(t,n,"Predefined")}static async new(t){return ai("Predefined",t).then(([n,r])=>new cu(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}}function ti([e,t,n]){switch(n){case"Submenu":return new $a(e,t);case"Predefined":return new cu(e,t);case"Check":return new au(e,t);case"Icon":return new lu(e,t);case"MenuItem":default:return new ou(e,t)}}class $a extends li{constructor(t,n){super(t,n,"Submenu")}static async new(t){return ai("Submenu",t).then(([n,r])=>new $a(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async append(t){return Le("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return Le("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return Le("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return Le("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return Le("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(ti)}async items(){return Le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(ti))}async get(t){return Le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?ti(n):null)}async popup(t,n){var r;return Le("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof ya?t:t?new ya(t):null})}async setAsWindowsMenuForNSApp(){return Le("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return Le("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(t){return Le("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Xs(t)})}}class Qs extends li{constructor(t,n){super(t,n,"Menu")}static async new(t){return ai("Menu",t).then(([n,r])=>new Qs(n,r))}static async default(){return Le("plugin:menu|create_default").then(([t,n])=>new Qs(t,n))}async append(t){return Le("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return Le("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return Le("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return Le("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return Le("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(ti)}async items(){return Le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(ti))}async get(t){return Le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?ti(n):null)}async popup(t,n){var r;return Le("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof ya?t:t?new ya(t):null})}async setAsAppMenu(){return Le("plugin:menu|set_as_app_menu",{rid:this.rid}).then(t=>t?new Qs(t[0],t[1]):null)}async setAsWindowMenu(t){var n;return Le("plugin:menu|set_as_window_menu",{rid:this.rid,window:(n=t==null?void 0:t.label)!==null&&n!==void 0?n:null}).then(r=>r?new Qs(r[0],r[1]):null)}}async function dx(e){if(e.length===0)return;await(await Qs.new({items:await Promise.all(e.map(n=>Nf(n)))})).popup(void 0,xf())}async function Nf(e){return"items"in e?$a.new({id:e.id,text:e.label,enabled:!e.disabled,items:await Promise.all(e.items.map(t=>Nf(t)))}):{id:e.id,text:e.label,enabled:!e.disabled,accelerator:e.accelerator,action:()=>{e.onSelect()}}}const ad={"parallel-group-1":{accent:"#0ea5e9",soft:"rgba(14, 165, 233, 0.16)",surface:"rgba(14, 165, 233, 0.08)"},"parallel-group-2":{accent:"#10b981",soft:"rgba(16, 185, 129, 0.16)",surface:"rgba(16, 185, 129, 0.08)"},"parallel-group-3":{accent:"#f59e0b",soft:"rgba(245, 158, 11, 0.16)",surface:"rgba(245, 158, 11, 0.08)"},"parallel-group-4":{accent:"#ec4899",soft:"rgba(236, 72, 153, 0.16)",surface:"rgba(236, 72, 153, 0.08)"},"parallel-group-5":{accent:"#8b5cf6",soft:"rgba(139, 92, 246, 0.16)",surface:"rgba(139, 92, 246, 0.08)"},"parallel-group-6":{accent:"#f97316",soft:"rgba(249, 115, 22, 0.16)",surface:"rgba(249, 115, 22, 0.08)"}},hx=2600,jf="workbench.parallel.pane.palette";let Us=null;const ld=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"];function px(e="create"){return e==="append"?{totalDurationMs:1200,sidebarCollapseDurationMs:0,paneEnterDelayMs:0,paneEnterDurationMs:1e3,gridRevealDelayMs:0,gridRevealDurationMs:920,shellExpandDurationMs:0,paneStaggerMs:80}:{totalDurationMs:2e3,sidebarCollapseDurationMs:720,paneEnterDelayMs:520,paneEnterDurationMs:1480,gridRevealDelayMs:420,gridRevealDurationMs:1360,shellExpandDurationMs:720,paneStaggerMs:96}}function Tf(e){var n,r;const t=(n=e.displayParentSessionId)==null?void 0:n.trim();return t||((r=e.parentSessionId)==null?void 0:r.trim())||null}function fx(e){var r;const t=(r=e==null?void 0:e.colorToken)==null?void 0:r.trim();if(!t)return;const n=ad[t]??ad["parallel-group-1"];return{"--parallel-group-accent":n.accent,"--parallel-group-soft":n.soft,"--parallel-group-surface":n.surface}}function tP(e){const t=va(e.overrideColor)??mx(e.groupId,e.ordinal);return{"--parallel-group-accent":t,"--parallel-group-soft":cd(t,.08),"--parallel-group-surface":cd(t,.03)}}function nP(e){if(typeof window>"u")return null;const t=e.trim();if(!t)return null;const n=If();return va(n[t]??null)}function rP(e,t){if(typeof window>"u")return va(t);const n=e.trim();if(!n)return null;const r=If(),i=va(t);return i?r[n]=i:delete r[n],window.localStorage.setItem(jf,JSON.stringify(r)),i}function mx(e,t){const n=ld.length,r=Math.abs(wx(e))%n;return ld[(r+t*5)%n]}function sP(e){return e?e.role==="anchor"?l("shell.parallelGroupAnchorBadge"):l("shell.parallelGroupMemberBadge"):null}function gx(e){return e?l("shell.parallelGroupBadge",{count:e.memberCount}):null}function iP(e){var n;return((n=e==null?void 0:e.branchName)==null?void 0:n.trim())||null}function oP(e){var n,r,i;return((r=(n=e==null?void 0:e.parallelGroup)==null?void 0:n.groupId)==null?void 0:r.trim())?((i=e==null?void 0:e.sessionIsolatedWorkspace)==null?void 0:i.lifecycleStatus)!=="promoted":!1}function bx(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="removing")?t.sourceWorkspaceId:e.workspaceId}function kx(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="promoted")?t.workspaceId:e.workspaceId}function xx(e,t="create"){Us={groupId:e,createdAt:Date.now(),...px(t)}}function yx(e){return!Us||Us.groupId!==e?null:Date.now()-Us.createdAt>hx?(Us=null,null):Us}function If(){if(typeof window>"u")return{};const e=window.localStorage.getItem(jf);if(!e)return{};try{const t=JSON.parse(e);return!t||typeof t!="object"?{}:t}catch{return{}}}function wx(e){let t=0;for(const n of e)t=t*31+n.charCodeAt(0)|0;return t}function va(e){const t=(e==null?void 0:e.trim().toUpperCase())??"";return/^#[0-9A-F]{6}$/.test(t)?t:null}function cd(e,t){const n=Math.max(0,Math.min(t,1)),r=Number.parseInt(e.slice(1,3),16),i=Number.parseInt(e.slice(3,5),16),o=Number.parseInt(e.slice(5,7),16);return`rgba(${r}, ${i}, ${o}, ${n})`}function uu(e,t){const n=new Map(e.map(o=>[t.getId(o),o])),r=new Map,i=[];for(const o of e){const a=vx(o,n,t);if(!a){i.push(o);continue}const c=r.get(a)??[];r.set(a,[...c,o])}return[...i].sort(t.compare).map(o=>Rf(o,0,r,t,new Set))}function ci(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function Ef(e){return e.flatMap(t=>[t.item,...Ef(ci(t))])}function ss(e){return e.flatMap(t=>[t,...ss(ci(t))])}function du(e,t){return e.some(n=>t(n.item)||du(ci(n),t))}function Mf(e,t,n){return e?n(e.item)===t?!0:ci(e).some(r=>Mf(r,t,n)):!1}function qs(e,t,n){for(const r of e){const i=n(r.item);if(i===t)return[];const o=qs(ci(r),t,n);if(Mf(r,t,n)&&o.length>=0)return[i,...o]}return[]}function Rf(e,t,n,r,i){const o=r.getId(e),a=new Set(i);a.add(o);const c=[...n.get(o)??[]].filter(u=>!a.has(r.getId(u))).sort(r.compare).map(u=>Rf(u,t+1,n,r,a));return{item:e,depth:t,children:c}}function vx(e,t,n){const r=ud(n.getParentId(e));if(!r)return null;const i=t.get(r);if(!i)return null;const o=new Set([n.getId(e)]);let a=i;for(;a;){const c=n.getId(a);if(o.has(c))return null;o.add(c);const u=ud(n.getParentId(a));if(!u||(a=t.get(u),!a))return r}return r}function ud(e){const t=e==null?void 0:e.trim();return t||null}function Zt(){return"/workspaces"}function rr(e){return`/workspaces/${encodeURIComponent(e)}`}function Af(e){return`${rr(e)}/debug`}function ii(e){return`${rr(e)}/sessions`}function _n(e,t){return`${ii(e)}/${encodeURIComponent(t)}`}function Pf(e,t){const n=`${rr(e)}/tools`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function Lf(e){return`${rr(e)}/tools/files`}function Df(e){return`${rr(e)}/tools/git`}function _f(e){return`${rr(e)}/tools/processes`}function is(e){return`${rr(e)}/terminals`}function cs(e,t){const n=`${rr(e)}/butler`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function Sx(e){return Wf(e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...Of(t.childWorktrees??[])])).sort((t,n)=>(n.session.lastMessageAt??n.session.updatedAt).localeCompare(t.session.lastMessageAt??t.session.updatedAt))}function aP(e,t){return uu(Wf(e),{getId:n=>n.session.sessionId,getParentId:n=>Cx(n.session,t),compare:jx})}function Cx(e,t){var n;return(t==null?void 0:t.mode)==="mobile"?((n=e.parentSessionId)==null?void 0:n.trim())||null:Tf(e)}function Bf(e,t){const n=Nx(),r=new URLSearchParams({provider:t});return`${_n(e,n)}?${r.toString()}`}function Nx(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function jx(e,t){return(t.session.lastMessageAt??t.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function Of(e){return e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...Of(t.children)])}function Wf(e){const t=[],n=new Set;for(const r of e){const i=r.session.sessionId.trim();!i||n.has(i)||(n.add(i),t.push(r))}return t}const Tx="mobile.tools.last-primary-tool";function Ff(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(Tx)==="git"?"git":"files"}catch{return"files"}}function hu(e){var r;const t=[{pattern:"/workspaces/:workspaceId/tools/processes",routeKind:"processes"},{pattern:"/workspaces/:workspaceId/tools/files",routeKind:"files"},{pattern:"/workspaces/:workspaceId/tools/git",routeKind:"git"},{pattern:"/workspaces/:workspaceId/tools",routeKind:"home"}];for(const i of t){const o=at(i.pattern,e),a=((r=o==null?void 0:o.params.workspaceId)==null?void 0:r.trim())??null;if(a)return{workspaceId:a,routeKind:i.routeKind,legacy:!1}}const n=[{pattern:"/tools/processes",routeKind:"processes"},{pattern:"/tools/files",routeKind:"files"},{pattern:"/tools/git",routeKind:"git"},{pattern:"/tools",routeKind:"home"}];for(const i of n)if(at(i.pattern,e))return{workspaceId:null,routeKind:i.routeKind,legacy:!0};return null}function Ix(e,t){const n=hu(e);if((n==null?void 0:n.routeKind)==="git")return"git";if((n==null?void 0:n.routeKind)==="files")return"files";const r=new URLSearchParams(t).get("tab");return r==="git"?"git":r==="files"?"files":Ff()}function pu(e,t){const n=hu(e);return(n==null?void 0:n.routeKind)==="processes"&&n.workspaceId?is(n.workspaceId):n!=null&&n.workspaceId?Pf(n.workspaceId,Ix(e,t)):n!=null&&n.legacy?Ff()==="git"?"/tools?tab=git":"/tools?tab=files":null}function fu({activeEntry:e,presentation:t,pathname:n,search:r,moreButtonLabel:i}){if(t==="conversation-focus"||e!=="butler")return null;const o=hu(n);return o?o.routeKind==="processes"?{title:l("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:i}:(o.routeKind==="home"||o.routeKind==="files"||o.routeKind==="git",null):null}const $f=f.createContext({composerPortalTarget:null});function mu({composerPortalTarget:e,children:t}){return s.jsx($f.Provider,{value:{composerPortalTarget:e},children:t})}function lP(){return f.useContext($f)}function gu(e,t,n){const[r,i]=f.useState(void 0);return f.useEffect(()=>{const o=e.current,a=t.current;if(!n||!o||!a){i(void 0),o&&o.style.removeProperty("--mobile-conversation-tabbar-height");return}const c=o,u=a;function d(){if(!e.current||!u.isConnected)return;const p=`${Math.round(u.getBoundingClientRect().height)}px`;c.style.setProperty("--mobile-conversation-tabbar-height",p),i(p)}d();const h=typeof ResizeObserver<"u"?new ResizeObserver(d):null;return h==null||h.observe(u),window.addEventListener("resize",d),()=>{h==null||h.disconnect(),window.removeEventListener("resize",d),c.style.removeProperty("--mobile-conversation-tabbar-height")}},[n,e,t]),r}const Ex=3e3,Bo=10,dd=84,hd=.36;function bu({enabled:e,rootRef:t,suspended:n=!1,resetKey:r}){const i=f.useRef(null),o=f.useRef(null),a=f.useRef("visible"),c=f.useRef(1),[u,d]=f.useState("visible"),[h,p]=f.useState(1);f.useEffect(()=>{a.current=u},[u]),f.useEffect(()=>{c.current=h},[h]);function m(){ts(i),i.current=window.setTimeout(()=>{g()},Ex)}function g(){d("hidden"),p(0)}function x(){d("visible"),p(1),m()}f.useEffect(()=>{if(ts(i),!e){ts(i),d("visible"),p(1);return}if(n){d("hidden"),p(0);return}return x(),()=>{ts(i)}},[e,r,n]),f.useEffect(()=>()=>{ts(i)},[]),f.useEffect(()=>{if(!e||n){o.current=null;return}const C=t.current;if(!C)return;function y(q){if(q.touches.length!==1){o.current=null;return}const P=q.touches[0],T=md(q.target);if(!P||!T){o.current=null;return}o.current={surface:T,startX:P.clientX,startY:P.clientY,pointerType:"touch",initialState:a.current==="visible"?"visible":"hidden",touchId:P.identifier,dragging:!1,latestProgress:c.current},a.current==="visible"&&ts(i)}function A(q){const P=o.current;if(!P||P.pointerType!=="touch")return;const T=wl(q.touches,P.touchId);if(!T)return;const H=T.clientX-P.startX,_=T.clientY-P.startY;if(P.surface==="conversation"){if(Math.abs(_)<=Bo||Math.abs(_)<=Math.abs(H))return;o.current=null,P.initialState==="visible"&&g();return}const ie=P.initialState==="hidden"?-_:_;ie<=Bo&&!P.dragging||(bd(q),P.dragging=!0,P.latestProgress=pd(P.initialState,ie),d("dragging"),p(P.latestProgress))}function j(q){const P=o.current;if(!(!P||P.pointerType!=="touch"||!wl(q.changedTouches,P.touchId))){if(o.current=null,!P.dragging){P.initialState==="visible"&&m();return}fd(P.initialState,P.latestProgress,x,d,p)}}function V(q){const P=o.current;if(!(!P||P.pointerType!=="touch"||!wl(q.changedTouches,P.touchId))){if(o.current=null,!P.dragging){P.initialState==="visible"&&m();return}if(P.initialState==="visible"){x();return}d("hidden"),p(0)}}function L(q){if(q.pointerType!=="touch")return;const P=md(q.target);if(!P){o.current=null;return}if(o.current={surface:P,startX:q.clientX,startY:q.clientY,pointerType:"pointer",initialState:a.current==="visible"?"visible":"hidden",pointerId:q.pointerId,captureTarget:q.target instanceof Element?q.target:null,dragging:!1,latestProgress:c.current},q.target instanceof Element)try{q.target.setPointerCapture(q.pointerId)}catch{}a.current==="visible"&&ts(i)}function I(q){const P=o.current;if(!P||P.pointerType!=="pointer")return;const T=q.clientX-P.startX,H=q.clientY-P.startY;if(P.surface==="conversation"){if(Math.abs(H)<=Bo||Math.abs(H)<=Math.abs(T))return;o.current=null,P.initialState==="visible"&&g();return}const _=P.initialState==="hidden"?-H:H;_<=Bo&&!P.dragging||(bd(q),P.dragging=!0,P.latestProgress=pd(P.initialState,_),d("dragging"),p(P.latestProgress))}function G(q){const P=o.current;if(!(!P||P.pointerType!=="pointer"||P.pointerId!==q.pointerId)){if(o.current=null,Mx(P),!P.dragging){P.initialState==="visible"&&m();return}fd(P.initialState,P.latestProgress,x,d,p)}}return C.addEventListener("touchstart",y,{passive:!0}),C.addEventListener("pointerdown",L,{passive:!0}),window.addEventListener("touchmove",A,{passive:!1}),window.addEventListener("touchend",j),window.addEventListener("touchcancel",V),window.addEventListener("pointermove",I,{passive:!1}),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G),()=>{C.removeEventListener("touchstart",y),C.removeEventListener("pointerdown",L),window.removeEventListener("touchmove",A),window.removeEventListener("touchend",j),window.removeEventListener("touchcancel",V),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G)}},[e,t,n]);const S=e&&!n?h:e?0:1;return{state:n&&e?"hidden":u,progress:S,isOpen:S>.01}}function ts(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function pd(e,t){return gd(e==="hidden"?t/dd:1-t/dd,0,1)}function fd(e,t,n,r,i){if(e==="hidden"){if(t>=hd){n();return}r("hidden"),i(0);return}if(t<=1-hd){r("hidden"),i(0);return}n()}function Mx(e){if(!(e.pointerType!=="pointer"||typeof e.pointerId!="number"||!(e.captureTarget instanceof Element)))try{e.captureTarget.hasPointerCapture(e.pointerId)&&e.captureTarget.releasePointerCapture(e.pointerId)}catch{}}function wl(e,t){if(typeof t!="number")return e[0]??null;for(let n=0;n<e.length;n+=1){const r=e[n];if((r==null?void 0:r.identifier)===t)return r}return null}function md(e){return e instanceof Element?e.closest(".composer-panel")?"composer":e.closest(".message-list, .message-timeline, .mobile-conversation-main, .conversation-page-shell, .mobile-butler-main-stage, .mobile-butler-chat-body, .mobile-butler-page-shell")?"conversation":null:null}function gd(e,t,n){return Math.min(Math.max(e,t),n)}function bd(e){e.cancelable&&e.preventDefault()}function lo({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1}){return i||e==="compact"?"compact":e==="expanded"&&n&&r?"expanded":t==="butler"&&r?"medium-auxiliary":n?"medium-navigation":r?"medium-auxiliary":"compact"}function za(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function zf(e){return e==="medium-navigation"||e==="expanded"}function Hf(e){return e==="medium-auxiliary"||e==="expanded"}function ku({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1,children:o,navigationPanel:a,auxiliaryPanel:c}){const u=lo({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i}),d=zf(u)&&a,h=Hf(u)&&c;return s.jsxs("div",{className:"mobile-adaptive-pane-layout","data-pane-layout":u,children:[d?s.jsx("aside",{className:"workbench-nav surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-navigation",children:a}):null,s.jsx("div",{className:"mobile-adaptive-pane-main",children:o}),h?s.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:c}):null]})}function Rx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=bn(),m=nu(),g=Fa(),x=ao(),S=f.useRef(null),C=f.useRef(null),[y,A]=f.useState(null),j=t==="conversation-focus",V=za({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),L=bu({enabled:j,rootRef:S,resetKey:`${g.pathname}${g.search}`}),I=lo({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:V}),G=fu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.androidMoreAction")}),q=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Lx,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Dx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Bx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(_x,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Ox,{}),onClick:h}],P=j?{"--mobile-conversation-tabbar-progress":L.progress.toFixed(4)}:void 0;gu(S,C,j);function T(){const _=pu(g.pathname,g.search);if(!_){a();return}x(_,{replace:!0})}const H=s.jsx("nav",{ref:C,className:"android-workbench-bottom-nav","aria-label":l("shell.title"),children:q.map(_=>s.jsxs("button",{type:"button",className:"android-workbench-bottom-nav-item","data-active":_.key===e,"aria-current":_.key===e?"page":void 0,onClick:()=>{_.key!==e&&m.trigger("selection"),_.onClick()},children:[s.jsx("span",{className:"android-workbench-bottom-nav-icon","aria-hidden":"true",children:_.icon}),s.jsx("span",{className:"android-workbench-bottom-nav-label",children:_.label})]},_.key))});return s.jsx(mu,{composerPortalTarget:j?y:null,children:s.jsxs("div",{ref:S,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":I,"data-tabbar-open":j?L.isOpen:!0,"data-conversation-tabbar-state":j?L.state:"default",style:P,children:[G?s.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[s.jsxs("div",{className:"android-workbench-topbar-leading",children:[G.showBackButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":l("common.back"),onClick:T,children:s.jsx(Ax,{})}):null,s.jsx("div",{className:"android-workbench-topbar-copy",children:s.jsx("h1",{children:G.title})})]}),s.jsx("div",{className:"android-workbench-topbar-actions",children:G.showMoreButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":G.moreButtonLabel,onClick:d,children:s.jsx(Px,{})}):null})]}):null,s.jsx("div",{className:"android-workbench-content",children:s.jsx(ku,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:V,navigationPanel:r,auxiliaryPanel:i,children:n})}),j?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:H})]}):H]})})}function Ax(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function Px(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Lx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function Dx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function _x(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function Bx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Ox(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}const Wx=120,Oi={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function gc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Fx(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable||e.closest("[contenteditable='true']"))return!0;if(e instanceof HTMLTextAreaElement)return!e.readOnly&&!e.disabled;if(e instanceof HTMLInputElement){if(e.readOnly||e.disabled)return!1;const t=(e.type||"text").toLowerCase();return!["button","checkbox","color","file","hidden","image","radio","range","reset","submit"].includes(t)}return!1}function $x(){var t;if(typeof window>"u")return 0;const e=[window.innerHeight,typeof document<"u"?(t=document.documentElement)==null?void 0:t.clientHeight:0].filter(gc);return e.length>0?Math.max(...e):0}function kd(){if(typeof window>"u")return Oi;const e=window.visualViewport,t=$x(),n=(e==null?void 0:e.height)??t,r=gc(n)?Math.round(n):null,i=gc(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,o=r===null?0:Math.max(0,Math.round(t-r-i));return{viewportHeight:r,keyboardInset:o,keyboardOpen:Fx(typeof document<"u"?document.activeElement:null)&&o>=Wx}}function vl(e,t){if(typeof document>"u")return;[document.documentElement,document.body].filter(r=>r instanceof HTMLElement).forEach(r=>{if(!e){delete r.dataset.mobileKeyboardOpen,delete r.dataset.mobileViewportBound,r.style.removeProperty("--mobile-shell-viewport-height"),r.style.removeProperty("--mobile-shell-keyboard-inset");return}r.dataset.mobileKeyboardOpen=String(t.keyboardOpen),r.dataset.mobileViewportBound="true",t.viewportHeight===null?r.style.removeProperty("--mobile-shell-viewport-height"):r.style.setProperty("--mobile-shell-viewport-height",`${t.viewportHeight}px`),r.style.setProperty("--mobile-shell-keyboard-inset",`${t.keyboardInset}px`)})}function zx(e){const[t,n]=f.useState(()=>e?kd():Oi),r=f.useRef(null);return f.useEffect(()=>{if(!e){n(Oi),vl(!1,Oi);return}function i(){n(kd())}function o(){r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,i()},0)}i();const a=window.visualViewport;return window.addEventListener("resize",i),window.addEventListener("orientationchange",i),a==null||a.addEventListener("resize",i),a==null||a.addEventListener("scroll",i),document.addEventListener("focusin",i),document.addEventListener("focusout",o),()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),window.removeEventListener("resize",i),window.removeEventListener("orientationchange",i),a==null||a.removeEventListener("resize",i),a==null||a.removeEventListener("scroll",i),document.removeEventListener("focusin",i),document.removeEventListener("focusout",o),vl(!1,Oi)}},[e]),f.useEffect(()=>{vl(e,t)},[e,t]),t}function Hx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=bn(),m=nu(),g=Fa(),x=ao(),S=f.useRef(null),C=f.useRef(null),[y,A]=f.useState(null),j=t==="conversation-focus",V=za({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),L=bu({enabled:j,rootRef:S,resetKey:`${g.pathname}${g.search}`}),I=lo({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:V}),G=fu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.iosMoreAction")}),q=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Gx,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Vx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Yx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(Kx,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Xx,{}),onClick:h}],P=j?{"--mobile-conversation-tabbar-progress":L.progress.toFixed(4)}:void 0;gu(S,C,j);function T(){const _=pu(g.pathname,g.search);if(!_){a();return}x(_,{replace:!0})}const H=s.jsx("nav",{ref:C,className:"ios-workbench-tabbar","aria-label":l("shell.title"),children:q.map(_=>s.jsxs("button",{type:"button",className:"ios-workbench-tabbar-item","data-active":_.key===e,"aria-current":_.key===e?"page":void 0,onClick:()=>{_.key!==e&&m.trigger("selection"),_.onClick()},children:[s.jsx("span",{className:"ios-workbench-tabbar-icon","aria-hidden":"true",children:_.icon}),s.jsx("span",{className:"ios-workbench-tabbar-label",children:_.label})]},_.key))});return s.jsx(mu,{composerPortalTarget:j?y:null,children:s.jsxs("div",{ref:S,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":I,"data-tabbar-open":j?L.isOpen:!0,"data-conversation-tabbar-state":j?L.state:"default",style:P,children:[G?s.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[s.jsx("div",{className:"ios-workbench-nav-leading",children:G.showBackButton?s.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":l("common.back"),onClick:T,children:[s.jsx(Ux,{}),s.jsx("span",{children:l("common.back")})]}):null}),s.jsx("div",{className:"ios-workbench-nav-copy",children:s.jsx("h1",{children:G.title})}),s.jsx("div",{className:"ios-workbench-nav-actions",children:G.showMoreButton?s.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":G.moreButtonLabel,onClick:d,children:s.jsx(qx,{})}):null})]}):null,s.jsx("div",{className:"ios-workbench-content",children:s.jsx(ku,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:V,navigationPanel:r,auxiliaryPanel:i,children:n})}),j?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:H})]}):H]})})}function Ux(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:s.jsx("path",{d:"m15 18-6-6 6-6"})})}function qx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Gx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function Vx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Kx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function Yx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Xx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function Jx(e){const t=bn();return t.platform==="ios"?s.jsx(Hx,{...e}):t.platform==="android"?s.jsx(Rx,{...e}):s.jsx(Qx,{...e})}function Qx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=bn(),m=nu(),g=Fa(),x=ao(),S=f.useRef(null),C=f.useRef(null),[y,A]=f.useState(null),j=zx(p.platform==="web"),V=p.platform==="web"&&j.keyboardOpen,L=t==="conversation-focus",I=za({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),G=bu({enabled:L,rootRef:S,suspended:V,resetKey:`${g.pathname}${g.search}`}),q=lo({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I}),P=fu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.iosMoreAction")}),T=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(ty,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(ny,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(sy,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(ry,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(iy,{}),onClick:h}],H=L?{"--mobile-conversation-tabbar-progress":G.progress.toFixed(4)}:void 0;gu(S,C,L);function _(){const Y=pu(g.pathname,g.search);if(!Y){a();return}x(Y,{replace:!0})}const ie=s.jsx("nav",{ref:C,className:"mobile-workbench-tabbar","aria-label":l("shell.title"),hidden:V,children:T.map(Y=>s.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":Y.key===e,"aria-current":Y.key===e?"page":void 0,onClick:()=>{Y.key!==e&&m.trigger("selection"),Y.onClick()},children:[s.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:Y.icon}),s.jsx("span",{className:"mobile-workbench-tabbar-label",children:Y.label})]},Y.key))});return s.jsx(mu,{composerPortalTarget:L?y:null,children:s.jsxs("div",{ref:S,className:"mobile-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-mobile-runtime":p.platform,"data-mobile-keyboard-open":V,"data-pane-layout":q,"data-tabbar-open":V?!1:L?G.isOpen:!0,"data-conversation-tabbar-state":L?G.state:"default",style:H,children:[P?s.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[s.jsxs("div",{className:"mobile-workbench-header-leading",children:[P.showBackButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":l("common.back"),onClick:_,children:s.jsx(Zx,{})}):null,s.jsx("div",{className:"mobile-workbench-header-copy",children:s.jsx("h1",{children:P.title})})]}),s.jsx("div",{className:"mobile-workbench-header-actions",children:P.showMoreButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":P.moreButtonLabel,onClick:d,children:s.jsx(ey,{})}):null})]}):null,s.jsx("div",{className:"mobile-workbench-content",children:s.jsx(ku,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I,navigationPanel:r,auxiliaryPanel:i,children:n})}),L?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:ie})]}):ie]})})}function Zx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function ey(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function ty(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function ny(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function ry(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function sy(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function iy(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}class oy{constructor(t){Ke(this,"maxAttempts");Ke(this,"baseDelayMs");Ke(this,"reconnectAttempts",0);Ke(this,"reconnectTimer",null);Ke(this,"disposed",!1);this.options=t,this.maxAttempts=t.maxAttempts??4,this.baseDelayMs=t.baseDelayMs??300}start(){this.options.onReconnect(!1)}markConnected(){this.reconnectAttempts=0,this.options.onStateChange("connected")}markTransientFailure(){this.disposed||this.reconnectAttempts>0||this.options.onStateChange("reconnecting")}markDisconnected(){if(this.disposed)return;if(!Bn.getState().autoReconnect){this.options.onStateChange("reconnect_failed");return}if(this.reconnectAttempts+=1,this.reconnectAttempts>this.maxAttempts){this.options.onStateChange("reconnect_failed");return}this.options.onStateChange("reconnecting");const t=this.baseDelayMs*this.reconnectAttempts;this.reconnectTimer=window.setTimeout(()=>{this.options.onReconnect(!0)},t)}reconnectNow(){this.reconnectAttempts=0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onReconnect(!0)}close(){this.disposed=!0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onStateChange("closed")}}class ay{constructor(t){Ke(this,"socket",null);Ke(this,"disposed",!1);Ke(this,"authRecoveryInFlight",!1);Ke(this,"pendingRefresh",!1);Ke(this,"workbenchKnownRevision");Ke(this,"lastWorkbenchSnapshot",null);Ke(this,"fileTreeSubscription",null);Ke(this,"gitSubscription",null);Ke(this,"terminalManagerSubscription",null);Ke(this,"workspaceManagementSubscription",null);Ke(this,"pendingFileTreeRefresh",null);Ke(this,"pendingGitRefresh",null);Ke(this,"pendingTerminalManagerRefresh",null);Ke(this,"pendingWorkspaceManagementRefresh",null);Ke(this,"fileTreeRevisionByPath",new Map);Ke(this,"gitRevisionByWorkspaceId",new Map);Ke(this,"terminalManagerRevisionByWorkspaceId",new Map);Ke(this,"workspaceManagementRevisionByWorkspaceId",new Map);Ke(this,"fileTreeListeners",new Set);Ke(this,"gitListeners",new Set);Ke(this,"terminalManagerListeners",new Set);Ke(this,"workspaceManagementListeners",new Set);Ke(this,"workbenchSubscribeStartedAtMs",null);Ke(this,"workbenchRefreshStartedAtMs",null);Ke(this,"connectionManager");this.options=t,this.workbenchKnownRevision=null,this.connectionManager=new oy({onReconnect:n=>{this.connect(n)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const t=this.socket;if(!xd(t)){this.pendingRefresh=!0;return}this.workbenchRefreshStartedAtMs=performance.now(),t.send(JSON.stringify({type:"workbench.refresh",knownRevision:this.workbenchKnownRevision??void 0})),Ot("workbench.refresh.sent",{knownRevision:this.workbenchKnownRevision}),this.pendingRefresh=!1}setWorkbenchKnownRevision(t){this.workbenchKnownRevision=jn(t)}primeWorkbenchSnapshot(t){if(!t||!Array.isArray(t.items)){this.lastWorkbenchSnapshot=null,this.workbenchKnownRevision=null;return}this.lastWorkbenchSnapshot=t,this.workbenchKnownRevision=jn(t.revision)??null}subscribeFileTree(t,n,r){this.fileTreeSubscription={workspaceId:t,paths:yd(n),knownRevisionByPath:Sl(r==null?void 0:r.knownRevisionByPath)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:t,paths:this.fileTreeSubscription.paths,knownRevisions:Cl(t,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})}requestFileTreeRefresh(t,n,r){const i=yd(n),o={type:"fileTree.refresh",workspaceId:t,paths:i,knownRevisions:Cl(t,i,Sl(r==null?void 0:r.knownRevisionByPath),this.fileTreeRevisionByPath)};this.sendWhenReady(o)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:t,paths:i,knownRevisionByPath:Sl(r==null?void 0:r.knownRevisionByPath)}}subscribeGit(t,n){this.gitSubscription={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"git.subscribe",workspaceId:t,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(t)})}requestGitRefresh(t,n){const r={type:"git.refresh",workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)??this.gitRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingGitRefresh=null:this.pendingGitRefresh={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)}}subscribeTerminalManager(t,n){this.terminalManagerSubscription={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"terminalManager.subscribe",workspaceId:t,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(t)})}requestTerminalManagerRefresh(t,n){const r={type:"terminalManager.refresh",workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)??this.terminalManagerRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingTerminalManagerRefresh=null:this.pendingTerminalManagerRefresh={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)}}subscribeWorkspaceManagement(t,n){this.workspaceManagementSubscription={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"workspaceManagement.subscribe",workspaceId:t,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(t)})}requestWorkspaceManagementRefresh(t,n){const r={type:"workspaceManagement.refresh",workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)??this.workspaceManagementRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingWorkspaceManagementRefresh=null:this.pendingWorkspaceManagementRefresh={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)}}addFileTreeSnapshotListener(t){return this.fileTreeListeners.add(t),()=>{this.fileTreeListeners.delete(t)}}addGitSnapshotListener(t){return this.gitListeners.add(t),()=>{this.gitListeners.delete(t)}}addTerminalManagerSnapshotListener(t){return this.terminalManagerListeners.add(t),()=>{this.terminalManagerListeners.delete(t)}}addWorkspaceManagementSnapshotListener(t){return this.workspaceManagementListeners.add(t),()=>{this.workspaceManagementListeners.delete(t)}}close(){var t;this.disposed=!0,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var u;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const n=(u=Ji.getState().session)==null?void 0:u.accessToken;if(!n){this.options.onUnauthorized();return}const r=Jc(),i=af(r),o=i.baseUrl,a=`${ik("/ws",o)}?access_token=${encodeURIComponent(n)}`,c=i.transport.createWebSocket({path:"/ws",baseUrl:o,url:a});this.socket=c,c.addEventListener("open",()=>{this.workbenchSubscribeStartedAtMs=performance.now(),c.send(JSON.stringify({type:"workbench.subscribe",knownRevision:this.workbenchKnownRevision??void 0})),Ot("workbench.subscribe.sent",{knownRevision:this.workbenchKnownRevision,baseUrl:o}),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&c.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths,knownRevisions:Cl(this.fileTreeSubscription.workspaceId,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})),this.pendingFileTreeRefresh&&this.requestFileTreeRefresh(this.pendingFileTreeRefresh.workspaceId,this.pendingFileTreeRefresh.paths,{knownRevisionByPath:this.pendingFileTreeRefresh.knownRevisionByPath}),this.gitSubscription&&c.send(JSON.stringify({type:"git.subscribe",workspaceId:this.gitSubscription.workspaceId,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(this.gitSubscription.workspaceId)})),this.pendingGitRefresh&&this.requestGitRefresh(this.pendingGitRefresh.workspaceId,{knownRevision:this.pendingGitRefresh.knownRevision}),this.terminalManagerSubscription&&c.send(JSON.stringify({type:"terminalManager.subscribe",workspaceId:this.terminalManagerSubscription.workspaceId,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(this.terminalManagerSubscription.workspaceId)})),this.pendingTerminalManagerRefresh&&this.requestTerminalManagerRefresh(this.pendingTerminalManagerRefresh.workspaceId,{knownRevision:this.pendingTerminalManagerRefresh.knownRevision}),this.workspaceManagementSubscription&&c.send(JSON.stringify({type:"workspaceManagement.subscribe",workspaceId:this.workspaceManagementSubscription.workspaceId,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(this.workspaceManagementSubscription.workspaceId)})),this.pendingWorkspaceManagementRefresh&&this.requestWorkspaceManagementRefresh(this.pendingWorkspaceManagementRefresh.workspaceId,{knownRevision:this.pendingWorkspaceManagementRefresh.knownRevision})}),c.addEventListener("message",d=>{var p,m,g,x,S,C,y,A,j,V;if(!(d instanceof MessageEvent)||typeof d.data!="string")return;const h=JSON.parse(d.data);if(h.type==="system.connected"){this.connectionManager.markConnected();return}if(h.type==="session.error"){h.error_code==="UNAUTHORIZED"&&this.handleUnauthorized();return}if(h.type==="workbench.snapshot"&&(Ot("workbench.snapshot.received",{unchanged:h.unchanged,revision:h.revision,workspaceCount:((p=h.snapshot)==null?void 0:p.items.length)??0,sessionCount:h.snapshot?uy(h.snapshot):0,subscribeDurationMs:Oo(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Oo(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null),h.type==="workbench.delta"){Ot("workbench.delta.received",{baseRevision:h.baseRevision,revision:h.revision,changedWorkspaceCount:h.changedItems.length,removedWorkspaceCount:h.removedWorkspaceIds.length,subscribeDurationMs:Oo(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Oo(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null;const L=cy(this.lastWorkbenchSnapshot,h);if(!L){Ot("workbench.delta.mismatch",{currentRevision:((m=this.lastWorkbenchSnapshot)==null?void 0:m.revision)??null,baseRevision:h.baseRevision,revision:h.revision}),this.workbenchKnownRevision=null,this.lastWorkbenchSnapshot=null,this.connectionManager.reconnectNow();return}this.lastWorkbenchSnapshot=L,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(L);return}if(h.type==="fileTree.snapshot"){const L=h.snapshot;if(L)L.revision=h.revision,this.fileTreeRevisionByPath.set(bc(L.workspaceId,L.path),h.revision);else if(h.unchanged&&this.fileTreeSubscription)for(const I of this.fileTreeSubscription.paths)this.fileTreeRevisionByPath.set(bc(this.fileTreeSubscription.workspaceId,I),h.revision);if(!L)return;(x=(g=this.options).onFileTreeSnapshot)==null||x.call(g,L),this.fileTreeListeners.forEach(I=>I(L));return}if(h.type==="git.snapshot"){const L=h.snapshot;if(L?(L.revision=h.revision,this.gitRevisionByWorkspaceId.set(L.workspaceId,h.revision)):h.unchanged&&this.gitSubscription&&this.gitRevisionByWorkspaceId.set(this.gitSubscription.workspaceId,h.revision),!L)return;(C=(S=this.options).onGitSnapshot)==null||C.call(S,L),this.gitListeners.forEach(I=>I(L));return}if(h.type==="terminalManager.snapshot"){const L=h.snapshot;if(L?(L.revision=h.revision,this.terminalManagerRevisionByWorkspaceId.set(L.workspaceId,h.revision)):h.unchanged&&this.terminalManagerSubscription&&this.terminalManagerRevisionByWorkspaceId.set(this.terminalManagerSubscription.workspaceId,h.revision),!L)return;(A=(y=this.options).onTerminalManagerSnapshot)==null||A.call(y,L),this.terminalManagerListeners.forEach(I=>I(L));return}if(h.type==="workspaceManagement.snapshot"){const L=h.snapshot;if(L?(L.revision=h.revision,this.workspaceManagementRevisionByWorkspaceId.set(L.workspaceId,h.revision)):h.unchanged&&this.workspaceManagementSubscription&&this.workspaceManagementRevisionByWorkspaceId.set(this.workspaceManagementSubscription.workspaceId,h.revision),!L)return;(V=(j=this.options).onWorkspaceManagementSnapshot)==null||V.call(j,L),this.workspaceManagementListeners.forEach(I=>I(L));return}h.type==="workbench.snapshot"&&h.snapshot&&ly(h.snapshot)?(h.snapshot.revision=h.revision,this.lastWorkbenchSnapshot=h.snapshot,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(h.snapshot)):h.type==="workbench.snapshot"&&h.unchanged&&(this.workbenchKnownRevision=h.revision,this.lastWorkbenchSnapshot&&(this.lastWorkbenchSnapshot={...this.lastWorkbenchSnapshot,revision:h.revision}))}),c.addEventListener("close",()=>{this.disposed||this.socket!==c||this.connectionManager.markDisconnected()}),c.addEventListener("error",()=>{this.disposed||this.socket!==c||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,t==null||t.close(),Ji.refresh().then(n=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(n.status==="refreshed"){this.connectionManager.reconnectNow();return}if(n.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendWhenReady(t){const n=this.socket;return xd(n)?(n.send(JSON.stringify(t)),!0):!1}}function xd(e){return e!==null&&e.readyState===1}function ly(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function yd(e){const t=new Set;for(const n of e??[""])t.add(n.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...t]}function jn(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function cy(e,t){if(!e||e.revision!==t.baseRevision)return null;const n=new Map(e.items.map(i=>[i.workspace.id,i]));for(const i of t.removedWorkspaceIds)n.delete(i);for(const i of t.changedItems)n.set(i.workspace.id,i);const r=[];for(const i of t.orderedWorkspaceIds){const o=n.get(i);if(!o)return null;r.push(o)}return{revision:t.revision,items:r}}function Sl(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),jn(n)]).filter(t=>t[1]!==null)):{}}function Cl(e,t,n,r){const i=t.map(o=>{const a=o.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return[a,n[a]??r.get(bc(e,a))??null]}).filter(o=>!!o[1]);if(i.length!==0)return Object.fromEntries(i)}function bc(e,t){return`${e}::${t}`}function uy(e){return e.items.reduce((t,n)=>t+n.sessions.length+Uf(n.childWorktrees??[]),0)}function Uf(e){return e.reduce((t,n)=>{if(typeof n!="object"||n===null)return t;const r=n,i=Array.isArray(r.sessions)?r.sessions.length:0,o=Array.isArray(r.children)?Uf(r.children):0;return t+i+o},0)}function Oo(e){return e===null||typeof performance>"u"?null:Math.round(performance.now()-e)}const wd=6,dy=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function hy(e){return e instanceof HTMLElement?!e.closest(dy):!0}function kc(e,t,n){return e.isDesktop&&e.ui.osFamily==="macos"&&t===0&&hy(n)}function qf(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function Gf(e){return qf(e)?"":void 0}function py(e){if(!kc(e.platform,e.button,e.target)||typeof window>"u")return;const t=e.clientX,n=e.clientY;let r=!0;const i=()=>{r&&(r=!1,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",a),window.removeEventListener("blur",c))},o=u=>{Math.abs(u.clientX-t)<wd&&Math.abs(u.clientY-n)<wd||(i(),fy())},a=()=>{i()},c=()=>{i()};window.addEventListener("mousemove",o),window.addEventListener("mouseup",a),window.addEventListener("blur",c)}async function fy(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await xf().startDragging()}const Sa=.78,my=1;function gy(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function Vf(e,t,n,r){const i=Math.hypot(n-e,r-t),o=Math.min(1,i/120);return Sa+(my-Sa)*o}function Lr(e){return Math.round(Number.isFinite(e)?e:0)}function by(e){if(!gy())return null;const t=Lr(e.x),n=Lr(e.y);let r=!1,i=Promise.resolve();const o=(c,u)=>(i=i.then(async()=>{await window.__TAURI_INTERNALS__.invoke(c,u)}).catch(()=>{}),i),a=async()=>{r||(r=!0,await o("close_detach_preview"))};return o("show_detach_preview",{title:e.title,x:t,y:n,scale:Sa}),{updatePosition(c,u){if(r)return;const d=Lr(c),h=Lr(u);o("update_detach_preview_position",{x:d,y:h,scale:Vf(t,n,d,h)})},complete(){return a()},cancel(){return a()}}}function ky(e){if(typeof document>"u")return null;const t=Lr(e.x),n=Lr(e.y),r=document.createElement("div");r.className="desktop-window-detach-animation",r.setAttribute("aria-hidden","true"),r.dataset.state="preview",r.style.left=`${t}px`,r.style.top=`${n}px`,r.style.setProperty("--detach-preview-scale",Sa.toFixed(3));const i=document.createElement("div");i.className="desktop-window-detach-animation-bar";const o=document.createElement("strong");o.className="desktop-window-detach-animation-title",o.textContent=e.title;const a=document.createElement("div");a.className="desktop-window-detach-animation-body",i.append(o),r.append(i,a),document.body.append(r);let c=!1;const u=()=>{c||(c=!0,r.remove())};return{updatePosition(d,h){if(c)return;const p=Lr(d),m=Lr(h),g=Vf(t,n,p,m);r.style.left=`${p}px`,r.style.top=`${m}px`,r.style.setProperty("--detach-preview-scale",g.toFixed(3))},async complete(){u()},async cancel(){u()}}}function vd(e){return by(e)??ky(e)}const xy={files:{kind:"files",label:"文件",defaultFocusOwner:"file-context-panel"},git:{kind:"git",label:"Git",defaultFocusOwner:"git-sidebar"},processes:{kind:"processes",label:"调试",defaultFocusOwner:"terminal-manager-panel"},terminals:{kind:"terminals",label:"终端",defaultFocusOwner:"terminal-page"}};function yy(e){return{...e,bounds:{...e.bounds}}}function wy(e,t,n){t&&(e.windows.registerDescriptor(t),n?e.windows.markWindowOpen(t.windowId):e.windows.markWindowClosed(t.windowId))}function vy(e){return xy[e]}function Kf(e,t){return`${e}-${t}`}async function Ha(e,t,n){const r=n.workspaceId.trim(),i=vy(t);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!r)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:`${i.label}外部窗口必须绑定工作区。`};const o=Kf(t,r),a=e.windows.getDescriptor(o),c=a?yy(a):null,u=e.windows.isWindowOpen(o),d=ok({windowId:o,kind:t,workspaceId:r,workspaceName:n.workspaceName??(c==null?void 0:c.workspaceName)??null,sessionId:n.sessionId??(c==null?void 0:c.sessionId)??null,mode:"external",bounds:c==null?void 0:c.bounds,focusOwner:n.focusOwner??i.defaultFocusOwner});e.windows.registerDescriptor(d);const h=await e.bridge.createWindow(d);return h.ok?(e.windows.markWindowOpen(o),{ok:!0,value:d}):(c?wy(e,c,u):e.windows.removeWindow(o),{ok:!1,errorCode:h.errorCode,detail:h.detail})}function cP(e){return Kf("terminals",e)}function Sy(e,t){return Ha(e,"files",t)}function Cy(e,t){return Ha(e,"git",t)}function Ny(e,t){return Ha(e,"processes",t)}function uP(e,t){return Ha(e,"terminals",t)}async function Sd(){return await xe.request("/api/skills/overview")}async function jy(e){await xe.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function Ty(e){await xe.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function Iy(e){await xe.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}async function Ey(){return await xe.request("/api/opencli/catalog")}async function Cd(){return await xe.request("/api/opencli/check",{method:"POST"})}async function My(e){return await xe.request("/api/opencli/config",{method:"POST",body:JSON.stringify(e)})}const Nl="all",jl="status";function Ry({toolbarMode:e="internal",onToolbarStateChange:t}={}){var We,Ue,Fe,rt;const n=Qc(F=>{var ne;return((ne=F.session)==null?void 0:ne.accessToken)??null}),[r,i]=f.useState(null),[o,a]=f.useState(!1),[c,u]=f.useState(!1),[d,h]=f.useState(!1),[p,m]=f.useState(!1),[g,x]=f.useState([]),[S,C]=f.useState(null),[y,A]=f.useState(null),[j,V]=f.useState(Nl),[L,I]=f.useState(null),[G,q]=f.useState(!1),[P,T]=f.useState(""),[H,_]=f.useState(jl);f.useEffect(()=>{let F=!0;if(!n){i(null),m(!1),x([]),A(null),C(null),a(!1),V(Nl),I(null),q(!1),T(""),_(jl);return}return(async()=>{a(!0),A(null),C(null);try{const re=await Cd();if(!F)return;N(re)}catch(re){if(!F)return;const Se=Fo(re);try{const ke=await Ey();if(!F)return;N(ke),A(Se)}catch(ke){if(!F)return;A(Fo(ke))}}finally{F&&a(!1)}})(),()=>{F=!1}},[n]);const ie=f.useMemo(()=>new Set(g),[g]),Y=f.useMemo(()=>Ly((r==null?void 0:r.entries)??[]),[r==null?void 0:r.entries]),W=f.useMemo(()=>Oy(),[]);f.useEffect(()=>{Y.some(F=>F.id===j)||V(Nl)},[j,Y]);const U=f.useMemo(()=>((r==null?void 0:r.siteGroups)??[]).filter(F=>F.commands.some(ne=>Nd(ne,j,ie))),[j,r==null?void 0:r.siteGroups,ie]),D=f.useMemo(()=>L?U.find(F=>F.site===L)??null:null,[L,U]);f.useEffect(()=>{L&&!D&&I(null)},[L,D]),f.useEffect(()=>{T(""),_(jl)},[L]);const K=f.useMemo(()=>{if(!D)return[];const F=P.trim().toLowerCase();return D.commands.filter(ne=>Nd(ne,j,ie)&&_y(ne,F)).sort((ne,re)=>By(ne,re,{sortId:H,selectedCommandIdSet:ie}))},[j,D,P,H,ie]),ee=!!(r&&(r.provider.enabled!==p||r.entries.some(F=>F.enabled!==ie.has(F.commandId)))),v=f.useMemo(()=>({draftEnabled:p,enableDisabled:o||c||d,refreshDisabled:!n||o||c||d,detailDisabled:!r||o,saveDisabled:!n||o||c||d||!r||!ee,refreshing:c,saving:d,onEnabledChange:de,onRefresh:()=>{Ne()},onShowDetails:()=>q(!0),onSave:()=>{ve()}}),[n,r,g,p,ee,o,c,d]);f.useEffect(()=>{t==null||t(v)},[t,v]),f.useEffect(()=>()=>{t==null||t(null)},[t]);async function Ne(){if(n){u(!0),A(null),C(null);try{const F=await Cd();N(F),C(Gy(F.refreshState,F.runtimeAvailability))}catch(F){A(Fo(F))}finally{u(!1)}}}async function ve(){if(n){h(!0),A(null),C(null);try{const F=await My({enabled:p,enabledCommandIds:g});N(F),C(Vy(F))}catch(F){A(Fo(F))}finally{h(!1)}}}function N(F){i(F),m(F.provider.enabled),x(F.entries.filter(ne=>ne.enabled).map(ne=>ne.commandId).sort((ne,re)=>ne.localeCompare(re))),A(null)}function de(F){m(F)}function Ee(F,ne){const re=F.commands.map(Se=>Se.commandId);x(Se=>{const ke=new Set(Se);for(const pe of re)ne?ke.add(pe):ke.delete(pe);return[...ke].sort((pe,xt)=>pe.localeCompare(xt))})}function me(F,ne){x(re=>{const Se=new Set(re);return ne?Se.add(F):Se.delete(F),[...Se].sort((ke,pe)=>ke.localeCompare(pe))})}const le=(r==null?void 0:r.summary)??{catalogCount:0,browserDependentCount:0,installState:"not_installed"};return s.jsxs("section",{className:"settings-opencli-panel settings-skill-section",children:[e==="internal"?s.jsx(Ay,{state:v,className:"settings-opencli-inline-toolbar"}):null,s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(Wo,{label:l("settings.opencliSummaryInstallState"),value:Id(le.installState)}),s.jsx(Wo,{label:l("settings.opencliSummaryCatalogCount"),value:String(le.catalogCount)}),s.jsx(Wo,{label:l("settings.opencliSummaryEnabledCount"),value:String(g.length)}),s.jsx(Wo,{label:l("settings.opencliSummaryBrowserCount"),value:String(le.browserDependentCount)})]}),S?s.jsx("p",{className:"settings-release-status",children:S}):null,y?s.jsx("p",{className:"settings-release-status",children:y}):null,o?s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliLoading")}):r!=null&&r.siteGroups.length?s.jsxs("section",{className:"settings-opencli-catalog-section settings-skill-section",children:[s.jsx("div",{className:"settings-model-tabs settings-opencli-filter-tabs",role:"tablist","aria-label":l("settings.opencliFilterTabsLabel"),children:Y.map(F=>{const ne=j===F.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":ne,"data-active":ne?"true":"false",onClick:()=>V(F.id),children:F.label},F.id)})}),U.length>0?s.jsx("div",{className:"settings-opencli-site-grid",children:U.map(F=>{const ne=Dy(F,ie),re=Wy(F.commands),Se=Td(F,{maxDescriptions:2}),ke=Td(F),pe=Xf(F.site),xt=L===F.site;return s.jsxs("div",{className:"settings-opencli-site-card","data-selected":xt?"true":"false",children:[s.jsxs("div",{className:"settings-opencli-site-card-head",children:[s.jsx("div",{className:"settings-opencli-site-card-visual",style:pe.style,children:s.jsx("span",{children:pe.label})}),s.jsxs("div",{className:"settings-opencli-site-card-body",children:[s.jsxs("div",{className:"settings-opencli-site-card-topline",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:F.site}),s.jsxs("div",{className:"settings-opencli-site-card-actions",children:[s.jsx("button",{className:"ghost-button settings-opencli-site-detail-button",type:"button",onClick:()=>I(F.site),children:l("settings.opencliSiteViewAction")}),s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-site-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliSiteToggleLabel",{site:F.site}),type:"checkbox",checked:ne.allSelected,disabled:c||d,ref:Xe=>{Xe&&(Xe.indeterminate=ne.partialSelected)},onChange:Xe=>Ee(F,Xe.target.checked)}),s.jsx("span",{children:l("settings.opencliSiteEnableAction")})]})]})]}),s.jsx("p",{className:"settings-opencli-site-card-description",title:ke,children:Se})]})]}),s.jsx("div",{className:"settings-opencli-site-card-summary",children:s.jsx("div",{className:"settings-opencli-site-card-tag-rows",children:s.jsx("div",{className:"settings-skill-tags settings-opencli-site-card-tag-row settings-opencli-site-card-type-row",children:(re.length>0?re:["unknown"]).slice(0,2).map(Xe=>s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Zf(Xe),children:Jf(Xe)},`${F.site}:${Xe}`))})})})]},F.site)})}):s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliFilteredEmpty")})]}):s.jsx("div",{className:"settings-skill-empty",children:Ky(r)}),s.jsx(Et,{open:G,title:l("settings.opencliDetailTitle"),className:"settings-opencli-detail-modal",onClose:()=>q(!1),children:r?s.jsxs(s.Fragment,{children:[s.jsx(Ys,{heading:l("settings.opencliDetailStatusHeading"),actions:s.jsxs("div",{className:"settings-opencli-detail-tags",children:[s.jsx(Lo,{children:Id(r.provider.installState)}),s.jsx(Lo,{children:zy(r.provider.healthState)}),s.jsx(Lo,{children:Uy(((We=r.activeRuntimeProfile)==null?void 0:We.status)??null)})]}),children:s.jsxs(ru,{compact:!0,className:"settings-opencli-detail-list",children:[s.jsx(pn,{label:l("settings.opencliEnabledStateLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:p?l("settings.opencliEnabledStateOn"):l("settings.opencliEnabledStateOff")})}),s.jsx(pn,{label:l("settings.opencliSummaryCatalogCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(le.catalogCount)})}),s.jsx(pn,{label:l("settings.opencliSummaryEnabledCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(g.length)})}),s.jsx(pn,{label:l("settings.opencliSummaryBrowserCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(le.browserDependentCount)})}),s.jsx(pn,{label:l("settings.opencliVersionLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:r.provider.version??"-"})}),s.jsx(pn,{label:l("settings.opencliCatalogSourceLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Hy(r.effectiveCatalogSource??null)})}),s.jsx(pn,{label:l("settings.opencliLastCheckedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Ed(r.provider.lastCheckedAt)})}),s.jsx(pn,{label:l("settings.opencliCatalogRefreshedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Ed(r.provider.catalogRefreshedAt)})}),s.jsx(pn,{label:l("settings.opencliInstallPathLabel"),description:r.provider.installPath??"-"}),s.jsx(pn,{label:l("settings.opencliDetailRuntimeIdLabel"),description:r.provider.activeRuntimeId??"-"}),s.jsx(pn,{label:l("settings.opencliDetailRuntimeRootLabel"),description:((Ue=r.activeRuntimeProfile)==null?void 0:Ue.runtimeRootPath)??"-"})]})}),r.provider.lastErrorDetail||(Fe=r.activeRuntimeProfile)!=null&&Fe.lastErrorDetail?s.jsx(Ys,{tone:"danger",heading:l("settings.opencliDetailErrorHeading"),children:s.jsxs("div",{className:"settings-opencli-detail-errors",children:[r.provider.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.provider.lastErrorDetail}):null,(rt=r.activeRuntimeProfile)!=null&&rt.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.activeRuntimeProfile.lastErrorDetail}):null]})}):null]}):null}),s.jsx(Et,{open:D!==null,title:D?l("settings.opencliSiteDetailTitle",{site:D.site}):l("settings.opencliCommandModalFallbackTitle"),description:D?l("settings.opencliSiteDetailDescription",{count:K.length,total:D.totalCount}):void 0,className:"settings-opencli-command-modal",onClose:()=>I(null),children:D?s.jsxs("section",{className:"settings-skill-section",children:[s.jsx(Ys,{heading:l("settings.opencliSiteDescriptionHeading"),children:s.jsx("div",{className:"settings-opencli-site-detail-copy",children:Yf(D.commands).map(F=>s.jsx("p",{className:"settings-opencli-site-detail-description",children:F},F))})}),s.jsx(Ys,{heading:l("settings.opencliCommandSearchLabel"),actions:s.jsx(Lo,{children:l("settings.opencliCommandResultCount",{count:K.length})}),children:s.jsxs("div",{className:"settings-opencli-command-tools",children:[s.jsxs("label",{className:"settings-opencli-command-search",htmlFor:"opencli-command-search",children:[s.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSearchLabel")}),s.jsx("input",{id:"opencli-command-search",className:"settings-text-input",type:"search",value:P,placeholder:l("settings.opencliCommandSearchPlaceholder"),onChange:F=>T(F.target.value)})]}),s.jsxs("div",{className:"settings-opencli-command-sort",children:[s.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSortLabel")}),s.jsx("div",{className:"settings-opencli-command-sort-tabs",role:"tablist","aria-label":l("settings.opencliCommandSortLabel"),children:W.map(F=>{const ne=H===F.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab settings-opencli-command-sort-button","aria-selected":ne,"data-active":ne?"true":"false",onClick:()=>_(F.id),children:F.label},F.id)})})]})]})}),K.length>0?s.jsx("div",{className:"settings-opencli-command-grid",children:K.map(F=>s.jsx(Py,{command:F,checked:ie.has(F.commandId),disabled:c||d,onToggle:me},F.commandId))}):s.jsx(hf,{compact:!0,title:l("settings.opencliCommandModalEmpty")})]}):null})]})}function Ay({state:e,className:t}){return s.jsxs("div",{className:`settings-opencli-toolbar${t?` ${t}`:""}`,children:[s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-toolbar-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliProviderToggleLabel"),type:"checkbox",checked:e.draftEnabled,disabled:e.enableDisabled,onChange:n=>e.onEnabledChange(n.target.checked)}),s.jsx("span",{children:l("settings.opencliEnableAction")})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:e.refreshDisabled,onClick:e.onRefresh,children:e.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:e.detailDisabled,onClick:e.onShowDetails,children:l("settings.opencliDetailAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:e.saveDisabled,onClick:e.onSave,children:e.saving?l("common.loading"):l("settings.opencliSaveAction")})]})}function Py({command:e,checked:t,disabled:n,onToggle:r}){const i=Xf(e.commandId);return s.jsxs("div",{className:"settings-opencli-command-card",children:[s.jsxs("div",{className:"settings-opencli-command-card-head",children:[s.jsx("div",{className:"settings-opencli-command-badge",style:i.style,children:s.jsx("span",{children:e.name.slice(0,1).toUpperCase()})}),s.jsxs("div",{className:"settings-opencli-command-card-main",children:[s.jsxs("label",{className:"settings-opencli-checkbox",children:[s.jsx("input",{"aria-label":l("settings.opencliCommandToggleLabel",{commandId:e.commandId}),type:"checkbox",checked:t,disabled:n,onChange:o=>r(e.commandId,o.target.checked)}),s.jsx("span",{children:e.commandId})]}),s.jsx("p",{className:"settings-skill-entry-meta",children:e.description||l("settings.opencliCommandDescriptionEmpty")})]})]}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Zf(e.strategy),children:qy(e.strategy)}),e.browser?s.jsx("span",{className:"settings-skill-tag","data-status":"failed",children:l("settings.opencliBrowserTag")}):s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:l("settings.opencliHttpTag")})]})]})}function Wo({label:e,value:t}){return s.jsxs("div",{className:"settings-skill-summary-card",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function Ly(e){const t=Array.from(new Set(e.map(n=>n.strategy.trim()).filter(n=>n.length>0&&n!=="unknown"))).sort((n,r)=>n.localeCompare(r));return[{id:"all",label:l("settings.opencliFilterAll")},{id:"enabled",label:l("settings.opencliFilterEnabled")},{id:"browser",label:l("settings.opencliFilterBrowser")},{id:"direct",label:l("settings.opencliFilterDirect")},...t.map(n=>({id:`strategy:${n}`,label:l("settings.opencliFilterStrategy",{strategy:Jf(n)})}))]}function Nd(e,t,n){switch(t){case"all":return!0;case"enabled":return n.has(e.commandId);case"browser":return e.browser;case"direct":return!e.browser;default:return t.startsWith("strategy:")?e.strategy===t.slice(9):!0}}function Dy(e,t){const n=e.commands.filter(r=>t.has(r.commandId)).length;return{selectedCount:n,allSelected:n>0&&n===e.commands.length,partialSelected:n>0&&n<e.commands.length}}function _y(e,t){return t?[e.commandId,e.name,e.description,e.strategy].join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel-h0kvRbSR.js","assets/index-DvkfRpBe.js","assets/index-CkkzIvxs.css","assets/App-BRupl2Ul.js","assets/App-CcDXqFl1.css","assets/model-switch-api-Dps4yN2t.js","assets/WorkbenchModal-CAj_TqWW.js","assets/file-tree-icon-CLfk31E7.js","assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js","assets/relay-entry-WiotM2TL.js","assets/GitSidebar-TlaPNhxG.js","assets/TerminalManagerPanel-Bkgr9ZNV.js","assets/terminal-runtime-meta-C3Mr0zW5.js","assets/TerminalRuntimeFallbackModal-D_BUt6HD.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var rk=Object.defineProperty;var sk=(e,t,n)=>t in e?rk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ke=(e,t,n)=>sk(e,typeof t!="symbol"?t+"":t,n);import{C as xe,t as l,b as f,j as s,e as Bn,m as Ji,H as Jc,J as af,F as ik,K as ok,w as Qc,A as Zc,g as lf,D as ak,p as Wa,L as lk,M as ck,N as cf,i as uf,O as dc,f as eu,h as hc,P as uk,l as df,y as dk,n as hk,z as pk,d as fk,_ as tu}from"./index-DvkfRpBe.js";import{m as at,e as bn,h as Fa,u as ao,f as Wn,g as ur,i as mk,j as gk,O as td}from"./App-BRupl2Ul.js";import{e as nu,f as Ys,i as ru,j as pn,k as Lo,V as hf,A as bk,a2 as kk,a3 as xk,H as pf,l as yk,m as wk,a4 as ff,a5 as vk,M as Sk,a6 as Ck,a7 as Nk,n as jk,t as Tk,q as Ik,s as mf,h as Hs,a as pc,v as Ek,o as Mk,p as su,a8 as Rk,a9 as Ak,aa as Pk,u as Do,g as Lk,ab as Dk,ac as _k,ad as Bk,ae as gf,af as Ok,ag as bf,ah as Wk,ai as Fk,aj as kf,K as $k,S as zk,R as nd,r as Hk,ak as Uk}from"./model-switch-api-Dps4yN2t.js";import{t as Xs,P as ya,g as xf}from"./window-BVUB8gMK.js";import{R as qk,_ as rd,a as sd,C as yf,i as Le}from"./event-DvH9tcej.js";import{W as Et,M as Gk,D as iu}from"./WorkbenchModal-CAj_TqWW.js";import{r as Vk,b as Kk}from"./relay-entry-WiotM2TL.js";const Js=new Map,wf=48;function ps(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function id(e,t){return!Number.isFinite(e)||Date.now()-e>t}function Yk(e){return!e||typeof e!="object"||!("savedAt"in e)||!("value"in e)?!1:Number.isFinite(e.savedAt)}function vf(e){try{const t=JSON.parse(e);return Yk(t)?t:null}catch{return null}}function Xk(){if(!ps())return[];try{return Array.from({length:window.sessionStorage.length},(e,t)=>window.sessionStorage.key(t)).filter(e=>typeof e=="string"&&e.length>0)}catch{return[]}}function Sf(){if(!ps())return[];const e=[];for(const t of Xk()){let n=null;try{n=window.sessionStorage.getItem(t)}catch{continue}if(!n)continue;const r=vf(n);r&&e.push({key:t,savedAt:r.savedAt})}return e.sort((t,n)=>t.savedAt-n.savedAt)}function Qi(e){if(ps())try{window.sessionStorage.removeItem(e)}catch{}}function _o(e){const t=new Set((e==null?void 0:e.preserveKeys)??[]),n=(e==null?void 0:e.maxCount)??wf,r=Sf().filter(o=>!t.has(o.key)),i=Math.max(0,t.size+r.length-n);for(let o=0;o<i;o+=1){const a=r[o];if(!a)break;Qi(a.key)}}function Jk(e){return e instanceof DOMException&&(e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED"||e.code===22||e.code===1014)}function yl(e,t){if(!ps())return"failed";try{return window.sessionStorage.setItem(e,t),"success"}catch(n){return Jk(n)?"quota_exceeded":"failed"}}function Qk(e,t){const n=yl(e,t);if(n==="success"){_o({preserveKeys:[e]});return}if(n==="quota_exceeded"){if(Qi(e),_o({maxCount:Math.max(0,wf-1)}),yl(e,t)==="success"){_o({preserveKeys:[e]});return}for(const r of Sf())if(r.key!==e&&(Qi(r.key),yl(e,t)==="success")){_o({preserveKeys:[e]});return}}}function wa(e,t){const n=Js.get(e);if(n){if(!id(n.savedAt,t))return n.value;Js.delete(e)}if(!ps())return null;let r=null;try{r=window.sessionStorage.getItem(e)}catch{return null}if(!r)return null;const i=vf(r);return!i||id(i.savedAt,t)?(Qi(e),Js.delete(e),null):(Js.set(e,i),i.value)}function qi(e,t){const n={savedAt:Date.now(),value:t};if(Js.set(e,n),!!ps())try{Qk(e,JSON.stringify(n))}catch{}}function LA(e){Js.delete(e),ps()&&Qi(e)}const Zk="codingns.debug.perf",ex="codingns.debug.sessionMessageDedup",tx="codingns.debug.opencodeOrder",nx="codingns.debug.timelineScroll";function rx(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Zk)==="1"}catch{return!1}}function Ot(e,t){if(!rx()||typeof performance>"u")return;const n=Math.round(performance.now());if(t&&Object.keys(t).length>0){console.info(`[perf-ui] ${e} ${n}ms`,t);return}console.info(`[perf-ui] ${e} ${n}ms`)}function sx(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(ex)==="1"}catch{return!1}}function fc(e,t){if(!sx()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,o=i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__??[];o.push(r),o.length>300&&o.splice(0,o.length-300),i.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[session-dedup] ${e} ${n}ms`,t);return}console.info(`[session-dedup] ${e} ${n}ms`)}function ix(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(tx)==="1"}catch{return!1}}function DA(e,t){if(!ix()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,o=i.__CODINGNS_OPENCODE_ORDER_DEBUG__??[];o.push(r),o.length>500&&o.splice(0,o.length-500),i.__CODINGNS_OPENCODE_ORDER_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[opencode-order-ui] ${e} ${n}ms`,t);return}console.info(`[opencode-order-ui] ${e} ${n}ms`)}function mc(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(nx)==="1"}catch{return!1}}function ox(e,t){if(!mc()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const i=window,o=i.__CODINGNS_TIMELINE_SCROLL_DEBUG__??[];o.push(r),o.length>300&&o.splice(0,o.length-300),i.__CODINGNS_TIMELINE_SCROLL_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[timeline-scroll] ${e} ${n}ms`,t);return}console.info(`[timeline-scroll] ${e} ${n}ms`)}function _A(e,t,n,r){return xe.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:t,content:n,expectedVersion:r??void 0})})}function BA(e){return xe.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function OA(e){return xe.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function WA(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return xe.request(`/api/files/download?${n.toString()}`)}function ax(e,t,n=1,r=20){const i=new URLSearchParams({workspaceId:e,keyword:t,page:String(n),pageSize:String(r)});return xe.request(`/api/files/search?${i.toString()}`)}function FA(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return xe.request(`/api/files/preview?${n.toString()}`)}function lx(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return xe.request(`/api/files/preview-link?${n.toString()}`)}function $A(e){return xe.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function zA(e){return xe.request("/api/git/init",{method:"POST",body:JSON.stringify({workspaceId:e})})}function HA(e,t,n){const r=new URLSearchParams({workspaceId:e,path:t,staged:String(n)});return xe.request(`/api/git/diff?${r.toString()}`)}function UA(e,t){return xe.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function qA(e,t){return xe.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function GA(e,t){return xe.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function VA(e,t){return xe.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:t})})}function KA(e,t){return xe.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:t})})}function YA(e){return xe.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function XA(e,t=5,n=null){const r=new URLSearchParams({workspaceId:e,limit:String(t)});return n&&r.set("cursor",n),xe.request(`/api/git/history?${r.toString()}`)}function JA(e,t){const n=new URLSearchParams({workspaceId:e,commitHash:t});return xe.request(`/api/git/commit-detail?${n.toString()}`)}function cx(e){return xe.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function ux(e){return xe.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function QA(e,t,n){return xe.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:t,create:n})})}function ZA(e,t,n,r,i){return xe.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:t,...n?{remote:n}:{},...r?{auth:r}:{},...i?{remember:i}:{}})})}function eP(e){return xe.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}var pa,fa;function Cf(e){var t;if("items"in e)e.items=(t=e.items)===null||t===void 0?void 0:t.map(n=>"rid"in n?n:Cf(n));else if("action"in e&&e.action){const n=new yf;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function ai(e,t){const n=new yf;if(t&&typeof t=="object"&&("action"in t&&t.action&&(n.onmessage=t.action,delete t.action),"item"in t&&t.item&&typeof t.item=="object"&&"About"in t.item&&t.item.About&&typeof t.item.About=="object"&&"icon"in t.item.About&&t.item.About.icon&&(t.item.About.icon=Xs(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=Xs(t.icon)),"items"in t&&t.items)){let r=function(i){var o;return"rid"in i?[i.rid,i.kind]:("item"in i&&typeof i.item=="object"&&(!((o=i.item.About)===null||o===void 0)&&o.icon)&&(i.item.About.icon=Xs(i.item.About.icon)),"icon"in i&&i.icon&&(i.icon=Xs(i.icon)),"items"in i&&i.items&&(i.items=i.items.map(r)),Cf(i))};t.items=t.items.map(r)}return Le("plugin:menu|new",{kind:e,options:t,handler:n})}class li extends qk{get id(){return rd(this,pa,"f")}get kind(){return rd(this,fa,"f")}constructor(t,n,r){super(t),pa.set(this,void 0),fa.set(this,void 0),sd(this,pa,n),sd(this,fa,r)}}pa=new WeakMap,fa=new WeakMap;class ou extends li{constructor(t,n){super(t,n,"MenuItem")}static async new(t){return ai("MenuItem",t).then(([n,r])=>new ou(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}}class au extends li{constructor(t,n){super(t,n,"Check")}static async new(t){return ai("Check",t).then(([n,r])=>new au(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async isChecked(){return Le("plugin:menu|is_checked",{rid:this.rid})}async setChecked(t){return Le("plugin:menu|set_checked",{rid:this.rid,checked:t})}}var od;(function(e){e.Add="Add",e.Advanced="Advanced",e.Bluetooth="Bluetooth",e.Bookmarks="Bookmarks",e.Caution="Caution",e.ColorPanel="ColorPanel",e.ColumnView="ColumnView",e.Computer="Computer",e.EnterFullScreen="EnterFullScreen",e.Everyone="Everyone",e.ExitFullScreen="ExitFullScreen",e.FlowView="FlowView",e.Folder="Folder",e.FolderBurnable="FolderBurnable",e.FolderSmart="FolderSmart",e.FollowLinkFreestanding="FollowLinkFreestanding",e.FontPanel="FontPanel",e.GoLeft="GoLeft",e.GoRight="GoRight",e.Home="Home",e.IChatTheater="IChatTheater",e.IconView="IconView",e.Info="Info",e.InvalidDataFreestanding="InvalidDataFreestanding",e.LeftFacingTriangle="LeftFacingTriangle",e.ListView="ListView",e.LockLocked="LockLocked",e.LockUnlocked="LockUnlocked",e.MenuMixedState="MenuMixedState",e.MenuOnState="MenuOnState",e.MobileMe="MobileMe",e.MultipleDocuments="MultipleDocuments",e.Network="Network",e.Path="Path",e.PreferencesGeneral="PreferencesGeneral",e.QuickLook="QuickLook",e.RefreshFreestanding="RefreshFreestanding",e.Refresh="Refresh",e.Remove="Remove",e.RevealFreestanding="RevealFreestanding",e.RightFacingTriangle="RightFacingTriangle",e.Share="Share",e.Slideshow="Slideshow",e.SmartBadge="SmartBadge",e.StatusAvailable="StatusAvailable",e.StatusNone="StatusNone",e.StatusPartiallyAvailable="StatusPartiallyAvailable",e.StatusUnavailable="StatusUnavailable",e.StopProgressFreestanding="StopProgressFreestanding",e.StopProgress="StopProgress",e.TrashEmpty="TrashEmpty",e.TrashFull="TrashFull",e.User="User",e.UserAccounts="UserAccounts",e.UserGroup="UserGroup",e.UserGuest="UserGuest"})(od||(od={}));class lu extends li{constructor(t,n){super(t,n,"Icon")}static async new(t){return ai("Icon",t).then(([n,r])=>new lu(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async setIcon(t){return Le("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Xs(t)})}}class cu extends li{constructor(t,n){super(t,n,"Predefined")}static async new(t){return ai("Predefined",t).then(([n,r])=>new cu(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}}function ti([e,t,n]){switch(n){case"Submenu":return new $a(e,t);case"Predefined":return new cu(e,t);case"Check":return new au(e,t);case"Icon":return new lu(e,t);case"MenuItem":default:return new ou(e,t)}}class $a extends li{constructor(t,n){super(t,n,"Submenu")}static async new(t){return ai("Submenu",t).then(([n,r])=>new $a(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async append(t){return Le("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return Le("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return Le("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return Le("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return Le("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(ti)}async items(){return Le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(ti))}async get(t){return Le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?ti(n):null)}async popup(t,n){var r;return Le("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof ya?t:t?new ya(t):null})}async setAsWindowsMenuForNSApp(){return Le("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return Le("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(t){return Le("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Xs(t)})}}class Qs extends li{constructor(t,n){super(t,n,"Menu")}static async new(t){return ai("Menu",t).then(([n,r])=>new Qs(n,r))}static async default(){return Le("plugin:menu|create_default").then(([t,n])=>new Qs(t,n))}async append(t){return Le("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return Le("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return Le("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return Le("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return Le("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(ti)}async items(){return Le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(ti))}async get(t){return Le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?ti(n):null)}async popup(t,n){var r;return Le("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof ya?t:t?new ya(t):null})}async setAsAppMenu(){return Le("plugin:menu|set_as_app_menu",{rid:this.rid}).then(t=>t?new Qs(t[0],t[1]):null)}async setAsWindowMenu(t){var n;return Le("plugin:menu|set_as_window_menu",{rid:this.rid,window:(n=t==null?void 0:t.label)!==null&&n!==void 0?n:null}).then(r=>r?new Qs(r[0],r[1]):null)}}async function dx(e){if(e.length===0)return;await(await Qs.new({items:await Promise.all(e.map(n=>Nf(n)))})).popup(void 0,xf())}async function Nf(e){return"items"in e?$a.new({id:e.id,text:e.label,enabled:!e.disabled,items:await Promise.all(e.items.map(t=>Nf(t)))}):{id:e.id,text:e.label,enabled:!e.disabled,accelerator:e.accelerator,action:()=>{e.onSelect()}}}const ad={"parallel-group-1":{accent:"#0ea5e9",soft:"rgba(14, 165, 233, 0.16)",surface:"rgba(14, 165, 233, 0.08)"},"parallel-group-2":{accent:"#10b981",soft:"rgba(16, 185, 129, 0.16)",surface:"rgba(16, 185, 129, 0.08)"},"parallel-group-3":{accent:"#f59e0b",soft:"rgba(245, 158, 11, 0.16)",surface:"rgba(245, 158, 11, 0.08)"},"parallel-group-4":{accent:"#ec4899",soft:"rgba(236, 72, 153, 0.16)",surface:"rgba(236, 72, 153, 0.08)"},"parallel-group-5":{accent:"#8b5cf6",soft:"rgba(139, 92, 246, 0.16)",surface:"rgba(139, 92, 246, 0.08)"},"parallel-group-6":{accent:"#f97316",soft:"rgba(249, 115, 22, 0.16)",surface:"rgba(249, 115, 22, 0.08)"}},hx=2600,jf="workbench.parallel.pane.palette";let Us=null;const ld=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"];function px(e="create"){return e==="append"?{totalDurationMs:1200,sidebarCollapseDurationMs:0,paneEnterDelayMs:0,paneEnterDurationMs:1e3,gridRevealDelayMs:0,gridRevealDurationMs:920,shellExpandDurationMs:0,paneStaggerMs:80}:{totalDurationMs:2e3,sidebarCollapseDurationMs:720,paneEnterDelayMs:520,paneEnterDurationMs:1480,gridRevealDelayMs:420,gridRevealDurationMs:1360,shellExpandDurationMs:720,paneStaggerMs:96}}function Tf(e){var n,r;const t=(n=e.displayParentSessionId)==null?void 0:n.trim();return t||((r=e.parentSessionId)==null?void 0:r.trim())||null}function fx(e){var r;const t=(r=e==null?void 0:e.colorToken)==null?void 0:r.trim();if(!t)return;const n=ad[t]??ad["parallel-group-1"];return{"--parallel-group-accent":n.accent,"--parallel-group-soft":n.soft,"--parallel-group-surface":n.surface}}function tP(e){const t=va(e.overrideColor)??mx(e.groupId,e.ordinal);return{"--parallel-group-accent":t,"--parallel-group-soft":cd(t,.08),"--parallel-group-surface":cd(t,.03)}}function nP(e){if(typeof window>"u")return null;const t=e.trim();if(!t)return null;const n=If();return va(n[t]??null)}function rP(e,t){if(typeof window>"u")return va(t);const n=e.trim();if(!n)return null;const r=If(),i=va(t);return i?r[n]=i:delete r[n],window.localStorage.setItem(jf,JSON.stringify(r)),i}function mx(e,t){const n=ld.length,r=Math.abs(wx(e))%n;return ld[(r+t*5)%n]}function sP(e){return e?e.role==="anchor"?l("shell.parallelGroupAnchorBadge"):l("shell.parallelGroupMemberBadge"):null}function gx(e){return e?l("shell.parallelGroupBadge",{count:e.memberCount}):null}function iP(e){var n;return((n=e==null?void 0:e.branchName)==null?void 0:n.trim())||null}function oP(e){var n,r,i;return((r=(n=e==null?void 0:e.parallelGroup)==null?void 0:n.groupId)==null?void 0:r.trim())?((i=e==null?void 0:e.sessionIsolatedWorkspace)==null?void 0:i.lifecycleStatus)!=="promoted":!1}function bx(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="removing")?t.sourceWorkspaceId:e.workspaceId}function kx(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="promoted")?t.workspaceId:e.workspaceId}function xx(e,t="create"){Us={groupId:e,createdAt:Date.now(),...px(t)}}function yx(e){return!Us||Us.groupId!==e?null:Date.now()-Us.createdAt>hx?(Us=null,null):Us}function If(){if(typeof window>"u")return{};const e=window.localStorage.getItem(jf);if(!e)return{};try{const t=JSON.parse(e);return!t||typeof t!="object"?{}:t}catch{return{}}}function wx(e){let t=0;for(const n of e)t=t*31+n.charCodeAt(0)|0;return t}function va(e){const t=(e==null?void 0:e.trim().toUpperCase())??"";return/^#[0-9A-F]{6}$/.test(t)?t:null}function cd(e,t){const n=Math.max(0,Math.min(t,1)),r=Number.parseInt(e.slice(1,3),16),i=Number.parseInt(e.slice(3,5),16),o=Number.parseInt(e.slice(5,7),16);return`rgba(${r}, ${i}, ${o}, ${n})`}function uu(e,t){const n=new Map(e.map(o=>[t.getId(o),o])),r=new Map,i=[];for(const o of e){const a=vx(o,n,t);if(!a){i.push(o);continue}const c=r.get(a)??[];r.set(a,[...c,o])}return[...i].sort(t.compare).map(o=>Rf(o,0,r,t,new Set))}function ci(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function Ef(e){return e.flatMap(t=>[t.item,...Ef(ci(t))])}function ss(e){return e.flatMap(t=>[t,...ss(ci(t))])}function du(e,t){return e.some(n=>t(n.item)||du(ci(n),t))}function Mf(e,t,n){return e?n(e.item)===t?!0:ci(e).some(r=>Mf(r,t,n)):!1}function qs(e,t,n){for(const r of e){const i=n(r.item);if(i===t)return[];const o=qs(ci(r),t,n);if(Mf(r,t,n)&&o.length>=0)return[i,...o]}return[]}function Rf(e,t,n,r,i){const o=r.getId(e),a=new Set(i);a.add(o);const c=[...n.get(o)??[]].filter(u=>!a.has(r.getId(u))).sort(r.compare).map(u=>Rf(u,t+1,n,r,a));return{item:e,depth:t,children:c}}function vx(e,t,n){const r=ud(n.getParentId(e));if(!r)return null;const i=t.get(r);if(!i)return null;const o=new Set([n.getId(e)]);let a=i;for(;a;){const c=n.getId(a);if(o.has(c))return null;o.add(c);const u=ud(n.getParentId(a));if(!u||(a=t.get(u),!a))return r}return r}function ud(e){const t=e==null?void 0:e.trim();return t||null}function Zt(){return"/workspaces"}function rr(e){return`/workspaces/${encodeURIComponent(e)}`}function Af(e){return`${rr(e)}/debug`}function ii(e){return`${rr(e)}/sessions`}function _n(e,t){return`${ii(e)}/${encodeURIComponent(t)}`}function Pf(e,t){const n=`${rr(e)}/tools`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function Lf(e){return`${rr(e)}/tools/files`}function Df(e){return`${rr(e)}/tools/git`}function _f(e){return`${rr(e)}/tools/processes`}function is(e){return`${rr(e)}/terminals`}function cs(e,t){const n=`${rr(e)}/butler`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function Sx(e){return Wf(e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...Of(t.childWorktrees??[])])).sort((t,n)=>(n.session.lastMessageAt??n.session.updatedAt).localeCompare(t.session.lastMessageAt??t.session.updatedAt))}function aP(e,t){return uu(Wf(e),{getId:n=>n.session.sessionId,getParentId:n=>Cx(n.session,t),compare:jx})}function Cx(e,t){var n;return(t==null?void 0:t.mode)==="mobile"?((n=e.parentSessionId)==null?void 0:n.trim())||null:Tf(e)}function Bf(e,t){const n=Nx(),r=new URLSearchParams({provider:t});return`${_n(e,n)}?${r.toString()}`}function Nx(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function jx(e,t){return(t.session.lastMessageAt??t.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function Of(e){return e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...Of(t.children)])}function Wf(e){const t=[],n=new Set;for(const r of e){const i=r.session.sessionId.trim();!i||n.has(i)||(n.add(i),t.push(r))}return t}const Tx="mobile.tools.last-primary-tool";function Ff(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(Tx)==="git"?"git":"files"}catch{return"files"}}function hu(e){var r;const t=[{pattern:"/workspaces/:workspaceId/tools/processes",routeKind:"processes"},{pattern:"/workspaces/:workspaceId/tools/files",routeKind:"files"},{pattern:"/workspaces/:workspaceId/tools/git",routeKind:"git"},{pattern:"/workspaces/:workspaceId/tools",routeKind:"home"}];for(const i of t){const o=at(i.pattern,e),a=((r=o==null?void 0:o.params.workspaceId)==null?void 0:r.trim())??null;if(a)return{workspaceId:a,routeKind:i.routeKind,legacy:!1}}const n=[{pattern:"/tools/processes",routeKind:"processes"},{pattern:"/tools/files",routeKind:"files"},{pattern:"/tools/git",routeKind:"git"},{pattern:"/tools",routeKind:"home"}];for(const i of n)if(at(i.pattern,e))return{workspaceId:null,routeKind:i.routeKind,legacy:!0};return null}function Ix(e,t){const n=hu(e);if((n==null?void 0:n.routeKind)==="git")return"git";if((n==null?void 0:n.routeKind)==="files")return"files";const r=new URLSearchParams(t).get("tab");return r==="git"?"git":r==="files"?"files":Ff()}function pu(e,t){const n=hu(e);return(n==null?void 0:n.routeKind)==="processes"&&n.workspaceId?is(n.workspaceId):n!=null&&n.workspaceId?Pf(n.workspaceId,Ix(e,t)):n!=null&&n.legacy?Ff()==="git"?"/tools?tab=git":"/tools?tab=files":null}function fu({activeEntry:e,presentation:t,pathname:n,search:r,moreButtonLabel:i}){if(t==="conversation-focus"||e!=="butler")return null;const o=hu(n);return o?o.routeKind==="processes"?{title:l("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:i}:(o.routeKind==="home"||o.routeKind==="files"||o.routeKind==="git",null):null}const $f=f.createContext({composerPortalTarget:null});function mu({composerPortalTarget:e,children:t}){return s.jsx($f.Provider,{value:{composerPortalTarget:e},children:t})}function lP(){return f.useContext($f)}function gu(e,t,n){const[r,i]=f.useState(void 0);return f.useEffect(()=>{const o=e.current,a=t.current;if(!n||!o||!a){i(void 0),o&&o.style.removeProperty("--mobile-conversation-tabbar-height");return}const c=o,u=a;function d(){if(!e.current||!u.isConnected)return;const p=`${Math.round(u.getBoundingClientRect().height)}px`;c.style.setProperty("--mobile-conversation-tabbar-height",p),i(p)}d();const h=typeof ResizeObserver<"u"?new ResizeObserver(d):null;return h==null||h.observe(u),window.addEventListener("resize",d),()=>{h==null||h.disconnect(),window.removeEventListener("resize",d),c.style.removeProperty("--mobile-conversation-tabbar-height")}},[n,e,t]),r}const Ex=3e3,Bo=10,dd=84,hd=.36;function bu({enabled:e,rootRef:t,suspended:n=!1,resetKey:r}){const i=f.useRef(null),o=f.useRef(null),a=f.useRef("visible"),c=f.useRef(1),[u,d]=f.useState("visible"),[h,p]=f.useState(1);f.useEffect(()=>{a.current=u},[u]),f.useEffect(()=>{c.current=h},[h]);function m(){ts(i),i.current=window.setTimeout(()=>{g()},Ex)}function g(){d("hidden"),p(0)}function x(){d("visible"),p(1),m()}f.useEffect(()=>{if(ts(i),!e){ts(i),d("visible"),p(1);return}if(n){d("hidden"),p(0);return}return x(),()=>{ts(i)}},[e,r,n]),f.useEffect(()=>()=>{ts(i)},[]),f.useEffect(()=>{if(!e||n){o.current=null;return}const C=t.current;if(!C)return;function y(q){if(q.touches.length!==1){o.current=null;return}const P=q.touches[0],T=md(q.target);if(!P||!T){o.current=null;return}o.current={surface:T,startX:P.clientX,startY:P.clientY,pointerType:"touch",initialState:a.current==="visible"?"visible":"hidden",touchId:P.identifier,dragging:!1,latestProgress:c.current},a.current==="visible"&&ts(i)}function A(q){const P=o.current;if(!P||P.pointerType!=="touch")return;const T=wl(q.touches,P.touchId);if(!T)return;const H=T.clientX-P.startX,_=T.clientY-P.startY;if(P.surface==="conversation"){if(Math.abs(_)<=Bo||Math.abs(_)<=Math.abs(H))return;o.current=null,P.initialState==="visible"&&g();return}const ie=P.initialState==="hidden"?-_:_;ie<=Bo&&!P.dragging||(bd(q),P.dragging=!0,P.latestProgress=pd(P.initialState,ie),d("dragging"),p(P.latestProgress))}function j(q){const P=o.current;if(!(!P||P.pointerType!=="touch"||!wl(q.changedTouches,P.touchId))){if(o.current=null,!P.dragging){P.initialState==="visible"&&m();return}fd(P.initialState,P.latestProgress,x,d,p)}}function V(q){const P=o.current;if(!(!P||P.pointerType!=="touch"||!wl(q.changedTouches,P.touchId))){if(o.current=null,!P.dragging){P.initialState==="visible"&&m();return}if(P.initialState==="visible"){x();return}d("hidden"),p(0)}}function L(q){if(q.pointerType!=="touch")return;const P=md(q.target);if(!P){o.current=null;return}if(o.current={surface:P,startX:q.clientX,startY:q.clientY,pointerType:"pointer",initialState:a.current==="visible"?"visible":"hidden",pointerId:q.pointerId,captureTarget:q.target instanceof Element?q.target:null,dragging:!1,latestProgress:c.current},q.target instanceof Element)try{q.target.setPointerCapture(q.pointerId)}catch{}a.current==="visible"&&ts(i)}function I(q){const P=o.current;if(!P||P.pointerType!=="pointer")return;const T=q.clientX-P.startX,H=q.clientY-P.startY;if(P.surface==="conversation"){if(Math.abs(H)<=Bo||Math.abs(H)<=Math.abs(T))return;o.current=null,P.initialState==="visible"&&g();return}const _=P.initialState==="hidden"?-H:H;_<=Bo&&!P.dragging||(bd(q),P.dragging=!0,P.latestProgress=pd(P.initialState,_),d("dragging"),p(P.latestProgress))}function G(q){const P=o.current;if(!(!P||P.pointerType!=="pointer"||P.pointerId!==q.pointerId)){if(o.current=null,Mx(P),!P.dragging){P.initialState==="visible"&&m();return}fd(P.initialState,P.latestProgress,x,d,p)}}return C.addEventListener("touchstart",y,{passive:!0}),C.addEventListener("pointerdown",L,{passive:!0}),window.addEventListener("touchmove",A,{passive:!1}),window.addEventListener("touchend",j),window.addEventListener("touchcancel",V),window.addEventListener("pointermove",I,{passive:!1}),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G),()=>{C.removeEventListener("touchstart",y),C.removeEventListener("pointerdown",L),window.removeEventListener("touchmove",A),window.removeEventListener("touchend",j),window.removeEventListener("touchcancel",V),window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G)}},[e,t,n]);const S=e&&!n?h:e?0:1;return{state:n&&e?"hidden":u,progress:S,isOpen:S>.01}}function ts(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function pd(e,t){return gd(e==="hidden"?t/dd:1-t/dd,0,1)}function fd(e,t,n,r,i){if(e==="hidden"){if(t>=hd){n();return}r("hidden"),i(0);return}if(t<=1-hd){r("hidden"),i(0);return}n()}function Mx(e){if(!(e.pointerType!=="pointer"||typeof e.pointerId!="number"||!(e.captureTarget instanceof Element)))try{e.captureTarget.hasPointerCapture(e.pointerId)&&e.captureTarget.releasePointerCapture(e.pointerId)}catch{}}function wl(e,t){if(typeof t!="number")return e[0]??null;for(let n=0;n<e.length;n+=1){const r=e[n];if((r==null?void 0:r.identifier)===t)return r}return null}function md(e){return e instanceof Element?e.closest(".composer-panel")?"composer":e.closest(".message-list, .message-timeline, .mobile-conversation-main, .conversation-page-shell, .mobile-butler-main-stage, .mobile-butler-chat-body, .mobile-butler-page-shell")?"conversation":null:null}function gd(e,t,n){return Math.min(Math.max(e,t),n)}function bd(e){e.cancelable&&e.preventDefault()}function lo({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1}){return i||e==="compact"?"compact":e==="expanded"&&n&&r?"expanded":t==="butler"&&r?"medium-auxiliary":n?"medium-navigation":r?"medium-auxiliary":"compact"}function za(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function zf(e){return e==="medium-navigation"||e==="expanded"}function Hf(e){return e==="medium-auxiliary"||e==="expanded"}function ku({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i=!1,children:o,navigationPanel:a,auxiliaryPanel:c}){const u=lo({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:i}),d=zf(u)&&a,h=Hf(u)&&c;return s.jsxs("div",{className:"mobile-adaptive-pane-layout","data-pane-layout":u,children:[d?s.jsx("aside",{className:"workbench-nav surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-navigation",children:a}):null,s.jsx("div",{className:"mobile-adaptive-pane-main",children:o}),h?s.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:c}):null]})}function Rx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=bn(),m=nu(),g=Fa(),x=ao(),S=f.useRef(null),C=f.useRef(null),[y,A]=f.useState(null),j=t==="conversation-focus",V=za({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),L=bu({enabled:j,rootRef:S,resetKey:`${g.pathname}${g.search}`}),I=lo({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:V}),G=fu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.androidMoreAction")}),q=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Lx,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Dx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Bx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(_x,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Ox,{}),onClick:h}],P=j?{"--mobile-conversation-tabbar-progress":L.progress.toFixed(4)}:void 0;gu(S,C,j);function T(){const _=pu(g.pathname,g.search);if(!_){a();return}x(_,{replace:!0})}const H=s.jsx("nav",{ref:C,className:"android-workbench-bottom-nav","aria-label":l("shell.title"),children:q.map(_=>s.jsxs("button",{type:"button",className:"android-workbench-bottom-nav-item","data-active":_.key===e,"aria-current":_.key===e?"page":void 0,onClick:()=>{_.key!==e&&m.trigger("selection"),_.onClick()},children:[s.jsx("span",{className:"android-workbench-bottom-nav-icon","aria-hidden":"true",children:_.icon}),s.jsx("span",{className:"android-workbench-bottom-nav-label",children:_.label})]},_.key))});return s.jsx(mu,{composerPortalTarget:j?y:null,children:s.jsxs("div",{ref:S,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":I,"data-tabbar-open":j?L.isOpen:!0,"data-conversation-tabbar-state":j?L.state:"default",style:P,children:[G?s.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[s.jsxs("div",{className:"android-workbench-topbar-leading",children:[G.showBackButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":l("common.back"),onClick:T,children:s.jsx(Ax,{})}):null,s.jsx("div",{className:"android-workbench-topbar-copy",children:s.jsx("h1",{children:G.title})})]}),s.jsx("div",{className:"android-workbench-topbar-actions",children:G.showMoreButton?s.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":G.moreButtonLabel,onClick:d,children:s.jsx(Px,{})}):null})]}):null,s.jsx("div",{className:"android-workbench-content",children:s.jsx(ku,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:V,navigationPanel:r,auxiliaryPanel:i,children:n})}),j?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:H})]}):H]})})}function Ax(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function Px(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Lx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function Dx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function _x(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function Bx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Ox(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}const Wx=120,Oi={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function gc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Fx(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable||e.closest("[contenteditable='true']"))return!0;if(e instanceof HTMLTextAreaElement)return!e.readOnly&&!e.disabled;if(e instanceof HTMLInputElement){if(e.readOnly||e.disabled)return!1;const t=(e.type||"text").toLowerCase();return!["button","checkbox","color","file","hidden","image","radio","range","reset","submit"].includes(t)}return!1}function $x(){var t;if(typeof window>"u")return 0;const e=[window.innerHeight,typeof document<"u"?(t=document.documentElement)==null?void 0:t.clientHeight:0].filter(gc);return e.length>0?Math.max(...e):0}function kd(){if(typeof window>"u")return Oi;const e=window.visualViewport,t=$x(),n=(e==null?void 0:e.height)??t,r=gc(n)?Math.round(n):null,i=gc(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,o=r===null?0:Math.max(0,Math.round(t-r-i));return{viewportHeight:r,keyboardInset:o,keyboardOpen:Fx(typeof document<"u"?document.activeElement:null)&&o>=Wx}}function vl(e,t){if(typeof document>"u")return;[document.documentElement,document.body].filter(r=>r instanceof HTMLElement).forEach(r=>{if(!e){delete r.dataset.mobileKeyboardOpen,delete r.dataset.mobileViewportBound,r.style.removeProperty("--mobile-shell-viewport-height"),r.style.removeProperty("--mobile-shell-keyboard-inset");return}r.dataset.mobileKeyboardOpen=String(t.keyboardOpen),r.dataset.mobileViewportBound="true",t.viewportHeight===null?r.style.removeProperty("--mobile-shell-viewport-height"):r.style.setProperty("--mobile-shell-viewport-height",`${t.viewportHeight}px`),r.style.setProperty("--mobile-shell-keyboard-inset",`${t.keyboardInset}px`)})}function zx(e){const[t,n]=f.useState(()=>e?kd():Oi),r=f.useRef(null);return f.useEffect(()=>{if(!e){n(Oi),vl(!1,Oi);return}function i(){n(kd())}function o(){r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,i()},0)}i();const a=window.visualViewport;return window.addEventListener("resize",i),window.addEventListener("orientationchange",i),a==null||a.addEventListener("resize",i),a==null||a.addEventListener("scroll",i),document.addEventListener("focusin",i),document.addEventListener("focusout",o),()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),window.removeEventListener("resize",i),window.removeEventListener("orientationchange",i),a==null||a.removeEventListener("resize",i),a==null||a.removeEventListener("scroll",i),document.removeEventListener("focusin",i),document.removeEventListener("focusout",o),vl(!1,Oi)}},[e]),f.useEffect(()=>{vl(e,t)},[e,t]),t}function Hx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=bn(),m=nu(),g=Fa(),x=ao(),S=f.useRef(null),C=f.useRef(null),[y,A]=f.useState(null),j=t==="conversation-focus",V=za({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),L=bu({enabled:j,rootRef:S,resetKey:`${g.pathname}${g.search}`}),I=lo({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:V}),G=fu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.iosMoreAction")}),q=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(Gx,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(Vx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(Yx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(Kx,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(Xx,{}),onClick:h}],P=j?{"--mobile-conversation-tabbar-progress":L.progress.toFixed(4)}:void 0;gu(S,C,j);function T(){const _=pu(g.pathname,g.search);if(!_){a();return}x(_,{replace:!0})}const H=s.jsx("nav",{ref:C,className:"ios-workbench-tabbar","aria-label":l("shell.title"),children:q.map(_=>s.jsxs("button",{type:"button",className:"ios-workbench-tabbar-item","data-active":_.key===e,"aria-current":_.key===e?"page":void 0,onClick:()=>{_.key!==e&&m.trigger("selection"),_.onClick()},children:[s.jsx("span",{className:"ios-workbench-tabbar-icon","aria-hidden":"true",children:_.icon}),s.jsx("span",{className:"ios-workbench-tabbar-label",children:_.label})]},_.key))});return s.jsx(mu,{composerPortalTarget:j?y:null,children:s.jsxs("div",{ref:S,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":I,"data-tabbar-open":j?L.isOpen:!0,"data-conversation-tabbar-state":j?L.state:"default",style:P,children:[G?s.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[s.jsx("div",{className:"ios-workbench-nav-leading",children:G.showBackButton?s.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":l("common.back"),onClick:T,children:[s.jsx(Ux,{}),s.jsx("span",{children:l("common.back")})]}):null}),s.jsx("div",{className:"ios-workbench-nav-copy",children:s.jsx("h1",{children:G.title})}),s.jsx("div",{className:"ios-workbench-nav-actions",children:G.showMoreButton?s.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":G.moreButtonLabel,onClick:d,children:s.jsx(qx,{})}):null})]}):null,s.jsx("div",{className:"ios-workbench-content",children:s.jsx(ku,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:V,navigationPanel:r,auxiliaryPanel:i,children:n})}),j?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:H})]}):H]})})}function Ux(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:s.jsx("path",{d:"m15 18-6-6 6-6"})})}function qx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function Gx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function Vx(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Kx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function Yx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Xx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function Jx(e){const t=bn();return t.platform==="ios"?s.jsx(Hx,{...e}):t.platform==="android"?s.jsx(Rx,{...e}):s.jsx(Qx,{...e})}function Qx({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:i,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:h}){const p=bn(),m=nu(),g=Fa(),x=ao(),S=f.useRef(null),C=f.useRef(null),[y,A]=f.useState(null),j=zx(p.platform==="web"),V=p.platform==="web"&&j.keyboardOpen,L=t==="conversation-focus",I=za({isNativeMobile:p.isNativeMobile,viewportClass:p.viewportClass}),G=bu({enabled:L,rootRef:S,suspended:V,resetKey:`${g.pathname}${g.search}`}),q=lo({viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I}),P=fu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.iosMoreAction")}),T=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:s.jsx(ty,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:s.jsx(ny,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:s.jsx(sy,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:s.jsx(ry,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:s.jsx(iy,{}),onClick:h}],H=L?{"--mobile-conversation-tabbar-progress":G.progress.toFixed(4)}:void 0;gu(S,C,L);function _(){const Y=pu(g.pathname,g.search);if(!Y){a();return}x(Y,{replace:!0})}const ie=s.jsx("nav",{ref:C,className:"mobile-workbench-tabbar","aria-label":l("shell.title"),hidden:V,children:T.map(Y=>s.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":Y.key===e,"aria-current":Y.key===e?"page":void 0,onClick:()=>{Y.key!==e&&m.trigger("selection"),Y.onClick()},children:[s.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:Y.icon}),s.jsx("span",{className:"mobile-workbench-tabbar-label",children:Y.label})]},Y.key))});return s.jsx(mu,{composerPortalTarget:L?y:null,children:s.jsxs("div",{ref:S,className:"mobile-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-mobile-runtime":p.platform,"data-mobile-keyboard-open":V,"data-pane-layout":q,"data-tabbar-open":V?!1:L?G.isOpen:!0,"data-conversation-tabbar-state":L?G.state:"default",style:H,children:[P?s.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[s.jsxs("div",{className:"mobile-workbench-header-leading",children:[P.showBackButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":l("common.back"),onClick:_,children:s.jsx(Zx,{})}):null,s.jsx("div",{className:"mobile-workbench-header-copy",children:s.jsx("h1",{children:P.title})})]}),s.jsx("div",{className:"mobile-workbench-header-actions",children:P.showMoreButton?s.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":P.moreButtonLabel,onClick:d,children:s.jsx(ey,{})}):null})]}):null,s.jsx("div",{className:"mobile-workbench-content",children:s.jsx(ku,{viewportClass:p.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!i,preferCompactLayout:I,navigationPanel:r,auxiliaryPanel:i,children:n})}),L?s.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[s.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),s.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:ie})]}):ie]})})}function Zx(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"m15 18-6-6 6-6"}),s.jsx("path",{d:"M21 12H9"})]})}function ey(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function ty(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M8 13h8"})]})}function ny(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function ry(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 9 3 3-3 3"}),s.jsx("path",{d:"M12.5 15H17"})]})}function sy(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),s.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),s.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function iy(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}class oy{constructor(t){Ke(this,"maxAttempts");Ke(this,"baseDelayMs");Ke(this,"reconnectAttempts",0);Ke(this,"reconnectTimer",null);Ke(this,"disposed",!1);this.options=t,this.maxAttempts=t.maxAttempts??4,this.baseDelayMs=t.baseDelayMs??300}start(){this.options.onReconnect(!1)}markConnected(){this.reconnectAttempts=0,this.options.onStateChange("connected")}markTransientFailure(){this.disposed||this.reconnectAttempts>0||this.options.onStateChange("reconnecting")}markDisconnected(){if(this.disposed)return;if(!Bn.getState().autoReconnect){this.options.onStateChange("reconnect_failed");return}if(this.reconnectAttempts+=1,this.reconnectAttempts>this.maxAttempts){this.options.onStateChange("reconnect_failed");return}this.options.onStateChange("reconnecting");const t=this.baseDelayMs*this.reconnectAttempts;this.reconnectTimer=window.setTimeout(()=>{this.options.onReconnect(!0)},t)}reconnectNow(){this.reconnectAttempts=0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onReconnect(!0)}close(){this.disposed=!0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onStateChange("closed")}}class ay{constructor(t){Ke(this,"socket",null);Ke(this,"disposed",!1);Ke(this,"authRecoveryInFlight",!1);Ke(this,"pendingRefresh",!1);Ke(this,"workbenchKnownRevision");Ke(this,"lastWorkbenchSnapshot",null);Ke(this,"fileTreeSubscription",null);Ke(this,"gitSubscription",null);Ke(this,"terminalManagerSubscription",null);Ke(this,"workspaceManagementSubscription",null);Ke(this,"pendingFileTreeRefresh",null);Ke(this,"pendingGitRefresh",null);Ke(this,"pendingTerminalManagerRefresh",null);Ke(this,"pendingWorkspaceManagementRefresh",null);Ke(this,"fileTreeRevisionByPath",new Map);Ke(this,"gitRevisionByWorkspaceId",new Map);Ke(this,"terminalManagerRevisionByWorkspaceId",new Map);Ke(this,"workspaceManagementRevisionByWorkspaceId",new Map);Ke(this,"fileTreeListeners",new Set);Ke(this,"gitListeners",new Set);Ke(this,"terminalManagerListeners",new Set);Ke(this,"workspaceManagementListeners",new Set);Ke(this,"workbenchSubscribeStartedAtMs",null);Ke(this,"workbenchRefreshStartedAtMs",null);Ke(this,"connectionManager");this.options=t,this.workbenchKnownRevision=null,this.connectionManager=new oy({onReconnect:n=>{this.connect(n)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const t=this.socket;if(!xd(t)){this.pendingRefresh=!0;return}this.workbenchRefreshStartedAtMs=performance.now(),t.send(JSON.stringify({type:"workbench.refresh",knownRevision:this.workbenchKnownRevision??void 0})),Ot("workbench.refresh.sent",{knownRevision:this.workbenchKnownRevision}),this.pendingRefresh=!1}setWorkbenchKnownRevision(t){this.workbenchKnownRevision=jn(t)}primeWorkbenchSnapshot(t){if(!t||!Array.isArray(t.items)){this.lastWorkbenchSnapshot=null,this.workbenchKnownRevision=null;return}this.lastWorkbenchSnapshot=t,this.workbenchKnownRevision=jn(t.revision)??null}subscribeFileTree(t,n,r){this.fileTreeSubscription={workspaceId:t,paths:yd(n),knownRevisionByPath:Sl(r==null?void 0:r.knownRevisionByPath)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:t,paths:this.fileTreeSubscription.paths,knownRevisions:Cl(t,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})}requestFileTreeRefresh(t,n,r){const i=yd(n),o={type:"fileTree.refresh",workspaceId:t,paths:i,knownRevisions:Cl(t,i,Sl(r==null?void 0:r.knownRevisionByPath),this.fileTreeRevisionByPath)};this.sendWhenReady(o)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:t,paths:i,knownRevisionByPath:Sl(r==null?void 0:r.knownRevisionByPath)}}subscribeGit(t,n){this.gitSubscription={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"git.subscribe",workspaceId:t,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(t)})}requestGitRefresh(t,n){const r={type:"git.refresh",workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)??this.gitRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingGitRefresh=null:this.pendingGitRefresh={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)}}subscribeTerminalManager(t,n){this.terminalManagerSubscription={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"terminalManager.subscribe",workspaceId:t,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(t)})}requestTerminalManagerRefresh(t,n){const r={type:"terminalManager.refresh",workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)??this.terminalManagerRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingTerminalManagerRefresh=null:this.pendingTerminalManagerRefresh={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)}}subscribeWorkspaceManagement(t,n){this.workspaceManagementSubscription={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"workspaceManagement.subscribe",workspaceId:t,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(t)})}requestWorkspaceManagementRefresh(t,n){const r={type:"workspaceManagement.refresh",workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)??this.workspaceManagementRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingWorkspaceManagementRefresh=null:this.pendingWorkspaceManagementRefresh={workspaceId:t,knownRevision:jn(n==null?void 0:n.knownRevision)}}addFileTreeSnapshotListener(t){return this.fileTreeListeners.add(t),()=>{this.fileTreeListeners.delete(t)}}addGitSnapshotListener(t){return this.gitListeners.add(t),()=>{this.gitListeners.delete(t)}}addTerminalManagerSnapshotListener(t){return this.terminalManagerListeners.add(t),()=>{this.terminalManagerListeners.delete(t)}}addWorkspaceManagementSnapshotListener(t){return this.workspaceManagementListeners.add(t),()=>{this.workspaceManagementListeners.delete(t)}}close(){var t;this.disposed=!0,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var u;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const n=(u=Ji.getState().session)==null?void 0:u.accessToken;if(!n){this.options.onUnauthorized();return}const r=Jc(),i=af(r),o=i.baseUrl,a=`${ik("/ws",o)}?access_token=${encodeURIComponent(n)}`,c=i.transport.createWebSocket({path:"/ws",baseUrl:o,url:a});this.socket=c,c.addEventListener("open",()=>{this.workbenchSubscribeStartedAtMs=performance.now(),c.send(JSON.stringify({type:"workbench.subscribe",knownRevision:this.workbenchKnownRevision??void 0})),Ot("workbench.subscribe.sent",{knownRevision:this.workbenchKnownRevision,baseUrl:o}),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&c.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths,knownRevisions:Cl(this.fileTreeSubscription.workspaceId,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})),this.pendingFileTreeRefresh&&this.requestFileTreeRefresh(this.pendingFileTreeRefresh.workspaceId,this.pendingFileTreeRefresh.paths,{knownRevisionByPath:this.pendingFileTreeRefresh.knownRevisionByPath}),this.gitSubscription&&c.send(JSON.stringify({type:"git.subscribe",workspaceId:this.gitSubscription.workspaceId,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(this.gitSubscription.workspaceId)})),this.pendingGitRefresh&&this.requestGitRefresh(this.pendingGitRefresh.workspaceId,{knownRevision:this.pendingGitRefresh.knownRevision}),this.terminalManagerSubscription&&c.send(JSON.stringify({type:"terminalManager.subscribe",workspaceId:this.terminalManagerSubscription.workspaceId,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(this.terminalManagerSubscription.workspaceId)})),this.pendingTerminalManagerRefresh&&this.requestTerminalManagerRefresh(this.pendingTerminalManagerRefresh.workspaceId,{knownRevision:this.pendingTerminalManagerRefresh.knownRevision}),this.workspaceManagementSubscription&&c.send(JSON.stringify({type:"workspaceManagement.subscribe",workspaceId:this.workspaceManagementSubscription.workspaceId,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(this.workspaceManagementSubscription.workspaceId)})),this.pendingWorkspaceManagementRefresh&&this.requestWorkspaceManagementRefresh(this.pendingWorkspaceManagementRefresh.workspaceId,{knownRevision:this.pendingWorkspaceManagementRefresh.knownRevision})}),c.addEventListener("message",d=>{var p,m,g,x,S,C,y,A,j,V;if(!(d instanceof MessageEvent)||typeof d.data!="string")return;const h=JSON.parse(d.data);if(h.type==="system.connected"){this.connectionManager.markConnected();return}if(h.type==="session.error"){h.error_code==="UNAUTHORIZED"&&this.handleUnauthorized();return}if(h.type==="workbench.snapshot"&&(Ot("workbench.snapshot.received",{unchanged:h.unchanged,revision:h.revision,workspaceCount:((p=h.snapshot)==null?void 0:p.items.length)??0,sessionCount:h.snapshot?uy(h.snapshot):0,subscribeDurationMs:Oo(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Oo(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null),h.type==="workbench.delta"){Ot("workbench.delta.received",{baseRevision:h.baseRevision,revision:h.revision,changedWorkspaceCount:h.changedItems.length,removedWorkspaceCount:h.removedWorkspaceIds.length,subscribeDurationMs:Oo(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Oo(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null;const L=cy(this.lastWorkbenchSnapshot,h);if(!L){Ot("workbench.delta.mismatch",{currentRevision:((m=this.lastWorkbenchSnapshot)==null?void 0:m.revision)??null,baseRevision:h.baseRevision,revision:h.revision}),this.workbenchKnownRevision=null,this.lastWorkbenchSnapshot=null,this.connectionManager.reconnectNow();return}this.lastWorkbenchSnapshot=L,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(L);return}if(h.type==="fileTree.snapshot"){const L=h.snapshot;if(L)L.revision=h.revision,this.fileTreeRevisionByPath.set(bc(L.workspaceId,L.path),h.revision);else if(h.unchanged&&this.fileTreeSubscription)for(const I of this.fileTreeSubscription.paths)this.fileTreeRevisionByPath.set(bc(this.fileTreeSubscription.workspaceId,I),h.revision);if(!L)return;(x=(g=this.options).onFileTreeSnapshot)==null||x.call(g,L),this.fileTreeListeners.forEach(I=>I(L));return}if(h.type==="git.snapshot"){const L=h.snapshot;if(L?(L.revision=h.revision,this.gitRevisionByWorkspaceId.set(L.workspaceId,h.revision)):h.unchanged&&this.gitSubscription&&this.gitRevisionByWorkspaceId.set(this.gitSubscription.workspaceId,h.revision),!L)return;(C=(S=this.options).onGitSnapshot)==null||C.call(S,L),this.gitListeners.forEach(I=>I(L));return}if(h.type==="terminalManager.snapshot"){const L=h.snapshot;if(L?(L.revision=h.revision,this.terminalManagerRevisionByWorkspaceId.set(L.workspaceId,h.revision)):h.unchanged&&this.terminalManagerSubscription&&this.terminalManagerRevisionByWorkspaceId.set(this.terminalManagerSubscription.workspaceId,h.revision),!L)return;(A=(y=this.options).onTerminalManagerSnapshot)==null||A.call(y,L),this.terminalManagerListeners.forEach(I=>I(L));return}if(h.type==="workspaceManagement.snapshot"){const L=h.snapshot;if(L?(L.revision=h.revision,this.workspaceManagementRevisionByWorkspaceId.set(L.workspaceId,h.revision)):h.unchanged&&this.workspaceManagementSubscription&&this.workspaceManagementRevisionByWorkspaceId.set(this.workspaceManagementSubscription.workspaceId,h.revision),!L)return;(V=(j=this.options).onWorkspaceManagementSnapshot)==null||V.call(j,L),this.workspaceManagementListeners.forEach(I=>I(L));return}h.type==="workbench.snapshot"&&h.snapshot&&ly(h.snapshot)?(h.snapshot.revision=h.revision,this.lastWorkbenchSnapshot=h.snapshot,this.workbenchKnownRevision=h.revision,this.options.onSnapshot(h.snapshot)):h.type==="workbench.snapshot"&&h.unchanged&&(this.workbenchKnownRevision=h.revision,this.lastWorkbenchSnapshot&&(this.lastWorkbenchSnapshot={...this.lastWorkbenchSnapshot,revision:h.revision}))}),c.addEventListener("close",()=>{this.disposed||this.socket!==c||this.connectionManager.markDisconnected()}),c.addEventListener("error",()=>{this.disposed||this.socket!==c||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,t==null||t.close(),Ji.refresh().then(n=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(n.status==="refreshed"){this.connectionManager.reconnectNow();return}if(n.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendWhenReady(t){const n=this.socket;return xd(n)?(n.send(JSON.stringify(t)),!0):!1}}function xd(e){return e!==null&&e.readyState===1}function ly(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function yd(e){const t=new Set;for(const n of e??[""])t.add(n.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...t]}function jn(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function cy(e,t){if(!e||e.revision!==t.baseRevision)return null;const n=new Map(e.items.map(i=>[i.workspace.id,i]));for(const i of t.removedWorkspaceIds)n.delete(i);for(const i of t.changedItems)n.set(i.workspace.id,i);const r=[];for(const i of t.orderedWorkspaceIds){const o=n.get(i);if(!o)return null;r.push(o)}return{revision:t.revision,items:r}}function Sl(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),jn(n)]).filter(t=>t[1]!==null)):{}}function Cl(e,t,n,r){const i=t.map(o=>{const a=o.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return[a,n[a]??r.get(bc(e,a))??null]}).filter(o=>!!o[1]);if(i.length!==0)return Object.fromEntries(i)}function bc(e,t){return`${e}::${t}`}function uy(e){return e.items.reduce((t,n)=>t+n.sessions.length+Uf(n.childWorktrees??[]),0)}function Uf(e){return e.reduce((t,n)=>{if(typeof n!="object"||n===null)return t;const r=n,i=Array.isArray(r.sessions)?r.sessions.length:0,o=Array.isArray(r.children)?Uf(r.children):0;return t+i+o},0)}function Oo(e){return e===null||typeof performance>"u"?null:Math.round(performance.now()-e)}const wd=6,dy=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function hy(e){return e instanceof HTMLElement?!e.closest(dy):!0}function kc(e,t,n){return e.isDesktop&&e.ui.osFamily==="macos"&&t===0&&hy(n)}function qf(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function Gf(e){return qf(e)?"":void 0}function py(e){if(!kc(e.platform,e.button,e.target)||typeof window>"u")return;const t=e.clientX,n=e.clientY;let r=!0;const i=()=>{r&&(r=!1,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",a),window.removeEventListener("blur",c))},o=u=>{Math.abs(u.clientX-t)<wd&&Math.abs(u.clientY-n)<wd||(i(),fy())},a=()=>{i()},c=()=>{i()};window.addEventListener("mousemove",o),window.addEventListener("mouseup",a),window.addEventListener("blur",c)}async function fy(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await xf().startDragging()}const Sa=.78,my=1;function gy(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function Vf(e,t,n,r){const i=Math.hypot(n-e,r-t),o=Math.min(1,i/120);return Sa+(my-Sa)*o}function Lr(e){return Math.round(Number.isFinite(e)?e:0)}function by(e){if(!gy())return null;const t=Lr(e.x),n=Lr(e.y);let r=!1,i=Promise.resolve();const o=(c,u)=>(i=i.then(async()=>{await window.__TAURI_INTERNALS__.invoke(c,u)}).catch(()=>{}),i),a=async()=>{r||(r=!0,await o("close_detach_preview"))};return o("show_detach_preview",{title:e.title,x:t,y:n,scale:Sa}),{updatePosition(c,u){if(r)return;const d=Lr(c),h=Lr(u);o("update_detach_preview_position",{x:d,y:h,scale:Vf(t,n,d,h)})},complete(){return a()},cancel(){return a()}}}function ky(e){if(typeof document>"u")return null;const t=Lr(e.x),n=Lr(e.y),r=document.createElement("div");r.className="desktop-window-detach-animation",r.setAttribute("aria-hidden","true"),r.dataset.state="preview",r.style.left=`${t}px`,r.style.top=`${n}px`,r.style.setProperty("--detach-preview-scale",Sa.toFixed(3));const i=document.createElement("div");i.className="desktop-window-detach-animation-bar";const o=document.createElement("strong");o.className="desktop-window-detach-animation-title",o.textContent=e.title;const a=document.createElement("div");a.className="desktop-window-detach-animation-body",i.append(o),r.append(i,a),document.body.append(r);let c=!1;const u=()=>{c||(c=!0,r.remove())};return{updatePosition(d,h){if(c)return;const p=Lr(d),m=Lr(h),g=Vf(t,n,p,m);r.style.left=`${p}px`,r.style.top=`${m}px`,r.style.setProperty("--detach-preview-scale",g.toFixed(3))},async complete(){u()},async cancel(){u()}}}function vd(e){return by(e)??ky(e)}const xy={files:{kind:"files",label:"文件",defaultFocusOwner:"file-context-panel"},git:{kind:"git",label:"Git",defaultFocusOwner:"git-sidebar"},processes:{kind:"processes",label:"调试",defaultFocusOwner:"terminal-manager-panel"},terminals:{kind:"terminals",label:"终端",defaultFocusOwner:"terminal-page"}};function yy(e){return{...e,bounds:{...e.bounds}}}function wy(e,t,n){t&&(e.windows.registerDescriptor(t),n?e.windows.markWindowOpen(t.windowId):e.windows.markWindowClosed(t.windowId))}function vy(e){return xy[e]}function Kf(e,t){return`${e}-${t}`}async function Ha(e,t,n){const r=n.workspaceId.trim(),i=vy(t);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!r)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:`${i.label}外部窗口必须绑定工作区。`};const o=Kf(t,r),a=e.windows.getDescriptor(o),c=a?yy(a):null,u=e.windows.isWindowOpen(o),d=ok({windowId:o,kind:t,workspaceId:r,workspaceName:n.workspaceName??(c==null?void 0:c.workspaceName)??null,sessionId:n.sessionId??(c==null?void 0:c.sessionId)??null,mode:"external",bounds:c==null?void 0:c.bounds,focusOwner:n.focusOwner??i.defaultFocusOwner});e.windows.registerDescriptor(d);const h=await e.bridge.createWindow(d);return h.ok?(e.windows.markWindowOpen(o),{ok:!0,value:d}):(c?wy(e,c,u):e.windows.removeWindow(o),{ok:!1,errorCode:h.errorCode,detail:h.detail})}function cP(e){return Kf("terminals",e)}function Sy(e,t){return Ha(e,"files",t)}function Cy(e,t){return Ha(e,"git",t)}function Ny(e,t){return Ha(e,"processes",t)}function uP(e,t){return Ha(e,"terminals",t)}async function Sd(){return await xe.request("/api/skills/overview")}async function jy(e){await xe.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function Ty(e){await xe.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function Iy(e){await xe.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}async function Ey(){return await xe.request("/api/opencli/catalog")}async function Cd(){return await xe.request("/api/opencli/check",{method:"POST"})}async function My(e){return await xe.request("/api/opencli/config",{method:"POST",body:JSON.stringify(e)})}const Nl="all",jl="status";function Ry({toolbarMode:e="internal",onToolbarStateChange:t}={}){var We,Ue,Fe,rt;const n=Qc(F=>{var ne;return((ne=F.session)==null?void 0:ne.accessToken)??null}),[r,i]=f.useState(null),[o,a]=f.useState(!1),[c,u]=f.useState(!1),[d,h]=f.useState(!1),[p,m]=f.useState(!1),[g,x]=f.useState([]),[S,C]=f.useState(null),[y,A]=f.useState(null),[j,V]=f.useState(Nl),[L,I]=f.useState(null),[G,q]=f.useState(!1),[P,T]=f.useState(""),[H,_]=f.useState(jl);f.useEffect(()=>{let F=!0;if(!n){i(null),m(!1),x([]),A(null),C(null),a(!1),V(Nl),I(null),q(!1),T(""),_(jl);return}return(async()=>{a(!0),A(null),C(null);try{const re=await Cd();if(!F)return;N(re)}catch(re){if(!F)return;const Se=Fo(re);try{const ke=await Ey();if(!F)return;N(ke),A(Se)}catch(ke){if(!F)return;A(Fo(ke))}}finally{F&&a(!1)}})(),()=>{F=!1}},[n]);const ie=f.useMemo(()=>new Set(g),[g]),Y=f.useMemo(()=>Ly((r==null?void 0:r.entries)??[]),[r==null?void 0:r.entries]),W=f.useMemo(()=>Oy(),[]);f.useEffect(()=>{Y.some(F=>F.id===j)||V(Nl)},[j,Y]);const U=f.useMemo(()=>((r==null?void 0:r.siteGroups)??[]).filter(F=>F.commands.some(ne=>Nd(ne,j,ie))),[j,r==null?void 0:r.siteGroups,ie]),D=f.useMemo(()=>L?U.find(F=>F.site===L)??null:null,[L,U]);f.useEffect(()=>{L&&!D&&I(null)},[L,D]),f.useEffect(()=>{T(""),_(jl)},[L]);const K=f.useMemo(()=>{if(!D)return[];const F=P.trim().toLowerCase();return D.commands.filter(ne=>Nd(ne,j,ie)&&_y(ne,F)).sort((ne,re)=>By(ne,re,{sortId:H,selectedCommandIdSet:ie}))},[j,D,P,H,ie]),ee=!!(r&&(r.provider.enabled!==p||r.entries.some(F=>F.enabled!==ie.has(F.commandId)))),v=f.useMemo(()=>({draftEnabled:p,enableDisabled:o||c||d,refreshDisabled:!n||o||c||d,detailDisabled:!r||o,saveDisabled:!n||o||c||d||!r||!ee,refreshing:c,saving:d,onEnabledChange:de,onRefresh:()=>{Ne()},onShowDetails:()=>q(!0),onSave:()=>{ve()}}),[n,r,g,p,ee,o,c,d]);f.useEffect(()=>{t==null||t(v)},[t,v]),f.useEffect(()=>()=>{t==null||t(null)},[t]);async function Ne(){if(n){u(!0),A(null),C(null);try{const F=await Cd();N(F),C(Gy(F.refreshState,F.runtimeAvailability))}catch(F){A(Fo(F))}finally{u(!1)}}}async function ve(){if(n){h(!0),A(null),C(null);try{const F=await My({enabled:p,enabledCommandIds:g});N(F),C(Vy(F))}catch(F){A(Fo(F))}finally{h(!1)}}}function N(F){i(F),m(F.provider.enabled),x(F.entries.filter(ne=>ne.enabled).map(ne=>ne.commandId).sort((ne,re)=>ne.localeCompare(re))),A(null)}function de(F){m(F)}function Ee(F,ne){const re=F.commands.map(Se=>Se.commandId);x(Se=>{const ke=new Set(Se);for(const pe of re)ne?ke.add(pe):ke.delete(pe);return[...ke].sort((pe,xt)=>pe.localeCompare(xt))})}function me(F,ne){x(re=>{const Se=new Set(re);return ne?Se.add(F):Se.delete(F),[...Se].sort((ke,pe)=>ke.localeCompare(pe))})}const le=(r==null?void 0:r.summary)??{catalogCount:0,browserDependentCount:0,installState:"not_installed"};return s.jsxs("section",{className:"settings-opencli-panel settings-skill-section",children:[e==="internal"?s.jsx(Ay,{state:v,className:"settings-opencli-inline-toolbar"}):null,s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx(Wo,{label:l("settings.opencliSummaryInstallState"),value:Id(le.installState)}),s.jsx(Wo,{label:l("settings.opencliSummaryCatalogCount"),value:String(le.catalogCount)}),s.jsx(Wo,{label:l("settings.opencliSummaryEnabledCount"),value:String(g.length)}),s.jsx(Wo,{label:l("settings.opencliSummaryBrowserCount"),value:String(le.browserDependentCount)})]}),S?s.jsx("p",{className:"settings-release-status",children:S}):null,y?s.jsx("p",{className:"settings-release-status",children:y}):null,o?s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliLoading")}):r!=null&&r.siteGroups.length?s.jsxs("section",{className:"settings-opencli-catalog-section settings-skill-section",children:[s.jsx("div",{className:"settings-model-tabs settings-opencli-filter-tabs",role:"tablist","aria-label":l("settings.opencliFilterTabsLabel"),children:Y.map(F=>{const ne=j===F.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":ne,"data-active":ne?"true":"false",onClick:()=>V(F.id),children:F.label},F.id)})}),U.length>0?s.jsx("div",{className:"settings-opencli-site-grid",children:U.map(F=>{const ne=Dy(F,ie),re=Wy(F.commands),Se=Td(F,{maxDescriptions:2}),ke=Td(F),pe=Xf(F.site),xt=L===F.site;return s.jsxs("div",{className:"settings-opencli-site-card","data-selected":xt?"true":"false",children:[s.jsxs("div",{className:"settings-opencli-site-card-head",children:[s.jsx("div",{className:"settings-opencli-site-card-visual",style:pe.style,children:s.jsx("span",{children:pe.label})}),s.jsxs("div",{className:"settings-opencli-site-card-body",children:[s.jsxs("div",{className:"settings-opencli-site-card-topline",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:F.site}),s.jsxs("div",{className:"settings-opencli-site-card-actions",children:[s.jsx("button",{className:"ghost-button settings-opencli-site-detail-button",type:"button",onClick:()=>I(F.site),children:l("settings.opencliSiteViewAction")}),s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-site-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliSiteToggleLabel",{site:F.site}),type:"checkbox",checked:ne.allSelected,disabled:c||d,ref:Xe=>{Xe&&(Xe.indeterminate=ne.partialSelected)},onChange:Xe=>Ee(F,Xe.target.checked)}),s.jsx("span",{children:l("settings.opencliSiteEnableAction")})]})]})]}),s.jsx("p",{className:"settings-opencli-site-card-description",title:ke,children:Se})]})]}),s.jsx("div",{className:"settings-opencli-site-card-summary",children:s.jsx("div",{className:"settings-opencli-site-card-tag-rows",children:s.jsx("div",{className:"settings-skill-tags settings-opencli-site-card-tag-row settings-opencli-site-card-type-row",children:(re.length>0?re:["unknown"]).slice(0,2).map(Xe=>s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Zf(Xe),children:Jf(Xe)},`${F.site}:${Xe}`))})})})]},F.site)})}):s.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliFilteredEmpty")})]}):s.jsx("div",{className:"settings-skill-empty",children:Ky(r)}),s.jsx(Et,{open:G,title:l("settings.opencliDetailTitle"),className:"settings-opencli-detail-modal",onClose:()=>q(!1),children:r?s.jsxs(s.Fragment,{children:[s.jsx(Ys,{heading:l("settings.opencliDetailStatusHeading"),actions:s.jsxs("div",{className:"settings-opencli-detail-tags",children:[s.jsx(Lo,{children:Id(r.provider.installState)}),s.jsx(Lo,{children:zy(r.provider.healthState)}),s.jsx(Lo,{children:Uy(((We=r.activeRuntimeProfile)==null?void 0:We.status)??null)})]}),children:s.jsxs(ru,{compact:!0,className:"settings-opencli-detail-list",children:[s.jsx(pn,{label:l("settings.opencliEnabledStateLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:p?l("settings.opencliEnabledStateOn"):l("settings.opencliEnabledStateOff")})}),s.jsx(pn,{label:l("settings.opencliSummaryCatalogCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(le.catalogCount)})}),s.jsx(pn,{label:l("settings.opencliSummaryEnabledCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(g.length)})}),s.jsx(pn,{label:l("settings.opencliSummaryBrowserCount"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:String(le.browserDependentCount)})}),s.jsx(pn,{label:l("settings.opencliVersionLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:r.provider.version??"-"})}),s.jsx(pn,{label:l("settings.opencliCatalogSourceLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Hy(r.effectiveCatalogSource??null)})}),s.jsx(pn,{label:l("settings.opencliLastCheckedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Ed(r.provider.lastCheckedAt)})}),s.jsx(pn,{label:l("settings.opencliCatalogRefreshedLabel"),trailing:s.jsx("span",{className:"settings-opencli-detail-value",children:Ed(r.provider.catalogRefreshedAt)})}),s.jsx(pn,{label:l("settings.opencliInstallPathLabel"),description:r.provider.installPath??"-"}),s.jsx(pn,{label:l("settings.opencliDetailRuntimeIdLabel"),description:r.provider.activeRuntimeId??"-"}),s.jsx(pn,{label:l("settings.opencliDetailRuntimeRootLabel"),description:((Ue=r.activeRuntimeProfile)==null?void 0:Ue.runtimeRootPath)??"-"})]})}),r.provider.lastErrorDetail||(Fe=r.activeRuntimeProfile)!=null&&Fe.lastErrorDetail?s.jsx(Ys,{tone:"danger",heading:l("settings.opencliDetailErrorHeading"),children:s.jsxs("div",{className:"settings-opencli-detail-errors",children:[r.provider.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.provider.lastErrorDetail}):null,(rt=r.activeRuntimeProfile)!=null&&rt.lastErrorDetail?s.jsx("p",{className:"settings-skill-entry-meta",children:r.activeRuntimeProfile.lastErrorDetail}):null]})}):null]}):null}),s.jsx(Et,{open:D!==null,title:D?l("settings.opencliSiteDetailTitle",{site:D.site}):l("settings.opencliCommandModalFallbackTitle"),description:D?l("settings.opencliSiteDetailDescription",{count:K.length,total:D.totalCount}):void 0,className:"settings-opencli-command-modal",onClose:()=>I(null),children:D?s.jsxs("section",{className:"settings-skill-section",children:[s.jsx(Ys,{heading:l("settings.opencliSiteDescriptionHeading"),children:s.jsx("div",{className:"settings-opencli-site-detail-copy",children:Yf(D.commands).map(F=>s.jsx("p",{className:"settings-opencli-site-detail-description",children:F},F))})}),s.jsx(Ys,{heading:l("settings.opencliCommandSearchLabel"),actions:s.jsx(Lo,{children:l("settings.opencliCommandResultCount",{count:K.length})}),children:s.jsxs("div",{className:"settings-opencli-command-tools",children:[s.jsxs("label",{className:"settings-opencli-command-search",htmlFor:"opencli-command-search",children:[s.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSearchLabel")}),s.jsx("input",{id:"opencli-command-search",className:"settings-text-input",type:"search",value:P,placeholder:l("settings.opencliCommandSearchPlaceholder"),onChange:F=>T(F.target.value)})]}),s.jsxs("div",{className:"settings-opencli-command-sort",children:[s.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSortLabel")}),s.jsx("div",{className:"settings-opencli-command-sort-tabs",role:"tablist","aria-label":l("settings.opencliCommandSortLabel"),children:W.map(F=>{const ne=H===F.id;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab settings-opencli-command-sort-button","aria-selected":ne,"data-active":ne?"true":"false",onClick:()=>_(F.id),children:F.label},F.id)})})]})]})}),K.length>0?s.jsx("div",{className:"settings-opencli-command-grid",children:K.map(F=>s.jsx(Py,{command:F,checked:ie.has(F.commandId),disabled:c||d,onToggle:me},F.commandId))}):s.jsx(hf,{compact:!0,title:l("settings.opencliCommandModalEmpty")})]}):null})]})}function Ay({state:e,className:t}){return s.jsxs("div",{className:`settings-opencli-toolbar${t?` ${t}`:""}`,children:[s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-toolbar-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliProviderToggleLabel"),type:"checkbox",checked:e.draftEnabled,disabled:e.enableDisabled,onChange:n=>e.onEnabledChange(n.target.checked)}),s.jsx("span",{children:l("settings.opencliEnableAction")})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:e.refreshDisabled,onClick:e.onRefresh,children:e.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:e.detailDisabled,onClick:e.onShowDetails,children:l("settings.opencliDetailAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:e.saveDisabled,onClick:e.onSave,children:e.saving?l("common.loading"):l("settings.opencliSaveAction")})]})}function Py({command:e,checked:t,disabled:n,onToggle:r}){const i=Xf(e.commandId);return s.jsxs("div",{className:"settings-opencli-command-card",children:[s.jsxs("div",{className:"settings-opencli-command-card-head",children:[s.jsx("div",{className:"settings-opencli-command-badge",style:i.style,children:s.jsx("span",{children:e.name.slice(0,1).toUpperCase()})}),s.jsxs("div",{className:"settings-opencli-command-card-main",children:[s.jsxs("label",{className:"settings-opencli-checkbox",children:[s.jsx("input",{"aria-label":l("settings.opencliCommandToggleLabel",{commandId:e.commandId}),type:"checkbox",checked:t,disabled:n,onChange:o=>r(e.commandId,o.target.checked)}),s.jsx("span",{children:e.commandId})]}),s.jsx("p",{className:"settings-skill-entry-meta",children:e.description||l("settings.opencliCommandDescriptionEmpty")})]})]}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":Zf(e.strategy),children:qy(e.strategy)}),e.browser?s.jsx("span",{className:"settings-skill-tag","data-status":"failed",children:l("settings.opencliBrowserTag")}):s.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:l("settings.opencliHttpTag")})]})]})}function Wo({label:e,value:t}){return s.jsxs("div",{className:"settings-skill-summary-card",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function Ly(e){const t=Array.from(new Set(e.map(n=>n.strategy.trim()).filter(n=>n.length>0&&n!=="unknown"))).sort((n,r)=>n.localeCompare(r));return[{id:"all",label:l("settings.opencliFilterAll")},{id:"enabled",label:l("settings.opencliFilterEnabled")},{id:"browser",label:l("settings.opencliFilterBrowser")},{id:"direct",label:l("settings.opencliFilterDirect")},...t.map(n=>({id:`strategy:${n}`,label:l("settings.opencliFilterStrategy",{strategy:Jf(n)})}))]}function Nd(e,t,n){switch(t){case"all":return!0;case"enabled":return n.has(e.commandId);case"browser":return e.browser;case"direct":return!e.browser;default:return t.startsWith("strategy:")?e.strategy===t.slice(9):!0}}function Dy(e,t){const n=e.commands.filter(r=>t.has(r.commandId)).length;return{selectedCount:n,allSelected:n>0&&n===e.commands.length,partialSelected:n>0&&n<e.commands.length}}function _y(e,t){return t?[e.commandId,e.name,e.description,e.strategy].join(`
|
|
3
3
|
`).toLowerCase().includes(t):!0}function By(e,t,n){const r=jd(e,n)-jd(t,n);if(r!==0)return r;const i=e.name.localeCompare(t.name);return i!==0?i:e.commandId.localeCompare(t.commandId)}function jd(e,t){const n=t.selectedCommandIdSet.has(e.commandId)?0:1,r=e.browser?1:0;switch(t.sortId){case"browser":return(e.browser?0:2)+n;case"name":return 0;case"status":default:return n*2+r}}function Oy(){return[{id:"status",label:l("settings.opencliCommandSortStatus")},{id:"browser",label:l("settings.opencliCommandSortBrowser")},{id:"name",label:l("settings.opencliCommandSortName")}]}function Yf(e){return Array.from(new Set(e.map(t=>t.description.trim()).filter(t=>t.length>0)))}function Td(e,t={}){const n=Yf(e.commands);if(n.length===0)return l("settings.opencliSiteDescriptionEmpty");const r=t.maxDescriptions??n.length;return n.slice(0,r).join(" · ")}function Wy(e){return Array.from(new Set(e.map(t=>t.strategy.trim()).filter(t=>t.length>0&&t!=="unknown"))).sort((t,n)=>t.localeCompare(n))}function Xf(e){const t=Yy[e.toLowerCase()];if(t)return{label:t.label,style:{background:t.background}};const n=Md[Math.abs($y(e))%Md.length];return{label:Fy(e),style:{background:`linear-gradient(135deg, ${n[0]} 0%, ${n[1]} 100%)`}}}function Fy(e){const t=e.split(/[^a-z0-9]+/i).map(r=>r.trim()).filter(r=>r.length>0);if(t.length>=2)return`${t[0][0]??""}${t[1][0]??""}`.toUpperCase();const n=t[0]??e;return n.slice(0,Math.min(2,n.length)).toUpperCase()}function $y(e){let t=0;for(const n of e)t=(t<<5)-t+n.charCodeAt(0),t|=0;return t}function Fo(e){return e instanceof Zc?e.message||l("settings.opencliLoadFailed"):e instanceof Error?e.message:l("settings.opencliLoadFailed")}function Id(e){switch(e){case"installed":return l("settings.opencliInstallInstalled");case"broken":return l("settings.opencliInstallBroken");default:return l("settings.opencliInstallMissing")}}function zy(e){switch(e){case"ready":return l("settings.opencliHealthReady");case"bridge_missing":return l("settings.opencliHealthBridgeMissing");case"binary_ready":return l("settings.opencliHealthBinaryReady");case"runtime_build_failed":return l("settings.opencliHealthRuntimeBuildFailed");default:return l("settings.opencliHealthUnknown")}}function Hy(e){switch(e){case"manifest":return l("settings.opencliCatalogSourceManifest");case"cli_list":return l("settings.opencliCatalogSourceCliList");case"local_manifest":return l("settings.opencliCatalogSourceLocalManifest");case"cache":return l("settings.opencliCatalogSourceCache");default:return"-"}}function Uy(e){switch(e){case"ready":return l("settings.opencliRuntimeReady");case"failed":return l("settings.opencliRuntimeFailed");case"pending":return l("settings.opencliRuntimePending");case"stale":return l("settings.opencliRuntimeStale");default:return l("settings.opencliRuntimeIdle")}}function qy(e){return l("settings.opencliStrategyLabel",{strategy:Qf(e)})}function Jf(e){return l("settings.opencliStrategyShortLabel",{strategy:Qf(e)})}function Qf(e){switch(em(e)){case"cookie":return l("settings.opencliStrategyCookie");case"header":return l("settings.opencliStrategyHeader");case"intercept":return l("settings.opencliStrategyIntercept");case"local":return l("settings.opencliStrategyLocal");case"public":return l("settings.opencliStrategyPublic");case"ui":return l("settings.opencliStrategyUi");default:return l("settings.opencliStrategyUnknown")}}function Zf(e){return em(e)}function em(e){const t=e.trim().toLowerCase();return t.length>0?t:"unknown"}function Gy(e,t){return e==="cache_retained"?l("settings.opencliRefreshCacheRetained"):e==="unavailable"?l("settings.opencliRefreshUnavailable"):t==="ready"?l("settings.opencliRefreshReady"):l("settings.opencliRefreshDone")}function Vy(e){return e.runtimeAvailability==="ready"?l("settings.opencliSaveReady"):e.provider.enabled?l("settings.opencliSaveEnabled"):l("settings.opencliSaveDisabled")}function Ky(e){return e?e.provider.installState!=="installed"?l("settings.opencliEmptyNotInstalled"):l("settings.opencliEmpty"):l("settings.opencliEmpty")}function Ed(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}const Md=[["#2563eb","#0ea5e9"],["#0f766e","#14b8a6"],["#7c3aed","#6366f1"],["#ea580c","#f59e0b"],["#be123c","#f43f5e"],["#1d4ed8","#38bdf8"]],Yy={github:{label:"GH",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"},hackernews:{label:"HN",background:"linear-gradient(135deg, #f97316 0%, #fb923c 100%)"},twitter:{label:"TW",background:"linear-gradient(135deg, #2563eb 0%, #38bdf8 100%)"},x:{label:"X",background:"linear-gradient(135deg, #111827 0%, #6b7280 100%)"},reddit:{label:"RD",background:"linear-gradient(135deg, #f97316 0%, #ef4444 100%)"}},Xy=[{id:"skills"},{id:"opencli"}];function Jy({triggerClassName:e="secondary-button",triggerLabel:t,triggerLeading:n}){const r=Qc(E=>{var $;return(($=E.session)==null?void 0:$.accessToken)??null}),i=f.useRef(null),[o,a]=f.useState(null),[c,u]=f.useState(!1),[d,h]=f.useState(null),[p,m]=f.useState(null),[g,x]=f.useState(null),[S,C]=f.useState(!1),[y,A]=f.useState(!1),[j,V]=f.useState(null),[L,I]=f.useState("file"),[G,q]=f.useState("workspace"),[P,T]=f.useState(""),[H,_]=f.useState(()=>Ri("workspace")),[ie,Y]=f.useState("skills"),[W,U]=f.useState(null),D=f.useId(),ee=bk(S&&!!r).items??[],v=f.useMemo(()=>iw(ee),[ee]);f.useEffect(()=>{let E=!0;if(!S)return;if(!r){a(null),m(null),x(null),u(!1);return}return(async()=>{u(!0);try{const se=await Sd();if(!E)return;a(se),m(null)}catch(se){if(!E)return;m(Ls(se))}finally{E&&u(!1)}})(),()=>{E=!1}},[r,S]);async function Ne(){const E=await Sd();a(E),m(null)}async function ve(){if(r){h("refresh"),m(null),x(null);try{await Ne(),x(l("settings.skillRefreshSuccess"))}catch(E){m(Ls(E))}finally{h(null)}}}async function N(E){if(r){h(Rd(E)),m(null),x(null);try{await Ty({targetCli:E.targetCli,directoryPath:E.directoryPath,expectedContentHash:E.contentHash}),await Ne(),x(l("settings.skillImportSuccess",{name:E.name,target:mn(E.targetCli)}))}catch($){m(Ls($))}finally{h(null)}}}async function de(E){if(!r)return;const $=E.bindings.filter(se=>se.enabled).map(se=>se.targetCli).filter(se=>Gt(se,v));if($.length===0){m(pw(E.bindings));return}h(Ad(E.skill.id)),m(null),x(null);try{await Iy({skillId:E.skill.id,targetCli:$}),await Ne(),x(l("settings.skillSyncSuccess",{name:E.skill.name}))}catch(se){m(Ls(se))}finally{h(null)}}async function Ee(E){var se;const $=((se=E.target.files)==null?void 0:se[0])??null;if(E.target.value="",!!$){m(null),x(null);try{const ue=await yw($),we=rm($.name,ue);V(we),_(Ri(G,v))}catch(ue){m(Ls(ue))}}}async function me(){const E=Pd({sourceMode:L,fileDraft:j,pastedMarkdown:P});if(!r)return;if(!E){m(L==="paste"?l("settings.skillPasteEmpty"):l("settings.skillUploadEmpty"));return}const $=E.directoryName;if(!$){m(l("settings.skillUploadDirectoryInvalid"));return}const se=Ca(G).filter(ue=>H[ue]).filter(ue=>Gt(ue,v)).map(ue=>ue);if(se.length===0){m(fw(G,v));return}h("upload"),m(null),x(null);try{await jy({markdownContent:E.rawContent,scope:G,fileName:E.fileName,directoryName:$,targetCli:se}),await Ne(),x(l("settings.skillUploadSuccess",{name:$})),F(G),A(!1)}catch(ue){m(Ls(ue))}finally{h(null)}}function le(E){q(E),_(Ri(E,v))}function We(E){I(E),V(null),T(""),_(Ri(G,v)),m(null)}function Ue(E){Gt(E,v)&&_($=>({...$,[E]:!$[E]}))}function Fe(){A(!0),m(null),F(G)}function rt(){A(!1),m(null),F(G)}function F(E){V(null),T(""),I("file"),_(Ri(E,v))}const ne=(o==null?void 0:o.summary)??{managedSkillCount:0,managedEntryCount:0},re=bw((o==null?void 0:o.assistantRuntimeSkills)??[],(o==null?void 0:o.conflictedEntries)??[],(o==null?void 0:o.diagnostics)??[]),Se=((o==null?void 0:o.conflictedEntries)??[]).filter(E=>!nm(E,(o==null?void 0:o.diagnostics)??[])),ke=((o==null?void 0:o.diagnostics)??[]).filter(E=>!co(E)),pe=Pd({sourceMode:L,fileDraft:j,pastedMarkdown:P}),xt=t??l("settings.skillManageAction"),Xe=ie==="skills",st=ie==="opencli";return s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:e,type:"button","data-open":S?"true":"false","aria-haspopup":"dialog","aria-expanded":S,onClick:()=>{Y("skills"),C(!0)},children:[n,s.jsx("span",{children:xt})]}),s.jsxs(Et,{open:S,title:l("settings.skillConfigModalTitle"),hideHeader:!0,className:"settings-skill-modal",onClose:()=>{Y("skills"),C(!1)},children:[s.jsxs("div",{className:"settings-skill-modal-topbar",children:[s.jsxs("div",{className:"settings-skill-modal-topbar-main",children:[s.jsx("div",{className:"settings-model-tabs settings-skill-tabs",role:"tablist","aria-label":l("settings.skillConfigTabsLabel"),children:Xy.map(E=>{const $=ie===E.id,se=`${D}-${E.id}-tab`,ue=`${D}-${E.id}-panel`;return s.jsx("button",{id:se,type:"button",role:"tab",className:"settings-model-tab","aria-selected":$,"aria-controls":ue,"data-active":$?"true":"false",onClick:()=>Y(E.id),children:Sw(E.id)},E.id)})}),Xe?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar",children:[s.jsx("button",{className:"secondary-button",type:"button",disabled:!r||c||d!==null,onClick:Fe,children:l("settings.skillCreateAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:!r||c||d!==null,onClick:()=>{ve()},children:d==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,st&&W?s.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar settings-opencli-toolbar",children:[s.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-toolbar-toggle",children:[s.jsx("input",{"aria-label":l("settings.opencliProviderToggleLabel"),type:"checkbox",checked:W.draftEnabled,disabled:W.enableDisabled,onChange:E=>W.onEnabledChange(E.target.checked)}),s.jsx("span",{children:l("settings.opencliEnableAction")})]}),s.jsx("button",{className:"secondary-button",type:"button",disabled:W.refreshDisabled,onClick:W.onRefresh,children:W.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),s.jsx("button",{className:"secondary-button",type:"button",disabled:W.detailDisabled,onClick:W.onShowDetails,children:l("settings.opencliDetailAction")}),s.jsx("button",{className:"primary-button",type:"button",disabled:W.saveDisabled,onClick:W.onSave,children:W.saving?l("common.loading"):l("settings.opencliSaveAction")})]}):null]}),s.jsx(Gk,{onClick:()=>{Y("skills"),C(!1)}})]}),Xe?s.jsxs("div",{id:`${D}-skills-panel`,role:"tabpanel","aria-labelledby":`${D}-skills-tab`,className:"settings-skill-panel",children:[s.jsxs("section",{className:"settings-skill-summary-block",children:[s.jsxs("div",{className:"settings-skill-summary-grid",children:[s.jsx($o,{label:l("settings.skillSummaryManagedSkills"),value:String(ne.managedSkillCount)}),s.jsx($o,{label:l("settings.skillSummaryManagedEntries"),value:String(ne.managedEntryCount)}),s.jsx($o,{label:l("settings.skillSummaryConflictedEntries"),value:String(Se.length)}),s.jsx($o,{label:l("settings.skillSummaryDiagnostics"),value:String(ke.length)})]}),s.jsx("div",{className:"settings-release-meta",children:s.jsxs("span",{children:[l("settings.skillScannedAt"),": ",c?l("common.loading"):gw(o==null?void 0:o.scannedAt)]})}),g?s.jsx("p",{className:"settings-release-status",children:g}):null,p?s.jsx("p",{className:"settings-release-status",children:p}):null]}),s.jsx(Mi,{title:l("settings.skillManagedListTitle"),emptyText:l("settings.skillManagedEmpty"),items:(o==null?void 0:o.managedSkills)??[],renderItem:E=>{const $=Ad(E.skill.id);return s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:E.skill.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:uw(E.bindings)}),s.jsx("div",{className:"settings-skill-tags",children:E.bindings.map(se=>s.jsx("span",{className:"settings-skill-tag","data-status":lw(se,v),children:cw(se,v)},`${E.skill.id}-${se.targetCli}`))})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:c||d!==null||!aw(E.bindings,v),onClick:()=>{de(E)},children:d===$?l("common.loading"):l("settings.skillSyncAction")})})]},E.skill.id)}}),s.jsx(Mi,{title:l("settings.skillUnmanagedListTitle"),emptyText:l("settings.skillUnmanagedEmpty"),items:(o==null?void 0:o.unmanagedEntries)??[],renderItem:E=>{const $=Rd(E);return s.jsxs("div",{className:"settings-skill-entry",children:[s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:E.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:dw(E,v)}),Gt(E.targetCli,v)?null:s.jsx("div",{className:"settings-skill-tags",children:s.jsx("span",{className:"settings-skill-tag","data-status":"failed",children:l("settings.skillTargetDisabledTag")})})]}),s.jsx("div",{className:"settings-skill-entry-actions",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:c||d!==null||!Gt(E.targetCli,v),onClick:()=>{N(E)},children:d===$?l("common.loading"):l("settings.skillImportAction")})})]},`${E.targetCli}:${E.directoryPath}`)}}),s.jsx(Mi,{title:l("settings.skillAssistantRuntimeListTitle"),description:l("settings.skillAssistantRuntimeListDescription"),emptyText:l("settings.skillAssistantRuntimeEmpty"),items:re,renderItem:E=>s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:E.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillAssistantRuntimeItemDescription")}),s.jsxs("p",{className:"settings-skill-entry-meta",children:[l("settings.skillAssistantRuntimeUsedBy"),": ",tm(E.usedByTargetCli)]}),s.jsxs("div",{className:"settings-skill-tags",children:[s.jsx("span",{className:"settings-skill-tag","data-status":"assistant-runtime",children:l("settings.skillTagAssistantOnly")}),E.usedByTargetCli.map($=>s.jsx("span",{className:"settings-skill-tag","data-status":Gt($,v)?"synced":"failed",children:Gt($,v)?mn($):`${mn($)} · ${l("settings.skillTargetDisabledTag")}`},`${E.directoryName}:${$}`))]})]})},`${E.directoryName}:${E.sourcePath}`)}),s.jsx(Mi,{title:l("settings.skillConflictedListTitle"),emptyText:l("settings.skillConflictedEmpty"),items:Se,renderItem:E=>{const $=kw(E,(o==null?void 0:o.diagnostics)??[]);return s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:E.name}),s.jsx("p",{className:"settings-skill-entry-meta",children:hw(E,v)}),$.length>0?s.jsx("div",{className:"settings-skill-tags",children:$.map(se=>s.jsx("span",{className:"settings-skill-tag","data-status":se.status,children:se.label},se.key))}):null]})},`${E.targetCli}:${E.directoryPath}`)}}),s.jsx(Mi,{title:l("settings.skillDiagnosticsTitle"),emptyText:l("settings.skillDiagnosticsEmpty"),items:ke,renderItem:E=>{const $=xw(E),se=mw(E);return s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:se.title}),s.jsx("p",{className:"settings-skill-entry-meta",children:se.detail}),$.length>0?s.jsx("div",{className:"settings-skill-tags",children:$.map(ue=>s.jsx("span",{className:"settings-skill-tag","data-status":ue.status,children:ue.label},ue.key))}):null]})},`${E.targetCli}:${E.code}:${E.directoryPath??E.rootDir}`)}})]}):s.jsx("div",{id:`${D}-opencli-panel`,role:"tabpanel","aria-labelledby":`${D}-opencli-tab`,className:"settings-skill-panel",children:s.jsx(Ry,{toolbarMode:"external",onToolbarStateChange:U})})]}),s.jsx(Et,{open:y,title:l("settings.skillCreateModalTitle"),description:l("settings.skillCreateModalDescription"),className:"settings-skill-create-modal",onClose:rt,children:s.jsxs("section",{className:"settings-skill-section",children:[s.jsx("h3",{className:"settings-skill-section-title",children:l("settings.skillUploadSectionTitle")}),s.jsx("p",{className:"settings-skill-section-description",children:l("settings.skillUploadSectionDescription")}),s.jsxs("div",{className:"settings-skill-create-panel",children:[s.jsx("input",{ref:i,type:"file",accept:".md,text/markdown,text/plain",className:"settings-skill-upload-input",onChange:E=>{Ee(E)}}),s.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":l("settings.skillCreateSourceTabsLabel"),children:tw.map(E=>{const $=L===E;return s.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":$,"data-active":$?"true":"false",onClick:()=>We(E),children:rw(E)},E)})}),s.jsx("div",{className:"settings-skill-upload-targets",role:"radiogroup","aria-label":l("settings.skillUploadScopeLabel"),children:ew.map(E=>s.jsxs("label",{className:"settings-skill-upload-target","data-selected":G===E?"true":"false",children:[s.jsx("input",{type:"radio",name:"skill-upload-scope",checked:G===E,onChange:()=>le(E)}),s.jsx("span",{children:nw(E)})]},E))}),L==="file"?s.jsx("div",{className:"settings-skill-create-toolbar",children:s.jsx("button",{className:"secondary-button",type:"button",disabled:c||d!==null,onClick:()=>{var E;(E=i.current)==null||E.click()},children:l("settings.skillUploadPickAction")})}):s.jsxs("label",{className:"settings-skill-upload-field",children:[s.jsx("span",{children:l("settings.skillPasteLabel")}),s.jsx("textarea",{className:"settings-skill-create-textarea",value:P,onChange:E=>T(E.target.value),placeholder:l("settings.skillPastePlaceholder")})]}),pe?s.jsx("div",{className:"settings-skill-entry",children:s.jsxs("div",{className:"settings-skill-entry-main",children:[s.jsx("strong",{className:"settings-skill-entry-title",children:pe.previewTitle}),s.jsxs("p",{className:"settings-skill-entry-meta",children:[l("settings.skillUploadPickedFile"),": ",pe.fileName]})]})}):s.jsx("div",{className:"settings-skill-empty",children:L==="paste"?l("settings.skillPasteEmpty"):l("settings.skillUploadEmpty")}),s.jsxs("div",{className:"settings-skill-upload-field",children:[s.jsx("span",{children:l("settings.skillUploadTargetsLabel")}),s.jsx("div",{className:"settings-skill-upload-targets",children:Ca(G).map(E=>s.jsxs("label",{className:"settings-skill-upload-target","data-selected":H[E]?"true":"false",children:[s.jsx("input",{type:"checkbox",checked:H[E],disabled:!Gt(E,v),onChange:()=>Ue(E)}),s.jsx("span",{children:Gt(E,v)?mn(E):`${mn(E)} · ${l("settings.skillTargetDisabledTag")}`})]},E))})]}),pe!=null&&pe.notes.length?s.jsx("div",{className:"settings-skill-tags",children:pe.notes.map((E,$)=>s.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:E},`${pe.fileName}:${$}`))}):null,p?s.jsx("p",{className:"settings-release-status",children:p}):null,s.jsx("div",{className:"settings-skill-create-actions",children:s.jsx("button",{className:"primary-button",type:"button",disabled:c||d!==null,onClick:()=>{me()},children:d==="upload"?l("common.loading"):l("settings.skillCreateSubmitAction")})})]})]})})]})}function Mi({title:e,description:t,emptyText:n,items:r,renderItem:i}){return s.jsxs("section",{className:"settings-skill-section",children:[s.jsx("h3",{className:"settings-skill-section-title",children:e}),t?s.jsx("p",{className:"settings-skill-section-description",children:t}):null,r.length>0?s.jsx("div",{className:"settings-skill-entry-list",children:r.map(o=>i(o))}):s.jsx("div",{className:"settings-skill-empty",children:n})]})}function $o({label:e,value:t}){return s.jsxs("div",{className:"settings-skill-summary-card",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function Rd(e){return`import:${e.targetCli}:${e.directoryPath}`}function Ad(e){return`sync:${e}`}const Qy=["codex","claude-code","gemini","opencode"],Zy=["codex","claude-code"],ew=["workspace","assistant"],tw=["file","paste"];function Ls(e){return e instanceof Zc?e.message||l("settings.skillLoadFailed"):e instanceof Error?e.message:l("settings.skillLoadFailed")}function mn(e){switch(e){case"claude-code":return l("settings.skillTargetClaudeCode");case"gemini":return l("settings.skillTargetGemini");case"opencode":return l("settings.skillTargetOpenCode");default:return l("settings.skillTargetCodex")}}function nw(e){return e==="assistant"?l("settings.skillUploadScopeAssistant"):l("settings.skillUploadScopeWorkspace")}function rw(e){return e==="paste"?l("settings.skillCreateSourcePaste"):l("settings.skillCreateSourceFile")}function Ri(e,t={}){const r=Ca(e).filter(i=>Gt(i,t))[0]??null;return{codex:r==="codex","claude-code":r==="claude-code",gemini:r==="gemini",opencode:r==="opencode"}}function Ca(e){return e==="assistant"?Zy:Qy}function Pd({sourceMode:e,fileDraft:t,pastedMarkdown:n}){return e==="file"?t:n.trim()?rm(ww(n),n):null}function sw(e){switch(e){case"conflicted":return l("settings.skillBindingConflicted");case"failed":return l("settings.skillBindingFailed");case"pending":return l("settings.skillBindingPending");default:return l("settings.skillBindingSynced")}}function iw(e){const t={};for(const n of e){const r=ow(n.provider);r&&(t[r]=n)}return t}function ow(e){switch(e){case"claude-code":return"claude-code";case"codex":return"codex";case"gemini":return"gemini";case"opencode":return"opencode";default:return null}}function Gt(e,t){var n;return((n=t[e])==null?void 0:n.enabled)!==!1}function aw(e,t){return e.some(n=>n.enabled&&Gt(n.targetCli,t))}function lw(e,t){return Gt(e.targetCli,t)?e.syncStatus:"failed"}function cw(e,t){return Gt(e.targetCli,t)?`${mn(e.targetCli)} · ${sw(e.syncStatus)}`:`${mn(e.targetCli)} · ${l("settings.skillTargetDisabledTag")}`}function tm(e){return e.map(mn).join(" / ")}function uw(e){const t=e.filter(n=>n.enabled);return t.length===0?l("settings.skillManagedItemNoTarget"):l("settings.skillManagedItemDescription",{targets:tm(t.map(n=>n.targetCli))})}function dw(e,t){return Gt(e.targetCli,t)?l("settings.skillUnmanagedItemDescription",{target:mn(e.targetCli)}):l("settings.skillUnmanagedItemDisabledDescription",{target:mn(e.targetCli)})}function hw(e,t){return Gt(e.targetCli,t)?l("settings.skillConflictedItemDescription",{target:mn(e.targetCli)}):l("settings.skillConflictedItemDisabledDescription",{target:mn(e.targetCli)})}function pw(e,t){return e.some(r=>r.enabled)?l("settings.skillSyncTargetDisabled"):l("settings.skillSyncTargetMissing")}function fw(e,t){return Ca(e).some(r=>Gt(r,t))?l("settings.skillUploadTargetRequired"):l("settings.skillUploadTargetDisabled")}function mw(e){const t=mn(e.targetCli);switch(e.code){case"SKILL_TARGET_ROOT_MISSING":return{title:l("settings.skillDiagnosticTargetMissingTitle",{target:t}),detail:l("settings.skillDiagnosticTargetMissingDetail",{target:t})};case"SKILL_TARGET_ROOT_INVALID":case"SKILL_TARGET_STAT_FAILED":case"SKILL_TARGET_READ_FAILED":return{title:l("settings.skillDiagnosticReadFailedTitle",{target:t}),detail:l("settings.skillDiagnosticReadFailedDetail",{target:t})};case"SKILL_TARGET_SKILL_MISSING":return{title:l("settings.skillDiagnosticSyncMissingTitle",{target:t}),detail:l("settings.skillDiagnosticSyncMissingDetail",{target:t})};default:return{title:l("settings.skillDiagnosticGenericTitle",{target:t}),detail:l("settings.skillDiagnosticGenericDetail",{target:t})}}}function gw(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function bw(e,t,n){if(e.length>0)return e.map(i=>({name:i.name,directoryName:i.directoryName,sourcePath:i.sourcePath,usedByTargetCli:i.usedByTargetCli}));const r=new Map;for(const i of t)nm(i,n)&&r.set(Ld(i.targetCli,i.directoryPath),{name:i.name,directoryName:i.directoryName,sourcePath:i.directoryPath,usedByTargetCli:[i.targetCli]});for(const i of n){if(!co(i))continue;const o=i.directoryPath??i.rootDir,a=Ld(i.targetCli,o);r.has(a)||r.set(a,{name:i.directoryName??"codingns-assistant",directoryName:i.directoryName??"codingns-assistant",sourcePath:o,usedByTargetCli:[i.targetCli]})}return[...r.values()]}function Ld(e,t){return`${e}:${t}`}function nm(e,t){return t.some(n=>co(n)&&n.targetCli===e.targetCli&&n.directoryPath===e.directoryPath&&n.directoryName===e.directoryName)}function co(e){return e.code==="SKILL_RESERVED_FOR_ASSISTANT_RUNTIME"}function kw(e,t){return t.find(r=>co(r)&&r.targetCli===e.targetCli&&r.directoryName===e.directoryName&&r.directoryPath===e.directoryPath)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath}`,label:l("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function xw(e){return co(e)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath??e.rootDir}`,label:l("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function rm(e,t){const n=[],r=t.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
4
4
|
`).trim();if(!r)throw new Error(l("settings.skillUploadContentEmpty"));r!==t.trim()&&n.push(l("settings.skillUploadNormalizedNote"));const i=sm(r),o=xc(e)??xc(i)??"";return o||n.push(l("settings.skillUploadDirectoryRequiredNote")),i||n.push(l("settings.skillUploadHeadingNote")),{fileName:e,rawContent:r,directoryName:o,previewTitle:i||vw(o||"skill"),notes:n}}async function yw(e){if(typeof e.text=="function")return await e.text();if(typeof FileReader>"u")throw new Error(l("settings.skillUploadReadFailed"));return await new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>{n(r.error??new Error(l("settings.skillUploadReadFailed")))},r.onload=()=>{if(typeof r.result=="string"){t(r.result);return}n(new Error(l("settings.skillUploadReadFailed")))},r.readAsText(e)})}function xc(e){const r=(e.replace(/\\/g,"/").split("/").pop()??e).replace(/\.[A-Za-z0-9]+$/,"").trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-._]+|[-._]+$/g,"").toLowerCase();return r.length>0?r:null}function ww(e){const t=xc(sm(e));return t?`${t}.md`:"pasted-skill.md"}function sm(e){var t,n;return((n=(t=e.match(/^#\s+(.+)$/m))==null?void 0:t[1])==null?void 0:n.trim())??""}function vw(e){return e.split(/[._-]+/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||e}function Sw(e){switch(e){case"opencli":return l("settings.skillConfigTabOpenCli");default:return l("settings.skillConfigTabSkills")}}function Cw(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Nw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,jw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Tw={};function Dd(e,t){return(Tw.jsx?jw:Nw).test(e)}const Iw=/[ \t\n\f\r]/g;function Ew(e){return typeof e=="object"?e.type==="text"?_d(e.value):!1:_d(e)}function _d(e){return e.replace(Iw,"")===""}class uo{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}uo.prototype.normal={};uo.prototype.property={};uo.prototype.space=void 0;function im(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new uo(n,r,t)}function yc(e){return e.toLowerCase()}class ln{constructor(t,n){this.attribute=n,this.property=t}}ln.prototype.attribute="";ln.prototype.booleanish=!1;ln.prototype.boolean=!1;ln.prototype.commaOrSpaceSeparated=!1;ln.prototype.commaSeparated=!1;ln.prototype.defined=!1;ln.prototype.mustUseProperty=!1;ln.prototype.number=!1;ln.prototype.overloadedBoolean=!1;ln.prototype.property="";ln.prototype.spaceSeparated=!1;ln.prototype.space=void 0;let Mw=0;const Be=fs(),Rt=fs(),wc=fs(),oe=fs(),bt=fs(),ni=fs(),hn=fs();function fs(){return 2**++Mw}const vc=Object.freeze(Object.defineProperty({__proto__:null,boolean:Be,booleanish:Rt,commaOrSpaceSeparated:hn,commaSeparated:ni,number:oe,overloadedBoolean:wc,spaceSeparated:bt},Symbol.toStringTag,{value:"Module"})),Tl=Object.keys(vc);class xu extends ln{constructor(t,n,r,i){let o=-1;if(super(t,n),Bd(this,"space",i),typeof r=="number")for(;++o<Tl.length;){const a=Tl[o];Bd(this,Tl[o],(r&vc[a])===vc[a])}}}xu.prototype.defined=!0;function Bd(e,t,n){n&&(e[t]=n)}function ui(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const o=new xu(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[yc(r)]=r,n[yc(o.attribute)]=r}return new uo(t,n,e.space)}const om=ui({properties:{ariaActiveDescendant:null,ariaAtomic:Rt,ariaAutoComplete:null,ariaBusy:Rt,ariaChecked:Rt,ariaColCount:oe,ariaColIndex:oe,ariaColSpan:oe,ariaControls:bt,ariaCurrent:null,ariaDescribedBy:bt,ariaDetails:null,ariaDisabled:Rt,ariaDropEffect:bt,ariaErrorMessage:null,ariaExpanded:Rt,ariaFlowTo:bt,ariaGrabbed:Rt,ariaHasPopup:null,ariaHidden:Rt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:bt,ariaLevel:oe,ariaLive:null,ariaModal:Rt,ariaMultiLine:Rt,ariaMultiSelectable:Rt,ariaOrientation:null,ariaOwns:bt,ariaPlaceholder:null,ariaPosInSet:oe,ariaPressed:Rt,ariaReadOnly:Rt,ariaRelevant:null,ariaRequired:Rt,ariaRoleDescription:bt,ariaRowCount:oe,ariaRowIndex:oe,ariaRowSpan:oe,ariaSelected:Rt,ariaSetSize:oe,ariaSort:null,ariaValueMax:oe,ariaValueMin:oe,ariaValueNow:oe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function am(e,t){return t in e?e[t]:t}function lm(e,t){return am(e,t.toLowerCase())}const Rw=ui({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ni,acceptCharset:bt,accessKey:bt,action:null,allow:null,allowFullScreen:Be,allowPaymentRequest:Be,allowUserMedia:Be,alt:null,as:null,async:Be,autoCapitalize:null,autoComplete:bt,autoFocus:Be,autoPlay:Be,blocking:bt,capture:null,charSet:null,checked:Be,cite:null,className:bt,cols:oe,colSpan:null,content:null,contentEditable:Rt,controls:Be,controlsList:bt,coords:oe|ni,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Be,defer:Be,dir:null,dirName:null,disabled:Be,download:wc,draggable:Rt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Be,formTarget:null,headers:bt,height:oe,hidden:wc,high:oe,href:null,hrefLang:null,htmlFor:bt,httpEquiv:bt,id:null,imageSizes:null,imageSrcSet:null,inert:Be,inputMode:null,integrity:null,is:null,isMap:Be,itemId:null,itemProp:bt,itemRef:bt,itemScope:Be,itemType:bt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Be,low:oe,manifest:null,max:null,maxLength:oe,media:null,method:null,min:null,minLength:oe,multiple:Be,muted:Be,name:null,nonce:null,noModule:Be,noValidate:Be,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Be,optimum:oe,pattern:null,ping:bt,placeholder:null,playsInline:Be,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Be,referrerPolicy:null,rel:bt,required:Be,reversed:Be,rows:oe,rowSpan:oe,sandbox:bt,scope:null,scoped:Be,seamless:Be,selected:Be,shadowRootClonable:Be,shadowRootDelegatesFocus:Be,shadowRootMode:null,shape:null,size:oe,sizes:null,slot:null,span:oe,spellCheck:Rt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:oe,step:null,style:null,tabIndex:oe,target:null,title:null,translate:null,type:null,typeMustMatch:Be,useMap:null,value:Rt,width:oe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:bt,axis:null,background:null,bgColor:null,border:oe,borderColor:null,bottomMargin:oe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Be,declare:Be,event:null,face:null,frame:null,frameBorder:null,hSpace:oe,leftMargin:oe,link:null,longDesc:null,lowSrc:null,marginHeight:oe,marginWidth:oe,noResize:Be,noHref:Be,noShade:Be,noWrap:Be,object:null,profile:null,prompt:null,rev:null,rightMargin:oe,rules:null,scheme:null,scrolling:Rt,standby:null,summary:null,text:null,topMargin:oe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:oe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Be,disableRemotePlayback:Be,prefix:null,property:null,results:oe,security:null,unselectable:null},space:"html",transform:lm}),Aw=ui({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:hn,accentHeight:oe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:oe,amplitude:oe,arabicForm:null,ascent:oe,attributeName:null,attributeType:null,azimuth:oe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:oe,by:null,calcMode:null,capHeight:oe,className:bt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:oe,diffuseConstant:oe,direction:null,display:null,dur:null,divisor:oe,dominantBaseline:null,download:Be,dx:null,dy:null,edgeMode:null,editable:null,elevation:oe,enableBackground:null,end:null,event:null,exponent:oe,externalResourcesRequired:null,fill:null,fillOpacity:oe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ni,g2:ni,glyphName:ni,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:oe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:oe,horizOriginX:oe,horizOriginY:oe,id:null,ideographic:oe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:oe,k:oe,k1:oe,k2:oe,k3:oe,k4:oe,kernelMatrix:hn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:oe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:oe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:oe,overlineThickness:oe,paintOrder:null,panose1:null,path:null,pathLength:oe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:bt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:oe,pointsAtY:oe,pointsAtZ:oe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:hn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:hn,rev:hn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:hn,requiredFeatures:hn,requiredFonts:hn,requiredFormats:hn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:oe,specularExponent:oe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:oe,strikethroughThickness:oe,string:null,stroke:null,strokeDashArray:hn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:oe,strokeOpacity:oe,strokeWidth:null,style:null,surfaceScale:oe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:hn,tabIndex:oe,tableValues:null,target:null,targetX:oe,targetY:oe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:hn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:oe,underlineThickness:oe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:oe,values:null,vAlphabetic:oe,vMathematical:oe,vectorEffect:null,vHanging:oe,vIdeographic:oe,version:null,vertAdvY:oe,vertOriginX:oe,vertOriginY:oe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:oe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:am}),cm=ui({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),um=ui({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:lm}),dm=ui({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Pw={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Lw=/[A-Z]/g,Od=/-[a-z]/g,Dw=/^data[-\w.:]+$/i;function _w(e,t){const n=yc(t);let r=t,i=ln;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Dw.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(Od,Ow);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!Od.test(o)){let a=o.replace(Lw,Bw);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=xu}return new i(r,t)}function Bw(e){return"-"+e.toLowerCase()}function Ow(e){return e.charAt(1).toUpperCase()}const Ww=im([om,Rw,cm,um,dm],"html"),yu=im([om,Aw,cm,um,dm],"svg");function Fw(e){return e.join(" ").trim()}var Ds={},Il,Wd;function $w(){if(Wd)return Il;Wd=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,c=/^\s+|\s+$/g,u=`
|
|
5
5
|
`,d="/",h="*",p="",m="comment",g="declaration";function x(C,y){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];y=y||{};var A=1,j=1;function V(Y){var W=Y.match(t);W&&(A+=W.length);var U=Y.lastIndexOf(u);j=~U?Y.length-U:j+Y.length}function L(){var Y={line:A,column:j};return function(W){return W.position=new I(Y),P(),W}}function I(Y){this.start=Y,this.end={line:A,column:j},this.source=y.source}I.prototype.content=C;function G(Y){var W=new Error(y.source+":"+A+":"+j+": "+Y);if(W.reason=Y,W.filename=y.source,W.line=A,W.column=j,W.source=C,!y.silent)throw W}function q(Y){var W=Y.exec(C);if(W){var U=W[0];return V(U),C=C.slice(U.length),W}}function P(){q(n)}function T(Y){var W;for(Y=Y||[];W=H();)W!==!1&&Y.push(W);return Y}function H(){var Y=L();if(!(d!=C.charAt(0)||h!=C.charAt(1))){for(var W=2;p!=C.charAt(W)&&(h!=C.charAt(W)||d!=C.charAt(W+1));)++W;if(W+=2,p===C.charAt(W-1))return G("End of comment missing");var U=C.slice(2,W-2);return j+=2,V(U),C=C.slice(W),j+=2,Y({type:m,comment:U})}}function _(){var Y=L(),W=q(r);if(W){if(H(),!q(i))return G("property missing ':'");var U=q(o),D=Y({type:g,property:S(W[0].replace(e,p)),value:U?S(U[0].replace(e,p)):p});return q(a),D}}function ie(){var Y=[];T(Y);for(var W;W=_();)W!==!1&&(Y.push(W),T(Y));return Y}return P(),ie()}function S(C){return C?C.replace(c,p):p}return Il=x,Il}var Fd;function zw(){if(Fd)return Ds;Fd=1;var e=Ds&&Ds.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ds,"__esModule",{value:!0}),Ds.default=n;const t=e($w());function n(r,i){let o=null;if(!r||typeof r!="string")return o;const a=(0,t.default)(r),c=typeof i=="function";return a.forEach(u=>{if(u.type!=="declaration")return;const{property:d,value:h}=u;c?i(d,h,u):h&&(o=o||{},o[d]=h)}),o}return Ds}var Ai={},$d;function Hw(){if($d)return Ai;$d=1,Object.defineProperty(Ai,"__esModule",{value:!0}),Ai.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(d){return!d||n.test(d)||e.test(d)},a=function(d,h){return h.toUpperCase()},c=function(d,h){return"".concat(h,"-")},u=function(d,h){return h===void 0&&(h={}),o(d)?d:(d=d.toLowerCase(),h.reactCompat?d=d.replace(i,c):d=d.replace(r,c),d.replace(t,a))};return Ai.camelCase=u,Ai}var Pi,zd;function Uw(){if(zd)return Pi;zd=1;var e=Pi&&Pi.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(zw()),n=Hw();function r(i,o){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(c,u){c&&u&&(a[(0,n.camelCase)(c,o)]=u)}),a}return r.default=r,Pi=r,Pi}var qw=Uw();const Gw=lf(qw),hm=pm("end"),wu=pm("start");function pm(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Vw(e){const t=wu(e),n=hm(e);if(t&&n)return{start:t,end:n}}function Gi(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Hd(e.position):"start"in e||"end"in e?Hd(e):"line"in e||"column"in e?Sc(e):""}function Sc(e){return Ud(e&&e.line)+":"+Ud(e&&e.column)}function Hd(e){return Sc(e&&e.start)+"-"+Sc(e&&e.end)}function Ud(e){return e&&typeof e=="number"?e:1}class Kt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?i=t:!o.cause&&t&&(a=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?o.ruleId=r:(o.source=r.slice(0,u),o.ruleId=r.slice(u+1))}if(!o.place&&o.ancestors&&o.ancestors){const u=o.ancestors[o.ancestors.length-1];u&&(o.place=u.position)}const c=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=c?c.line:void 0,this.name=Gi(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Kt.prototype.file="";Kt.prototype.name="";Kt.prototype.reason="";Kt.prototype.message="";Kt.prototype.stack="";Kt.prototype.column=void 0;Kt.prototype.line=void 0;Kt.prototype.ancestors=void 0;Kt.prototype.cause=void 0;Kt.prototype.fatal=void 0;Kt.prototype.place=void 0;Kt.prototype.ruleId=void 0;Kt.prototype.source=void 0;const vu={}.hasOwnProperty,Kw=new Map,Yw=/[A-Z]/g,Xw=new Set(["table","tbody","thead","tfoot","tr"]),Jw=new Set(["td","th"]),fm="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Qw(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=ov(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=iv(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?yu:Ww,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=mm(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function mm(e,t,n){if(t.type==="element")return Zw(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return ev(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return nv(e,t,n);if(t.type==="mdxjsEsm")return tv(e,t);if(t.type==="root")return rv(e,t,n);if(t.type==="text")return sv(e,t)}function Zw(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=yu,e.schema=i),e.ancestors.push(t);const o=bm(e,t.tagName,!1),a=av(e,t);let c=Cu(e,t);return Xw.has(t.tagName)&&(c=c.filter(function(u){return typeof u=="string"?!Ew(u):!0})),gm(e,a,o,t),Su(a,c),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function ev(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Zi(e,t.position)}function tv(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Zi(e,t.position)}function nv(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=yu,e.schema=i),e.ancestors.push(t);const o=t.name===null?e.Fragment:bm(e,t.name,!0),a=lv(e,t),c=Cu(e,t);return gm(e,a,o,t),Su(a,c),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function rv(e,t,n){const r={};return Su(r,Cu(e,t)),e.create(t,e.Fragment,r,n)}function sv(e,t){return t.value}function gm(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Su(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function iv(e,t,n){return r;function r(i,o,a,c){const d=Array.isArray(a.children)?n:t;return c?d(o,a,c):d(o,a)}}function ov(e,t){return n;function n(r,i,o,a){const c=Array.isArray(o.children),u=wu(r);return t(i,o,a,c,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function av(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&vu.call(t.properties,i)){const o=cv(e,i,t.properties[i]);if(o){const[a,c]=o;e.tableCellAlignToStyle&&a==="align"&&typeof c=="string"&&Jw.has(t.tagName)?r=c:n[a]=c}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function lv(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const c=a.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else Zi(e,t.position);else{const i=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,o=e.evaluater.evaluateExpression(c.expression)}else Zi(e,t.position);else o=r.value===null?!0:r.value;n[i]=o}return n}function Cu(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Kw;for(;++r<t.children.length;){const o=t.children[r];let a;if(e.passKeys){const u=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(u){const d=i.get(u)||0;a=u+"-"+d,i.set(u,d+1)}}const c=mm(e,o,a);c!==void 0&&n.push(c)}return n}function cv(e,t,n){const r=_w(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Cw(n):Fw(n)),r.property==="style"){let i=typeof n=="object"?n:uv(e,String(n));return e.stylePropertyNameCase==="css"&&(i=dv(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Pw[r.property]||r.property:r.attribute,n]}}function uv(e,t){try{return Gw(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Kt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=fm+"#cannot-parse-style-attribute",i}}function bm(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let o=-1,a;for(;++o<i.length;){const c=Dd(i[o])?{type:"Identifier",name:i[o]}:{type:"Literal",value:i[o]};a=a?{type:"MemberExpression",object:a,property:c,computed:!!(o&&c.type==="Literal"),optional:!1}:c}r=a}else r=Dd(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return vu.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Zi(e)}function Zi(e,t){const n=new Kt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=fm+"#cannot-handle-mdx-estrees-without-createevaluater",n}function dv(e){const t={};let n;for(n in e)vu.call(e,n)&&(t[hv(n)]=e[n]);return t}function hv(e){let t=e.replace(Yw,pv);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function pv(e){return"-"+e.toLowerCase()}const El={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},fv={};function Nu(e,t){const n=fv,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return km(e,r,i)}function km(e,t,n){if(mv(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return qd(e.children,t,n)}return Array.isArray(e)?qd(e,t,n):""}function qd(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=km(e[i],t,n);return r.join("")}function mv(e){return!!(e&&typeof e=="object")}const Gd=document.createElement("i");function ju(e){const t="&"+e+";";Gd.innerHTML=t;const n=Gd.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function gn(e,t,n,r){const i=e.length;let o=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function Tn(e,t){return e.length>0?(gn(e,e.length,0,t),e):t}const Vd={}.hasOwnProperty;function xm(e){const t={};let n=-1;for(;++n<e.length;)gv(t,e[n]);return t}function gv(e,t){let n;for(n in t){const i=(Vd.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){Vd.call(i,a)||(i[a]=[]);const c=o[a];bv(i[a],Array.isArray(c)?c:c?[c]:[])}}}function bv(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);gn(e,0,0,r)}function ym(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function On(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const en=Br(/[A-Za-z]/),Vt=Br(/[\dA-Za-z]/),kv=Br(/[#-'*+\--9=?A-Z^-~]/);function Na(e){return e!==null&&(e<32||e===127)}const Cc=Br(/\d/),xv=Br(/[\dA-Fa-f]/),yv=Br(/[!-/:-@[-`{-~]/);function Ie(e){return e!==null&&e<-2}function dt(e){return e!==null&&(e<0||e===32)}function ze(e){return e===-2||e===-1||e===32}const Ua=Br(new RegExp("\\p{P}|\\p{S}","u")),us=Br(/\s/);function Br(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function di(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&Vt(e.charCodeAt(n+1))&&Vt(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const c=e.charCodeAt(n+1);o<56320&&c>56319&&c<57344?(a=String.fromCharCode(o,c),i=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Ye(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(u){return ze(u)?(e.enter(n),c(u)):t(u)}function c(u){return ze(u)&&o++<i?(e.consume(u),c):(e.exit(n),t(u))}}const wv={tokenize:vv};function vv(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Ye(e,t,"linePrefix")}function i(c){return e.enter("paragraph"),o(c)}function o(c){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,a(c)}function a(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return Ie(c)?(e.consume(c),e.exit("chunkText"),o):(e.consume(c),a)}}const Sv={tokenize:Cv},Kd={tokenize:Nv};function Cv(e){const t=this,n=[];let r=0,i,o,a;return c;function c(j){if(r<n.length){const V=n[r];return t.containerState=V[1],e.attempt(V[0].continuation,u,d)(j)}return d(j)}function u(j){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&A();const V=t.events.length;let L=V,I;for(;L--;)if(t.events[L][0]==="exit"&&t.events[L][1].type==="chunkFlow"){I=t.events[L][1].end;break}y(r);let G=V;for(;G<t.events.length;)t.events[G][1].end={...I},G++;return gn(t.events,L+1,0,t.events.slice(V)),t.events.length=G,d(j)}return c(j)}function d(j){if(r===n.length){if(!i)return m(j);if(i.currentConstruct&&i.currentConstruct.concrete)return x(j);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Kd,h,p)(j)}function h(j){return i&&A(),y(r),m(j)}function p(j){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,x(j)}function m(j){return t.containerState={},e.attempt(Kd,g,x)(j)}function g(j){return r++,n.push([t.currentConstruct,t.containerState]),m(j)}function x(j){if(j===null){i&&A(),y(0),e.consume(j);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),S(j)}function S(j){if(j===null){C(e.exit("chunkFlow"),!0),y(0),e.consume(j);return}return Ie(j)?(e.consume(j),C(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(j),S)}function C(j,V){const L=t.sliceStream(j);if(V&&L.push(null),j.previous=o,o&&(o.next=j),o=j,i.defineSkip(j.start),i.write(L),t.parser.lazy[j.start.line]){let I=i.events.length;for(;I--;)if(i.events[I][1].start.offset<a&&(!i.events[I][1].end||i.events[I][1].end.offset>a))return;const G=t.events.length;let q=G,P,T;for(;q--;)if(t.events[q][0]==="exit"&&t.events[q][1].type==="chunkFlow"){if(P){T=t.events[q][1].end;break}P=!0}for(y(r),I=G;I<t.events.length;)t.events[I][1].end={...T},I++;gn(t.events,q+1,0,t.events.slice(G)),t.events.length=I}}function y(j){let V=n.length;for(;V-- >j;){const L=n[V];t.containerState=L[1],L[0].exit.call(t,e)}n.length=j}function A(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Nv(e,t,n){return Ye(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function oi(e){if(e===null||dt(e)||us(e))return 1;if(Ua(e))return 2}function qa(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const Nc={name:"attention",resolveAll:jv,tokenize:Tv};function jv(e,t){let n=-1,r,i,o,a,c,u,d,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},m={...e[n][1].start};Yd(p,-u),Yd(m,u),a={type:u>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},c={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:m},o={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?"strong":"emphasis",start:{...a.start},end:{...c.end}},e[r][1].end={...a.start},e[n][1].start={...c.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=Tn(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=Tn(d,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",o,t]]),d=Tn(d,qa(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=Tn(d,[["exit",o,t],["enter",c,t],["exit",c,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,d=Tn(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,gn(e,r-1,n-r+3,d),n=r+d.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Tv(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=oi(r);let o;return a;function a(u){return o=u,e.enter("attentionSequence"),c(u)}function c(u){if(u===o)return e.consume(u),c;const d=e.exit("attentionSequence"),h=oi(u),p=!h||h===2&&i||n.includes(u),m=!i||i===2&&h||n.includes(r);return d._open=!!(o===42?p:p&&(i||!m)),d._close=!!(o===42?m:m&&(h||!p)),t(u)}}function Yd(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Iv={name:"autolink",tokenize:Ev};function Ev(e,t,n){let r=0;return i;function i(g){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(g){return en(g)?(e.consume(g),a):g===64?n(g):d(g)}function a(g){return g===43||g===45||g===46||Vt(g)?(r=1,c(g)):d(g)}function c(g){return g===58?(e.consume(g),r=0,u):(g===43||g===45||g===46||Vt(g))&&r++<32?(e.consume(g),c):(r=0,d(g))}function u(g){return g===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.exit("autolink"),t):g===null||g===32||g===60||Na(g)?n(g):(e.consume(g),u)}function d(g){return g===64?(e.consume(g),h):kv(g)?(e.consume(g),d):n(g)}function h(g){return Vt(g)?p(g):n(g)}function p(g){return g===46?(e.consume(g),r=0,h):g===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.exit("autolink"),t):m(g)}function m(g){if((g===45||Vt(g))&&r++<63){const x=g===45?m:p;return e.consume(g),x}return n(g)}}const ho={partial:!0,tokenize:Mv};function Mv(e,t,n){return r;function r(o){return ze(o)?Ye(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||Ie(o)?t(o):n(o)}}const wm={continuation:{tokenize:Av},exit:Pv,name:"blockQuote",tokenize:Rv};function Rv(e,t,n){const r=this;return i;function i(a){if(a===62){const c=r.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return n(a)}function o(a){return ze(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Av(e,t,n){const r=this;return i;function i(a){return ze(a)?Ye(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(wm,t,n)(a)}}function Pv(e){e.exit("blockQuote")}const vm={name:"characterEscape",tokenize:Lv};function Lv(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),i}function i(o){return yv(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const Sm={name:"characterReference",tokenize:Dv};function Dv(e,t,n){const r=this;let i=0,o,a;return c;function c(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),u}function u(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),o=31,a=Vt,h(p))}function d(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=xv,h):(e.enter("characterReferenceValue"),o=7,a=Cc,h(p))}function h(p){if(p===59&&i){const m=e.exit("characterReferenceValue");return a===Vt&&!ju(r.sliceSerialize(m))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(p)&&i++<o?(e.consume(p),h):n(p)}}const Xd={partial:!0,tokenize:Bv},Jd={concrete:!0,name:"codeFenced",tokenize:_v};function _v(e,t,n){const r=this,i={partial:!0,tokenize:L};let o=0,a=0,c;return u;function u(I){return d(I)}function d(I){const G=r.events[r.events.length-1];return o=G&&G[1].type==="linePrefix"?G[2].sliceSerialize(G[1],!0).length:0,c=I,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(I)}function h(I){return I===c?(a++,e.consume(I),h):a<3?n(I):(e.exit("codeFencedFenceSequence"),ze(I)?Ye(e,p,"whitespace")(I):p(I))}function p(I){return I===null||Ie(I)?(e.exit("codeFencedFence"),r.interrupt?t(I):e.check(Xd,S,V)(I)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(I))}function m(I){return I===null||Ie(I)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(I)):ze(I)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ye(e,g,"whitespace")(I)):I===96&&I===c?n(I):(e.consume(I),m)}function g(I){return I===null||Ie(I)?p(I):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),x(I))}function x(I){return I===null||Ie(I)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(I)):I===96&&I===c?n(I):(e.consume(I),x)}function S(I){return e.attempt(i,V,C)(I)}function C(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),y}function y(I){return o>0&&ze(I)?Ye(e,A,"linePrefix",o+1)(I):A(I)}function A(I){return I===null||Ie(I)?e.check(Xd,S,V)(I):(e.enter("codeFlowValue"),j(I))}function j(I){return I===null||Ie(I)?(e.exit("codeFlowValue"),A(I)):(e.consume(I),j)}function V(I){return e.exit("codeFenced"),t(I)}function L(I,G,q){let P=0;return T;function T(W){return I.enter("lineEnding"),I.consume(W),I.exit("lineEnding"),H}function H(W){return I.enter("codeFencedFence"),ze(W)?Ye(I,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(W):_(W)}function _(W){return W===c?(I.enter("codeFencedFenceSequence"),ie(W)):q(W)}function ie(W){return W===c?(P++,I.consume(W),ie):P>=a?(I.exit("codeFencedFenceSequence"),ze(W)?Ye(I,Y,"whitespace")(W):Y(W)):q(W)}function Y(W){return W===null||Ie(W)?(I.exit("codeFencedFence"),G(W)):q(W)}}}function Bv(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Ml={name:"codeIndented",tokenize:Wv},Ov={partial:!0,tokenize:Fv};function Wv(e,t,n){const r=this;return i;function i(d){return e.enter("codeIndented"),Ye(e,o,"linePrefix",5)(d)}function o(d){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?u(d):Ie(d)?e.attempt(Ov,a,u)(d):(e.enter("codeFlowValue"),c(d))}function c(d){return d===null||Ie(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),c)}function u(d){return e.exit("codeIndented"),t(d)}}function Fv(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):Ie(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):Ye(e,o,"linePrefix",5)(a)}function o(a){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(a):Ie(a)?i(a):n(a)}}const $v={name:"codeText",previous:Hv,resolve:zv,tokenize:Uv};function zv(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Hv(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Uv(e,t,n){let r=0,i,o;return a;function a(p){return e.enter("codeText"),e.enter("codeTextSequence"),c(p)}function c(p){return p===96?(e.consume(p),r++,c):(e.exit("codeTextSequence"),u(p))}function u(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),u):p===96?(o=e.enter("codeTextSequence"),i=0,h(p)):Ie(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("codeTextData"),d(p))}function d(p){return p===null||p===32||p===96||Ie(p)?(e.exit("codeTextData"),u(p)):(e.consume(p),d)}function h(p){return p===96?(e.consume(p),i++,h):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(o.type="codeTextData",d(p))}}class qv{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Li(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Li(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Li(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Li(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Li(this.left,n.reverse())}}}function Li(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Cm(e){const t={};let n=-1,r,i,o,a,c,u,d;const h=new qv(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type==="lineEndingBlank"&&(o+=2),o<u.length&&u[o][1].type==="content"))for(;++o<u.length&&u[o][1].type!=="content";)u[o][1].type==="chunkText"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Gv(h,n)),n=t[n],d=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(a=h.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(h.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=o);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...h.get(i)[1].start},c=h.slice(i,n),c.unshift(r),h.splice(i,n-i+1,c))}}return gn(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!d}function Gv(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const c=a.events,u=[],d={};let h,p,m=-1,g=n,x=0,S=0;const C=[S];for(;g;){for(;e.get(++i)[1]!==g;);o.push(i),g._tokenizer||(h=r.sliceStream(g),g.next||h.push(null),p&&a.defineSkip(g.start),g._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(h),g._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),p=g,g=g.next}for(g=n;++m<c.length;)c[m][0]==="exit"&&c[m-1][0]==="enter"&&c[m][1].type===c[m-1][1].type&&c[m][1].start.line!==c[m][1].end.line&&(S=m+1,C.push(S),g._tokenizer=void 0,g.previous=void 0,g=g.next);for(a.events=[],g?(g._tokenizer=void 0,g.previous=void 0):C.pop(),m=C.length;m--;){const y=c.slice(C[m],C[m+1]),A=o.pop();u.push([A,A+y.length-1]),e.splice(A,2,y)}for(u.reverse(),m=-1;++m<u.length;)d[x+u[m][0]]=x+u[m][1],x+=u[m][1]-u[m][0]-1;return d}const Vv={resolve:Yv,tokenize:Xv},Kv={partial:!0,tokenize:Jv};function Yv(e){return Cm(e),e}function Xv(e,t){let n;return r;function r(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(c)}function i(c){return c===null?o(c):Ie(c)?e.check(Kv,a,o)(c):(e.consume(c),i)}function o(c){return e.exit("chunkContent"),e.exit("content"),t(c)}function a(c){return e.consume(c),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function Jv(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ye(e,o,"linePrefix")}function o(a){if(a===null||Ie(a))return n(a);const c=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Nm(e,t,n,r,i,o,a,c,u){const d=u||Number.POSITIVE_INFINITY;let h=0;return p;function p(y){return y===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(y),e.exit(o),m):y===null||y===32||y===41||Na(y)?n(y):(e.enter(r),e.enter(a),e.enter(c),e.enter("chunkString",{contentType:"string"}),S(y))}function m(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),g(y))}function g(y){return y===62?(e.exit("chunkString"),e.exit(c),m(y)):y===null||y===60||Ie(y)?n(y):(e.consume(y),y===92?x:g)}function x(y){return y===60||y===62||y===92?(e.consume(y),g):g(y)}function S(y){return!h&&(y===null||y===41||dt(y))?(e.exit("chunkString"),e.exit(c),e.exit(a),e.exit(r),t(y)):h<d&&y===40?(e.consume(y),h++,S):y===41?(e.consume(y),h--,S):y===null||y===32||y===40||Na(y)?n(y):(e.consume(y),y===92?C:S)}function C(y){return y===40||y===41||y===92?(e.consume(y),S):S(y)}}function jm(e,t,n,r,i,o){const a=this;let c=0,u;return d;function d(g){return e.enter(r),e.enter(i),e.consume(g),e.exit(i),e.enter(o),h}function h(g){return c>999||g===null||g===91||g===93&&!u||g===94&&!c&&"_hiddenFootnoteSupport"in a.parser.constructs?n(g):g===93?(e.exit(o),e.enter(i),e.consume(g),e.exit(i),e.exit(r),t):Ie(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===null||g===91||g===93||Ie(g)||c++>999?(e.exit("chunkString"),h(g)):(e.consume(g),u||(u=!ze(g)),g===92?m:p)}function m(g){return g===91||g===92||g===93?(e.consume(g),c++,p):p(g)}}function Tm(e,t,n,r,i,o){let a;return c;function c(m){return m===34||m===39||m===40?(e.enter(r),e.enter(i),e.consume(m),e.exit(i),a=m===40?41:m,u):n(m)}function u(m){return m===a?(e.enter(i),e.consume(m),e.exit(i),e.exit(r),t):(e.enter(o),d(m))}function d(m){return m===a?(e.exit(o),u(a)):m===null?n(m):Ie(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),Ye(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(m))}function h(m){return m===a||m===null||Ie(m)?(e.exit("chunkString"),d(m)):(e.consume(m),m===92?p:h)}function p(m){return m===a||m===92?(e.consume(m),h):h(m)}}function Vi(e,t){let n;return r;function r(i){return Ie(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ze(i)?Ye(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Qv={name:"definition",tokenize:eS},Zv={partial:!0,tokenize:tS};function eS(e,t,n){const r=this;let i;return o;function o(g){return e.enter("definition"),a(g)}function a(g){return jm.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(g)}function c(g){return i=On(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),u):n(g)}function u(g){return dt(g)?Vi(e,d)(g):d(g)}function d(g){return Nm(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(g)}function h(g){return e.attempt(Zv,p,p)(g)}function p(g){return ze(g)?Ye(e,m,"whitespace")(g):m(g)}function m(g){return g===null||Ie(g)?(e.exit("definition"),r.parser.defined.push(i),t(g)):n(g)}}function tS(e,t,n){return r;function r(c){return dt(c)?Vi(e,i)(c):n(c)}function i(c){return Tm(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return ze(c)?Ye(e,a,"whitespace")(c):a(c)}function a(c){return c===null||Ie(c)?t(c):n(c)}}const nS={name:"hardBreakEscape",tokenize:rS};function rS(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return Ie(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const sS={name:"headingAtx",resolve:iS,tokenize:oS};function iS(e,t){let n=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},gn(e,r,n-r+1,[["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t]])),e}function oS(e,t,n){let r=0;return i;function i(h){return e.enter("atxHeading"),o(h)}function o(h){return e.enter("atxHeadingSequence"),a(h)}function a(h){return h===35&&r++<6?(e.consume(h),a):h===null||dt(h)?(e.exit("atxHeadingSequence"),c(h)):n(h)}function c(h){return h===35?(e.enter("atxHeadingSequence"),u(h)):h===null||Ie(h)?(e.exit("atxHeading"),t(h)):ze(h)?Ye(e,c,"whitespace")(h):(e.enter("atxHeadingText"),d(h))}function u(h){return h===35?(e.consume(h),u):(e.exit("atxHeadingSequence"),c(h))}function d(h){return h===null||h===35||dt(h)?(e.exit("atxHeadingText"),c(h)):(e.consume(h),d)}}const aS=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Qd=["pre","script","style","textarea"],lS={concrete:!0,name:"htmlFlow",resolveTo:dS,tokenize:hS},cS={partial:!0,tokenize:fS},uS={partial:!0,tokenize:pS};function dS(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function hS(e,t,n){const r=this;let i,o,a,c,u;return d;function d(N){return h(N)}function h(N){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(N),p}function p(N){return N===33?(e.consume(N),m):N===47?(e.consume(N),o=!0,S):N===63?(e.consume(N),i=3,r.interrupt?t:v):en(N)?(e.consume(N),a=String.fromCharCode(N),C):n(N)}function m(N){return N===45?(e.consume(N),i=2,g):N===91?(e.consume(N),i=5,c=0,x):en(N)?(e.consume(N),i=4,r.interrupt?t:v):n(N)}function g(N){return N===45?(e.consume(N),r.interrupt?t:v):n(N)}function x(N){const de="CDATA[";return N===de.charCodeAt(c++)?(e.consume(N),c===de.length?r.interrupt?t:_:x):n(N)}function S(N){return en(N)?(e.consume(N),a=String.fromCharCode(N),C):n(N)}function C(N){if(N===null||N===47||N===62||dt(N)){const de=N===47,Ee=a.toLowerCase();return!de&&!o&&Qd.includes(Ee)?(i=1,r.interrupt?t(N):_(N)):aS.includes(a.toLowerCase())?(i=6,de?(e.consume(N),y):r.interrupt?t(N):_(N)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(N):o?A(N):j(N))}return N===45||Vt(N)?(e.consume(N),a+=String.fromCharCode(N),C):n(N)}function y(N){return N===62?(e.consume(N),r.interrupt?t:_):n(N)}function A(N){return ze(N)?(e.consume(N),A):T(N)}function j(N){return N===47?(e.consume(N),T):N===58||N===95||en(N)?(e.consume(N),V):ze(N)?(e.consume(N),j):T(N)}function V(N){return N===45||N===46||N===58||N===95||Vt(N)?(e.consume(N),V):L(N)}function L(N){return N===61?(e.consume(N),I):ze(N)?(e.consume(N),L):j(N)}function I(N){return N===null||N===60||N===61||N===62||N===96?n(N):N===34||N===39?(e.consume(N),u=N,G):ze(N)?(e.consume(N),I):q(N)}function G(N){return N===u?(e.consume(N),u=null,P):N===null||Ie(N)?n(N):(e.consume(N),G)}function q(N){return N===null||N===34||N===39||N===47||N===60||N===61||N===62||N===96||dt(N)?L(N):(e.consume(N),q)}function P(N){return N===47||N===62||ze(N)?j(N):n(N)}function T(N){return N===62?(e.consume(N),H):n(N)}function H(N){return N===null||Ie(N)?_(N):ze(N)?(e.consume(N),H):n(N)}function _(N){return N===45&&i===2?(e.consume(N),U):N===60&&i===1?(e.consume(N),D):N===62&&i===4?(e.consume(N),Ne):N===63&&i===3?(e.consume(N),v):N===93&&i===5?(e.consume(N),ee):Ie(N)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(cS,ve,ie)(N)):N===null||Ie(N)?(e.exit("htmlFlowData"),ie(N)):(e.consume(N),_)}function ie(N){return e.check(uS,Y,ve)(N)}function Y(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),W}function W(N){return N===null||Ie(N)?ie(N):(e.enter("htmlFlowData"),_(N))}function U(N){return N===45?(e.consume(N),v):_(N)}function D(N){return N===47?(e.consume(N),a="",K):_(N)}function K(N){if(N===62){const de=a.toLowerCase();return Qd.includes(de)?(e.consume(N),Ne):_(N)}return en(N)&&a.length<8?(e.consume(N),a+=String.fromCharCode(N),K):_(N)}function ee(N){return N===93?(e.consume(N),v):_(N)}function v(N){return N===62?(e.consume(N),Ne):N===45&&i===2?(e.consume(N),v):_(N)}function Ne(N){return N===null||Ie(N)?(e.exit("htmlFlowData"),ve(N)):(e.consume(N),Ne)}function ve(N){return e.exit("htmlFlow"),t(N)}}function pS(e,t,n){const r=this;return i;function i(a){return Ie(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function fS(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(ho,t,n)}}const mS={name:"htmlText",tokenize:gS};function gS(e,t,n){const r=this;let i,o,a;return c;function c(v){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(v),u}function u(v){return v===33?(e.consume(v),d):v===47?(e.consume(v),L):v===63?(e.consume(v),j):en(v)?(e.consume(v),q):n(v)}function d(v){return v===45?(e.consume(v),h):v===91?(e.consume(v),o=0,x):en(v)?(e.consume(v),A):n(v)}function h(v){return v===45?(e.consume(v),g):n(v)}function p(v){return v===null?n(v):v===45?(e.consume(v),m):Ie(v)?(a=p,D(v)):(e.consume(v),p)}function m(v){return v===45?(e.consume(v),g):p(v)}function g(v){return v===62?U(v):v===45?m(v):p(v)}function x(v){const Ne="CDATA[";return v===Ne.charCodeAt(o++)?(e.consume(v),o===Ne.length?S:x):n(v)}function S(v){return v===null?n(v):v===93?(e.consume(v),C):Ie(v)?(a=S,D(v)):(e.consume(v),S)}function C(v){return v===93?(e.consume(v),y):S(v)}function y(v){return v===62?U(v):v===93?(e.consume(v),y):S(v)}function A(v){return v===null||v===62?U(v):Ie(v)?(a=A,D(v)):(e.consume(v),A)}function j(v){return v===null?n(v):v===63?(e.consume(v),V):Ie(v)?(a=j,D(v)):(e.consume(v),j)}function V(v){return v===62?U(v):j(v)}function L(v){return en(v)?(e.consume(v),I):n(v)}function I(v){return v===45||Vt(v)?(e.consume(v),I):G(v)}function G(v){return Ie(v)?(a=G,D(v)):ze(v)?(e.consume(v),G):U(v)}function q(v){return v===45||Vt(v)?(e.consume(v),q):v===47||v===62||dt(v)?P(v):n(v)}function P(v){return v===47?(e.consume(v),U):v===58||v===95||en(v)?(e.consume(v),T):Ie(v)?(a=P,D(v)):ze(v)?(e.consume(v),P):U(v)}function T(v){return v===45||v===46||v===58||v===95||Vt(v)?(e.consume(v),T):H(v)}function H(v){return v===61?(e.consume(v),_):Ie(v)?(a=H,D(v)):ze(v)?(e.consume(v),H):P(v)}function _(v){return v===null||v===60||v===61||v===62||v===96?n(v):v===34||v===39?(e.consume(v),i=v,ie):Ie(v)?(a=_,D(v)):ze(v)?(e.consume(v),_):(e.consume(v),Y)}function ie(v){return v===i?(e.consume(v),i=void 0,W):v===null?n(v):Ie(v)?(a=ie,D(v)):(e.consume(v),ie)}function Y(v){return v===null||v===34||v===39||v===60||v===61||v===96?n(v):v===47||v===62||dt(v)?P(v):(e.consume(v),Y)}function W(v){return v===47||v===62||dt(v)?P(v):n(v)}function U(v){return v===62?(e.consume(v),e.exit("htmlTextData"),e.exit("htmlText"),t):n(v)}function D(v){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),K}function K(v){return ze(v)?Ye(e,ee,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(v):ee(v)}function ee(v){return e.enter("htmlTextData"),a(v)}}const Tu={name:"labelEnd",resolveAll:yS,resolveTo:wS,tokenize:vS},bS={tokenize:SS},kS={tokenize:CS},xS={tokenize:NS};function yS(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&gn(e,0,e.length,n),e}function wS(e,t){let n=e.length,r=0,i,o,a,c;for(;n--;)if(i=e[n][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const u={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},h={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return c=[["enter",u,t],["enter",d,t]],c=Tn(c,e.slice(o+1,o+r+3)),c=Tn(c,[["enter",h,t]]),c=Tn(c,qa(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),c=Tn(c,[["exit",h,t],e[a-2],e[a-1],["exit",d,t]]),c=Tn(c,e.slice(a+1)),c=Tn(c,[["exit",u,t]]),gn(e,o,e.length,c),e}function vS(e,t,n){const r=this;let i=r.events.length,o,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return c;function c(m){return o?o._inactive?p(m):(a=r.parser.defined.includes(On(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),u):n(m)}function u(m){return m===40?e.attempt(bS,h,a?h:p)(m):m===91?e.attempt(kS,h,a?d:p)(m):a?h(m):p(m)}function d(m){return e.attempt(xS,h,p)(m)}function h(m){return t(m)}function p(m){return o._balanced=!0,n(m)}}function SS(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),i}function i(p){return dt(p)?Vi(e,o)(p):o(p)}function o(p){return p===41?h(p):Nm(e,a,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function a(p){return dt(p)?Vi(e,u)(p):h(p)}function c(p){return n(p)}function u(p){return p===34||p===39||p===40?Tm(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):h(p)}function d(p){return dt(p)?Vi(e,h)(p):h(p)}function h(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function CS(e,t,n){const r=this;return i;function i(c){return jm.call(r,e,o,a,"reference","referenceMarker","referenceString")(c)}function o(c){return r.parser.defined.includes(On(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function a(c){return n(c)}}function NS(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),i}function i(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const jS={name:"labelStartImage",resolveAll:Tu.resolveAll,tokenize:TS};function TS(e,t,n){const r=this;return i;function i(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),o}function o(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),a):n(c)}function a(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const IS={name:"labelStartLink",resolveAll:Tu.resolveAll,tokenize:ES};function ES(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Rl={name:"lineEnding",tokenize:MS};function MS(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ye(e,t,"linePrefix")}}const ma={name:"thematicBreak",tokenize:RS};function RS(e,t,n){let r=0,i;return o;function o(d){return e.enter("thematicBreak"),a(d)}function a(d){return i=d,c(d)}function c(d){return d===i?(e.enter("thematicBreakSequence"),u(d)):r>=3&&(d===null||Ie(d))?(e.exit("thematicBreak"),t(d)):n(d)}function u(d){return d===i?(e.consume(d),r++,u):(e.exit("thematicBreakSequence"),ze(d)?Ye(e,c,"whitespace")(d):c(d))}}const on={continuation:{tokenize:DS},exit:BS,name:"list",tokenize:LS},AS={partial:!0,tokenize:OS},PS={partial:!0,tokenize:_S};function LS(e,t,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return c;function c(g){const x=r.containerState.type||(g===42||g===43||g===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!r.containerState.marker||g===r.containerState.marker:Cc(g)){if(r.containerState.type||(r.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),g===42||g===45?e.check(ma,n,d)(g):d(g);if(!r.interrupt||g===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(g)}return n(g)}function u(g){return Cc(g)&&++a<10?(e.consume(g),u):(!r.interrupt||a<2)&&(r.containerState.marker?g===r.containerState.marker:g===41||g===46)?(e.exit("listItemValue"),d(g)):n(g)}function d(g){return e.enter("listItemMarker"),e.consume(g),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||g,e.check(ho,r.interrupt?n:h,e.attempt(AS,m,p))}function h(g){return r.containerState.initialBlankLine=!0,o++,m(g)}function p(g){return ze(g)?(e.enter("listItemPrefixWhitespace"),e.consume(g),e.exit("listItemPrefixWhitespace"),m):n(g)}function m(g){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(g)}}function DS(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ho,i,o);function i(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ye(e,t,"listItemIndent",r.containerState.size+1)(c)}function o(c){return r.containerState.furtherBlankLines||!ze(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(PS,t,a)(c))}function a(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ye(e,e.attempt(on,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function _S(e,t,n){const r=this;return Ye(e,i,"listItemIndent",r.containerState.size+1);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function BS(e){e.exit(this.containerState.type)}function OS(e,t,n){const r=this;return Ye(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const a=r.events[r.events.length-1];return!ze(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Zd={name:"setextUnderline",resolveTo:WS,tokenize:FS};function WS(e,t){let n=e.length,r,i,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",a,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function FS(e,t,n){const r=this;let i;return o;function o(d){let h=r.events.length,p;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){p=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(e.enter("setextHeadingLine"),i=d,a(d)):n(d)}function a(d){return e.enter("setextHeadingLineSequence"),c(d)}function c(d){return d===i?(e.consume(d),c):(e.exit("setextHeadingLineSequence"),ze(d)?Ye(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||Ie(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const $S={tokenize:zS};function zS(e){const t=this,n=e.attempt(ho,r,e.attempt(this.parser.constructs.flowInitial,i,Ye(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Vv,i)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const HS={resolveAll:Em()},US=Im("string"),qS=Im("text");function Im(e){return{resolveAll:Em(e==="text"?GS:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],o=n.attempt(i,a,c);return a;function a(h){return d(h)?o(h):c(h)}function c(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),u}function u(h){return d(h)?(n.exit("data"),o(h)):(n.consume(h),u)}function d(h){if(h===null)return!0;const p=i[h];let m=-1;if(p)for(;++m<p.length;){const g=p[m];if(!g.previous||g.previous.call(r,r.previous))return!0}return!1}}}function Em(e){return t;function t(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type==="data"&&(o=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(n,r):n}}function GS(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let o=i.length,a=-1,c=0,u;for(;o--;){const d=i[o];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)c++,a--;if(a)break;a=-1}else if(d===-2)u=!0,c++;else if(d!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const d={type:n===e.length||u||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,line:r.end.line,column:r.end.column-c,offset:r.end.offset-c},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const VS={42:on,43:on,45:on,48:on,49:on,50:on,51:on,52:on,53:on,54:on,55:on,56:on,57:on,62:wm},KS={91:Qv},YS={[-2]:Ml,[-1]:Ml,32:Ml},XS={35:sS,42:ma,45:[Zd,ma],60:lS,61:Zd,95:ma,96:Jd,126:Jd},JS={38:Sm,92:vm},QS={[-5]:Rl,[-4]:Rl,[-3]:Rl,33:jS,38:Sm,42:Nc,60:[Iv,mS],91:IS,92:[nS,vm],93:Tu,95:Nc,96:$v},ZS={null:[Nc,HS]},eC={null:[42,95]},tC={null:[]},nC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:eC,contentInitial:KS,disable:tC,document:VS,flow:XS,flowInitial:YS,insideSpan:ZS,string:JS,text:QS},Symbol.toStringTag,{value:"Module"}));function rC(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},o=[];let a=[],c=[];const u={attempt:G(L),check:G(I),consume:A,enter:j,exit:V,interrupt:G(I,{interrupt:!0})},d={code:null,containerState:{},defineSkip:S,events:[],now:x,parser:e,previous:null,sliceSerialize:m,sliceStream:g,write:p};let h=t.tokenize.call(d,u);return t.resolveAll&&o.push(t),d;function p(H){return a=Tn(a,H),C(),a[a.length-1]!==null?[]:(q(t,0),d.events=qa(o,d.events,d),d.events)}function m(H,_){return iC(g(H),_)}function g(H){return sC(a,H)}function x(){const{_bufferIndex:H,_index:_,line:ie,column:Y,offset:W}=r;return{_bufferIndex:H,_index:_,line:ie,column:Y,offset:W}}function S(H){i[H.line]=H.column,T()}function C(){let H;for(;r._index<a.length;){const _=a[r._index];if(typeof _=="string")for(H=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===H&&r._bufferIndex<_.length;)y(_.charCodeAt(r._bufferIndex));else y(_)}}function y(H){h=h(H)}function A(H){Ie(H)?(r.line++,r.column=1,r.offset+=H===-3?2:1,T()):H!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=H}function j(H,_){const ie=_||{};return ie.type=H,ie.start=x(),d.events.push(["enter",ie,d]),c.push(ie),ie}function V(H){const _=c.pop();return _.end=x(),d.events.push(["exit",_,d]),_}function L(H,_){q(H,_.from)}function I(H,_){_.restore()}function G(H,_){return ie;function ie(Y,W,U){let D,K,ee,v;return Array.isArray(Y)?ve(Y):"tokenize"in Y?ve([Y]):Ne(Y);function Ne(me){return le;function le(We){const Ue=We!==null&&me[We],Fe=We!==null&&me.null,rt=[...Array.isArray(Ue)?Ue:Ue?[Ue]:[],...Array.isArray(Fe)?Fe:Fe?[Fe]:[]];return ve(rt)(We)}}function ve(me){return D=me,K=0,me.length===0?U:N(me[K])}function N(me){return le;function le(We){return v=P(),ee=me,me.partial||(d.currentConstruct=me),me.name&&d.parser.constructs.disable.null.includes(me.name)?Ee():me.tokenize.call(_?Object.assign(Object.create(d),_):d,u,de,Ee)(We)}}function de(me){return H(ee,v),W}function Ee(me){return v.restore(),++K<D.length?N(D[K]):U}}}function q(H,_){H.resolveAll&&!o.includes(H)&&o.push(H),H.resolve&&gn(d.events,_,d.events.length-_,H.resolve(d.events.slice(_),d)),H.resolveTo&&(d.events=H.resolveTo(d.events,d))}function P(){const H=x(),_=d.previous,ie=d.currentConstruct,Y=d.events.length,W=Array.from(c);return{from:Y,restore:U};function U(){r=H,d.previous=_,d.currentConstruct=ie,d.events.length=Y,c=W,T()}}function T(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function sC(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,o)];else{if(a=e.slice(n,i),r>-1){const c=a[0];typeof c=="string"?a[0]=c.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function iC(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const o=e[n];let a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=`
|
|
@@ -68,7 +68,7 @@ endobj
|
|
|
68
68
|
`;d.push(C),p+=new TextEncoder().encode(C).length}const m=p,g=["xref",`0 ${u+1}`,"0000000000 65535 f "];for(let x=1;x<h.length;x+=1){const S=h[x];typeof S=="number"&&g.push(`${String(S).padStart(10,"0")} 00000 n `)}return d.push(`${g.join(`
|
|
69
69
|
`)}
|
|
70
70
|
`),d.push(["trailer",`<< /Size ${u+1} /Root 1 0 R >>`,"startxref",String(m),"%%EOF"].join(`
|
|
71
|
-
`)),new TextEncoder().encode(d.join(""))}const sp=48;function OE(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function Vu(e,t){const n=OE(e)||t,r=n.length>sp?n.slice(0,sp).trimEnd():n;return{fullTitle:n,displayTitle:r}}function Zo(e,t){return(t??"").localeCompare(e??"")}function ip(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function ea(e){return(e==null?void 0:e.trim())??""}function oo(e,t,n){if(n==="updatedAt"){const a=Zo(e.updatedAt,t.updatedAt);if(a!==0)return a}if(n==="title"){const a=ip(ea(e.title),ea(t.title));if(a!==0)return a}else{const a=Zo(e.createdAt,t.createdAt);if(a!==0)return a}const r=Zo(e.updatedAt,t.updatedAt);if(r!==0)return r;const i=Zo(e.createdAt,t.createdAt);if(i!==0)return i;const o=ip(ea(e.title),ea(t.title));return o!==0?o:e.sessionId.localeCompare(t.sessionId)}function mo(e,t){return[...e].sort((n,r)=>oo(n,r,t))}function Ku(e,t){return Array.isArray(e)?e.map(n=>({...n,sessions:mo(n.sessions,t),children:Ku(n.children,t)})):[]}const Zl=5,ec=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function WE(e){const t=Math.round(e.ratio*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}function FE(e,t){const n=e.reduce((c,u)=>c+u.count,0);if(n<=0)return[];const i=e.slice(0,Zl).map((c,u)=>({...c,key:c.type,ratio:c.count/n,color:ec[u]??ec[0]})),o=e.slice(Zl);if(o.length===0)return i;const a=o.reduce((c,u)=>c+u.count,0);return i.push({key:"other",type:t,count:a,ratio:a/n,color:ec[Zl]}),i}function $E(e){if(e.length===0)return"conic-gradient(color-mix(in srgb, var(--border-primary) 78%, transparent) 0% 100%)";let t=0;return`conic-gradient(${e.map((r,i)=>{const o=t,a=i===e.length-1?1:Math.min(1,t+r.ratio);return t=a,`${r.color} ${op(o)} ${op(a)}`}).join(", ")})`}function zE(e){return{"--workbench-manage-chart-background":$E(e)}}function op(e){const t=Math.round(e*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}const HE=8,UE=12,qE=160,ap=96;function GE(e,t,n,r={}){const i=r.gapPx??HE,o=r.viewportMarginPx??UE,a=r.defaultWidthPx??qE,c=r.estimatedHeightPx??ap,u=r.minHeightPx??ap,d=Math.max(0,n.width),h=Math.max(0,n.height),p=Math.max(0,h-o*2),m=Math.max(0,d-o*2),g=ta(Math.max(t.width||a,a),0,m),x=Math.max(t.height||c,c),S=Math.max(0,d-e.x-o),C=Math.max(0,e.x-o),y=S<g&&C>S,A=Math.max(0,h-e.y-i-o),j=Math.max(0,e.y-i-o),V=A<x&&j>A,I=ta(Math.max(V?j:A,u),0,p),G=Math.min(x,I),q=y?e.x-g:e.x,P=Math.max(o,d-o-g),T=V?e.y-i-G:e.y+i,H=Math.max(o,h-o-G),_=ta(q,o,P),ie=ta(T,o,H),Y=y||_<e.x?"right":"left";return{top:ie,left:_,width:g,maxHeight:Math.max(0,I),transformOrigin:`${V?"bottom":"top"} ${Y}`}}function ta(e,t,n){return!Number.isFinite(e)||n<t?t:Math.min(Math.max(e,t),n)}const ob="workbench.navigation.snapshot",ab=1800*1e3,VE="workbench.navigation.snapshot.host.";function lb(e){return`${VE}${e}`}function KE(e=ab,t=Wa(Bn.getState())){if(t){const n=wa(lb(t),e);if(n)return n}return wa(ob,e)}function na(e,t=Wa(Bn.getState())){qi(ob,e),t&&qi(lb(t),e)}function lp(e,t="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(n=>({workspace:n.workspace,sessions:mo(n.sessions,t),childWorktrees:YE(n.childWorktrees,t)}))}function YE(e,t){return Ku(e,t)}function Ba(e){return{workspaceId:e.id,tone:"root",backgroundColor:e.backgroundColor??null,displayName:e.name,workspaceName:e.name,branchName:null,depth:0,rootWorkspaceId:e.id,rootDisplayName:e.name,parentWorkspaceId:null,parentDisplayName:null}}function XE(e){const t=new Map;for(const n of e)t.set(n.workspace.id,Ba(n.workspace)),cb(t,n.childWorktrees??[],n.workspace,n.workspace);return Object.fromEntries(t)}function cr(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function cb(e,t,n,r,i=r.name){var o;for(const a of t){const c=((o=a.meta.displayName)==null?void 0:o.trim())||a.workspace.name;e.set(a.workspace.id,{workspaceId:a.workspace.id,tone:"worktree",backgroundColor:a.workspace.backgroundColor??null,displayName:c,workspaceName:a.workspace.name,branchName:a.meta.branchName||null,depth:a.meta.depth,rootWorkspaceId:n.id,rootDisplayName:n.name,parentWorkspaceId:a.meta.parentWorkspaceId||r.id,parentDisplayName:i}),cb(e,a.children,n,a.workspace,c)}}class Uc extends Error{constructor(t,n){super(n),this.code=t,this.name="HostSwitchError"}}class JE{constructor(){Ke(this,"inFlight",null)}async switchHost(t){this.inFlight&&await this.inFlight;const n=this.performSwitch(t).finally(()=>{this.inFlight===n&&(this.inFlight=null)});this.inFlight=n,await n}async performSwitch(t){const n=Bn.getState();if(Wa(n)===t)return;const r=lk(n,t);if(!r)throw new Uc("HOST_NOT_FOUND",`找不到 HOST:${t}`);if(!(await ck(r.baseUrl)).reachable)throw new Uc("HOST_UNREACHABLE",`目标 HOST 不可达:${r.baseUrl}`);const o=cf(r.id);if(o)try{await Ji.loginForHost(r,{username:o.username,password:o.password})}catch{}const a=Bn.getState(),c=new Date().toISOString();if(uf(r)){Bn.updateRuntime({discoveredHosts:a.discoveredHosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeDiscoveredHostId:t});return}dc.setActiveDiscoveredHost(null),await Bn.update({hosts:a.hosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeHostId:t})}}const QE=new JE,ZE=1700;function eM({open:e,id:t,role:n="dialog",labelledBy:r,className:i,anchorRef:o,popoverRef:a,children:c,maxWidth:u=360,gap:d=10,viewportPadding:h=16}){const[p,m]=f.useState(null);if(f.useEffect(()=>{if(!e||typeof window>"u"||typeof document>"u"){m(null);return}let x=0;const S=()=>{const y=o.current;if(!y)return;const A=y.getBoundingClientRect(),j=Math.max(180,Math.min(u,window.innerWidth-h*2)),V=Math.min(Math.max(h,A.right-j),Math.max(h,window.innerWidth-h-j)),L=A.top>=Math.min(240,window.innerHeight*.42),I=Math.round(L?A.top-d:A.bottom+d);m({top:I,left:Math.round(V),width:j,placeAbove:L})},C=()=>{window.cancelAnimationFrame(x),x=window.requestAnimationFrame(S)};return S(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.cancelAnimationFrame(x),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[o,d,u,e,h]),!e||!p||typeof document>"u")return null;const g={position:"fixed",top:p.top,left:p.left,width:p.width,maxWidth:`calc(100vw - ${h*2}px)`,zIndex:ZE,transform:p.placeAbove?"translateY(-100%)":void 0};return ur.createPortal(s.jsx("div",{id:t,ref:a,role:n,"aria-labelledby":r,className:i,"data-placement":p.placeAbove?"top":"bottom",style:g,children:c}),document.body)}const tc={status:"idle",latencyMs:null};function ub({collapsed:e=!1}){const[t,n]=f.useState(!1),[r,i]=f.useState(!1),[o,a]=f.useState(""),[c,u]=f.useState(""),[d,h]=f.useState(""),[p,m]=f.useState(""),[g,x]=f.useState(null),[S,C]=f.useState(null),[y,A]=f.useState(null),[j,V]=f.useState(!1),[L,I]=f.useState(!1),[G,q]=f.useState(tc),[P,T]=f.useState(null),H=f.useRef(null),_=f.useRef(null),ie=f.useRef(null),Y=f.useRef(null),W=eu(F=>F),U=Qc(F=>F.session),{showToast:D}=Wn(),K=hc(W),ee=Wa(W),v=yk(),Ne=uk(ee),ve=f.useMemo(()=>cp(W.hosts,ee),[ee,W.hosts]),N=f.useMemo(()=>cp(df(W),ee),[ee,W]),de=f.useCallback(()=>{if(typeof window>"u")return;const F=H.current;if(!F)return;const ne=F.getBoundingClientRect(),re=window.innerWidth,Se=window.innerHeight,ke=16,pe=8,Xe=Math.min(320,Math.max(240,re-ke*2)),st=Math.min(e?Math.max(ke,ne.right+pe):Math.max(ke,ne.left),Math.max(ke,re-Xe-ke)),E=r?440:240,$=e?ne.top:ne.bottom+pe,se=Math.min(Math.max(ke,$),Math.max(ke,Se-E-ke));T({position:"fixed",top:se,left:st,width:Xe,maxWidth:re-ke*2})},[e,r]);f.useEffect(()=>{if(!t){T(null),V(!1),q(tc);return}dc.refresh();function F(re){var Se,ke,pe;re.target instanceof Node&&!((Se=H.current)!=null&&Se.contains(re.target))&&!((ke=_.current)!=null&&ke.contains(re.target))&&!((pe=Y.current)!=null&&pe.contains(re.target))&&(n(!1),i(!1),V(!1),A(null))}function ne(re){re.key==="Escape"&&(n(!1),i(!1),V(!1),A(null))}return window.addEventListener("pointerdown",F),window.addEventListener("keydown",ne),window.addEventListener("resize",de),window.addEventListener("scroll",de,!0),de(),()=>{window.removeEventListener("pointerdown",F),window.removeEventListener("keydown",ne),window.removeEventListener("resize",de),window.removeEventListener("scroll",de,!0)}},[t,de]),f.useEffect(()=>{if(!j||!t||(v==null?void 0:v.kind)!=="relay"){q(tc);return}let F=!1;const ne=performance.now();return q({status:"probing",latencyMs:null}),xe.request("/api/client/runtime-config").then(()=>{F||q({status:"ready",latencyMs:performance.now()-ne})}).catch(()=>{F||q({status:"error",latencyMs:null})}),()=>{F=!0}},[v==null?void 0:v.kind,j,t]);async function Ee(F){if(g||S||F.id===ee){n(!1);return}x(F.id);try{await QE.switchHost(F.id),n(!1),i(!1),V(!1),A(null)}catch(ne){D({title:iM(ne,F.name),tone:"error"})}finally{x(null)}}async function me(F){if(!(F.id===ee||g||S)){if(y!==F.id){A(F.id);return}C(F.id);try{await Bn.update({hosts:W.hosts.filter(ne=>ne.id!==F.id)}),dk(F.id),Ji.clearHostSession(F.id),A(null),D({title:l("shell.hostDeleteSuccess",{name:F.name})})}catch{D({title:l("shell.hostDeleteFailed",{name:F.name}),tone:"error"})}finally{C(null)}}}async function le(){if(L)return;const F=o.trim(),ne=d.trim();if((ne.length>0||p.length>0)&&(!ne||!p)){D({title:l("shell.hostAddIncompleteCredentials"),tone:"error"});return}let Se;try{Se=hk(c)}catch{D({title:l("shell.hostAddInvalidUrl"),tone:"error"});return}I(!0);try{const ke=await Vk(Se),pe=Bn.getState(),xt=hc(pe);if(ke?pe.hosts.find(se=>{var ue;return se.baseUrl===Se||!!ke.bindingId&&((ue=se.relayTunnel)==null?void 0:ue.bindingId)===ke.bindingId}):pe.hosts.find(se=>se.baseUrl===Se)){D({title:l("shell.hostAddDuplicate"),tone:"error"});return}const st=uf(xt)&&xt.baseUrl===Se;st&&dc.setActiveDiscoveredHost(null);let E,$;if(ke){const ue=(await Bn.update(Kk(pe,ke,{activate:st,displayName:F}))).hosts.find(we=>rM(we,Se,ke.bindingId??null));if(!ue)throw new Error("relay entry host missing after save");E=ue.id,$=ue.name}else{const se=new Date().toISOString(),ue={id:sM(),name:F||tM(Se),baseUrl:Se,kind:nM(Se),createdAt:se,updatedAt:se,lastConnectedAt:null,lastUserId:null,lastUsername:null};await Bn.update({hosts:[...pe.hosts,ue],activeHostId:st?ue.id:pe.activeHostId}),E=ue.id,$=ue.name}ne&&p&&pk({hostId:E,username:ne,password:p}),We(),i(!1),A(null),D({title:l("shell.hostAddSuccess",{name:$})})}catch{D({title:l("shell.hostAddFailed"),tone:"error"})}finally{I(!1)}}function We(){a(""),u(""),h(""),m("")}if(!K)return null;const Ue=U!=null&&U.user.username?`${K.baseUrl} · ${U.user.username}`:K.baseUrl,Fe=(v==null?void 0:v.kind)==="relay"?l("shell.hostSwitcherDetailStatusRelay"):l("shell.hostSwitcherDetailStatusDirect"),rt=v?l(wk(v.kind)):l("common.unknown");return s.jsxs("div",{ref:H,className:"workbench-host-switcher-anchor","data-collapsed":e,children:[s.jsx("button",{type:"button",className:e?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.hostSwitcherAriaLabel"),title:Ue,"aria-expanded":t,onClick:()=>{n(F=>!F),i(!1)},children:s.jsx(lM,{})}),t&&P&&typeof document<"u"?ur.createPortal(s.jsxs("div",{ref:_,className:"workbench-host-switcher-menu",style:P,role:"menu","aria-label":l("shell.hostSwitcherTitle"),children:[s.jsx("div",{className:"workbench-host-switcher-menu-header",children:s.jsx("strong",{children:l("shell.hostSwitcherTitle")})}),s.jsxs("div",{className:"workbench-host-switcher-list",children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherSavedSection")}),ve.map(F=>{const ne=F.id===ee,re=ne?(U==null?void 0:U.user.username)??F.lastUsername??F.baseUrl:F.lastUsername??F.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":ne,children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:g!==null||S!==null,onClick:()=>{Ee(F)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[F.name,ne?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:re})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:g===F.id?l("shell.hostSwitcherSwitching"):ne?s.jsx(dp,{}):s.jsx(up,{})})]}),ne?s.jsx("button",{ref:ie,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:F.name}),"aria-expanded":j,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{V(Se=>!Se),A(null)},children:l("shell.hostSwitcherDetailAction")}):s.jsx("button",{type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostDeleteAriaLabel",{name:F.name}),title:y===F.id?l("shell.hostDeleteConfirmAction"):l("shell.hostDeleteAction"),"data-confirming":y===F.id,disabled:g!==null||S!==null,onClick:()=>{me(F)},children:S===F.id?l("shell.hostDeleteBusy"):y===F.id?l("shell.hostDeleteConfirmAction"):s.jsx(uM,{})})]},F.id)}),N.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherDiscoveredSection")}),N.map(F=>{const ne=F.id===ee,re=cf(F.id),Se=ne?(U==null?void 0:U.user.username)??(re==null?void 0:re.username)??F.baseUrl:(re==null?void 0:re.username)??F.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":ne,"data-discovered":"true",children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:g!==null||S!==null,onClick:()=>{Ee(F)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[F.name,s.jsx("span",{className:"workbench-host-switcher-item-badge","data-tone":"discovered",children:l("shell.hostSwitcherDiscoveredBadge")}),ne?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:Se})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:g===F.id?l("shell.hostSwitcherSwitching"):ne?s.jsx(dp,{}):s.jsx(up,{})})]}),ne?s.jsx("button",{ref:ie,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:F.name}),"aria-expanded":j,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{V(ke=>!ke),A(null)},children:l("shell.hostSwitcherDetailAction")}):null]},F.id)})]}):null,W.localHostDiscovery.status==="refreshing"?s.jsx("div",{className:"workbench-host-switcher-state-row",children:l("shell.hostDiscoveryRefreshing")}):null,W.localHostDiscovery.status==="failed"?s.jsx("div",{className:"workbench-host-switcher-state-row","data-tone":"error",children:l("shell.hostDiscoveryFailed")}):null]}),r?s.jsxs("div",{className:"workbench-host-switcher-form",children:[s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("shell.hostSwitcherNameLabel")}),s.jsx("input",{value:o,disabled:L,onChange:F=>a(F.target.value),placeholder:l("shell.hostSwitcherNamePlaceholder")})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("shell.hostSwitcherUrlLabel")}),s.jsx("input",{value:c,disabled:L,onChange:F=>u(F.target.value),placeholder:l("shell.hostSwitcherUrlPlaceholder")})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("auth.username")}),s.jsx("input",{value:d,disabled:L,onChange:F=>h(F.target.value),autoComplete:"username"})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("auth.password")}),s.jsx("input",{type:"password",value:p,disabled:L,onChange:F=>m(F.target.value),autoComplete:"current-password"})]}),s.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:L,onClick:()=>{i(!1),We()},children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:L,onClick:()=>{le()},children:L?l("common.loading"):l("shell.hostSwitcherSaveAction")})]})]}):s.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{i(!0),A(null)},children:[s.jsx(cM,{}),l("shell.hostSwitcherAddAction")]}),s.jsxs(eM,{open:j&&v!==null&&ie.current!==null,className:"workbench-host-switcher-detail-popover",anchorRef:ie,popoverRef:Y,labelledBy:"workbench-host-switcher-detail-title",children:[s.jsx("div",{className:"workbench-host-switcher-detail-header",children:s.jsx("strong",{id:"workbench-host-switcher-detail-title",children:l("shell.hostSwitcherDetailTitle")})}),s.jsxs("div",{className:"workbench-host-switcher-detail-grid",children:[s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailStatusLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:Fe})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailRouteLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:rt})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailAddressLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value","data-multiline":"true",children:(v==null?void 0:v.url)??K.baseUrl})]}),(v==null?void 0:v.kind)==="relay"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailLatencyLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:oM(G)})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailTrafficLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:aM(Ne.totalBytes)})]})]}):null]})]})]}),document.body):null]})}function cp(e,t){return[...e].sort((n,r)=>{if(n.id===t)return-1;if(r.id===t)return 1;const i=n.lastConnectedAt??n.updatedAt??n.createdAt;return(r.lastConnectedAt??r.updatedAt??r.createdAt).localeCompare(i)})}function tM(e){try{const t=new URL(e),n=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${n}`}catch{return e}}function nM(e){try{const t=new URL(e).hostname.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"?"local":/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[0-1])\./.test(t)?"lan":"remote"}catch{return"custom"}}function rM(e,t,n){var r;return!!(e.baseUrl===t||n&&((r=e.relayTunnel)==null?void 0:r.bindingId)===n)}function sM(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function iM(e,t){return e instanceof Uc?e.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:t}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function oM(e){return e.status==="probing"?l("shell.hostSwitcherDetailLatencyLoading"):e.status==="error"?l("shell.hostSwitcherDetailUnavailable"):e.status==="ready"?`${Math.max(1,Math.round(e.latencyMs))} ms`:l("shell.hostSwitcherDetailUnavailable")}function aM(e){return!Number.isFinite(e)||e<1024?`${Math.max(0,Math.round(e))} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function lM(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"4",y:"4.5",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("rect",{x:"4",y:"13",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("path",{d:"M11 7.75h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),s.jsx("path",{d:"M11 16.25h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),s.jsx("circle",{cx:"7.5",cy:"7.75",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"7.5",cy:"16.25",r:"1",fill:"currentColor",stroke:"none"})]})}function up(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function dp(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function cM(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M8 3.5v9M3.5 8h9",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function uM(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 4.5h9M6.5 2.75h3M5 4.5v7.25a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1V4.5M6.75 6.5v4M9.25 6.5v4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.35"})})}const ra={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function dM({open:e,onClose:t,onCloned:n}){const{showToast:r}=Wn(),[i,o]=f.useState(!1),[a,c]=f.useState(ra),[u,d]=f.useState(!1),[h,p]=f.useState(!1),[m,g]=f.useState(null),[x,S]=f.useState(""),[C,y]=f.useState(""),[A,j]=f.useState(null),[V,L]=f.useState([]),[I,G]=f.useState([]),q=i||h;f.useEffect(()=>{!e&&!i&&(c(ra),d(!1),g(null))},[i,e]);const P=f.useCallback(async U=>{p(!0),g(null);try{const D=await ff(U);S(D.currentPath),y(D.currentPath),j(D.parentPath),L(D.roots),G(D.items),c(K=>({...K,parentPath:D.currentPath}))}catch(D){S(""),j(null),G([]),g(D instanceof Error?D.message:l("shell.importBrowserBrowseFailed"))}finally{p(!1)}},[]);function T(){i||(d(!1),g(null),c(ra),t())}function H(){d(!0),P(a.parentPath||void 0)}function _(){i||(d(!1),g(null))}async function ie(U){U.preventDefault(),await P(C)}function Y(){c(U=>({...U,parentPath:x})),d(!1),g(null)}async function W(U){U.preventDefault();const D=a.repositoryUrl.trim(),K=a.parentPath.trim();if(!D){r({title:l("shell.cloneRepoRequired"),tone:"error"});return}if(!K){r({title:l("shell.clonePathRequired"),tone:"error"});return}o(!0);try{const ee=await vk({repositoryUrl:D,parentPath:K,directoryName:a.directoryName.trim()||void 0,name:a.name.trim()||void 0,auth:a.authMode==="none"?{mode:"none"}:a.authMode==="basic"?{mode:"basic",username:a.username.trim(),password:a.password}:{mode:"token",username:a.username.trim()||void 0,token:a.token}});await(n==null?void 0:n(ee)),c(ra),d(!1),r({title:l("shell.cloneSuccess"),description:ee.path,tone:"success"}),t()}catch(ee){r({title:ee instanceof Error?ee.message:l("shell.cloneFailed"),tone:"error"})}finally{o(!1)}}return s.jsxs(s.Fragment,{children:[s.jsx(Et,{open:e,title:l("shell.cloneWorkspaceTitle"),description:l("shell.cloneWorkspaceHint"),onClose:T,children:s.jsxs("form",{className:"workbench-clone-form",onSubmit:U=>void W(U),children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneRepositoryLabel")}),s.jsx("input",{type:"text",value:a.repositoryUrl,placeholder:l("shell.cloneRepositoryPlaceholder"),onChange:U=>c(D=>({...D,repositoryUrl:U.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneParentPathLabel")}),s.jsxs("div",{className:"workbench-modal-inline-field",children:[s.jsx("input",{type:"text",value:a.parentPath,placeholder:l("shell.cloneParentPathPlaceholder"),onChange:U=>c(D=>({...D,parentPath:U.target.value}))}),s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:H,children:l("shell.clonePickDirectory")})]})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneDirectoryNameLabel")}),s.jsx("input",{type:"text",value:a.directoryName,placeholder:l("shell.cloneDirectoryNamePlaceholder"),onChange:U=>c(D=>({...D,directoryName:U.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importNameLabel")}),s.jsx("input",{type:"text",value:a.name,placeholder:l("shell.importNamePlaceholder"),onChange:U=>c(D=>({...D,name:U.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneAuthModeLabel")}),s.jsxs("select",{value:a.authMode,onChange:U=>c(D=>({...D,authMode:U.target.value})),children:[s.jsx("option",{value:"none",children:l("shell.cloneAuthModeNone")}),s.jsx("option",{value:"basic",children:l("shell.cloneAuthModeBasic")}),s.jsx("option",{value:"token",children:l("shell.cloneAuthModeToken")})]})]}),a.authMode==="basic"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneUsernameLabel")}),s.jsx("input",{type:"text",value:a.username,placeholder:l("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:U=>c(D=>({...D,username:U.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.clonePasswordLabel")}),s.jsx("input",{type:"password",value:a.password,placeholder:l("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:U=>c(D=>({...D,password:U.target.value}))})]})]}):null,a.authMode==="token"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneUsernameLabel")}),s.jsx("input",{type:"text",value:a.username,placeholder:l("shell.cloneTokenUsernamePlaceholder"),onChange:U=>c(D=>({...D,username:U.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneTokenLabel")}),s.jsx("input",{type:"password",value:a.token,placeholder:l("shell.cloneTokenPlaceholder"),onChange:U=>c(D=>({...D,token:U.target.value}))})]})]}):null,s.jsx("p",{className:"workbench-import-hint",children:l("shell.cloneHint")}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:T,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:i,children:i?l("shell.cloneSubmitting"):l("shell.cloneSubmit")})]})]})}),s.jsxs(Et,{open:e&&u,title:l("shell.cloneBrowserTitle"),description:l("shell.cloneBrowserDescription"),onClose:_,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ie,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:C,placeholder:l("shell.importPathPlaceholder"),onChange:U=>y(U.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:q||!A,onClick:()=>{A&&P(A)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:q,children:l("shell.importBrowserOpenPath")})]})]}),s.jsxs("section",{className:"workbench-directory-browser-panel",children:[s.jsxs("div",{className:"workbench-directory-browser-section",children:[s.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),s.jsx("div",{className:"workbench-directory-browser-root-list",children:V.map(U=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:q,onClick:()=>{P(U.path)},children:U.name},U.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:x}),m?s.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:m}):null,h?s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):I.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:I.map(U=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:q,onClick:()=>{P(U.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:U.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:U.path})]},U.path))}):s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:_,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:q||!x,onClick:Y,children:l("shell.cloneBrowserSubmit")})]})]})]})}const hM="butler:inbox-updated";function nc(){typeof window>"u"||window.dispatchEvent(new Event(hM))}const hp={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function db({active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,compactComposer:o=!1,composerOpen:a=!0,onComposerOpenChange:c}){const{showToast:u}=Wn(),[d,h]=f.useState(!1),[p,m]=f.useState(!1),[g,x]=f.useState([]),[S,C]=f.useState([]),[y,A]=f.useState(null),[j,V]=f.useState(null),[L,I]=f.useState(hp),[G,q]=f.useState(!1),P=f.useMemo(()=>fp(g,t,j),[j,t,g]),T=f.useMemo(()=>G?S:S.filter(D=>D.status!=="closed"),[S,G]);f.useEffect(()=>{e&&H()},[e,n]),f.useEffect(()=>{!e||y||I(D=>{const K=gp({projects:P,currentProjectId:D.projectId,preferredProjectId:j,preferredWorkspaceId:t});return K===D.projectId?D:{...D,projectId:K}})},[e,y,j,t,P]),f.useEffect(()=>{!e||r<=0||(_(void 0,t,i,j),c==null||c(!0))},[e,r,i,c,j,t]);async function H(){h(!0);try{const[D,K,ee]=await Promise.all([ej(),cg(),n?aj(n).catch(()=>null):Promise.resolve(null)]),v=(ee==null?void 0:ee.target.project.id)??null;V(v),x(D.items),C(K.items),y||_(D.items,t,r>0?i:null,v)}catch(D){u({title:l("shell.butlerInboxLoadFailed"),description:D instanceof Error?D.message:void 0,tone:"error"})}finally{h(!1)}}function _(D=g,K=t,ee=i,v=j){var ve,N;const Ne=fp(D,K,v);A(null),I({...hp,projectId:gp({projects:Ne,preferredProjectId:v,preferredWorkspaceId:K}),title:((ve=ee==null?void 0:ee.title)==null?void 0:ve.trim())??"",content:((N=ee==null?void 0:ee.content)==null?void 0:N.trim())??""})}function ie(D){A(D.id),I({projectId:D.projectId,itemType:D.itemType,title:D.title,content:D.content,status:D.status}),o&&(c==null||c(!0))}async function Y(D){D.preventDefault(),m(!0);try{y?(await jh(y,{projectId:L.projectId,itemType:L.itemType,title:L.title,content:L.content,status:L.status,priority:"medium"}),u({title:l("shell.butlerInboxUpdated"),tone:"success"})):(await tj({projectId:L.projectId,itemType:L.itemType,title:L.title,content:L.content,status:L.status,priority:"medium"}),u({title:l("shell.butlerInboxCreated"),tone:"success"})),nc(),await H(),_(),o&&(c==null||c(!1))}catch(K){u({title:l("shell.butlerInboxSaveFailed"),description:K instanceof Error?K.message:void 0,tone:"error"})}finally{m(!1)}}async function W(D){m(!0);try{await sj(D),u({title:l("shell.butlerInboxDeleted"),tone:"success"}),nc(),await H(),y===D&&_()}catch(K){u({title:l("shell.butlerInboxDeleteFailed"),description:K instanceof Error?K.message:void 0,tone:"error"})}finally{m(!1)}}async function U(D,K){if(D.status!==K){m(!0);try{await jh(D.id,{status:K}),u({title:l("shell.butlerInboxUpdated"),tone:"success"}),nc(),await H(),y===D.id&&I(ee=>({...ee,status:K}))}catch(ee){u({title:l("shell.butlerInboxSaveFailed"),description:ee instanceof Error?ee.message:void 0,tone:"error"})}finally{m(!1)}}}return s.jsxs("div",{className:"workspace-inbox-modal",children:[o?null:s.jsx("section",{className:"workspace-inbox-panel",children:s.jsx(pp,{selectableProjects:P,formState:L,saving:p,editingItemId:y,useMobilePicker:!1,onProjectChange:D=>{I(K=>({...K,projectId:D}))},onItemTypeChange:D=>{I(K=>({...K,itemType:D}))},onStatusChange:D=>{I(K=>({...K,status:D}))},onTitleChange:D=>{I(K=>({...K,title:D}))},onContentChange:D=>{I(K=>({...K,content:D}))},onCancel:()=>_(),onSubmit:Y})}),s.jsxs("section",{className:"workspace-inbox-panel",children:[s.jsxs("header",{className:"workspace-inbox-panel-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:l("shell.butlerInboxListTitle")}),s.jsx("p",{children:l("shell.butlerInboxListDescription")})]}),s.jsxs("label",{className:"workspace-inbox-closed-toggle",children:[s.jsx("input",{type:"checkbox",checked:G,onChange:D=>q(D.target.checked)}),s.jsx("span",{children:l("shell.butlerInboxShowClosedAction")})]})]}),d?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxLoading")}):null,!d&&T.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxEmpty")}):null,!d&&T.length>0?s.jsx("div",{className:"workspace-inbox-list",children:T.map(D=>s.jsxs("article",{className:"workspace-inbox-item",children:[s.jsxs("div",{className:"workspace-inbox-item-header",children:[s.jsxs("div",{children:[s.jsx("strong",{children:D.title}),s.jsx("p",{children:D.projectName})]}),s.jsxs("div",{className:"workspace-inbox-item-badges",children:[s.jsx("span",{className:"workspace-inbox-badge",children:bp(D.status)}),s.jsx("span",{className:"workspace-inbox-badge",children:bM(D.itemType)})]})]}),s.jsx("p",{className:"workspace-inbox-item-content",children:D.content}),s.jsxs("div",{className:"workspace-inbox-item-footer",children:[s.jsx("span",{children:kM(D.updatedAt)}),s.jsxs("div",{className:"workspace-inbox-item-actions",children:[s.jsx("div",{className:"workspace-inbox-status-quick-actions",role:"group","aria-label":l("shell.butlerInboxQuickStatusLabel"),children:["pending","in_progress","closed"].map(K=>{const ee=D.status===K;return s.jsx("button",{type:"button",className:"secondary-button","data-active":ee,disabled:p,onClick:()=>{U(D,K)},children:bp(K)},`${D.id}:${K}`)})}),s.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>ie(D),children:l("shell.butlerInboxEditAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{W(D.id)},children:l("shell.butlerInboxDeleteAction")})]})]})]},D.id))}):null]}),o?s.jsx(Et,{open:e&&a,title:y?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle"),description:l("shell.butlerInboxFormDescription"),className:"workspace-inbox-modal-card workspace-inbox-composer-modal-card",onClose:()=>{c==null||c(!1),_()},children:s.jsx("div",{className:"workspace-inbox-composer-modal-body",children:s.jsx(pp,{selectableProjects:P,formState:L,saving:p,editingItemId:y,useMobilePicker:!0,onProjectChange:D=>{I(K=>({...K,projectId:D}))},onItemTypeChange:D=>{I(K=>({...K,itemType:D}))},onStatusChange:D=>{I(K=>({...K,status:D}))},onTitleChange:D=>{I(K=>({...K,title:D}))},onContentChange:D=>{I(K=>({...K,content:D}))},onCancel:()=>{c==null||c(!1),_()},onSubmit:Y})})}):null]})}function pp(e){const t=e.selectableProjects.map(i=>({value:i.id,label:i.name})),n=[{value:"task",label:l("shell.butlerInboxTypeTask")},{value:"bug",label:l("shell.butlerInboxTypeBug")},{value:"feature",label:l("shell.butlerInboxTypeFeature")},{value:"change",label:l("shell.butlerInboxTypeChange")}],r=[{value:"pending",label:l("shell.butlerInboxStatusPending")},{value:"in_progress",label:l("shell.butlerInboxStatusInProgress")},{value:"closed",label:l("shell.butlerInboxStatusClosed")}];return s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"workspace-inbox-panel-header",children:[s.jsx("h3",{children:e.editingItemId?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle")}),s.jsx("p",{children:l("shell.butlerInboxFormDescription")})]}),e.selectableProjects.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxProjectsEmpty")}):s.jsxs("form",{className:"workspace-inbox-form",onSubmit:e.onSubmit,children:[s.jsx("div",{className:"workspace-inbox-form-grid",children:e.useMobilePicker?s.jsxs(s.Fragment,{children:[s.jsx(rc,{label:l("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:t,disabled:e.saving,onChange:e.onProjectChange}),s.jsx(rc,{label:l("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:n,disabled:e.saving,onChange:e.onItemTypeChange}),s.jsx(rc,{label:l("shell.butlerInboxStatusLabel"),value:e.formState.status,options:r,disabled:e.saving,onChange:e.onStatusChange})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxProjectLabel")}),s.jsx("select",{value:e.formState.projectId,disabled:e.saving,onChange:i=>e.onProjectChange(i.target.value),children:e.selectableProjects.map(i=>s.jsx("option",{value:i.id,children:i.name},i.id))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxTypeLabel")}),s.jsxs("select",{value:e.formState.itemType,disabled:e.saving,onChange:i=>e.onItemTypeChange(i.target.value),children:[s.jsx("option",{value:"task",children:l("shell.butlerInboxTypeTask")}),s.jsx("option",{value:"bug",children:l("shell.butlerInboxTypeBug")}),s.jsx("option",{value:"feature",children:l("shell.butlerInboxTypeFeature")}),s.jsx("option",{value:"change",children:l("shell.butlerInboxTypeChange")})]})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxStatusLabel")}),s.jsxs("select",{value:e.formState.status,disabled:e.saving,onChange:i=>e.onStatusChange(i.target.value),children:[s.jsx("option",{value:"pending",children:l("shell.butlerInboxStatusPending")}),s.jsx("option",{value:"in_progress",children:l("shell.butlerInboxStatusInProgress")}),s.jsx("option",{value:"closed",children:l("shell.butlerInboxStatusClosed")})]})]})]})}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxTitleLabel")}),s.jsx("input",{value:e.formState.title,placeholder:l("shell.butlerInboxTitlePlaceholder"),disabled:e.saving,onChange:i=>e.onTitleChange(i.target.value)})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxContentLabel")}),s.jsx("textarea",{rows:4,value:e.formState.content,placeholder:l("shell.butlerInboxContentPlaceholder"),disabled:e.saving,onChange:i=>e.onContentChange(i.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onCancel,children:e.editingItemId?l("shell.butlerInboxCancelEditAction"):l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:e.saving||!e.formState.projectId,children:e.editingItemId?l("shell.butlerInboxUpdateAction"):l("shell.butlerInboxCreateAction")})]})]})]})}function rc({label:e,value:t,options:n,disabled:r,onChange:i}){const[o,a]=f.useState(!1),c=n.find(u=>u.value===t)??n[0]??null;return f.useEffect(()=>{if(!o)return;function u(d){d.key==="Escape"&&a(!1)}return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[o]),s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-modal-field workspace-inbox-mobile-picker",children:[s.jsx("span",{children:e}),s.jsxs("button",{type:"button",className:"workspace-inbox-mobile-picker-trigger","aria-label":e,"aria-haspopup":"dialog","aria-expanded":o,disabled:r||n.length===0,onClick:()=>a(!0),children:[s.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-value",children:(c==null?void 0:c.label)??""}),s.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-icon",children:s.jsx(mM,{expanded:o})})]})]}),s.jsx(pM,{open:o,title:e,options:n,selectedValue:t,onClose:()=>a(!1),onSelect:u=>{i(u),a(!1)}})]})}function pM({open:e,title:t,options:n,selectedValue:r,onClose:i,onSelect:o}){return e?s.jsx(Sk,{open:e,title:t,kind:"picker",height:"half",className:"workspace-inbox-picker-sheet",cardClassName:"workspace-inbox-picker-sheet-card",bodyClassName:"workspace-inbox-picker-sheet-body",showHandle:!0,onClose:i,children:s.jsx(ru,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":t,children:n.map(a=>{const c=a.value===r;return s.jsx(pn,{as:"button",className:"workspace-inbox-picker-option",role:"option","aria-selected":c,selected:c,trailing:s.jsx("span",{className:"workspace-inbox-picker-option-indicator","aria-hidden":"true",children:c?s.jsx(gM,{}):null}),onClick:()=>o(a.value),children:s.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[s.jsx("strong",{children:a.label}),a.description?s.jsx("span",{children:a.description}):null]})},a.value)})})}):null}function eL({open:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,onClose:o,compactComposer:a=!1}){const[c,u]=f.useState(0),[d,h]=f.useState(!a);return f.useEffect(()=>{e||h(!a)},[a,e]),s.jsx(Et,{open:e,title:l("shell.butlerInboxModalTitle"),description:l("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!a,headerActions:a?s.jsx("button",{type:"button",className:"workspace-inbox-modal-create-button","aria-label":l("shell.butlerInboxCreateAction"),title:l("shell.butlerInboxCreateAction"),onClick:()=>{u(p=>p+1),h(!0)},children:s.jsx(fM,{})}):void 0,onClose:o,children:s.jsx(db,{active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:Math.max(r,c),initialDraft:i,compactComposer:a,composerOpen:d,onComposerOpenChange:h})})}function fp(e,t,n){return[...e].filter(r=>r.lifecycleStatus!=="archived").sort((r,i)=>{const o=mp(r,t,n),a=mp(i,t,n);return o!==a?a-o:r.name.localeCompare(i.name,"zh-Hans-CN")})}function mp(e,t,n){return n&&e.id===n?2:t&&e.workspaceId===t?1:0}function gp({projects:e,currentProjectId:t,preferredProjectId:n,preferredWorkspaceId:r}){var o;if(t&&e.some(a=>a.id===t))return t;if(n&&e.some(a=>a.id===n))return n;const i=r?e.find(a=>a.workspaceId===r):null;return(i==null?void 0:i.id)||((o=e[0])==null?void 0:o.id)||""}function fM(){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"M12 5v14"}),s.jsx("path",{d:"M5 12h14"})]})}function mM({expanded:e}){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true","data-expanded":e?"true":void 0,children:s.jsx("path",{d:"M3.5 6 8 10l4.5-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function gM(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 8.4 6.6 11.5 12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function bM(e){switch(e){case"bug":return l("shell.butlerInboxTypeBug");case"feature":return l("shell.butlerInboxTypeFeature");case"change":return l("shell.butlerInboxTypeChange");case"task":default:return l("shell.butlerInboxTypeTask")}}function bp(e){switch(e){case"in_progress":return l("shell.butlerInboxStatusInProgress");case"closed":return l("shell.butlerInboxStatusClosed");case"pending":default:return l("shell.butlerInboxStatusPending")}}function kM(e){return new Date(e).toLocaleString()}function xM({open:e,onClose:t,onImported:n}){const{showToast:r}=Wn(),[i,o]=f.useState(!1),[a,c]=f.useState(!1),[u,d]=f.useState(!1),[h,p]=f.useState(null),[m,g]=f.useState(""),[x,S]=f.useState(""),[C,y]=f.useState(null),[A,j]=f.useState([]),[V,L]=f.useState([]),[I,G]=f.useState(!1),[q,P]=f.useState(""),T=i||a||u,H=f.useCallback(async K=>{o(!0),p(null);try{const ee=await ff(K);g(ee.currentPath),S(ee.currentPath),y(ee.parentPath),j(ee.roots),L(ee.items)}catch(ee){g(""),y(null),L([]),p(ee instanceof Error?ee.message:l("shell.importBrowserBrowseFailed"))}finally{o(!1)}},[]);f.useEffect(()=>{if(!e){G(!1),P(""),p(null);return}H(m||void 0)},[H,e]);function _(){T||(G(!1),P(""),t())}async function ie(K){K.preventDefault(),await H(x)}function Y(){!m||T||(P(""),G(!0))}function W(){a||(G(!1),P(""))}async function U(K){K==null||K.preventDefault();const ee=q.trim();if(!(!m||!ee||T)){c(!0),p(null);try{const v=await Nk({parentPath:m,directoryName:ee});r({title:l("shell.importBrowserCreateDirectorySuccess"),description:v.path,tone:"success"}),G(!1),P(""),await H(v.path)}catch(v){const Ne=v instanceof Error?v.message:l("shell.importBrowserCreateDirectoryFailed");p(Ne),r({title:Ne,tone:"error"})}finally{c(!1)}}}async function D(){const K=m.trim();if(!(!K||T)){d(!0),p(null);try{const ee=await Ck({path:K});r({title:l("shell.importSuccess"),description:ee.path,tone:"success"}),t(),Promise.resolve().then(()=>n==null?void 0:n(ee)).catch(v=>{r({title:v instanceof Error?v.message:l("shell.navigationLoadFailed"),tone:"error"})})}catch(ee){r({title:ee instanceof Error?ee.message:l("shell.importFailed"),tone:"error"})}finally{d(!1)}}}return s.jsxs(s.Fragment,{children:[s.jsxs(Et,{open:e,title:l("shell.importBrowserTitle"),description:l("shell.importBrowserDescription"),onClose:_,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ie,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:x,placeholder:l("shell.importPathPlaceholder"),onChange:K=>S(K.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:T||!C,onClick:()=>{C&&H(C)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:T,children:l("shell.importBrowserOpenPath")}),s.jsx("button",{type:"button",className:"secondary-button",disabled:T||!m,onClick:Y,children:l("shell.importBrowserCreateDirectory")})]})]}),s.jsxs("section",{className:"workbench-directory-browser-panel",children:[s.jsxs("div",{className:"workbench-directory-browser-section",children:[s.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),s.jsx("div",{className:"workbench-directory-browser-root-list",children:A.map(K=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:T,onClick:()=>{H(K.path)},children:K.name},K.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:m}),h?s.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:h}):null,i?s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):V.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:V.map(K=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:T,onClick:()=>{H(K.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:K.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:K.path})]},K.path))}):s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:T,onClick:_,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:T||!m,onClick:()=>{D()},children:u?l("shell.importSubmitting"):l("shell.importBrowserSubmit")})]})]}),s.jsx(Et,{open:e&&I,title:l("shell.importBrowserCreateDirectoryTitle"),description:l("shell.importBrowserCreateDirectoryDescription"),onClose:W,children:s.jsxs("form",{className:"workbench-rename-form",onSubmit:K=>void U(K),children:[s.jsx("div",{className:"workbench-directory-browser-current-path",children:m}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCreateDirectoryLabel")}),s.jsx("input",{type:"text",value:q,placeholder:l("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:K=>P(K.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:a,onClick:W,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:a||!q.trim(),children:a?l("shell.importBrowserCreatingDirectory"):l("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function yM({onOpenSoftwareUpdate:e}){var r;const t=eu(i=>i.platform),n=mk(i=>i.latestState);return t!=="desktop"||!(n!=null&&n.hasUpdate)?null:s.jsx("button",{className:"workbench-nav-update-badge",type:"button",title:((r=n.manifest)==null?void 0:r.version)??l("settings.releaseUpdateReady"),onClick:e,children:s.jsx("span",{className:"workbench-nav-update-badge-label",children:l("settings.releaseUpdateBadge")})})}function wM(){const e=fk.getState().profile.defaultPermissionMode;return e==="default"?null:e}const Hi="provider-default",ba="__global_default__";function vM(e){switch(e){case"claude-code":case"codex":case"gemini":return e;default:return null}}function sa(e,t){const n=(t==null?void 0:t.trim())||null;return e==="cc-switch-preset"&&n?{providerConfigMode:"cc-switch-preset",providerPresetId:n}:{providerConfigMode:"global-default",providerPresetId:null}}function SM(e){const t=e!=null&&e.currentPresetName?e.currentModel?`${e.currentPresetName} · ${e.currentModel}`:e.currentPresetName:null;return[{value:ba,label:l("conversation.deploymentDefaultPreset"),summary:t},...((e==null?void 0:e.options)??[]).map(n=>({value:n.id,label:n.name,summary:n.model??n.summary??null}))]}function CM(e){return e.usesProviderDefault===!0||e.id===Hi}function NM(e){return e?e.cliAvailable===!0&&e.status!=="unavailable"&&e.options.length>1:!0}function jM({triggerId:e,ariaLabel:t,triggerLabel:n,presetOptions:r,selectedPresetValue:i,selectedPresetSummary:o,onSelectPreset:a,modelOptions:c,selectedModelValue:u,onSelectModel:d,loadingPresets:h=!1,loadingModels:p=!1,modelColumnDisabled:m=!1,showPresetColumn:g=!0,modelEmptyText:x}){const[S,C]=f.useState(!1),y=f.useRef(null),A=f.useRef(null),j=f.useRef(null),[V,L]=f.useState(null),I=f.useId(),G=f.useCallback(()=>{const q=A.current;if(!q||typeof window>"u")return;const P=q.getBoundingClientRect(),T=q.closest(".workbench-modal-card"),H=T instanceof HTMLElement?T.getBoundingClientRect():null,_=window.innerWidth,ie=window.innerHeight,Y=12,W=8,U=320,D=Math.min(560,Math.max(320,_-Y*2)),K=Math.min(D,420),ee=Math.max(Math.min(D,Math.max(K,Math.round(P.width*1.9))),Math.min(320,D)),v=Math.min(Math.max(Y,P.left),Math.max(Y,_-ee-Y)),Ne=H?Math.max(Y,H.top+8):Y,ve=H?Math.min(ie-Y,H.bottom-8):ie-Y,N=Math.max(0,P.top-Ne-W),de=Math.max(0,ve-P.bottom-W),Ee=H?!(de>=U||de>N+40):N>=240||N>=de;L({position:"fixed",left:v,width:ee,maxWidth:D,zIndex:1905,top:Ee?void 0:P.bottom+W,bottom:Ee?ie-P.top+W:void 0})},[]);return f.useEffect(()=>{if(!S)return;function q(T){var _,ie;const H=T.target;!((_=y.current)!=null&&_.contains(H))&&!((ie=j.current)!=null&&ie.contains(H))&&C(!1)}function P(T){T.key==="Escape"&&C(!1)}return window.addEventListener("pointerdown",q),window.addEventListener("keydown",P),window.addEventListener("resize",G),window.addEventListener("scroll",G,!0),G(),()=>{window.removeEventListener("pointerdown",q),window.removeEventListener("keydown",P),window.removeEventListener("resize",G),window.removeEventListener("scroll",G,!0)}},[S,G]),s.jsxs("div",{ref:y,className:"composer-mac-select composer-deployment-select","data-open":S?"true":"false",children:[s.jsxs("button",{id:e,ref:A,type:"button",className:"composer-mac-select-trigger composer-deployment-select-trigger","aria-label":t,"aria-haspopup":"dialog","aria-expanded":S,"aria-controls":I,onClick:()=>C(q=>!q),children:[s.jsx("span",{className:"composer-mac-select-label composer-deployment-select-label",children:n}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),S&&V&&typeof document<"u"?ur.createPortal(s.jsx("div",{ref:j,className:"composer-mac-select-popover composer-deployment-select-popover",style:V,role:"presentation",children:s.jsxs("div",{id:I,className:`composer-deployment-select-panel${g?"":" is-model-only"}`,role:"dialog","aria-label":t,children:[g?s.jsxs("div",{className:"composer-deployment-select-column",children:[s.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentConfigColumn")}),s.jsxs("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentConfigColumn"),children:[r.map(q=>{const P=q.value===i;return s.jsxs("button",{type:"button",role:"option","aria-selected":P,className:`composer-deployment-select-option ${P?"is-selected":""}`,onClick:()=>a(q.value),children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:P?"✓":""}),s.jsxs("span",{className:"composer-deployment-select-option-copy",children:[s.jsx("span",{className:"composer-deployment-select-option-label",children:q.label}),q.summary?s.jsx("span",{className:"composer-deployment-select-option-summary",children:q.summary}):null]})]},q.value)}),h?s.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentLoading")}):null]})]}):null,s.jsxs("div",{className:"composer-deployment-select-column","data-disabled":m?"true":"false",children:[s.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentModelColumn")}),g&&o?s.jsx("div",{className:"composer-deployment-select-column-hint",children:o}):null,s.jsx("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentModelColumn"),children:p&&m?s.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentModelLoading")}):c.length>0?c.map(q=>{const P=q.value===u;return s.jsxs("button",{type:"button",role:"option","aria-selected":P,className:`composer-deployment-select-option ${P?"is-selected":""}`,disabled:m,onClick:()=>{d(q.value),C(!1)},children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:P?"✓":""}),s.jsx("span",{className:"composer-deployment-select-option-copy",children:s.jsx("span",{className:"composer-deployment-select-option-label",children:q.label})})]},q.value)}):s.jsx("div",{className:"composer-deployment-select-state",children:x})})]})]})}),document.body):null]})}const hb=144,TM=196,IM=124,EM=72;let kp=null;function MM(e,t){if(typeof document>"u")return t.length*8;kp??(kp=document.createElement("canvas"));const n=kp.getContext("2d");if(!n)return t.length*8;const r=window.getComputedStyle(e),i=r.fontStyle||"normal",o=r.fontWeight||"600",a=r.fontSize||"13px",c=r.fontFamily||"system-ui";return n.font=`${i} ${o} ${a} ${c}`,n.measureText(t).width}function RM({labels:e,triggerWidth:t,maxWidth:n,preferredWidth:r,measureText:i}){const o=e.reduce((a,c)=>Math.max(a,Math.ceil(i(c)+EM)),0);return Math.min(n,Math.max(t,hb,r,o))}function xp({triggerId:e,ariaLabel:t,value:n,options:r,onChange:i,disabled:o=!1,compact:a=!1,className:c}){const[u,d]=f.useState(!1),h=f.useRef(null),p=f.useRef(null),m=f.useRef(null),[g,x]=f.useState(null),S=f.useId(),C=r.find(j=>j.value===n)??r[0]??null,y=f.useMemo(()=>r.map(j=>j.label),[r]),A=f.useCallback(()=>{const j=p.current;if(!j||typeof window>"u")return;const V=j.getBoundingClientRect(),L=window.innerWidth,I=window.innerHeight,G=12,q=10,P=Math.max(hb,L-G*2),T=a?IM:TM,H=RM({labels:y,triggerWidth:V.width,maxWidth:P,preferredWidth:T,measureText:U=>MM(j,U)}),_=Math.min(Math.max(G,V.left),Math.max(G,L-H-G)),ie=V.top-G,Y=I-V.bottom-G,W=ie>=180||ie>=Y;x({position:"fixed",left:_,width:H,maxWidth:P,zIndex:1905,top:W?void 0:V.bottom+q,bottom:W?I-V.top+q:void 0})},[a,y]);return f.useEffect(()=>{if(!u)return;function j(L){var G,q;const I=L.target;!((G=h.current)!=null&&G.contains(I))&&!((q=m.current)!=null&&q.contains(I))&&d(!1)}function V(L){L.key==="Escape"&&d(!1)}return window.addEventListener("pointerdown",j),window.addEventListener("keydown",V),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),A(),()=>{window.removeEventListener("pointerdown",j),window.removeEventListener("keydown",V),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[u,A]),C?s.jsxs("div",{ref:h,className:`composer-mac-select ${a?"is-compact":""}${c?` ${c}`:""}`,"data-open":u?"true":"false",children:[s.jsxs("button",{id:e,ref:p,type:"button",className:"composer-mac-select-trigger","aria-label":t,"aria-haspopup":"listbox","aria-expanded":u,"aria-controls":S,disabled:o,onClick:()=>d(j=>!j),children:[s.jsx("span",{className:"composer-mac-select-label",children:C.label}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),u&&g&&typeof document<"u"?ur.createPortal(s.jsx("div",{ref:m,className:"composer-mac-select-popover",style:g,role:"presentation",children:s.jsx("div",{id:S,className:"composer-mac-select-list",role:"listbox","aria-label":t,children:r.map(j=>{const V=j.value===n;return s.jsxs("button",{type:"button",role:"option","aria-selected":V,className:`composer-mac-select-option ${V?"is-selected":""}`,onClick:()=>{i(j.value),d(!1)},children:[s.jsx("span",{className:"composer-mac-select-option-check","aria-hidden":"true",children:V?"✓":""}),s.jsx("span",{className:"composer-mac-select-option-label",children:j.label})]},j.value)})})}),document.body):null]}):null}const ia=["codex","claude-code","gemini"];function pb(e){return{provider:e,model:"",providerConfigMode:"global-default",providerPresetId:null,memberPrompt:"",workspaceIsolationMode:"none"}}function yp(e,t){return Array.from({length:t},()=>pb(e))}function sc(e,t){var n;return(n=e==null?void 0:e.modelOptions)!=null&&n.length?e.modelOptions:su(t).modelOptions??[]}function wp(e,t,n){return t!=="cc-switch-preset"||!n?null:`${e}::${n}`}function vp(e,t){return Math.max(0,e-t.length)}function AM({open:e,source:t,onClose:n,onCreated:r}){const i=f.useId(),o=(t==null?void 0:t.defaultProvider)??"codex",a=(t==null?void 0:t.kind)==="group",c=(t==null?void 0:t.kind)==="group"?Math.max(0,4-t.currentMemberCount):4,u=f.useMemo(()=>(t==null?void 0:t.kind)==="group"?Array.from({length:c},(E,$)=>$+1):[2,3,4],[c,t==null?void 0:t.kind]),d=(t==null?void 0:t.kind)==="group"?1:2,h=(t==null?void 0:t.kind)==="group"?t.sharedPrompt:"",{visibleProviders:p}=jk(Mk,e),[m,g]=f.useState(h),[x,S]=f.useState(d),[C,y]=f.useState(()=>yp(o,d)),[A,j]=f.useState({}),[V,L]=f.useState({}),[I,G]=f.useState({}),[q,P]=f.useState({}),[T,H]=f.useState({}),[_,ie]=f.useState(!1),[Y,W]=f.useState(!1),[U,D]=f.useState(null),[K,ee]=f.useState(null),[v,Ne]=f.useState({}),ve=f.useRef(!1),N=f.useRef({});f.useEffect(()=>{if(!e)return;const E=(t==null?void 0:t.defaultProvider)??"codex",$=(t==null?void 0:t.kind)==="group"?1:2;g((t==null?void 0:t.kind)==="group"?t.sharedPrompt:""),S($),y(yp(E,$)),j({}),L({}),G({}),P({}),H({}),ie(!1),W(!1),D(null),ee(null),Ne({}),ve.current=!1,Object.keys(N.current).forEach(se=>{delete N.current[se]})},[e,t==null?void 0:t.defaultProvider,t==null?void 0:t.kind,t==null?void 0:t.workspaceId,(t==null?void 0:t.kind)==="session"?t.sessionId:null,(t==null?void 0:t.kind)==="group"?t.groupId:null,(t==null?void 0:t.kind)==="group"?t.sharedPrompt:null]),f.useEffect(()=>{y(E=>{var ue;if(E.length===x)return E;if(E.length>x)return E.slice(0,x);const $=E.slice(),se=((ue=E[0])==null?void 0:ue.provider)??o;for(;$.length<x;)$.push(pb(se));return $})},[o,x]),f.useEffect(()=>{u.length!==0&&S(E=>u.includes(E)?E:u[0]??E)},[u]),f.useEffect(()=>{if(!e||!t)return;let E=!1;return ie(!0),Tk(p,t.workspaceId).then($=>{E||j($)}).finally(()=>{E||ie(!1)}),()=>{E=!0}},[e,t==null?void 0:t.workspaceId,p]),f.useEffect(()=>{e&&(ve.current||(ve.current=!0,G(E=>({...E,...Object.fromEntries(ia.map($=>[$,!0]))})),Ik().then(E=>{const $=Object.fromEntries(E.items.map(se=>[se.app,se]));L(Object.fromEntries(ia.map(se=>[se,$[se]??null])))}).catch(()=>{L(Object.fromEntries(ia.map(E=>[E,null])))}).finally(()=>{G(E=>({...E,...Object.fromEntries(ia.map($=>[$,!1]))}))})))},[e]),f.useEffect(()=>{if(!e||!t)return;const E=Array.from(new Set(C.map($=>{const se=sa($.providerConfigMode,$.providerPresetId);return wp($.provider,se.providerConfigMode,se.providerPresetId)}).filter($=>$!==null))).filter($=>q[$]===void 0&&!N.current[$]);if(E.length!==0)for(const $ of E){const[se,ue]=$.split("::");N.current[$]=!0,H(we=>({...we,[$]:!0})),mf(se,t.workspaceId,{providerConfigMode:"cc-switch-preset",providerPresetId:ue}).then(we=>{P(z=>({...z,[$]:we}))}).catch(()=>{P(we=>({...we,[$]:null}))}).finally(()=>{delete N.current[$],H(we=>({...we,[$]:!1}))})}},[q,C,e,t]);const de=f.useMemo(()=>p.filter(E=>{const $=A[E];return $?$.canStartSession!==!1:!1}),[A,p]);f.useEffect(()=>{if(!de.length)return;const E=de.includes(o)?o:de[0];y($=>{let se=!1;const ue=$.map(we=>de.includes(we.provider)?we:(se=!0,{...we,provider:E,providerConfigMode:"global-default",providerPresetId:null,model:""}));return se?ue:$})},[de,o]);const Ee=f.useMemo(()=>C.map((E,$)=>{var qe;const se=sa(E.providerConfigMode,E.providerPresetId),ue=vM(E.provider),we=ue?V[ue]??null:null,z=SM(we),X=se.providerConfigMode==="cc-switch-preset"?se.providerPresetId??ba:ba,ge=z.find(ft=>ft.value===X)??z[0]??null,ye=wp(E.provider,se.providerConfigMode,se.providerPresetId),De=A[E.provider]??null,He=ye?q[ye]??null:null,lt=(se.providerConfigMode==="cc-switch-preset"?He?sc(He,E.provider):[{id:Hi,name:l("conversation.modelUseCliDefault"),usesProviderDefault:!0}]:sc(De,E.provider)).map(ft=>({value:ft.id,label:CM(ft)?l("conversation.modelUseCliDefault"):ft.name})),Ve=E.model.trim()||Hi,tt=((qe=lt.find(ft=>ft.value===Ve))==null?void 0:qe.label)??l("conversation.modelUseCliDefault"),Je=NM(we),nt=ue!==null,pt=ye?T[ye]===!0:!1,Ft=!!(ye&&pt&&He===null);return{index:$,draft:E,supportsDeploymentPicker:nt,showPresetColumn:Je,deploymentPresetOptions:z,selectedPresetValue:X,selectedPresetOption:ge,triggerLabel:Je?`${(ge==null?void 0:ge.label)??l("conversation.deploymentDefaultPreset")} · ${tt}`:tt,selectedModelValue:Ve,modelOptions:lt,loadingPresets:ue?I[ue]===!0:!1,loadingModels:pt,modelColumnDisabled:Ft}}),[q,V,I,T,C,A]);if(f.useEffect(()=>{e&&y(E=>{let $=!1;const se=E.map((ue,we)=>{const z=Ee[we];if(!z)return ue;let X=ue;const ge=sa(ue.providerConfigMode,ue.providerPresetId);ge.providerConfigMode==="cc-switch-preset"&&ge.providerPresetId&&!z.loadingPresets&&!z.deploymentPresetOptions.some(He=>He.value===ge.providerPresetId)&&(X={...X,providerConfigMode:"global-default",providerPresetId:null,model:""},$=!0);const ye=new Set(z.modelOptions.map(He=>He.value)),De=X.model.trim()||Hi;return ye.has(De)||(X={...X,model:""},$=!0),X});return $?se:E})},[Ee,e]),!e||!t)return null;const me=t,le=K?vp(C.length,K.memberFailures):0,We=new Set(K?C.map((E,$)=>$).filter(E=>!(E in v)):[]),Ue=me.kind==="group"?l("shell.parallelAppendModalTitle"):l("shell.parallelCreateModalTitle"),Fe=me.kind==="session"?`${me.workspaceName} · ${me.sessionTitle}`:me.workspaceName,rt=me.kind==="group"?l("shell.parallelAppendSharedPromptLabel"):l("shell.parallelCreateSharedPromptLabel"),F=me.kind==="group"?l("shell.parallelAppendCountLabel"):l("shell.parallelCreateCountLabel"),ne=me.kind==="group"?l("shell.parallelAppendSubmit"):l("shell.parallelCreateSubmit"),re=me.kind==="group"?l("shell.parallelAppendSubmitting"):l("shell.parallelCreateSubmitting"),Se=U??(me.kind==="group"&&c===0?l("shell.parallelAppendNoRemainingSlots"):null)??(!_&&de.length===0?l("shell.parallelCreateNoAvailableProviders"):null),ke={"--parallel-member-columns":String(Math.max(1,Math.min(x,4)))};function pe(E){D(null),ee(null),Ne($=>{if(!(E in $))return $;const se={...$};return delete se[E],se})}function xt(){D(null),ee(null),Ne({})}function Xe(E,$){pe(E);const se=$?"temporary_worktree":"none";y(ue=>ue.map((we,z)=>z===E?{...we,workspaceIsolationMode:se}:we))}async function st(){const E=m.trim();if(!a&&!E){D(l("shell.parallelCreatePromptRequired"));return}if(me.kind==="group"&&c===0){D(l("shell.parallelAppendNoRemainingSlots"));return}if(!de.length){D(l("shell.parallelCreateNoAvailableProviders"));return}W(!0),D(null),ee(null),Ne({});try{const $=wM(),se=C.map(we=>{const z=sa(we.providerConfigMode,we.providerPresetId);return{provider:we.provider,model:we.model.trim()||null,providerConfigMode:z.providerConfigMode,providerPresetId:z.providerConfigMode==="cc-switch-preset"?z.providerPresetId:null,memberPrompt:we.memberPrompt.trim()||null,workspaceIsolationMode:we.workspaceIsolationMode}}),ue=me.kind==="group"?await Rk(me.groupId,{permissionMode:$,members:se}):me.kind==="session"?await Ak(me.sessionId,{sharedPrompt:E,permissionMode:$,members:se}):await Pk(me.workspaceId,{sharedPrompt:E,permissionMode:$,members:se});if(ue.memberFailures.length>0){const we=vp(C.length,ue.memberFailures);ee(ue),Ne(Object.fromEntries(ue.memberFailures.map(z=>[z.ordinal,z]))),D(we>0?l("shell.parallelCreatePartialFailure",{successCount:we,failureCount:ue.memberFailures.length}):l("shell.parallelCreateAllFailed",{failureCount:ue.memberFailures.length}));return}await r(ue)}catch($){D($ instanceof Error?$.message:l("shell.parallelGroupLoadFailed"))}finally{W(!1)}}return s.jsx(iu,{open:e,title:Ue,description:Fe,size:"xwide",layout:"form",className:"parallel-create-modal",bodyClassName:"parallel-create-modal-body",dismissible:!Y,onClose:n,footer:s.jsxs(Ek,{align:"between",className:"parallel-create-modal-footer",children:[s.jsx("div",{className:"parallel-create-modal-status",role:"status","aria-live":"polite",children:Se?s.jsx("span",{className:"parallel-create-modal-error",children:Se}):null}),s.jsxs("div",{className:"parallel-create-modal-footer-actions",children:[K&&le>0?s.jsx("button",{type:"button",className:"secondary-button",disabled:Y,onClick:()=>{r(K)},children:l("shell.parallelCreateContinuePartial")}):null,s.jsx("button",{type:"button",className:"secondary-button",disabled:Y,onClick:n,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:Y||_||de.length===0||me.kind==="group"&&c===0,onClick:()=>{st()},children:Y?re:ne})]})]}),children:s.jsxs("div",{className:"parallel-create-layout",children:[s.jsx(Ys,{className:"parallel-create-shared-section",tone:"accent",children:s.jsxs("div",{className:"parallel-create-target-row",children:[s.jsx(Hs,{className:"parallel-create-target-field",label:rt,htmlFor:`${i}-shared-prompt`,children:s.jsx("textarea",{id:`${i}-shared-prompt`,className:"parallel-create-textarea parallel-create-textarea-target",rows:2,value:m,readOnly:a,"aria-readonly":a,"data-readonly":a?"true":void 0,onChange:E=>{a||(xt(),g(E.target.value))}})}),s.jsx(Hs,{className:"parallel-create-count-field",label:F,children:s.jsx("div",{className:"parallel-create-count-group",role:"group","aria-label":F,children:u.map(E=>s.jsx("button",{type:"button",className:"parallel-create-count-button","data-active":x===E,onClick:()=>{xt(),S(E)},children:E},E))})})]})}),s.jsx(Ys,{className:"parallel-create-members-section",heading:l("shell.parallelCreateMembersTitle"),children:s.jsx("div",{className:"parallel-create-member-list",style:ke,children:Ee.map(({draft:E,index:$,supportsDeploymentPicker:se,showPresetColumn:ue,deploymentPresetOptions:we,selectedPresetValue:z,selectedPresetOption:X,triggerLabel:ge,selectedModelValue:ye,modelOptions:De,loadingPresets:He,loadingModels:yt,modelColumnDisabled:lt})=>{var Ft;const Ve=de,tt=Ve.includes(E.provider)?E.provider:"",Je=Ve.length>0?Ve.map(qe=>({value:qe,label:pc(qe,"full")})):[{value:"",label:_?l("shell.parallelCreateProvidersLoading"):l("shell.parallelCreateNoAvailableProviders")}],nt=sc(A[E.provider]??null,E.provider),pt=nt.length>0?[{value:"",label:((Ft=nt.find(qe=>qe.usesProviderDefault===!0))==null?void 0:Ft.name)??l("shell.parallelPaneModelFallback")},...nt.filter(qe=>qe.usesProviderDefault!==!0).map(qe=>({value:qe.id,label:qe.name}))]:[{value:"",label:l("shell.parallelCreateNoModelsAvailable")}];return s.jsxs("article",{className:"parallel-create-member-card","data-state":v[$]?"error":We.has($)?"success":void 0,children:[s.jsxs("header",{className:"parallel-create-member-header",children:[s.jsxs("div",{className:"parallel-create-member-title-block",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberTitle",{index:$+1})}),s.jsx("span",{className:"parallel-create-member-provider",children:pc(E.provider,"full")}),s.jsxs("label",{className:"parallel-create-isolation-toggle",children:[s.jsx("input",{type:"checkbox",checked:E.workspaceIsolationMode==="temporary_worktree",onChange:qe=>{Xe($,qe.target.checked)}}),s.jsx("span",{className:"parallel-create-isolation-copy",children:l("shell.parallelCreateIsolationLabel")})]})]}),v[$]?s.jsx("span",{className:"parallel-create-member-status error",children:l("shell.parallelCreateMemberFailed")}):We.has($)?s.jsx("span",{className:"parallel-create-member-status success",children:l("shell.parallelCreateMemberSucceeded")}):null]}),s.jsxs("div",{className:"parallel-create-member-grid",children:[s.jsx(Hs,{label:l("shell.createSessionProviderLabel"),htmlFor:`${i}-member-${$}-provider`,children:s.jsx(xp,{triggerId:`${i}-member-${$}-provider`,className:"parallel-create-provider-select",ariaLabel:l("shell.createSessionProviderLabel"),value:tt,options:Je,disabled:!Ve.length,onChange:qe=>{pe($);const ft=qe;y(_e=>_e.map((Nt,Qe)=>Qe===$?{...Nt,provider:ft,providerConfigMode:"global-default",providerPresetId:null,model:""}:Nt))}})}),s.jsx(Hs,{label:l("shell.parallelCreateModelLabel"),htmlFor:se?void 0:`${i}-member-${$}-model`,children:se?s.jsx("div",{className:"parallel-create-deployment-select",children:s.jsx(jM,{triggerId:`${i}-member-${$}-model`,ariaLabel:l("shell.parallelCreateModelLabel"),triggerLabel:ge,presetOptions:we,selectedPresetValue:z,selectedPresetSummary:(X==null?void 0:X.summary)??null,onSelectPreset:qe=>{pe($),y(ft=>ft.map((_e,Nt)=>Nt!==$?_e:qe===ba?{..._e,providerConfigMode:"global-default",providerPresetId:null,model:""}:{..._e,providerConfigMode:"cc-switch-preset",providerPresetId:qe,model:""}))},modelOptions:De,selectedModelValue:ye,onSelectModel:qe=>{pe($),y(ft=>ft.map((_e,Nt)=>Nt===$?{..._e,model:qe===Hi?"":qe}:_e))},loadingPresets:He,loadingModels:yt,modelColumnDisabled:lt,showPresetColumn:ue,modelEmptyText:l("conversation.deploymentModelEmpty")})}):s.jsx(xp,{triggerId:`${i}-member-${$}-model`,className:"parallel-create-provider-select",ariaLabel:l("shell.parallelCreateModelLabel"),value:E.model,options:pt,disabled:!Ve.length||nt.length===0,onChange:qe=>{pe($),y(ft=>ft.map((_e,Nt)=>Nt===$?{..._e,model:qe}:_e))}})})]}),s.jsx(Hs,{label:l("shell.parallelCreateMemberPromptLabel"),htmlFor:`${i}-member-${$}-prompt`,children:s.jsx("textarea",{id:`${i}-member-${$}-prompt`,className:"parallel-create-textarea member",rows:2,value:E.memberPrompt,onChange:qe=>{pe($);const ft=qe.target.value;y(_e=>_e.map((Nt,Qe)=>Qe===$?{...Nt,memberPrompt:ft}:Nt))}})}),v[$]?s.jsxs("div",{className:"parallel-create-member-error",role:"alert",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberErrorTitle")}),s.jsx("p",{children:v[$].detail})]}):null]},`parallel-member-${$}`)})})})]})})}const PM=12,LM=180,Sp=72;function DM(e,t){const[n,r]=f.useState(!1),[i,o]=f.useState(""),[a,c]=f.useState({}),[u,d]=f.useState({}),[h,p]=f.useState(!1),[m,g]=f.useState(null);f.useEffect(()=>{e||(r(!1),o(""),g(null))},[e]),f.useEffect(()=>{if(!e||!n)return;const C=t.filter(A=>u[A.sessionId]!==!0);if(C.length===0)return;let y=!1;return p(!0),g(null),Promise.allSettled(C.map(async A=>{const j=await pf(A.sessionId,null,PM,"backward");return{sessionId:A.sessionId,summary:_M(j.messages)}})).then(A=>{if(y)return;const j={},V={};let L=0;C.forEach(I=>{j[I.sessionId]=!0});for(const I of A){if(I.status==="fulfilled"){V[I.value.sessionId]=I.value.summary;continue}L+=1}d(I=>({...I,...j})),Object.keys(V).length>0&&c(I=>({...I,...V})),g(L>0?l("shell.archiveSearchSummaryFailed"):null)}).finally(()=>{y||p(!1)}),()=>{y=!0}},[u,e,n,t]);const x=f.useMemo(()=>{const C=ic(i);return C?t.filter(y=>ic(y.title).includes(C)?!0:ic(a[y.sessionId]??"").includes(C)):t},[i,t,a]);function S(){r(C=>{const y=!C;return y||(o(""),g(null)),y})}return{searchOpen:n,searchKeyword:i,filteredSessions:x,summaryLoading:h,summaryError:m,summaryBySessionId:a,setSearchKeyword:o,toggleSearch:S}}function _M(e){const t=[...e].sort((r,i)=>r.sequence-i.sequence).map(BM).filter(r=>r.length>0);if(t.length===0)return"";const n=t.slice(-3).join(" · ");return qc(n,LM)}function BM(e){var n,r;const t=fb(e.content);return t.length>0?qc(t,Sp):(r=(n=e.toolCall)==null?void 0:n.name)!=null&&r.trim()?qc(e.toolCall.name.trim(),Sp):""}function ic(e){return fb(e).toLocaleLowerCase()}function fb(e){return e.replace(/\s+/g," ").trim()}function qc(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}const Cp="workbench.left.width",Np="workbench.right.width",jp="workbench.left.collapsed",Tp="workbench.right.collapsed",oa="workbench.last.session.path",oc="workbench.workspace.selected.id",Ip="workbench.notifications.seen_at",OM=280,WM=320,Ep=240,Mp=280,Rp=520,Ap=560,FM=200,ac=20,Bi=40,aa=5,$M=3e4,zM=12,Pp=60*1e3,HM=4e3,Lp=220,Dp=18,UM=6,zs="data-workbench-panel-resizing",la="data-workbench-window-resizing",qM=180,GM="workbench:focus-composer",VM=new Set(["starting","running","reconnecting","stale","unknown"]),KM=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],YM=["--workbench-titlebar-live-content-shift-y","--workbench-nav-toolbar-live-shift-y","--workbench-info-tabs-live-shift-y","--workbench-auxiliary-toolbar-button-live-shift-y","--workbench-conversation-header-main-live-shift-y","--workbench-conversation-header-actions-live-shift-y","--workbench-terminal-tabbar-live-shift-y","--workbench-collapsed-controls-live-shift-y","--workbench-collapsed-left-controls-live-shift-y","--workbench-collapsed-right-controls-live-shift-y"],kt={navToolbar:{selector:".workbench-nav-toolbar",variableName:"--workbench-nav-toolbar-live-shift-y"},infoTabs:{selector:".workbench-info-tabs",variableName:"--workbench-info-tabs-live-shift-y"},auxiliaryToolbarButton:{selector:".workbench-auxiliary-header > .workbench-nav-toolbar-button",variableName:"--workbench-auxiliary-toolbar-button-live-shift-y"},conversationHeaderMain:{selector:".conversation-header-main",variableName:"--workbench-conversation-header-main-live-shift-y"},conversationHeaderActions:{selector:".conversation-header-actions",variableName:"--workbench-conversation-header-actions-live-shift-y"},terminalTabbarMain:{selector:".terminal-tabbar-main",variableName:"--workbench-terminal-tabbar-live-shift-y"},collapsedLeftControls:{selector:'.workbench-collapsed-controls.left[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-left-controls-live-shift-y"},collapsedRightControls:{selector:'.workbench-collapsed-controls.right[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-right-controls-live-shift-y"}};function mb(e,t){const n=e.getPropertyValue(t).trim();if(!n)return null;const r=Number.parseFloat(n);return Number.isFinite(r)?r:null}function XM(e){return Math.round(e*100)/100}function JM(e,t){const n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return null;const r=window.getComputedStyle(t);return r.display==="none"||r.visibility==="hidden"?null:n.top-e.top+n.height/2}function Rr(e,t){const n=e.getBoundingClientRect(),i=Array.from(e.querySelectorAll(t)).map(o=>JM(n,o)).filter(o=>o!==null);return i.length===0?null:i.reduce((o,a)=>o+a,0)/i.length}function Jn(e,t,n){const r=e.style.getPropertyValue(t).trim();if(n===null||!Number.isFinite(n)){r&&e.style.removeProperty(t);return}const i=`${XM(n)}px`;r!==i&&e.style.setProperty(t,i)}function Qn(e,t,n,r){return r===null?null:(mb(e,t)??0)+(n-r)}function _p(e){if(e)for(const t of YM)e.style.removeProperty(t)}function QM(e){return VM.has(e.runningState??"idle")||e.activityState==="running"}function ZM(e,t){const n=[];for(const r of[...t].sort()){const i=e.get(r);!i||i.size===0||n.push(`${r}:${[...i].sort().join(",")}`)}return n.join("|")}function eR(e){var i,o;const t=((i=e.lastErrorCode)==null?void 0:i.trim())??"",n=((o=e.lastErrorDetail)==null?void 0:o.trim())??"",r=[t,n].filter(a=>a.length>0).join(" · ");return r?r.length<=Lp?r:`${r.slice(0,Lp-3)}...`:null}function tR(e,t,n){var o,a,c,u,d,h,p,m,g,x,S,C;const r=new Map(e.projects.map(y=>[y.id,y.workspaceId])),i=[];for(const y of n){const A=y.title.trim()||y.projectName;if(y.assistantState.lifecycleStage==="analyzed"&&!((o=y.assistantState.linkedSessionId)!=null&&o.trim())&&y.assistantState.lastAnalyzedAt){i.push({id:`todo-analysis-completed:${y.id}:${y.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:l("shell.globalNotificationTodoAnalyzedTitle",{title:A}),body:((a=y.assistantState.analysisSummary)==null?void 0:a.trim())||((c=y.assistantState.generatedPrompt)==null?void 0:c.trim())||y.content,routePath:cs(y.workspaceId),workspaceId:y.workspaceId,createdAt:y.assistantState.lastAnalyzedAt});continue}y.assistantState.lifecycleStage==="failed"&&i.push({id:`todo-analysis-failed:${y.id}:${y.updatedAt}`,kind:"todo_analyze_failed",title:l("shell.globalNotificationTodoAnalyzeFailedTitle",{title:A}),body:((u=y.assistantState.lastError)==null?void 0:u.trim())||y.content,routePath:cs(y.workspaceId),workspaceId:y.workspaceId,createdAt:y.updatedAt})}for(const y of t){const A=((d=y.sessionTitle)==null?void 0:d.trim())||y.projectName,j=y.updatedAt||y.lastAutomationAt||y.createdAt;if(y.status==="waiting_user"){i.push({id:`follow-up-waiting:${y.id}`,kind:"follow_up_waiting_user",title:l("shell.globalNotificationFollowUpWaitingTitle",{title:A}),body:((h=y.waitingReason)==null?void 0:h.trim())||((p=y.lastAutomationSummary)==null?void 0:p.trim())||y.objective,routePath:_n(y.workspaceId,y.sessionId),workspaceId:y.workspaceId,createdAt:j});continue}if(y.status==="completed"){i.push({id:`follow-up-completed:${y.id}`,kind:"follow_up_completed",title:l("shell.globalNotificationFollowUpCompletedTitle",{title:A}),body:((m=y.lastAutomationSummary)==null?void 0:m.trim())||y.objective,routePath:_n(y.workspaceId,y.sessionId),workspaceId:y.workspaceId,createdAt:j});continue}y.status==="failed"&&i.push({id:`follow-up-failed:${y.id}`,kind:"follow_up_failed",title:l("shell.globalNotificationFollowUpFailedTitle",{title:A}),body:((g=y.lastAutomationSummary)==null?void 0:g.trim())||((x=y.waitingReason)==null?void 0:x.trim())||y.objective,routePath:_n(y.workspaceId,y.sessionId),workspaceId:y.workspaceId,createdAt:j})}for(const y of e.verifications){if(y.status!=="failed")continue;const A=y.projectId?r.get(y.projectId)??null:null,j=((S=y.targetRef)==null?void 0:S.trim())||y.verificationType;i.push({id:`verification-failed:${y.id}`,kind:"verification_failed",title:l("shell.globalNotificationVerificationFailedTitle",{title:j}),body:((C=y.summary)==null?void 0:C.trim())||l("shell.globalNotificationVerificationFailedFallback"),routePath:A?cs(A):null,workspaceId:A,createdAt:y.finishedAt||y.startedAt||y.createdAt})}return i.sort((y,A)=>{const j=Bp(y.kind)-Bp(A.kind);return j!==0?j:Dr(A.createdAt)-Dr(y.createdAt)}).slice(0,zM)}function Bp(e){switch(e){case"follow_up_waiting_user":return 0;case"todo_analyze_failed":return 1;case"follow_up_failed":return 2;case"verification_failed":return 3;case"todo_analyzed":return 4;case"follow_up_completed":return 5;default:return 9}}function nR(e){switch(e){case"follow_up_waiting_user":return l("shell.globalNotificationKindWaitingUser");case"todo_analyzed":return l("shell.globalNotificationKindTodoAnalyzed");case"todo_analyze_failed":return l("shell.globalNotificationKindTodoAnalyzeFailed");case"follow_up_completed":return l("shell.globalNotificationKindFollowUpCompleted");case"follow_up_failed":return l("shell.globalNotificationKindFollowUpFailed");case"verification_failed":return l("shell.globalNotificationKindVerificationFailed");default:return l("shell.globalNotificationsPanelTitle")}}function Dr(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function rR(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function sR(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function iR(e,t){const n=new Set,r=(e==null?void 0:e.currentBranch)??"",i=((e==null?void 0:e.local)??[]).slice().sort((c,u)=>Number(u.current)-Number(c.current)||c.name.localeCompare(u.name)).map(c=>({value:c.name,current:c.current,recommended:c.name===r})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),o=((e==null?void 0:e.remote)??[]).map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),a=t.map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0));return{localBranches:i,remoteBranches:o,tags:a}}function oR(e){return e.getBoundingClientRect()}function aR(e,t){return t?Dr(e.createdAt)>Dr(t):!0}function lR(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function Op(e,t){var a,c;const n=["/workspaces/:workspaceId","/workspaces/:workspaceId/sessions","/workspaces/:workspaceId/sessions/:sessionId","/workspaces/:workspaceId/tools","/workspaces/:workspaceId/tools/files","/workspaces/:workspaceId/tools/git","/workspaces/:workspaceId/tools/processes","/workspaces/:workspaceId/terminals","/workspaces/:workspaceId/butler"];for(const u of n){const d=at(u,e),h=(a=d==null?void 0:d.params.workspaceId)==null?void 0:a.trim();if(h)return h}const r=Xi(e),i=(r==null?void 0:r.sessionId)??null;return!i||!Vb(i)?null:((c=new URLSearchParams(t).get("workspaceId"))==null?void 0:c.trim())||null}function cR(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function lc(e){return e==="mobile"?Zt():"/landing"}function Xi(e){var o,a,c;const t=at("/workspaces/:workspaceId/sessions/:sessionId",e),n=(o=t==null?void 0:t.params.sessionId)==null?void 0:o.trim();if(n)return{sessionId:n,workspaceId:((a=t==null?void 0:t.params.workspaceId)==null?void 0:a.trim())??null};const r=at("/sessions/:sessionId",e),i=(c=r==null?void 0:r.params.sessionId)==null?void 0:c.trim();return i?{sessionId:i,workspaceId:null}:null}function uR(e){return!!(at("/sessions",e)||at("/workspaces/:workspaceId/sessions",e))}function Wp(e){return!!Xi(e)}function dR(e){return!!(at("/tools",e)||at("/tools/files",e)||at("/tools/git",e)||at("/tools/processes",e)||at("/workspaces/:workspaceId/tools",e)||at("/workspaces/:workspaceId/tools/files",e)||at("/workspaces/:workspaceId/tools/git",e)||at("/workspaces/:workspaceId/tools/processes",e))}function ka(e){return!!(at("/terminals",e)||at("/workspaces/:workspaceId/terminals",e))}function xa(e){return!!at("/workspaces/:workspaceId/butler",e)}function hR(e,t){return at("/workspaces/:workspaceId/debug",e)?Af(t):at("/workspaces/:workspaceId",e)?rr(t):at("/workspaces/:workspaceId/tools/files",e)||at("/tools/files",e)?Lf(t):at("/workspaces/:workspaceId/tools/git",e)||at("/tools/git",e)?Df(t):at("/workspaces/:workspaceId/tools/processes",e)||at("/tools/processes",e)?_f(t):at("/workspaces/:workspaceId/tools",e)||at("/tools",e)?Pf(t):ka(e)?is(t):xa(e)?cs(t):ii(t)}function pR(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const fR=f.lazy(async()=>({default:(await tu(()=>import("./FileContextPanel-CNOjhsi5.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).FileContextPanel})),mR=f.lazy(async()=>({default:(await tu(()=>import("./GitSidebar-DpC4UhFy.js"),__vite__mapDeps([11,1,2,3,4,5,7,6,8,9,10]))).GitSidebar})),gR=f.lazy(async()=>({default:(await tu(()=>import("./TerminalManagerPanel-BEMzisSy.js"),__vite__mapDeps([12,1,2,6,3,4,5,13,14,8,9,10]))).TerminalManagerPanel}));function bR(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function an(e){return ci(e)}function kR(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function Ks(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(bR):[]}async function gb(e,t){const n=await mf(t,e);if(n.canStartSession===!1)throw new Error(n.limitations[0]??l("conversation.capabilityDenied"))}const bb=f.createContext(null);function Oa(e){return xI(e)}function tr(e){return e.isArchived===!0}function go(e){return Tf(e)}function kb(e,t){return uu(e,{getId:n=>n.sessionId,getParentId:go,compare:(n,r)=>oo(n,r,t)})}function xR(e,t){const n=yR(e);return xb(n,t)}function xb(e,t){const n=wR(e);return uu(n,{getId:r=>r.session.sessionId,getParentId:r=>go(r.session),compare:(r,i)=>oo(r.session,i.session,t)}).map(r=>wb(r))}function yR(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...yb(t.childWorktrees)])}function yb(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...yb(t.children)])}function wR(e){const t=[],n=new Set;for(const r of e){const i=r.session.sessionId.trim();!i||n.has(i)||(n.add(i),t.push(r))}return t}function wb(e,t=0){return{item:e.item.session,depth:t,children:e.children.map(n=>wb(n,t+1))}}function Gc(e,t){return{...e,depth:e.depth+t,children:an(e).map(n=>Gc(n,t))}}function Fp(e){return`${e}::parallel-anchor-member`}function $p(e){const{session:t,depth:n,children:r}=e;return{item:t,depth:n,children:[...r]}}function Vc(e,t){for(const n of e){if(n.item.sessionId===t)return n;const r=Vc(an(n),t);if(r)return r}return null}function vR(e,t){const n=t.trim();if(!n)return null;for(const r of e){const i=vb(r,n,null);if(i)return i}return null}function vb(e,t,n){var i,o;const r=((o=(i=e.item.parallelGroup)==null?void 0:i.groupId)==null?void 0:o.trim())||n;if(e.item.sessionId===t)return r;for(const a of an(e)){const c=vb(a,t,r);if(c)return c}return null}function Sb(e){return e.filter(t=>{if(tr(t))return!1;const n=go(t);if(!n)return!0;const r=e.find(i=>i.sessionId===n);return r&&tr(r)?!Oa(t):!0})}function SR(e){return e.flatMap(t=>{const n=kR(t);return n?[n,...Ef(an(t))]:[]})}function CR(e,t,n){var m;const r=an(e),i=ss(r).sort((g,x)=>oo(g.item,x.item,n));if(!(((m=e.item.parallelGroup)==null?void 0:m.role)==="anchor"&&r.some(g=>{var x,S;return((x=g.item.parallelGroup)==null?void 0:x.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}))){const g=new Set(i.slice(0,Math.max(0,t)).map(x=>x.item.sessionId));return{...e,children:Kc(r,g)}}const a=r.slice().sort((g,x)=>oo(g.item,x.item,n)),c=a.filter(g=>{var x,S;return((x=g.item.parallelGroup)==null?void 0:x.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(g=>g.item.sessionId),u=a.filter(g=>{var x,S;return((x=g.item.parallelGroup)==null?void 0:x.groupId)!==((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(g=>g.item.sessionId),d=[...c,...u],h=Math.max(0,t-d.length),p=new Set(d);for(const g of i){if(p.size>=d.length+h)break;p.add(g.item.sessionId)}return{...e,children:Kc(r,p)}}function Kc(e,t){return e.flatMap(n=>{const r=Kc(an(n),t);return!t.has(n.item.sessionId)&&r.length===0?[]:[{...n,children:r}]})}function ca(e,t,n,r=-1){if(e<=0)return 0;const i=r>=0?Math.max(t,r+1):t;return Math.min(e,Math.max(n??0,i))}function zp(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>e[i]===t[i])}function NR(e){const t=e.lastMessageAt??e.updatedAt;return t?new Date(t).toLocaleDateString():""}function Za(e,t="compact"){return pc(e,t)}const jR={position:"relative",zIndex:0},TR={zIndex:1};function Cb(e,t,n,r){const i=[],o=(r==null?void 0:r.trim())||t.name;n&&i.push(o);const a=NR(e);return a&&i.push(a),i.join(" · ")||o}function Hp(e,t){return tT("session-state-indicator",e,t)}function IR(e,t){return Ng(e,t)}function Up(e,t){try{const n=window.localStorage.getItem(e),r=n?Number(n):Number.NaN;return Number.isFinite(r)?r:t}catch{return t}}function qp(e,t){try{const n=window.localStorage.getItem(e);return n===null?t:n==="true"}catch{return t}}function Gp(e){var t;try{const n=(t=window.localStorage.getItem(e))==null?void 0:t.trim();return n||null}catch{return null}}function rs(e,t){try{window.localStorage.setItem(e,t)}catch{}}function ER(e){try{window.localStorage.removeItem(e)}catch{}}function ua(e,t,n){return Math.max(t,Math.min(n,e))}function da(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function MR(e){const t=window.getComputedStyle(e),n=da(t.getPropertyValue("--desktop-macos-titlebar-height")),r=da(t.getPropertyValue("--workbench-header-min-height")),i=da(t.getPropertyValue("--workbench-macos-titlebar-padding-top")),o=da(t.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(n,r,40)+i+o+8}function Vp(e,t){const n=t.getBoundingClientRect();return e>=n.top&&e<=n.top+MR(t)}function RR(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function AR(){typeof window>"u"||window.dispatchEvent(new CustomEvent(GM))}function Nb(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){if(r.workspace.id===n)return r;const i=Nb(r.children,n);if(i)return i}return null}function Kp(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){const i=Nb(r.childWorktrees,n);if(i)return i}return null}function jb(e){return e.flatMap(t=>[t.workspace.id,...jb(t.children)])}function PR(e){return new Set(e.flatMap(t=>[t.workspace.id,...jb(t.childWorktrees)]))}function Yp(e){return!e||!Array.isArray(e.items)?[]:e.items.filter(t=>{var n;return t.collapsed===!0&&((n=t.workspace)==null?void 0:n.id)}).map(t=>t.workspace.id)}function cc(e,t){const n=new Set(t);return{items:e.map(r=>({workspace:r.workspace,sessions:r.sessions,childWorktrees:r.childWorktrees,collapsed:n.has(r.workspace.id)}))}}function Tb(e,t,n,r=new Set){return e.map(i=>{const o=i.sessions.filter(c=>!r.has(c.sessionId)),a=Sb(o);return{workspace:i.workspace,meta:i.meta,visibleSessions:a,archivedSessions:o.filter(c=>tr(c)&&!go(c)),visibleSessionTree:kb(a,n).filter(c=>!t.has(c.item.sessionId)&&!du(an(c),u=>t.has(u.sessionId))),children:Tb(i.children,t,n,r)}})}function Yc(e){return e.flatMap(t=>[t.workspace.id,...Yc(t.children)])}function Ui(e){return e.flatMap(t=>[...t.visibleSessionTree,...Ui(t.children)])}function Ib(e){return e.flatMap(t=>[t,...Ib(t.children)])}function LR(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:Ks(n)};const r=Eb(n.childWorktrees,t);if(r)return r}return null}function Eb(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:n.visibleSessionTree};const r=Eb(n.children,t);if(r)return r}return null}function DR(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=Mb(n.childWorktrees,t);if(r)return r}return null}function uc(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return n.workspace;const r=Rb(n.childWorktrees,t);if(r)return r}return null}function Mb(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=Mb(n.children,t);if(r)return r}return null}function Rb(e,t){for(const n of e){if(n.workspace.id===t)return n.workspace;const r=Rb(n.children,t);if(r)return r}return null}function Ab(e,t){for(const n of e){if(n.workspace.id===t)return[n.workspace.id];const r=Ab(n.children,t);if(r.length>0)return[n.workspace.id,...r]}return[]}function Xp(e){return e.flatMap(t=>[t.workspace.id,...Pb(t.childWorktrees)])}function Pb(e){return e.flatMap(t=>[t.workspace.id,...Pb(t.children)])}function _R(e,t=[]){if(e.tone!=="worktree")return e.rootDisplayName;if(t.length>0)return t.join(" / ");const n=[e.rootDisplayName];return e.parentDisplayName&&e.parentDisplayName!==e.rootDisplayName&&n.push(e.parentDisplayName),n.join(" / ")}function BR(e,t,n,r){if(t===n)return e;const i=e.findIndex(d=>d.workspace.id===t),o=e.findIndex(d=>d.workspace.id===n);if(i<0||o<0)return e;const a=[...e],[c]=a.splice(i,1);if(!c)return e;const u=a.findIndex(d=>d.workspace.id===n);return u<0?e:(a.splice(r==="before"?u:u+1,0,c),a.every((d,h)=>{var p;return d.workspace.id===((p=e[h])==null?void 0:p.workspace.id)})?e:a)}function OR(e,t){if(!Array.isArray(e.items)||t.size===0)return e;let n=!1;const r=e.items.map(i=>{let o=!1;const a=i.sessions.map(u=>{const d=t.get(u.sessionId);return d===void 0||tr(u)===d?u:(n=!0,o=!0,{...u,isArchived:d})}),c=Db(i.childWorktrees??[],t,u=>{u&&(n=!0,o=!0)});return o?{...i,sessions:a,childWorktrees:c}:i});return n?{...e,items:r}:e}function WR(e,t){if(!(!Array.isArray(t.items)||e.size===0))for(const n of t.items){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&tr(r)===i&&e.delete(r.sessionId)}_b(e,n.childWorktrees??[])}}function FR(e,t,n){let r=!1;const i=e.map(o=>{if(o.workspace.id!==t.workspaceId){const{nodes:u,changed:d}=Bb(o.childWorktrees,t,n);return d?(r=!0,{...o,childWorktrees:u}):o}const a=o.sessions.findIndex(u=>u.sessionId===t.sessionId),c=a>=0?o.sessions.map((u,d)=>d===a?t:u):[t,...o.sessions];return r=!0,{...o,sessions:mo(c,n)}});return r?i:e}function $R(e,t,n){let r=!1;const i=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t?d:(r=!0,a=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState})),u=el(o.childWorktrees,d=>d.sessionId!==t?d:(r=!0,a=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?i:e}function Jp(e,t,n){let r=!1;const i=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,a=!0,{...d,isArchived:n})),u=el(o.childWorktrees,d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,a=!0,{...d,isArchived:n}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?i:e}function Qp(e,t,n){let r=!1;const i=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,a=!0,{...d,isFavorite:n})),u=el(o.childWorktrees,d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,a=!0,{...d,isFavorite:n}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?i:e}function zR(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function HR(e){return e?e.slice(0,8):"--"}function Zp(e,t,n){return n?e.includes(t)?e:[...e,t]:e.includes(t)?e.filter(r=>r!==t):e}function Lb(e,t){const n=e.filter(r=>t.has(r));return n.length===e.length?e:n}function Db(e,t,n){return e.map(r=>{let i=!1;const o=r.sessions.map(c=>{const u=t.get(c.sessionId);return u===void 0||tr(c)===u?c:(i=!0,{...c,isArchived:u})}),a=Db(r.children,t,c=>{c&&(i=!0)});return n(i),i?{...r,sessions:o,children:a}:r})}function _b(e,t){for(const n of t){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&tr(r)===i&&e.delete(r.sessionId)}_b(e,n.children)}}function Bb(e,t,n){let r=!1;const i=e.map(o=>{if(o.workspace.id===t.workspaceId){const c=o.sessions.findIndex(d=>d.sessionId===t.sessionId),u=c>=0?o.sessions.map((d,h)=>h===c?t:d):[t,...o.sessions];return r=!0,{...o,sessions:mo(u,n)}}const a=Bb(o.children,t,n);return a.changed?(r=!0,{...o,children:a.nodes}):o});return{nodes:r?i:[...e],changed:r}}function UR(e,t){return e.map(n=>({...n,sessions:mo(n.sessions,t),childWorktrees:Ku(n.childWorktrees,t)}))}function el(e,t){let n=!1;const r=e.map(i=>{let o=!1;const a=i.sessions.map(u=>{const d=t(u);return d!==u&&(o=!0,n=!0),d}),c=el(i.children,t);return c!==i.children&&(o=!0,n=!0),o?{...i,sessions:a,children:c}:i});return n?r:[...e]}function Xc(e){return`workspace-management.summary.${e}`}function Ob(e){return`git-sidebar.snapshot.${e}`}function Wb(e,t){const n=e.repoRoot??null;return{workspaceId:e.id,name:e.name,path:e.path,git:{isRepository:!!n,repoRoot:n,currentBranch:null,commitCount:null,remotes:[],error:null},codeComposition:{scannedFileCount:0,truncated:!1,items:[],error:null}}}function Fb(e,t){const n=e.git.repoRoot??t.repoRoot??null;return{...e,workspaceId:t.id,name:t.name,path:t.path,git:{...e.git,isRepository:e.git.isRepository||!!n,repoRoot:n}}}function $b(e,t){var o,a,c,u;const n=((o=t.status)==null?void 0:o.snapshot.enabled)!==!1,r=n?((a=t.status)==null?void 0:a.snapshot.repoRoot)??e.git.repoRoot:e.git.repoRoot,i=n?((c=t.status)==null?void 0:c.snapshot.branch)??((u=t.branches)==null?void 0:u.currentBranch)??e.git.currentBranch??null:e.git.currentBranch??null;return{...e,git:{...e.git,isRepository:n&&(e.git.isRepository||!!r),repoRoot:r,currentBranch:i,error:null}}}function zb({count:e,className:t="workbench-skeleton-lines"}){return s.jsx("div",{className:t,"aria-hidden":"true",children:Array.from({length:e},(n,r)=>s.jsx("span",{className:"skeleton-line"},r))})}function qR(){return s.jsx("div",{className:"workbench-nav-loading","aria-hidden":"true",children:Array.from({length:3},(e,t)=>s.jsxs("section",{className:"workbench-skeleton-card",children:[s.jsxs("div",{className:"workbench-skeleton-heading",children:[s.jsx("span",{className:"skeleton-line short"}),s.jsx("span",{className:"skeleton-line tiny"})]}),s.jsx("div",{className:"workbench-skeleton-list",children:Array.from({length:3},(n,r)=>s.jsxs("div",{className:"workbench-skeleton-session",children:[s.jsx("span",{className:"workbench-skeleton-dot"}),s.jsx(zb,{count:2,className:"workbench-skeleton-lines compact"})]},r))})]},t))})}function ha(){return s.jsx("section",{className:"workbench-info-skeleton","aria-hidden":"true",children:Array.from({length:4},(e,t)=>s.jsxs("article",{className:"workbench-info-skeleton-card",children:[s.jsx("span",{className:"skeleton-line short"}),s.jsx(zb,{count:3})]},t))})}function GR({side:e,collapsed:t}){const n=e==="left"?8.5:15.5,r=e==="left"?t?"12 9 15 12 12 15":"15 9 12 12 15 15":t?"12 9 9 12 12 15":"9 9 12 12 9 15";return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("line",{x1:n,y1:"4",x2:n,y2:"20"}),s.jsx("polyline",{points:r})]})}function ef({ariaLabel:e,side:t,collapsed:n,className:r="panel-icon-button",onClick:i}){return s.jsx("button",{className:r,type:"button","aria-label":e,title:e,onClick:i,children:s.jsx(GR,{side:t,collapsed:n})})}function ei({expanded:e}){return s.jsx("svg",{className:e?"workbench-chevron":"workbench-chevron collapsed",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})}function VR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function KR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"}),s.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),s.jsx("line",{x1:"8",y1:"14",x2:"12",y2:"14"}),s.jsx("circle",{cx:"17.5",cy:"15.5",r:"2.5"})]})}function YR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M7.5 10.2a4.5 4.5 0 1 1 9 0v3.1c0 .8.3 1.6.9 2.2l.8.8H5.8l.8-.8c.6-.6.9-1.4.9-2.2z",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 18.5a2 2 0 0 0 4 0",strokeLinecap:"round"})]})}function Hb(e){return s.jsx("div",{className:"workbench-notification-anchor",children:s.jsxs("button",{type:"button",className:e.collapsed?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.globalNotificationsAction"),title:l("shell.globalNotificationsAction"),"aria-expanded":e.open,onClick:e.onToggle,children:[s.jsx(YR,{}),e.unreadCount>0?s.jsx("span",{className:"workbench-notification-badge","aria-label":l("shell.globalNotificationsUnreadAria",{count:String(e.unreadCount)}),children:e.unreadCount>99?"99+":e.unreadCount}):null]})})}function XR(e){const[t,n]=f.useState("notifications");f.useEffect(()=>{e.open&&n("notifications")},[e.open]);const r=f.useMemo(()=>e.notifications.filter(i=>e.showArchivedNotifications||!e.archivedNotificationIds.has(i.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return s.jsxs(Et,{open:e.open,title:l("shell.globalNotificationsPanelTitle"),description:l("shell.globalNotificationsPanelDescription"),className:"workbench-notification-modal-card workspace-inbox-modal-card",showCloseButton:!1,onClose:e.onClose,children:[s.jsxs("div",{className:"workbench-notification-tabs",role:"tablist","aria-label":l("shell.globalNotificationsPanelTitle"),children:[s.jsx("button",{type:"button",className:t==="notifications"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="notifications",onClick:()=>n("notifications"),children:l("shell.globalNotificationsAction")}),s.jsx("button",{type:"button",className:t==="inbox"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="inbox",onClick:()=>n("inbox"),children:l("shell.butlerInboxAction")})]}),s.jsx("div",{className:"workbench-notification-content","data-tab":t,children:t==="notifications"?s.jsxs("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.globalNotificationsAction"),children:[s.jsx("div",{className:"workbench-notification-toolbar",children:s.jsxs("label",{className:"workbench-notification-filter",children:[s.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:i=>e.onToggleShowArchivedNotifications(i.target.checked)}),s.jsx("span",{children:l("shell.globalNotificationsShowArchived")})]})}),r.length>0?s.jsx("div",{className:"workbench-notification-list",children:r.map(i=>{const o=e.archivedNotificationIds.has(i.id);return s.jsxs("article",{className:"workbench-notification-item","data-archived":o,children:[s.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(i)},children:[s.jsx("span",{className:"workbench-notification-item-kind",children:nR(i.kind)}),s.jsx("strong",{children:i.title}),s.jsx("p",{children:i.body})]}),s.jsxs("div",{className:"workbench-notification-item-side",children:[s.jsx("time",{children:lR(i.createdAt)}),s.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(o){e.onUnarchiveNotification(i.id);return}e.onArchiveNotification(i.id)},children:o?l("shell.globalNotificationsRemoveArchiveAction"):l("shell.globalNotificationsArchiveAction")})]})]},i.id)})}):s.jsx("p",{className:"workbench-notification-empty",children:l("shell.globalNotificationsEmpty")})]}):s.jsx("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.butlerInboxAction"),children:s.jsx(db,{active:e.open&&t==="inbox",preferredWorkspaceId:e.preferredWorkspaceId,preferredSessionId:e.preferredSessionId})})}),s.jsx("div",{className:"workbench-modal-actions workbench-notification-footer-actions",children:s.jsx("button",{type:"button",className:"secondary-button",onClick:e.onClose,children:l("common.close")})})]})}function JR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function QR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"7"}),s.jsx("line",{x1:"20",y1:"20",x2:"16.65",y2:"16.65"})]})}function ZR(){return s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function eA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("path",{d:"M7 9l3 3-3 3"}),s.jsx("path",{d:"M13 15h4"})]})}function tA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"3"}),s.jsx("circle",{cx:"9",cy:"11",r:"1"}),s.jsx("circle",{cx:"15",cy:"11",r:"1"}),s.jsx("path",{d:"M8 15h8"}),s.jsx("path",{d:"M12 5V3"})]})}function nA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M12 4.5 13.6 8l3.9.4-2.9 2.7.8 3.9L12 13.2 8.6 15l.8-3.9-2.9-2.7L10.4 8 12 4.5Z"}),s.jsx("path",{d:"m18.5 4.5.5 1.3 1.3.5-1.3.5-.5 1.3-.5-1.3-1.3-.5 1.3-.5.5-1.3Z"})]})}function Ub(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),s.jsx("polyline",{points:"14 9 11 12 14 15"})]})}function rA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"18",cy:"6",r:"3"}),s.jsx("circle",{cx:"6",cy:"6",r:"3"}),s.jsx("circle",{cx:"18",cy:"18",r:"3"}),s.jsx("path",{d:"M6 9v6a3 3 0 0 0 3 3h3"}),s.jsx("line",{x1:"18",y1:"9",x2:"18",y2:"15"})]})}function sA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function iA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"5",width:"6",height:"6",rx:"1.5"}),s.jsx("rect",{x:"14",y:"5",width:"6",height:"6",rx:"1.5"}),s.jsx("rect",{x:"4",y:"13",width:"6",height:"6",rx:"1.5"}),s.jsx("path",{d:"M14 16l2 2 4-4"})]})}function oA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"6",width:"10",height:"12",rx:"2"}),s.jsx("path",{d:"M10 12h8"}),s.jsx("path",{d:"M15 8l4 4-4 4"})]})}function aA({selected:e}){return e?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"}),s.jsx("path",{d:"M8 12.5l2.8 2.8L16.5 9.5"})]}):s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"})})}function qb({active:e,className:t}){return e?s.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})}):s.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:s.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})})}function lA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 7h18"}),s.jsx("path",{d:"M5 7l1 12h12l1-12"}),s.jsx("path",{d:"M9 11h6"}),s.jsx("path",{d:"M8 4h8l1 3H7l1-3z"})]})}function cA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function uA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M12 4v10"}),s.jsx("path",{d:"M8.5 7.5L12 4l3.5 3.5"}),s.jsx("path",{d:"M5 14v4a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-4"})]})}function dA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M8 6V4h8v2"}),s.jsx("path",{d:"M6 6l1 14h10l1-14"}),s.jsx("path",{d:"M10 11v5"}),s.jsx("path",{d:"M14 11v5"})]})}function hA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M9 13h6"})]})}function pA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M9.7 9.4a2.5 2.5 0 1 1 4.1 2c-.8.7-1.8 1.2-1.8 2.6",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"17.2",r:"1",fill:"currentColor",stroke:"none"})]})}function fA({open:e,mode:t,keyword:n,codeWorkspaceId:r,codeResults:i,codeLoading:o,codeError:a,workspaceOptions:c,sessionResults:u,onClose:d,onModeChange:h,onKeywordChange:p,onCodeWorkspaceChange:m,onCodeSearch:g,onOpenSession:x}){const S=n.trim().length>0&&r.trim().length>0;return s.jsx(Et,{open:e,title:l("shell.searchModalTitle"),description:l("shell.searchModalDescription"),onClose:d,children:s.jsxs("div",{className:"workbench-search-modal",children:[s.jsxs("div",{className:"workbench-search-mode-switch",role:"tablist","aria-label":l("shell.searchModeLabel"),children:[s.jsx("button",{type:"button",className:t==="sessions"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="sessions",onClick:()=>h("sessions"),children:l("shell.searchModeSessions")}),s.jsx("button",{type:"button",className:t==="code"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="code",onClick:()=>h("code"),children:l("shell.searchModeCode")})]}),t==="sessions"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchKeywordLabel")}),s.jsx("input",{type:"text",value:n,placeholder:l("shell.searchSessionPlaceholder"),autoFocus:!0,onChange:C=>p(C.target.value)})]}),s.jsx("div",{className:"workbench-search-results",children:n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionHint")}):u.length>0?u.map(C=>{const y=Vu(C.session.title,l("common.unknown"));return s.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>x(C.session.sessionId),children:[s.jsx("span",{className:"workbench-search-result-title",title:y.fullTitle,children:y.displayTitle}),s.jsxs("span",{className:"workbench-search-result-meta",children:[C.workspace.name," · ",Za(C.session.provider,"full")]})]},C.session.sessionId)}):s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionEmpty")})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchWorkspaceLabel")}),s.jsx("select",{value:r,onChange:C=>m(C.target.value),children:c.map(C=>s.jsx("option",{value:C.id,children:C.name},C.id))})]}),s.jsxs("form",{className:"workbench-search-code-form",onSubmit:C=>{C.preventDefault(),g()},children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchKeywordLabel")}),s.jsx("input",{type:"text",value:n,placeholder:l("shell.searchCodePlaceholder"),autoFocus:!0,onChange:C=>p(C.target.value)})]}),s.jsx("button",{type:"submit",className:"primary-button",disabled:!S||o,children:o?l("common.loading"):l("shell.searchSubmit")})]}),s.jsxs("div",{className:"workbench-search-results",children:[a?s.jsx("p",{className:"status-text","data-tone":"error",children:a}):null,!a&&n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeHint")}):null,!a&&n.trim().length>0&&!o&&i.length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeEmpty")}):null,i.map(C=>s.jsxs("div",{className:"workbench-search-result-item static",children:[s.jsx("span",{className:"workbench-search-result-title",children:C.name}),s.jsx("span",{className:"workbench-search-result-meta",children:C.path})]},`${C.path}-${C.kind}`))]})]})]})})}const mA=`
|
|
71
|
+
`)),new TextEncoder().encode(d.join(""))}const sp=48;function OE(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function Vu(e,t){const n=OE(e)||t,r=n.length>sp?n.slice(0,sp).trimEnd():n;return{fullTitle:n,displayTitle:r}}function Zo(e,t){return(t??"").localeCompare(e??"")}function ip(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function ea(e){return(e==null?void 0:e.trim())??""}function oo(e,t,n){if(n==="updatedAt"){const a=Zo(e.updatedAt,t.updatedAt);if(a!==0)return a}if(n==="title"){const a=ip(ea(e.title),ea(t.title));if(a!==0)return a}else{const a=Zo(e.createdAt,t.createdAt);if(a!==0)return a}const r=Zo(e.updatedAt,t.updatedAt);if(r!==0)return r;const i=Zo(e.createdAt,t.createdAt);if(i!==0)return i;const o=ip(ea(e.title),ea(t.title));return o!==0?o:e.sessionId.localeCompare(t.sessionId)}function mo(e,t){return[...e].sort((n,r)=>oo(n,r,t))}function Ku(e,t){return Array.isArray(e)?e.map(n=>({...n,sessions:mo(n.sessions,t),children:Ku(n.children,t)})):[]}const Zl=5,ec=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function WE(e){const t=Math.round(e.ratio*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}function FE(e,t){const n=e.reduce((c,u)=>c+u.count,0);if(n<=0)return[];const i=e.slice(0,Zl).map((c,u)=>({...c,key:c.type,ratio:c.count/n,color:ec[u]??ec[0]})),o=e.slice(Zl);if(o.length===0)return i;const a=o.reduce((c,u)=>c+u.count,0);return i.push({key:"other",type:t,count:a,ratio:a/n,color:ec[Zl]}),i}function $E(e){if(e.length===0)return"conic-gradient(color-mix(in srgb, var(--border-primary) 78%, transparent) 0% 100%)";let t=0;return`conic-gradient(${e.map((r,i)=>{const o=t,a=i===e.length-1?1:Math.min(1,t+r.ratio);return t=a,`${r.color} ${op(o)} ${op(a)}`}).join(", ")})`}function zE(e){return{"--workbench-manage-chart-background":$E(e)}}function op(e){const t=Math.round(e*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}const HE=8,UE=12,qE=160,ap=96;function GE(e,t,n,r={}){const i=r.gapPx??HE,o=r.viewportMarginPx??UE,a=r.defaultWidthPx??qE,c=r.estimatedHeightPx??ap,u=r.minHeightPx??ap,d=Math.max(0,n.width),h=Math.max(0,n.height),p=Math.max(0,h-o*2),m=Math.max(0,d-o*2),g=ta(Math.max(t.width||a,a),0,m),x=Math.max(t.height||c,c),S=Math.max(0,d-e.x-o),C=Math.max(0,e.x-o),y=S<g&&C>S,A=Math.max(0,h-e.y-i-o),j=Math.max(0,e.y-i-o),V=A<x&&j>A,I=ta(Math.max(V?j:A,u),0,p),G=Math.min(x,I),q=y?e.x-g:e.x,P=Math.max(o,d-o-g),T=V?e.y-i-G:e.y+i,H=Math.max(o,h-o-G),_=ta(q,o,P),ie=ta(T,o,H),Y=y||_<e.x?"right":"left";return{top:ie,left:_,width:g,maxHeight:Math.max(0,I),transformOrigin:`${V?"bottom":"top"} ${Y}`}}function ta(e,t,n){return!Number.isFinite(e)||n<t?t:Math.min(Math.max(e,t),n)}const ob="workbench.navigation.snapshot",ab=1800*1e3,VE="workbench.navigation.snapshot.host.";function lb(e){return`${VE}${e}`}function KE(e=ab,t=Wa(Bn.getState())){if(t){const n=wa(lb(t),e);if(n)return n}return wa(ob,e)}function na(e,t=Wa(Bn.getState())){qi(ob,e),t&&qi(lb(t),e)}function lp(e,t="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(n=>({workspace:n.workspace,sessions:mo(n.sessions,t),childWorktrees:YE(n.childWorktrees,t)}))}function YE(e,t){return Ku(e,t)}function Ba(e){return{workspaceId:e.id,tone:"root",backgroundColor:e.backgroundColor??null,displayName:e.name,workspaceName:e.name,branchName:null,depth:0,rootWorkspaceId:e.id,rootDisplayName:e.name,parentWorkspaceId:null,parentDisplayName:null}}function XE(e){const t=new Map;for(const n of e)t.set(n.workspace.id,Ba(n.workspace)),cb(t,n.childWorktrees??[],n.workspace,n.workspace);return Object.fromEntries(t)}function cr(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function cb(e,t,n,r,i=r.name){var o;for(const a of t){const c=((o=a.meta.displayName)==null?void 0:o.trim())||a.workspace.name;e.set(a.workspace.id,{workspaceId:a.workspace.id,tone:"worktree",backgroundColor:a.workspace.backgroundColor??null,displayName:c,workspaceName:a.workspace.name,branchName:a.meta.branchName||null,depth:a.meta.depth,rootWorkspaceId:n.id,rootDisplayName:n.name,parentWorkspaceId:a.meta.parentWorkspaceId||r.id,parentDisplayName:i}),cb(e,a.children,n,a.workspace,c)}}class Uc extends Error{constructor(t,n){super(n),this.code=t,this.name="HostSwitchError"}}class JE{constructor(){Ke(this,"inFlight",null)}async switchHost(t){this.inFlight&&await this.inFlight;const n=this.performSwitch(t).finally(()=>{this.inFlight===n&&(this.inFlight=null)});this.inFlight=n,await n}async performSwitch(t){const n=Bn.getState();if(Wa(n)===t)return;const r=lk(n,t);if(!r)throw new Uc("HOST_NOT_FOUND",`找不到 HOST:${t}`);if(!(await ck(r.baseUrl)).reachable)throw new Uc("HOST_UNREACHABLE",`目标 HOST 不可达:${r.baseUrl}`);const o=cf(r.id);if(o)try{await Ji.loginForHost(r,{username:o.username,password:o.password})}catch{}const a=Bn.getState(),c=new Date().toISOString();if(uf(r)){Bn.updateRuntime({discoveredHosts:a.discoveredHosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeDiscoveredHostId:t});return}dc.setActiveDiscoveredHost(null),await Bn.update({hosts:a.hosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeHostId:t})}}const QE=new JE,ZE=1700;function eM({open:e,id:t,role:n="dialog",labelledBy:r,className:i,anchorRef:o,popoverRef:a,children:c,maxWidth:u=360,gap:d=10,viewportPadding:h=16}){const[p,m]=f.useState(null);if(f.useEffect(()=>{if(!e||typeof window>"u"||typeof document>"u"){m(null);return}let x=0;const S=()=>{const y=o.current;if(!y)return;const A=y.getBoundingClientRect(),j=Math.max(180,Math.min(u,window.innerWidth-h*2)),V=Math.min(Math.max(h,A.right-j),Math.max(h,window.innerWidth-h-j)),L=A.top>=Math.min(240,window.innerHeight*.42),I=Math.round(L?A.top-d:A.bottom+d);m({top:I,left:Math.round(V),width:j,placeAbove:L})},C=()=>{window.cancelAnimationFrame(x),x=window.requestAnimationFrame(S)};return S(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.cancelAnimationFrame(x),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[o,d,u,e,h]),!e||!p||typeof document>"u")return null;const g={position:"fixed",top:p.top,left:p.left,width:p.width,maxWidth:`calc(100vw - ${h*2}px)`,zIndex:ZE,transform:p.placeAbove?"translateY(-100%)":void 0};return ur.createPortal(s.jsx("div",{id:t,ref:a,role:n,"aria-labelledby":r,className:i,"data-placement":p.placeAbove?"top":"bottom",style:g,children:c}),document.body)}const tc={status:"idle",latencyMs:null};function ub({collapsed:e=!1}){const[t,n]=f.useState(!1),[r,i]=f.useState(!1),[o,a]=f.useState(""),[c,u]=f.useState(""),[d,h]=f.useState(""),[p,m]=f.useState(""),[g,x]=f.useState(null),[S,C]=f.useState(null),[y,A]=f.useState(null),[j,V]=f.useState(!1),[L,I]=f.useState(!1),[G,q]=f.useState(tc),[P,T]=f.useState(null),H=f.useRef(null),_=f.useRef(null),ie=f.useRef(null),Y=f.useRef(null),W=eu(F=>F),U=Qc(F=>F.session),{showToast:D}=Wn(),K=hc(W),ee=Wa(W),v=yk(),Ne=uk(ee),ve=f.useMemo(()=>cp(W.hosts,ee),[ee,W.hosts]),N=f.useMemo(()=>cp(df(W),ee),[ee,W]),de=f.useCallback(()=>{if(typeof window>"u")return;const F=H.current;if(!F)return;const ne=F.getBoundingClientRect(),re=window.innerWidth,Se=window.innerHeight,ke=16,pe=8,Xe=Math.min(320,Math.max(240,re-ke*2)),st=Math.min(e?Math.max(ke,ne.right+pe):Math.max(ke,ne.left),Math.max(ke,re-Xe-ke)),E=r?440:240,$=e?ne.top:ne.bottom+pe,se=Math.min(Math.max(ke,$),Math.max(ke,Se-E-ke));T({position:"fixed",top:se,left:st,width:Xe,maxWidth:re-ke*2})},[e,r]);f.useEffect(()=>{if(!t){T(null),V(!1),q(tc);return}dc.refresh();function F(re){var Se,ke,pe;re.target instanceof Node&&!((Se=H.current)!=null&&Se.contains(re.target))&&!((ke=_.current)!=null&&ke.contains(re.target))&&!((pe=Y.current)!=null&&pe.contains(re.target))&&(n(!1),i(!1),V(!1),A(null))}function ne(re){re.key==="Escape"&&(n(!1),i(!1),V(!1),A(null))}return window.addEventListener("pointerdown",F),window.addEventListener("keydown",ne),window.addEventListener("resize",de),window.addEventListener("scroll",de,!0),de(),()=>{window.removeEventListener("pointerdown",F),window.removeEventListener("keydown",ne),window.removeEventListener("resize",de),window.removeEventListener("scroll",de,!0)}},[t,de]),f.useEffect(()=>{if(!j||!t||(v==null?void 0:v.kind)!=="relay"){q(tc);return}let F=!1;const ne=performance.now();return q({status:"probing",latencyMs:null}),xe.request("/api/client/runtime-config").then(()=>{F||q({status:"ready",latencyMs:performance.now()-ne})}).catch(()=>{F||q({status:"error",latencyMs:null})}),()=>{F=!0}},[v==null?void 0:v.kind,j,t]);async function Ee(F){if(g||S||F.id===ee){n(!1);return}x(F.id);try{await QE.switchHost(F.id),n(!1),i(!1),V(!1),A(null)}catch(ne){D({title:iM(ne,F.name),tone:"error"})}finally{x(null)}}async function me(F){if(!(F.id===ee||g||S)){if(y!==F.id){A(F.id);return}C(F.id);try{await Bn.update({hosts:W.hosts.filter(ne=>ne.id!==F.id)}),dk(F.id),Ji.clearHostSession(F.id),A(null),D({title:l("shell.hostDeleteSuccess",{name:F.name})})}catch{D({title:l("shell.hostDeleteFailed",{name:F.name}),tone:"error"})}finally{C(null)}}}async function le(){if(L)return;const F=o.trim(),ne=d.trim();if((ne.length>0||p.length>0)&&(!ne||!p)){D({title:l("shell.hostAddIncompleteCredentials"),tone:"error"});return}let Se;try{Se=hk(c)}catch{D({title:l("shell.hostAddInvalidUrl"),tone:"error"});return}I(!0);try{const ke=await Vk(Se),pe=Bn.getState(),xt=hc(pe);if(ke?pe.hosts.find(se=>{var ue;return se.baseUrl===Se||!!ke.bindingId&&((ue=se.relayTunnel)==null?void 0:ue.bindingId)===ke.bindingId}):pe.hosts.find(se=>se.baseUrl===Se)){D({title:l("shell.hostAddDuplicate"),tone:"error"});return}const st=uf(xt)&&xt.baseUrl===Se;st&&dc.setActiveDiscoveredHost(null);let E,$;if(ke){const ue=(await Bn.update(Kk(pe,ke,{activate:st,displayName:F}))).hosts.find(we=>rM(we,Se,ke.bindingId??null));if(!ue)throw new Error("relay entry host missing after save");E=ue.id,$=ue.name}else{const se=new Date().toISOString(),ue={id:sM(),name:F||tM(Se),baseUrl:Se,kind:nM(Se),createdAt:se,updatedAt:se,lastConnectedAt:null,lastUserId:null,lastUsername:null};await Bn.update({hosts:[...pe.hosts,ue],activeHostId:st?ue.id:pe.activeHostId}),E=ue.id,$=ue.name}ne&&p&&pk({hostId:E,username:ne,password:p}),We(),i(!1),A(null),D({title:l("shell.hostAddSuccess",{name:$})})}catch{D({title:l("shell.hostAddFailed"),tone:"error"})}finally{I(!1)}}function We(){a(""),u(""),h(""),m("")}if(!K)return null;const Ue=U!=null&&U.user.username?`${K.baseUrl} · ${U.user.username}`:K.baseUrl,Fe=(v==null?void 0:v.kind)==="relay"?l("shell.hostSwitcherDetailStatusRelay"):l("shell.hostSwitcherDetailStatusDirect"),rt=v?l(wk(v.kind)):l("common.unknown");return s.jsxs("div",{ref:H,className:"workbench-host-switcher-anchor","data-collapsed":e,children:[s.jsx("button",{type:"button",className:e?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.hostSwitcherAriaLabel"),title:Ue,"aria-expanded":t,onClick:()=>{n(F=>!F),i(!1)},children:s.jsx(lM,{})}),t&&P&&typeof document<"u"?ur.createPortal(s.jsxs("div",{ref:_,className:"workbench-host-switcher-menu",style:P,role:"menu","aria-label":l("shell.hostSwitcherTitle"),children:[s.jsx("div",{className:"workbench-host-switcher-menu-header",children:s.jsx("strong",{children:l("shell.hostSwitcherTitle")})}),s.jsxs("div",{className:"workbench-host-switcher-list",children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherSavedSection")}),ve.map(F=>{const ne=F.id===ee,re=ne?(U==null?void 0:U.user.username)??F.lastUsername??F.baseUrl:F.lastUsername??F.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":ne,children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:g!==null||S!==null,onClick:()=>{Ee(F)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[F.name,ne?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:re})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:g===F.id?l("shell.hostSwitcherSwitching"):ne?s.jsx(dp,{}):s.jsx(up,{})})]}),ne?s.jsx("button",{ref:ie,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:F.name}),"aria-expanded":j,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{V(Se=>!Se),A(null)},children:l("shell.hostSwitcherDetailAction")}):s.jsx("button",{type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostDeleteAriaLabel",{name:F.name}),title:y===F.id?l("shell.hostDeleteConfirmAction"):l("shell.hostDeleteAction"),"data-confirming":y===F.id,disabled:g!==null||S!==null,onClick:()=>{me(F)},children:S===F.id?l("shell.hostDeleteBusy"):y===F.id?l("shell.hostDeleteConfirmAction"):s.jsx(uM,{})})]},F.id)}),N.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherDiscoveredSection")}),N.map(F=>{const ne=F.id===ee,re=cf(F.id),Se=ne?(U==null?void 0:U.user.username)??(re==null?void 0:re.username)??F.baseUrl:(re==null?void 0:re.username)??F.baseUrl;return s.jsxs("div",{className:"workbench-host-switcher-item","data-active":ne,"data-discovered":"true",children:[s.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:g!==null||S!==null,onClick:()=>{Ee(F)},children:[s.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[s.jsxs("span",{className:"workbench-host-switcher-item-title",children:[F.name,s.jsx("span",{className:"workbench-host-switcher-item-badge","data-tone":"discovered",children:l("shell.hostSwitcherDiscoveredBadge")}),ne?s.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),s.jsx("span",{className:"workbench-host-switcher-item-meta",children:Se})]}),s.jsx("span",{className:"workbench-host-switcher-item-trailing",children:g===F.id?l("shell.hostSwitcherSwitching"):ne?s.jsx(dp,{}):s.jsx(up,{})})]}),ne?s.jsx("button",{ref:ie,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:F.name}),"aria-expanded":j,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{V(ke=>!ke),A(null)},children:l("shell.hostSwitcherDetailAction")}):null]},F.id)})]}):null,W.localHostDiscovery.status==="refreshing"?s.jsx("div",{className:"workbench-host-switcher-state-row",children:l("shell.hostDiscoveryRefreshing")}):null,W.localHostDiscovery.status==="failed"?s.jsx("div",{className:"workbench-host-switcher-state-row","data-tone":"error",children:l("shell.hostDiscoveryFailed")}):null]}),r?s.jsxs("div",{className:"workbench-host-switcher-form",children:[s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("shell.hostSwitcherNameLabel")}),s.jsx("input",{value:o,disabled:L,onChange:F=>a(F.target.value),placeholder:l("shell.hostSwitcherNamePlaceholder")})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("shell.hostSwitcherUrlLabel")}),s.jsx("input",{value:c,disabled:L,onChange:F=>u(F.target.value),placeholder:l("shell.hostSwitcherUrlPlaceholder")})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("auth.username")}),s.jsx("input",{value:d,disabled:L,onChange:F=>h(F.target.value),autoComplete:"username"})]}),s.jsxs("label",{className:"workbench-host-switcher-field",children:[s.jsx("span",{children:l("auth.password")}),s.jsx("input",{type:"password",value:p,disabled:L,onChange:F=>m(F.target.value),autoComplete:"current-password"})]}),s.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:L,onClick:()=>{i(!1),We()},children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:L,onClick:()=>{le()},children:L?l("common.loading"):l("shell.hostSwitcherSaveAction")})]})]}):s.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{i(!0),A(null)},children:[s.jsx(cM,{}),l("shell.hostSwitcherAddAction")]}),s.jsxs(eM,{open:j&&v!==null&&ie.current!==null,className:"workbench-host-switcher-detail-popover",anchorRef:ie,popoverRef:Y,labelledBy:"workbench-host-switcher-detail-title",children:[s.jsx("div",{className:"workbench-host-switcher-detail-header",children:s.jsx("strong",{id:"workbench-host-switcher-detail-title",children:l("shell.hostSwitcherDetailTitle")})}),s.jsxs("div",{className:"workbench-host-switcher-detail-grid",children:[s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailStatusLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:Fe})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailRouteLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:rt})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailAddressLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value","data-multiline":"true",children:(v==null?void 0:v.url)??K.baseUrl})]}),(v==null?void 0:v.kind)==="relay"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailLatencyLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:oM(G)})]}),s.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[s.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailTrafficLabel")}),s.jsx("span",{className:"workbench-host-switcher-detail-value",children:aM(Ne.totalBytes)})]})]}):null]})]})]}),document.body):null]})}function cp(e,t){return[...e].sort((n,r)=>{if(n.id===t)return-1;if(r.id===t)return 1;const i=n.lastConnectedAt??n.updatedAt??n.createdAt;return(r.lastConnectedAt??r.updatedAt??r.createdAt).localeCompare(i)})}function tM(e){try{const t=new URL(e),n=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${n}`}catch{return e}}function nM(e){try{const t=new URL(e).hostname.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"?"local":/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[0-1])\./.test(t)?"lan":"remote"}catch{return"custom"}}function rM(e,t,n){var r;return!!(e.baseUrl===t||n&&((r=e.relayTunnel)==null?void 0:r.bindingId)===n)}function sM(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function iM(e,t){return e instanceof Uc?e.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:t}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function oM(e){return e.status==="probing"?l("shell.hostSwitcherDetailLatencyLoading"):e.status==="error"?l("shell.hostSwitcherDetailUnavailable"):e.status==="ready"?`${Math.max(1,Math.round(e.latencyMs))} ms`:l("shell.hostSwitcherDetailUnavailable")}function aM(e){return!Number.isFinite(e)||e<1024?`${Math.max(0,Math.round(e))} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function lM(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[s.jsx("rect",{x:"4",y:"4.5",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("rect",{x:"4",y:"13",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("path",{d:"M11 7.75h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),s.jsx("path",{d:"M11 16.25h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),s.jsx("circle",{cx:"7.5",cy:"7.75",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"7.5",cy:"16.25",r:"1",fill:"currentColor",stroke:"none"})]})}function up(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function dp(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function cM(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M8 3.5v9M3.5 8h9",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function uM(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 4.5h9M6.5 2.75h3M5 4.5v7.25a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1V4.5M6.75 6.5v4M9.25 6.5v4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.35"})})}const ra={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function dM({open:e,onClose:t,onCloned:n}){const{showToast:r}=Wn(),[i,o]=f.useState(!1),[a,c]=f.useState(ra),[u,d]=f.useState(!1),[h,p]=f.useState(!1),[m,g]=f.useState(null),[x,S]=f.useState(""),[C,y]=f.useState(""),[A,j]=f.useState(null),[V,L]=f.useState([]),[I,G]=f.useState([]),q=i||h;f.useEffect(()=>{!e&&!i&&(c(ra),d(!1),g(null))},[i,e]);const P=f.useCallback(async U=>{p(!0),g(null);try{const D=await ff(U);S(D.currentPath),y(D.currentPath),j(D.parentPath),L(D.roots),G(D.items),c(K=>({...K,parentPath:D.currentPath}))}catch(D){S(""),j(null),G([]),g(D instanceof Error?D.message:l("shell.importBrowserBrowseFailed"))}finally{p(!1)}},[]);function T(){i||(d(!1),g(null),c(ra),t())}function H(){d(!0),P(a.parentPath||void 0)}function _(){i||(d(!1),g(null))}async function ie(U){U.preventDefault(),await P(C)}function Y(){c(U=>({...U,parentPath:x})),d(!1),g(null)}async function W(U){U.preventDefault();const D=a.repositoryUrl.trim(),K=a.parentPath.trim();if(!D){r({title:l("shell.cloneRepoRequired"),tone:"error"});return}if(!K){r({title:l("shell.clonePathRequired"),tone:"error"});return}o(!0);try{const ee=await vk({repositoryUrl:D,parentPath:K,directoryName:a.directoryName.trim()||void 0,name:a.name.trim()||void 0,auth:a.authMode==="none"?{mode:"none"}:a.authMode==="basic"?{mode:"basic",username:a.username.trim(),password:a.password}:{mode:"token",username:a.username.trim()||void 0,token:a.token}});await(n==null?void 0:n(ee)),c(ra),d(!1),r({title:l("shell.cloneSuccess"),description:ee.path,tone:"success"}),t()}catch(ee){r({title:ee instanceof Error?ee.message:l("shell.cloneFailed"),tone:"error"})}finally{o(!1)}}return s.jsxs(s.Fragment,{children:[s.jsx(Et,{open:e,title:l("shell.cloneWorkspaceTitle"),description:l("shell.cloneWorkspaceHint"),onClose:T,children:s.jsxs("form",{className:"workbench-clone-form",onSubmit:U=>void W(U),children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneRepositoryLabel")}),s.jsx("input",{type:"text",value:a.repositoryUrl,placeholder:l("shell.cloneRepositoryPlaceholder"),onChange:U=>c(D=>({...D,repositoryUrl:U.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneParentPathLabel")}),s.jsxs("div",{className:"workbench-modal-inline-field",children:[s.jsx("input",{type:"text",value:a.parentPath,placeholder:l("shell.cloneParentPathPlaceholder"),onChange:U=>c(D=>({...D,parentPath:U.target.value}))}),s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:H,children:l("shell.clonePickDirectory")})]})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneDirectoryNameLabel")}),s.jsx("input",{type:"text",value:a.directoryName,placeholder:l("shell.cloneDirectoryNamePlaceholder"),onChange:U=>c(D=>({...D,directoryName:U.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importNameLabel")}),s.jsx("input",{type:"text",value:a.name,placeholder:l("shell.importNamePlaceholder"),onChange:U=>c(D=>({...D,name:U.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneAuthModeLabel")}),s.jsxs("select",{value:a.authMode,onChange:U=>c(D=>({...D,authMode:U.target.value})),children:[s.jsx("option",{value:"none",children:l("shell.cloneAuthModeNone")}),s.jsx("option",{value:"basic",children:l("shell.cloneAuthModeBasic")}),s.jsx("option",{value:"token",children:l("shell.cloneAuthModeToken")})]})]}),a.authMode==="basic"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneUsernameLabel")}),s.jsx("input",{type:"text",value:a.username,placeholder:l("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:U=>c(D=>({...D,username:U.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.clonePasswordLabel")}),s.jsx("input",{type:"password",value:a.password,placeholder:l("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:U=>c(D=>({...D,password:U.target.value}))})]})]}):null,a.authMode==="token"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneUsernameLabel")}),s.jsx("input",{type:"text",value:a.username,placeholder:l("shell.cloneTokenUsernamePlaceholder"),onChange:U=>c(D=>({...D,username:U.target.value}))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.cloneTokenLabel")}),s.jsx("input",{type:"password",value:a.token,placeholder:l("shell.cloneTokenPlaceholder"),onChange:U=>c(D=>({...D,token:U.target.value}))})]})]}):null,s.jsx("p",{className:"workbench-import-hint",children:l("shell.cloneHint")}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:T,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:i,children:i?l("shell.cloneSubmitting"):l("shell.cloneSubmit")})]})]})}),s.jsxs(Et,{open:e&&u,title:l("shell.cloneBrowserTitle"),description:l("shell.cloneBrowserDescription"),onClose:_,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ie,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:C,placeholder:l("shell.importPathPlaceholder"),onChange:U=>y(U.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:q||!A,onClick:()=>{A&&P(A)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:q,children:l("shell.importBrowserOpenPath")})]})]}),s.jsxs("section",{className:"workbench-directory-browser-panel",children:[s.jsxs("div",{className:"workbench-directory-browser-section",children:[s.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),s.jsx("div",{className:"workbench-directory-browser-root-list",children:V.map(U=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:q,onClick:()=>{P(U.path)},children:U.name},U.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:x}),m?s.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:m}):null,h?s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):I.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:I.map(U=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:q,onClick:()=>{P(U.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:U.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:U.path})]},U.path))}):s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:_,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:q||!x,onClick:Y,children:l("shell.cloneBrowserSubmit")})]})]})]})}const hM="butler:inbox-updated";function nc(){typeof window>"u"||window.dispatchEvent(new Event(hM))}const hp={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function db({active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,compactComposer:o=!1,composerOpen:a=!0,onComposerOpenChange:c}){const{showToast:u}=Wn(),[d,h]=f.useState(!1),[p,m]=f.useState(!1),[g,x]=f.useState([]),[S,C]=f.useState([]),[y,A]=f.useState(null),[j,V]=f.useState(null),[L,I]=f.useState(hp),[G,q]=f.useState(!1),P=f.useMemo(()=>fp(g,t,j),[j,t,g]),T=f.useMemo(()=>G?S:S.filter(D=>D.status!=="closed"),[S,G]);f.useEffect(()=>{e&&H()},[e,n]),f.useEffect(()=>{!e||y||I(D=>{const K=gp({projects:P,currentProjectId:D.projectId,preferredProjectId:j,preferredWorkspaceId:t});return K===D.projectId?D:{...D,projectId:K}})},[e,y,j,t,P]),f.useEffect(()=>{!e||r<=0||(_(void 0,t,i,j),c==null||c(!0))},[e,r,i,c,j,t]);async function H(){h(!0);try{const[D,K,ee]=await Promise.all([ej(),cg(),n?aj(n).catch(()=>null):Promise.resolve(null)]),v=(ee==null?void 0:ee.target.project.id)??null;V(v),x(D.items),C(K.items),y||_(D.items,t,r>0?i:null,v)}catch(D){u({title:l("shell.butlerInboxLoadFailed"),description:D instanceof Error?D.message:void 0,tone:"error"})}finally{h(!1)}}function _(D=g,K=t,ee=i,v=j){var ve,N;const Ne=fp(D,K,v);A(null),I({...hp,projectId:gp({projects:Ne,preferredProjectId:v,preferredWorkspaceId:K}),title:((ve=ee==null?void 0:ee.title)==null?void 0:ve.trim())??"",content:((N=ee==null?void 0:ee.content)==null?void 0:N.trim())??""})}function ie(D){A(D.id),I({projectId:D.projectId,itemType:D.itemType,title:D.title,content:D.content,status:D.status}),o&&(c==null||c(!0))}async function Y(D){D.preventDefault(),m(!0);try{y?(await jh(y,{projectId:L.projectId,itemType:L.itemType,title:L.title,content:L.content,status:L.status,priority:"medium"}),u({title:l("shell.butlerInboxUpdated"),tone:"success"})):(await tj({projectId:L.projectId,itemType:L.itemType,title:L.title,content:L.content,status:L.status,priority:"medium"}),u({title:l("shell.butlerInboxCreated"),tone:"success"})),nc(),await H(),_(),o&&(c==null||c(!1))}catch(K){u({title:l("shell.butlerInboxSaveFailed"),description:K instanceof Error?K.message:void 0,tone:"error"})}finally{m(!1)}}async function W(D){m(!0);try{await sj(D),u({title:l("shell.butlerInboxDeleted"),tone:"success"}),nc(),await H(),y===D&&_()}catch(K){u({title:l("shell.butlerInboxDeleteFailed"),description:K instanceof Error?K.message:void 0,tone:"error"})}finally{m(!1)}}async function U(D,K){if(D.status!==K){m(!0);try{await jh(D.id,{status:K}),u({title:l("shell.butlerInboxUpdated"),tone:"success"}),nc(),await H(),y===D.id&&I(ee=>({...ee,status:K}))}catch(ee){u({title:l("shell.butlerInboxSaveFailed"),description:ee instanceof Error?ee.message:void 0,tone:"error"})}finally{m(!1)}}}return s.jsxs("div",{className:"workspace-inbox-modal",children:[o?null:s.jsx("section",{className:"workspace-inbox-panel",children:s.jsx(pp,{selectableProjects:P,formState:L,saving:p,editingItemId:y,useMobilePicker:!1,onProjectChange:D=>{I(K=>({...K,projectId:D}))},onItemTypeChange:D=>{I(K=>({...K,itemType:D}))},onStatusChange:D=>{I(K=>({...K,status:D}))},onTitleChange:D=>{I(K=>({...K,title:D}))},onContentChange:D=>{I(K=>({...K,content:D}))},onCancel:()=>_(),onSubmit:Y})}),s.jsxs("section",{className:"workspace-inbox-panel",children:[s.jsxs("header",{className:"workspace-inbox-panel-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:l("shell.butlerInboxListTitle")}),s.jsx("p",{children:l("shell.butlerInboxListDescription")})]}),s.jsxs("label",{className:"workspace-inbox-closed-toggle",children:[s.jsx("input",{type:"checkbox",checked:G,onChange:D=>q(D.target.checked)}),s.jsx("span",{children:l("shell.butlerInboxShowClosedAction")})]})]}),d?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxLoading")}):null,!d&&T.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxEmpty")}):null,!d&&T.length>0?s.jsx("div",{className:"workspace-inbox-list",children:T.map(D=>s.jsxs("article",{className:"workspace-inbox-item",children:[s.jsxs("div",{className:"workspace-inbox-item-header",children:[s.jsxs("div",{children:[s.jsx("strong",{children:D.title}),s.jsx("p",{children:D.projectName})]}),s.jsxs("div",{className:"workspace-inbox-item-badges",children:[s.jsx("span",{className:"workspace-inbox-badge",children:bp(D.status)}),s.jsx("span",{className:"workspace-inbox-badge",children:bM(D.itemType)})]})]}),s.jsx("p",{className:"workspace-inbox-item-content",children:D.content}),s.jsxs("div",{className:"workspace-inbox-item-footer",children:[s.jsx("span",{children:kM(D.updatedAt)}),s.jsxs("div",{className:"workspace-inbox-item-actions",children:[s.jsx("div",{className:"workspace-inbox-status-quick-actions",role:"group","aria-label":l("shell.butlerInboxQuickStatusLabel"),children:["pending","in_progress","closed"].map(K=>{const ee=D.status===K;return s.jsx("button",{type:"button",className:"secondary-button","data-active":ee,disabled:p,onClick:()=>{U(D,K)},children:bp(K)},`${D.id}:${K}`)})}),s.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>ie(D),children:l("shell.butlerInboxEditAction")}),s.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{W(D.id)},children:l("shell.butlerInboxDeleteAction")})]})]})]},D.id))}):null]}),o?s.jsx(Et,{open:e&&a,title:y?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle"),description:l("shell.butlerInboxFormDescription"),className:"workspace-inbox-modal-card workspace-inbox-composer-modal-card",onClose:()=>{c==null||c(!1),_()},children:s.jsx("div",{className:"workspace-inbox-composer-modal-body",children:s.jsx(pp,{selectableProjects:P,formState:L,saving:p,editingItemId:y,useMobilePicker:!0,onProjectChange:D=>{I(K=>({...K,projectId:D}))},onItemTypeChange:D=>{I(K=>({...K,itemType:D}))},onStatusChange:D=>{I(K=>({...K,status:D}))},onTitleChange:D=>{I(K=>({...K,title:D}))},onContentChange:D=>{I(K=>({...K,content:D}))},onCancel:()=>{c==null||c(!1),_()},onSubmit:Y})})}):null]})}function pp(e){const t=e.selectableProjects.map(i=>({value:i.id,label:i.name})),n=[{value:"task",label:l("shell.butlerInboxTypeTask")},{value:"bug",label:l("shell.butlerInboxTypeBug")},{value:"feature",label:l("shell.butlerInboxTypeFeature")},{value:"change",label:l("shell.butlerInboxTypeChange")}],r=[{value:"pending",label:l("shell.butlerInboxStatusPending")},{value:"in_progress",label:l("shell.butlerInboxStatusInProgress")},{value:"closed",label:l("shell.butlerInboxStatusClosed")}];return s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"workspace-inbox-panel-header",children:[s.jsx("h3",{children:e.editingItemId?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle")}),s.jsx("p",{children:l("shell.butlerInboxFormDescription")})]}),e.selectableProjects.length===0?s.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxProjectsEmpty")}):s.jsxs("form",{className:"workspace-inbox-form",onSubmit:e.onSubmit,children:[s.jsx("div",{className:"workspace-inbox-form-grid",children:e.useMobilePicker?s.jsxs(s.Fragment,{children:[s.jsx(rc,{label:l("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:t,disabled:e.saving,onChange:e.onProjectChange}),s.jsx(rc,{label:l("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:n,disabled:e.saving,onChange:e.onItemTypeChange}),s.jsx(rc,{label:l("shell.butlerInboxStatusLabel"),value:e.formState.status,options:r,disabled:e.saving,onChange:e.onStatusChange})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxProjectLabel")}),s.jsx("select",{value:e.formState.projectId,disabled:e.saving,onChange:i=>e.onProjectChange(i.target.value),children:e.selectableProjects.map(i=>s.jsx("option",{value:i.id,children:i.name},i.id))})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxTypeLabel")}),s.jsxs("select",{value:e.formState.itemType,disabled:e.saving,onChange:i=>e.onItemTypeChange(i.target.value),children:[s.jsx("option",{value:"task",children:l("shell.butlerInboxTypeTask")}),s.jsx("option",{value:"bug",children:l("shell.butlerInboxTypeBug")}),s.jsx("option",{value:"feature",children:l("shell.butlerInboxTypeFeature")}),s.jsx("option",{value:"change",children:l("shell.butlerInboxTypeChange")})]})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxStatusLabel")}),s.jsxs("select",{value:e.formState.status,disabled:e.saving,onChange:i=>e.onStatusChange(i.target.value),children:[s.jsx("option",{value:"pending",children:l("shell.butlerInboxStatusPending")}),s.jsx("option",{value:"in_progress",children:l("shell.butlerInboxStatusInProgress")}),s.jsx("option",{value:"closed",children:l("shell.butlerInboxStatusClosed")})]})]})]})}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxTitleLabel")}),s.jsx("input",{value:e.formState.title,placeholder:l("shell.butlerInboxTitlePlaceholder"),disabled:e.saving,onChange:i=>e.onTitleChange(i.target.value)})]}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.butlerInboxContentLabel")}),s.jsx("textarea",{rows:4,value:e.formState.content,placeholder:l("shell.butlerInboxContentPlaceholder"),disabled:e.saving,onChange:i=>e.onContentChange(i.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onCancel,children:e.editingItemId?l("shell.butlerInboxCancelEditAction"):l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:e.saving||!e.formState.projectId,children:e.editingItemId?l("shell.butlerInboxUpdateAction"):l("shell.butlerInboxCreateAction")})]})]})]})}function rc({label:e,value:t,options:n,disabled:r,onChange:i}){const[o,a]=f.useState(!1),c=n.find(u=>u.value===t)??n[0]??null;return f.useEffect(()=>{if(!o)return;function u(d){d.key==="Escape"&&a(!1)}return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[o]),s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"workbench-modal-field workspace-inbox-mobile-picker",children:[s.jsx("span",{children:e}),s.jsxs("button",{type:"button",className:"workspace-inbox-mobile-picker-trigger","aria-label":e,"aria-haspopup":"dialog","aria-expanded":o,disabled:r||n.length===0,onClick:()=>a(!0),children:[s.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-value",children:(c==null?void 0:c.label)??""}),s.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-icon",children:s.jsx(mM,{expanded:o})})]})]}),s.jsx(pM,{open:o,title:e,options:n,selectedValue:t,onClose:()=>a(!1),onSelect:u=>{i(u),a(!1)}})]})}function pM({open:e,title:t,options:n,selectedValue:r,onClose:i,onSelect:o}){return e?s.jsx(Sk,{open:e,title:t,kind:"picker",height:"half",className:"workspace-inbox-picker-sheet",cardClassName:"workspace-inbox-picker-sheet-card",bodyClassName:"workspace-inbox-picker-sheet-body",showHandle:!0,onClose:i,children:s.jsx(ru,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":t,children:n.map(a=>{const c=a.value===r;return s.jsx(pn,{as:"button",className:"workspace-inbox-picker-option",role:"option","aria-selected":c,selected:c,trailing:s.jsx("span",{className:"workspace-inbox-picker-option-indicator","aria-hidden":"true",children:c?s.jsx(gM,{}):null}),onClick:()=>o(a.value),children:s.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[s.jsx("strong",{children:a.label}),a.description?s.jsx("span",{children:a.description}):null]})},a.value)})})}):null}function eL({open:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:i=null,onClose:o,compactComposer:a=!1}){const[c,u]=f.useState(0),[d,h]=f.useState(!a);return f.useEffect(()=>{e||h(!a)},[a,e]),s.jsx(Et,{open:e,title:l("shell.butlerInboxModalTitle"),description:l("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!a,headerActions:a?s.jsx("button",{type:"button",className:"workspace-inbox-modal-create-button","aria-label":l("shell.butlerInboxCreateAction"),title:l("shell.butlerInboxCreateAction"),onClick:()=>{u(p=>p+1),h(!0)},children:s.jsx(fM,{})}):void 0,onClose:o,children:s.jsx(db,{active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:Math.max(r,c),initialDraft:i,compactComposer:a,composerOpen:d,onComposerOpenChange:h})})}function fp(e,t,n){return[...e].filter(r=>r.lifecycleStatus!=="archived").sort((r,i)=>{const o=mp(r,t,n),a=mp(i,t,n);return o!==a?a-o:r.name.localeCompare(i.name,"zh-Hans-CN")})}function mp(e,t,n){return n&&e.id===n?2:t&&e.workspaceId===t?1:0}function gp({projects:e,currentProjectId:t,preferredProjectId:n,preferredWorkspaceId:r}){var o;if(t&&e.some(a=>a.id===t))return t;if(n&&e.some(a=>a.id===n))return n;const i=r?e.find(a=>a.workspaceId===r):null;return(i==null?void 0:i.id)||((o=e[0])==null?void 0:o.id)||""}function fM(){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"M12 5v14"}),s.jsx("path",{d:"M5 12h14"})]})}function mM({expanded:e}){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true","data-expanded":e?"true":void 0,children:s.jsx("path",{d:"M3.5 6 8 10l4.5-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function gM(){return s.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:s.jsx("path",{d:"M3.5 8.4 6.6 11.5 12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function bM(e){switch(e){case"bug":return l("shell.butlerInboxTypeBug");case"feature":return l("shell.butlerInboxTypeFeature");case"change":return l("shell.butlerInboxTypeChange");case"task":default:return l("shell.butlerInboxTypeTask")}}function bp(e){switch(e){case"in_progress":return l("shell.butlerInboxStatusInProgress");case"closed":return l("shell.butlerInboxStatusClosed");case"pending":default:return l("shell.butlerInboxStatusPending")}}function kM(e){return new Date(e).toLocaleString()}function xM({open:e,onClose:t,onImported:n}){const{showToast:r}=Wn(),[i,o]=f.useState(!1),[a,c]=f.useState(!1),[u,d]=f.useState(!1),[h,p]=f.useState(null),[m,g]=f.useState(""),[x,S]=f.useState(""),[C,y]=f.useState(null),[A,j]=f.useState([]),[V,L]=f.useState([]),[I,G]=f.useState(!1),[q,P]=f.useState(""),T=i||a||u,H=f.useCallback(async K=>{o(!0),p(null);try{const ee=await ff(K);g(ee.currentPath),S(ee.currentPath),y(ee.parentPath),j(ee.roots),L(ee.items)}catch(ee){g(""),y(null),L([]),p(ee instanceof Error?ee.message:l("shell.importBrowserBrowseFailed"))}finally{o(!1)}},[]);f.useEffect(()=>{if(!e){G(!1),P(""),p(null);return}H(m||void 0)},[H,e]);function _(){T||(G(!1),P(""),t())}async function ie(K){K.preventDefault(),await H(x)}function Y(){!m||T||(P(""),G(!0))}function W(){a||(G(!1),P(""))}async function U(K){K==null||K.preventDefault();const ee=q.trim();if(!(!m||!ee||T)){c(!0),p(null);try{const v=await Nk({parentPath:m,directoryName:ee});r({title:l("shell.importBrowserCreateDirectorySuccess"),description:v.path,tone:"success"}),G(!1),P(""),await H(v.path)}catch(v){const Ne=v instanceof Error?v.message:l("shell.importBrowserCreateDirectoryFailed");p(Ne),r({title:Ne,tone:"error"})}finally{c(!1)}}}async function D(){const K=m.trim();if(!(!K||T)){d(!0),p(null);try{const ee=await Ck({path:K});r({title:l("shell.importSuccess"),description:ee.path,tone:"success"}),t(),Promise.resolve().then(()=>n==null?void 0:n(ee)).catch(v=>{r({title:v instanceof Error?v.message:l("shell.navigationLoadFailed"),tone:"error"})})}catch(ee){r({title:ee instanceof Error?ee.message:l("shell.importFailed"),tone:"error"})}finally{d(!1)}}}return s.jsxs(s.Fragment,{children:[s.jsxs(Et,{open:e,title:l("shell.importBrowserTitle"),description:l("shell.importBrowserDescription"),onClose:_,children:[s.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ie,children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCurrentPath")}),s.jsx("input",{type:"text",value:x,placeholder:l("shell.importPathPlaceholder"),onChange:K=>S(K.target.value)})]}),s.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:T||!C,onClick:()=>{C&&H(C)},children:l("shell.importBrowserOpenParent")}),s.jsx("button",{type:"submit",className:"secondary-button",disabled:T,children:l("shell.importBrowserOpenPath")}),s.jsx("button",{type:"button",className:"secondary-button",disabled:T||!m,onClick:Y,children:l("shell.importBrowserCreateDirectory")})]})]}),s.jsxs("section",{className:"workbench-directory-browser-panel",children:[s.jsxs("div",{className:"workbench-directory-browser-section",children:[s.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),s.jsx("div",{className:"workbench-directory-browser-root-list",children:A.map(K=>s.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:T,onClick:()=>{H(K.path)},children:K.name},K.path))})]}),s.jsx("div",{className:"workbench-directory-browser-current-path",children:m}),h?s.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:h}):null,i?s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):V.length>0?s.jsx("div",{className:"workbench-directory-browser-list",children:V.map(K=>s.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:T,onClick:()=>{H(K.path)},children:[s.jsx("span",{className:"workbench-directory-browser-item-name",children:K.name}),s.jsx("span",{className:"workbench-directory-browser-item-path",children:K.path})]},K.path))}):s.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:T,onClick:_,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:T||!m,onClick:()=>{D()},children:u?l("shell.importSubmitting"):l("shell.importBrowserSubmit")})]})]}),s.jsx(Et,{open:e&&I,title:l("shell.importBrowserCreateDirectoryTitle"),description:l("shell.importBrowserCreateDirectoryDescription"),onClose:W,children:s.jsxs("form",{className:"workbench-rename-form",onSubmit:K=>void U(K),children:[s.jsx("div",{className:"workbench-directory-browser-current-path",children:m}),s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.importBrowserCreateDirectoryLabel")}),s.jsx("input",{type:"text",value:q,placeholder:l("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:K=>P(K.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",disabled:a,onClick:W,children:l("common.cancel")}),s.jsx("button",{type:"submit",className:"primary-button",disabled:a||!q.trim(),children:a?l("shell.importBrowserCreatingDirectory"):l("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function yM({onOpenSoftwareUpdate:e}){var r;const t=eu(i=>i.platform),n=mk(i=>i.latestState);return t!=="desktop"||!(n!=null&&n.hasUpdate)?null:s.jsx("button",{className:"workbench-nav-update-badge",type:"button",title:((r=n.manifest)==null?void 0:r.version)??l("settings.releaseUpdateReady"),onClick:e,children:s.jsx("span",{className:"workbench-nav-update-badge-label",children:l("settings.releaseUpdateBadge")})})}function wM(){const e=fk.getState().profile.defaultPermissionMode;return e==="default"?null:e}const Hi="provider-default",ba="__global_default__";function vM(e){switch(e){case"claude-code":case"codex":case"gemini":return e;default:return null}}function sa(e,t){const n=(t==null?void 0:t.trim())||null;return e==="cc-switch-preset"&&n?{providerConfigMode:"cc-switch-preset",providerPresetId:n}:{providerConfigMode:"global-default",providerPresetId:null}}function SM(e){const t=e!=null&&e.currentPresetName?e.currentModel?`${e.currentPresetName} · ${e.currentModel}`:e.currentPresetName:null;return[{value:ba,label:l("conversation.deploymentDefaultPreset"),summary:t},...((e==null?void 0:e.options)??[]).map(n=>({value:n.id,label:n.name,summary:n.model??n.summary??null}))]}function CM(e){return e.usesProviderDefault===!0||e.id===Hi}function NM(e){return e?e.cliAvailable===!0&&e.status!=="unavailable"&&e.options.length>1:!0}function jM({triggerId:e,ariaLabel:t,triggerLabel:n,presetOptions:r,selectedPresetValue:i,selectedPresetSummary:o,onSelectPreset:a,modelOptions:c,selectedModelValue:u,onSelectModel:d,loadingPresets:h=!1,loadingModels:p=!1,modelColumnDisabled:m=!1,showPresetColumn:g=!0,modelEmptyText:x}){const[S,C]=f.useState(!1),y=f.useRef(null),A=f.useRef(null),j=f.useRef(null),[V,L]=f.useState(null),I=f.useId(),G=f.useCallback(()=>{const q=A.current;if(!q||typeof window>"u")return;const P=q.getBoundingClientRect(),T=q.closest(".workbench-modal-card"),H=T instanceof HTMLElement?T.getBoundingClientRect():null,_=window.innerWidth,ie=window.innerHeight,Y=12,W=8,U=320,D=Math.min(560,Math.max(320,_-Y*2)),K=Math.min(D,420),ee=Math.max(Math.min(D,Math.max(K,Math.round(P.width*1.9))),Math.min(320,D)),v=Math.min(Math.max(Y,P.left),Math.max(Y,_-ee-Y)),Ne=H?Math.max(Y,H.top+8):Y,ve=H?Math.min(ie-Y,H.bottom-8):ie-Y,N=Math.max(0,P.top-Ne-W),de=Math.max(0,ve-P.bottom-W),Ee=H?!(de>=U||de>N+40):N>=240||N>=de;L({position:"fixed",left:v,width:ee,maxWidth:D,zIndex:1905,top:Ee?void 0:P.bottom+W,bottom:Ee?ie-P.top+W:void 0})},[]);return f.useEffect(()=>{if(!S)return;function q(T){var _,ie;const H=T.target;!((_=y.current)!=null&&_.contains(H))&&!((ie=j.current)!=null&&ie.contains(H))&&C(!1)}function P(T){T.key==="Escape"&&C(!1)}return window.addEventListener("pointerdown",q),window.addEventListener("keydown",P),window.addEventListener("resize",G),window.addEventListener("scroll",G,!0),G(),()=>{window.removeEventListener("pointerdown",q),window.removeEventListener("keydown",P),window.removeEventListener("resize",G),window.removeEventListener("scroll",G,!0)}},[S,G]),s.jsxs("div",{ref:y,className:"composer-mac-select composer-deployment-select","data-open":S?"true":"false",children:[s.jsxs("button",{id:e,ref:A,type:"button",className:"composer-mac-select-trigger composer-deployment-select-trigger","aria-label":t,"aria-haspopup":"dialog","aria-expanded":S,"aria-controls":I,onClick:()=>C(q=>!q),children:[s.jsx("span",{className:"composer-mac-select-label composer-deployment-select-label",children:n}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),S&&V&&typeof document<"u"?ur.createPortal(s.jsx("div",{ref:j,className:"composer-mac-select-popover composer-deployment-select-popover",style:V,role:"presentation",children:s.jsxs("div",{id:I,className:`composer-deployment-select-panel${g?"":" is-model-only"}`,role:"dialog","aria-label":t,children:[g?s.jsxs("div",{className:"composer-deployment-select-column",children:[s.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentConfigColumn")}),s.jsxs("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentConfigColumn"),children:[r.map(q=>{const P=q.value===i;return s.jsxs("button",{type:"button",role:"option","aria-selected":P,className:`composer-deployment-select-option ${P?"is-selected":""}`,onClick:()=>a(q.value),children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:P?"✓":""}),s.jsxs("span",{className:"composer-deployment-select-option-copy",children:[s.jsx("span",{className:"composer-deployment-select-option-label",children:q.label}),q.summary?s.jsx("span",{className:"composer-deployment-select-option-summary",children:q.summary}):null]})]},q.value)}),h?s.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentLoading")}):null]})]}):null,s.jsxs("div",{className:"composer-deployment-select-column","data-disabled":m?"true":"false",children:[s.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentModelColumn")}),g&&o?s.jsx("div",{className:"composer-deployment-select-column-hint",children:o}):null,s.jsx("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentModelColumn"),children:p&&m?s.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentModelLoading")}):c.length>0?c.map(q=>{const P=q.value===u;return s.jsxs("button",{type:"button",role:"option","aria-selected":P,className:`composer-deployment-select-option ${P?"is-selected":""}`,disabled:m,onClick:()=>{d(q.value),C(!1)},children:[s.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:P?"✓":""}),s.jsx("span",{className:"composer-deployment-select-option-copy",children:s.jsx("span",{className:"composer-deployment-select-option-label",children:q.label})})]},q.value)}):s.jsx("div",{className:"composer-deployment-select-state",children:x})})]})]})}),document.body):null]})}const hb=144,TM=196,IM=124,EM=72;let kp=null;function MM(e,t){if(typeof document>"u")return t.length*8;kp??(kp=document.createElement("canvas"));const n=kp.getContext("2d");if(!n)return t.length*8;const r=window.getComputedStyle(e),i=r.fontStyle||"normal",o=r.fontWeight||"600",a=r.fontSize||"13px",c=r.fontFamily||"system-ui";return n.font=`${i} ${o} ${a} ${c}`,n.measureText(t).width}function RM({labels:e,triggerWidth:t,maxWidth:n,preferredWidth:r,measureText:i}){const o=e.reduce((a,c)=>Math.max(a,Math.ceil(i(c)+EM)),0);return Math.min(n,Math.max(t,hb,r,o))}function xp({triggerId:e,ariaLabel:t,value:n,options:r,onChange:i,disabled:o=!1,compact:a=!1,className:c}){const[u,d]=f.useState(!1),h=f.useRef(null),p=f.useRef(null),m=f.useRef(null),[g,x]=f.useState(null),S=f.useId(),C=r.find(j=>j.value===n)??r[0]??null,y=f.useMemo(()=>r.map(j=>j.label),[r]),A=f.useCallback(()=>{const j=p.current;if(!j||typeof window>"u")return;const V=j.getBoundingClientRect(),L=window.innerWidth,I=window.innerHeight,G=12,q=10,P=Math.max(hb,L-G*2),T=a?IM:TM,H=RM({labels:y,triggerWidth:V.width,maxWidth:P,preferredWidth:T,measureText:U=>MM(j,U)}),_=Math.min(Math.max(G,V.left),Math.max(G,L-H-G)),ie=V.top-G,Y=I-V.bottom-G,W=ie>=180||ie>=Y;x({position:"fixed",left:_,width:H,maxWidth:P,zIndex:1905,top:W?void 0:V.bottom+q,bottom:W?I-V.top+q:void 0})},[a,y]);return f.useEffect(()=>{if(!u)return;function j(L){var G,q;const I=L.target;!((G=h.current)!=null&&G.contains(I))&&!((q=m.current)!=null&&q.contains(I))&&d(!1)}function V(L){L.key==="Escape"&&d(!1)}return window.addEventListener("pointerdown",j),window.addEventListener("keydown",V),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),A(),()=>{window.removeEventListener("pointerdown",j),window.removeEventListener("keydown",V),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[u,A]),C?s.jsxs("div",{ref:h,className:`composer-mac-select ${a?"is-compact":""}${c?` ${c}`:""}`,"data-open":u?"true":"false",children:[s.jsxs("button",{id:e,ref:p,type:"button",className:"composer-mac-select-trigger","aria-label":t,"aria-haspopup":"listbox","aria-expanded":u,"aria-controls":S,disabled:o,onClick:()=>d(j=>!j),children:[s.jsx("span",{className:"composer-mac-select-label",children:C.label}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),u&&g&&typeof document<"u"?ur.createPortal(s.jsx("div",{ref:m,className:"composer-mac-select-popover",style:g,role:"presentation",children:s.jsx("div",{id:S,className:"composer-mac-select-list",role:"listbox","aria-label":t,children:r.map(j=>{const V=j.value===n;return s.jsxs("button",{type:"button",role:"option","aria-selected":V,className:`composer-mac-select-option ${V?"is-selected":""}`,onClick:()=>{i(j.value),d(!1)},children:[s.jsx("span",{className:"composer-mac-select-option-check","aria-hidden":"true",children:V?"✓":""}),s.jsx("span",{className:"composer-mac-select-option-label",children:j.label})]},j.value)})})}),document.body):null]}):null}const ia=["codex","claude-code","gemini"];function pb(e){return{provider:e,model:"",providerConfigMode:"global-default",providerPresetId:null,memberPrompt:"",workspaceIsolationMode:"none"}}function yp(e,t){return Array.from({length:t},()=>pb(e))}function sc(e,t){var n;return(n=e==null?void 0:e.modelOptions)!=null&&n.length?e.modelOptions:su(t).modelOptions??[]}function wp(e,t,n){return t!=="cc-switch-preset"||!n?null:`${e}::${n}`}function vp(e,t){return Math.max(0,e-t.length)}function AM({open:e,source:t,onClose:n,onCreated:r}){const i=f.useId(),o=(t==null?void 0:t.defaultProvider)??"codex",a=(t==null?void 0:t.kind)==="group",c=(t==null?void 0:t.kind)==="group"?Math.max(0,4-t.currentMemberCount):4,u=f.useMemo(()=>(t==null?void 0:t.kind)==="group"?Array.from({length:c},(E,$)=>$+1):[2,3,4],[c,t==null?void 0:t.kind]),d=(t==null?void 0:t.kind)==="group"?1:2,h=(t==null?void 0:t.kind)==="group"?t.sharedPrompt:"",{visibleProviders:p}=jk(Mk,e),[m,g]=f.useState(h),[x,S]=f.useState(d),[C,y]=f.useState(()=>yp(o,d)),[A,j]=f.useState({}),[V,L]=f.useState({}),[I,G]=f.useState({}),[q,P]=f.useState({}),[T,H]=f.useState({}),[_,ie]=f.useState(!1),[Y,W]=f.useState(!1),[U,D]=f.useState(null),[K,ee]=f.useState(null),[v,Ne]=f.useState({}),ve=f.useRef(!1),N=f.useRef({});f.useEffect(()=>{if(!e)return;const E=(t==null?void 0:t.defaultProvider)??"codex",$=(t==null?void 0:t.kind)==="group"?1:2;g((t==null?void 0:t.kind)==="group"?t.sharedPrompt:""),S($),y(yp(E,$)),j({}),L({}),G({}),P({}),H({}),ie(!1),W(!1),D(null),ee(null),Ne({}),ve.current=!1,Object.keys(N.current).forEach(se=>{delete N.current[se]})},[e,t==null?void 0:t.defaultProvider,t==null?void 0:t.kind,t==null?void 0:t.workspaceId,(t==null?void 0:t.kind)==="session"?t.sessionId:null,(t==null?void 0:t.kind)==="group"?t.groupId:null,(t==null?void 0:t.kind)==="group"?t.sharedPrompt:null]),f.useEffect(()=>{y(E=>{var ue;if(E.length===x)return E;if(E.length>x)return E.slice(0,x);const $=E.slice(),se=((ue=E[0])==null?void 0:ue.provider)??o;for(;$.length<x;)$.push(pb(se));return $})},[o,x]),f.useEffect(()=>{u.length!==0&&S(E=>u.includes(E)?E:u[0]??E)},[u]),f.useEffect(()=>{if(!e||!t)return;let E=!1;return ie(!0),Tk(p,t.workspaceId).then($=>{E||j($)}).finally(()=>{E||ie(!1)}),()=>{E=!0}},[e,t==null?void 0:t.workspaceId,p]),f.useEffect(()=>{e&&(ve.current||(ve.current=!0,G(E=>({...E,...Object.fromEntries(ia.map($=>[$,!0]))})),Ik().then(E=>{const $=Object.fromEntries(E.items.map(se=>[se.app,se]));L(Object.fromEntries(ia.map(se=>[se,$[se]??null])))}).catch(()=>{L(Object.fromEntries(ia.map(E=>[E,null])))}).finally(()=>{G(E=>({...E,...Object.fromEntries(ia.map($=>[$,!1]))}))})))},[e]),f.useEffect(()=>{if(!e||!t)return;const E=Array.from(new Set(C.map($=>{const se=sa($.providerConfigMode,$.providerPresetId);return wp($.provider,se.providerConfigMode,se.providerPresetId)}).filter($=>$!==null))).filter($=>q[$]===void 0&&!N.current[$]);if(E.length!==0)for(const $ of E){const[se,ue]=$.split("::");N.current[$]=!0,H(we=>({...we,[$]:!0})),mf(se,t.workspaceId,{providerConfigMode:"cc-switch-preset",providerPresetId:ue}).then(we=>{P(z=>({...z,[$]:we}))}).catch(()=>{P(we=>({...we,[$]:null}))}).finally(()=>{delete N.current[$],H(we=>({...we,[$]:!1}))})}},[q,C,e,t]);const de=f.useMemo(()=>p.filter(E=>{const $=A[E];return $?$.canStartSession!==!1:!1}),[A,p]);f.useEffect(()=>{if(!de.length)return;const E=de.includes(o)?o:de[0];y($=>{let se=!1;const ue=$.map(we=>de.includes(we.provider)?we:(se=!0,{...we,provider:E,providerConfigMode:"global-default",providerPresetId:null,model:""}));return se?ue:$})},[de,o]);const Ee=f.useMemo(()=>C.map((E,$)=>{var qe;const se=sa(E.providerConfigMode,E.providerPresetId),ue=vM(E.provider),we=ue?V[ue]??null:null,z=SM(we),X=se.providerConfigMode==="cc-switch-preset"?se.providerPresetId??ba:ba,ge=z.find(ft=>ft.value===X)??z[0]??null,ye=wp(E.provider,se.providerConfigMode,se.providerPresetId),De=A[E.provider]??null,He=ye?q[ye]??null:null,lt=(se.providerConfigMode==="cc-switch-preset"?He?sc(He,E.provider):[{id:Hi,name:l("conversation.modelUseCliDefault"),usesProviderDefault:!0}]:sc(De,E.provider)).map(ft=>({value:ft.id,label:CM(ft)?l("conversation.modelUseCliDefault"):ft.name})),Ve=E.model.trim()||Hi,tt=((qe=lt.find(ft=>ft.value===Ve))==null?void 0:qe.label)??l("conversation.modelUseCliDefault"),Je=NM(we),nt=ue!==null,pt=ye?T[ye]===!0:!1,Ft=!!(ye&&pt&&He===null);return{index:$,draft:E,supportsDeploymentPicker:nt,showPresetColumn:Je,deploymentPresetOptions:z,selectedPresetValue:X,selectedPresetOption:ge,triggerLabel:Je?`${(ge==null?void 0:ge.label)??l("conversation.deploymentDefaultPreset")} · ${tt}`:tt,selectedModelValue:Ve,modelOptions:lt,loadingPresets:ue?I[ue]===!0:!1,loadingModels:pt,modelColumnDisabled:Ft}}),[q,V,I,T,C,A]);if(f.useEffect(()=>{e&&y(E=>{let $=!1;const se=E.map((ue,we)=>{const z=Ee[we];if(!z)return ue;let X=ue;const ge=sa(ue.providerConfigMode,ue.providerPresetId);ge.providerConfigMode==="cc-switch-preset"&&ge.providerPresetId&&!z.loadingPresets&&!z.deploymentPresetOptions.some(He=>He.value===ge.providerPresetId)&&(X={...X,providerConfigMode:"global-default",providerPresetId:null,model:""},$=!0);const ye=new Set(z.modelOptions.map(He=>He.value)),De=X.model.trim()||Hi;return ye.has(De)||(X={...X,model:""},$=!0),X});return $?se:E})},[Ee,e]),!e||!t)return null;const me=t,le=K?vp(C.length,K.memberFailures):0,We=new Set(K?C.map((E,$)=>$).filter(E=>!(E in v)):[]),Ue=me.kind==="group"?l("shell.parallelAppendModalTitle"):l("shell.parallelCreateModalTitle"),Fe=me.kind==="session"?`${me.workspaceName} · ${me.sessionTitle}`:me.workspaceName,rt=me.kind==="group"?l("shell.parallelAppendSharedPromptLabel"):l("shell.parallelCreateSharedPromptLabel"),F=me.kind==="group"?l("shell.parallelAppendCountLabel"):l("shell.parallelCreateCountLabel"),ne=me.kind==="group"?l("shell.parallelAppendSubmit"):l("shell.parallelCreateSubmit"),re=me.kind==="group"?l("shell.parallelAppendSubmitting"):l("shell.parallelCreateSubmitting"),Se=U??(me.kind==="group"&&c===0?l("shell.parallelAppendNoRemainingSlots"):null)??(!_&&de.length===0?l("shell.parallelCreateNoAvailableProviders"):null),ke={"--parallel-member-columns":String(Math.max(1,Math.min(x,4)))};function pe(E){D(null),ee(null),Ne($=>{if(!(E in $))return $;const se={...$};return delete se[E],se})}function xt(){D(null),ee(null),Ne({})}function Xe(E,$){pe(E);const se=$?"temporary_worktree":"none";y(ue=>ue.map((we,z)=>z===E?{...we,workspaceIsolationMode:se}:we))}async function st(){const E=m.trim();if(!a&&!E){D(l("shell.parallelCreatePromptRequired"));return}if(me.kind==="group"&&c===0){D(l("shell.parallelAppendNoRemainingSlots"));return}if(!de.length){D(l("shell.parallelCreateNoAvailableProviders"));return}W(!0),D(null),ee(null),Ne({});try{const $=wM(),se=C.map(we=>{const z=sa(we.providerConfigMode,we.providerPresetId);return{provider:we.provider,model:we.model.trim()||null,providerConfigMode:z.providerConfigMode,providerPresetId:z.providerConfigMode==="cc-switch-preset"?z.providerPresetId:null,memberPrompt:we.memberPrompt.trim()||null,workspaceIsolationMode:we.workspaceIsolationMode}}),ue=me.kind==="group"?await Rk(me.groupId,{permissionMode:$,members:se}):me.kind==="session"?await Ak(me.sessionId,{sharedPrompt:E,permissionMode:$,members:se}):await Pk(me.workspaceId,{sharedPrompt:E,permissionMode:$,members:se});if(ue.memberFailures.length>0){const we=vp(C.length,ue.memberFailures);ee(ue),Ne(Object.fromEntries(ue.memberFailures.map(z=>[z.ordinal,z]))),D(we>0?l("shell.parallelCreatePartialFailure",{successCount:we,failureCount:ue.memberFailures.length}):l("shell.parallelCreateAllFailed",{failureCount:ue.memberFailures.length}));return}await r(ue)}catch($){D($ instanceof Error?$.message:l("shell.parallelGroupLoadFailed"))}finally{W(!1)}}return s.jsx(iu,{open:e,title:Ue,description:Fe,size:"xwide",layout:"form",className:"parallel-create-modal",bodyClassName:"parallel-create-modal-body",dismissible:!Y,onClose:n,footer:s.jsxs(Ek,{align:"between",className:"parallel-create-modal-footer",children:[s.jsx("div",{className:"parallel-create-modal-status",role:"status","aria-live":"polite",children:Se?s.jsx("span",{className:"parallel-create-modal-error",children:Se}):null}),s.jsxs("div",{className:"parallel-create-modal-footer-actions",children:[K&&le>0?s.jsx("button",{type:"button",className:"secondary-button",disabled:Y,onClick:()=>{r(K)},children:l("shell.parallelCreateContinuePartial")}):null,s.jsx("button",{type:"button",className:"secondary-button",disabled:Y,onClick:n,children:l("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:Y||_||de.length===0||me.kind==="group"&&c===0,onClick:()=>{st()},children:Y?re:ne})]})]}),children:s.jsxs("div",{className:"parallel-create-layout",children:[s.jsx(Ys,{className:"parallel-create-shared-section",tone:"accent",children:s.jsxs("div",{className:"parallel-create-target-row",children:[s.jsx(Hs,{className:"parallel-create-target-field",label:rt,htmlFor:`${i}-shared-prompt`,children:s.jsx("textarea",{id:`${i}-shared-prompt`,className:"parallel-create-textarea parallel-create-textarea-target",rows:2,value:m,readOnly:a,"aria-readonly":a,"data-readonly":a?"true":void 0,onChange:E=>{a||(xt(),g(E.target.value))}})}),s.jsx(Hs,{className:"parallel-create-count-field",label:F,children:s.jsx("div",{className:"parallel-create-count-group",role:"group","aria-label":F,children:u.map(E=>s.jsx("button",{type:"button",className:"parallel-create-count-button","data-active":x===E,onClick:()=>{xt(),S(E)},children:E},E))})})]})}),s.jsx(Ys,{className:"parallel-create-members-section",heading:l("shell.parallelCreateMembersTitle"),children:s.jsx("div",{className:"parallel-create-member-list",style:ke,children:Ee.map(({draft:E,index:$,supportsDeploymentPicker:se,showPresetColumn:ue,deploymentPresetOptions:we,selectedPresetValue:z,selectedPresetOption:X,triggerLabel:ge,selectedModelValue:ye,modelOptions:De,loadingPresets:He,loadingModels:yt,modelColumnDisabled:lt})=>{var Ft;const Ve=de,tt=Ve.includes(E.provider)?E.provider:"",Je=Ve.length>0?Ve.map(qe=>({value:qe,label:pc(qe,"full")})):[{value:"",label:_?l("shell.parallelCreateProvidersLoading"):l("shell.parallelCreateNoAvailableProviders")}],nt=sc(A[E.provider]??null,E.provider),pt=nt.length>0?[{value:"",label:((Ft=nt.find(qe=>qe.usesProviderDefault===!0))==null?void 0:Ft.name)??l("shell.parallelPaneModelFallback")},...nt.filter(qe=>qe.usesProviderDefault!==!0).map(qe=>({value:qe.id,label:qe.name}))]:[{value:"",label:l("shell.parallelCreateNoModelsAvailable")}];return s.jsxs("article",{className:"parallel-create-member-card","data-state":v[$]?"error":We.has($)?"success":void 0,children:[s.jsxs("header",{className:"parallel-create-member-header",children:[s.jsxs("div",{className:"parallel-create-member-title-block",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberTitle",{index:$+1})}),s.jsx("span",{className:"parallel-create-member-provider",children:pc(E.provider,"full")}),s.jsxs("label",{className:"parallel-create-isolation-toggle",children:[s.jsx("input",{type:"checkbox",checked:E.workspaceIsolationMode==="temporary_worktree",onChange:qe=>{Xe($,qe.target.checked)}}),s.jsx("span",{className:"parallel-create-isolation-copy",children:l("shell.parallelCreateIsolationLabel")})]})]}),v[$]?s.jsx("span",{className:"parallel-create-member-status error",children:l("shell.parallelCreateMemberFailed")}):We.has($)?s.jsx("span",{className:"parallel-create-member-status success",children:l("shell.parallelCreateMemberSucceeded")}):null]}),s.jsxs("div",{className:"parallel-create-member-grid",children:[s.jsx(Hs,{label:l("shell.createSessionProviderLabel"),htmlFor:`${i}-member-${$}-provider`,children:s.jsx(xp,{triggerId:`${i}-member-${$}-provider`,className:"parallel-create-provider-select",ariaLabel:l("shell.createSessionProviderLabel"),value:tt,options:Je,disabled:!Ve.length,onChange:qe=>{pe($);const ft=qe;y(_e=>_e.map((Nt,Qe)=>Qe===$?{...Nt,provider:ft,providerConfigMode:"global-default",providerPresetId:null,model:""}:Nt))}})}),s.jsx(Hs,{label:l("shell.parallelCreateModelLabel"),htmlFor:se?void 0:`${i}-member-${$}-model`,children:se?s.jsx("div",{className:"parallel-create-deployment-select",children:s.jsx(jM,{triggerId:`${i}-member-${$}-model`,ariaLabel:l("shell.parallelCreateModelLabel"),triggerLabel:ge,presetOptions:we,selectedPresetValue:z,selectedPresetSummary:(X==null?void 0:X.summary)??null,onSelectPreset:qe=>{pe($),y(ft=>ft.map((_e,Nt)=>Nt!==$?_e:qe===ba?{..._e,providerConfigMode:"global-default",providerPresetId:null,model:""}:{..._e,providerConfigMode:"cc-switch-preset",providerPresetId:qe,model:""}))},modelOptions:De,selectedModelValue:ye,onSelectModel:qe=>{pe($),y(ft=>ft.map((_e,Nt)=>Nt===$?{..._e,model:qe===Hi?"":qe}:_e))},loadingPresets:He,loadingModels:yt,modelColumnDisabled:lt,showPresetColumn:ue,modelEmptyText:l("conversation.deploymentModelEmpty")})}):s.jsx(xp,{triggerId:`${i}-member-${$}-model`,className:"parallel-create-provider-select",ariaLabel:l("shell.parallelCreateModelLabel"),value:E.model,options:pt,disabled:!Ve.length||nt.length===0,onChange:qe=>{pe($),y(ft=>ft.map((_e,Nt)=>Nt===$?{..._e,model:qe}:_e))}})})]}),s.jsx(Hs,{label:l("shell.parallelCreateMemberPromptLabel"),htmlFor:`${i}-member-${$}-prompt`,children:s.jsx("textarea",{id:`${i}-member-${$}-prompt`,className:"parallel-create-textarea member",rows:2,value:E.memberPrompt,onChange:qe=>{pe($);const ft=qe.target.value;y(_e=>_e.map((Nt,Qe)=>Qe===$?{...Nt,memberPrompt:ft}:Nt))}})}),v[$]?s.jsxs("div",{className:"parallel-create-member-error",role:"alert",children:[s.jsx("strong",{children:l("shell.parallelCreateMemberErrorTitle")}),s.jsx("p",{children:v[$].detail})]}):null]},`parallel-member-${$}`)})})})]})})}const PM=12,LM=180,Sp=72;function DM(e,t){const[n,r]=f.useState(!1),[i,o]=f.useState(""),[a,c]=f.useState({}),[u,d]=f.useState({}),[h,p]=f.useState(!1),[m,g]=f.useState(null);f.useEffect(()=>{e||(r(!1),o(""),g(null))},[e]),f.useEffect(()=>{if(!e||!n)return;const C=t.filter(A=>u[A.sessionId]!==!0);if(C.length===0)return;let y=!1;return p(!0),g(null),Promise.allSettled(C.map(async A=>{const j=await pf(A.sessionId,null,PM,"backward");return{sessionId:A.sessionId,summary:_M(j.messages)}})).then(A=>{if(y)return;const j={},V={};let L=0;C.forEach(I=>{j[I.sessionId]=!0});for(const I of A){if(I.status==="fulfilled"){V[I.value.sessionId]=I.value.summary;continue}L+=1}d(I=>({...I,...j})),Object.keys(V).length>0&&c(I=>({...I,...V})),g(L>0?l("shell.archiveSearchSummaryFailed"):null)}).finally(()=>{y||p(!1)}),()=>{y=!0}},[u,e,n,t]);const x=f.useMemo(()=>{const C=ic(i);return C?t.filter(y=>ic(y.title).includes(C)?!0:ic(a[y.sessionId]??"").includes(C)):t},[i,t,a]);function S(){r(C=>{const y=!C;return y||(o(""),g(null)),y})}return{searchOpen:n,searchKeyword:i,filteredSessions:x,summaryLoading:h,summaryError:m,summaryBySessionId:a,setSearchKeyword:o,toggleSearch:S}}function _M(e){const t=[...e].sort((r,i)=>r.sequence-i.sequence).map(BM).filter(r=>r.length>0);if(t.length===0)return"";const n=t.slice(-3).join(" · ");return qc(n,LM)}function BM(e){var n,r;const t=fb(e.content);return t.length>0?qc(t,Sp):(r=(n=e.toolCall)==null?void 0:n.name)!=null&&r.trim()?qc(e.toolCall.name.trim(),Sp):""}function ic(e){return fb(e).toLocaleLowerCase()}function fb(e){return e.replace(/\s+/g," ").trim()}function qc(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}const Cp="workbench.left.width",Np="workbench.right.width",jp="workbench.left.collapsed",Tp="workbench.right.collapsed",oa="workbench.last.session.path",oc="workbench.workspace.selected.id",Ip="workbench.notifications.seen_at",OM=280,WM=320,Ep=240,Mp=280,Rp=520,Ap=560,FM=200,ac=20,Bi=40,aa=5,$M=3e4,zM=12,Pp=60*1e3,HM=4e3,Lp=220,Dp=18,UM=6,zs="data-workbench-panel-resizing",la="data-workbench-window-resizing",qM=180,GM="workbench:focus-composer",VM=new Set(["starting","running","reconnecting","stale","unknown"]),KM=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],YM=["--workbench-titlebar-live-content-shift-y","--workbench-nav-toolbar-live-shift-y","--workbench-info-tabs-live-shift-y","--workbench-auxiliary-toolbar-button-live-shift-y","--workbench-conversation-header-main-live-shift-y","--workbench-conversation-header-actions-live-shift-y","--workbench-terminal-tabbar-live-shift-y","--workbench-collapsed-controls-live-shift-y","--workbench-collapsed-left-controls-live-shift-y","--workbench-collapsed-right-controls-live-shift-y"],kt={navToolbar:{selector:".workbench-nav-toolbar",variableName:"--workbench-nav-toolbar-live-shift-y"},infoTabs:{selector:".workbench-info-tabs",variableName:"--workbench-info-tabs-live-shift-y"},auxiliaryToolbarButton:{selector:".workbench-auxiliary-header > .workbench-nav-toolbar-button",variableName:"--workbench-auxiliary-toolbar-button-live-shift-y"},conversationHeaderMain:{selector:".conversation-header-main",variableName:"--workbench-conversation-header-main-live-shift-y"},conversationHeaderActions:{selector:".conversation-header-actions",variableName:"--workbench-conversation-header-actions-live-shift-y"},terminalTabbarMain:{selector:".terminal-tabbar-main",variableName:"--workbench-terminal-tabbar-live-shift-y"},collapsedLeftControls:{selector:'.workbench-collapsed-controls.left[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-left-controls-live-shift-y"},collapsedRightControls:{selector:'.workbench-collapsed-controls.right[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-right-controls-live-shift-y"}};function mb(e,t){const n=e.getPropertyValue(t).trim();if(!n)return null;const r=Number.parseFloat(n);return Number.isFinite(r)?r:null}function XM(e){return Math.round(e*100)/100}function JM(e,t){const n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return null;const r=window.getComputedStyle(t);return r.display==="none"||r.visibility==="hidden"?null:n.top-e.top+n.height/2}function Rr(e,t){const n=e.getBoundingClientRect(),i=Array.from(e.querySelectorAll(t)).map(o=>JM(n,o)).filter(o=>o!==null);return i.length===0?null:i.reduce((o,a)=>o+a,0)/i.length}function Jn(e,t,n){const r=e.style.getPropertyValue(t).trim();if(n===null||!Number.isFinite(n)){r&&e.style.removeProperty(t);return}const i=`${XM(n)}px`;r!==i&&e.style.setProperty(t,i)}function Qn(e,t,n,r){return r===null?null:(mb(e,t)??0)+(n-r)}function _p(e){if(e)for(const t of YM)e.style.removeProperty(t)}function QM(e){return VM.has(e.runningState??"idle")||e.activityState==="running"}function ZM(e,t){const n=[];for(const r of[...t].sort()){const i=e.get(r);!i||i.size===0||n.push(`${r}:${[...i].sort().join(",")}`)}return n.join("|")}function eR(e){var i,o;const t=((i=e.lastErrorCode)==null?void 0:i.trim())??"",n=((o=e.lastErrorDetail)==null?void 0:o.trim())??"",r=[t,n].filter(a=>a.length>0).join(" · ");return r?r.length<=Lp?r:`${r.slice(0,Lp-3)}...`:null}function tR(e,t,n){var o,a,c,u,d,h,p,m,g,x,S,C;const r=new Map(e.projects.map(y=>[y.id,y.workspaceId])),i=[];for(const y of n){const A=y.title.trim()||y.projectName;if(y.assistantState.lifecycleStage==="analyzed"&&!((o=y.assistantState.linkedSessionId)!=null&&o.trim())&&y.assistantState.lastAnalyzedAt){i.push({id:`todo-analysis-completed:${y.id}:${y.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:l("shell.globalNotificationTodoAnalyzedTitle",{title:A}),body:((a=y.assistantState.analysisSummary)==null?void 0:a.trim())||((c=y.assistantState.generatedPrompt)==null?void 0:c.trim())||y.content,routePath:cs(y.workspaceId),workspaceId:y.workspaceId,createdAt:y.assistantState.lastAnalyzedAt});continue}y.assistantState.lifecycleStage==="failed"&&i.push({id:`todo-analysis-failed:${y.id}:${y.updatedAt}`,kind:"todo_analyze_failed",title:l("shell.globalNotificationTodoAnalyzeFailedTitle",{title:A}),body:((u=y.assistantState.lastError)==null?void 0:u.trim())||y.content,routePath:cs(y.workspaceId),workspaceId:y.workspaceId,createdAt:y.updatedAt})}for(const y of t){const A=((d=y.sessionTitle)==null?void 0:d.trim())||y.projectName,j=y.updatedAt||y.lastAutomationAt||y.createdAt;if(y.status==="waiting_user"){i.push({id:`follow-up-waiting:${y.id}`,kind:"follow_up_waiting_user",title:l("shell.globalNotificationFollowUpWaitingTitle",{title:A}),body:((h=y.waitingReason)==null?void 0:h.trim())||((p=y.lastAutomationSummary)==null?void 0:p.trim())||y.objective,routePath:_n(y.workspaceId,y.sessionId),workspaceId:y.workspaceId,createdAt:j});continue}if(y.status==="completed"){i.push({id:`follow-up-completed:${y.id}`,kind:"follow_up_completed",title:l("shell.globalNotificationFollowUpCompletedTitle",{title:A}),body:((m=y.lastAutomationSummary)==null?void 0:m.trim())||y.objective,routePath:_n(y.workspaceId,y.sessionId),workspaceId:y.workspaceId,createdAt:j});continue}y.status==="failed"&&i.push({id:`follow-up-failed:${y.id}`,kind:"follow_up_failed",title:l("shell.globalNotificationFollowUpFailedTitle",{title:A}),body:((g=y.lastAutomationSummary)==null?void 0:g.trim())||((x=y.waitingReason)==null?void 0:x.trim())||y.objective,routePath:_n(y.workspaceId,y.sessionId),workspaceId:y.workspaceId,createdAt:j})}for(const y of e.verifications){if(y.status!=="failed")continue;const A=y.projectId?r.get(y.projectId)??null:null,j=((S=y.targetRef)==null?void 0:S.trim())||y.verificationType;i.push({id:`verification-failed:${y.id}`,kind:"verification_failed",title:l("shell.globalNotificationVerificationFailedTitle",{title:j}),body:((C=y.summary)==null?void 0:C.trim())||l("shell.globalNotificationVerificationFailedFallback"),routePath:A?cs(A):null,workspaceId:A,createdAt:y.finishedAt||y.startedAt||y.createdAt})}return i.sort((y,A)=>{const j=Bp(y.kind)-Bp(A.kind);return j!==0?j:Dr(A.createdAt)-Dr(y.createdAt)}).slice(0,zM)}function Bp(e){switch(e){case"follow_up_waiting_user":return 0;case"todo_analyze_failed":return 1;case"follow_up_failed":return 2;case"verification_failed":return 3;case"todo_analyzed":return 4;case"follow_up_completed":return 5;default:return 9}}function nR(e){switch(e){case"follow_up_waiting_user":return l("shell.globalNotificationKindWaitingUser");case"todo_analyzed":return l("shell.globalNotificationKindTodoAnalyzed");case"todo_analyze_failed":return l("shell.globalNotificationKindTodoAnalyzeFailed");case"follow_up_completed":return l("shell.globalNotificationKindFollowUpCompleted");case"follow_up_failed":return l("shell.globalNotificationKindFollowUpFailed");case"verification_failed":return l("shell.globalNotificationKindVerificationFailed");default:return l("shell.globalNotificationsPanelTitle")}}function Dr(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function rR(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function sR(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function iR(e,t){const n=new Set,r=(e==null?void 0:e.currentBranch)??"",i=((e==null?void 0:e.local)??[]).slice().sort((c,u)=>Number(u.current)-Number(c.current)||c.name.localeCompare(u.name)).map(c=>({value:c.name,current:c.current,recommended:c.name===r})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),o=((e==null?void 0:e.remote)??[]).map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),a=t.map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0));return{localBranches:i,remoteBranches:o,tags:a}}function oR(e){return e.getBoundingClientRect()}function aR(e,t){return t?Dr(e.createdAt)>Dr(t):!0}function lR(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function Op(e,t){var a,c;const n=["/workspaces/:workspaceId","/workspaces/:workspaceId/sessions","/workspaces/:workspaceId/sessions/:sessionId","/workspaces/:workspaceId/tools","/workspaces/:workspaceId/tools/files","/workspaces/:workspaceId/tools/git","/workspaces/:workspaceId/tools/processes","/workspaces/:workspaceId/terminals","/workspaces/:workspaceId/butler"];for(const u of n){const d=at(u,e),h=(a=d==null?void 0:d.params.workspaceId)==null?void 0:a.trim();if(h)return h}const r=Xi(e),i=(r==null?void 0:r.sessionId)??null;return!i||!Vb(i)?null:((c=new URLSearchParams(t).get("workspaceId"))==null?void 0:c.trim())||null}function cR(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function lc(e){return e==="mobile"?Zt():"/landing"}function Xi(e){var o,a,c;const t=at("/workspaces/:workspaceId/sessions/:sessionId",e),n=(o=t==null?void 0:t.params.sessionId)==null?void 0:o.trim();if(n)return{sessionId:n,workspaceId:((a=t==null?void 0:t.params.workspaceId)==null?void 0:a.trim())??null};const r=at("/sessions/:sessionId",e),i=(c=r==null?void 0:r.params.sessionId)==null?void 0:c.trim();return i?{sessionId:i,workspaceId:null}:null}function uR(e){return!!(at("/sessions",e)||at("/workspaces/:workspaceId/sessions",e))}function Wp(e){return!!Xi(e)}function dR(e){return!!(at("/tools",e)||at("/tools/files",e)||at("/tools/git",e)||at("/tools/processes",e)||at("/workspaces/:workspaceId/tools",e)||at("/workspaces/:workspaceId/tools/files",e)||at("/workspaces/:workspaceId/tools/git",e)||at("/workspaces/:workspaceId/tools/processes",e))}function ka(e){return!!(at("/terminals",e)||at("/workspaces/:workspaceId/terminals",e))}function xa(e){return!!at("/workspaces/:workspaceId/butler",e)}function hR(e,t){return at("/workspaces/:workspaceId/debug",e)?Af(t):at("/workspaces/:workspaceId",e)?rr(t):at("/workspaces/:workspaceId/tools/files",e)||at("/tools/files",e)?Lf(t):at("/workspaces/:workspaceId/tools/git",e)||at("/tools/git",e)?Df(t):at("/workspaces/:workspaceId/tools/processes",e)||at("/tools/processes",e)?_f(t):at("/workspaces/:workspaceId/tools",e)||at("/tools",e)?Pf(t):ka(e)?is(t):xa(e)?cs(t):ii(t)}function pR(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const fR=f.lazy(async()=>({default:(await tu(()=>import("./FileContextPanel-h0kvRbSR.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).FileContextPanel})),mR=f.lazy(async()=>({default:(await tu(()=>import("./GitSidebar-TlaPNhxG.js"),__vite__mapDeps([11,1,2,3,4,5,7,6,8,9,10]))).GitSidebar})),gR=f.lazy(async()=>({default:(await tu(()=>import("./TerminalManagerPanel-Bkgr9ZNV.js"),__vite__mapDeps([12,1,2,6,3,4,5,13,14,8,9,10]))).TerminalManagerPanel}));function bR(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function an(e){return ci(e)}function kR(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function Ks(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(bR):[]}async function gb(e,t){const n=await mf(t,e);if(n.canStartSession===!1)throw new Error(n.limitations[0]??l("conversation.capabilityDenied"))}const bb=f.createContext(null);function Oa(e){return xI(e)}function tr(e){return e.isArchived===!0}function go(e){return Tf(e)}function kb(e,t){return uu(e,{getId:n=>n.sessionId,getParentId:go,compare:(n,r)=>oo(n,r,t)})}function xR(e,t){const n=yR(e);return xb(n,t)}function xb(e,t){const n=wR(e);return uu(n,{getId:r=>r.session.sessionId,getParentId:r=>go(r.session),compare:(r,i)=>oo(r.session,i.session,t)}).map(r=>wb(r))}function yR(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...yb(t.childWorktrees)])}function yb(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...yb(t.children)])}function wR(e){const t=[],n=new Set;for(const r of e){const i=r.session.sessionId.trim();!i||n.has(i)||(n.add(i),t.push(r))}return t}function wb(e,t=0){return{item:e.item.session,depth:t,children:e.children.map(n=>wb(n,t+1))}}function Gc(e,t){return{...e,depth:e.depth+t,children:an(e).map(n=>Gc(n,t))}}function Fp(e){return`${e}::parallel-anchor-member`}function $p(e){const{session:t,depth:n,children:r}=e;return{item:t,depth:n,children:[...r]}}function Vc(e,t){for(const n of e){if(n.item.sessionId===t)return n;const r=Vc(an(n),t);if(r)return r}return null}function vR(e,t){const n=t.trim();if(!n)return null;for(const r of e){const i=vb(r,n,null);if(i)return i}return null}function vb(e,t,n){var i,o;const r=((o=(i=e.item.parallelGroup)==null?void 0:i.groupId)==null?void 0:o.trim())||n;if(e.item.sessionId===t)return r;for(const a of an(e)){const c=vb(a,t,r);if(c)return c}return null}function Sb(e){return e.filter(t=>{if(tr(t))return!1;const n=go(t);if(!n)return!0;const r=e.find(i=>i.sessionId===n);return r&&tr(r)?!Oa(t):!0})}function SR(e){return e.flatMap(t=>{const n=kR(t);return n?[n,...Ef(an(t))]:[]})}function CR(e,t,n){var m;const r=an(e),i=ss(r).sort((g,x)=>oo(g.item,x.item,n));if(!(((m=e.item.parallelGroup)==null?void 0:m.role)==="anchor"&&r.some(g=>{var x,S;return((x=g.item.parallelGroup)==null?void 0:x.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}))){const g=new Set(i.slice(0,Math.max(0,t)).map(x=>x.item.sessionId));return{...e,children:Kc(r,g)}}const a=r.slice().sort((g,x)=>oo(g.item,x.item,n)),c=a.filter(g=>{var x,S;return((x=g.item.parallelGroup)==null?void 0:x.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(g=>g.item.sessionId),u=a.filter(g=>{var x,S;return((x=g.item.parallelGroup)==null?void 0:x.groupId)!==((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(g=>g.item.sessionId),d=[...c,...u],h=Math.max(0,t-d.length),p=new Set(d);for(const g of i){if(p.size>=d.length+h)break;p.add(g.item.sessionId)}return{...e,children:Kc(r,p)}}function Kc(e,t){return e.flatMap(n=>{const r=Kc(an(n),t);return!t.has(n.item.sessionId)&&r.length===0?[]:[{...n,children:r}]})}function ca(e,t,n,r=-1){if(e<=0)return 0;const i=r>=0?Math.max(t,r+1):t;return Math.min(e,Math.max(n??0,i))}function zp(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>e[i]===t[i])}function NR(e){const t=e.lastMessageAt??e.updatedAt;return t?new Date(t).toLocaleDateString():""}function Za(e,t="compact"){return pc(e,t)}const jR={position:"relative",zIndex:0},TR={zIndex:1};function Cb(e,t,n,r){const i=[],o=(r==null?void 0:r.trim())||t.name;n&&i.push(o);const a=NR(e);return a&&i.push(a),i.join(" · ")||o}function Hp(e,t){return tT("session-state-indicator",e,t)}function IR(e,t){return Ng(e,t)}function Up(e,t){try{const n=window.localStorage.getItem(e),r=n?Number(n):Number.NaN;return Number.isFinite(r)?r:t}catch{return t}}function qp(e,t){try{const n=window.localStorage.getItem(e);return n===null?t:n==="true"}catch{return t}}function Gp(e){var t;try{const n=(t=window.localStorage.getItem(e))==null?void 0:t.trim();return n||null}catch{return null}}function rs(e,t){try{window.localStorage.setItem(e,t)}catch{}}function ER(e){try{window.localStorage.removeItem(e)}catch{}}function ua(e,t,n){return Math.max(t,Math.min(n,e))}function da(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function MR(e){const t=window.getComputedStyle(e),n=da(t.getPropertyValue("--desktop-macos-titlebar-height")),r=da(t.getPropertyValue("--workbench-header-min-height")),i=da(t.getPropertyValue("--workbench-macos-titlebar-padding-top")),o=da(t.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(n,r,40)+i+o+8}function Vp(e,t){const n=t.getBoundingClientRect();return e>=n.top&&e<=n.top+MR(t)}function RR(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function AR(){typeof window>"u"||window.dispatchEvent(new CustomEvent(GM))}function Nb(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){if(r.workspace.id===n)return r;const i=Nb(r.children,n);if(i)return i}return null}function Kp(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){const i=Nb(r.childWorktrees,n);if(i)return i}return null}function jb(e){return e.flatMap(t=>[t.workspace.id,...jb(t.children)])}function PR(e){return new Set(e.flatMap(t=>[t.workspace.id,...jb(t.childWorktrees)]))}function Yp(e){return!e||!Array.isArray(e.items)?[]:e.items.filter(t=>{var n;return t.collapsed===!0&&((n=t.workspace)==null?void 0:n.id)}).map(t=>t.workspace.id)}function cc(e,t){const n=new Set(t);return{items:e.map(r=>({workspace:r.workspace,sessions:r.sessions,childWorktrees:r.childWorktrees,collapsed:n.has(r.workspace.id)}))}}function Tb(e,t,n,r=new Set){return e.map(i=>{const o=i.sessions.filter(c=>!r.has(c.sessionId)),a=Sb(o);return{workspace:i.workspace,meta:i.meta,visibleSessions:a,archivedSessions:o.filter(c=>tr(c)&&!go(c)),visibleSessionTree:kb(a,n).filter(c=>!t.has(c.item.sessionId)&&!du(an(c),u=>t.has(u.sessionId))),children:Tb(i.children,t,n,r)}})}function Yc(e){return e.flatMap(t=>[t.workspace.id,...Yc(t.children)])}function Ui(e){return e.flatMap(t=>[...t.visibleSessionTree,...Ui(t.children)])}function Ib(e){return e.flatMap(t=>[t,...Ib(t.children)])}function LR(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:Ks(n)};const r=Eb(n.childWorktrees,t);if(r)return r}return null}function Eb(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:n.visibleSessionTree};const r=Eb(n.children,t);if(r)return r}return null}function DR(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=Mb(n.childWorktrees,t);if(r)return r}return null}function uc(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return n.workspace;const r=Rb(n.childWorktrees,t);if(r)return r}return null}function Mb(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=Mb(n.children,t);if(r)return r}return null}function Rb(e,t){for(const n of e){if(n.workspace.id===t)return n.workspace;const r=Rb(n.children,t);if(r)return r}return null}function Ab(e,t){for(const n of e){if(n.workspace.id===t)return[n.workspace.id];const r=Ab(n.children,t);if(r.length>0)return[n.workspace.id,...r]}return[]}function Xp(e){return e.flatMap(t=>[t.workspace.id,...Pb(t.childWorktrees)])}function Pb(e){return e.flatMap(t=>[t.workspace.id,...Pb(t.children)])}function _R(e,t=[]){if(e.tone!=="worktree")return e.rootDisplayName;if(t.length>0)return t.join(" / ");const n=[e.rootDisplayName];return e.parentDisplayName&&e.parentDisplayName!==e.rootDisplayName&&n.push(e.parentDisplayName),n.join(" / ")}function BR(e,t,n,r){if(t===n)return e;const i=e.findIndex(d=>d.workspace.id===t),o=e.findIndex(d=>d.workspace.id===n);if(i<0||o<0)return e;const a=[...e],[c]=a.splice(i,1);if(!c)return e;const u=a.findIndex(d=>d.workspace.id===n);return u<0?e:(a.splice(r==="before"?u:u+1,0,c),a.every((d,h)=>{var p;return d.workspace.id===((p=e[h])==null?void 0:p.workspace.id)})?e:a)}function OR(e,t){if(!Array.isArray(e.items)||t.size===0)return e;let n=!1;const r=e.items.map(i=>{let o=!1;const a=i.sessions.map(u=>{const d=t.get(u.sessionId);return d===void 0||tr(u)===d?u:(n=!0,o=!0,{...u,isArchived:d})}),c=Db(i.childWorktrees??[],t,u=>{u&&(n=!0,o=!0)});return o?{...i,sessions:a,childWorktrees:c}:i});return n?{...e,items:r}:e}function WR(e,t){if(!(!Array.isArray(t.items)||e.size===0))for(const n of t.items){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&tr(r)===i&&e.delete(r.sessionId)}_b(e,n.childWorktrees??[])}}function FR(e,t,n){let r=!1;const i=e.map(o=>{if(o.workspace.id!==t.workspaceId){const{nodes:u,changed:d}=Bb(o.childWorktrees,t,n);return d?(r=!0,{...o,childWorktrees:u}):o}const a=o.sessions.findIndex(u=>u.sessionId===t.sessionId),c=a>=0?o.sessions.map((u,d)=>d===a?t:u):[t,...o.sessions];return r=!0,{...o,sessions:mo(c,n)}});return r?i:e}function $R(e,t,n){let r=!1;const i=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t?d:(r=!0,a=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState})),u=el(o.childWorktrees,d=>d.sessionId!==t?d:(r=!0,a=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?i:e}function Jp(e,t,n){let r=!1;const i=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,a=!0,{...d,isArchived:n})),u=el(o.childWorktrees,d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,a=!0,{...d,isArchived:n}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?i:e}function Qp(e,t,n){let r=!1;const i=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,a=!0,{...d,isFavorite:n})),u=el(o.childWorktrees,d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,a=!0,{...d,isFavorite:n}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?i:e}function zR(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function HR(e){return e?e.slice(0,8):"--"}function Zp(e,t,n){return n?e.includes(t)?e:[...e,t]:e.includes(t)?e.filter(r=>r!==t):e}function Lb(e,t){const n=e.filter(r=>t.has(r));return n.length===e.length?e:n}function Db(e,t,n){return e.map(r=>{let i=!1;const o=r.sessions.map(c=>{const u=t.get(c.sessionId);return u===void 0||tr(c)===u?c:(i=!0,{...c,isArchived:u})}),a=Db(r.children,t,c=>{c&&(i=!0)});return n(i),i?{...r,sessions:o,children:a}:r})}function _b(e,t){for(const n of t){for(const r of n.sessions){const i=e.get(r.sessionId);i!==void 0&&tr(r)===i&&e.delete(r.sessionId)}_b(e,n.children)}}function Bb(e,t,n){let r=!1;const i=e.map(o=>{if(o.workspace.id===t.workspaceId){const c=o.sessions.findIndex(d=>d.sessionId===t.sessionId),u=c>=0?o.sessions.map((d,h)=>h===c?t:d):[t,...o.sessions];return r=!0,{...o,sessions:mo(u,n)}}const a=Bb(o.children,t,n);return a.changed?(r=!0,{...o,children:a.nodes}):o});return{nodes:r?i:[...e],changed:r}}function UR(e,t){return e.map(n=>({...n,sessions:mo(n.sessions,t),childWorktrees:Ku(n.childWorktrees,t)}))}function el(e,t){let n=!1;const r=e.map(i=>{let o=!1;const a=i.sessions.map(u=>{const d=t(u);return d!==u&&(o=!0,n=!0),d}),c=el(i.children,t);return c!==i.children&&(o=!0,n=!0),o?{...i,sessions:a,children:c}:i});return n?r:[...e]}function Xc(e){return`workspace-management.summary.${e}`}function Ob(e){return`git-sidebar.snapshot.${e}`}function Wb(e,t){const n=e.repoRoot??null;return{workspaceId:e.id,name:e.name,path:e.path,git:{isRepository:!!n,repoRoot:n,currentBranch:null,commitCount:null,remotes:[],error:null},codeComposition:{scannedFileCount:0,truncated:!1,items:[],error:null}}}function Fb(e,t){const n=e.git.repoRoot??t.repoRoot??null;return{...e,workspaceId:t.id,name:t.name,path:t.path,git:{...e.git,isRepository:e.git.isRepository||!!n,repoRoot:n}}}function $b(e,t){var o,a,c,u;const n=((o=t.status)==null?void 0:o.snapshot.enabled)!==!1,r=n?((a=t.status)==null?void 0:a.snapshot.repoRoot)??e.git.repoRoot:e.git.repoRoot,i=n?((c=t.status)==null?void 0:c.snapshot.branch)??((u=t.branches)==null?void 0:u.currentBranch)??e.git.currentBranch??null:e.git.currentBranch??null;return{...e,git:{...e.git,isRepository:n&&(e.git.isRepository||!!r),repoRoot:r,currentBranch:i,error:null}}}function zb({count:e,className:t="workbench-skeleton-lines"}){return s.jsx("div",{className:t,"aria-hidden":"true",children:Array.from({length:e},(n,r)=>s.jsx("span",{className:"skeleton-line"},r))})}function qR(){return s.jsx("div",{className:"workbench-nav-loading","aria-hidden":"true",children:Array.from({length:3},(e,t)=>s.jsxs("section",{className:"workbench-skeleton-card",children:[s.jsxs("div",{className:"workbench-skeleton-heading",children:[s.jsx("span",{className:"skeleton-line short"}),s.jsx("span",{className:"skeleton-line tiny"})]}),s.jsx("div",{className:"workbench-skeleton-list",children:Array.from({length:3},(n,r)=>s.jsxs("div",{className:"workbench-skeleton-session",children:[s.jsx("span",{className:"workbench-skeleton-dot"}),s.jsx(zb,{count:2,className:"workbench-skeleton-lines compact"})]},r))})]},t))})}function ha(){return s.jsx("section",{className:"workbench-info-skeleton","aria-hidden":"true",children:Array.from({length:4},(e,t)=>s.jsxs("article",{className:"workbench-info-skeleton-card",children:[s.jsx("span",{className:"skeleton-line short"}),s.jsx(zb,{count:3})]},t))})}function GR({side:e,collapsed:t}){const n=e==="left"?8.5:15.5,r=e==="left"?t?"12 9 15 12 12 15":"15 9 12 12 15 15":t?"12 9 9 12 12 15":"9 9 12 12 9 15";return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("line",{x1:n,y1:"4",x2:n,y2:"20"}),s.jsx("polyline",{points:r})]})}function ef({ariaLabel:e,side:t,collapsed:n,className:r="panel-icon-button",onClick:i}){return s.jsx("button",{className:r,type:"button","aria-label":e,title:e,onClick:i,children:s.jsx(GR,{side:t,collapsed:n})})}function ei({expanded:e}){return s.jsx("svg",{className:e?"workbench-chevron":"workbench-chevron collapsed",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})}function VR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function KR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"}),s.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),s.jsx("line",{x1:"8",y1:"14",x2:"12",y2:"14"}),s.jsx("circle",{cx:"17.5",cy:"15.5",r:"2.5"})]})}function YR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M7.5 10.2a4.5 4.5 0 1 1 9 0v3.1c0 .8.3 1.6.9 2.2l.8.8H5.8l.8-.8c.6-.6.9-1.4.9-2.2z",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M10 18.5a2 2 0 0 0 4 0",strokeLinecap:"round"})]})}function Hb(e){return s.jsx("div",{className:"workbench-notification-anchor",children:s.jsxs("button",{type:"button",className:e.collapsed?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.globalNotificationsAction"),title:l("shell.globalNotificationsAction"),"aria-expanded":e.open,onClick:e.onToggle,children:[s.jsx(YR,{}),e.unreadCount>0?s.jsx("span",{className:"workbench-notification-badge","aria-label":l("shell.globalNotificationsUnreadAria",{count:String(e.unreadCount)}),children:e.unreadCount>99?"99+":e.unreadCount}):null]})})}function XR(e){const[t,n]=f.useState("notifications");f.useEffect(()=>{e.open&&n("notifications")},[e.open]);const r=f.useMemo(()=>e.notifications.filter(i=>e.showArchivedNotifications||!e.archivedNotificationIds.has(i.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return s.jsxs(Et,{open:e.open,title:l("shell.globalNotificationsPanelTitle"),description:l("shell.globalNotificationsPanelDescription"),className:"workbench-notification-modal-card workspace-inbox-modal-card",showCloseButton:!1,onClose:e.onClose,children:[s.jsxs("div",{className:"workbench-notification-tabs",role:"tablist","aria-label":l("shell.globalNotificationsPanelTitle"),children:[s.jsx("button",{type:"button",className:t==="notifications"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="notifications",onClick:()=>n("notifications"),children:l("shell.globalNotificationsAction")}),s.jsx("button",{type:"button",className:t==="inbox"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="inbox",onClick:()=>n("inbox"),children:l("shell.butlerInboxAction")})]}),s.jsx("div",{className:"workbench-notification-content","data-tab":t,children:t==="notifications"?s.jsxs("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.globalNotificationsAction"),children:[s.jsx("div",{className:"workbench-notification-toolbar",children:s.jsxs("label",{className:"workbench-notification-filter",children:[s.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:i=>e.onToggleShowArchivedNotifications(i.target.checked)}),s.jsx("span",{children:l("shell.globalNotificationsShowArchived")})]})}),r.length>0?s.jsx("div",{className:"workbench-notification-list",children:r.map(i=>{const o=e.archivedNotificationIds.has(i.id);return s.jsxs("article",{className:"workbench-notification-item","data-archived":o,children:[s.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(i)},children:[s.jsx("span",{className:"workbench-notification-item-kind",children:nR(i.kind)}),s.jsx("strong",{children:i.title}),s.jsx("p",{children:i.body})]}),s.jsxs("div",{className:"workbench-notification-item-side",children:[s.jsx("time",{children:lR(i.createdAt)}),s.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(o){e.onUnarchiveNotification(i.id);return}e.onArchiveNotification(i.id)},children:o?l("shell.globalNotificationsRemoveArchiveAction"):l("shell.globalNotificationsArchiveAction")})]})]},i.id)})}):s.jsx("p",{className:"workbench-notification-empty",children:l("shell.globalNotificationsEmpty")})]}):s.jsx("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.butlerInboxAction"),children:s.jsx(db,{active:e.open&&t==="inbox",preferredWorkspaceId:e.preferredWorkspaceId,preferredSessionId:e.preferredSessionId})})}),s.jsx("div",{className:"workbench-modal-actions workbench-notification-footer-actions",children:s.jsx("button",{type:"button",className:"secondary-button",onClick:e.onClose,children:l("common.close")})})]})}function JR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function QR(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("circle",{cx:"11",cy:"11",r:"7"}),s.jsx("line",{x1:"20",y1:"20",x2:"16.65",y2:"16.65"})]})}function ZR(){return s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function eA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("path",{d:"M7 9l3 3-3 3"}),s.jsx("path",{d:"M13 15h4"})]})}function tA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"3"}),s.jsx("circle",{cx:"9",cy:"11",r:"1"}),s.jsx("circle",{cx:"15",cy:"11",r:"1"}),s.jsx("path",{d:"M8 15h8"}),s.jsx("path",{d:"M12 5V3"})]})}function nA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M12 4.5 13.6 8l3.9.4-2.9 2.7.8 3.9L12 13.2 8.6 15l.8-3.9-2.9-2.7L10.4 8 12 4.5Z"}),s.jsx("path",{d:"m18.5 4.5.5 1.3 1.3.5-1.3.5-.5 1.3-.5-1.3-1.3-.5 1.3-.5.5-1.3Z"})]})}function Ub(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),s.jsx("polyline",{points:"14 9 11 12 14 15"})]})}function rA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"18",cy:"6",r:"3"}),s.jsx("circle",{cx:"6",cy:"6",r:"3"}),s.jsx("circle",{cx:"18",cy:"18",r:"3"}),s.jsx("path",{d:"M6 9v6a3 3 0 0 0 3 3h3"}),s.jsx("line",{x1:"18",y1:"9",x2:"18",y2:"15"})]})}function sA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function iA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"5",width:"6",height:"6",rx:"1.5"}),s.jsx("rect",{x:"14",y:"5",width:"6",height:"6",rx:"1.5"}),s.jsx("rect",{x:"4",y:"13",width:"6",height:"6",rx:"1.5"}),s.jsx("path",{d:"M14 16l2 2 4-4"})]})}function oA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"6",width:"10",height:"12",rx:"2"}),s.jsx("path",{d:"M10 12h8"}),s.jsx("path",{d:"M15 8l4 4-4 4"})]})}function aA({selected:e}){return e?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"}),s.jsx("path",{d:"M8 12.5l2.8 2.8L16.5 9.5"})]}):s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"})})}function qb({active:e,className:t}){return e?s.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})}):s.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:s.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})})}function lA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 7h18"}),s.jsx("path",{d:"M5 7l1 12h12l1-12"}),s.jsx("path",{d:"M9 11h6"}),s.jsx("path",{d:"M8 4h8l1 3H7l1-3z"})]})}function cA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function uA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M12 4v10"}),s.jsx("path",{d:"M8.5 7.5L12 4l3.5 3.5"}),s.jsx("path",{d:"M5 14v4a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-4"})]})}function dA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M8 6V4h8v2"}),s.jsx("path",{d:"M6 6l1 14h10l1-14"}),s.jsx("path",{d:"M10 11v5"}),s.jsx("path",{d:"M14 11v5"})]})}function hA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),s.jsx("path",{d:"M9 13h6"})]})}function pA(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M9.7 9.4a2.5 2.5 0 1 1 4.1 2c-.8.7-1.8 1.2-1.8 2.6",strokeLinecap:"round"}),s.jsx("circle",{cx:"12",cy:"17.2",r:"1",fill:"currentColor",stroke:"none"})]})}function fA({open:e,mode:t,keyword:n,codeWorkspaceId:r,codeResults:i,codeLoading:o,codeError:a,workspaceOptions:c,sessionResults:u,onClose:d,onModeChange:h,onKeywordChange:p,onCodeWorkspaceChange:m,onCodeSearch:g,onOpenSession:x}){const S=n.trim().length>0&&r.trim().length>0;return s.jsx(Et,{open:e,title:l("shell.searchModalTitle"),description:l("shell.searchModalDescription"),onClose:d,children:s.jsxs("div",{className:"workbench-search-modal",children:[s.jsxs("div",{className:"workbench-search-mode-switch",role:"tablist","aria-label":l("shell.searchModeLabel"),children:[s.jsx("button",{type:"button",className:t==="sessions"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="sessions",onClick:()=>h("sessions"),children:l("shell.searchModeSessions")}),s.jsx("button",{type:"button",className:t==="code"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="code",onClick:()=>h("code"),children:l("shell.searchModeCode")})]}),t==="sessions"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchKeywordLabel")}),s.jsx("input",{type:"text",value:n,placeholder:l("shell.searchSessionPlaceholder"),autoFocus:!0,onChange:C=>p(C.target.value)})]}),s.jsx("div",{className:"workbench-search-results",children:n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionHint")}):u.length>0?u.map(C=>{const y=Vu(C.session.title,l("common.unknown"));return s.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>x(C.session.sessionId),children:[s.jsx("span",{className:"workbench-search-result-title",title:y.fullTitle,children:y.displayTitle}),s.jsxs("span",{className:"workbench-search-result-meta",children:[C.workspace.name," · ",Za(C.session.provider,"full")]})]},C.session.sessionId)}):s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionEmpty")})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchWorkspaceLabel")}),s.jsx("select",{value:r,onChange:C=>m(C.target.value),children:c.map(C=>s.jsx("option",{value:C.id,children:C.name},C.id))})]}),s.jsxs("form",{className:"workbench-search-code-form",onSubmit:C=>{C.preventDefault(),g()},children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:l("shell.searchKeywordLabel")}),s.jsx("input",{type:"text",value:n,placeholder:l("shell.searchCodePlaceholder"),autoFocus:!0,onChange:C=>p(C.target.value)})]}),s.jsx("button",{type:"submit",className:"primary-button",disabled:!S||o,children:o?l("common.loading"):l("shell.searchSubmit")})]}),s.jsxs("div",{className:"workbench-search-results",children:[a?s.jsx("p",{className:"status-text","data-tone":"error",children:a}):null,!a&&n.trim().length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeHint")}):null,!a&&n.trim().length>0&&!o&&i.length===0?s.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeEmpty")}):null,i.map(C=>s.jsxs("div",{className:"workbench-search-result-item static",children:[s.jsx("span",{className:"workbench-search-result-title",children:C.name}),s.jsx("span",{className:"workbench-search-result-meta",children:C.path})]},`${C.path}-${C.kind}`))]})]})]})})}const mA=`
|
|
72
72
|
html,
|
|
73
73
|
body {
|
|
74
74
|
width: 100% !important;
|